/* ميزان — نظام إدارة مكتب المحاماة
   Design system (ui-ux-pro-max: Trust & Authority): authority navy + trust gold,
   EB Garamond/Lato → Arabic: Amiri (display) + Almarai (UI). Dense dashboard scale,
   ledger-strip KPIs, flat ruled tables — not the rounded-card kit. */

:root {
  --bg: #f4f6fa;
  --surface: #ffffff;
  --surface-2: #edf1f7;
  --ink: #0f172a;
  --ink-2: #475569;
  --ink-3: #8794a6;
  --brand: #1e3a8a;          /* authority navy */
  --brand-deep: #172e74;
  --brand-soft: #e7ecf8;
  --on-brand: #ffffff;
  --brass: #b45309;          /* trust gold */
  --brass-strong: #92400e;
  --brass-soft: #f9f0e3;
  --brass-ink: #ffffff;
  --line: #dbe2ec;
  --line-strong: #cbd5e1;
  --side-bg: #0f1c42;
  --side-ink: #dde4f5;
  --side-muted: #8291b8;
  --side-line: rgba(221, 228, 245, .12);
  --gold-on-dark: #d9a441;
  --ok: #15803d;
  --ok-soft: #e4f3e9;
  --warn: #a16207;
  --warn-soft: #faf2d9;
  --danger: #c22e2e;
  --danger-soft: #fae7e7;
  --info: #1e40af;
  --info-soft: #e7ecfa;
  --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 10px 28px -20px rgba(15, 28, 66, .35);
  --r: 6px;
  --r-lg: 9px;
  --font-ui: "Almarai", system-ui, -apple-system, "Segoe UI", Tahoma, sans-serif;
  --font-display: "Amiri", "Times New Roman", serif;
  /* chart chrome — سلاسل الرسوم بألوان الهوية (اتفحصت CVD) */
  --viz-grid: #e3e2db;
  --viz-axis: #c3c2b7;
  --viz-s1: #1e3a8a;
  --viz-s2: #b45309;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1120;
    --surface: #111a30;
    --surface-2: #19233d;
    --ink: #e6ebf4;
    --ink-2: #a2aec6;
    --ink-3: #6e7b96;
    --brand: #93aaf0;
    --brand-deep: #aebff4;
    --brand-soft: #1b2850;
    --on-brand: #ffffff;
    --brass: #d9a441;
    --brass-strong: #e5bb6b;
    --brass-soft: #2c2410;
    --brass-ink: #2a1c05;
    --line: #223050;
    --line-strong: #314469;
    --side-bg: #0c1631;
    --side-ink: #d7dff2;
    --side-muted: #7483a8;
    --side-line: rgba(215, 223, 242, .1);
    --gold-on-dark: #d9a441;
    --ok: #4cc272;
    --ok-soft: #14301f;
    --warn: #dfa83c;
    --warn-soft: #332a10;
    --danger: #e26c6c;
    --danger-soft: #3a1c1c;
    --info: #8fa8f0;
    --info-soft: #182448;
    --shadow: 0 1px 2px rgba(0, 0, 0, .5), 0 12px 30px -20px rgba(0, 0, 0, .7);
    --viz-grid: #22304f;
    --viz-axis: #314469;
    --viz-s1: #93aaf0;
    --viz-s2: #d9a441;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b1120;
  --surface: #111a30;
  --surface-2: #19233d;
  --ink: #e6ebf4;
  --ink-2: #a2aec6;
  --ink-3: #6e7b96;
  --brand: #93aaf0;
  --brand-deep: #aebff4;
  --brand-soft: #1b2850;
  --on-brand: #ffffff;
  --brass: #d9a441;
  --brass-strong: #e5bb6b;
  --brass-soft: #2c2410;
  --brass-ink: #2a1c05;
  --line: #223050;
  --line-strong: #314469;
  --side-bg: #0c1631;
  --side-ink: #d7dff2;
  --side-muted: #7483a8;
  --side-line: rgba(215, 223, 242, .1);
  --gold-on-dark: #d9a441;
  --ok: #4cc272;
  --ok-soft: #14301f;
  --warn: #dfa83c;
  --warn-soft: #332a10;
  --danger: #e26c6c;
  --danger-soft: #3a1c1c;
  --info: #8fa8f0;
  --info-soft: #182448;
  --shadow: 0 1px 2px rgba(0, 0, 0, .5), 0 12px 30px -20px rgba(0, 0, 0, .7);
  --viz-grid: #22304f;
  --viz-axis: #314469;
  --viz-s1: #93aaf0;
  --viz-s2: #d9a441;
  color-scheme: dark;
}

/* الأزرار الممتلئة محتاجة كحلي ثابت بنص أبيض في الوضعين */
:root { --solid: #1e3a8a; --solid-hover: #172e74; }
:root[data-theme="dark"] { --solid: #2c4cb3; --solid-hover: #3a5ccb; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --solid: #2c4cb3; --solid-hover: #3a5ccb; }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.6;
  direction: rtl;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0; text-wrap: balance; }
p { margin: 0; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; font-size: inherit; cursor: pointer; }
svg { flex-shrink: 0; }
::placeholder { color: var(--ink-3); }
:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; border-radius: 2px; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- app frame ---------- */
#app { min-height: 100%; }
.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 236px;
  flex-shrink: 0;
  background: var(--side-bg);
  color: var(--side-ink);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 20px 18px 12px; }
.brand .logo {
  width: 40px; height: 40px; border-radius: 7px;
  background: transparent; border: 1px solid var(--gold-on-dark);
  display: grid; place-items: center; color: var(--gold-on-dark);
}
.brand b {
  font-family: var(--font-display);
  font-size: 27px; font-weight: 700; line-height: 1; color: #fff;
}
.brand small { display: block; color: var(--side-muted); font-size: 11px; margin-top: 4px; letter-spacing: .2px; }
.office-name {
  margin: 0 18px 10px; padding-bottom: 12px;
  border-bottom: 1px solid var(--side-line);
  color: var(--side-muted); font-size: 11.5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.nav { padding: 4px 0 8px; display: flex; flex-direction: column; flex: 1; }
.nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 8px 15px; min-height: 38px;
  color: var(--side-ink); font-size: 13.5px; text-decoration: none;
  border-inline-start: 3px solid transparent;
}
.nav a svg { color: var(--side-muted); }
.nav a:hover { background: var(--side-line); text-decoration: none; }
.nav a.active {
  background: linear-gradient(to left, rgba(217, 164, 65, .12), transparent 70%);
  border-inline-start-color: var(--gold-on-dark);
  font-weight: 700; color: #fff;
}
.nav a.active svg { color: var(--gold-on-dark); }
.nav .count {
  margin-inline-start: auto; font-size: 12px; font-weight: 700;
  color: var(--gold-on-dark); font-variant-numeric: tabular-nums;
}
.nav .count.hot { color: #0f1c42; background: var(--gold-on-dark); border-radius: 4px; padding: 0 6px; line-height: 18px; }
.side-foot {
  padding: 10px 12px; border-top: 1px solid var(--side-line);
  display: flex; align-items: center; gap: 6px; color: var(--side-muted); font-size: 12px;
}
.side-foot button {
  background: none; border: 0; color: var(--side-muted);
  display: flex; align-items: center; gap: 6px; padding: 5px 7px; border-radius: 4px; font-size: 12px;
}
.side-foot button:hover { color: var(--side-ink); background: var(--side-line); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 22px;
  background: var(--surface);
  border-bottom: 1px solid var(--line-strong);
  position: sticky; top: 0; z-index: 40;
}
.menu-btn { display: none; }
.searchbox { position: relative; flex: 1; max-width: 420px; }
.searchbox input {
  width: 100%; padding: 7px 34px 7px 12px;
  border: 1px solid var(--line-strong); border-radius: var(--r);
  background: var(--bg); color: var(--ink); font-family: inherit; font-size: 13px;
}
.searchbox input:focus { border-color: var(--brand); outline: none; }
.searchbox > svg { position: absolute; top: 50%; right: 10px; transform: translateY(-50%); color: var(--ink-3); }
.search-pop {
  position: absolute; top: calc(100% + 5px); right: 0; left: 0;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r);
  box-shadow: var(--shadow); overflow: hidden; z-index: 60;
}
.search-pop a {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px;
  color: var(--ink); font-size: 13px; border-bottom: 1px solid var(--line);
}
.search-pop a:last-child { border-bottom: 0; }
.search-pop a:hover { background: var(--surface-2); text-decoration: none; }
.search-pop .kind { font-size: 11px; color: var(--brass); margin-inline-start: auto; white-space: nowrap; font-weight: 700; }
.search-pop .empty-line { padding: 10px 12px; color: var(--ink-3); font-size: 13px; }
.topbar .today { color: var(--ink-2); font-size: 12.5px; margin-inline-start: auto; white-space: nowrap; }

/* جرس الإشعارات (نسخة الشركات) */
.notif-wrap { position: relative; }
.notif-badge {
  position: absolute; top: -3px; inset-inline-start: -3px;
  min-width: 17px; height: 17px; border-radius: 99px; padding: 0 4px;
  background: var(--danger); color: #fff; font-size: 10.5px; font-weight: 800;
  display: grid; place-items: center; line-height: 1; pointer-events: none;
  font-variant-numeric: tabular-nums;
}
.notif-pop {
  position: absolute; top: calc(100% + 8px); inset-inline-end: -8px;
  width: min(340px, calc(100vw - 32px));
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r-lg);
  box-shadow: var(--shadow); z-index: 70; overflow: hidden;
}
.notif-pop .np-head {
  display: flex; align-items: center; gap: 8px; padding: 9px 13px;
  border-bottom: 1px solid var(--line-strong); font-size: 13px; font-weight: 800;
}
.notif-pop .np-list { max-height: 330px; overflow-y: auto; }
.nt-item {
  display: flex; gap: 9px; align-items: flex-start; width: 100%;
  padding: 9px 13px; border: 0; border-bottom: 1px solid var(--line);
  background: none; text-align: start; font-family: inherit; font-size: 12.5px;
  color: var(--ink); line-height: 1.55; cursor: pointer;
}
.nt-item:last-child { border-bottom: 0; }
.nt-item:hover { background: var(--surface-2); }
.nt-item.unread { background: var(--brand-soft); }
.nt-item .nt-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--brass); margin-top: 6px; flex-shrink: 0; }
.nt-item.read .nt-dot { background: var(--line-strong); }
.nt-item .nt-when { display: block; color: var(--ink-3); font-size: 11px; margin-top: 1px; }
.np-empty { padding: 20px; text-align: center; color: var(--ink-3); font-size: 12.5px; }

.content { padding: 20px 22px 32px; max-width: 1280px; width: 100%; margin: 0 auto; }

.page-head { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h1 {
  font-family: var(--font-display); font-size: 31px; font-weight: 700; color: var(--ink);
  line-height: 1.25; position: relative; padding-bottom: 10px;
}
.page-head h1::after {
  content: ""; position: absolute; bottom: 0; right: 0;
  width: 44px; height: 3px; background: var(--brass); border-radius: 0;
}
.page-head .sub { color: var(--ink-2); font-size: 13px; }
.page-head .spacer, .spacer { flex: 1; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 6px 13px; min-height: 34px; border-radius: var(--r);
  border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--ink);
  font-size: 13px; font-weight: 700; white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s;
}
.btn:hover { border-color: var(--brand); color: var(--brand); background: var(--surface); }
.btn-primary { background: var(--solid); border-color: var(--solid); color: #fff; }
.btn-primary:hover { background: var(--solid-hover); border-color: var(--solid-hover); color: #fff; }
.btn-danger { color: var(--danger); border-color: var(--danger); background: transparent; }
.btn-danger:hover { background: var(--danger-soft); color: var(--danger); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--brand); border-color: transparent; }
.btn-sm { padding: 3px 9px; min-height: 28px; font-size: 12px; }
.btn-icon { padding: 6px; }
.btn[disabled] { opacity: .5; cursor: default; }

/* ---------- cards / panels ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r-lg);
  padding: 16px 18px;
}
.panel { background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r-lg); overflow: hidden; }
.panel-head {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 14px; border-bottom: 1px solid var(--line-strong);
}
.panel-head h3 {
  font-size: 13.5px; font-weight: 800; color: var(--ink);
  display: flex; align-items: center; gap: 8px;
}
.panel-head h3 svg { color: var(--brass); }
.panel-body { padding: 12px 14px; }

/* شريط الأرقام — سطر ملخص متصل زي دفتر الحساب، مش كروت متناثرة */
.kpis {
  display: flex; flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: var(--r-lg);
  overflow: hidden; margin-bottom: 18px;
}
.kpi {
  flex: 1 1 150px; min-width: 150px;
  background: var(--surface); border: 0; border-radius: 0;
  border-inline-start: 1px solid var(--line); border-top: 1px solid var(--line);
  margin-inline-start: -1px; margin-top: -1px;
  padding: 12px 15px 10px; display: flex; flex-direction: column; gap: 1px;
  cursor: pointer; text-align: start; color: var(--ink);
  transition: background .15s;
}
.kpi:hover { background: var(--surface-2); text-decoration: none; }
.kpi .k-label { font-size: 11.5px; font-weight: 700; color: var(--ink-2); display: flex; align-items: center; gap: 6px; }
.kpi .k-label svg { color: var(--brass); }
.kpi .k-value {
  font-size: 27px; font-weight: 800; color: var(--brand);
  font-variant-numeric: tabular-nums; line-height: 1.25;
}
.kpi .k-foot { font-size: 11px; color: var(--ink-3); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th {
  text-align: start; font-weight: 800; color: var(--ink-2); font-size: 11.5px;
  padding: 8px 11px; border-bottom: 2px solid var(--line-strong); white-space: nowrap;
  background: var(--surface);
}
.tbl td { padding: 8px 11px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr.rowlink { cursor: pointer; }
.tbl tbody tr.rowlink:hover { background: var(--brand-soft); }
.tbl .num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl .actions { white-space: nowrap; text-align: left; }
.tbl .actions .btn { margin-inline-start: 2px; }
.tbl .main-cell b { font-weight: 700; }
.tbl .sub-line { color: var(--ink-3); font-size: 11.5px; margin-top: 1px; }
.tbl td.muted, .muted { color: var(--ink-3); }
.tbl tfoot td { font-weight: 800; border-top: 2px solid var(--line-strong); background: var(--surface-2); }

/* ---------- badges & tags ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 700; border-radius: 4px; padding: 1px 7px 2px;
  white-space: nowrap; border: 1px solid transparent;
}
.b-green { background: var(--ok-soft); color: var(--ok); }
.b-red { background: var(--danger-soft); color: var(--danger); }
.b-amber { background: var(--warn-soft); color: var(--warn); }
.b-blue { background: var(--info-soft); color: var(--info); }
.b-gray { background: var(--surface-2); color: var(--ink-2); }
.b-brass { background: var(--brass-soft); color: var(--brass); }
.b-brand { background: var(--brand-soft); color: var(--brand); }
.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }

/* ---------- filters row ---------- */
.filters { display: flex; gap: 7px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.filters input[type="search"], .filters input[type="text"], .filters input[type="date"], .filters select {
  padding: 6px 10px; min-height: 34px;
  border: 1px solid var(--line-strong); border-radius: var(--r);
  background: var(--surface); color: var(--ink); font-family: inherit; font-size: 13px;
}
.filters input:focus, .filters select:focus { border-color: var(--brand); outline: none; }
.chip {
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink-2);
  padding: 3px 11px; min-height: 28px; border-radius: var(--r); font-size: 12px; font-weight: 700;
  display: inline-flex; align-items: center; gap: 5px;
}
.chip:hover { border-color: var(--brand); color: var(--brand); }
.chip.active { background: var(--solid); border-color: var(--solid); color: #fff; }

/* شريط أدوات موحد — بيلم الفلاتر والبحث في كتلة واحدة حتى على الشاشات العريضة */
.toolbar {
  display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
  background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: var(--r-lg); padding: 8px 10px; margin-bottom: 14px;
}
.toolbar input[type="search"], .toolbar select, .toolbar input[type="date"] {
  padding: 5px 10px; min-height: 30px;
  border: 1px solid var(--line-strong); border-radius: var(--r);
  background: var(--bg); color: var(--ink); font-family: inherit; font-size: 12.5px;
}
.toolbar input:focus, .toolbar select:focus { border-color: var(--brand); outline: none; }
.tool-sep { width: 1px; align-self: stretch; background: var(--line); margin-inline: 4px; }

/* مبدّل عرض (قائمة/تقويم) — شكل مختلف عن شيبات الفلترة */
.seg-sw { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--r); overflow: hidden; }
.seg-sw button {
  display: inline-flex; align-items: center; gap: 6px;
  border: 0; background: var(--surface); color: var(--ink-2);
  padding: 5px 13px; min-height: 30px; font-weight: 700; font-size: 12.5px;
  border-inline-start: 1px solid var(--line);
}
.seg-sw button:first-child { border-inline-start: 0; }
.seg-sw button:hover { color: var(--brand); }
.seg-sw button.active { background: var(--solid); color: #fff; }

/* تاريخ + زراره المرتبط بيه كقطعة واحدة */
.date-join { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--r); overflow: hidden; background: var(--surface); }
.date-join input[type="date"] {
  border: 0; min-height: 32px; padding: 5px 10px;
  background: var(--surface); color: var(--ink); font-family: inherit; font-size: 13px;
}
.date-join input[type="date"]:focus { outline: none; background: var(--brand-soft); }
.date-join .btn { border: 0; border-radius: 0; border-inline-start: 1px solid var(--line); min-height: 32px; }
.date-join select { border: 0; border-inline-end: 1px solid var(--line); min-height: 32px; padding: 5px 10px; background: var(--surface); color: var(--ink); font-family: inherit; font-size: 12.5px; }

/* ---------- forms ---------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 11px 14px; }
.form-grid .full { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field > span { font-size: 12px; color: var(--ink-2); font-weight: 700; }
.field > span .req { color: var(--danger); font-style: normal; }
.field input, .field select, .field textarea {
  padding: 7px 10px; min-height: 36px;
  border: 1px solid var(--line-strong); border-radius: var(--r);
  background: var(--surface); color: var(--ink); font-family: inherit; font-size: 13.5px;
  width: 100%;
}
.field textarea { resize: vertical; min-height: 64px; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--brand); outline: none; box-shadow: 0 0 0 3px var(--brand-soft); }
.hint { font-size: 11.5px; color: var(--ink-3); }
.form-note {
  background: var(--brass-soft); color: var(--ink); border-inline-start: 3px solid var(--brass);
  border-radius: 4px; padding: 8px 12px; font-size: 12.5px;
}

/* ---------- modal ---------- */
.overlay {
  position: fixed; inset: 0; background: rgba(10, 16, 35, .55); z-index: 100;
  display: grid; place-items: center; padding: 18px;
  animation: fadeIn .15s ease;
}
@keyframes fadeIn { from { opacity: 0; } }
.modal {
  background: var(--surface); border-radius: var(--r-lg); border: 1px solid var(--line-strong);
  border-top: 3px solid var(--brass);
  width: 100%; max-width: 560px; max-height: calc(100vh - 40px);
  display: flex; flex-direction: column; box-shadow: var(--shadow);
}
.modal.wide { max-width: 760px; }
.modal-head {
  display: flex; align-items: center; gap: 10px; padding: 13px 18px 11px;
  border-bottom: 1px solid var(--line-strong);
}
.modal-head h3 { font-size: 16.5px; font-weight: 800; font-family: var(--font-display); }
.modal-head .x { margin-inline-start: auto; }
.modal-body { padding: 16px 18px; overflow-y: auto; }
.modal-foot {
  display: flex; gap: 8px; align-items: center; justify-content: flex-start; padding: 11px 18px;
  border-top: 1px solid var(--line-strong); background: var(--surface-2);
  border-radius: 0 0 var(--r-lg) var(--r-lg);
}
.modal-foot .end { margin-inline-start: auto; }

/* ---------- toast ---------- */
#toasts { position: fixed; bottom: 18px; right: 50%; transform: translateX(50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  background: var(--side-bg); color: var(--side-ink); border: 1px solid var(--side-line);
  border-radius: var(--r); padding: 8px 16px; font-size: 13px; box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 8px; animation: toastIn .2s ease;
}
.toast.err { background: var(--danger); border-color: var(--danger); color: #fff; }
.toast svg { color: var(--gold-on-dark); }
.toast.err svg { color: #fff; }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 0; border-bottom: 2px solid var(--line-strong); margin-bottom: 16px; flex-wrap: wrap; }
.tabs button {
  border: 0; background: none; padding: 8px 14px; color: var(--ink-2);
  font-size: 13px; font-weight: 700; border-bottom: 2px solid transparent; margin-bottom: -2px;
}
.tabs button:hover { color: var(--brand); }
.tabs button.active { color: var(--brand); border-bottom-color: var(--brass); font-weight: 800; }

/* ---------- misc blocks ---------- */
.empty {
  text-align: center; padding: 32px 16px; color: var(--ink-3);
  display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.empty svg { color: var(--line-strong); }
.empty b { color: var(--ink-2); font-weight: 700; }

.alert-item {
  display: flex; gap: 10px; padding: 9px 14px; border-bottom: 1px solid var(--line);
  font-size: 12.5px; align-items: flex-start;
}
.alert-item:last-child { border-bottom: 0; }
.alert-item svg { margin-top: 2px; }
.alert-item .t-red { color: var(--danger); }
.alert-item .t-amber { color: var(--warn); }
.alert-item .t-blue { color: var(--info); }
.alert-item a { font-weight: 700; }
.alert-item .when { color: var(--ink-3); font-size: 11.5px; }

.two-col { display: grid; grid-template-columns: 1.6fr 1fr; gap: 14px; align-items: start; }
.two-col.half { grid-template-columns: 1fr 1fr; }
.two-col > * { min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.stack > * { min-width: 0; }

/* صفوف بيانات مسطّرة — مفيش كروت فاضية */
.dl { display: grid; grid-template-columns: auto 1fr; gap: 0 18px; font-size: 13.5px; }
.dl dt { color: var(--ink-3); font-weight: 700; white-space: nowrap; font-size: 12px; padding: 8px 0 7px; border-top: 1px solid var(--line); }
.dl dd { margin: 0; min-width: 0; overflow-wrap: break-word; padding: 7px 0; border-top: 1px solid var(--line); }
.dl dt:first-of-type, .dl dd:first-of-type { border-top: 0; padding-top: 1px; }

.case-title-row { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.money { font-variant-numeric: tabular-nums; white-space: nowrap; }
.money.pos { color: var(--ok); font-weight: 700; }
.money.neg { color: var(--danger); font-weight: 700; }

/* ---------- calendar ---------- */
.cal-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.cal-head b { font-size: 17px; min-width: 130px; text-align: center; font-family: var(--font-display); }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; background: var(--line-strong); border: 1px solid var(--line-strong); border-radius: var(--r); overflow: hidden; }
.cal-dow { text-align: center; font-size: 11px; color: var(--ink-2); font-weight: 800; padding: 6px 0; background: var(--surface-2); }
.cal-cell {
  min-height: 86px; background: var(--surface);
  padding: 4px 6px; font-size: 12px; cursor: pointer;
  display: flex; flex-direction: column; gap: 3px; overflow: hidden;
}
.cal-cell:hover { background: var(--brand-soft); }
.cal-cell .d { font-size: 11px; color: var(--ink-3); font-variant-numeric: tabular-nums; font-weight: 700; }
.cal-cell.out { background: var(--surface-2); cursor: default; }
.cal-cell.today-cell { box-shadow: inset 0 3px 0 var(--brass); background: var(--brass-soft); }
.cal-cell.today-cell .d { color: var(--brass); font-weight: 800; }
.cal-ev {
  background: var(--brand-soft); color: var(--brand); border-radius: 3px;
  border-inline-start: 2px solid var(--brand);
  padding: 1px 5px; font-size: 10.5px; font-weight: 700;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cal-ev.done-ev { background: var(--surface-2); color: var(--ink-3); border-inline-start-color: var(--line-strong); text-decoration: line-through; }
.cal-more { font-size: 10px; color: var(--ink-3); }

/* ---------- login ---------- */
.login-wrap {
  min-height: 100vh; display: grid; place-items: center; padding: 20px;
  background:
    linear-gradient(170deg, var(--side-bg) 0 290px, transparent 290px),
    var(--bg);
}
.login-card {
  width: 100%; max-width: 400px; background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: var(--r-lg); box-shadow: var(--shadow);
  overflow: hidden; display: flex; flex-direction: column;
}
.login-head {
  background: var(--side-bg); color: #fff; text-align: center;
  padding: 26px 24px 20px; border-bottom: 3px solid var(--gold-on-dark);
  display: flex; flex-direction: column; gap: 8px; align-items: center;
}
.login-card .logo-big {
  width: 58px; height: 58px; border-radius: 8px;
  border: 1px solid var(--gold-on-dark); color: var(--gold-on-dark);
  display: grid; place-items: center;
}
.login-card h1 { font-family: var(--font-display); font-size: 38px; line-height: 1.1; color: #fff; }
.login-card .sub { color: var(--side-muted); font-size: 13px; }
.login-body { padding: 22px 24px 20px; display: flex; flex-direction: column; gap: 13px; }
.login-note { font-size: 12px; color: var(--ink-3); text-align: center; }

/* ---------- attachments / docs ---------- */
.file-pill {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px;
  background: var(--surface-2); border: 1px solid var(--line-strong); border-radius: 4px; padding: 2px 8px;
  color: var(--ink-2); cursor: pointer;
}
.file-pill:hover { border-color: var(--brand); color: var(--brand); }
.storage-meter { height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; }
.storage-meter i { display: block; height: 100%; background: var(--brand); border-radius: 3px; }

/* ---------- التقارير ---------- */
.hb-row {
  display: grid; grid-template-columns: fit-content(120px) 1fr 40px;
  gap: 8px; align-items: center; width: 100%;
  padding: 5px 8px; border: 0; background: none; border-radius: 6px;
  font-size: 12.5px; color: var(--ink); font-family: inherit; text-align: start;
}
button.hb-row:hover { background: var(--surface-2); }
button.hb-row .hb-label { color: var(--brand); font-weight: 700; }
.hb-label { color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hb-track { height: 12px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.hb-track i { display: block; height: 100%; border-radius: 4px; }
.hb-val { font-variant-numeric: tabular-nums; text-align: left; font-weight: 800; }

.avatar {
  width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
  background: var(--brand-soft); color: var(--brand);
  display: grid; place-items: center; font-weight: 800; font-size: 14px;
}
.avatar.co { background: var(--brass-soft); color: var(--brass); }
.name-cell { display: flex; gap: 10px; align-items: center; min-width: 0; }
.name-cell > div { min-width: 0; }

.deb-item { display: flex; gap: 10px; align-items: center; padding: 9px 14px; border-bottom: 1px solid var(--line); font-size: 13px; }
.deb-item:last-child { border-bottom: 0; }
.deb-main { flex: 1; min-width: 0; }
.deb-main .ag-sub { white-space: normal; }

.mini-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(105px, 1fr)); }
.mini-stat { text-align: center; padding: 14px 8px 12px; border-inline-start: 1px solid var(--line); border-top: 1px solid var(--line); margin-inline-start: -1px; margin-top: -1px; }
.mini-stat b { display: block; font-size: 24px; font-weight: 800; color: var(--brand); font-variant-numeric: tabular-nums; line-height: 1.2; }
.mini-stat span { font-size: 11px; color: var(--ink-2); font-weight: 700; }

/* ---------- charts ---------- */
.chart-box { padding: 10px 6px 2px; }
.chart-tip {
  position: fixed; z-index: 300; pointer-events: none;
  background: var(--side-bg); color: var(--side-ink); font-size: 12px;
  border-radius: 4px; padding: 5px 10px; box-shadow: var(--shadow); white-space: nowrap;
}
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--ink-2); }
.chart-table { border-top: 1px solid var(--line-strong); }
.legend i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; margin-inline-end: 5px; vertical-align: -1px; }

/* ---------- الرئيسية: أجندة وتنبيهات ---------- */
.notice-bar {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  background: var(--warn-soft); border: 1px solid var(--warn);
  border-radius: var(--r); padding: 8px 14px; font-size: 13px; margin-bottom: 14px;
}
.notice-bar svg { color: var(--warn); flex-shrink: 0; }
.notice-bar a { font-weight: 800; }

.kpi.kpi-gold .k-value { color: var(--brass-strong); }

.ag-day {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 14px; background: var(--surface-2);
  border-bottom: 1px solid var(--line); border-top: 1px solid var(--line);
  font-size: 12.5px; font-weight: 800; color: var(--ink-2);
}
.ag-day:first-child, .panel-head + .ag-day { border-top: 0; }
.ag-item {
  display: flex; gap: 12px; align-items: center;
  padding: 10px 14px; border-bottom: 1px solid var(--line);
}
.ag-item:last-child { border-bottom: 0; }
.ag-time {
  width: 54px; flex-shrink: 0; text-align: center;
  background: var(--brand-soft); color: var(--brand);
  border-radius: var(--r); padding: 6px 0 5px;
  font-weight: 800; font-variant-numeric: tabular-nums; font-size: 14px; line-height: 1.15;
}
.ag-time small { display: block; font-size: 10px; font-weight: 700; }
.ag-time.no-time { background: var(--surface-2); color: var(--ink-3); }
.ag-main { flex: 1; min-width: 0; }
.ag-case { font-weight: 800; font-size: 13.5px; }
.ag-sub { font-size: 12px; color: var(--ink-3); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ag-acts { display: flex; gap: 5px; align-items: center; flex-shrink: 0; }
.ag-empty { padding: 14px; font-size: 12.5px; color: var(--ink-3); }

.al-item {
  display: flex; gap: 10px; align-items: center;
  padding: 8px 14px; border-bottom: 1px solid var(--line); line-height: 1.5;
}
.al-item:last-child { border-bottom: 0; }
.al-chip {
  width: 28px; height: 28px; border-radius: 7px; flex-shrink: 0;
  display: grid; place-items: center;
}
.al-chip.red { background: var(--danger-soft); color: var(--danger); }
.al-chip.amber { background: var(--warn-soft); color: var(--warn); }
.al-chip.blue { background: var(--info-soft); color: var(--info); }
.al-body { flex: 1; min-width: 0; }
.al-title { font-size: 12.5px; font-weight: 800; }
.al-title.t-red { color: var(--danger); }
.al-title.t-amber { color: var(--warn); }
.al-sub { font-size: 11.5px; color: var(--ink-3); margin-top: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.al-item > .btn { flex-shrink: 0; }

.wk-item { display: flex; gap: 10px; align-items: center; padding: 8px 14px; border-bottom: 1px solid var(--line); font-size: 12.5px; }
.wk-item:last-child { border-bottom: 0; }
.wk-date {
  flex-shrink: 0; font-size: 11px; font-weight: 800; color: var(--brand);
  background: var(--brand-soft); border-radius: 5px; padding: 2px 8px;
  font-variant-numeric: tabular-nums;
}
.wk-main { min-width: 0; flex: 1; }
.wk-main .ag-sub { white-space: normal; }

/* ---------- ملف القضية ---------- */
.case-hero {
  background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: var(--r-lg); overflow: hidden; margin-bottom: 16px;
}
.ch-top { display: flex; gap: 14px; flex-wrap: wrap; align-items: flex-start; padding: 16px 18px 13px; }
.ch-title { font-family: var(--font-display); font-size: 29px; font-weight: 700; line-height: 1.2; }
.ch-sub { color: var(--ink-2); font-size: 13px; margin-top: 3px; }
.ch-actions { margin-inline-start: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--r); overflow: hidden; }
.seg .btn { border: 0; border-radius: 0; border-inline-start: 1px solid var(--line); }
.seg .btn:first-child { border-inline-start: 0; }
.ch-facts { display: flex; flex-wrap: wrap; border-top: 1px solid var(--line-strong); }
.ch-fact {
  flex: 1 1 180px; min-width: 0; padding: 9px 16px 10px;
  border-inline-start: 1px solid var(--line); border-top: 1px solid var(--line);
  margin-inline-start: -1px; margin-top: -1px;
}
.ch-fact .f-l { display: block; font-size: 10.5px; font-weight: 800; color: var(--ink-3); margin-bottom: 1px; }
.ch-fact .f-v { font-size: 13.5px; font-weight: 700; }
.ch-fact .f-s { font-size: 11.5px; color: var(--ink-3); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.case-cols { grid-template-columns: 1.7fr 1fr; }
.judgment-box {
  background: var(--brass-soft); border-inline-start: 3px solid var(--brass);
  border-radius: 4px; padding: 9px 12px; font-size: 13px; margin-top: 10px;
}
.subject-p { font-size: 13.5px; line-height: 1.7; }
.tbl .btn-ghost { opacity: .5; }
.tbl tr:hover .btn-ghost, .tbl .btn-ghost:focus-visible { opacity: 1; }
.tbl tr.today-row td:first-child { box-shadow: inset -3px 0 0 var(--brass); }
.badge.b-today { background: var(--brass); color: var(--brass-ink); }

/* ---------- يوم المحكمة ---------- */
.cd-court {
  display: flex; align-items: center; gap: 8px;
  font-family: var(--font-display); font-size: 19px; font-weight: 700; color: var(--brand);
  margin: 20px 0 10px; padding-bottom: 6px; border-bottom: 2px solid var(--line-strong);
}
.cd-court svg { color: var(--brass); }
.cd-court .muted { font-family: var(--font-ui); font-size: 12.5px; font-weight: 400; }
.cd-card {
  background: var(--surface); border: 1px solid var(--line-strong);
  border-inline-start: 4px solid var(--brand);
  border-radius: var(--r-lg); padding: 14px 16px; margin-bottom: 12px;
}
.cd-card.cd-done { border-inline-start-color: var(--line-strong); opacity: .75; }
.cd-top { display: flex; align-items: flex-start; gap: 10px; justify-content: space-between; flex-wrap: wrap; margin-bottom: 10px; }
.cd-case { font-family: var(--font-display); font-size: 21px; font-weight: 700; line-height: 1.3; }
.cd-sub { font-size: 12px; color: var(--ink-2); }
.cd-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 18px; font-size: 13.5px; }
.cd-l { display: block; font-size: 11px; font-weight: 800; color: var(--ink-3); margin-bottom: 1px; }
.cd-hist { margin-top: 10px; padding-top: 8px; border-top: 1px dashed var(--line); font-size: 12.5px; color: var(--ink-2); }
.cd-foot { margin-top: 10px; font-size: 12.5px; }
@media (max-width: 700px) { .cd-grid { grid-template-columns: 1fr; } }

/* ---------- النماذج الجاهزة ---------- */
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.tpl-card {
  display: flex; flex-direction: column; align-items: flex-start; gap: 7px;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r-lg);
  padding: 16px; text-align: start; color: var(--ink); font-family: inherit;
  transition: border-color .15s;
}
.tpl-card:hover { border-color: var(--brand); }
.tpl-card .tpl-ic {
  width: 42px; height: 42px; border-radius: 7px; display: grid; place-items: center;
  background: var(--brand-soft); color: var(--brand);
}
.tpl-card b { font-size: 15px; font-weight: 800; }
.tpl-card .tpl-desc { font-size: 12.5px; color: var(--ink-2); line-height: 1.55; }
.tpl-card .tpl-go { font-size: 12px; font-weight: 800; color: var(--brass); margin-top: 2px; }

.pick-list { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; max-height: 180px; overflow-y: auto; border: 1px solid var(--line); border-radius: var(--r); padding: 8px 10px; }
.pick-item { display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }
.pick-item input { width: auto; }

/* زرار واتساب */
.wa-btn, .wa-btn:hover { color: #1da851; }
a.btn .wa-icon, .btn svg + span { vertical-align: middle; }
a.btn { text-decoration: none; }

/* ---------- print ---------- */
#printRoot { display: none; }
.print-sheet { background: #fff; color: #111; font-family: var(--font-ui); }
.print-preview-body { background: var(--surface-2); padding: 18px; overflow-y: auto; }
.print-preview-body .print-sheet {
  box-shadow: 0 2px 14px rgba(0, 0, 0, .22); margin: 0 auto; max-width: 740px;
  padding: 34px 38px; border-radius: 2px;
}
.ph-head { display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 3px double #1e3a8a; padding-bottom: 10px; margin-bottom: 4px; }
.ph-head .o-name { font-family: var(--font-display); font-size: 24px; font-weight: 700; color: #1e3a8a; }
.ph-head .o-sub { font-size: 11.5px; color: #555; margin-top: 2px; }
.ph-head .o-meta { text-align: left; font-size: 11.5px; color: #555; }
.ph-title { text-align: center; font-family: var(--font-display); font-size: 22px; font-weight: 700; margin: 16px 0 4px; color: #111; }
.ph-sub { text-align: center; font-size: 12.5px; color: #444; margin-bottom: 14px; }
.print-sheet table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.print-sheet th, .print-sheet td { border: 1px solid #9aa3b5; padding: 6px 8px; text-align: start; vertical-align: top; }
.print-sheet th { background: #edf1f7; font-weight: 700; color: #1e3a8a; white-space: nowrap; }
.print-sheet .no-border td { border: 0; padding: 3px 0; }
.print-sheet .sign-row { display: flex; justify-content: space-between; margin-top: 38px; font-size: 13px; }
.print-sheet .sign-row .sig { text-align: center; }
.print-sheet .sig .line { margin-top: 34px; border-top: 1px dotted #777; padding-top: 4px; min-width: 150px; }
.print-sheet .amount-words { background: #f9f0e3; border: 1px dashed #b45309; border-radius: 3px; padding: 8px 12px; margin: 10px 0; font-weight: 700; }
.print-sheet .foot-note { margin-top: 18px; font-size: 10.5px; color: #777; text-align: center; border-top: 1px solid #ddd; padding-top: 6px; }
.print-sheet h4 { margin: 14px 0 6px; font-size: 14px; color: #1e3a8a; }
.print-sheet .meta-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 3px 24px; font-size: 12.5px; margin-bottom: 8px; }
.print-sheet .meta-grid b { color: #333; }

@media print {
  body { background: #fff; }
  .shell, #toasts, .overlay { display: none !important; }
  #printRoot { display: block !important; }
  #printRoot .print-sheet { padding: 0; }
  @page { margin: 14mm 12mm; }
}

/* ---------- responsive ---------- */
@media (max-width: 960px) {
  .two-col, .two-col.half { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .sidebar {
    position: fixed; inset-block: 0; right: 0; z-index: 90; transform: translateX(100%);
    transition: transform .18s ease; width: 250px; height: 100vh; height: 100dvh;
  }
  body.nav-open .sidebar { transform: none; box-shadow: -8px 0 30px rgba(0, 0, 0, .35); }
  .menu-btn { display: inline-flex; }
  .content { padding: 14px 14px 28px; }
  .topbar { padding-inline: 14px; }
  .topbar .today { display: none; }
  .page-head h1 { font-size: 25px; }
  .cal-cell { min-height: 56px; }
  .kpi .k-value { font-size: 21px; }
}
.scrim { display: none; }
body.nav-open .scrim { display: block; position: fixed; inset: 0; z-index: 80; background: rgba(10, 16, 35, .45); }
