/* ============================================================
   مسار — design system (RTL-first, teal/sand identity)
   Adapted from engines/design-system + Tawreed patterns.
   ============================================================ */
:root {
  --brand: #0f766e;
  --brand-2: #115e59;
  --accent: #c9973f;               /* sand */
  --brand-soft: rgba(15, 118, 110, 0.11);
  --brand-ring: rgba(15, 118, 110, 0.32);
  --accent-soft: rgba(201, 151, 63, 0.14);

  --ok: #0f9d6e;      --ok-soft: rgba(15, 157, 110, 0.13);
  --warn: #d5860a;    --warn-soft: rgba(213, 134, 10, 0.14);
  --bad: #e5484d;     --bad-soft: rgba(229, 72, 77, 0.13);
  --info: #3b82f6;    --info-soft: rgba(59, 130, 246, 0.13);

  --bg: #f5f7f6;
  --surface: #ffffff;
  --surface-2: #eef2f1;
  --surface-3: #e4eae8;
  --border: #e2e8e6;
  --border-strong: #cfd9d6;
  --ink: #101816;
  --muted: #56645f;
  --faint: #8a978f;

  --shadow-sm: 0 1px 2px rgba(16, 24, 22, 0.06), 0 1px 3px rgba(16, 24, 22, 0.04);
  --shadow-md: 0 4px 14px rgba(16, 24, 22, 0.07), 0 2px 6px rgba(16, 24, 22, 0.05);
  --shadow-lg: 0 20px 50px rgba(16, 24, 22, 0.16), 0 8px 20px rgba(16, 24, 22, 0.10);

  --r-sm: 8px; --r: 12px; --r-lg: 16px; --r-xl: 22px;
  --sb: 250px;
  --font: "Segoe UI", Tahoma, "Noto Kufi Arabic", "Noto Sans Arabic", "Helvetica Neue", Arial, sans-serif;
  --mono: "Cascadia Mono", "SF Mono", ui-monospace, Menlo, Consolas, monospace;
}
:root[data-theme="dark"] {
  --brand: #2dd4bf;
  --brand-2: #14b8a6;
  --accent: #e2b563;
  --brand-soft: rgba(45, 212, 191, 0.13);
  --brand-ring: rgba(45, 212, 191, 0.35);
  --accent-soft: rgba(226, 181, 99, 0.14);
  --ok: #34d399;      --ok-soft: rgba(52, 211, 153, 0.14);
  --warn: #f5b042;    --warn-soft: rgba(245, 176, 66, 0.15);
  --bad: #f87171;     --bad-soft: rgba(248, 113, 113, 0.15);
  --info: #60a5fa;    --info-soft: rgba(96, 165, 250, 0.15);
  --bg: #0a0f0e;
  --surface: #111917;
  --surface-2: #182220;
  --surface-3: #202b29;
  --border: #24302d;
  --border-strong: #32403c;
  --ink: #ecf2f0;
  --muted: #9aa8a2;
  --faint: #6b7975;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.4);
  --shadow-md: 0 6px 20px rgba(0,0,0,0.45);
  --shadow-lg: 0 24px 60px rgba(0,0,0,0.6), 0 8px 24px rgba(0,0,0,0.5);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; font-family: var(--font);
  background: var(--bg); color: var(--ink);
  font-size: 14px; line-height: 1.65;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
  transition: background .3s ease, color .3s ease;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }
.hidden { display: none !important; }
.tnum { font-variant-numeric: tabular-nums; }
::selection { background: var(--brand-ring); }
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }

/* ============================================================ Layout (RTL: sidebar on the right via grid order) */
.app { display: grid; grid-template-columns: var(--sb) 1fr; min-height: 100vh; }

.sidebar {
  position: sticky; top: 0; height: 100vh;
  background: var(--surface); border-inline-end: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 20px 14px; gap: 6px; z-index: 40;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 6px 8px 18px; }
.brand-mark { filter: drop-shadow(0 6px 14px var(--brand-ring)); }
.brand-name { font-weight: 800; font-size: 20px; letter-spacing: -0.01em; }
.brand-sub { font-size: 11.5px; color: var(--faint); }

.nav { display: flex; flex-direction: column; gap: 2px; margin-top: 6px; overflow-y: auto; }
.nav-label { font-size: 10.5px; font-weight: 700; letter-spacing: .06em; color: var(--faint); padding: 14px 12px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: var(--r-sm);
  color: var(--muted); font-weight: 550; font-size: 13.5px; cursor: pointer;
  border: 1px solid transparent; transition: all .16s ease; position: relative; background: none; text-align: start; width: 100%;
}
.nav-item:hover { background: var(--surface-2); color: var(--ink); }
.nav-item.active { background: var(--brand-soft); color: var(--brand); border-color: var(--brand-ring); font-weight: 700; }
.nav-item.active .ic { color: var(--brand); }
.nav-item .ic { width: 18px; height: 18px; color: var(--faint); flex: none; }
.nav-item .badge {
  margin-inline-start: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px;
  background: var(--bad); color: #fff; font-size: 11px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
}
.sidebar-foot { margin-top: auto; }
.org-card { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r); padding: 11px 13px; }
.org-name { font-weight: 700; font-size: 12.5px; }
.org-meta { font-size: 11.5px; color: var(--faint); margin-top: 2px; }

.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 12px;
  padding: 12px 24px; background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(180%) blur(12px); border-bottom: 1px solid var(--border);
}
.topbar-title { font-size: 17px; font-weight: 750; }
.topbar-spacer { flex: 1; }
.menu-btn { display: none; }

.icon-btn { width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface);
  color: var(--muted); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; transition: all .16s; flex: none; }
.icon-btn:hover { background: var(--surface-2); color: var(--ink); border-color: var(--border-strong); }
.icon-btn:focus-visible, .btn:focus-visible, .nav-item:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.icon-btn::before { content: ""; width: 18px; height: 18px; background: currentColor;
  -webkit-mask: var(--mi, none) center/contain no-repeat; mask: var(--mi, none) center/contain no-repeat; }
#themeBtn::before { --mi: var(--ic-moon); }
:root[data-theme="dark"] #themeBtn::before { --mi: var(--ic-sun); }
#menuBtn::before { --mi: var(--ic-menu); }
#bellBtn::before { --mi: var(--ic-bell); }
#tourBtn::before { --mi: var(--ic-help); }

.bell-wrap { position: relative; }
.bell-badge { position: absolute; top: -5px; inset-inline-start: -5px; min-width: 18px; height: 18px; border-radius: 999px;
  background: var(--bad); color: #fff; font-size: 10.5px; font-weight: 800; display: grid; place-items: center; padding: 0 4px; pointer-events: none; }
.bell-panel { position: absolute; top: 46px; inset-inline-start: 0; width: min(400px, 92vw); max-height: 480px; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-lg); z-index: 70; }
.bell-head { display: flex; justify-content: space-between; align-items: center; padding: 13px 16px; border-bottom: 1px solid var(--border); font-weight: 750; font-size: 13.5px; position: sticky; top: 0; background: var(--surface); }
.bell-item { padding: 12px 16px; border-bottom: 1px solid var(--border); cursor: pointer; transition: background .13s; }
.bell-item:hover { background: var(--surface-2); }
.bell-item.unread { background: var(--brand-soft); }
.bell-item .bi-t { font-weight: 650; font-size: 13px; }
.bell-item .bi-b { font-size: 12px; color: var(--muted); margin-top: 2px; white-space: pre-line; }
.bell-item .bi-m { font-size: 11px; color: var(--faint); margin-top: 4px; }

.persona { display: flex; align-items: center; gap: 10px; }
.avatar { width: 38px; height: 38px; border-radius: 11px; background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff; font-weight: 700; font-size: 13px; display: grid; place-items: center; box-shadow: var(--shadow-sm); flex: none; }
.persona-name { font-weight: 700; font-size: 13px; }
.persona-role { font-size: 11.5px; color: var(--faint); }
.logout-btn { background: none; border: none; color: var(--faint); font-size: 11.5px; cursor: pointer; padding: 0; text-align: start; }
.logout-btn:hover { color: var(--bad); }

.view { padding: 26px; max-width: 1280px; width: 100%; margin: 0 auto; animation: viewIn .34s cubic-bezier(.2,.7,.2,1); }
@keyframes viewIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ============================================================ Auth */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(1100px 500px at 85% -10%, var(--brand-soft), transparent), radial-gradient(900px 500px at 0% 110%, var(--accent-soft), transparent), var(--bg); }
.auth-box { width: min(920px, 100%); }
.auth-brand { display: flex; align-items: center; gap: 14px; justify-content: center; margin-bottom: 8px; }
.auth-brand .brand-name { font-size: 30px; }
.auth-sub { text-align: center; color: var(--muted); margin: 0 0 26px; font-size: 14px; }
.auth-grid { display: grid; grid-template-columns: 1.2fr 1fr; gap: 18px; align-items: start; }
.persona-cards { display: grid; gap: 10px; }
.persona-card { display: flex; align-items: center; gap: 13px; padding: 13px 15px; border-radius: var(--r-lg); border: 1px solid var(--border);
  background: var(--surface); cursor: pointer; transition: all .16s; text-align: start; width: 100%; box-shadow: var(--shadow-sm); }
.persona-card:hover { border-color: var(--brand-ring); transform: translateY(-1px); box-shadow: var(--shadow-md); }
.persona-card .pc-n { font-weight: 750; font-size: 14px; }
.persona-card .pc-r { font-size: 12px; color: var(--muted); }
.persona-card .pc-go { margin-inline-start: auto; color: var(--brand); font-weight: 700; font-size: 12.5px; }
.auth-form { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 20px; box-shadow: var(--shadow-sm); }
.auth-form h3 { margin: 0 0 14px; font-size: 15px; }
.auth-note { font-size: 12px; color: var(--faint); text-align: center; margin-top: 18px; }
.auth-switch { color: var(--brand); cursor: pointer; background: none; border: none; font-size: 12.5px; font-weight: 650; padding: 0; }

/* ============================================================ Common components */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { font-size: 23px; font-weight: 800; margin: 0 0 4px; }
.page-head p { color: var(--muted); margin: 0; font-size: 13.5px; max-width: 70ch; }
.grid { display: grid; gap: 16px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-sm); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 15px 18px; border-bottom: 1px solid var(--border); font-weight: 750; font-size: 13.5px; flex-wrap: wrap; }
.card-body { padding: 18px; }
.section-sub { font-size: 12px; color: var(--faint); font-weight: 500; }

.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 16px; position: relative; overflow: hidden; box-shadow: var(--shadow-sm); }
.kpi-label { font-size: 11.5px; color: var(--muted); font-weight: 600; }
.kpi-val { font-size: 26px; font-weight: 800; margin-top: 10px; line-height: 1; }
.kpi-val small { font-size: 13px; font-weight: 650; color: var(--muted); }
.kpi-sub { font-size: 12px; color: var(--faint); margin-top: 6px; }
.kpi-spark { position: absolute; bottom: 0; inset-inline: 0; height: 3px; background: linear-gradient(90deg, var(--brand), var(--accent)); opacity: .85; }
.kpi.tone-warn .kpi-spark { background: var(--warn); } .kpi.tone-bad .kpi-spark { background: var(--bad); } .kpi.tone-ok .kpi-spark { background: var(--ok); }

.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 700; padding: 3px 10px; border-radius: 999px; white-space: nowrap; }
.pill .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.neutral { color: var(--muted); background: var(--surface-2); border: 1px solid var(--border); }

.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: start; font-size: 11px; font-weight: 700; letter-spacing: .03em; color: var(--faint); padding: 10px 14px; border-bottom: 1px solid var(--border); background: var(--surface); white-space: nowrap; }
.tbl td { padding: 12px 14px; border-bottom: 1px solid var(--border); font-size: 13px; vertical-align: middle; }
.tbl tr:last-child td { border-bottom: none; }
.tbl tbody tr.rowlink { cursor: pointer; transition: background .13s; }
.tbl tbody tr.rowlink:hover { background: var(--surface-2); }
.tbl .muted { color: var(--muted); }
.tbl-wrap { overflow-x: auto; }
.ref { font-family: var(--mono); font-size: 12px; font-weight: 650; color: var(--brand); direction: ltr; unicode-bidi: isolate; }
/* one class for every LTR run inside RTL text: numbers, codes, sizes, usernames */
.ltr { direction: ltr; unicode-bidi: isolate; font-variant-numeric: tabular-nums; }

.btn { display: inline-flex; align-items: center; gap: 8px; padding: 9px 15px; border-radius: 10px; font-size: 13px; font-weight: 650;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--ink); cursor: pointer; transition: all .15s; white-space: nowrap; }
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn .ic { width: 16px; height: 16px; }
.btn-primary { background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; border-color: transparent; box-shadow: 0 4px 14px var(--brand-ring); }
:root[data-theme="dark"] .btn-primary { color: #06211d; }
.btn-primary:hover { filter: brightness(1.06); background: linear-gradient(135deg, var(--brand), var(--brand-2)); }
.btn-ok { background: var(--ok); color: #fff; border-color: transparent; }
.btn-bad { background: var(--surface); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 35%, var(--border)); }
.btn-bad:hover { background: var(--bad-soft); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn-sm { padding: 6px 11px; font-size: 12px; border-radius: 8px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; font-weight: 700; color: var(--muted); margin-bottom: 6px; }
.field .req { color: var(--bad); }
.input, select.input, textarea.input { width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--ink); font-size: 13.5px; font-family: inherit; outline: none; transition: all .15s; }
.input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
textarea.input { resize: vertical; min-height: 76px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }

.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.filters .input { width: auto; min-width: 150px; }
.filters .search-in { min-width: 220px; }
.counts-strip { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.count-chip { display: inline-flex; align-items: center; gap: 7px; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface); font-size: 12.5px; font-weight: 650; cursor: pointer; transition: all .15s; }
.count-chip:hover, .count-chip.active { border-color: var(--brand-ring); background: var(--brand-soft); color: var(--brand); }
.count-chip b { font-weight: 800; }

/* Empty & skeleton */
.empty { text-align: center; padding: 46px 20px; color: var(--muted); }
.empty .ic-wrap { width: 58px; height: 58px; border-radius: 16px; background: var(--surface-2); display: grid; place-items: center; margin: 0 auto 14px; color: var(--faint); }
.empty .ic-wrap .ic { width: 26px; height: 26px; }
.empty h3 { margin: 0 0 5px; font-size: 15px; color: var(--ink); }
.empty p { margin: 0; font-size: 13px; }
.shimmer { position: relative; overflow: hidden; background: var(--surface-2); border-radius: 7px; }
.shimmer::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--ink) 7%, transparent), transparent); animation: sh 1.3s infinite; }
@keyframes sh { 100% { transform: translateX(100%); } }
.sk { height: 12px; margin: 10px 0; } .sk.w60 { width: 60%; } .sk.w80 { width: 80%; } .sk.w40 { width: 40%; }
.sk-card { height: 90px; border-radius: var(--r-lg); margin-bottom: 12px; }

/* Timeline */
.timeline { position: relative; padding-inline-start: 22px; }
.timeline::before { content: ""; position: absolute; inset-inline-start: 7px; top: 6px; bottom: 6px; width: 2px; background: var(--border-strong); border-radius: 2px; }
.tl-item { position: relative; padding-bottom: 18px; }
.tl-item:last-child { padding-bottom: 2px; }
.tl-dot { position: absolute; inset-inline-start: -22px; top: 3px; width: 16px; height: 16px; border-radius: 50%; border: 3px solid var(--surface);
  background: var(--brand); box-shadow: 0 0 0 2px var(--border-strong); }
.tl-item.warn .tl-dot { background: var(--warn); } .tl-item.bad .tl-dot { background: var(--bad); } .tl-item.ok .tl-dot { background: var(--ok); }
.tl-t { font-size: 13px; font-weight: 650; }
.tl-t .st-arrow { color: var(--faint); font-weight: 400; }
.tl-m { font-size: 11.5px; color: var(--faint); margin-top: 2px; }
.tl-d { font-size: 12.5px; color: var(--muted); margin-top: 3px; }

/* Attachments */
.att-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
.att-card { border: 1px solid var(--border); border-radius: var(--r); background: var(--surface); padding: 13px; display: flex; gap: 11px; align-items: center; transition: all .15s; }
.att-card:hover { border-color: var(--brand-ring); box-shadow: var(--shadow-sm); }
.att-ic { width: 42px; height: 42px; border-radius: 11px; display: grid; place-items: center; font-size: 10.5px; font-weight: 800; color: #fff; flex: none; letter-spacing: .02em; }
.att-name { font-size: 12.5px; font-weight: 650; word-break: break-all; line-height: 1.35; }
.att-meta { font-size: 11px; color: var(--faint); margin-top: 3px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.att-verified { color: var(--ok); font-weight: 700; }
.att-act { display: flex; gap: 4px; margin-inline-start: auto; }

/* Dropzone */
.dropzone { border: 2px dashed var(--border-strong); border-radius: var(--r-lg); padding: 30px 20px; text-align: center; color: var(--muted);
  cursor: pointer; transition: all .18s; background: var(--surface); }
.dropzone:hover, .dropzone.drag { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); }
.dropzone .dz-big { font-weight: 750; font-size: 14px; }
.dropzone .dz-sub { font-size: 12px; margin-top: 4px; color: var(--faint); }
.upl-list { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.upl-row { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); font-size: 12.5px; }
.upl-row .u-name { font-weight: 650; word-break: break-all; }
.upl-row .u-size { color: var(--faint); font-size: 11px; }
.upl-row .u-st { margin-inline-start: auto; font-weight: 700; font-size: 11.5px; white-space: nowrap; }
.upl-row.ok { border-color: color-mix(in srgb, var(--ok) 40%, var(--border)); } .upl-row.ok .u-st { color: var(--ok); }
.upl-row.bad { border-color: color-mix(in srgb, var(--bad) 40%, var(--border)); background: var(--bad-soft); } .upl-row.bad .u-st { color: var(--bad); }
.upl-row.busy .u-st { color: var(--info); }

/* Wizard */
.wiz-steps { display: flex; align-items: center; gap: 8px; margin-bottom: 22px; flex-wrap: wrap; }
.wiz-step { display: flex; align-items: center; gap: 8px; font-size: 12.5px; font-weight: 650; color: var(--faint); }
.wiz-step .n { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; border: 2px solid var(--border-strong); font-size: 12px; font-weight: 800; background: var(--surface); }
.wiz-step.active { color: var(--brand); } .wiz-step.active .n { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); }
.wiz-step.done { color: var(--ok); } .wiz-step.done .n { border-color: var(--ok); background: var(--ok); color: #fff; }
.wiz-sep { width: 26px; height: 2px; background: var(--border-strong); border-radius: 2px; }
.type-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.type-card { border: 1.5px solid var(--border); border-radius: var(--r-lg); padding: 16px; background: var(--surface); cursor: pointer; transition: all .16s; text-align: start; }
.type-card:hover { border-color: var(--brand-ring); transform: translateY(-2px); box-shadow: var(--shadow-md); }
.type-card.sel { border-color: var(--brand); background: var(--brand-soft); }
.type-card h4 { margin: 0 0 5px; font-size: 14.5px; }
.type-card p { margin: 0; font-size: 12px; color: var(--muted); }
.wiz-foot { display: flex; justify-content: space-between; margin-top: 22px; gap: 10px; }
.review-kv { display: grid; grid-template-columns: auto 1fr; gap: 8px 18px; font-size: 13px; }
.review-kv .k { color: var(--muted); font-weight: 600; } .review-kv .v { font-weight: 650; }
.success-box { text-align: center; padding: 40px 20px; }
.success-box .ok-ring { width: 74px; height: 74px; border-radius: 50%; background: var(--ok-soft); color: var(--ok); display: grid; place-items: center; margin: 0 auto 18px; }
.success-box .ok-ring .ic { width: 34px; height: 34px; }
.success-box h2 { margin: 0 0 8px; } .success-box .num { font-family: var(--mono); font-size: 19px; color: var(--brand); font-weight: 800; direction: ltr; }

/* Completion banner */
.banner { display: flex; gap: 13px; align-items: flex-start; padding: 15px 17px; border-radius: var(--r-lg); border: 1px solid; margin-bottom: 18px; }
.banner.warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 35%, transparent); }
.banner .b-ic { width: 36px; height: 36px; border-radius: 10px; background: var(--warn); color: #fff; display: grid; place-items: center; flex: none; }
.banner .b-t { font-weight: 750; font-size: 13.5px; }
.banner .b-m { font-size: 12.5px; color: var(--muted); margin-top: 2px; }

/* Notes */
.note-item { padding: 11px 0; border-bottom: 1px dashed var(--border); }
.note-item:last-child { border-bottom: none; }
.note-a { font-size: 12px; font-weight: 750; }
.note-b { font-size: 13px; margin-top: 3px; }
.note-m { font-size: 11px; color: var(--faint); margin-top: 3px; }

/* Modal */
.modal-scrim { position: fixed; inset: 0; background: rgba(9, 14, 13, 0.55); backdrop-filter: blur(3px); z-index: 90; display: grid; place-items: center; padding: 18px; animation: fadeIn .2s; }
@keyframes fadeIn { from { opacity: 0 } }
.modal { width: min(560px, 100%); max-height: 88vh; overflow-y: auto; background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--r-xl); box-shadow: var(--shadow-lg); animation: modalIn .28s cubic-bezier(.2,.8,.2,1); }
.modal.wide { width: min(880px, 100%); }
@keyframes modalIn { from { opacity: 0; transform: translateY(14px) scale(.98); } to { opacity: 1; transform: none; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 17px 20px 13px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--bg); z-index: 2; }
.modal-head h3 { margin: 0; font-size: 16px; font-weight: 800; }
.modal-body { padding: 18px 20px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--border); position: sticky; bottom: 0; background: var(--bg); }
.preview-frame { width: 100%; height: 66vh; border: none; border-radius: var(--r); background: var(--surface-2); }
.preview-img { max-width: 100%; max-height: 66vh; display: block; margin: 0 auto; border-radius: var(--r); }

/* Toasts */
.toasts { position: fixed; bottom: 22px; inset-inline-start: 22px; display: flex; flex-direction: column; gap: 10px; z-index: 120; }
.toast { display: flex; align-items: center; gap: 11px; padding: 12px 15px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border);
  box-shadow: var(--shadow-lg); min-width: 260px; max-width: 380px; animation: toastIn .3s cubic-bezier(.2,.8,.2,1); }
.toast.out { animation: toastOut .25s forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateY(14px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(10px); } }
.toast .t-ic { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; flex: none; }
.toast.ok .t-ic { background: var(--ok-soft); color: var(--ok); } .toast.bad .t-ic { background: var(--bad-soft); color: var(--bad); }
.toast.info .t-ic { background: var(--brand-soft); color: var(--brand); }
.toast .t-ic .ic { width: 16px; height: 16px; }
.toast .t-msg { font-size: 13px; font-weight: 650; }
.toast .t-sub { font-size: 11.5px; color: var(--faint); }

/* Type builder */
.builder-sec { margin-bottom: 22px; }
.builder-sec > h3 { font-size: 14px; margin: 0 0 4px; }
.builder-sec > .hint { font-size: 12px; color: var(--faint); margin: 0 0 12px; }
.b-rows { display: flex; flex-direction: column; gap: 8px; }
.b-row { display: grid; gap: 8px; align-items: center; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.b-row.fields-row { grid-template-columns: 1.4fr 1fr auto auto auto; }
.b-row.states-row { grid-template-columns: auto 1.4fr auto auto auto auto; }
.b-row.trans-row { grid-template-columns: 1fr auto 1fr 1fr 1.2fr auto; }
.b-row .input { padding: 7px 10px; font-size: 12.5px; }
.b-row .chk { display: flex; align-items: center; gap: 5px; font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.color-dot-in { width: 34px; height: 34px; padding: 2px; border-radius: 9px; border: 1px solid var(--border-strong); background: var(--surface); cursor: pointer; }
.b-del { width: 30px; height: 30px; border-radius: 8px; border: none; background: none; color: var(--faint); cursor: pointer; display: grid; place-items: center; }
.b-del:hover { color: var(--bad); background: var(--bad-soft); }
.b-add { align-self: flex-start; }
.st-flow { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 12px 0 4px; }
.st-chip { display: inline-flex; align-items: center; gap: 7px; padding: 5px 12px; border-radius: 999px; font-size: 12px; font-weight: 700; color: #fff; }
.st-arrow2 { color: var(--faint); }

/* Reports */
.chart-card svg { width: 100%; height: auto; display: block; }
.bar-h { display: flex; align-items: center; gap: 10px; margin-bottom: 9px; font-size: 12.5px; }
.bar-h .bl { width: 110px; flex: none; font-weight: 650; text-align: start; }
.bar-h .track { flex: 1; height: 12px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.bar-h .fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--brand), var(--brand-2)); transition: width .8s cubic-bezier(.2,.8,.2,1); }
.bar-h .bv { width: 34px; flex: none; font-weight: 750; font-variant-numeric: tabular-nums; }
.cols2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }

/* Audit / outbox */
.audit-row td { font-size: 12.5px; }
.mono { font-family: var(--mono); direction: ltr; unicode-bidi: embed; }
.outbox-item { border: 1px solid var(--border); border-radius: var(--r); padding: 14px 16px; margin-bottom: 10px; background: var(--surface); }
.outbox-top { display: flex; align-items: center; gap: 9px; margin-bottom: 7px; flex-wrap: wrap; }
.chan-tag { font-size: 10.5px; font-weight: 800; padding: 2px 8px; border-radius: 5px; letter-spacing: .03em; }
.chan-tag.email { background: var(--info-soft); color: var(--info); }
.chan-tag.sms { background: var(--accent-soft); color: var(--accent); }
.outbox-sub { font-weight: 750; font-size: 13px; }
.outbox-body { font-size: 12.5px; color: var(--muted); white-space: pre-line; background: var(--surface-2); border-radius: 9px; padding: 10px 13px; }
.outbox-meta { font-size: 11px; color: var(--faint); margin-inline-start: auto; }

/* Tour */
.tour { position: fixed; inset: 0; z-index: 200; }
.tour-hole { position: absolute; border-radius: 12px; box-shadow: 0 0 0 9999px rgba(8, 13, 12, 0.62); transition: all .35s cubic-bezier(.2,.8,.2,1); pointer-events: none; outline: 2px solid var(--brand); outline-offset: 3px; }
.tour-card { position: absolute; width: min(360px, calc(100vw - 32px)); background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--shadow-lg); padding: 17px 19px; transition: all .35s cubic-bezier(.2,.8,.2,1); }
.tour-card h4 { margin: 0 0 6px; font-size: 15px; font-weight: 800; }
.tour-card p { margin: 0 0 14px; font-size: 13px; color: var(--muted); line-height: 1.7; }
.tour-foot { display: flex; align-items: center; gap: 8px; }
.tour-count { font-size: 11.5px; color: var(--faint); margin-inline-end: auto; }
.tour-badge { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 800; color: var(--brand); background: var(--brand-soft); border-radius: 999px; padding: 3px 10px; margin-bottom: 8px; }

/* Guide page */
.guide-sec { margin-bottom: 24px; }
.guide-sec h2 { font-size: 17px; margin: 0 0 10px; }
.guide-steps { counter-reset: gs; display: flex; flex-direction: column; gap: 10px; }
.guide-step { display: flex; gap: 12px; align-items: flex-start; padding: 12px 15px; border: 1px solid var(--border); border-radius: var(--r); background: var(--surface); }
.guide-step::before { counter-increment: gs; content: counter(gs); width: 26px; height: 26px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); font-weight: 800; font-size: 12.5px; display: grid; place-items: center; flex: none; }
.cred-chip { font-family: var(--mono); direction: ltr; unicode-bidi: embed; background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; padding: 1px 7px; font-size: 12px; }

/* icon spans (mask vars injected by app.js on :root) */
.ic { display: inline-block; background: currentColor; flex: none;
  -webkit-mask-position: center; mask-position: center; -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat; -webkit-mask-size: contain; mask-size: contain; }

/* Print (reports → PDF) */
@media print {
  .sidebar, .topbar, .filters, .no-print, .toasts, .tour { display: none !important; }
  .app { grid-template-columns: 1fr; }
  .view { padding: 0; max-width: none; }
  .card { box-shadow: none; break-inside: avoid; }
  body { background: #fff; }
}

/* ============================================================ Responsive */
@media (max-width: 1080px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .cols2 { grid-template-columns: 1fr; }
  .auth-grid { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset-inline-start: 0; top: 0; transform: translateX(100%); transition: transform .3s; width: 268px; }
  [dir="rtl"] .sidebar { transform: translateX(100%); }
  .sidebar.open { transform: none !important; box-shadow: var(--shadow-lg); }
  .menu-btn { display: inline-flex; }
  .view { padding: 16px; }
  .persona-text { display: none; }
  .b-row.fields-row, .b-row.states-row, .b-row.trans-row { grid-template-columns: 1fr 1fr; }
  /* tables → cards */
  .tbl.stack thead { display: none; }
  .tbl.stack tbody tr { display: block; border: 1px solid var(--border); border-radius: var(--r); margin-bottom: 10px; padding: 6px 2px; background: var(--surface); }
  .tbl.stack td { display: flex; justify-content: space-between; gap: 12px; border-bottom: none; padding: 7px 14px; }
  .tbl.stack td::before { content: attr(data-l); color: var(--faint); font-size: 11.5px; font-weight: 700; }
}
@media (max-width: 520px) {
  .kpis { grid-template-columns: 1fr; }
  .row2, .row3 { grid-template-columns: 1fr; }
  .topbar { padding: 10px 14px; }
  .topbar-title { font-size: 14.5px; }
}
@media (prefers-reduced-motion: reduce) { * { animation-duration: .01ms !important; transition-duration: .01ms !important; } }
