/* J1 — النظام الإداري المتكامل */

:root {
  --bg: #f3f2ee;
  --surface: #ffffff;
  --surface-2: #f8f7f3;
  --ink: #1b1c1f;
  --ink-2: #44474d;
  --muted: #74777e;
  --line: #e4e2da;
  --line-2: #d3d0c6;
  --brand: #0e6b5c;
  --brand-ink: #ffffff;
  --brand-soft: #e2f0ec;
  --red: #b3391f;
  --red-soft: #fbe8e3;
  --amber: #9a5b0b;
  --amber-soft: #fcf0d9;
  --amber-bar: #d99a2b;
  --green: #28734a;
  --green-soft: #e3f2e8;
  --shadow: 0 1px 2px rgb(20 20 15 / 5%), 0 4px 16px rgb(20 20 15 / 5%);
  --shadow-lg: 0 20px 60px rgb(10 10 5 / 22%);
  --radius: 14px;
  --radius-sm: 9px;
  --font: 'IBM Plex Sans Arabic', 'Segoe UI', Tahoma, sans-serif;
  --mono: ui-monospace, 'SF Mono', Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #0f1113; --surface: #171a1d; --surface-2: #1c2024; --ink: #ecebe6; --ink-2: #c4c3be; --muted: #8c9096;
    --line: #262a2f; --line-2: #343a40; --brand: #3fb49c; --brand-ink: #062019; --brand-soft: #13352f;
    --red: #f0866f; --red-soft: #3a1c16; --amber: #e8b45e; --amber-soft: #33270f; --amber-bar: #e0a33e; --green: #6ccb91; --green-soft: #15301f;
    --shadow: 0 1px 2px rgb(0 0 0 / 30%); --shadow-lg: 0 20px 60px rgb(0 0 0 / 55%);
    color-scheme: dark;
  }
}
:root[data-theme='dark'] {
  --bg: #0f1113; --surface: #171a1d; --surface-2: #1c2024; --ink: #ecebe6; --ink-2: #c4c3be; --muted: #8c9096;
  --line: #262a2f; --line-2: #343a40; --brand: #3fb49c; --brand-ink: #062019; --brand-soft: #13352f;
  --red: #f0866f; --red-soft: #3a1c16; --amber: #e8b45e; --amber-soft: #33270f; --amber-bar: #e0a33e; --green: #6ccb91; --green-soft: #15301f;
  --shadow: 0 1px 2px rgb(0 0 0 / 30%); --shadow-lg: 0 20px 60px rgb(0 0 0 / 55%);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 15px; line-height: 1.6;
  -webkit-font-smoothing: antialiased; font-variant-numeric: tabular-nums;
}
body.no-scroll { overflow: hidden; }
h1, h2, h3 { margin: 0; line-height: 1.3; }
a { color: var(--brand); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.ic { width: 18px; height: 18px; flex: none; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.pad { padding: 16px 18px; margin: 0; }
.print-only { display: none; }

/* ---------- البدء ---------- */
.boot { min-height: 100vh; display: grid; place-items: center; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--line-2); border-top-color: var(--brand); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- الأزرار ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 8px 16px;
  border-radius: var(--radius-sm); border: 1px solid transparent; font-weight: 600; font-size: 14px; white-space: nowrap;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--brand); color: var(--brand-ink); }
.btn-primary:hover:not(:disabled) { filter: brightness(1.08); }
.btn-ghost { background: var(--surface); border-color: var(--line-2); color: var(--ink); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); }
.btn-danger { background: var(--red); color: #fff; }
.btn-block { width: 100%; }
.btn-sm { min-height: 34px; padding: 5px 12px; font-size: 13px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }
.btn.is-busy { position: relative; color: transparent !important; }
.btn.is-busy::after { content: ''; position: absolute; width: 18px; height: 18px; border-radius: 50%; border: 2px solid currentColor; border-color: var(--brand-ink) var(--brand-ink) transparent transparent; animation: spin .7s linear infinite; }
.btn-ghost.is-busy::after { border-color: var(--ink) var(--ink) transparent transparent; }
.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 9px; border: 1px solid transparent;
  background: transparent; color: var(--ink-2); transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--surface-2); border-color: var(--line); color: var(--ink); }
.icon-btn.icon-danger:hover { color: var(--red); background: var(--red-soft); }
.icon-btn.icon-wa { color: #1f9e57; }
.icon-btn.icon-wa:hover { background: #e6f6ec; }
.icon-btn.spin .ic { animation: spin .8s linear infinite; }
.link-btn { background: none; border: 0; padding: 4px 2px; color: var(--brand); font-weight: 600; font-size: 13.5px; }
.link-btn:hover { text-decoration: underline; }
.link-btn:disabled { color: var(--muted); text-decoration: none; cursor: default; }

/* ---------- النماذج ---------- */
.form { display: flex; flex-direction: column; gap: 14px; }
.form.narrow { max-width: 420px; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field-full { grid-column: 1 / -1; }
.field-label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.req { color: var(--red); font-weight: 700; }
.field-hint { font-size: 12px; color: var(--muted); min-height: 1em; }
.hijri-hint[data-status='expired'] { color: var(--red); }
.hijri-hint[data-status='soon'] { color: var(--amber); }
.input {
  width: 100%; min-height: 42px; padding: 9px 12px; border-radius: var(--radius-sm); border: 1px solid var(--line-2);
  background: var(--surface); transition: border-color .15s, box-shadow .15s;
}
.input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
textarea.input { resize: vertical; min-height: 80px; }
.input-sm { min-height: 38px; width: auto; padding: 6px 10px; font-size: 13.5px; }
input[type='date'].input { direction: ltr; text-align: right; }
.input-wrap { position: relative; display: block; }
.input-wrap .input { padding-inline-end: 44px; }
.input-eye { position: absolute; inset-inline-end: 4px; top: 50%; transform: translateY(-50%); width: 36px; height: 36px; border: 0; background: none; color: var(--muted); display: grid; place-items: center; }
.otp-input { text-align: center; font-family: var(--mono); font-size: 26px; letter-spacing: 12px; min-height: 58px; }
.check { display: inline-flex; align-items: center; gap: 9px; font-size: 14px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--brand); flex: none; }
.form-error, .form-note {
  display: flex; gap: 10px; align-items: flex-start; padding: 11px 14px; border-radius: var(--radius-sm); font-size: 14px;
}
.form-error { background: var(--red-soft); color: var(--red); }
.form-error[hidden] { display: none; }
.form-note { background: var(--green-soft); color: var(--green); }
.form-error .ic, .form-note .ic { margin-top: 3px; }
.form-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding-top: 4px; }
fieldset { border: 0; margin: 0; padding: 0; }
legend { font-weight: 700; font-size: 13px; color: var(--brand); padding: 0 0 8px; grid-column: 1 / -1; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 14px; }
fieldset.grid-2 { padding-bottom: 14px; border-bottom: 1px dashed var(--line); }
.code-block { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px; font-family: var(--mono); font-size: 12px; direction: ltr; text-align: left; overflow: auto; white-space: pre; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-2); cursor: pointer; }
.switch-row span { display: flex; flex-direction: column; }
.switch-row small { font-size: 12.5px; }
.switch { appearance: none; width: 44px; height: 26px; border-radius: 99px; background: var(--line-2); position: relative; flex: none; cursor: pointer; transition: background .15s; }
.switch::after { content: ''; position: absolute; top: 3px; inset-inline-start: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgb(0 0 0 / 25%); transition: inset-inline-start .15s; }
.switch:checked { background: var(--brand); }
.switch:checked::after { inset-inline-start: 21px; }
.radio-group { display: flex; flex-direction: column; gap: 8px; }
.file-drop { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 22px; border: 2px dashed var(--line-2); border-radius: var(--radius); cursor: pointer; text-align: center; background: var(--surface-2); }
.file-drop:hover { border-color: var(--brand); }
.file-drop input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.file-drop span { display: inline-flex; gap: 8px; align-items: center; font-weight: 600; color: var(--brand); }

/* ---------- شاشات الدخول ---------- */
.auth { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px 16px; background:
  radial-gradient(1200px 500px at 85% -10%, var(--brand-soft), transparent 60%), var(--bg); }
.auth-card { width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 28px; box-shadow: var(--shadow); }
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.auth-brand .logo { width: 44px; height: 44px; }
.auth-app { font-weight: 700; }
.auth-tag { font-size: 12.5px; color: var(--muted); }
.auth-title { font-size: 22px; margin-bottom: 6px; }
.auth-sub { color: var(--muted); margin: 0 0 18px; font-size: 14px; }
.auth-row { display: flex; justify-content: space-between; }
.auth-foot { color: var(--muted); font-size: 12.5px; margin-top: 16px; }
.auth .link-btn { align-self: center; }

/* ---------- الإطار ---------- */
.shell { display: grid; grid-template-columns: 250px minmax(0, 1fr); min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 6px; padding: 18px 14px; background: var(--surface); border-inline-end: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); padding: 4px 6px 16px; }
.brand .logo { width: 38px; height: 38px; flex: none; }
.brand span { display: flex; flex-direction: column; min-width: 0; }
.brand b { font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand small { color: var(--muted); font-size: 12px; }
.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-item { display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 10px; color: var(--ink-2); font-weight: 500; }
.nav-item:hover { background: var(--surface-2); color: var(--ink); }
.nav-item.is-on { background: var(--brand-soft); color: var(--brand); font-weight: 700; }
.nav-badge { margin-inline-start: auto; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 99px; background: var(--red); color: #fff; font-size: 12px; display: grid; place-items: center; }
.side-user { display: flex; align-items: center; gap: 10px; padding: 12px 8px 4px; border-top: 1px solid var(--line); }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; font-weight: 700; flex: none; }
.side-user-name { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.side-user-name b { font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-user-name small { font-size: 12px; color: var(--muted); }
.main { min-width: 0; display: flex; flex-direction: column; }
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 10px 28px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); }
.brand-mobile { display: none; }
.top-tools { display: flex; align-items: center; gap: 4px; }
.sync { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; padding: 4px 10px; border-radius: 99px; margin-inline-end: 4px; }
.sync .ic { width: 16px; height: 16px; }
.sync-ok { color: var(--green); background: var(--green-soft); }
.sync-bad { color: var(--red); background: var(--red-soft); }
.content { padding: 4px 28px 40px; width: 100%; max-width: 1320px; }
.bottom-nav, .mobile-only { display: none; }

/* ---------- الصفحات ---------- */
.page { display: flex; flex-direction: column; gap: 18px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-head h1 { font-size: 24px; }
.page-head p { margin: 4px 0 0; font-size: 13.5px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.card.pad-lg { padding: 20px 22px; display: flex; flex-direction: column; gap: 12px; }
.card-title { font-size: 16px; }
.sub-title { font-size: 14px; display: flex; gap: 8px; align-items: center; color: var(--ink-2); margin-top: 6px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.card-head h2 { font-size: 15px; display: flex; align-items: center; gap: 8px; }
.card-head h2 .ic { color: var(--brand); }
.count { font-size: 12px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 99px; padding: 0 8px; color: var(--muted); }

/* شريط الأدوات */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.search { flex: 1 1 280px; display: flex; align-items: center; gap: 8px; min-height: 42px; padding: 0 12px; background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--radius-sm); color: var(--muted); }
.search:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.search input { flex: 1; min-width: 0; border: 0; background: none; outline: none; padding: 8px 0; color: var(--ink); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 7px; padding: 6px 12px; border-radius: 99px; border: 1px solid var(--line-2); background: var(--surface); font-size: 13.5px; font-weight: 500; }
.chip b { font-size: 12px; min-width: 20px; padding: 0 5px; border-radius: 99px; background: var(--surface-2); color: var(--ink-2); }
.chip.is-on { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.chip.is-on b { background: color-mix(in srgb, var(--surface) 20%, transparent); color: inherit; }
.chip-expired b { color: var(--red); }
.chip-soon b { color: var(--amber); }
.chip-valid b { color: var(--green); }
.seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; }
.seg button { border: 0; background: none; padding: 4px 12px; border-radius: 7px; font-size: 13px; color: var(--muted); }
.seg button.is-on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); font-weight: 600; }

/* الوسوم والحالات */
.tag { display: inline-flex; align-items: center; padding: 1px 9px; border-radius: 99px; font-size: 12px; background: var(--surface-2); border: 1px solid var(--line); color: var(--ink-2); white-space: nowrap; }
.tag-green { background: var(--green-soft); color: var(--green); border-color: transparent; }
.tag-amber { background: var(--amber-soft); color: var(--amber); border-color: transparent; }
.tag-red { background: var(--red-soft); color: var(--red); border-color: transparent; }
.tag-admin { background: var(--brand-soft); color: var(--brand); border-color: transparent; }
.plate { display: inline-block; font-size: 12.5px; font-weight: 600; padding: 0 8px; border: 1.5px solid var(--ink-2); border-radius: 5px; letter-spacing: .5px; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; flex: none; }
.dot-expired { background: var(--red); box-shadow: 0 0 0 3px var(--red-soft); }
.dot-soon { background: var(--amber-bar); box-shadow: 0 0 0 3px var(--amber-soft); }
.dot-valid { background: var(--green); }
.dot-none { background: var(--line-2); }

.pill { display: inline-flex; flex-direction: column; gap: 4px; min-width: 132px; padding: 6px 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); line-height: 1.3; }
.pill-top { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.pill-date { font-family: var(--mono); font-size: 12.5px; color: var(--ink); }
.pill-state { font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill-bar { position: relative; height: 4px; border-radius: 4px; background: var(--surface-2); overflow: visible; }
.pill-bar i { position: absolute; inset-block: 0; inset-inline-start: 0; border-radius: 4px; background: var(--green); }
.pill-bar em { position: absolute; top: -2px; bottom: -2px; width: 1.5px; background: var(--line-2); }
.pill-expired { background: var(--red-soft); border-color: transparent; }
.pill-expired .pill-state { color: var(--red); }
.pill-expired .pill-bar i { background: var(--red); opacity: .35; }
.pill-soon { background: var(--amber-soft); border-color: transparent; }
.pill-soon .pill-state { color: var(--amber); }
.pill-soon .pill-bar i { background: var(--amber-bar); }
.pill-valid .pill-state { color: var(--green); }
.pill-none { min-width: 0; color: var(--muted); border: 0; background: none; padding: 0; }

/* الجداول */
.table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow-x: auto; }
.card .table-wrap { border: 0; box-shadow: none; border-radius: 0; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: start; font-size: 12.5px; font-weight: 600; color: var(--muted); padding: 11px 14px; background: var(--surface-2); border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: color-mix(in srgb, var(--surface-2) 70%, transparent); }
.table tr.row-expired td:first-child { box-shadow: inset -3px 0 0 var(--red); }
.table tr.row-soon td:first-child { box-shadow: inset -3px 0 0 var(--amber-bar); }
.th-actions { width: 1%; }
.cell-actions { width: 1%; white-space: nowrap; }
.rec-title { font-weight: 600; }
.rec-sub { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 3px; }
.rec-note { font-size: 12.5px; color: var(--muted); margin-top: 4px; max-width: 380px; }
.row-actions { display: inline-flex; gap: 2px; align-items: center; }

.empty { text-align: center; padding: 48px 20px; background: var(--surface); border: 1px dashed var(--line-2); border-radius: var(--radius); display: flex; flex-direction: column; align-items: center; gap: 8px; }
.empty p { margin: 0 0 8px; color: var(--muted); max-width: 420px; }
.empty-art { width: 56px; height: 56px; border-radius: 16px; background: var(--surface-2); display: grid; place-items: center; color: var(--muted); }
.empty-art .ic { width: 26px; height: 26px; }
.empty-art.ok { background: var(--green-soft); color: var(--green); }
.empty-sm { border: 0; padding: 32px 20px; background: none; }

/* ---------- اللوحة الرئيسية ---------- */
.hero { padding: 6px 0 2px; }
.hero-hello { margin: 0; color: var(--muted); font-weight: 500; }
.hero h1 { font-size: 27px; margin: 2px 0 4px; letter-spacing: -.2px; }
.hero em { font-style: normal; }
.hero p { margin: 0; font-size: 13.5px; }
.t-expired { color: var(--red); }
.t-soon { color: var(--amber); }

.banner { display: flex; align-items: center; gap: 16px; padding: 16px 18px; border-radius: var(--radius); flex-wrap: wrap; }
.banner-rescue { background: var(--amber-soft); border: 1px solid color-mix(in srgb, var(--amber) 30%, transparent); }
.banner-icon { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; background: var(--surface); color: var(--amber); flex: none; }
.banner > div { flex: 1 1 300px; }
.banner p { margin: 2px 0 0; font-size: 13.5px; color: var(--ink-2); }
.banner-actions { display: flex; align-items: center; gap: 12px; flex: 0 0 auto !important; }

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.kpi {
  position: relative; display: grid; grid-template-columns: auto 1fr; grid-template-areas: 'icon label' 'value value' 'detail detail';
  gap: 2px 10px; align-items: center; text-align: start; padding: 16px 18px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); color: var(--ink); transition: border-color .15s, transform .1s;
}
.kpi:hover { border-color: var(--line-2); }
.kpi.is-on { border-color: currentColor; }
.kpi-icon { grid-area: icon; width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; background: var(--surface-2); }
.kpi-label { grid-area: label; font-size: 13.5px; color: var(--muted); font-weight: 500; }
.kpi-value { grid-area: value; font-size: 32px; font-weight: 700; line-height: 1.2; margin-top: 8px; }
.kpi-detail { grid-area: detail; font-size: 12.5px; color: var(--muted); }
.kpi-expired .kpi-icon { background: var(--red-soft); color: var(--red); }
.kpi-expired .kpi-value, .kpi-expired.is-on { color: var(--red); }
.kpi-soon .kpi-icon { background: var(--amber-soft); color: var(--amber); }
.kpi-soon .kpi-value, .kpi-soon.is-on { color: var(--amber); }
.kpi-valid .kpi-icon { background: var(--green-soft); color: var(--green); }
.kpi-valid .kpi-value, .kpi-valid.is-on { color: var(--green); }
.kpi-total .kpi-icon { background: var(--brand-soft); color: var(--brand); }
.kpi.is-on .kpi-label, .kpi.is-on .kpi-detail { color: var(--ink-2); }

.dash-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
.dash-main, .dash-side { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

.deadlines { list-style: none; margin: 0; padding: 0; max-height: 620px; overflow-y: auto; }
.dl { display: flex; align-items: center; gap: 12px; padding: 11px 18px; border-bottom: 1px solid var(--line); }
.dl:last-child { border-bottom: 0; }
.dl-icon { color: var(--muted); display: grid; }
.dl-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.dl-main b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dl-main small { display: flex; gap: 8px; align-items: center; font-size: 12.5px; }
.dl-pill .pill { min-width: 170px; }

.timeline { display: grid; grid-template-columns: repeat(13, minmax(0, 1fr)); gap: 6px; height: 190px; padding: 18px 18px 8px; align-items: end; }
.tl-col { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 4px; min-width: 0; }
.tl-n { font-size: 12px; font-weight: 600; color: var(--ink-2); min-height: 18px; }
.tl-bar { width: 100%; max-width: 34px; border-radius: 6px 6px 2px 2px; background: var(--line); }
.tl-expired { background: var(--red); }
.tl-soon { background: var(--amber-bar); }
.tl-valid { background: color-mix(in srgb, var(--green) 70%, var(--surface)); }
.tl-label { font-size: 10.5px; color: var(--muted); font-family: var(--mono); white-space: nowrap; direction: ltr; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; padding: 4px 18px 16px; font-size: 12px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend .dot { box-shadow: none; }

.cats { list-style: none; margin: 0; padding: 8px 18px 16px; display: flex; flex-direction: column; gap: 12px; }
.cat-top { display: flex; justify-content: space-between; font-size: 13.5px; margin-bottom: 5px; }
.stack { display: flex; height: 8px; border-radius: 8px; overflow: hidden; background: var(--surface-2); gap: 2px; }
.st-expired { background: var(--red); }
.st-soon { background: var(--amber-bar); }
.st-valid { background: var(--green); opacity: .75; }

.activity { list-style: none; margin: 0; padding: 0; }
.activity li { display: flex; align-items: center; gap: 12px; padding: 11px 18px; border-bottom: 1px solid var(--line); font-size: 14px; }
.activity li:last-child { border-bottom: 0; }
.activity-mini li { align-items: flex-start; font-size: 13px; padding: 10px 18px; }
.activity-mini li > span:last-child { display: flex; flex-direction: column; }
.act-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--line-2); flex: none; margin-top: 6px; }
.activity li:not(.activity-mini li) .act-dot { margin-top: 0; }
.act-create, .act-import { background: var(--green); }
.act-update { background: var(--brand); }
.act-delete, .act-user_delete { background: var(--red); }
.act-kind { font-size: 12px; min-width: 64px; color: var(--muted); }
.act-text { flex: 1; min-width: 0; }

/* ---------- الإعدادات ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tab { display: inline-flex; align-items: center; gap: 8px; padding: 10px 14px; border: 0; background: none; color: var(--muted); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tab.is-on { color: var(--brand); border-bottom-color: var(--brand); font-weight: 700; }
.tab-body { display: flex; flex-direction: column; gap: 16px; }
.roles-help { display: flex; gap: 18px; flex-wrap: wrap; padding: 10px 18px; font-size: 12.5px; color: var(--muted); background: var(--surface-2); border-bottom: 1px solid var(--line); }
.steps { margin: 0; padding-inline-start: 20px; font-size: 14px; color: var(--ink-2); }
.copy-line { display: flex; align-items: center; gap: 8px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 6px 6px 6px 12px; }
.copy-line code { flex: 1; min-width: 0; overflow-x: auto; white-space: nowrap; font-family: var(--mono); font-size: 12.5px; text-align: left; }

/* ---------- النوافذ ---------- */
.modal-wrap { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 16px; background: rgb(12 14 12 / 45%); opacity: 0; transition: opacity .18s; }
.modal-wrap.show { opacity: 1; }
.modal { width: 100%; max-width: 480px; max-height: calc(100vh - 32px); display: flex; flex-direction: column; background: var(--surface); border-radius: 18px; box-shadow: var(--shadow-lg); transform: translateY(8px) scale(.99); transition: transform .18s; }
.modal-wrap.show .modal { transform: none; }
.modal-wide { max-width: 900px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-head h2 { font-size: 17px; }
.modal-body { padding: 18px 20px 20px; overflow-y: auto; }
.modal-actions { display: flex; gap: 8px; flex-wrap: wrap; padding-top: 6px; position: sticky; bottom: -20px; background: var(--surface); padding-bottom: 2px; }
.confirm-text { margin: 0 0 16px; }
.renew-head { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.renew-head span { color: var(--muted); font-size: 13px; }
.renew-row .muted { display: block; font-size: 12.5px; margin-bottom: 4px; }
.renew-list { display: flex; flex-direction: column; gap: 8px; }
.renew-item { display: grid; grid-template-columns: 150px 190px minmax(0, 1fr); gap: 12px; align-items: center; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.renew-item .field-hint { min-height: 0; }

.rescue-intro { margin: 0; font-size: 14px; color: var(--ink-2); }
.rescue-tools { display: flex; gap: 12px; align-items: center; }
.rescue-list { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--radius-sm); max-height: 360px; overflow-y: auto; }
.rescue-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-bottom: 1px solid var(--line); cursor: pointer; }
.rescue-row:last-child { border-bottom: 0; }
.rescue-row input { width: 18px; height: 18px; accent-color: var(--brand); flex: none; }
.rescue-icon { color: var(--muted); display: grid; }
.rescue-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.rescue-main small { font-size: 12px; }
.rescue-tags { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

/* ---------- التنبيهات المنبثقة ---------- */
#toasts { position: fixed; z-index: 200; inset-inline: 0; bottom: 20px; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; padding: 0 16px; }
.toast { display: flex; gap: 10px; align-items: flex-start; max-width: 520px; padding: 12px 16px; border-radius: 12px; background: var(--ink); color: var(--surface); box-shadow: var(--shadow-lg); font-size: 14px; opacity: 0; transform: translateY(10px); transition: opacity .2s, transform .2s; pointer-events: auto; }
.toast.show { opacity: 1; transform: none; }
.toast .ic { margin-top: 2px; color: var(--green); }
.toast-error { background: var(--red); color: #fff; }
.toast-error .ic { color: #fff; }

/* ---------- الشاشات المتوسطة ---------- */
@media screen and (max-width: 1100px) {
  .dash-grid { grid-template-columns: minmax(0, 1fr); }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ---------- الجوال ---------- */
@media screen and (max-width: 860px) {
  body { font-size: 14.5px; }
  .shell { display: block; padding-bottom: calc(68px + env(safe-area-inset-bottom)); }
  .side { display: none; }
  .top { justify-content: space-between; padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--surface); }
  .brand-mobile { display: flex; padding: 0; gap: 8px; min-width: 0; }
  .brand-mobile .logo { width: 32px; height: 32px; }
  .brand-mobile b { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .sync span { display: none; }
  .sync { padding: 6px; }
  .mobile-only { display: inline-grid; }
  .content { padding: 16px 16px 32px; }
  .bottom-nav {
    display: flex; position: fixed; z-index: 30; inset-inline: 0; bottom: 0; background: var(--surface); border-top: 1px solid var(--line);
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
  }
  .bottom-nav .nav-item { flex: 1; flex-direction: column; gap: 2px; padding: 6px 2px; font-size: 11px; position: relative; justify-content: center; }
  .bottom-nav .nav-item .ic { width: 22px; height: 22px; }
  .bottom-nav .nav-badge { position: absolute; top: 0; inset-inline-start: 50%; margin: 0 8px 0 0; min-width: 18px; height: 18px; font-size: 11px; }
  .bottom-nav .nav-item.is-on { background: none; }
  .page-head h1 { font-size: 21px; }
  .hero h1 { font-size: 22px; }
  .page-actions { width: 100%; }
  .page-actions .btn-primary { flex: 1; }
  .page-actions .btn-ghost span { display: none; }
  .page-actions .btn-ghost { padding: 8px 12px; }
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .kpis { gap: 10px; }
  .kpi { padding: 12px 14px; }
  .kpi-value { font-size: 26px; margin-top: 4px; }
  .kpi-detail { font-size: 11.5px; }
  .toolbar .input-sm { flex: 1; }
  .card-head { padding: 12px 14px; }
  .dl { flex-wrap: wrap; padding: 12px 14px; gap: 8px 10px; }
  .dl-main { flex: 1 1 calc(100% - 60px); }
  .dl-pill { flex: 1; }
  .dl-pill .pill { width: 100%; min-width: 0; }
  .timeline { gap: 3px; padding: 14px 10px 6px; height: 160px; }
  .tl-label { font-size: 9px; writing-mode: vertical-rl; transform: rotate(180deg); height: 34px; }
  .modal-wrap { place-items: end center; padding: 0; }
  .modal { max-width: none; border-radius: 18px 18px 0 0; max-height: 92vh; }
  .modal-body { padding: 16px; padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
  .modal-actions .btn-primary { flex: 1; }
  .renew-item { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .card.pad-lg { padding: 16px; }

}

@media screen and (max-width: 1080px) {
  /* الجداول تتحول لبطاقات */
  .table-cards thead { display: none; }
  .table-cards, .table-cards tbody, .table-cards tr, .table-cards td { display: block; width: 100%; }
  .table-wrap { background: none; border: 0; box-shadow: none; overflow: visible; }
  .table-cards tbody { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); gap: 10px; }
  .card .table-cards tbody { padding: 8px; }
  .table-cards tr { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 6px 0; box-shadow: var(--shadow); position: relative; }
  .table-cards tr.row-expired { border-inline-start: 4px solid var(--red); }
  .table-cards tr.row-soon { border-inline-start: 4px solid var(--amber-bar); }
  .table tr.row-expired td:first-child, .table tr.row-soon td:first-child { box-shadow: none; }
  .table-cards td { border: 0; padding: 6px 14px; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
  .table-cards td[data-label]::before { content: attr(data-label); font-size: 12.5px; color: var(--muted); flex: none; }
  .table-cards td.cell-main { display: block; padding-top: 8px; }
  .table-cards td.cell-main::before { display: none; }
  .table-cards td.cell-actions { justify-content: flex-end; border-top: 1px solid var(--line); margin-top: 6px; padding: 6px 8px 0; width: 100%; }
  .table-cards .pill { min-width: 0; width: 62%; }
  .table-cards td > div:not(.row-actions) { text-align: end; }
  .card .table-cards tr { box-shadow: none; }
}

@media screen and (max-width: 420px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi-value { font-size: 23px; }
  .chip { padding: 5px 10px; font-size: 13px; }
  .auth-card { padding: 22px 18px; }
}

/* ================= الإصدار 3: الأقسام الجديدة ================= */

/* القائمة الجانبية والبحث العام */
.nav-group { display: block; font-size: 11.5px; font-weight: 600; color: var(--muted); padding: 14px 12px 4px; letter-spacing: .2px; }
.top { gap: 12px; }
.top-search { display: flex; align-items: center; gap: 10px; flex: 0 1 380px; margin-inline-end: auto; min-height: 38px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--surface); color: var(--muted); font-size: 13.5px; }
.top-search:hover { border-color: var(--brand); color: var(--ink-2); }
.top-search span { flex: 1; text-align: start; }
kbd { font-family: var(--mono); font-size: 11px; padding: 1px 6px; border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: 5px; color: var(--muted); direction: ltr; }
.gsearch { display: flex; flex-direction: column; gap: 10px; }
.gresults { list-style: none; margin: 0; padding: 0; max-height: 55vh; overflow-y: auto; }
.gres { display: flex; align-items: center; gap: 12px; width: 100%; text-align: start; padding: 10px 12px; border: 0; border-radius: 10px; background: none; }
.gres:hover, .gres:focus-visible, .gres.is-first { background: var(--surface-2); }
.gres .ic { color: var(--brand); }
.gres span { display: flex; flex-direction: column; min-width: 0; }
.more-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.more-item { position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 16px 8px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface-2); color: var(--ink); font-size: 13px; font-weight: 500; }
.more-item .ic { width: 24px; height: 24px; color: var(--brand); }
.more-item.is-on { border-color: var(--brand); background: var(--brand-soft); }
.more-item .nav-badge { position: absolute; top: 6px; inset-inline-end: 6px; margin: 0; }

/* عام */
.center { text-align: center; }
.t-valid { color: var(--green); }
.icon-sm { width: 28px; height: 28px; }
.icon-sm .ic { width: 15px; height: 15px; }
.icon-btn.icon-ok { color: var(--green); }
.icon-btn.icon-ok:hover { background: var(--green-soft); }
.btn-danger-ghost { color: var(--red); }
.btn-unlocked { background: var(--green-soft); color: var(--green); border-color: transparent; }
.tab-badge { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px; background: var(--amber-soft); color: var(--amber); font-size: 11.5px; display: inline-grid; place-items: center; }
.section-label { font-size: 13px; font-weight: 600; color: var(--muted); display: flex; gap: 6px; align-items: center; margin: 4px 0 -6px; }
.section-label .ic { width: 15px; height: 15px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px 14px; }
fieldset.grid-3 { padding-bottom: 14px; border-bottom: 1px dashed var(--line); }
.banner-info { background: var(--brand-soft); border: 1px solid color-mix(in srgb, var(--brand) 25%, transparent); }
.banner-info .banner-icon { color: var(--brand); }
.banner code { font-family: var(--mono); font-size: 12px; background: var(--surface); padding: 1px 6px; border-radius: 5px; }
.done-text { text-decoration: line-through; color: var(--muted); }
.mini-count { position: absolute; top: 2px; inset-inline-end: 2px; font-style: normal; font-size: 10px; min-width: 15px; height: 15px; border-radius: 99px; background: var(--brand); color: var(--brand-ink); display: grid; place-items: center; padding: 0 3px; }
.icon-btn { position: relative; }

/* ================= الإصدار 4 ================= */
/* الشعار */
.logo-img { object-fit: contain; border-radius: 10px; background: #fff; }
.brand .logo-img { width: 40px; height: 40px; padding: 2px; border: 1px solid var(--line); flex: none; }
.side .brand b { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; line-height: 1.35; }
.auth-brand .logo-img { width: 52px; height: 52px; padding: 3px; border: 1px solid var(--line); }
.doc-brand .logo-img { width: 54px; height: 54px; border-radius: 6px; background: none; }
.company-grid { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 20px; align-items: start; }
.logo-box { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.logo-preview { width: 180px; height: 180px; border: 1px dashed var(--line-2); border-radius: 16px; display: grid; place-items: center; background: repeating-conic-gradient(var(--surface-2) 0 25%, var(--surface) 0 50%) 0 0 / 16px 16px; overflow: hidden; }
.logo-preview .logo-big { width: 160px; height: 160px; object-fit: contain; background: none; border: 0; }
.logo-preview svg.logo-big, .logo-preview .logo { width: 120px; height: 120px; }
.logo-empty { display: flex; flex-direction: column; align-items: center; gap: 6px; color: var(--muted); }
.logo-empty .ic { width: 34px; height: 34px; }

/* التصنيفات */
.select-add { display: flex; gap: 6px; }
.select-add .input { flex: 1; min-width: 0; }
.cat-new { display: flex; gap: 6px; align-items: center; margin-top: 6px; padding: 8px; border-radius: var(--radius-sm); background: var(--brand-soft); }
.cat-new[hidden] { display: none; }
.cat-new .input { flex: 1; min-height: 36px; }
.cat-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.cat-row { display: flex; align-items: center; gap: 10px; }
.cat-row .input { flex: 1; min-height: 38px; }
.cat-handle { color: var(--muted); display: grid; }
.cat-count { min-width: 76px; text-align: center; }

/* المرفقات */
.clip-badge { display: inline-flex; align-items: center; gap: 3px; border: 1px solid var(--line); background: var(--surface); color: var(--muted); border-radius: 99px; padding: 1px 8px; font-size: 12px; cursor: pointer; }
.clip-badge .ic { width: 13px; height: 13px; }
.clip-badge.has { color: var(--brand); border-color: color-mix(in srgb, var(--brand) 35%, transparent); background: var(--brand-soft); }
.clip-badge:not(.has) { opacity: .55; }
.clip-badge:hover { opacity: 1; }
.att-box { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.modal-body > .att-box { margin-top: 14px; }
.att-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.att-head .sub-title { margin: 0; }
.att-upload { cursor: pointer; }
.att-drop { border: 2px dashed transparent; border-radius: 10px; padding: 4px 8px; text-align: center; transition: border-color .15s, background .15s; }
.att-drop.is-over { border-color: var(--brand); background: var(--brand-soft); padding: 16px; }
.att-progress { position: relative; height: 26px; border-radius: 8px; background: var(--surface-2); overflow: hidden; font-size: 12px; display: flex; align-items: center; padding: 0 10px; }
.att-progress[hidden] { display: none; }
.att-progress i { position: absolute; inset-block: 0; inset-inline-start: 0; inline-size: 0; background: var(--brand-soft); transition: inline-size .2s; }
.att-progress span { position: relative; }
.att-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.att-list li { display: grid; grid-template-columns: 30px minmax(0, 1fr) auto; grid-template-areas: 'i n a' 'i m a'; align-items: center; column-gap: 8px; padding: 6px 8px; border-radius: 8px; background: var(--surface-2); }
.att-icon { grid-area: i; width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; background: var(--surface); color: var(--brand); }
.att-name { grid-area: n; border: 0; background: none; padding: 0; text-align: start; color: var(--ink); font-weight: 600; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att-name:hover { color: var(--brand); text-decoration: underline; }
.att-list small { grid-area: m; font-size: 11.5px; }
.att-list .row-actions { grid-area: a; }
.att-empty { margin: 0; }

/* التقويم */
.cal-nav { align-items: center; }
.cal-title { display: flex; flex-direction: column; align-items: center; min-width: 170px; line-height: 1.3; }
.cal-title b { font-size: 16px; }
.cal-title small { font-size: 11.5px; }
.cal-layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 16px; align-items: start; }
.cal-wrap { padding: 10px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal-head span { text-align: center; font-size: 12px; font-weight: 600; color: var(--muted); padding: 6px 0; }
.cal-cell { position: relative; min-height: 96px; display: flex; flex-direction: column; gap: 3px; align-items: stretch; padding: 5px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); text-align: start; overflow: hidden; }
.cal-cell.is-empty { background: transparent; border-color: transparent; }
.cal-cell:hover { border-color: var(--line-2); }
.cal-cell.is-today { border-color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); }
.cal-cell.is-sel { background: var(--brand-soft); border-color: var(--brand); }
.cal-cell.has-expired { box-shadow: inset 0 3px 0 var(--red); }
.cal-cell.has-soon { box-shadow: inset 0 3px 0 var(--amber-bar); }
.cal-cell.is-today.has-expired, .cal-cell.is-today.has-soon { box-shadow: inset 0 0 0 1px var(--brand); }
.cal-num { display: flex; justify-content: space-between; align-items: baseline; }
.cal-num b { font-size: 14px; }
.cal-num small { font-size: 10px; color: var(--muted); }
.cal-cell.is-today .cal-num b { color: var(--brand); }
.cal-items { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cal-chip { font-style: normal; font-size: 10.5px; line-height: 1.5; padding: 0 5px; border-radius: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; background: var(--surface-2); color: var(--ink-2); }
.cal-chip.c-expired { background: var(--red-soft); color: var(--red); }
.cal-chip.c-soon { background: var(--amber-soft); color: var(--amber); }
.cal-chip.c-valid { background: var(--green-soft); color: var(--green); }
.cal-chip.c-meeting { background: var(--brand-soft); color: var(--brand); }
.cal-more { font-style: normal; font-size: 10.5px; color: var(--muted); padding: 0 4px; }
.cal-dots { display: none; gap: 3px; justify-content: center; }
.cal-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); }
.cal-dots .c-expired { background: var(--red); } .cal-dots .c-soon { background: var(--amber-bar); } .cal-dots .c-valid { background: var(--green); } .cal-dots .c-meeting { background: var(--brand); }
.dot-meeting { background: var(--brand); }
.dl-meeting .dl-icon { color: var(--brand); }
.cal-day .deadlines { max-height: 70vh; }
.doc-contact { font-size: 10px; }

@media screen and (max-width: 1100px) {
  .cal-layout { grid-template-columns: minmax(0, 1fr); }
}
@media screen and (max-width: 860px) {
  .company-grid { grid-template-columns: minmax(0, 1fr); }
  .cal-cell { min-height: 54px; padding: 4px 3px; align-items: center; }
  .cal-items { display: none; }
  .cal-dots { display: flex; }
  .cal-num { flex-direction: column; align-items: center; }
  .cal-head span { font-size: 10.5px; }
  .cal-nav { justify-content: space-between; }
  .att-list li { grid-template-columns: 30px minmax(0, 1fr); grid-template-areas: 'i n' 'i m' 'a a'; }
  .att-list .row-actions { justify-self: end; }
}

/* إعدادات البريد */
.smtp-status, .mail-result { display: flex; gap: 10px; align-items: flex-start; padding: 10px 14px; border-radius: var(--radius-sm); font-size: 13.5px; }
.smtp-status .ic, .mail-result .ic { margin-top: 3px; flex: none; }
.smtp-status.is-ok, .mail-result.is-ok { background: var(--green-soft); color: var(--green); }
.smtp-status.is-warn { background: var(--amber-soft); color: var(--amber); }
.mail-result.is-bad { background: var(--red-soft); color: var(--red); }
.mail-result[hidden] { display: none; }
.howto { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 8px 12px; font-size: 13.5px; }
.howto summary { cursor: pointer; font-weight: 600; color: var(--brand); }
.howto .steps { margin-top: 8px; }
.howto code { font-family: var(--mono); font-size: 12.5px; background: var(--surface-2); padding: 1px 6px; border-radius: 5px; }
.grid-2.tight { gap: 10px; }

/* الإجراءات السريعة */
.hero { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.quick { display: flex; gap: 8px; flex-wrap: wrap; }
.quick-btn { display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 76px; padding: 10px 8px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); font-size: 12.5px; box-shadow: var(--shadow); }
.quick-btn:hover { border-color: var(--brand); color: var(--brand); }
.quick-btn > .ic { width: 22px; height: 22px; color: var(--brand); }
.quick-btn span { display: inline-flex; align-items: center; gap: 2px; }
.q-plus { width: 12px; height: 12px; }

/* اللوحة: الاجتماعات القادمة */
.mini-stats { display: flex; gap: 16px; padding: 10px 18px 0; font-size: 13px; color: var(--muted); }
.mini-stats b { color: var(--ink); font-size: 15px; }
.mini-stats .t-expired b { color: var(--red); }
.upcoming { list-style: none; margin: 0; padding: 8px 10px 12px; }
.upcoming li { display: flex; gap: 12px; align-items: center; padding: 8px; border-radius: 10px; cursor: pointer; }
.upcoming li:hover { background: var(--surface-2); }
.upcoming li > span:last-child { display: flex; flex-direction: column; min-width: 0; font-size: 13.5px; }
.up-date { display: flex; flex-direction: column; align-items: center; min-width: 46px; padding: 4px; border-radius: 10px; background: var(--brand-soft); color: var(--brand); line-height: 1.1; }
.up-date b { font-size: 18px; }
.up-date small { font-size: 10px; font-family: var(--mono); }

/* الخزنة */
.cred-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 330px), 1fr)); gap: 14px; }
.cred-card { display: flex; flex-direction: column; gap: 10px; padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.cred-head { display: flex; align-items: center; gap: 10px; }
.cred-icon { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); flex: none; }
.cred-title { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
.cred-title b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.cred-fields { margin: 0; display: flex; flex-direction: column; gap: 4px; }
.cred-fields > div { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 30px; }
.cred-fields dt { font-size: 12.5px; color: var(--muted); flex: none; }
.cred-fields dd { margin: 0; display: flex; align-items: center; gap: 2px; min-width: 0; }
.cred-fields code { font-family: var(--mono); font-size: 13px; background: var(--surface-2); padding: 2px 8px; border-radius: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 190px; }
.cred-renew .pill { width: 100%; }
.cred-notes { margin: 0; font-size: 12.5px; color: var(--ink-2); white-space: pre-wrap; background: var(--surface-2); border-radius: 8px; padding: 8px 10px; max-height: 90px; overflow: auto; }
.cred-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; border-top: 1px solid var(--line); padding-top: 8px; margin-top: auto; }
.vault-lock-art { width: 56px; height: 56px; margin: 0 auto; border-radius: 16px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); }
.vault-lock-art .ic { width: 26px; height: 26px; }
.timeline-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; max-height: 50vh; overflow-y: auto; }
.tl-item { display: flex; gap: 12px; align-items: flex-start; padding: 8px 4px; border-bottom: 1px solid var(--line); }
.tl-item div { display: flex; flex-direction: column; font-size: 13.5px; }
.tl-icon { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); color: var(--ink-2); flex: none; }
.tl-icon .ic { width: 14px; height: 14px; }
.tl-password .tl-icon { background: var(--amber-soft); color: var(--amber); }
.tl-create .tl-icon { background: var(--green-soft); color: var(--green); }
.inline-add { display: flex; gap: 8px; }
.inline-add .input { flex: 1; }

/* الملاحظات */
.notes-grid { columns: 280px; column-gap: 14px; }
.note-card { break-inside: avoid; margin-bottom: 14px; display: flex; flex-direction: column; gap: 8px; padding: 14px 16px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow); cursor: pointer; transition: transform .1s, box-shadow .15s; }
.note-card:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgb(20 20 15 / 10%); }
.note-card header { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.note-card header b { font-size: 15px; }
.note-icons { display: flex; gap: 4px; color: var(--muted); }
.note-icons .ic { width: 15px; height: 15px; }
.note-icons .pinned { color: var(--brand); }
.note-body { margin: 0; white-space: pre-wrap; font-size: 13.5px; color: var(--ink-2); display: -webkit-box; -webkit-line-clamp: 9; -webkit-box-orient: vertical; overflow: hidden; }
.note-card footer { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.note-card .tag .ic { width: 12px; height: 12px; margin-inline-end: 3px; }
.note-meta { margin-inline-start: auto; }
.note-yellow { --note: #fdf3c4; --note-line: #efd97a; }
.note-green { --note: #dcf2e3; --note-line: #9fd3b0; }
.note-blue { --note: #dde9fa; --note-line: #a7c3ec; }
.note-red { --note: #fbe2dd; --note-line: #eeb0a3; }
.note-purple { --note: #ebe2f7; --note-line: #c7b3e6; }
:root[data-theme='dark'] .note-yellow, :root[data-theme='dark'] .note-green, :root[data-theme='dark'] .note-blue, :root[data-theme='dark'] .note-red, :root[data-theme='dark'] .note-purple { --note: color-mix(in srgb, var(--note-line) 18%, var(--surface)); }
@media (prefers-color-scheme: dark) { :root:not([data-theme='light']) :is(.note-yellow, .note-green, .note-blue, .note-red, .note-purple) { --note: color-mix(in srgb, var(--note-line) 18%, var(--surface)); } }
.note-card:is(.note-yellow, .note-green, .note-blue, .note-red, .note-purple) { background: var(--note); border-color: var(--note-line); }
.note-form:is(.note-yellow, .note-green, .note-blue, .note-red, .note-purple) .note-editor { background: var(--note); border-color: var(--note-line); }
.note-editor { min-height: 240px; line-height: 1.8; }
.note-options { display: flex; flex-wrap: wrap; gap: 14px 22px; align-items: center; }
.swatches { display: flex; gap: 8px; }
.swatch input { position: absolute; opacity: 0; }
.swatch span { display: block; width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--line-2); cursor: pointer; background: var(--surface); }
.swatch input:checked + span { outline: 2px solid var(--brand); outline-offset: 2px; }
.swatch input:focus-visible + span { outline: 2px solid var(--brand); }
.sw-yellow span { background: #fdf3c4; } .sw-green span { background: #dcf2e3; } .sw-blue span { background: #dde9fa; } .sw-red span { background: #fbe2dd; } .sw-purple span { background: #ebe2f7; }

/* الاجتماعات */
.mtg-list { display: flex; flex-direction: column; gap: 10px; }
.mtg-card { display: flex; align-items: center; gap: 14px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.mtg-date { display: flex; flex-direction: column; align-items: center; min-width: 64px; padding: 6px 4px; border-radius: 12px; background: var(--brand-soft); color: var(--brand); line-height: 1.15; }
.mtg-date b { font-size: 22px; }
.mtg-date span { font-size: 11px; font-family: var(--mono); }
.mtg-date small { font-size: 10.5px; }
.mtg-main { flex: 1; min-width: 0; cursor: pointer; }
.mtg-title { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.mtg-title b { font-size: 15px; }
.mtg-meta { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 4px; }
.mtg-meta span { display: inline-flex; align-items: center; gap: 4px; }
.mtg-meta .ic { width: 13px; height: 13px; }
.rep { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px; }
.rep legend { padding: 0 6px; }
.rep-list { display: flex; flex-direction: column; gap: 8px; }
.rep-row { display: grid; gap: 8px; align-items: start; }
.rep-att { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1.2fr) 110px 36px; }
.rep-act { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) 150px 120px 36px; }
.rep-block { grid-template-columns: 26px minmax(0, 1fr) 36px; }
.rep-fields { display: flex; flex-direction: column; gap: 6px; }
.rep-num { width: 26px; height: 26px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; font-size: 12.5px; font-weight: 700; margin-top: 8px; }
.rep-row .icon-btn { margin-top: 3px; }
.rep-tools { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.meeting-form .input { min-height: 40px; }

/* التقارير */
.report-picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; }
.report-card { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; text-align: start; padding: 14px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow); }
.report-card .ic { width: 22px; height: 22px; color: var(--brand); margin-bottom: 4px; }
.report-card small { color: var(--muted); font-size: 12px; line-height: 1.5; }
.report-card.is-on { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.report-bar { display: flex; justify-content: space-between; align-items: flex-end; gap: 14px; flex-wrap: wrap; padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.report-opts { display: flex; gap: 14px; flex-wrap: wrap; align-items: flex-end; }
.chip-check { cursor: pointer; }
.chip-check input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.chip-check:has(input:focus-visible) { outline: 2px solid var(--brand); }

/* ---------- المستند الرسمي (معاينة وطباعة) ---------- */
#print-root { display: none; }
.paper-preview { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; overflow-x: auto; }
.doc { position: relative; background: #fff; color: #111; max-width: 900px; margin: 0 auto; padding: 28px 30px; border-radius: 6px; box-shadow: 0 2px 10px rgb(0 0 0 / 10%); font-size: 13px; line-height: 1.7; overflow: hidden; }
.doc-watermark { position: absolute; inset: 0; display: grid; place-items: center; font-size: 110px; font-weight: 700; color: rgb(180 60 30 / 7%); transform: rotate(-24deg); pointer-events: none; }
.doc-head { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; padding-bottom: 12px; border-bottom: 2.5px solid #0e6b5c; margin-bottom: 16px; }
.doc-brand { display: flex; align-items: center; gap: 10px; }
.doc-brand .logo { width: 40px; height: 40px; --brand: #0e6b5c; --brand-ink: #fff; }
.doc-brand div { display: flex; flex-direction: column; }
.doc-brand b { font-size: 14px; }
.doc-brand small { font-size: 10.5px; color: #666; }
.doc-title { text-align: center; }
.doc-title h1 { font-size: 20px; color: #0e6b5c; }
.doc-title p { margin: 2px 0 0; font-size: 13px; font-weight: 600; }
.doc-date { display: flex; flex-direction: column; align-items: flex-end; font-size: 11.5px; color: #444; }
.doc-body { display: flex; flex-direction: column; gap: 14px; }
.doc-section h2 { font-size: 14px; color: #0e6b5c; border-bottom: 1px solid #d9e6e3; padding-bottom: 4px; margin-bottom: 8px; }
.doc-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.doc-table th { background: #eef4f2; color: #0b4d43; font-weight: 700; }
.doc-table th, .doc-table td { border: 1px solid #cfd8d5; padding: 5px 8px; text-align: start; vertical-align: top; }
.doc-table .num { width: 30px; text-align: center; }
.doc-table tr { break-inside: avoid; }
.doc-table tr.sign-row td { height: 30px; }
.doc-table tr.r-expired td:first-child + td { border-inline-start: 3px solid #b3391f; }
.doc-table small { font-size: 10.5px; }
.st-text { font-weight: 600; }
.st-text.st-expired { color: #b3391f; } .st-text.st-soon { color: #9a5b0b; } .st-text.st-valid { color: #28734a; } .st-text.st-none { color: #777; }
.doc-info { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.doc-info th, .doc-info td { border: 1px solid #cfd8d5; padding: 6px 10px; text-align: start; }
.doc-info th { width: 150px; background: #eef4f2; color: #0b4d43; }
.doc-list { margin: 0; padding-inline-start: 22px; display: flex; flex-direction: column; gap: 6px; }
.doc-text { white-space: pre-wrap; }
.doc-list .doc-text { color: #333; }
.doc-note { font-size: 12px; color: #444; background: #f6f8f7; border-inline-start: 3px solid #0e6b5c; padding: 6px 10px; margin: 0; }
.doc-empty { color: #777; font-size: 12px; margin: 0; }
.doc-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; }
.doc-stat { border: 1px solid #cfd8d5; border-radius: 8px; padding: 8px 10px; display: flex; flex-direction: column; }
.doc-stat b { font-size: 20px; line-height: 1.2; }
.doc-stat span { font-size: 11.5px; color: #555; }
.doc-stat.st-expired b { color: #b3391f; } .doc-stat.st-soon b { color: #9a5b0b; } .doc-stat.st-valid b { color: #28734a; }
.doc-kv { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0; margin: 0; border: 1px solid #cfd8d5; border-radius: 6px; overflow: hidden; }
.doc-kv div { display: grid; grid-template-columns: 130px 1fr; border-bottom: 1px solid #e3e9e7; }
.doc-kv dt { background: #eef4f2; padding: 5px 10px; font-weight: 600; color: #0b4d43; }
.doc-kv dd { margin: 0; padding: 5px 10px; }
.doc-meta-row { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 12px; color: #555; }
.doc-signs { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; margin-top: 28px; break-inside: avoid; }
.doc-signs div { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; }
.doc-signs span { font-weight: 700; color: #0b4d43; }
.doc-signs i { font-style: normal; color: #555; margin-top: 18px; }
.doc-foot { display: flex; justify-content: space-between; margin-top: 22px; padding-top: 8px; border-top: 1px solid #ddd; font-size: 10.5px; color: #777; }

@media screen and (max-width: 860px) {
  .top-search { display: none; }
  .quick { width: 100%; }
  .quick-btn { flex: 1; min-width: 0; padding: 8px 4px; font-size: 11.5px; }
  .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .rep-att, .rep-act { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); padding: 10px; border: 1px solid var(--line); border-radius: 10px; }
  .rep-att [data-k=name], .rep-act [data-k=task] { grid-column: 1 / -1; }
  .rep-row [data-rep-del] { justify-self: end; }
  .mtg-card { flex-wrap: wrap; }
  .mtg-main { flex: 1 1 calc(100% - 90px); }
  .mtg-card .row-actions { width: 100%; justify-content: flex-end; border-top: 1px solid var(--line); padding-top: 6px; }
  .doc { padding: 16px; font-size: 12px; }
  .doc-head { grid-template-columns: 1fr; text-align: center; }
  .doc-brand, .doc-date { justify-content: center; align-items: center; }
  .doc-kv { grid-template-columns: 1fr; }
  .paper-preview { padding: 8px; }
  .more-grid { grid-template-columns: repeat(3, 1fr); }
  .report-bar { flex-direction: column; align-items: stretch; }
}
/* ---------- الطباعة ---------- */
@media print {
  @page { margin: 12mm; }
  body { background: #fff; color: #000; font-size: 11pt; }
  .no-print, .side, .top, .bottom-nav, .row-actions, .cell-actions, .th-actions, #toasts, .banner { display: none !important; }
  .print-only { display: flex !important; }
  .print-head { justify-content: space-between; border-bottom: 2px solid #000; padding-bottom: 6px; margin-bottom: 10px; order: -1; }
  #app { display: flex; flex-direction: column; }
  .shell { display: block; }
  .content { padding: 0; max-width: none; }
  .table-wrap, .card { box-shadow: none; border-color: #bbb; }
  .table th { background: #eee; }
  .table tr { break-inside: avoid; }
  .pill { border-color: #ccc; min-width: 0; }
  .pill-bar { display: none; }
  .page-head p { display: none; }
}

/* الطباعة الرسمية: يُطبع المستند وحده */
@media print {
  body.print-mode > *:not(#print-root) { display: none !important; }
  body.print-mode #print-root { display: block !important; }
  body.print-mode .doc { box-shadow: none; max-width: none; padding: 0; border-radius: 0; }
  body.print-mode { background: #fff; }
  .doc-section { break-inside: auto; }
  .doc-section h2 { break-after: avoid; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}