/* ================= نظام إدارة مكتب المحاماة ================= */
:root {
  --bg: #f4f5f8;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --border: #e4e7ee;
  --text: #18223a;
  --muted: #6b7489;
  --primary: #1d3a6e;
  --primary-ink: #ffffff;
  --primary-soft: #e8eef9;
  --gold: #b8912a;
  --gold-soft: #f8f1dc;
  --side: #0f1b33;
  --side-2: #17264a;
  --side-text: #c6cde0;
  --ok: #1f8a5a;   --ok-soft: #e3f4ec;
  --warn: #b7741a; --warn-soft: #fbf0de;
  --bad: #c0392b;  --bad-soft: #fbe6e3;
  --info: #2c6bc4; --info-soft: #e5effc;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 4px 16px rgba(16, 24, 40, .05);
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1322; --surface: #151d31; --surface-2: #1a2339; --border: #26314c; --text: #e6e9f2; --muted: #8e98b0;
    --primary: #6f9cf0; --primary-ink: #0b1220; --primary-soft: #1c2a4a; --gold: #d9b65a; --gold-soft: #2c2817;
    --side: #0a0f1c; --side-2: #141c30; --ok: #4cc38a; --ok-soft: #15301f; --warn: #e3a04a; --warn-soft: #33270f;
    --bad: #ef6b5d; --bad-soft: #3a1916; --info: #6ea5f5; --info-soft: #16264a; --shadow: 0 1px 2px rgba(0,0,0,.3); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d1322; --surface: #151d31; --surface-2: #1a2339; --border: #26314c; --text: #e6e9f2; --muted: #8e98b0;
  --primary: #6f9cf0; --primary-ink: #0b1220; --primary-soft: #1c2a4a; --gold: #d9b65a; --gold-soft: #2c2817;
  --side: #0a0f1c; --side-2: #141c30; --ok: #4cc38a; --ok-soft: #15301f; --warn: #e3a04a; --warn-soft: #33270f;
  --bad: #ef6b5d; --bad-soft: #3a1916; --info: #6ea5f5; --info-soft: #16264a; --shadow: 0 1px 2px rgba(0,0,0,.3); color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font: 15px/1.6 "IBM Plex Sans Arabic", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.3; }
h1 { font-size: 1.55rem; font-weight: 700; }
h2 { font-size: 1.05rem; font-weight: 600; }
h3 { font-size: 1rem; font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.num { font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; display: inline-block; }
button, input, select, textarea { font: inherit; color: inherit; }
svg.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- boot / auth ---------- */
.boot { min-height: 100vh; display: grid; place-items: center; }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--border); border-top-color: var(--gold); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.auth {
  min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr;
}
.auth-art {
  background: radial-gradient(circle at 20% 20%, #23407a 0, transparent 55%), linear-gradient(160deg, #0f1b33, #0a1224);
  color: #e9ecf5; padding: 56px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden;
}
.auth-art::after {
  content: ""; position: absolute; inset: auto -120px -120px auto; width: 420px; height: 420px; border-radius: 50%;
  border: 1px solid rgba(212, 175, 55, .25); box-shadow: 0 0 0 60px rgba(212,175,55,.04), 0 0 0 120px rgba(212,175,55,.03);
}
.auth-art h1 { font-family: Amiri, serif; font-size: 2.6rem; color: #e8c766; }
.auth-art p { color: #aeb8d3; max-width: 420px; font-size: 1.05rem; }
.auth-art ul { list-style: none; padding: 0; margin: 28px 0 0; display: grid; gap: 12px; color: #cdd4e6; }
.auth-art li { display: flex; gap: 10px; align-items: center; }
.auth-art li svg { color: #d4af37; }
.auth-form { display: grid; place-items: center; padding: 32px 20px; }
.auth-form form { width: 100%; max-width: 380px; display: grid; gap: 16px; }
.auth-form h2 { font-size: 1.5rem; }
.brand-mark { width: 52px; height: 52px; border-radius: 14px; background: var(--side); display: grid; place-items: center; }
.brand-mark svg { width: 30px; height: 30px; stroke: #d4af37; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 252px 1fr; min-height: 100vh; }
.side {
  background: var(--side); color: var(--side-text); position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; padding: 18px 12px; gap: 6px; overflow-y: auto;
}
.side .brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; border-bottom: 1px solid rgba(255,255,255,.07); margin-bottom: 8px; }
.side .brand .brand-mark { width: 40px; height: 40px; border-radius: 11px; background: var(--side-2); }
.side .brand .brand-mark svg { width: 22px; height: 22px; }
.side .brand b { color: #fff; font-family: Amiri, serif; font-size: 1.15rem; display: block; line-height: 1.2; }
.side .brand small { color: #8591ad; font-size: .75rem; }
.side nav { display: grid; gap: 2px; }
.side nav .sep { font-size: .72rem; color: #6c7795; padding: 14px 12px 4px; letter-spacing: .02em; }
.side nav a {
  display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 10px; color: var(--side-text); font-weight: 500;
}
.side nav a:hover { background: rgba(255,255,255,.05); text-decoration: none; color: #fff; }
.side nav a.active { background: var(--side-2); color: #fff; box-shadow: inset -3px 0 0 #d4af37; }
.side nav a.active svg { color: #d4af37; }
.side nav a .count { margin-inline-start: auto; background: #d4af37; color: #1a1406; border-radius: 99px; font-size: .72rem; padding: 0 7px; font-weight: 700; }
.side .me { margin-top: auto; border-top: 1px solid rgba(255,255,255,.07); padding: 14px 6px 0; display: flex; gap: 10px; align-items: center; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: linear-gradient(135deg, #d4af37, #a3801f); color: #1a1406; display: grid; place-items: center; font-weight: 700; flex: none; }
.side .me .who { flex: 1; min-width: 0; }
.side .me .who b { color: #fff; display: block; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side .me .who small { color: #8591ad; }
.side .icon-btn { color: var(--side-text); }

.main-wrap { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(8px);
  display: flex; align-items: center; gap: 12px; padding: 12px 28px; border-bottom: 1px solid var(--border);
}
.search { position: relative; flex: 1; max-width: 520px; }
.search input { width: 100%; padding: 9px 40px 9px 14px; border-radius: 11px; border: 1px solid var(--border); background: var(--surface); }
.search > svg { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search-results {
  position: absolute; top: calc(100% + 6px); inset-inline: 0; background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: var(--shadow); padding: 6px; max-height: 60vh; overflow: auto; display: none;
}
.search-results.open { display: block; }
.search-results .grp { font-size: .75rem; color: var(--muted); padding: 6px 10px 2px; }
.search-results a { display: block; padding: 8px 10px; border-radius: 8px; color: var(--text); }
.search-results a:hover, .search-results a.hl { background: var(--primary-soft); text-decoration: none; }
.search-results small { color: var(--muted); display: block; }
.top-actions { display: flex; gap: 6px; margin-inline-start: auto; }
.menu-btn { display: none; }

main#view { padding: 26px 28px 60px; max-width: 1400px; width: 100%; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.crumbs { font-size: .85rem; color: var(--muted); margin-bottom: 6px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--border); background: var(--surface);
  padding: 8px 14px; border-radius: 10px; cursor: pointer; font-weight: 500; white-space: nowrap; transition: background .15s, border-color .15s;
}
.btn:hover { border-color: color-mix(in srgb, var(--primary) 40%, var(--border)); text-decoration: none; }
.btn.primary { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.gold { background: var(--gold); color: #1a1406; border-color: var(--gold); }
.btn.danger { color: var(--bad); }
.btn.danger:hover { background: var(--bad-soft); border-color: var(--bad); }
.btn.sm { padding: 4px 10px; font-size: .85rem; border-radius: 8px; }
.btn:disabled { opacity: .6; cursor: wait; }
.icon-btn { background: none; border: 0; padding: 7px; border-radius: 9px; cursor: pointer; display: inline-grid; place-items: center; color: var(--muted); }
.icon-btn:hover { background: var(--primary-soft); color: var(--text); }

/* ---------- cards / stats ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card > header { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 15px 18px; border-bottom: 1px solid var(--border); }
.card > .body { padding: 16px 18px; }
.card > .body.flush { padding: 0; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.grid-3 { display: grid; grid-template-columns: 2fr 1fr; gap: 18px; }
.stack { display: grid; gap: 18px; grid-template-columns: minmax(0, 1fr); }
.grid-2 > *, .grid-3 > *, .stack > * { min-width: 0; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 4px; color: var(--text); position: relative; overflow: hidden;
}
a.stat:hover { text-decoration: none; border-color: color-mix(in srgb, var(--primary) 35%, var(--border)); }
.stat .lbl { color: var(--muted); font-size: .85rem; display: flex; align-items: center; gap: 8px; }
.stat .lbl svg { color: var(--gold); }
.stat .val { font-size: 1.85rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat .sub { font-size: .8rem; color: var(--muted); }
.stat.warn { background: linear-gradient(0deg, var(--warn-soft), var(--surface) 70%); border-color: color-mix(in srgb, var(--warn) 35%, var(--border)); }
.stat.warn .val { color: var(--warn); }
.stat.money .val { font-size: 1.35rem; }

/* ---------- table ---------- */
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; }
table.t th { text-align: start; font-weight: 600; font-size: .8rem; color: var(--muted); padding: 10px 14px; background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap; }
table.t td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.t tr:last-child td { border-bottom: 0; }
table.t tr[data-href] { cursor: pointer; }
table.t tr[data-href]:hover td { background: var(--primary-soft); }
table.t td.actions-cell { white-space: nowrap; text-align: end; }
table.t td b { font-weight: 600; }
.empty { padding: 36px 20px; text-align: center; color: var(--muted); }
.empty svg { width: 34px; height: 34px; color: var(--border); display: block; margin: 0 auto 8px; }

/* ---------- badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 10px; border-radius: 99px; font-size: .78rem; font-weight: 600; background: var(--surface-2); color: var(--muted); white-space: nowrap; border: 1px solid var(--border); }
.badge.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.badge.info { background: var(--info-soft); color: var(--info); border-color: transparent; }
.badge.gold { background: var(--gold-soft); color: var(--gold); border-color: transparent; }

/* ---------- filters ---------- */
.filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; align-items: center; }
.filters input, .filters select, .field input, .field select, .field textarea {
  padding: 9px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); min-width: 0;
}
.filters input[type="search"] { flex: 1; min-width: 200px; max-width: 360px; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--primary) 45%, transparent); outline-offset: 0; border-color: var(--primary); }
.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--border); border-radius: 11px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: none; padding: 6px 13px; border-radius: 8px; cursor: pointer; color: var(--muted); font-weight: 500; }
.seg button.on { background: var(--primary); color: var(--primary-ink); }

/* ---------- forms / modal ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.field { display: grid; gap: 5px; }
.field.full { grid-column: 1 / -1; }
.field > span { font-size: .85rem; font-weight: 500; color: var(--muted); }
.field > span b { color: var(--bad); }
.field textarea { min-height: 84px; resize: vertical; }
.field small { color: var(--muted); font-size: .78rem; }
.field input[type="date"], .field input[type="time"], .field input[type="number"], .field input[type="tel"] { direction: rtl; text-align: right; }

.modal-back { position: fixed; inset: 0; background: rgba(8, 13, 26, .55); display: grid; place-items: center; z-index: 100; padding: 16px; animation: fade .15s; }
.modal { background: var(--surface); border-radius: 16px; width: 100%; max-width: 620px; max-height: calc(100vh - 32px); display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,.3); animation: pop .18s; }
.modal.wide { max-width: 880px; }
.modal.narrow { max-width: 440px; }
.modal > header { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-body { padding: 18px 20px; overflow-y: auto; }
.modal > footer { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-start; gap: 8px; flex-direction: row-reverse; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }

#toasts { position: fixed; bottom: 20px; left: 20px; display: grid; gap: 8px; z-index: 200; }
.toast { background: var(--text); color: var(--bg); padding: 11px 16px; border-radius: 11px; box-shadow: var(--shadow); max-width: 360px; animation: pop .2s; transition: opacity .3s, transform .3s; }
.toast.err { background: var(--bad); color: #fff; }
.toast.out { opacity: 0; transform: translateY(6px); }

/* ---------- lists ---------- */
.list { display: grid; grid-template-columns: minmax(0, 1fr); }
.list .row { display: flex; gap: 12px; align-items: center; padding: 12px 18px; border-bottom: 1px solid var(--border); color: var(--text); }
.list .row:last-child { border-bottom: 0; }
a.row:hover { background: var(--primary-soft); text-decoration: none; }
.row .grow { flex: 1; min-width: 0; }
.row .grow > b { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .grow > small { color: var(--muted); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.datechip { width: 52px; flex: none; text-align: center; border-radius: 11px; background: var(--primary-soft); color: var(--primary); padding: 5px 0; line-height: 1.15; }
.datechip b { font-size: 1.2rem; display: block; }
.datechip small { font-size: .7rem; }
.datechip.today { background: var(--gold); color: #1a1406; }
.daygroup { padding: 8px 18px; background: var(--surface-2); font-size: .8rem; font-weight: 600; color: var(--muted); border-bottom: 1px solid var(--border); }

.bars { display: grid; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 120px 1fr 40px; gap: 10px; align-items: center; font-size: .88rem; }
.bar-track { height: 9px; background: var(--surface-2); border-radius: 99px; overflow: hidden; border: 1px solid var(--border); }
.bar-fill { height: 100%; background: var(--primary); border-radius: 99px; }

.chart { display: flex; align-items: flex-end; gap: 8px; height: 200px; padding: 10px 4px 0; }
.chart .col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; min-width: 0; }
.chart .pair { flex: 1; width: 100%; display: flex; align-items: flex-end; justify-content: center; gap: 3px; }
.chart .b { width: 42%; max-width: 18px; border-radius: 5px 5px 0 0; min-height: 2px; }
.chart .b.in { background: var(--primary); }
.chart .b.out { background: var(--gold); }
.chart small { font-size: .7rem; color: var(--muted); white-space: nowrap; }
.legend { display: flex; gap: 16px; font-size: .82rem; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-inline-end: 6px; vertical-align: middle; }

/* ---------- detail ---------- */
.hero { padding: 20px 22px; display: grid; gap: 14px; }
.hero-top { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; align-items: flex-start; }
.hero h1 { font-size: 1.4rem; }
.kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px 22px; }
.kv div small { display: block; color: var(--muted); font-size: .78rem; }
.kv div span { font-weight: 500; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin: 22px 0 16px; overflow-x: auto; overflow-y: hidden; scrollbar-width: thin; }
.tabs button { background: none; border: 0; padding: 10px 14px; cursor: pointer; color: var(--muted); font-weight: 500; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs button.on { color: var(--text); border-bottom-color: var(--gold); }
.tabs button .c { background: var(--surface-2); border: 1px solid var(--border); border-radius: 99px; font-size: .72rem; padding: 0 7px; margin-inline-start: 4px; }
.money-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 16px; }
.money-strip > div { background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; }
.money-strip small { color: var(--muted); display: block; font-size: .8rem; }
.money-strip b { font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.pos { color: var(--ok); } .neg { color: var(--bad); }

.timeline { display: grid; gap: 0; padding: 6px 18px; }
.tl { display: grid; grid-template-columns: 18px 1fr; gap: 12px; position: relative; padding: 10px 0; }
.tl::before { content: ""; position: absolute; right: 8px; top: 0; bottom: 0; width: 2px; background: var(--border); }
.tl:first-child::before { top: 18px; } .tl:last-child::before { bottom: calc(100% - 18px); }
.tl .dot { width: 18px; height: 18px; border-radius: 50%; background: var(--surface); border: 3px solid var(--primary); margin-top: 3px; position: relative; z-index: 1; }
.tl.done .dot { border-color: var(--ok); background: var(--ok); }
.tl.late .dot { border-color: var(--warn); }
.tl .tl-body { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.tl .decision { margin-top: 4px; padding: 8px 12px; background: var(--surface-2); border-radius: 9px; border-inline-start: 3px solid var(--ok); font-size: .92rem; }

/* ---------- calendar ---------- */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-top: 1px solid var(--border); border-inline-start: 1px solid var(--border); }
.cal .dow { padding: 8px; text-align: center; font-size: .8rem; color: var(--muted); font-weight: 600; background: var(--surface-2); border-inline-end: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.cal .day { min-height: 112px; padding: 6px; border-inline-end: 1px solid var(--border); border-bottom: 1px solid var(--border); cursor: pointer; display: flex; flex-direction: column; gap: 3px; min-width: 0; background: var(--surface); }
.cal .day:hover { background: var(--primary-soft); }
.cal .day.other { background: var(--surface-2); color: var(--muted); }
.cal .day .n { font-weight: 600; font-size: .85rem; width: 26px; height: 26px; display: grid; place-items: center; border-radius: 50%; }
.cal .day.today .n { background: var(--gold); color: #1a1406; }
.cal .ev { font-size: .74rem; padding: 2px 6px; border-radius: 6px; background: var(--primary-soft); color: var(--primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal .ev.done { background: var(--ok-soft); color: var(--ok); }
.cal .ev.task { background: var(--gold-soft); color: var(--gold); }
.cal .more { font-size: .72rem; color: var(--muted); }
.cal .day .dots { display: none; gap: 3px; flex-wrap: wrap; }
.cal .day .dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--primary); }

/* ---------- kanban ---------- */
.kanban { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; align-items: start; }
.kcol { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; min-height: 300px; transition: background .15s; }
.kcol.over { background: var(--primary-soft); border-color: var(--primary); }
.kcol > h3 { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; padding: 0 4px; font-size: .95rem; }
.kcard { background: var(--surface); border: 1px solid var(--border); border-radius: 11px; padding: 11px 12px; margin-bottom: 9px; cursor: grab; box-shadow: var(--shadow); display: grid; gap: 6px; }
.kcard:active { cursor: grabbing; }
.kcard.dragging { opacity: .5; }
.kcard .meta { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; font-size: .8rem; color: var(--muted); }
.kcard .k-actions { display: flex; gap: 4px; justify-content: flex-end; }
.prio-urgent { border-inline-start: 4px solid var(--bad); }
.prio-high { border-inline-start: 4px solid var(--warn); }

.banner { display: flex; gap: 14px; align-items: center; justify-content: space-between; padding: 16px 18px; border-radius: var(--radius); background: linear-gradient(90deg, var(--gold-soft), var(--surface)); border: 1px solid color-mix(in srgb, var(--gold) 35%, var(--border)); margin-bottom: 18px; flex-wrap: wrap; }

.doc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; padding: 16px; }
.doc { border: 1px solid var(--border); border-radius: 12px; padding: 12px; display: flex; gap: 10px; align-items: center; background: var(--surface); }
.doc .ico { width: 40px; height: 40px; border-radius: 10px; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; flex: none; font-size: .7rem; font-weight: 700; }
.doc .grow { min-width: 0; flex: 1; }
.doc .grow b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; font-size: .9rem; }
.doc .grow small { color: var(--muted); font-size: .75rem; }
.dropzone { border: 2px dashed var(--border); border-radius: 12px; padding: 22px; text-align: center; color: var(--muted); cursor: pointer; }
.dropzone.over { border-color: var(--primary); background: var(--primary-soft); }

/* ---------- print ---------- */
#print-area { display: none; }
@media print {
  body.printing > *:not(#print-area) { display: none !important; }
  body.printing #print-area { display: block; }
  body { background: #fff; color: #000; font-size: 12pt; }
  @page { size: A4; margin: 14mm; }
}
.print-doc { font-family: "IBM Plex Sans Arabic", sans-serif; color: #000; }
.print-doc .ph { display: flex; justify-content: space-between; align-items: flex-end; border-bottom: 3px double #000; padding-bottom: 10px; margin-bottom: 14px; }
.print-doc .ph h1 { font-family: Amiri, serif; font-size: 22pt; }
.print-doc .ph h2 { font-family: Amiri, serif; font-size: 18pt; }
.print-doc .ph p { margin: 2px 0 0; font-size: 10pt; }
.ptable { width: 100%; border-collapse: collapse; font-size: 10pt; }
.ptable th, .ptable td { border: 1px solid #000; padding: 6px 7px; text-align: right; vertical-align: top; }
.ptable th { background: #eee; }
.ptable td.blank { min-width: 140px; }
.receipt { border: 2px solid #000; padding: 18px 22px; border-radius: 8px; max-width: 680px; margin: 0 auto; }
.receipt .line { display: flex; gap: 10px; border-bottom: 1px dotted #000; padding: 9px 0; }
.receipt .line b { min-width: 130px; }
.receipt .sign { display: flex; justify-content: space-between; margin-top: 40px; }

/* ---------- bottom nav (phones) ---------- */
.bottom-nav { display: none; }
@media (max-width: 860px) {
  .bottom-nav {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; inset: auto 0 0 0; z-index: 40;
    background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(10px);
    border-top: 1px solid var(--border); padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  .bottom-nav a, .bottom-nav button {
    display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 0; color: var(--muted);
    font-size: .7rem; font-weight: 500; background: none; border: 0; cursor: pointer; border-radius: 10px;
  }
  .bottom-nav a:hover { text-decoration: none; }
  .bottom-nav svg.i { width: 22px; height: 22px; }
  .bottom-nav a.active { color: var(--primary); }
  .bottom-nav a.active svg { stroke-width: 2.2; }
  main#view { padding-bottom: 96px; }
  #toasts { bottom: 84px; left: 16px; right: 16px; }
  .modal-back { place-items: end center; padding: 0; }
  .modal { max-width: 100% !important; border-radius: 18px 18px 0 0; max-height: 92vh; animation: sheet .22s; }
  @keyframes sheet { from { transform: translateY(40px); opacity: 0; } }
  .page-head .actions .btn { flex: 1; justify-content: center; }
  .page-head .actions { width: 100%; }
  .filters > * { flex: 1 1 140px; }
  .filters input[type="search"] { max-width: none; flex-basis: 100%; }
  .topbar .search { max-width: none; }
  .kv { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; }
  .tabs { scrollbar-width: none; }
  .tabs::-webkit-scrollbar { display: none; }
  .hero { padding: 16px; }
  .hero-top .actions { width: 100%; }
  /* الجداول تتحول لبطاقات على الموبايل */
  table.t thead { display: none; }
  table.t, table.t tbody { display: block; }
  table.t tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 14px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
  table.t tr:last-child { border-bottom: 0; }
  table.t td { display: block; padding: 0; border: 0; min-width: 0; overflow-wrap: anywhere; }
  table.t td[data-label]:not([data-label=""])::before { content: attr(data-label); display: block; font-size: .72rem; color: var(--muted); margin-bottom: 2px; }
  table.t td.actions-cell { grid-column: 1 / -1; text-align: start; border-top: 1px dashed var(--border); padding-top: 8px; }
  table.t td.actions-cell:empty { display: none; }
  table.t td.hide-sm { display: none; }
  table.t tr[data-href]:hover td { background: none; }
  table.t tr[data-href]:active { background: var(--primary-soft); }
}

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 0 0 auto; width: 270px; z-index: 60; display: none; }
  .shell.nav-open .side { display: flex; box-shadow: -20px 0 60px rgba(0,0,0,.35); animation: slidein .2s; }
  @keyframes slidein { from { transform: translateX(100%); } }
  .shell.nav-open::after { content: ""; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 50; }
  .menu-btn { display: inline-grid; }
  .topbar { padding: 10px 16px; }
  main#view { padding: 18px 16px 50px; }
  .auth { grid-template-columns: 1fr; }
  .auth-art { display: none; }
  .form-grid { grid-template-columns: 1fr; }
  .kanban { grid-template-columns: 1fr; }
  .cal .day { min-height: 64px; }
  .cal .ev { display: none; }
  .cal .day .dots { display: flex; }
  h1 { font-size: 1.3rem; }
  .bar-row { grid-template-columns: 90px 1fr 32px; }
  .hide-sm { display: none; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat { padding: 12px 14px; }
  .stat .val { font-size: 1.5rem; }
  .stat.money .val { font-size: 1.05rem; }
}
