/* Layout: right-hand sidebar app shell (RTL) mirroring the real Filament panel,
   with a coaching layer (spotlight + coach card) floating above it. */
:root {
  --bg: #f5f4ef;
  --surface: #ffffff;
  --surface-2: #efede5;
  --fg: #142030;
  --muted: #5a6474;
  --faint: #89909c;
  --line: #e2dfd5;
  --accent: #1f3b5c;
  --accent-strong: #132a45;
  --accent-soft: #e6ecf3;
  --accent-ink: #ffffff;
  --deep: #0f1c2c;
  --deep-2: #1a2d45;
  --on-deep: #f4efe2;
  --on-deep-muted: #b9c3cf;
  --gold: #c9a65a;
  --danger: #d61f4b;
  --danger-soft: #fde8ee;
  --warn: #b25b06;
  --warn-soft: #fdf1df;
  --ok: #047857;
  --ok-soft: #e1f5ec;
  --info: #0369a1;
  --info-soft: #e2f1fa;
  --paper: #fbf8f1;
  --paper-ink: #2b2620;
  --mark: #ffe58a;
  --scrim: rgba(9, 17, 28, .62);
  --shadow: 0 1px 2px rgba(15, 28, 44, .06), 0 8px 24px -12px rgba(15, 28, 44, .18);
  --shadow-lg: 0 24px 60px -20px rgba(15, 28, 44, .45);

  --font-ui: "Tajawal", "Segoe UI", system-ui, sans-serif;
  --font-display: "Noto Naskh Arabic", "Amiri", "Times New Roman", serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;

  --r-sm: 6px;
  --r: 10px;
  --r-lg: 16px;
  --side: 264px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b121b; --surface: #121c28; --surface-2: #192535; --fg: #e8ebf0; --muted: #a3acb9; --faint: #77808e;
    --line: #263345; --accent: #d4b26a; --accent-strong: #e8cb8b; --accent-soft: #2b2617; --accent-ink: #0b121b;
    --deep: #0a1420; --deep-2: #132336; --on-deep: #f2ecdd; --on-deep-muted: #aab5c3; --gold: #d4b26a;
    --danger: #ff6d8f; --danger-soft: #3a1622; --warn: #f2a54a; --warn-soft: #36240f; --ok: #3dd6a0; --ok-soft: #0f2e24;
    --info: #5fb8ec; --info-soft: #0f2536; --paper: #ece6d8; --paper-ink: #2b2620; --mark: #ffd75e;
    --scrim: rgba(3, 7, 12, .72);
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px -12px rgba(0, 0, 0, .6);
    --shadow-lg: 0 24px 60px -20px rgba(0, 0, 0, .8);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b121b; --surface: #121c28; --surface-2: #192535; --fg: #e8ebf0; --muted: #a3acb9; --faint: #77808e;
  --line: #263345; --accent: #d4b26a; --accent-strong: #e8cb8b; --accent-soft: #2b2617; --accent-ink: #0b121b;
  --deep: #0a1420; --deep-2: #132336; --on-deep: #f2ecdd; --on-deep-muted: #aab5c3; --gold: #d4b26a;
  --danger: #ff6d8f; --danger-soft: #3a1622; --warn: #f2a54a; --warn-soft: #36240f; --ok: #3dd6a0; --ok-soft: #0f2e24;
  --info: #5fb8ec; --info-soft: #0f2536; --paper: #ece6d8; --paper-ink: #2b2620; --mark: #ffd75e;
  --scrim: rgba(3, 7, 12, .72);
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px -12px rgba(0, 0, 0, .6);
  --shadow-lg: 0 24px 60px -20px rgba(0, 0, 0, .8);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
svg { width: 18px; height: auto; flex: none; vertical-align: middle; }
.row > svg { width: 16px; color: var(--faint); }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font-family: var(--font-ui); font-size: 15px; line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
h1, h2, h3, h4 { margin: 0; line-height: 1.35; text-wrap: balance; }
p { margin: 0; }
.num, .tabular { font-variant-numeric: tabular-nums; }
.ltr { direction: ltr; unicode-bidi: isolate; display: inline-block; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ───────── Buttons & chips ───────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--line); background: var(--surface); color: var(--fg);
  padding: 8px 14px; border-radius: var(--r); font-weight: 700; font-size: .92rem;
  cursor: pointer; transition: background .15s, border-color .15s, transform .1s; white-space: nowrap;
}
.btn:hover { border-color: var(--accent); }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .5; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn-ok { background: var(--ok); border-color: var(--ok); color: var(--surface); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--fg); background: var(--surface-2); }
.btn-sm { padding: 5px 10px; font-size: .84rem; }
.btn svg { width: 17px; height: 17px; flex: none; }

.pill {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 10px; border-radius: 999px;
  font-size: .78rem; font-weight: 700; background: var(--surface-2); color: var(--muted); white-space: nowrap;
}
.pill svg { width: 13px; height: 13px; }
.pill.danger { background: var(--danger-soft); color: var(--danger); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.info { background: var(--info-soft); color: var(--info); }
.pill.accent { background: var(--accent-soft); color: var(--accent); }

.chip {
  border: 1px dashed var(--accent); color: var(--accent); background: var(--accent-soft);
  padding: 4px 12px; border-radius: 999px; font-size: .85rem; font-weight: 700; cursor: pointer;
}
.chip:hover { border-style: solid; }

/* ───────── App shell ───────── */
.shell { display: grid; grid-template-columns: var(--side) minmax(0, 1fr); min-height: 100%; }
.side {
  background: var(--surface); border-inline-start: 0; border-inline-end: 1px solid var(--line);
  position: sticky; top: 0; height: 100vh; overflow-y: auto; padding: 18px 14px 24px;
  display: flex; flex-direction: column; gap: 18px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 11px; background: var(--deep); color: var(--gold);
  display: grid; place-items: center; flex: none;
}
.brand-mark svg { width: 82%; height: 82%; display: block; }
.brand b { display: block; font-size: 1.05rem; }
.brand small { color: var(--muted); font-size: .78rem; }
.nav-group { display: grid; gap: 2px; }
.nav-group > span { font-size: .74rem; font-weight: 800; color: var(--faint); padding: 0 10px 4px; letter-spacing: .02em; }
.nav-link {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 9px;
  color: var(--muted); font-weight: 600; font-size: .93rem; text-decoration: none !important; position: relative;
}
.nav-link svg { width: 19px; height: 19px; flex: none; }
.nav-link:hover { background: var(--surface-2); color: var(--fg); }
.nav-link.active { background: var(--accent-soft); color: var(--accent); }
.nav-link .count { margin-inline-start: auto; font-size: .74rem; background: var(--danger); color: var(--surface); border-radius: 999px; padding: 0 7px; font-weight: 800; }
.side-foot { margin-top: auto; font-size: .78rem; color: var(--faint); padding: 0 8px; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 10px; padding: 10px 24px; flex-wrap: wrap;
}
.menu-btn { display: none; }
.search {
  flex: 1 1 260px; min-width: 0; position: relative; max-width: 460px;
}
.search input {
  width: 100%; border: 1px solid var(--line); background: var(--surface); border-radius: var(--r);
  padding: 8px 38px 8px 12px; font-size: .92rem;
}
.search svg { position: absolute; inset-inline-start: 11px; top: 50%; transform: translateY(-50%); width: 17px; color: var(--faint); }
.search-results {
  position: absolute; top: calc(100% + 6px); inset-inline: 0; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); box-shadow: var(--shadow-lg); padding: 6px; z-index: 40; max-height: 360px; overflow: auto;
}
.search-results a { display: block; padding: 8px 10px; border-radius: 8px; color: var(--fg); text-decoration: none; }
.search-results a:hover, .search-results a:focus { background: var(--surface-2); }
.search-results small { display: block; color: var(--muted); }
.top-actions { display: flex; align-items: center; gap: 8px; margin-inline-start: auto; }
.role-switch { position: relative; }
.role-btn { display: flex; align-items: center; gap: 9px; padding: 4px 6px 4px 12px; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-size: .78rem; font-weight: 800;
  background: var(--accent-soft); color: var(--accent); flex: none;
}
.role-btn .who { text-align: start; line-height: 1.25; }
.role-btn .who b { display: block; font-size: .86rem; }
.role-btn .who small { color: var(--muted); font-size: .74rem; font-weight: 600; }
.role-menu {
  position: absolute; inset-inline-end: 0; top: calc(100% + 8px); width: 320px; max-width: calc(100vw - 32px);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-lg); padding: 8px; z-index: 50;
}
.role-menu header { padding: 8px 10px 10px; font-size: .82rem; color: var(--muted); }
.role-opt { display: flex; gap: 10px; width: 100%; text-align: start; padding: 9px 10px; border-radius: 10px; border: 0; background: none; cursor: pointer; align-items: center; }
.role-opt:hover, .role-opt.on { background: var(--surface-2); }
.role-opt b { display: block; font-size: .9rem; }
.role-opt small { display: block; color: var(--muted); font-size: .78rem; line-height: 1.4; }

.demo-ribbon {
  background: var(--deep); color: var(--on-deep-muted); font-size: .8rem; padding: 6px 24px;
  display: flex; gap: 12px; align-items: center; flex-wrap: wrap;
}
.demo-ribbon b { color: var(--on-deep); }
.demo-ribbon button { background: none; border: 0; color: var(--on-deep); text-decoration: underline; cursor: pointer; font-size: .8rem; padding: 0; }

.content { padding: 24px; display: grid; gap: 20px; max-width: 1240px; width: 100%; margin-inline: auto; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.crumbs { font-size: .8rem; color: var(--faint); display: flex; gap: 6px; flex-wrap: wrap; }
.crumbs a { color: var(--muted); }
.page-head h1 { font-size: 1.55rem; font-weight: 800; }
.page-head .sub { color: var(--muted); margin-top: 2px; max-width: 70ch; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ───────── Cards & grids ───────── */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow); min-width: 0; }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.card-h h3 { font-size: 1rem; font-weight: 800; display: flex; align-items: center; gap: 8px; }
.card-h h3 svg { width: 18px; color: var(--accent); }
.card-b { padding: 16px 18px; }
.grid { display: grid; gap: 16px; }
.g-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-main { grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); }

.stat {
  display: grid; gap: 4px; padding: 16px 18px; text-align: start; cursor: pointer; border: 1px solid var(--line);
  background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow); color: var(--fg); position: relative; overflow: hidden;
  transition: border-color .15s, transform .15s;
}
.stat:hover { border-color: var(--accent); transform: translateY(-2px); }
.stat .label { color: var(--muted); font-weight: 700; font-size: .86rem; display: flex; align-items: center; gap: 7px; }
.stat .label svg { width: 17px; }
.stat .value { font-size: 2rem; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.2; }
.stat .hint { font-size: .8rem; color: var(--muted); }
.stat.danger .value { color: var(--danger); }
.stat.warn .value { color: var(--warn); }
.stat .go { position: absolute; inset-inline-end: 14px; top: 14px; color: var(--faint); width: 16px; }

.list { display: grid; }
.row {
  display: flex; align-items: center; gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--line);
  color: var(--fg); text-decoration: none !important; min-width: 0;
}
.row:last-child { border-bottom: 0; }
a.row:hover, button.row:hover { background: var(--surface-2); }
button.row { width: 100%; border: 0; border-bottom: 1px solid var(--line); background: none; text-align: start; cursor: pointer; }
.row .grow { flex: 1; min-width: 0; }
.row .t { font-weight: 700; display: block; overflow: hidden; text-overflow: ellipsis; }
.row .s { font-size: .84rem; color: var(--muted); display: block; }
.date-tile {
  width: 52px; flex: none; text-align: center; border-radius: 10px; background: var(--surface-2); padding: 4px 0; line-height: 1.2;
}
.date-tile b { display: block; font-size: 1.2rem; font-variant-numeric: tabular-nums; }
.date-tile small { font-size: .7rem; color: var(--muted); }
.sev { width: 4px; align-self: stretch; border-radius: 4px; background: var(--line); flex: none; }
.sev.danger { background: var(--danger); } .sev.warn { background: var(--warn); } .sev.ok { background: var(--ok); } .sev.info { background: var(--accent); }

.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.t th { text-align: start; font-size: .78rem; color: var(--muted); font-weight: 800; padding: 10px 14px; background: var(--surface-2); white-space: nowrap; }
table.t td { padding: 11px 14px; border-top: 1px solid var(--line); vertical-align: middle; }
table.t tr.click { cursor: pointer; }
table.t tr.click:hover td { background: var(--surface-2); }
table.t .amount { font-variant-numeric: tabular-nums; white-space: nowrap; }

.empty { text-align: center; padding: 30px 18px; color: var(--muted); display: grid; gap: 8px; justify-items: center; }
.empty svg { width: 34px; color: var(--faint); }

.callout { display: flex; gap: 12px; padding: 12px 14px; border-radius: var(--r); background: var(--surface-2); font-size: .9rem; align-items: flex-start; }
.callout svg { width: 20px; flex: none; margin-top: 2px; }
.callout.warn { background: var(--warn-soft); color: var(--warn); }
.callout.danger { background: var(--danger-soft); color: var(--danger); }
.callout.ok { background: var(--ok-soft); color: var(--ok); }
.callout.info { background: var(--accent-soft); color: var(--accent); }
.callout .body { color: var(--fg); }
.callout b { color: inherit; }

/* ───────── Matter file ───────── */
.matter-hero { padding: 18px 20px; display: grid; gap: 14px; }
.matter-hero h1 { font-size: 1.4rem; font-weight: 800; }
.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px 20px; }
.kv div { min-width: 0; }
.kv dt { font-size: .76rem; color: var(--faint); font-weight: 700; }
.kv dd { margin: 0; font-weight: 700; font-size: .92rem; }
.stages { display: flex; gap: 4px; flex-wrap: wrap; }
.stage { font-size: .76rem; padding: 3px 10px; border-radius: 999px; background: var(--surface-2); color: var(--faint); font-weight: 700; }
.stage.done { color: var(--accent); background: var(--accent-soft); }
.stage.now { background: var(--accent); color: var(--accent-ink); }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); overflow-x: auto; padding-inline: 10px; scrollbar-width: thin; }
.tab {
  border: 0; background: none; padding: 11px 14px; font-weight: 700; color: var(--muted); cursor: pointer; white-space: nowrap;
  border-bottom: 2px solid transparent; margin-bottom: -1px; display: inline-flex; gap: 6px; align-items: center; font-size: .9rem;
}
.tab:hover { color: var(--fg); }
.tab.on { color: var(--accent); border-bottom-color: var(--accent); }
.tab .n { font-size: .72rem; background: var(--surface-2); border-radius: 999px; padding: 0 7px; color: var(--muted); }
.tab .n.alert { background: var(--danger); color: var(--surface); }

.timeline { list-style: none; margin: 0; padding: 4px 0; display: grid; }
.timeline li { display: grid; grid-template-columns: 26px minmax(0, 1fr); gap: 12px; padding: 10px 0; position: relative; }
.timeline li::before { content: ""; position: absolute; inset-inline-start: 12px; top: 34px; bottom: -10px; width: 2px; background: var(--line); }
.timeline li:last-child::before { display: none; }
.timeline .dot { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); color: var(--muted); }
.timeline .dot svg { width: 14px; }
.timeline .dot.accent { background: var(--accent-soft); color: var(--accent); }
.timeline .dot.danger { background: var(--danger-soft); color: var(--danger); }
.timeline .dot.ok { background: var(--ok-soft); color: var(--ok); }
.timeline .when { font-size: .78rem; color: var(--faint); }
.timeline li.fresh { animation: fresh 1.6s ease-out; }
@keyframes fresh { from { background: var(--accent-soft); } to { background: transparent; } }

/* ───────── Forms ───────── */
.form { display: grid; gap: 14px; }
.field { display: grid; gap: 5px; min-width: 0; }
.field label { font-size: .84rem; font-weight: 700; color: var(--muted); }
.field input, .field select, .field textarea {
  border: 1px solid var(--line); background: var(--surface); border-radius: var(--r); padding: 9px 12px; width: 100%;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.field .help { font-size: .78rem; color: var(--faint); }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.seg { display: inline-flex; background: var(--surface-2); border-radius: var(--r); padding: 3px; gap: 3px; }
.seg button { border: 0; background: none; padding: 6px 14px; border-radius: 8px; font-weight: 700; cursor: pointer; color: var(--muted); }
.seg button.on { background: var(--surface); color: var(--fg); box-shadow: var(--shadow); }

/* ───────── Deadline trace ───────── */
.trace { display: grid; gap: 0; counter-reset: step; }
.trace-step { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; gap: 12px; padding: 11px 0; border-bottom: 1px dashed var(--line); align-items: center; }
.trace-step:last-child { border-bottom: 0; }
.trace-step::before {
  counter-increment: step; content: counter(step); width: 28px; height: 28px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: 800; font-size: .82rem;
}
.trace-step .v { font-weight: 800; font-variant-numeric: tabular-nums; text-align: end; }
.trace-step.final::before { background: var(--accent); color: var(--accent-ink); }
.trace-step.roll .v { color: var(--warn); }
.due-big { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.due-big b { font-size: 1.9rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; font-size: .78rem; text-align: center; }
.cal span { padding: 6px 0; border-radius: 7px; font-variant-numeric: tabular-nums; }
.cal .h { color: var(--faint); font-weight: 700; }
.cal .we { color: var(--faint); background: var(--surface-2); text-decoration: line-through; }
.cal .hol { color: var(--warn); background: var(--warn-soft); }
.cal .due { background: var(--accent); color: var(--accent-ink); font-weight: 800; }
.cal .skip { background: var(--danger-soft); color: var(--danger); text-decoration: line-through; }

/* ───────── Scanned document / OCR ───────── */
.doc-split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.paper {
  background: var(--paper); color: var(--paper-ink); border-radius: 4px; padding: 30px 30px 40px; font-family: var(--font-display);
  font-size: .95rem; line-height: 2.05; box-shadow: var(--shadow-lg); transform: rotate(-.6deg); position: relative; overflow: hidden;
  background-image: radial-gradient(rgba(60, 40, 10, .07) 1px, transparent 1px); background-size: 3px 3px;
  filter: contrast(1.02);
}
.paper::after { content: ""; position: absolute; inset: 0; background: linear-gradient(100deg, transparent 60%, rgba(0, 0, 0, .05)); pointer-events: none; }
.paper .ph { text-align: center; border-bottom: 1.5px solid rgba(43, 38, 32, .5); padding-bottom: 8px; margin-bottom: 12px; }
.paper .ph b { display: block; font-size: 1.15rem; }
.paper .stamp {
  position: absolute; inset-inline-start: 26px; bottom: 26px; width: 92px; height: 92px; border-radius: 50%;
  border: 2.5px solid rgba(180, 30, 50, .55); color: rgba(180, 30, 50, .6); display: grid; place-items: center; text-align: center;
  font-size: .62rem; line-height: 1.3; transform: rotate(-14deg); font-family: var(--font-ui); font-weight: 800;
}
.paper mark { background: transparent; color: inherit; border-radius: 3px; transition: background .2s, box-shadow .2s; }
.paper mark.lit { background: var(--mark); box-shadow: 0 0 0 3px var(--mark); }
.paper.scanning::before {
  content: ""; position: absolute; inset-inline: 0; height: 60px; top: -60px; z-index: 2;
  background: linear-gradient(to bottom, transparent, color-mix(in srgb, var(--accent) 35%, transparent), transparent);
  animation: scan 1.4s linear infinite;
}
@keyframes scan { to { top: 100%; } }
.field-x { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 10px; padding: 11px 14px; border-bottom: 1px solid var(--line); cursor: default; }
.field-x:hover, .field-x:focus-within { background: var(--surface-2); }
.field-x .k { font-size: .78rem; color: var(--muted); font-weight: 700; }
.field-x .val { font-weight: 800; }
.field-x .src { grid-column: 1 / -1; font-size: .8rem; color: var(--faint); font-family: var(--font-display); }
.field-x input { border: 1px solid var(--line); border-radius: 7px; padding: 4px 8px; background: var(--surface); width: 100%; font-weight: 700; }
.conf { display: inline-flex; align-items: center; gap: 6px; font-size: .76rem; font-weight: 800; }
.conf i { display: block; width: 46px; height: 5px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.conf i::after { content: ""; display: block; height: 100%; width: var(--w); background: currentColor; }
.conf.ok { color: var(--ok); } .conf.warn { color: var(--warn); } .conf.danger { color: var(--danger); }

/* ───────── Recording / transcript ───────── */
.wave { display: flex; align-items: center; gap: 2px; height: 46px; }
.wave i { flex: 1; background: var(--accent); opacity: .35; border-radius: 2px; }
.wave i.played { opacity: 1; }
.seg-line { display: grid; grid-template-columns: 54px minmax(0, 1fr); gap: 10px; padding: 7px 0; font-size: .92rem; }
.seg-line .ts { font-family: var(--font-mono); font-size: .76rem; color: var(--faint); padding-top: 3px; direction: ltr; }
.seg-line .who { font-weight: 800; color: var(--accent); margin-inline-end: 6px; }
.seg-line.lit { background: var(--mark); color: var(--paper-ink); border-radius: 6px; padding-inline: 6px; }
.seg-line.lit .who { color: var(--paper-ink); }
.suggest { display: grid; gap: 6px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); }
.suggest.accepted { border-color: var(--ok); background: var(--ok-soft); }
.suggest.rejected { opacity: .45; }
.suggest .basis { font-size: .82rem; color: var(--muted); border-inline-start: 3px solid var(--accent); padding-inline-start: 9px; font-family: var(--font-display); }
.suggest .acts { display: flex; gap: 6px; flex-wrap: wrap; }

/* ───────── Assistant ───────── */
.chat { display: grid; gap: 12px; padding: 16px 18px; max-height: 560px; overflow-y: auto; }
.msg { max-width: 88%; padding: 10px 14px; border-radius: 14px; font-size: .93rem; }
.msg.me { background: var(--accent); color: var(--accent-ink); justify-self: start; border-end-start-radius: 4px; }
.msg.bot { background: var(--surface-2); justify-self: end; border-end-end-radius: 4px; display: grid; gap: 8px; }
.msg .intent { font-size: .74rem; color: var(--muted); display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.msg .intent code { font-family: var(--font-mono); font-size: .72rem; background: var(--surface); padding: 1px 6px; border-radius: 5px; direction: ltr; }
.msg ul { margin: 0; padding-inline-start: 18px; }
.chat-input { display: flex; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); }
.chat-input input { flex: 1; min-width: 0; border: 1px solid var(--line); border-radius: var(--r); padding: 9px 12px; background: var(--surface); }
.prompts { display: flex; gap: 6px; flex-wrap: wrap; padding: 0 18px 14px; }

/* ───────── Security ───────── */
.layers { display: grid; gap: 10px; }
.layer { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 12px 14px; border-radius: var(--r); border: 1px solid var(--line); }
.layer .ix { width: 40px; height: 40px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; }
.layer .ix svg { width: 20px; }
.matrix th, .matrix td { text-align: center !important; }
.matrix td:first-child, .matrix th:first-child { text-align: start !important; }
.yes { color: var(--ok); font-weight: 800; } .no { color: var(--faint); }

/* ───────── Toasts ───────── */
.toasts { position: fixed; inset-inline-end: 20px; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); display: grid; gap: 8px; z-index: 120; max-width: min(380px, calc(100vw - 40px)); }
.toast {
  background: var(--deep); color: var(--on-deep); padding: 12px 14px; border-radius: 12px; box-shadow: var(--shadow-lg);
  display: flex; gap: 10px; align-items: flex-start; font-size: .9rem; animation: toast-in .25s ease-out;
}
.toast svg { width: 19px; flex: none; color: var(--ok); margin-top: 2px; }
.toast.bad svg { color: var(--danger); }
.toast small { display: block; color: var(--on-deep-muted); }
@keyframes toast-in { from { transform: translateY(10px); opacity: 0; } }

/* ───────── Modal ───────── */
.modal-back { position: fixed; inset: 0; background: var(--scrim); z-index: 90; display: grid; place-items: center; padding: 16px; }
.modal { background: var(--surface); border-radius: var(--r-lg); width: min(560px, 100%); max-height: calc(100vh - 32px); overflow: auto; box-shadow: var(--shadow-lg); }
.modal .card-h { position: sticky; top: 0; background: var(--surface); z-index: 1; }
.modal-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 14px 18px; border-top: 1px solid var(--line); flex-wrap: wrap; }

/* ───────── Welcome ───────── */
.welcome {
  position: fixed; inset: 0; z-index: 100; overflow-y: auto; background: var(--deep); color: var(--on-deep);
  padding-block: 0; padding-inline: 16px;
}
.welcome::before {
  content: ""; position: fixed; inset: 0; pointer-events: none;
  background:
    radial-gradient(900px 500px at 85% -10%, color-mix(in srgb, var(--accent) 40%, transparent), transparent 60%),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, .025) 0 1px, transparent 1px 34px);
}
.welcome-in { position: relative; max-width: 1120px; margin: 0 auto; padding-block: 28px 48px; display: grid; gap: 34px; }
.w-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.w-top .brand-mark { background: var(--deep-2); color: var(--gold); box-shadow: inset 0 0 0 1px rgba(201, 166, 90, .35); }
.w-top .brand small { color: var(--on-deep-muted); }
.w-hero { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 40px; align-items: center; }
.w-eyebrow { color: var(--gold); font-weight: 700; font-size: .92rem; }
.w-hero h1 { font-family: var(--font-display); font-size: clamp(2rem, 4.4vw, 3.3rem); font-weight: 700; line-height: 1.45; margin-top: 10px; }
.w-hero h1 em { font-style: normal; color: var(--gold); }
.w-hero p.lead { color: var(--on-deep-muted); font-size: 1.08rem; margin-top: 14px; max-width: 52ch; }
.w-choices { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.w-choice {
  text-align: start; border: 1px solid rgba(255, 255, 255, .16); background: rgba(255, 255, 255, .05); color: var(--on-deep);
  border-radius: var(--r-lg); padding: 18px; cursor: pointer; display: grid; gap: 6px; transition: background .2s, border-color .2s, transform .2s;
}
.w-choice:hover { background: rgba(255, 255, 255, .1); border-color: rgba(255, 255, 255, .4); transform: translateY(-3px); }
.w-choice.primary { background: var(--on-deep); color: var(--deep); border-color: var(--on-deep); }
.w-choice.primary small { color: var(--deep-2); }
.w-choice b { font-size: 1.08rem; display: flex; align-items: center; gap: 8px; }
.w-choice b svg { width: 20px; }
.w-choice small { color: var(--on-deep-muted); font-size: .88rem; line-height: 1.55; }
.w-choice .meta { font-size: .76rem; font-weight: 800; opacity: .75; }
.w-roles { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; }
.w-role { border: 1px solid rgba(255, 255, 255, .16); background: rgba(255, 255, 255, .04); color: var(--on-deep); border-radius: var(--r); padding: 12px; cursor: pointer; text-align: start; display: grid; gap: 4px; }
.w-role:hover { border-color: var(--on-deep-muted); }
.w-role b { font-size: .92rem; }
.w-role small { color: var(--on-deep-muted); font-size: .78rem; line-height: 1.5; }
.w-preview { position: relative; min-height: 330px; }
.w-card {
  position: absolute; background: var(--surface); color: var(--fg); border-radius: var(--r-lg); box-shadow: 0 30px 60px -20px rgba(0, 0, 0, .55);
  padding: 16px; width: min(340px, 92%);
}
.w-card.c1 { inset-inline-end: 0; top: 0; transform: rotate(1.5deg); }
.w-card.c2 { inset-inline-start: 0; top: 150px; transform: rotate(-2deg); animation: float 6s ease-in-out infinite; }
@keyframes float { 50% { transform: rotate(-2deg) translateY(-8px); } }
.w-card h4 { font-size: .95rem; display: flex; gap: 8px; align-items: center; }
.w-pillars { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; border-top: 1px solid rgba(255, 255, 255, .14); padding-top: 24px; }
.w-pillars div { display: grid; gap: 4px; }
.w-pillars b { font-size: .95rem; }
.w-pillars small { color: var(--on-deep-muted); font-size: .84rem; line-height: 1.6; }
.w-foot { color: var(--on-deep-muted); font-size: .8rem; }

/* ───────── Coach (guided tour) ───────── */
.spot {
  position: fixed; z-index: 80; border-radius: 12px; pointer-events: none;
  box-shadow: 0 0 0 4px var(--accent), 0 0 0 9999px var(--scrim);
  transition: top .35s cubic-bezier(.2, .8, .2, 1), left .35s cubic-bezier(.2, .8, .2, 1), width .35s, height .35s;
}
.spot.pulse::after {
  content: ""; position: absolute; inset: -4px; border-radius: 14px; border: 3px solid var(--accent); animation: pulse 1.6s ease-out infinite;
}
@keyframes pulse { from { opacity: .9; transform: scale(1); } to { opacity: 0; transform: scale(1.06); } }
.spot.none { box-shadow: 0 0 0 9999px var(--scrim); }
.coach-block { position: fixed; inset: 0; z-index: 79; }
.coach {
  position: fixed; z-index: 85; width: min(380px, calc(100vw - 32px)); background: var(--surface); color: var(--fg);
  border-radius: var(--r-lg); box-shadow: var(--shadow-lg); border: 1px solid var(--line); padding: 16px 18px 14px; display: grid; gap: 10px;
  transition: top .35s cubic-bezier(.2, .8, .2, 1), left .35s cubic-bezier(.2, .8, .2, 1), opacity .2s;
}
.coach .chap { font-size: .76rem; font-weight: 800; color: var(--accent); display: flex; justify-content: space-between; gap: 8px; }
.coach h3 { font-size: 1.08rem; font-weight: 800; }
.coach p { color: var(--muted); font-size: .92rem; }
.coach .do {
  display: flex; gap: 8px; align-items: flex-start; background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: .88rem;
  padding: 8px 10px; border-radius: 9px;
}
.coach .do svg { width: 17px; flex: none; margin-top: 2px; }
.coach .done-note { display: flex; gap: 8px; align-items: center; background: var(--ok-soft); color: var(--ok); font-weight: 700; font-size: .88rem; padding: 8px 10px; border-radius: 9px; }
.coach .done-note svg { width: 17px; }
.coach .bar { height: 4px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.coach .bar i { display: block; height: 100%; background: var(--accent); transition: width .3s; }
.coach .nav { display: flex; gap: 6px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.coach .nav .l { display: flex; gap: 6px; }
.coach-tab {
  position: fixed; z-index: 70; inset-inline-end: 20px; bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  display: flex; gap: 8px; align-items: center; background: var(--deep); color: var(--on-deep); border: 0; padding: 10px 16px;
  border-radius: 999px; box-shadow: var(--shadow-lg); cursor: pointer; font-weight: 700;
}
.coach-tab svg { width: 18px; }
.chapters { display: grid; gap: 4px; }
.chapters button { display: flex; gap: 10px; align-items: center; width: 100%; text-align: start; padding: 10px 12px; border: 0; background: none; border-radius: 10px; cursor: pointer; }
.chapters button:hover { background: var(--surface-2); }
.chapters .ck { width: 26px; height: 26px; border-radius: 50%; background: var(--surface-2); display: grid; place-items: center; font-weight: 800; font-size: .8rem; color: var(--muted); flex: none; }
.chapters .ck.done { background: var(--ok-soft); color: var(--ok); }
.chapters small { display: block; color: var(--muted); font-size: .8rem; }

/* ───────── Finale ───────── */
.finale { display: grid; gap: 14px; text-align: center; padding: 26px 22px; }
.finale h2 { font-family: var(--font-display); font-size: 1.7rem; }
.finale .opts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }

.gate { display: grid; gap: 12px; justify-items: center; text-align: center; padding: 48px 20px; }
.gate .ic { width: 64px; height: 64px; border-radius: 18px; background: var(--danger-soft); color: var(--danger); display: grid; place-items: center; }
.gate .ic svg { width: 30px; }
.gate h2 { font-size: 1.3rem; }
.gate p { color: var(--muted); max-width: 52ch; }
.gate code { font-family: var(--font-mono); font-size: .8rem; background: var(--surface-2); padding: 2px 8px; border-radius: 6px; direction: ltr; display: inline-block; }

.stack { display: grid; gap: 16px; }
.inline { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.between { display: flex; justify-content: space-between; gap: 10px; align-items: center; flex-wrap: wrap; }
.steps-h { display: flex; gap: 6px; flex-wrap: wrap; }
.steps-h span { padding: 6px 12px; border-radius: 999px; font-size: .82rem; font-weight: 700; background: var(--surface-2); color: var(--faint); }
.steps-h span.on { background: var(--accent); color: var(--accent-ink); }
.steps-h span.done { background: var(--accent-soft); color: var(--accent); }
.match { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; padding: 12px 14px; border-radius: var(--r); border: 1px solid var(--line); align-items: center; }
.match.danger { border-color: var(--danger); background: var(--danger-soft); }
.match.warn { border-color: var(--warn); background: var(--warn-soft); }
.match .why { grid-column: 1 / -1; font-size: .82rem; color: var(--muted); }
.match .norm { font-family: var(--font-mono); font-size: .76rem; color: var(--faint); direction: rtl; }
.bucket { display: grid; gap: 6px; }
.bucket .barline { height: 10px; border-radius: 6px; background: var(--surface-2); overflow: hidden; }
.bucket .barline i { display: block; height: 100%; border-radius: 6px; }
.portal-banner { background: linear-gradient(135deg, var(--ok-soft), var(--surface)); }

/* ───────── Responsive ───────── */
@media (max-width: 1080px) {
  .g-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g-main, .doc-split, .w-hero { grid-template-columns: minmax(0, 1fr); }
  .w-preview { display: none; }
  .w-roles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .w-pillars { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side {
    position: fixed; inset-block: 0; inset-inline-start: 0; width: min(290px, 86vw); z-index: 60; height: 100%;
    transform: translateX(110%); transition: transform .25s; box-shadow: var(--shadow-lg);
  }
  .side.open { transform: none; }
  .menu-btn { display: inline-flex; }
  .topbar { padding: 10px 16px; }
  .content { padding: 16px; }
  .demo-ribbon { padding: 6px 16px; }
  .g-3, .g-2 { grid-template-columns: minmax(0, 1fr); }
  .w-choices { grid-template-columns: minmax(0, 1fr); }
  .role-btn .who { display: none; }
  .search { order: 5; flex-basis: 100%; max-width: none; }
}
@media (max-width: 560px) {
  .g-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat .value { font-size: 1.6rem; }
  .w-roles, .w-pillars { grid-template-columns: minmax(0, 1fr); }
  .coach { inset-inline: 16px !important; left: auto !important; width: auto; bottom: calc(12px + env(safe-area-inset-bottom, 0px)) !important; top: auto !important; }
  .finale .opts { grid-template-columns: minmax(0, 1fr); }
  .msg { max-width: 96%; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ───────── «جرّب النظام الحقيقي» ───────── */
.live-cta {
  display: inline-flex; align-items: center; gap: 8px; font-weight: 800; text-decoration: none !important;
  border-radius: 999px; padding: 8px 16px; background: var(--accent); color: var(--accent-ink);
  box-shadow: 0 8px 24px -10px var(--accent); transition: transform .15s, background .15s;
}
.live-cta:hover { transform: translateY(-1px); background: var(--accent-strong); }
.live-cta svg { width: 18px; }
.live-cta.on-deep { background: var(--on-deep); color: var(--deep); }
.live-cta.big { padding: 12px 22px; font-size: 1.02rem; background: var(--on-deep); color: var(--deep); }
.live-cta.ribbon { margin-inline-start: auto; padding: 3px 12px; font-size: .8rem; box-shadow: none; }
.live-cta.btn { border-radius: var(--r); justify-content: center; }
.w-live {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  border: 1px solid rgba(255, 255, 255, .22); background: rgba(255, 255, 255, .07); border-radius: var(--r-lg); padding: 16px 18px;
}
.w-live > div { display: grid; gap: 4px; min-width: 0; flex: 1 1 320px; }
.w-live small { color: var(--on-deep-muted); font-size: .88rem; line-height: 1.6; }
