/* ===== Sehhetna design tokens & shared components ===== */
:root {
  --ink: #0d2235; --ink-2: #33475b; --muted: #687a8c; --line: #e2e8ee; --line-2: #eef2f5;
  --bg: #f5f8f7; --surface: #ffffff; --surface-2: #f9fbfa;
  --brand: #0e7c6b; --brand-700: #095c50; --brand-600: #0b6b5d; --brand-100: #d5eee7; --brand-50: #ebf7f3;
  --accent: #f0a23b; --accent-50: #fff5e6;
  --ok: #17905f; --ok-50: #e7f6ee; --warn: #c97a10; --warn-50: #fff4e2; --danger: #cf3b3b; --danger-50: #fdecec; --info: #2e69c9; --info-50: #ebf2fd;
  --radius: 14px; --radius-sm: 10px; --radius-lg: 22px;
  --shadow-sm: 0 1px 2px rgba(13,34,53,.06); --shadow: 0 4px 18px rgba(13,34,53,.07); --shadow-lg: 0 18px 50px rgba(13,34,53,.12);
  --font-en: "Plus Jakarta Sans", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  --font-ar: "IBM Plex Sans Arabic", "Noto Sans Arabic", "Segoe UI", Tahoma, Arial, sans-serif;
  --font: var(--font-en);
  --brand-hover: #095c50; --hero-a: #dff3ec; --hero-b: #fff3df; --nav-bg: rgba(255,255,255,.88); --topbar-bg: rgba(245,248,247,.9);
  --urgent-bg: #fff8f8; --urgent-line: #f3c2c2; --warning-bg: #fffcf6; --warning-line: #f1d9b0; --admin-bg: #efe9fb; --admin-fg: #6b3fc4;
  color-scheme: light;
}
/* ===== Dark mode (screen only — printing always uses the light palette) ===== */
@media screen {
  html[data-theme="dark"] {
    --ink: #e7eef4; --ink-2: #c2cfdb; --muted: #8fa1b2; --line: #263642; --line-2: #1b2832;
    --bg: #0b1419; --surface: #111d24; --surface-2: #15232c;
    --brand: #17a088; --brand-hover: #12866f; --brand-700: #63d8c1; --brand-600: #3cc4aa; --brand-100: #17423b; --brand-50: #0f2f2a;
    --accent-50: #2f2410; --ok: #3fcf8e; --ok-50: #0f2c1f; --warn: #f0a94a; --warn-50: #2f2310; --danger: #ff6b6b; --danger-50: #351a1c; --info: #6ea8ff; --info-50: #142540;
    --shadow-sm: 0 1px 2px rgba(0,0,0,.35); --shadow: 0 4px 18px rgba(0,0,0,.4); --shadow-lg: 0 18px 50px rgba(0,0,0,.5);
    --hero-a: #0f3a33; --hero-b: #2a2212; --nav-bg: rgba(17,29,36,.88); --topbar-bg: rgba(11,20,25,.88);
    --urgent-bg: #241517; --urgent-line: #5a2a2d; --warning-bg: #231d12; --warning-line: #5a4520; --admin-bg: #2a2142; --admin-fg: #b9a2f5;
    color-scheme: dark;
  }
  html[data-theme="dark"] img.logo-img { filter: brightness(1.1); }
}
html[lang="ar"] { --font: var(--font-ar); }
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body { margin: 0; font-family: var(--font); color: var(--ink); background: var(--bg); line-height: 1.6; font-size: 15.5px; -webkit-font-smoothing: antialiased; }
html[lang="ar"] body { font-size: 16px; line-height: 1.75; }
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .5em; letter-spacing: -.01em; }
html[lang="ar"] h1, html[lang="ar"] h2, html[lang="ar"] h3 { letter-spacing: 0; line-height: 1.4; }
p { margin: 0 0 1em; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
img, svg { max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--brand) 45%, transparent); outline-offset: 2px; }
.ltr { direction: ltr; unicode-bidi: isolate; }
.muted { color: var(--muted); }
.small { font-size: .875em; }
.hidden { display: none !important; }
.nowrap { white-space: nowrap; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .5em; min-height: 44px; padding: .6em 1.15em; border-radius: 12px;
  border: 1px solid transparent; background: var(--surface); color: var(--ink); font-weight: 600; cursor: pointer; text-decoration: none !important;
  transition: background .15s, border-color .15s, transform .05s, box-shadow .15s; white-space: nowrap; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--brand); color: #fff; box-shadow: 0 6px 16px rgba(14,124,107,.25); }
.btn-primary:hover { background: var(--brand-hover); }
.btn-outline { border-color: var(--line); background: var(--surface); }
.btn-outline:hover { border-color: var(--brand); color: var(--brand); }
.btn-ghost { background: transparent; }
.btn-ghost:hover { background: var(--line-2); }
.btn-danger { background: var(--danger-50); color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-wa { background: #1fae5b; color: #fff; }
.btn-wa:hover { background: #178c48; }
.btn-sm { min-height: 34px; padding: .3em .8em; font-size: .875em; border-radius: 9px; }
.btn-lg { min-height: 54px; padding: .8em 1.6em; font-size: 1.05em; border-radius: 14px; }
.btn-block { width: 100%; }
.icon-btn { width: 40px; height: 40px; display: inline-grid; place-items: center; border-radius: 10px; border: 0; background: transparent; cursor: pointer; color: var(--ink-2); }
.icon-btn:hover { background: var(--line-2); }

/* forms */
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field > span, .label { font-weight: 600; font-size: .9em; color: var(--ink-2); }
.input, select.input, textarea.input { width: 100%; min-height: 46px; padding: .65em .85em; border: 1px solid var(--line); border-radius: 12px; background: var(--surface);
  transition: border-color .15s, box-shadow .15s; }
textarea.input { min-height: 110px; resize: vertical; line-height: 1.7; }
.input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-50); }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: .92em; cursor: pointer; }
.check input { width: 20px; height: 20px; margin-top: 3px; accent-color: var(--brand); flex: none; }
.form-error { background: var(--danger-50); color: var(--danger); padding: .6em .9em; border-radius: 10px; font-size: .92em; margin-bottom: 12px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 14px; }
@media (max-width: 640px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

/* chips (multi-select) */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: .5em .95em; min-height: 42px; border: 1.5px solid var(--line); border-radius: 999px; background: var(--surface);
  cursor: pointer; font-weight: 500; user-select: none; transition: all .15s; }
.chip:hover { border-color: var(--brand); }
.chip.on { background: var(--brand-50); border-color: var(--brand); color: var(--brand-700); font-weight: 600; }
.chip.on::before { content: "✓"; font-weight: 700; }

/* cards & badges */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow-sm); }
.card h3 { font-size: 1.05rem; }
.badge { display: inline-flex; align-items: center; gap: 5px; padding: .15em .65em; border-radius: 999px; font-size: .78em; font-weight: 700; background: var(--line-2); color: var(--ink-2); white-space: nowrap; }
.b-ok, .b-normal, .b-good, .b-done, .b-active { background: var(--ok-50); color: var(--ok); }
.b-warn, .b-high, .b-low, .b-warning, .b-attention, .b-trial, .b-soon, .b-processing, .b-pending { background: var(--warn-50); color: var(--warn); }
.b-danger, .b-critical, .b-urgent, .b-concern, .b-expired, .b-failed, .b-disabled { background: var(--danger-50); color: var(--danger); }
.b-info, .b-routine, .b-full, .b-tester { background: var(--info-50); color: var(--info); }
.b-admin { background: var(--admin-bg); color: var(--admin-fg); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: currentColor; }

/* toast & modal */
.toast-wrap { position: fixed; inset-inline: 0; bottom: 84px; display: grid; justify-items: center; gap: 8px; z-index: 100; pointer-events: none; }
.toast { background: #0d2235; color: #fff; padding: .7em 1.1em; border-radius: 12px; box-shadow: var(--shadow-lg); font-weight: 500; animation: pop .2s ease-out; max-width: 92vw; }
.toast.err { background: var(--danger); }
@keyframes pop { from { transform: translateY(8px); opacity: 0; } }
.modal-bg { position: fixed; inset: 0; background: rgba(13,34,53,.45); display: grid; place-items: center; z-index: 90; padding: 16px; animation: fade .15s; }
@keyframes fade { from { opacity: 0; } }
.modal { background: var(--surface); border-radius: 18px; width: min(560px, 100%); max-height: 92vh; overflow: auto; box-shadow: var(--shadow-lg); }
.modal.wide { width: min(860px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface); z-index: 1; }
.modal-head h3 { margin: 0; }
.modal-body { padding: 20px; }
.modal-foot { display: flex; gap: 10px; justify-content: flex-end; padding: 14px 20px; border-top: 1px solid var(--line); position: sticky; bottom: 0; background: var(--surface); }
@media (max-width: 640px) { .modal-bg { align-items: end; padding: 0; } .modal { border-radius: 18px 18px 0 0; max-height: 94vh; } }

.spinner { width: 18px; height: 18px; border: 2.5px solid currentColor; border-right-color: transparent; border-radius: 50%; display: inline-block; animation: spin .7s linear infinite; vertical-align: -3px; }
@keyframes spin { to { transform: rotate(360deg); } }
.logo { display: inline-flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.2rem; color: var(--ink); text-decoration: none !important; }
.logo-mark { width: 36px; height: 36px; border-radius: 11px; background: linear-gradient(140deg, var(--brand), #13a58d); display: grid; place-items: center; color: #fff; box-shadow: 0 4px 12px rgba(14,124,107,.3); flex: none; }
.logo small { display: block; font-size: .6em; font-weight: 600; color: var(--muted); margin-top: -4px; }

.theme-btn svg { width: 18px; height: 18px; }
.theme-btn .sun { display: none; } html[data-theme="dark"] .theme-btn .sun { display: inline; } html[data-theme="dark"] .theme-btn .moon { display: none; }
