/* Check Portal — Frappe-desk inspired UI (no external assets; CSP: style-src 'self') */
:root {
  --brand: #171717;
  --brand-ink: #ffffff;
  --gray-50: #f8f8f8;
  --gray-100: #f3f3f3;
  --gray-200: #ededed;
  --gray-300: #e2e2e2;
  --gray-400: #c7c7c7;
  --gray-500: #999999;
  --gray-600: #7c7c7c;
  --gray-700: #525252;
  --gray-800: #383838;
  --gray-900: #171717;
  --green-bg: #e4f5e9; --green-fg: #16794c;
  --red-bg: #ffe7e7;   --red-fg: #cc2929;
  --orange-bg: #fff1e7; --orange-fg: #bd3e0c;
  --blue-bg: #e6f4ff;  --blue-fg: #007be0;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.06);
  --shadow-lg: 0 10px 30px rgba(0,0,0,.12), 0 2px 6px rgba(0,0,0,.06);
  --navbar-h: 48px;
  --sidebar-w: 232px;
  --font: "Inter", "InterVariable", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font); font-size: 13px; line-height: 1.5; color: var(--gray-900);
  background: #fff; -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; }
.hidden { display: none !important; }
.muted { color: var(--gray-600); }
.small { font-size: 12px; }
.mono { direction: ltr; unicode-bidi: isolate; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; }
.icon { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.icon-lg { width: 20px; height: 20px; }

/* ------------------------------------------------------------------ navbar */
.navbar {
  position: sticky; top: 0; z-index: 30; height: var(--navbar-h);
  display: flex; align-items: center; gap: 12px; padding: 0 16px;
  background: #fff; border-bottom: 1px solid var(--gray-200);
}
.navbar .brand { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; min-width: 0; }
.navbar .brand span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-logo { width: 26px; height: 26px; border-radius: 6px; object-fit: contain; flex: none; }
.brand-mark {
  width: 26px; height: 26px; border-radius: 6px; flex: none; display: grid; place-items: center;
  background: var(--brand); color: var(--brand-ink); font-size: 12px; font-weight: 700;
}
.navbar .spacer { flex: 1; }
.awesomebar { position: relative; width: min(420px, 40vw); }
.awesomebar input {
  width: 100%; height: 30px; padding-block: 0; padding-inline: 32px 10px; border: 0; border-radius: var(--radius);
  background: var(--gray-100); outline: none;
}
.awesomebar input:focus { background: #fff; box-shadow: 0 0 0 1px var(--gray-300), 0 0 0 3px var(--gray-100); }
.awesomebar .icon { position: absolute; inset-inline-start: 10px; top: 7px; color: var(--gray-600); }
.awesomebar .results {
  position: absolute; top: 36px; inset-inline: 0; background: #fff; border-radius: var(--radius);
  box-shadow: var(--shadow-lg); padding: 6px; max-height: 320px; overflow: auto;
}
.awesomebar .results a { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 6px; }
.awesomebar .results a.active, .awesomebar .results a:hover { background: var(--gray-100); }
.icon-btn {
  display: inline-grid; place-items: center; width: 30px; height: 30px; border: 0; border-radius: var(--radius);
  background: transparent; cursor: pointer; color: var(--gray-700);
}
.icon-btn:hover { background: var(--gray-100); }
.avatar {
  width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--gray-200); color: var(--gray-800); font-size: 11px; font-weight: 600; border: 0; cursor: pointer;
}
.avatar.sm { width: 22px; height: 22px; font-size: 10px; cursor: default; }
.menu-toggle { display: none; }

/* --------------------------------------------------------------- dropdown */
.dropdown { position: relative; }
.dropdown-menu {
  position: absolute; inset-inline-end: 0; top: 36px; min-width: 200px; z-index: 40; background: #fff;
  border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 6px;
}
.dropdown-menu .head { padding: 6px 8px 8px; border-bottom: 1px solid var(--gray-200); margin-bottom: 4px; }
.dropdown-menu button, .dropdown-menu a {
  display: flex; width: 100%; align-items: center; gap: 8px; padding: 6px 8px; border: 0; background: none;
  border-radius: 6px; cursor: pointer; text-align: start;
}
.dropdown-menu button:hover, .dropdown-menu a:hover { background: var(--gray-100); }

/* ------------------------------------------------------------------ layout */
.layout { display: flex; min-height: calc(100vh - var(--navbar-h)); }
.sidebar {
  width: var(--sidebar-w); flex: none; padding: 12px 8px; position: sticky; top: var(--navbar-h);
  height: calc(100vh - var(--navbar-h)); overflow-y: auto; background: var(--gray-50);
  border-inline-end: 1px solid var(--gray-200);
}
.sidebar .ws-card {
  display: flex; align-items: center; gap: 10px; padding: 8px; margin-bottom: 8px; border-radius: var(--radius);
}
.sidebar .ws-card .name { font-weight: 600; line-height: 1.2; }
.sidebar .section { margin-top: 14px; }
.sidebar .section-title {
  padding: 0 10px 4px; font-size: 11px; font-weight: 500; color: var(--gray-500); text-transform: uppercase;
  letter-spacing: .04em;
}
.sidebar a.item {
  display: flex; align-items: center; gap: 10px; height: 30px; padding: 0 10px; margin: 1px 0;
  border-radius: var(--radius); color: var(--gray-800);
}
.sidebar a.item:hover { background: var(--gray-200); }
.sidebar a.item.active { background: #fff; box-shadow: var(--shadow-sm), 0 0 0 1px var(--gray-200); font-weight: 500; }
.sidebar a.item.active .icon { color: var(--brand); }
.main { flex: 1; min-width: 0; padding: 0 28px 48px; }

/* -------------------------------------------------------------- page head */
.page-head {
  position: sticky; top: var(--navbar-h); z-index: 20; background: #fff;
  display: flex; align-items: center; gap: 12px; min-height: 64px; padding: 14px 0;
}
.page-head h1 { font-size: 20px; letter-spacing: -.01em; }
.page-head .title { display: flex; align-items: center; gap: 10px; min-width: 0; }
.page-head .actions { margin-inline-start: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.breadcrumb { display: flex; align-items: center; gap: 6px; color: var(--gray-600); font-size: 13px; }
.breadcrumb a:hover { color: var(--gray-900); }

/* ---------------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 30px; padding: 0 12px;
  border: 0; border-radius: var(--radius); background: var(--gray-100); color: var(--gray-800);
  font-weight: 500; cursor: pointer; white-space: nowrap; transition: background .12s;
}
.btn:hover { background: var(--gray-200); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--brand); color: var(--brand-ink); }
.btn-primary:hover { background: var(--brand); filter: brightness(1.15); }
.btn-danger { background: var(--red-bg); color: var(--red-fg); }
.btn-danger:hover { background: #ffd6d6; }
.btn-ghost { background: transparent; }
.btn-lg { height: 36px; padding: 0 16px; font-size: 14px; }
.btn-block { width: 100%; }

/* ----------------------------------------------------------------- forms */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label { font-size: 12px; color: var(--gray-600); }
.field .help { font-size: 12px; color: var(--gray-500); }
.input, select.input, textarea.input {
  height: 30px; padding: 0 10px; border: 1px solid transparent; border-radius: var(--radius);
  background: var(--gray-100); outline: none; width: 100%; transition: background .12s, box-shadow .12s;
}
textarea.input { height: auto; min-height: 72px; padding: 8px 10px; resize: vertical; }
.input:focus { background: #fff; border-color: var(--gray-300); box-shadow: 0 0 0 3px var(--gray-100); }
.input.lg { height: 40px; font-size: 15px; }
.input[type=color] { padding: 2px; width: 56px; cursor: pointer; }
.input.invalid { border-color: var(--red-fg); }
.check-row { display: flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.check-row input { width: 14px; height: 14px; accent-color: var(--brand); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 24px; }
.form-grid .full { grid-column: 1 / -1; }
.form-section { padding: 20px 0; border-bottom: 1px solid var(--gray-200); }
.form-section:last-child { border-bottom: 0; }
.form-section > h3 { font-size: 14px; margin-bottom: 14px; }
.inline { display: flex; gap: 8px; align-items: center; }

/* ----------------------------------------------------------------- cards */
.card { border: 1px solid var(--gray-200); border-radius: var(--radius-lg); background: #fff; }
.card-pad { padding: 16px 18px; }
.card-head { display: flex; align-items: center; gap: 8px; padding: 12px 18px; border-bottom: 1px solid var(--gray-200); }
.card-head h3 { font-size: 14px; }
.card-head .right { margin-inline-start: auto; }
.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.number-card { padding: 14px 16px; }
.number-card .label { color: var(--gray-600); display: flex; align-items: center; gap: 6px; }
.number-card .value { font-size: 22px; font-weight: 600; margin-top: 4px; letter-spacing: -.01em; }
.number-card .sub { font-size: 12px; color: var(--gray-500); }
.progress { height: 6px; background: var(--gray-100); border-radius: 99px; overflow: hidden; margin-top: 8px; }
.progress > div { height: 100%; background: var(--brand); border-radius: 99px; }
.shortcut {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px; border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg); transition: background .12s;
}
.shortcut:hover { background: var(--gray-50); }
.shortcut .icon-wrap { width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; background: var(--gray-100); }
.section-label { font-size: 15px; font-weight: 600; margin: 24px 0 12px; }

/* -------------------------------------------------------------- indicator */
.pill {
  display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 8px; border-radius: 99px;
  font-size: 12px; font-weight: 500; white-space: nowrap; background: var(--gray-100); color: var(--gray-700);
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.success { background: var(--green-bg); color: var(--green-fg); }
.pill.danger { background: var(--red-bg); color: var(--red-fg); }
.pill.warning { background: var(--orange-bg); color: var(--orange-fg); }
.pill.info { background: var(--blue-bg); color: var(--blue-fg); }
.pill.plain::before { display: none; }

/* -------------------------------------------------------------- list view */
.list-toolbar { display: flex; gap: 8px; align-items: center; padding: 0 0 12px; flex-wrap: wrap; }
.list-toolbar .input { width: 200px; }
.list-toolbar .count { margin-inline-start: auto; color: var(--gray-600); font-size: 12px; }
.list { border: 1px solid var(--gray-200); border-radius: var(--radius-lg); overflow: hidden; }
.list table { width: 100%; border-collapse: collapse; }
.list th {
  text-align: start; font-weight: 500; font-size: 12px; color: var(--gray-600); background: var(--gray-50);
  padding: 8px 14px; border-bottom: 1px solid var(--gray-200); white-space: nowrap;
}
.list td { padding: 9px 14px; border-bottom: 1px solid var(--gray-200); vertical-align: middle; }
.list tr:last-child td { border-bottom: 0; }
.list tbody tr.clickable { cursor: pointer; }
.list tbody tr:hover td { background: var(--gray-50); }
.list .primary-cell { display: flex; align-items: center; gap: 10px; font-weight: 500; }
.list .sub { color: var(--gray-500); font-weight: 400; font-size: 12px; }
.list-footer { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; }
.empty { padding: 48px 16px; text-align: center; color: var(--gray-600); }
.empty .icon { width: 36px; height: 36px; color: var(--gray-400); margin-bottom: 8px; stroke-width: 1.2; }
.table-wrap { overflow-x: auto; }

/* ---------------------------------------------------------------- form view */
.doc-layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 28px; }
.doc-side { display: flex; flex-direction: column; gap: 14px; padding-top: 18px; }
.doc-side .meta { font-size: 12px; color: var(--gray-600); display: flex; flex-direction: column; gap: 4px; }
.doc-side .side-actions { display: flex; flex-direction: column; gap: 4px; }
.doc-side .side-actions .btn { justify-content: flex-start; }
.doc-body { border: 1px solid var(--gray-200); border-radius: var(--radius-lg); padding: 0 22px; }

/* ----------------------------------------------------------------- check */
.check-hero { padding: 26px; }
.check-hero h2 { font-size: 16px; }
.check-form { display: flex; gap: 10px; margin-top: 16px; }
.check-form .input { flex: 1; }
.result-box {
  margin-top: 18px; border-radius: var(--radius-lg); padding: 22px; display: flex; align-items: center; gap: 16px;
  background: var(--gray-50); border: 1px solid var(--gray-200);
}
.result-box .badge { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; flex: none; }
.result-box .badge .icon { width: 22px; height: 22px; stroke-width: 2.2; }
.result-box.success { background: var(--green-bg); border-color: #c7ead3; }
.result-box.success .badge { background: var(--green-fg); color: #fff; }
.result-box.danger { background: var(--red-bg); border-color: #ffd0d0; }
.result-box.danger .badge { background: var(--red-fg); color: #fff; }
.result-box.warning { background: var(--orange-bg); border-color: #ffdcc4; }
.result-box.warning .badge { background: var(--orange-fg); color: #fff; }
.result-box.neutral .badge { background: var(--gray-700); color: #fff; }
.result-box .big { font-size: 18px; font-weight: 600; }
.spinner {
  width: 22px; height: 22px; border-radius: 50%; border: 2.5px solid var(--gray-300); border-top-color: var(--brand);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* -------------------------------------------------------- matrix / labels */
.perm-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 20px; }
.perm-grid .check-row { align-items: flex-start; }
.perm-grid .key { font-size: 11px; color: var(--gray-500); }

/* ------------------------------------------------------------ modal/toast */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 60; display: grid; place-items: start center;
  padding: 10vh 16px 16px; overflow-y: auto;
}
.modal { width: min(560px, 100%); background: #fff; border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); }
.modal-head { display: flex; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--gray-200); }
.modal-head h3 { font-size: 15px; }
.modal-head .icon-btn { margin-inline-start: auto; }
.modal-body { padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--gray-200); }
.toasts { position: fixed; inset-inline-end: 16px; bottom: 16px; z-index: 80; display: flex; flex-direction: column; gap: 8px; }
.toast {
  min-width: 240px; max-width: 360px; padding: 10px 14px; border-radius: var(--radius); background: var(--gray-900);
  color: #fff; box-shadow: var(--shadow-lg); display: flex; align-items: center; gap: 8px; animation: rise .18s ease-out;
}
.toast.error { background: var(--red-fg); }
@keyframes rise { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
.secret-box {
  display: flex; gap: 8px; align-items: center; padding: 10px; border-radius: var(--radius); background: var(--gray-100);
  word-break: break-all;
}
.alert { padding: 10px 12px; border-radius: var(--radius); background: var(--orange-bg); color: var(--orange-fg); }
.alert.info { background: var(--blue-bg); color: var(--blue-fg); }
.alert.error { background: var(--red-bg); color: var(--red-fg); }

/* ------------------------------------------------------------------ login */
.login-page { min-height: 100vh; display: grid; place-items: center; background: var(--gray-50); padding: 24px 16px; }
.login-card { width: min(380px, 100%); }
.login-card .logo-wrap { display: flex; flex-direction: column; align-items: center; gap: 12px; margin-bottom: 22px; }
.login-card .logo-wrap img { max-width: 160px; max-height: 64px; object-fit: contain; }
.brand-mark.xl { width: 52px; height: 52px; border-radius: 14px; font-size: 22px; }
.login-card h1 { font-size: 18px; text-align: center; }
.login-card form { display: flex; flex-direction: column; gap: 14px; padding: 22px; }
.login-foot { text-align: center; margin-top: 16px; font-size: 12px; color: var(--gray-500); }

/* ------------------------------------------------------------- responsive */
@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-main { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .menu-toggle { display: inline-grid; }
  .sidebar {
    position: fixed; inset-inline-start: 0; top: var(--navbar-h); z-index: 50; transform: translateX(-100%);
    transition: transform .18s ease; box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: none; }
  .main { padding: 0 16px 40px; }
  .awesomebar { width: auto; flex: 1; }
  .navbar .brand span { display: none; }
  .doc-layout { grid-template-columns: 1fr; }
  .doc-side { padding-top: 0; }
  .form-grid, .grid-3, .grid-2, .perm-grid { grid-template-columns: 1fr; }
  .page-head { position: static; flex-wrap: wrap; }
  .check-form { flex-direction: column; }
}
@media (max-width: 520px) {
  .grid-4 { grid-template-columns: 1fr 1fr; }
  .list-toolbar .input { width: 100%; }
}

/* ------------------------------------------------------------------- RTL / Arabic */
html[lang="ar"] body, html[lang="ar"] button, html[lang="ar"] input, html[lang="ar"] select, html[lang="ar"] textarea {
  font-family: "Segoe UI", Tahoma, "Noto Sans Arabic", "Geeza Pro", Arial, sans-serif;
}
html[lang="ar"] .section-title { text-transform: none; letter-spacing: 0; font-size: 12px; }
[dir="rtl"] .flip-rtl { transform: scaleX(-1); }
[dir="rtl"] .num { direction: ltr; unicode-bidi: isolate; }
.lang-switch {
  display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border: 0; border-radius: var(--radius);
  background: transparent; color: var(--gray-700); cursor: pointer; font-size: 12px; font-weight: 500;
}
.lang-switch:hover { background: var(--gray-100); }
.login-lang { position: fixed; top: 14px; inset-inline-end: 16px; }
@media (max-width: 860px) {
  [dir="rtl"] .sidebar { transform: translateX(100%); }
  [dir="rtl"] .sidebar.open { transform: none; }
}
