/* FRAME — design system: tokens + components. Screens use only these. See docs/DESIGN.md */
:root {
  --bg: #F6F3ED;
  --side: #FBF9F5;
  --surface: #FFFFFF;
  --surface-2: #F2EDE4;
  --surface-3: #E8E1D5;
  --line: #E8E1D5;
  --line-2: #D4CAB9;
  --ink: #1E1D1B;
  --ink-2: #57534B;
  --ink-3: #78726A;

  --olive: #55602E;
  --olive-2: #434C22;
  --olive-soft: #ECEFDF;
  --olive-ink: #434C22;

  --amber: #90550A;  --amber-soft: #FAF0DE;
  --red: #9B3326;    --red-soft: #F7E5E0;
  --green: #2E6A44;  --green-soft: #E3EEE6;
  --blue: #2E5877;   --blue-soft: #E5EDF4;

  --display: "Amiri", "Noto Naskh Arabic", serif;
  --ui: "IBM Plex Sans Arabic", "Segoe UI", Tahoma, sans-serif;
  --latin: "Cormorant Garamond", Georgia, serif;

  --r-s: 8px; --r: 12px; --r-l: 18px; --r-xl: 24px;
  --shadow: 0 1px 2px rgba(30, 29, 27, .04), 0 4px 16px rgba(30, 29, 27, .04);
  --shadow-lg: 0 20px 48px rgba(30, 29, 27, .18);
  --ease: cubic-bezier(.2, .7, .2, 1);
  --side-w: 264px;
  --nav-h: 66px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--ui); font-size: 15px; line-height: 1.7; -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4, p, ul, ol, dl, dd, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
img { display: block; max-width: 100%; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--olive); outline-offset: 2px; border-radius: 8px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; top: -60px; inset-inline-start: 16px; z-index: 200; background: var(--ink); color: #fff; padding: 8px 14px; border-radius: 10px; }
.skip:focus { top: 12px; }
.ic { width: 20px; height: 20px; flex: none; }
.ltr { direction: ltr; unicode-bidi: isolate; display: inline-block; }
.money { white-space: nowrap; font-variant-numeric: tabular-nums; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-2); }
.faint { color: var(--ink-3); }
.small { font-size: 13px; }
.strong { font-weight: 600; }
.display { font-family: var(--display); font-weight: 700; letter-spacing: 0; }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 0 18px; border-radius: 999px; border: 1px solid transparent; font-weight: 600; font-size: 14px; cursor: pointer; white-space: nowrap; transition: background .15s var(--ease), border-color .15s var(--ease), color .15s var(--ease); }
.btn .ic { width: 18px; height: 18px; }
.btn-primary { background: var(--olive); color: #fff; }
.btn-primary:hover { background: var(--olive-2); }
.btn-dark { background: var(--ink); color: #fff; }
.btn-dark:hover { background: #000; }
.btn-secondary { background: var(--surface); border-color: var(--line-2); color: var(--ink); }
.btn-secondary:hover { border-color: var(--ink-3); }
.btn-ghost { background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn-danger { background: var(--red); color: #fff; }
.btn-light { background: rgba(255,255,255,.92); color: var(--ink); }
.btn-light:hover { background: #fff; }
.btn-sm { min-height: 34px; padding: 0 14px; font-size: 13px; }
.btn-lg { min-height: 50px; padding: 0 26px; font-size: 15px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.icon-btn { display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; border: 0; background: transparent; color: var(--ink-2); cursor: pointer; flex: none; }
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn.danger:hover { background: var(--red-soft); color: var(--red); }
.link { color: var(--olive-ink); font-weight: 600; font-size: 14px; display: inline-flex; align-items: center; gap: 4px; background: none; border: 0; padding: 0; cursor: pointer; }
.link:hover { text-decoration: underline; text-underline-offset: 4px; }
.link .ic { width: 16px; height: 16px; }
@media (pointer: coarse) { .btn { min-height: 46px; } .btn-sm { min-height: 40px; } .icon-btn { width: 44px; height: 44px; } }

/* ---------- Chips ---------- */
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 1px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 600; line-height: 1.9; white-space: nowrap; background: var(--surface-2); color: var(--ink-2); }
.chip.dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.chip-green { background: var(--green-soft); color: var(--green); }
.chip-amber { background: var(--amber-soft); color: var(--amber); }
.chip-red { background: var(--red-soft); color: var(--red); }
.chip-blue { background: var(--blue-soft); color: var(--blue); }
.chip-olive { background: var(--olive-soft); color: var(--olive-ink); }
.chip-dark { background: rgba(30,29,27,.72); color: #fff; backdrop-filter: blur(6px); }
.chip-glass { background: rgba(255,255,255,.88); color: var(--ink); }

/* ---------- Cards / sections ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-l); padding: 22px; min-width: 0; }
.card.flush { padding: 0; overflow: hidden; }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.card-h h2, .card-h h3 { font-size: 17px; font-weight: 600; line-height: 1.4; }
.card-h .sub { font-size: 13px; color: var(--ink-3); margin-top: 2px; }
.eyebrow { font-size: 12.5px; font-weight: 600; color: var(--ink-3); letter-spacing: .02em; }
.grid { display: grid; gap: 20px; }
.cols-main { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 24px; align-items: start; }
.cols-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.cols-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
.stack { display: grid; gap: 20px; align-content: start; min-width: 0; }
@media (max-width: 1100px) { .cols-main { grid-template-columns: minmax(0, 1fr); } .cols-3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 680px) { .cols-2, .cols-3 { grid-template-columns: 1fr; } .card { padding: 18px; border-radius: 16px; } }

/* ---------- Lists ---------- */
.rows > li { display: flex; gap: 14px; padding: 14px 0; border-top: 1px solid var(--line); align-items: flex-start; }
.rows > li:first-child { border-top: 0; padding-top: 0; }
.rows > li:last-child { padding-bottom: 0; }
.row-main { flex: 1; min-width: 0; display: grid; gap: 3px; }
.row-title { font-weight: 600; line-height: 1.5; }
.row-sub { color: var(--ink-2); font-size: 14px; }
.meta { display: flex; flex-wrap: wrap; gap: 2px 14px; color: var(--ink-2); font-size: 13px; }
.meta > span { display: inline-flex; align-items: center; gap: 5px; }
.meta .ic { width: 15px; height: 15px; color: var(--ink-3); }
.row-end { display: flex; gap: 4px; align-items: center; flex: none; }
.kv { display: grid; gap: 10px; }
.kv > div { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.kv dt { color: var(--ink-2); }
.kv dd { font-weight: 500; text-align: end; }
.kv .sum { border-top: 1px solid var(--line); padding-top: 12px; font-weight: 700; }
.kv .sum dt { color: var(--ink); }
.ticks li { display: flex; gap: 10px; align-items: flex-start; padding: 5px 0; font-size: 14px; }
.ticks .ic { width: 17px; height: 17px; color: var(--olive); margin-top: 3px; }
@media (max-width: 560px) {
  .rows.wrap-sm > li { flex-wrap: wrap; }
  .rows.wrap-sm .row-main { flex-basis: 100%; }
  .rows.wrap-sm .row-end { width: 100%; justify-content: space-between; }
}

/* Attention list: quiet rows, a tinted icon carries the urgency */
.attn > li { display: flex; align-items: center; gap: 14px; padding: 14px 0; border-top: 1px solid var(--line); }
.attn > li:first-child { border-top: 0; padding-top: 0; }
.attn > li:last-child { padding-bottom: 0; }
.attn .badge-ic { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; flex: none; }
.attn .badge-ic .ic { width: 18px; height: 18px; }
.tone-red .badge-ic { background: var(--red-soft); color: var(--red); }
.tone-amber .badge-ic { background: var(--amber-soft); color: var(--amber); }
.tone-blue .badge-ic { background: var(--blue-soft); color: var(--blue); }
.attn .row-main p:first-child { font-size: 14.5px; font-weight: 500; line-height: 1.55; }
@media (max-width: 560px) { .attn > li { flex-wrap: wrap; } .attn .row-main { flex-basis: calc(100% - 50px); } .attn .row-end { margin-inline-start: 50px; } }

/* ---------- Progress / steps ---------- */
.bar { height: 6px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--olive); border-radius: inherit; transition: width .3s var(--ease); }
.bar-line { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; color: var(--ink-2); margin-top: 8px; }
.steps { display: flex; gap: 6px; }
.steps li { flex: 1; min-width: 0; display: grid; gap: 6px; font-size: 12px; color: var(--ink-3); font-weight: 500; line-height: 1.35; }
.steps li::before { content: ""; height: 4px; border-radius: 4px; background: var(--surface-3); }
.steps li.done { color: var(--olive-ink); }
.steps li.done::before { background: var(--olive); }
.steps li.current { color: var(--ink); font-weight: 700; }
.steps li.current::before { background: linear-gradient(270deg, var(--olive) 50%, var(--surface-3) 50%); }

/* ---------- Segmented / tabs ---------- */
.seg { display: inline-flex; padding: 4px; gap: 2px; background: var(--surface-2); border-radius: 999px; max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.seg button, .seg a { border: 0; background: transparent; padding: 6px 16px; border-radius: 999px; font-size: 14px; font-weight: 500; color: var(--ink-2); cursor: pointer; min-height: 36px; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; }
.seg [aria-pressed="true"], .seg [aria-current="page"] { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: 0 1px 3px rgba(30,29,27,.1); }
.seg .count { font-size: 12px; color: var(--ink-3); font-weight: 500; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tabs a { display: inline-flex; align-items: center; gap: 8px; padding: 14px 14px; color: var(--ink-2); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; font-size: 14.5px; }
.tabs a:hover { color: var(--ink); }
.tabs a[aria-current="page"] { color: var(--ink); border-color: var(--olive); font-weight: 600; }
.tabs .n { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--red-soft); color: var(--red); font-size: 12px; font-weight: 700; display: inline-grid; place-items: center; }

/* ---------- Switch / checkbox ---------- */
.switch { display: inline-flex; align-items: center; gap: 8px; border: 0; background: none; cursor: pointer; padding: 4px 0; font-size: 13px; color: var(--ink-2); white-space: nowrap; }
.switch .track { width: 38px; height: 22px; border-radius: 999px; background: var(--line-2); position: relative; transition: background .15s var(--ease); flex: none; }
.switch .track::after { content: ""; position: absolute; top: 3px; inset-inline-start: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.2); transition: inset-inline-start .15s var(--ease); }
.switch[aria-checked="true"] .track { background: var(--olive); }
.switch[aria-checked="true"] .track::after { inset-inline-start: 19px; }
.switch[aria-checked="true"] { color: var(--olive-ink); font-weight: 600; }
.check { display: inline-flex; align-items: flex-start; gap: 10px; cursor: pointer; font-size: 14.5px; }
.check input { appearance: none; width: 22px; height: 22px; margin: 2px 0 0; border: 1.5px solid var(--line-2); border-radius: 7px; background: var(--surface); display: grid; place-items: center; cursor: pointer; flex: none; transition: background .12s var(--ease), border-color .12s var(--ease); }
.check input:checked { background: var(--olive); border-color: var(--olive); }
.check input:checked::after { content: ""; width: 6px; height: 11px; border: solid #fff; border-width: 0 2.2px 2.2px 0; transform: translateY(-1px) rotate(45deg); }

/* ---------- Forms ---------- */
.field { display: grid; gap: 6px; margin: 0 0 18px; border: 0; padding: 0; min-width: 0; }
.field > label, .field > legend { font-size: 14px; font-weight: 600; padding: 0; }
.field .opt { font-weight: 400; color: var(--ink-3); }
.field input:not([type=radio]):not([type=checkbox]), .field select, .field textarea, .input {
  width: 100%; min-height: 46px; padding: 9px 14px; border: 1px solid var(--line-2); border-radius: var(--r); background: var(--surface); font-size: 15px; transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.field textarea { resize: vertical; line-height: 1.6; }
.field input:focus, .field select:focus, .field textarea:focus, .input:focus { outline: none; border-color: var(--olive); box-shadow: 0 0 0 3px var(--olive-soft); }
.field [aria-invalid="true"] { border-color: var(--red) !important; }
.hint { font-size: 13px; color: var(--ink-3); }
.error { font-size: 13px; color: var(--red); font-weight: 500; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
@media (max-width: 460px) { .form-grid { grid-template-columns: 1fr; } }
.choices { display: flex; flex-wrap: wrap; gap: 8px; }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice > span { display: inline-flex; align-items: center; gap: 8px; min-height: 42px; padding: 0 16px; border: 1px solid var(--line-2); border-radius: 999px; cursor: pointer; font-size: 14px; font-weight: 500; background: var(--surface); }
.choice input:checked + span { border-color: var(--olive); background: var(--olive-soft); color: var(--olive-ink); font-weight: 600; }
.choice input:focus-visible + span { outline: 2px solid var(--olive); outline-offset: 2px; }
.choice input[aria-invalid="true"] + span { border-color: var(--red); }
.choice.block { display: block; }
.choice.block > span { display: flex; border-radius: var(--r); padding: 14px 16px; min-height: 60px; justify-content: space-between; flex-wrap: wrap; gap: 4px 12px; }
.calc { padding: 14px 16px; border-radius: var(--r); background: var(--surface-2); font-size: 14px; margin-bottom: 18px; }
.search { position: relative; }
.search .ic { position: absolute; inset-inline-start: 14px; top: 50%; transform: translateY(-50%); color: var(--ink-3); width: 18px; height: 18px; }
.search input { padding-inline-start: 42px !important; border-radius: 999px !important; min-height: 42px !important; }

/* ---------- Alerts ---------- */
.alert { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-radius: var(--r); font-size: 14px; line-height: 1.6; }
.alert .ic { width: 18px; height: 18px; margin-top: 2px; }
.alert-red { background: var(--red-soft); color: var(--red); }
.alert-amber { background: var(--amber-soft); color: var(--amber); }
.alert-green { background: var(--green-soft); color: var(--green); }
.alert-blue { background: var(--blue-soft); color: var(--blue); }
.alert > div { flex: 1; min-width: 0; }

/* ---------- Covers & avatars ---------- */
.cover { position: relative; background: var(--surface-3); overflow: hidden; }
.cover img { width: 100%; height: 100%; object-fit: cover; }
.cover.fallback { background: linear-gradient(135deg, #E9E2D4, #D9D0BE); }
.cover .mono { position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--display); font-size: 34px; color: rgba(30,29,27,.35); }
.avatar { width: 36px; height: 36px; border-radius: 50%; display: inline-grid; place-items: center; font-weight: 700; font-size: 14px; flex: none; background: var(--olive-soft); color: var(--olive-ink); }
.avatar.lg { width: 48px; height: 48px; font-size: 17px; }
.avatar.empty { background: var(--surface-2); color: var(--ink-3); border: 1.5px dashed var(--line-2); }

/* ---------- Empty / loading ---------- */
.empty { display: grid; justify-items: center; text-align: center; gap: 6px; padding: 32px 16px; color: var(--ink-2); font-size: 14px; }
.empty > .ic { width: 30px; height: 30px; color: var(--ink-3); margin-bottom: 6px; }
.empty h3 { color: var(--ink); font-weight: 600; font-size: 16px; }
.empty .btn { margin-top: 10px; }
.sk { border-radius: 10px; background: linear-gradient(90deg, var(--surface-2) 0%, var(--surface-3) 50%, var(--surface-2) 100%); background-size: 200% 100%; animation: sk 1.3s linear infinite; }
@keyframes sk { to { background-position: -200% 0; } }
.state { max-width: 460px; margin: 12vh auto; text-align: center; display: grid; gap: 12px; justify-items: center; padding: 0 16px; }
.state > .ic { width: 44px; height: 44px; color: var(--ink-3); }
.state h1 { font-family: var(--display); font-size: 30px; }

/* ---------- Dialog / sheet ---------- */
dialog { border: 0; padding: 0; border-radius: var(--r-xl); width: min(560px, calc(100% - 32px)); max-height: calc(100dvh - 48px); background: var(--surface); color: var(--ink); box-shadow: var(--shadow-lg); overflow: hidden; }
dialog[open] { display: flex; flex-direction: column; animation: dlg-in .2s var(--ease); }
dialog::backdrop { background: rgba(30, 29, 27, .45); }
.dlg-form { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.dlg-head { display: flex; gap: 12px; align-items: flex-start; padding: 22px 22px 0; }
.dlg-head > div { flex: 1; }
.dlg-head h2 { font-family: var(--display); font-size: 26px; font-weight: 700; line-height: 1.3; }
.dlg-desc { font-size: 14px; color: var(--ink-2); margin-top: 2px; }
.dlg-body { padding: 20px 22px; overflow-y: auto; flex: 1; }
.dlg-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 14px 22px; border-top: 1px solid var(--line); }
@keyframes dlg-in { from { opacity: 0; transform: translateY(10px); } }
@media (max-width: 640px) {
  dialog { width: 100%; max-width: 100%; margin: auto 0 0; border-radius: var(--r-xl) var(--r-xl) 0 0; max-height: 92dvh; }
  .dlg-foot { padding-bottom: calc(14px + env(safe-area-inset-bottom)); }
  .dlg-foot .btn { flex: 1; }
}

/* ---------- Toasts ---------- */
.toasts { position: fixed; z-index: 100; inset-inline: 0; bottom: 24px; display: grid; justify-items: center; gap: 8px; padding: 0 16px; pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 10px; max-width: 520px; width: 100%; padding: 10px 10px 10px 16px; padding-inline-start: 16px; border-radius: 16px; background: #24231F; color: #F6F3ED; box-shadow: var(--shadow-lg); font-size: 14px; animation: toast-in .2s var(--ease); }
.toast p { flex: 1; line-height: 1.5; }
.toast .ic { width: 18px; height: 18px; }
.toast-success .t-ic { color: #B3CFA2; }
.toast-error .t-ic { color: #F2A898; }
.toast-warn .t-ic { color: #EDC680; }
.toast-action { border: 0; background: rgba(255,255,255,.14); color: #fff; font-weight: 700; border-radius: 999px; padding: 6px 14px; cursor: pointer; white-space: nowrap; }
.toast .icon-btn { color: #CFC8BA; width: 32px; height: 32px; }
.toast .icon-btn:hover { background: rgba(255,255,255,.1); color: #fff; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
