/* =====================================================================
   SOS Fleet — Design System
   ===================================================================== */

:root {
  --font: 'IBM Plex Sans Arabic', system-ui, -apple-system, 'Segoe UI', Tahoma, sans-serif;

  --radius-xs: 6px;
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-xl: 22px;

  --sidebar-w: 268px;
  --topbar-h: 64px;
  --bottomnav-h: 64px;

  /* Light */
  --bg: #f3f5f8;
  --surface: #ffffff;
  --surface-2: #f7f9fb;
  --surface-3: #eef2f6;
  --border: #e2e8ef;
  --border-strong: #cdd6e1;
  --text: #0e1b2c;
  --text-2: #475569;
  --text-3: #7a8799;

  --primary: #0072bc;
  --primary-hover: #005e9c;
  --primary-soft: #e7f1fa;
  --primary-text: #00609f;
  --on-primary: #ffffff;
  --ring: rgba(0, 114, 188, 0.22);

  --success: #12805c;
  --success-soft: #e4f5ed;
  --warning: #b45309;
  --warning-soft: #fdf1df;
  --danger: #c42b3a;
  --danger-soft: #fce8ea;
  --info: #2f6fd6;
  --info-soft: #e8f0fc;
  --violet: #6b4fd3;
  --violet-soft: #efebfc;
  --neutral-soft: #eef1f5;

  --hero-from: #005b97;
  --hero-to: #0a2d4f;

  --sidebar-bg: #0a2540;
  --sidebar-text: #b9cbe0;
  --sidebar-text-strong: #ffffff;
  --sidebar-hover: rgba(255, 255, 255, 0.06);
  --sidebar-active: rgba(255, 255, 255, 0.11);
  --sidebar-border: rgba(255, 255, 255, 0.08);

  --shadow-xs: 0 1px 2px rgba(15, 30, 55, 0.05);
  --shadow-sm: 0 1px 2px rgba(15, 30, 55, 0.05), 0 2px 8px rgba(15, 30, 55, 0.04);
  --shadow: 0 2px 6px rgba(15, 30, 55, 0.06), 0 10px 28px rgba(15, 30, 55, 0.07);
  --shadow-lg: 0 20px 60px rgba(8, 20, 40, 0.25);

  --backdrop: rgba(6, 14, 28, 0.5);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a111c;
    --surface: #111a28;
    --surface-2: #142032;
    --surface-3: #1a283c;
    --border: #1f2e44;
    --border-strong: #2c405c;
    --text: #e6edf6;
    --text-2: #a7b5c8;
    --text-3: #73839a;
    --primary: #3b9de2;
    --primary-hover: #5daeea;
    --primary-soft: rgba(59, 157, 226, 0.14);
    --primary-text: #7fc2f3;
    --on-primary: #04121f;
    --ring: rgba(59, 157, 226, 0.3);
    --success: #3ccf91;
    --success-soft: rgba(60, 207, 145, 0.13);
    --warning: #f2a93b;
    --warning-soft: rgba(242, 169, 59, 0.13);
    --danger: #f06272;
    --danger-soft: rgba(240, 98, 114, 0.13);
    --info: #6ea3f5;
    --info-soft: rgba(110, 163, 245, 0.13);
    --violet: #a08cf5;
    --violet-soft: rgba(160, 140, 245, 0.14);
    --neutral-soft: rgba(148, 163, 184, 0.12);
    --hero-from: #0a5c96;
    --hero-to: #0b1f36;
    --sidebar-bg: #0c1625;
    --shadow-xs: none;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.25);
    --shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 24px 70px rgba(0, 0, 0, 0.55);
    --backdrop: rgba(0, 0, 0, 0.6);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0a111c;
  --surface: #111a28;
  --surface-2: #142032;
  --surface-3: #1a283c;
  --border: #1f2e44;
  --border-strong: #2c405c;
  --text: #e6edf6;
  --text-2: #a7b5c8;
  --text-3: #73839a;
  --primary: #3b9de2;
  --primary-hover: #5daeea;
  --primary-soft: rgba(59, 157, 226, 0.14);
  --primary-text: #7fc2f3;
  --on-primary: #04121f;
  --ring: rgba(59, 157, 226, 0.3);
  --success: #3ccf91;
  --success-soft: rgba(60, 207, 145, 0.13);
  --warning: #f2a93b;
  --warning-soft: rgba(242, 169, 59, 0.13);
  --danger: #f06272;
  --danger-soft: rgba(240, 98, 114, 0.13);
  --info: #6ea3f5;
  --info-soft: rgba(110, 163, 245, 0.13);
  --violet: #a08cf5;
  --violet-soft: rgba(160, 140, 245, 0.14);
  --neutral-soft: rgba(148, 163, 184, 0.12);
  --hero-from: #0a5c96;
  --hero-to: #0b1f36;
  --sidebar-bg: #0c1625;
  --shadow-xs: none;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.25);
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 24px 70px rgba(0, 0, 0, 0.55);
  --backdrop: rgba(0, 0, 0, 0.6);
  color-scheme: dark;
}

/* ===================== Base ===================== */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}

h1, h2, h3, h4, h5, p { margin: 0; }
h1 { font-size: 20px; font-weight: 700; line-height: 1.3; }
h2 { font-size: 17px; font-weight: 700; line-height: 1.35; }
h3 { font-size: 15px; font-weight: 700; }
a { color: var(--primary-text); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
svg.i { width: 18px; height: 18px; flex: none; stroke-width: 2; }
svg.i-sm { width: 15px; height: 15px; }
svg.i-lg { width: 22px; height: 22px; }
svg.i-xl { width: 28px; height: 28px; }

.num { font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; display: inline-block; }
.muted { color: var(--text-2); }
.subtle { color: var(--text-3); }
.small { font-size: 13px; }
.xsmall { font-size: 12px; }
.strong { font-weight: 700; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-primary { color: var(--primary-text); }

.row { display: flex; align-items: center; gap: 10px; }
.row-wrap { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.stack { display: grid; gap: 16px; }
.stack-sm { display: grid; gap: 10px; }
.stack-lg { display: grid; gap: 24px; }
.grow { flex: 1; min-width: 0; }
.mt-1 { margin-top: 4px; } .mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; }

.grid { display: grid; gap: 16px; }
.grid-2 { display: grid; gap: 14px; grid-template-columns: 1fr; }
.grid-3 { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 640px) {
  .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 1100px) {
  .grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
.span-2 { grid-column: 1 / -1; }

:focus-visible { outline: 3px solid var(--ring); outline-offset: 2px; border-radius: 6px; }

/* ===================== Buttons ===================== */

.btn {
  --btn-bg: var(--surface);
  --btn-fg: var(--text);
  --btn-border: var(--border-strong);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 16px;
  border-radius: 10px;
  border: 1px solid var(--btn-border);
  background: var(--btn-bg);
  color: var(--btn-fg);
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  transition: background-color .15s, border-color .15s, color .15s, box-shadow .15s, transform .06s;
  user-select: none;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .55; pointer-events: none; }
.btn-primary { --btn-bg: var(--primary); --btn-fg: var(--on-primary); --btn-border: var(--primary); box-shadow: 0 1px 2px rgba(0, 60, 110, .18); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-success { --btn-bg: var(--success); --btn-fg: #fff; --btn-border: var(--success); }
.btn-success:hover { filter: brightness(1.06); background: var(--success); }
.btn-danger { --btn-bg: var(--danger); --btn-fg: #fff; --btn-border: var(--danger); }
.btn-danger:hover { filter: brightness(1.06); background: var(--danger); }
.btn-soft { --btn-bg: var(--primary-soft); --btn-fg: var(--primary-text); --btn-border: transparent; }
.btn-soft:hover { background: var(--primary-soft); filter: brightness(.97); }
.btn-soft-danger { --btn-bg: var(--danger-soft); --btn-fg: var(--danger); --btn-border: transparent; }
.btn-soft-danger:hover { background: var(--danger-soft); filter: brightness(.97); }
.btn-ghost { --btn-bg: transparent; --btn-border: transparent; --btn-fg: var(--text-2); }
.btn-ghost:hover { background: var(--surface-3); color: var(--text); }
.btn-sm { height: 32px; padding: 0 11px; font-size: 13px; border-radius: 8px; gap: 6px; }
.btn-lg { height: 54px; padding: 0 22px; font-size: 16px; border-radius: 14px; }
.btn-block { width: 100%; }
.icon-btn { width: 38px; padding: 0; }
.icon-btn.btn-sm { width: 32px; }
.btn .spinner { width: 16px; height: 16px; }

.spinner {
  width: 20px; height: 20px;
  border: 2.5px solid currentColor;
  border-inline-end-color: transparent;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===================== Badges & chips ===================== */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: var(--neutral-soft);
  color: var(--text-2);
  white-space: nowrap;
}
.badge.dot::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.b-success { background: var(--success-soft); color: var(--success); }
.b-warning { background: var(--warning-soft); color: var(--warning); }
.b-danger { background: var(--danger-soft); color: var(--danger); }
.b-info { background: var(--info-soft); color: var(--info); }
.b-primary { background: var(--primary-soft); color: var(--primary-text); }
.b-violet { background: var(--violet-soft); color: var(--violet); }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px;
  background: var(--surface-3); color: var(--text-2);
  font-size: 13px; font-weight: 500;
}
.chip button { border: 0; background: transparent; padding: 0; display: inline-flex; color: var(--text-3); }
.chip button:hover { color: var(--danger); }

.count-badge {
  min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 999px; background: var(--danger); color: #fff;
  font-size: 11px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center;
}

/* ===================== Cards ===================== */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  min-width: 0;
}
.card-h {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  min-height: 58px;
}
.card-h h2 { font-size: 15.5px; }
.card-h .sub { font-size: 12.5px; color: var(--text-3); font-weight: 500; }
.card-b { padding: 18px; }
.card-b.flush { padding: 0; }
.card-f { padding: 12px 18px; border-top: 1px solid var(--border); }

.section-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.section-title h2 { font-size: 16px; }

.icon-tile {
  width: 40px; height: 40px; border-radius: 12px;
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  background: var(--primary-soft); color: var(--primary-text);
}
.icon-tile.sm { width: 32px; height: 32px; border-radius: 10px; }
.icon-tile.lg { width: 52px; height: 52px; border-radius: 16px; }
.t-success { background: var(--success-soft); color: var(--success); }
.t-warning { background: var(--warning-soft); color: var(--warning); }
.t-danger { background: var(--danger-soft); color: var(--danger); }
.t-info { background: var(--info-soft); color: var(--info); }
.t-violet { background: var(--violet-soft); color: var(--violet); }
.t-neutral { background: var(--neutral-soft); color: var(--text-2); }

/* KPI */
.kpis { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 900px) { .kpis { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; } }
.kpi { padding: 16px; display: grid; gap: 10px; }
.kpi-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.kpi-label { font-size: 13px; color: var(--text-2); font-weight: 600; }
.kpi-value { font-size: 26px; font-weight: 700; line-height: 1.1; letter-spacing: -.01em; }
.kpi-value small { font-size: 13px; font-weight: 600; color: var(--text-3); margin-inline-start: 4px; }
.kpi-sub { font-size: 12.5px; color: var(--text-3); }
@media (max-width: 420px) { .kpi-value { font-size: 22px; } .kpi { padding: 14px; } }

/* ===================== App shell ===================== */

.app { min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 1024px) { .app { grid-template-columns: var(--sidebar-w) minmax(0, 1fr); } }

.sidebar {
  display: none;
  position: sticky; top: 0; height: 100dvh;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  flex-direction: column;
  padding: 18px 14px;
  gap: 8px;
  overflow-y: auto;
}
@media (min-width: 1024px) { .sidebar { display: flex; } }

.brand { display: flex; align-items: center; gap: 12px; padding: 6px 8px 18px; border-bottom: 1px solid var(--sidebar-border); margin-bottom: 8px; }
.brand-mark {
  width: 42px; height: 42px; border-radius: 12px; flex: none;
  display: flex; align-items: center; justify-content: center; overflow: hidden;
  box-shadow: 0 0 0 1px rgba(255,255,255,.12);
}
.brand-mark { background: #00adef; }
.brand-mark img { width: 100% !important; height: 100%; object-fit: contain; padding: 9%; }
.brand-name { color: var(--sidebar-text-strong); font-weight: 700; font-size: 15px; line-height: 1.3; }
.brand-sub { font-size: 12px; color: var(--sidebar-text); opacity: .8; }

.nav { display: grid; gap: 2px; }
.nav-label { font-size: 11.5px; font-weight: 600; color: var(--sidebar-text); opacity: .6; padding: 12px 12px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  height: 42px; padding: 0 12px;
  border-radius: 10px;
  color: var(--sidebar-text);
  font-weight: 500; font-size: 14.5px;
  position: relative;
  border: 0; background: transparent; width: 100%; text-align: start;
}
.nav-item:hover { background: var(--sidebar-hover); color: var(--sidebar-text-strong); text-decoration: none; }
.nav-item.active { background: var(--sidebar-active); color: var(--sidebar-text-strong); font-weight: 600; }
.nav-item.active::before {
  content: ''; position: absolute; inset-inline-start: -14px; top: 10px; bottom: 10px; width: 3px; border-radius: 0 3px 3px 0;
  background: #4fb3f6;
}
.nav-item .count-badge { margin-inline-start: auto; }

.sidebar-foot { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--sidebar-border); display: grid; gap: 8px; }
.user-card { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 12px; color: var(--sidebar-text-strong); }
.user-card:hover { background: var(--sidebar-hover); text-decoration: none; }
.user-card .meta { min-width: 0; }
.user-card .name { font-weight: 600; font-size: 14px; }
.user-card .role { font-size: 12px; color: var(--sidebar-text); }

.avatar {
  width: 36px; height: 36px; border-radius: 50%; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px;
  background: var(--primary-soft); color: var(--primary-text);
}
.avatar.lg { width: 56px; height: 56px; font-size: 20px; }
.avatar.sm { width: 30px; height: 30px; font-size: 12px; }
.sidebar .avatar { background: rgba(79, 179, 246, .18); color: #9fd4fb; }

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

.topbar {
  position: sticky; top: 0; z-index: 30;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 12px;
  padding: 0 16px;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--border);
}
@media (min-width: 1024px) { .topbar { padding: 0 32px; } }
.topbar .title { min-width: 0; flex: 1; }
.topbar h1 { font-size: 18px; }
.topbar .crumb { font-size: 12.5px; color: var(--text-3); }
.topbar-mark { display: flex; }
@media (min-width: 1024px) { .topbar-mark { display: none; } }
.topbar-mark .brand-mark { width: 36px; height: 36px; border-radius: 10px; }
.topbar-mark .brand-mark img { width: 28px; }
.topbar-actions { display: flex; align-items: center; gap: 6px; }

.sync-pill {
  display: inline-flex; align-items: center; gap: 6px;
  height: 30px; padding: 0 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600;
  background: var(--success-soft); color: var(--success);
  border: 0;
}
.sync-pill::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.sync-pill.offline { background: var(--warning-soft); color: var(--warning); }
.sync-pill.syncing { background: var(--info-soft); color: var(--info); }
@media (max-width: 520px) { .sync-pill .label { display: none; } .sync-pill { padding: 0 9px; } }

.bell { position: relative; }
.bell .count-badge { position: absolute; top: -3px; inset-inline-end: -5px; box-shadow: 0 0 0 2px var(--bg); }

.content { padding: 18px 16px calc(var(--bottomnav-h) + 28px + env(safe-area-inset-bottom)); width: 100%; max-width: 1320px; margin: 0 auto; }
@media (min-width: 1024px) { .content { padding: 28px 32px 48px; } }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h1 { font-size: 22px; }
.page-head p { color: var(--text-2); font-size: 14px; margin-top: 2px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.bottom-nav {
  position: fixed; inset-inline: 0; bottom: 0; z-index: 40;
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  height: calc(var(--bottomnav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
}
@media (min-width: 1024px) { .bottom-nav { display: none; } }
.bn-item {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--text-3); font-size: 11.5px; font-weight: 600;
  border: 0; background: transparent; position: relative;
}
.bn-item:hover { text-decoration: none; color: var(--text-2); }
.bn-item svg { width: 22px; height: 22px; }
.bn-item.active { color: var(--primary-text); }
.bn-item.active::after { content: ''; position: absolute; top: 0; width: 28px; height: 3px; border-radius: 0 0 3px 3px; background: var(--primary); }
.bn-item .count-badge { position: absolute; top: 6px; inset-inline-start: calc(50% + 6px); }

/* ===================== Tabs / segmented ===================== */

.tabs {
  display: flex; gap: 4px; padding: 4px;
  background: var(--surface-3); border-radius: 12px;
  overflow-x: auto; scrollbar-width: none;
  max-width: 100%;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: none; display: inline-flex; align-items: center; gap: 8px;
  height: 36px; padding: 0 14px; border-radius: 9px; border: 0;
  background: transparent; color: var(--text-2); font-weight: 600; font-size: 13.5px;
}
.tab:hover { color: var(--text); }
.tab.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

.segmented { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; padding: 4px; background: var(--surface-3); border-radius: 12px; }
.segmented label { margin: 0; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; border-radius: 9px; font-weight: 600; font-size: 13.5px; color: var(--text-2); cursor: pointer;
}
.segmented input:checked + span { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.segmented input:focus-visible + span { outline: 3px solid var(--ring); }

/* ===================== Forms ===================== */

.form { display: grid; gap: 16px; }
.field { display: grid; gap: 6px; min-width: 0; }
.field > label, .label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.label-row { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.req::after { content: ' *'; color: var(--danger); }
.input, .select, .textarea {
  width: 100%;
  height: 44px;
  padding: 0 13px;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-size: 15px;
  transition: border-color .15s, box-shadow .15s;
  min-width: 0;
}
.textarea { height: auto; min-height: 84px; padding: 10px 13px; resize: vertical; line-height: 1.5; }
.select {
  appearance: none; -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%), linear-gradient(135deg, var(--text-3) 50%, transparent 50%);
  background-position: 18px 19px, 13px 19px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-inline-end: 13px; padding-inline-start: 34px;
}
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--ring); }
.input:disabled, .select:disabled, .textarea:disabled, .input[readonly] { background: var(--surface-2); color: var(--text-2); }
.input.lg { height: 52px; font-size: 18px; font-weight: 600; }
.input[type="number"] { direction: ltr; text-align: right; }
.input[type="datetime-local"], .input[type="date"], .input[type="month"] { direction: ltr; text-align: right; }
.hint { font-size: 12.5px; color: var(--text-3); }
.field-error { font-size: 12.5px; color: var(--danger); font-weight: 500; }
.input-wrap { position: relative; }
.input-wrap .input { padding-inline-start: 42px; }
.input-wrap > svg { position: absolute; inset-inline-start: 13px; top: 50%; transform: translateY(-50%); color: var(--text-3); pointer-events: none; }
.input-wrap .suffix { position: absolute; inset-inline-end: 6px; top: 50%; transform: translateY(-50%); }
.input-wrap.has-suffix .input { padding-inline-end: 44px; }
.unit-wrap { position: relative; }
.unit-wrap .unit { position: absolute; inset-inline-end: 12px; top: 50%; transform: translateY(-50%); color: var(--text-3); font-size: 13px; font-weight: 600; pointer-events: none; }
.unit-wrap .input { padding-inline-end: 52px; }

.check { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; font-size: 14px; }
.check input { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--primary); flex: none; }
.check .desc { display: block; font-size: 12.5px; color: var(--text-3); }

.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 600; font-size: 14px; }
.switch input { appearance: none; -webkit-appearance: none; width: 42px; height: 24px; border-radius: 999px; background: var(--border-strong); position: relative; transition: background .15s; margin: 0; flex: none; cursor: pointer; }
.switch input::after { content: ''; position: absolute; top: 3px; inset-inline-start: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.2); transition: inset-inline-start .15s; }
.switch input:checked { background: var(--primary); }
.switch input:checked::after { inset-inline-start: 21px; }

.fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; display: grid; gap: 14px; background: var(--surface-2); }
.fieldset-title { font-weight: 700; font-size: 14px; display: flex; align-items: center; gap: 8px; }

.tags-input {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  min-height: 44px; padding: 6px 8px; border-radius: 10px;
  border: 1px solid var(--border-strong); background: var(--surface);
}
.tags-input:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--ring); }
.tags-input input { border: 0; outline: 0; background: transparent; flex: 1; min-width: 120px; height: 30px; padding: 0 4px; }

/* Photo input */
.photo-input { display: grid; gap: 8px; }
.photo-drop {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; border-radius: 12px;
  border: 1.5px dashed var(--border-strong); background: var(--surface-2);
  color: var(--text-2); cursor: pointer; text-align: start; width: 100%;
}
.photo-drop:hover { border-color: var(--primary); color: var(--primary-text); }
.photo-drop strong { display: block; color: var(--text); font-size: 14px; }
.photo-preview { position: relative; border-radius: 12px; overflow: hidden; border: 1px solid var(--border); background: var(--surface-3); }
.photo-preview img { width: 100%; max-height: 220px; object-fit: contain; }
.photo-preview .remove { position: absolute; top: 8px; inset-inline-end: 8px; }

/* ===================== Tables ===================== */

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; }
.table th {
  text-align: start; font-size: 12.5px; font-weight: 600; color: var(--text-3);
  padding: 10px 14px; background: var(--surface-2); border-bottom: 1px solid var(--border);
  white-space: nowrap; position: sticky; top: 0;
}
.table td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background .1s; }
.table tbody tr:hover { background: var(--surface-2); }
.table tr.clickable { cursor: pointer; }
.table .actions { display: flex; gap: 4px; justify-content: flex-end; }
.table tfoot td { background: var(--surface-2); font-weight: 700; }
.cell-title { font-weight: 600; }
.cell-sub { font-size: 12.5px; color: var(--text-3); }

@media (max-width: 760px) {
  .table.responsive thead { display: none; }
  .table.responsive, .table.responsive tbody, .table.responsive tr, .table.responsive td { display: block; width: 100%; }
  .table.responsive tr { padding: 12px 14px; border-bottom: 1px solid var(--border); display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; }
  .table.responsive tr:last-child { border-bottom: 0; }
  .table.responsive td { padding: 0; border: 0; min-width: 0; }
  .table.responsive td[data-label]::before { content: attr(data-label); display: block; font-size: 11.5px; color: var(--text-3); font-weight: 600; margin-bottom: 1px; }
  .table.responsive td.primary-cell { grid-column: 1 / -1; }
  .table.responsive td.actions-cell { grid-column: 1 / -1; }
  .table.responsive .actions { justify-content: flex-start; }
  .table.responsive tfoot { display: block; }
  .table.responsive tfoot tr { background: var(--surface-2); }
}

/* ===================== Lists ===================== */

.list { display: grid; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--border); min-width: 0; }
.list-item:last-child { border-bottom: 0; }
.list-item.clickable { cursor: pointer; }
.list-item.clickable:hover { background: var(--surface-2); }
.list-item .meta { min-width: 0; flex: 1; }
.list-item .title { font-weight: 600; font-size: 14.5px; }
.list-item .sub { font-size: 12.5px; color: var(--text-3); display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.list-item .sub span { display: inline-flex; align-items: center; gap: 4px; }

.dl { display: grid; grid-template-columns: auto 1fr; gap: 10px 16px; font-size: 14px; }
.dl dt { color: var(--text-3); font-weight: 500; }
.dl dd { margin: 0; font-weight: 600; min-width: 0; overflow-wrap: anywhere; }

.info-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 640px) { .info-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.info-cell { background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; min-width: 0; }
.info-cell .k { font-size: 12px; color: var(--text-3); font-weight: 600; }
.info-cell .v { font-size: 15px; font-weight: 700; margin-top: 2px; overflow-wrap: anywhere; }

/* ===================== Empty / loading ===================== */

.empty { text-align: center; padding: 36px 20px; display: grid; justify-items: center; gap: 8px; color: var(--text-2); }
.empty .icon-tile { width: 56px; height: 56px; border-radius: 18px; margin-bottom: 4px; }
.empty h3 { color: var(--text); font-size: 15.5px; }
.empty p { font-size: 13.5px; max-width: 360px; }

.skeleton { background: linear-gradient(90deg, var(--surface-3), var(--surface-2), var(--surface-3)); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: 10px; }
@keyframes shimmer { to { background-position: -200% 0; } }

.boot { min-height: 100dvh; display: grid; place-items: center; gap: 16px; color: var(--text-3); }
.boot .brand-mark { width: 64px; height: 64px; border-radius: 18px; }
.boot .brand-mark img { width: 52px; }

/* ===================== Notice / alert ===================== */

.notice {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 12px 14px; border-radius: 12px;
  background: var(--info-soft); color: var(--text);
  border: 1px solid color-mix(in srgb, var(--info) 22%, transparent);
  font-size: 14px;
}
.notice > svg { color: var(--info); margin-top: 2px; }
.notice.warning { background: var(--warning-soft); border-color: color-mix(in srgb, var(--warning) 25%, transparent); }
.notice.warning > svg { color: var(--warning); }
.notice.danger { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 25%, transparent); }
.notice.danger > svg { color: var(--danger); }
.form-error { margin-top: 14px; }
.photo-status { margin-top: 8px; color: var(--text-2); display: flex; align-items: center; gap: 6px; }
.photo-status.error { color: var(--danger); font-weight: 600; }
.notice.success { background: var(--success-soft); border-color: color-mix(in srgb, var(--success) 25%, transparent); }
.notice.success > svg { color: var(--success); }
.notice .grow > strong { display: block; }
.mfa-enrollment { display: grid; justify-items: start; gap: 12px; }
.mfa-enrollment img { width: min(220px, 100%); height: auto; padding: 10px; border-radius: 12px; background: #fff; border: 1px solid var(--border); }
.mfa-otpauth { display: block; max-width: 100%; margin-top: 8px; padding: 10px; border-radius: 8px; background: var(--surface-2); overflow-wrap: anywhere; user-select: all; }
.mfa-backup-codes { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; max-width: 560px; }
.mfa-backup-codes code { padding: 10px 12px; text-align: center; border: 1px solid var(--border); border-radius: 9px; background: var(--surface-2); font-size: 15px; font-weight: 700; letter-spacing: .08em; }

/* ===================== Gauge / progress ===================== */

.gauge { height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.gauge > span { display: block; height: 100%; border-radius: inherit; background: var(--success); transition: width .3s; }
.gauge.low > span { background: var(--danger); }
.gauge.mid > span { background: var(--warning); }

.bar-list { display: grid; gap: 12px; }
.bar-row { display: grid; gap: 6px; }
.bar-row .between { font-size: 13.5px; }
.bar-track { height: 10px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.bar-track > span { display: block; height: 100%; border-radius: inherit; background: var(--primary); }

/* ===================== Modal (dialog) ===================== */

dialog.modal {
  border: 0; padding: 0;
  width: min(600px, calc(100vw - 32px));
  max-height: calc(100dvh - 48px);
  border-radius: var(--radius-xl);
  background: var(--surface); color: var(--text);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
dialog.modal.wide { width: min(880px, calc(100vw - 32px)); }
dialog.modal.narrow { width: min(440px, calc(100vw - 32px)); }
dialog.modal[open] { display: flex; flex-direction: column; animation: modal-in .18s ease-out; }
dialog.modal::backdrop { background: var(--backdrop); backdrop-filter: blur(2px); }
@keyframes modal-in { from { opacity: 0; transform: translateY(10px) scale(.985); } }
.modal-h { display: flex; align-items: center; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--border); flex: none; }
.modal-h h2 { font-size: 16.5px; flex: 1; min-width: 0; }
.modal-h .sub { font-size: 12.5px; color: var(--text-3); font-weight: 500; }
/* flex-basis auto (وليس 0%) — Safari على iPhone يطوي المحتوى إلى ارتفاع صفر عندما يكون ارتفاع النافذة غير محدد */
.modal-b { padding: 18px; overflow-y: auto; flex: 1 1 auto; min-height: 0; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.modal-f { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 18px; border-top: 1px solid var(--border); background: var(--surface-2); flex: none; flex-wrap: wrap; }
.modal-f .spacer { flex: 1; }
.modal > form { display: flex; flex-direction: column; min-height: 0; flex: 1 1 auto; }

@media (max-width: 640px) {
  dialog.modal, dialog.modal.wide, dialog.modal.narrow {
    width: 100vw; max-width: 100vw;
    margin: auto 0 0;
    max-height: 94dvh;
    border-radius: 22px 22px 0 0;
  }
  dialog.modal[open] { animation: sheet-in .22s cubic-bezier(.2,.8,.2,1); }
  .modal-f { padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
  .modal-f .btn { flex: 1; }
  .modal-f .spacer { display: none; }
}
@keyframes sheet-in { from { transform: translateY(40px); opacity: .4; } }

/* ===================== Toasts ===================== */

.toasts {
  position: fixed; z-index: 100;
  top: 12px; inset-inline: 12px;
  display: grid; gap: 8px; justify-items: center;
  pointer-events: none;
}
@media (min-width: 1024px) { .toasts { top: auto; bottom: 24px; inset-inline-start: auto; inset-inline-end: 24px; justify-items: end; } }
.toast {
  pointer-events: auto;
  display: flex; align-items: center; gap: 10px;
  max-width: 440px; width: max-content; min-width: 0;
  padding: 11px 14px; border-radius: 12px;
  background: #0f1d30; color: #f1f5fb;
  box-shadow: var(--shadow-lg);
  font-size: 14px; font-weight: 500;
  animation: toast-in .2s ease-out;
}
.toast.out { opacity: 0; transform: translateY(-6px); transition: .2s; }
.toast svg { flex: none; }
.toast.success svg { color: #4ade9c; }
.toast.error svg { color: #ff8593; }
.toast.warning svg { color: #fbbf5c; }
.toast.info svg { color: #7cc0f2; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } }

/* ===================== Popover (notifications) ===================== */

.popover {
  position: fixed; z-index: 60;
  top: calc(var(--topbar-h) + 6px); inset-inline-end: 12px;
  width: min(400px, calc(100vw - 24px));
  max-height: min(560px, calc(100dvh - 100px));
  display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  box-shadow: var(--shadow-lg); overflow: hidden;
  animation: modal-in .15s ease-out;
}
@media (min-width: 1024px) { .popover { inset-inline-end: 32px; } }
.popover .list { overflow-y: auto; }
.notif { display: flex; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.notif.unread { background: color-mix(in srgb, var(--primary-soft) 60%, transparent); }
.notif .meta { flex: 1; min-width: 0; font-size: 13.5px; }
.notif .time { font-size: 12px; color: var(--text-3); margin-top: 2px; }

/* ===================== Login ===================== */

.login { min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 1fr); background: var(--bg); }
@media (min-width: 960px) { .login { grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); } }
.login-brand {
  display: none;
  position: relative; overflow: hidden;
  background: radial-gradient(120% 90% at 100% 0%, #0a8ad8 0%, #0072bc 32%, #063b66 70%, #071f38 100%);
  color: #fff; padding: 48px;
  flex-direction: column; justify-content: space-between;
}
@media (min-width: 960px) { .login-brand { display: flex; } }
.login-brand::after {
  content: ''; position: absolute; inset: 0;
  background-image: radial-gradient(rgba(255,255,255,.09) 1px, transparent 1px);
  background-size: 22px 22px;
  mask-image: linear-gradient(180deg, transparent, #000 40%, #000 70%, transparent);
  pointer-events: none;
}
.login-brand > * { position: relative; z-index: 1; }
.login-brand img { width: 190px; }
.login-brand h2 { font-size: 34px; line-height: 1.25; font-weight: 700; max-width: 460px; }
.login-brand p { color: rgba(255,255,255,.78); font-size: 16px; max-width: 440px; margin-top: 14px; }
.login-features { display: grid; gap: 14px; margin-top: 34px; }
.login-features div { display: flex; align-items: center; gap: 12px; color: rgba(255,255,255,.9); font-size: 14.5px; }
.login-features .icon-tile { background: rgba(255,255,255,.12); color: #fff; }
.login-brand .foot { font-size: 12.5px; color: rgba(255,255,255,.6); }

.login-panel { display: flex; align-items: center; justify-content: center; padding: 28px 18px; }
.login-card { width: 100%; max-width: 400px; display: grid; gap: 22px; }
.login-mobile-brand { display: flex; align-items: center; gap: 12px; }
@media (min-width: 960px) { .login-mobile-brand { display: none; } }
.login-mobile-brand .brand-mark { width: 52px; height: 52px; border-radius: 15px; }
.login-mobile-brand .brand-mark img { width: 42px; }
.login-card h1 { font-size: 24px; }
.login-card .lead { color: var(--text-2); margin-top: 4px; }

/* ===================== Driver hero ===================== */

.hero {
  position: relative; overflow: hidden;
  border-radius: var(--radius-xl);
  background: linear-gradient(150deg, var(--hero-from), var(--hero-to));
  color: #fff;
  padding: 20px;
  box-shadow: var(--shadow);
}
.hero::after {
  content: ''; position: absolute; width: 320px; height: 320px; border-radius: 50%;
  inset-inline-end: -120px; top: -160px;
  background: radial-gradient(circle, rgba(255,255,255,.14), transparent 65%);
  pointer-events: none;
}
.hero > * { position: relative; z-index: 1; }
.hero .muted, .hero .subtle { color: rgba(255,255,255,.75); }
.hero .timer { font-size: 40px; font-weight: 700; letter-spacing: .02em; line-height: 1.1; }
.hero .live { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; background: rgba(255,255,255,.14); padding: 4px 10px; border-radius: 999px; }
.hero .live::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: #4ade9c; box-shadow: 0 0 0 0 rgba(74,222,156,.7); animation: pulse 1.8s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 8px rgba(74,222,156,0); } 100% { box-shadow: 0 0 0 0 rgba(74,222,156,0); } }
.hero .hero-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; }
@media (min-width: 640px) { .hero .hero-grid { grid-template-columns: repeat(4, minmax(0,1fr)); } }
.hero .hero-cell { background: rgba(255,255,255,.1); border-radius: 12px; padding: 10px 12px; min-width: 0; }
.hero .hero-cell .k { font-size: 12px; color: rgba(255,255,255,.7); }
.hero .hero-cell .v { font-weight: 700; margin-top: 2px; overflow-wrap: anywhere; }
.hero .btn-white { --btn-bg: #fff; --btn-fg: #0a3357; --btn-border: #fff; }
.hero .btn-white:hover { background: #eef5fb; }
.hero .btn-glass { --btn-bg: rgba(255,255,255,.12); --btn-fg: #fff; --btn-border: rgba(255,255,255,.2); }
.hero .btn-glass:hover { background: rgba(255,255,255,.2); }

.cta-card {
  display: flex; align-items: center; gap: 16px;
  width: 100%; padding: 20px; text-align: start;
  border-radius: var(--radius-xl);
  background: linear-gradient(150deg, var(--hero-from), var(--hero-to));
  color: #fff; border: 0;
  box-shadow: var(--shadow);
}
.cta-card:hover { filter: brightness(1.05); }
.cta-card .icon-tile { background: rgba(255,255,255,.16); color: #fff; width: 56px; height: 56px; border-radius: 18px; }
.cta-card strong { display: block; font-size: 18px; }
.cta-card span { color: rgba(255,255,255,.78); font-size: 13.5px; }

.dispatch-card { border-inline-start: 4px solid var(--warning); }
.dispatch-card.accepted { border-inline-start-color: var(--success); }

/* People board */
.person { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.person:last-child { border-bottom: 0; }
.person .meta { flex: 1; min-width: 0; }
.person .name { font-weight: 600; font-size: 14.5px; }
.person .sub { font-size: 12.5px; color: var(--text-3); display: flex; flex-wrap: wrap; gap: 4px 12px; }
.person .sub span { display: inline-flex; align-items: center; gap: 4px; }
.status-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--success); box-shadow: 0 0 0 3px var(--success-soft); }
.status-dot.busy { background: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }
.status-dot.pending { background: var(--warning); box-shadow: 0 0 0 3px var(--warning-soft); }

/* Vehicle card */
.vehicle-card { display: grid; gap: 14px; padding: 16px; }
.vehicle-card .head { display: flex; align-items: flex-start; gap: 12px; }
.vehicle-card .head .meta { flex: 1; min-width: 0; }
.vehicle-card .name { font-weight: 700; font-size: 15.5px; }
.vehicle-card .plate {
  display: inline-flex; align-items: center; gap: 4px; margin-top: 4px;
  font-size: 12.5px; font-weight: 600; padding: 2px 8px; border-radius: 6px;
  border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text-2);
}
.vehicle-card .stats { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; }
.vehicle-card .foot { display: flex; gap: 6px; flex-wrap: wrap; padding-top: 12px; border-top: 1px solid var(--border); }

.cards-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }

/* Permission matrix */
.perm-group { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.perm-group-h { padding: 8px 12px; font-size: 12.5px; font-weight: 700; color: var(--text-2); background: var(--surface-2); border-bottom: 1px solid var(--border); }
.perm-group .check { padding: 10px 12px; border-bottom: 1px solid var(--border); }
.perm-group .check:last-child { border-bottom: 0; }
.perm-group .check.changed { background: var(--warning-soft); }

/* Filters bar */
.filters { display: grid; gap: 10px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.filters .search { grid-column: 1 / -1; }
@media (min-width: 900px) { .filters { grid-template-columns: 2fr repeat(5, minmax(0, 1fr)); } .filters .search { grid-column: auto; } }
.filters .input, .filters .select { height: 40px; font-size: 14px; }

.more-row { display: flex; justify-content: center; padding: 14px; border-top: 1px solid var(--border); }

/* Charts */
.chart-box { position: relative; height: 260px; }
@media (max-width: 640px) { .chart-box { height: 220px; } }

/* Photos gallery */
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.photo-thumb { border-radius: 12px; overflow: hidden; border: 1px solid var(--border); background: var(--surface-3); display: block; position: relative; aspect-ratio: 4 / 3; }
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; }
.photo-thumb span { position: absolute; bottom: 0; inset-inline: 0; padding: 4px 8px; font-size: 12px; font-weight: 600; color: #fff; background: linear-gradient(transparent, rgba(0,0,0,.65)); }

.lightbox { width: min(980px, calc(100vw - 24px)); }
.lightbox img { width: 100%; max-height: calc(100dvh - 140px); object-fit: contain; background: #000; }

/* Timeline */
.timeline { display: grid; gap: 0; }
.tl-item { display: grid; grid-template-columns: 28px 1fr; gap: 10px; position: relative; padding-bottom: 14px; }
.tl-item:not(:last-child)::before { content: ''; position: absolute; inset-inline-start: 13px; top: 26px; bottom: 0; width: 2px; background: var(--border); }
.tl-dot { width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: var(--primary-soft); color: var(--primary-text); }
.tl-dot svg { width: 14px; height: 14px; }

/* ===================== Print ===================== */

#printRoot { display: none; }
/* ======================= الميزات الميدانية ======================= */
.ocr-hint { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-top: 8px; padding: 8px 10px; border-radius: var(--radius-sm); background: var(--info-soft); color: var(--info); font-size: 13px; }
.ocr-hint.warn { background: var(--warning-soft); color: var(--warning); }
.ocr-hint .btn { height: 28px; }
.spinner.sm { width: 14px; height: 14px; border-width: 2px; }
.loc-line { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-3); }
.loc-line.ok { color: var(--success); }
.hero-alert { display: flex; gap: 10px; align-items: flex-start; margin-top: 12px; padding: 12px 14px; border-radius: var(--radius); background: rgba(255, 255, 255, 0.14); border: 1px solid rgba(255, 210, 120, 0.5); color: #fff; font-size: 13.5px; }
.hero-alert strong { display: block; margin-bottom: 2px; }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }

/* الحجوزات */
.week-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-top: 1px solid var(--border); }
.week-day { min-height: 140px; border-inline-start: 1px solid var(--border); display: flex; flex-direction: column; }
.week-day:first-child { border-inline-start: 0; }
.week-day.past { background: var(--neutral-soft); }
.week-day.today .wd-head { color: var(--primary-text); background: var(--primary-soft); }
.wd-head { display: flex; justify-content: space-between; align-items: center; gap: 4px; padding: 8px 10px; font-size: 12.5px; font-weight: 600; border-bottom: 1px solid var(--border); }
.wd-body { display: flex; flex-direction: column; gap: 6px; padding: 8px; }
.bk-item { all: unset; cursor: pointer; display: flex; flex-direction: column; gap: 1px; padding: 6px 8px; border-radius: var(--radius-sm); font-size: 12px; background: var(--success-soft); border-inline-start: 3px solid var(--success); }
.bk-item.s-pending { background: var(--warning-soft); border-color: var(--warning); }
.bk-item:focus-visible { outline: 2px solid var(--primary); }
.bk-time { font-weight: 700; }
.bk-team { font-weight: 600; }
.bk-sub { color: var(--text-3); font-size: 11.5px; }
.pending-card { border-inline-start: 4px solid var(--warning); }
@media (max-width: 899px) {
  .week-grid { grid-template-columns: 1fr; }
  .week-day { min-height: 0; border-inline-start: 0; border-top: 1px solid var(--border); }
  .week-day:first-child { border-top: 0; }
  .wd-body { flex-direction: row; flex-wrap: wrap; }
  .bk-item { flex: 1 1 200px; }
}

/* المالية */
.lock-bar { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; padding: 14px 16px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); }
.lock-bar > svg { flex: none; }
.lock-bar .grow { min-width: 220px; font-size: 13.5px; color: var(--text-2, inherit); }
.lock-bar strong { display: block; color: var(--text); }
.lock-bar.locked { border-color: var(--success); background: var(--success-soft); }
.lock-bar.locked > svg { color: var(--success); }
.lock-bar.stale { border-color: var(--warning); background: var(--warning-soft); }
.lock-bar.stale > svg { color: var(--warning); }
.lock-bar.open > svg { color: var(--text-3); }
.delta { display: inline-flex; align-items: center; gap: 2px; font-size: 12px; font-weight: 600; color: var(--text-3); white-space: nowrap; }
.delta.up { color: var(--danger); }
.delta.down { color: var(--success); }
.chart-box.tall { height: 320px; }
.grid-2 > .span-2 { grid-column: 1 / -1; }
.row-flag td { background: color-mix(in srgb, var(--danger-soft) 55%, transparent); }
button.badge { border: 0; cursor: pointer; font: inherit; }
.card.attention { border-inline-start: 4px solid var(--danger); }
a.list-item { color: inherit; text-decoration: none; }

/* كشف الحساب الرسمي (للطباعة) */
#printRoot { display: none; }
.st-doc { position: relative; color: #111; background: #fff; font-size: 12px; }
@media print {
  @page statement { size: A4 portrait; margin: 14mm 12mm; }
  #printRoot .st-doc { page: statement; break-after: page; }
  #printRoot .st-doc:last-child { break-after: auto; }
  #printRoot .st-doc * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .st-head { display: flex; align-items: center; gap: 14px; padding-bottom: 10px; border-bottom: 3px solid #0072bc; }
  .st-logo { width: 64px; height: 64px; object-fit: contain; }
  .st-org { flex: 1; }
  .st-org-name { font-size: 17px; font-weight: 700; color: #0a2540; }
  .st-org-sub { color: #555; }
  .st-meta { font-size: 11px; line-height: 1.7; text-align: left; }
  .st-meta span { color: #666; }
  #printRoot .st-title { text-align: center; font-size: 19px; margin: 18px 0 4px; }
  .st-sub { text-align: center; margin-bottom: 14px; font-size: 13px; }
  #printRoot .st-summary { margin-bottom: 14px; }
  #printRoot .st-summary th { background: #e8eef5 !important; text-align: center; }
  #printRoot .st-summary td { text-align: center; font-size: 14px; }
  #printRoot .st-table td, #printRoot .st-table th { font-size: 11px; padding: 4px 5px; }
  #printRoot .st-table tbody tr:nth-child(even) td { background: #f7f9fb !important; }
  #printRoot .st-table tr { break-inside: avoid; }
  .st-note { color: #666; font-size: 9.5px; }
  .st-rule { margin-top: 10px; color: #444; font-size: 11px; }
  .st-signs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 22px; margin-top: 34px; break-inside: avoid; }
  .st-sign-label { font-weight: 700; margin-bottom: 38px; }
  .st-line { border-bottom: 1px solid #333; }
  .st-sign-hint { color: #777; font-size: 10px; margin-top: 4px; }
  .st-foot { margin-top: 24px; text-align: center; color: #888; font-size: 10px; border-top: 1px solid #ddd; padding-top: 6px; }
  .st-watermark { position: absolute; inset: 30% 0 auto 0; text-align: center; font-size: 110px; font-weight: 800; color: rgba(196, 43, 58, 0.09); transform: rotate(-24deg); pointer-events: none; }
}

@media print {
  @page { size: A4 landscape; margin: 12mm; }
  body { background: #fff !important; color: #000 !important; }
  body > *:not(#printRoot) { display: none !important; }
  #printRoot { display: block !important; font-size: 11px; }
  #printRoot h1 { font-size: 18px; margin-bottom: 4px; }
  #printRoot .meta { color: #444; margin-bottom: 12px; }
  #printRoot table { width: 100%; border-collapse: collapse; }
  #printRoot th, #printRoot td { border: 1px solid #999; padding: 5px 6px; text-align: right; }
  #printRoot th { background: #e8eef5 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  #printRoot tfoot td { font-weight: 700; background: #f3f3f3 !important; }
  #printRoot .sign { display: flex; justify-content: space-between; margin-top: 40px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
