/* Saaed FMS · Direction A · shared tokens
   Inline this anywhere via <link rel="stylesheet" href="../_shell.css">
   OR copy the :root block + body rule for a self-contained file. */

:root {
  --saaed-red: #C8102E;
  --saaed-red-600: #A60E26;
  --saaed-red-700: #870B1F;
  --saaed-red-50: #FDECEE;
  --saaed-red-100: #F9D2D7;

  --ink-900: #0E141B;
  --ink-800: #1A222C;
  --ink-700: #2C3744;
  --ink-600: #4A5667;
  --ink-500: #6B7787;
  --ink-400: #8D98A8;
  --ink-300: #B4BDC9;
  --ink-200: #D5DBE3;
  --ink-100: #E8ECF1;
  --ink-50: #F4F6F9;
  --ink-0: #FFFFFF;

  --bg-app: #F7F8FA;
  --bg-card: #FFFFFF;
  --bg-tinted: #F4F6F9;

  --ok: #1F8A5B; --ok-50: #E6F4EE; --ok-100: #C5E5D6;
  --warn: #C77600; --warn-50: #FCEFD9; --warn-100: #F5DCA6;
  --danger: #C8102E; --danger-50: #FDECEE;
  --info: #1A5FB4; --info-50: #E4EEF9; --info-100: #C0D5EE;
  --purple: #6E3FB5; --purple-50: #EEE6F8;
  --orange: #D2691E; --orange-50: #FBEADB;
  --neutral: #6B7787; --neutral-50: #ECEFF3;

  --dv-1:#C8102E; --dv-2:#0E3B5C; --dv-3:#1F8A5B; --dv-4:#C77600;
  --dv-5:#6E3FB5; --dv-6:#1A5FB4; --dv-7:#D2691E; --dv-8:#6B7787;

  --font-sans: "IBM Plex Sans","IBM Plex Sans Arabic",-apple-system,"Segoe UI",sans-serif;
  --font-arabic: "IBM Plex Sans Arabic","IBM Plex Sans",-apple-system,sans-serif;
  --font-mono: "IBM Plex Mono",ui-monospace,SFMono-Regular,Menlo,monospace;

  --r-xs:3px; --r-sm:6px; --r-md:8px; --r-lg:12px; --r-xl:16px; --r-pill:999px;
  --shadow-1: 0 1px 0 rgba(14,20,27,0.04), 0 1px 2px rgba(14,20,27,0.04);
  --shadow-pop: 0 12px 40px rgba(14,20,27,0.14), 0 2px 8px rgba(14,20,27,0.06);

  --topbar-h: 56px;
  --sidebar-w: 240px;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin:0; padding:0; background: var(--bg-app); color: var(--ink-800); font-family: var(--font-sans); font-size: 14px; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
button { font-family: inherit; }
a { color: inherit; text-decoration: none; }

/* ========== Type ========== */
.t-display { font-size: 56px; line-height: 62px; font-weight: 600; letter-spacing: -0.02em; color: var(--ink-900); }
.t-h1 { font-size: 32px; line-height: 40px; font-weight: 600; letter-spacing: -0.015em; color: var(--ink-900); }
.t-h2 { font-size: 24px; line-height: 32px; font-weight: 600; letter-spacing: -0.01em; color: var(--ink-900); }
.t-h3 { font-size: 20px; line-height: 28px; font-weight: 600; color: var(--ink-900); }
.t-h4 { font-size: 16px; line-height: 24px; font-weight: 600; color: var(--ink-900); }
.t-caption { font-size: 12px; line-height: 16px; font-weight: 500; color: var(--ink-500); letter-spacing: 0.02em; }
.t-overline { font-size: 11px; line-height: 14px; font-weight: 600; color: var(--ink-500); letter-spacing: 0.08em; text-transform: uppercase; }
.t-num { font-family: var(--font-mono); font-feature-settings: "tnum" 1; }
.t-link { color: var(--saaed-red); border-bottom: 1px solid transparent; }
.t-link:hover { border-bottom-color: var(--saaed-red); }
.ar { font-family: var(--font-arabic); direction: rtl; }
.mono { font-family: var(--font-mono); font-feature-settings: "tnum" 1; }

/* ========== App shell ========== */
.app { display: grid; grid-template-rows: var(--topbar-h) 1fr; height: 100vh; }
.app-body { display: grid; grid-template-columns: var(--sidebar-w) 1fr; height: calc(100vh - var(--topbar-h)); }
.content { overflow: auto; padding: 24px 32px 64px; }

/* ========== Top bar ========== */
.topbar { background: #fff; border-bottom: 1px solid var(--ink-100); display: flex; align-items: center; padding: 0 16px; gap: 12px; position: relative; z-index: 30; }
.topbar .logo { display: flex; align-items: center; gap: 12px; padding-right: 16px; }
/* logo-img-override */
.topbar .logo-mark { width: auto; height: 32px; background: transparent; display: inline-flex; align-items: center; justify-content: center; padding: 2px; }
.topbar .logo-mark img { display: block; }
.topbar .logo-name { font-size: 13px; font-weight: 600; color: var(--ink-900); line-height: 1.1; }
.topbar .logo-sub { font-size: 11px; color: var(--ink-500); }
.topbar .divider { width: 1px; height: 24px; background: var(--ink-100); margin: 0 4px; }
.topbar .search { flex: 1; max-width: 480px; margin-left: 8px; }
.topbar .search-input { display: flex; align-items: center; gap: 8px; height: 36px; background: var(--ink-50); border: 1px solid transparent; border-radius: 6px; padding: 0 12px; }
.topbar .search-input input { flex: 1; border: 0; outline: 0; background: transparent; font: inherit; color: var(--ink-900); min-width: 0; }
.topbar .search-input .kbd { font-family: var(--font-mono); font-size: 11px; color: var(--ink-400); background: #fff; border: 1px solid var(--ink-200); padding: 1px 6px; border-radius: 3px; }
.topbar .right { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.iconbtn { width: 36px; height: 36px; border-radius: 6px; background: transparent; border: 0; cursor: pointer; color: var(--ink-700); display: inline-flex; align-items: center; justify-content: center; position: relative; }
.iconbtn:hover { background: var(--ink-50); }
.iconbtn .badge { position: absolute; top: 4px; right: 4px; background: var(--saaed-red); color: #fff; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 999px; font-size: 10px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; font-family: var(--font-mono); }
.user-chip { display: inline-flex; align-items: center; gap: 10px; padding: 4px 10px 4px 4px; cursor: pointer; border-radius: 6px; }
.user-chip:hover { background: var(--ink-50); }
.user-chip .av { width: 28px; height: 28px; border-radius: 50%; background: var(--ink-900); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 600; font-size: 12px; }
.user-chip .name-block { line-height: 1.1; }
.user-chip .name { font-size: 13px; font-weight: 500; color: var(--ink-900); }
.user-chip .role { font-size: 11px; color: var(--ink-500); }

/* ========== Sidebar ========== */
.sidebar { background: #fff; border-right: 1px solid var(--ink-100); padding: 12px; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.nav-section-title { font-size: 10px; font-weight: 600; color: var(--ink-400); text-transform: uppercase; letter-spacing: 0.08em; padding: 12px 12px 6px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 6px; color: var(--ink-700); cursor: pointer; font-size: 13px; font-weight: 500; text-align: start; border: 1px solid transparent; background: transparent; width: 100%; }
.nav-item:hover { background: var(--ink-50); color: var(--ink-900); }
.nav-item.active { background: var(--saaed-red-50); color: var(--saaed-red); }
.nav-item .ico { color: inherit; opacity: 0.8; }
.nav-item .count { margin-left: auto; font-family: var(--font-mono); font-size: 11px; color: var(--ink-500); background: var(--ink-100); padding: 1px 6px; border-radius: 999px; }
.nav-item.active .count { background: #fff; color: var(--saaed-red); }

/* ========== Page chrome ========== */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.page-head .breadcrumb { font-size: 13px; color: var(--ink-500); display: flex; gap: 6px; align-items: center; }
.page-head .breadcrumb .sep { color: var(--ink-300); }
.page-head .breadcrumb .current { color: var(--saaed-red); font-weight: 500; }
.page-head h1 { margin: 8px 0 0; font-size: 28px; line-height: 36px; font-weight: 600; letter-spacing: -0.015em; color: var(--ink-900); }
.page-head .subtitle { color: var(--ink-500); font-size: 14px; margin-top: 4px; }
.page-head .actions { display: flex; gap: 8px; align-items: center; }

/* ========== Card ========== */
.card { background: #fff; border: 1px solid var(--ink-100); border-radius: 8px; box-shadow: var(--shadow-1); padding: 24px; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 16px; gap: 16px; }
.card-head h3 { margin: 0; font-size: 16px; font-weight: 600; color: var(--ink-900); }
.card-head .subtitle { color: var(--ink-500); font-size: 12px; margin-top: 4px; }
.card-head .actions { display: flex; gap: 8px; }

/* ========== Buttons ========== */
.btn { display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 14px; border-radius: 6px; font-size: 14px; font-weight: 500; border: 1px solid transparent; cursor: pointer; transition: background 120ms, border-color 120ms; }
.btn.sm { height: 28px; padding: 0 10px; font-size: 13px; }
.btn-primary { background: var(--saaed-red); color: #fff; }
.btn-primary:hover { background: var(--saaed-red-600); }
.btn-secondary { background: #fff; color: var(--ink-800); border-color: var(--ink-200); }
.btn-secondary:hover { background: var(--ink-50); }
.btn-ghost { background: transparent; color: var(--ink-700); }
.btn-ghost:hover { background: var(--ink-50); }
.btn-danger { background: #fff; color: var(--saaed-red); border-color: var(--saaed-red-100); }
.btn-danger:hover { background: var(--saaed-red-50); }

/* ========== Pills ========== */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 500; line-height: 18px; }
.pill .dot { width: 6px; height: 6px; border-radius: 50%; }
.pill.ok { background: var(--ok-50); color: var(--ok); } .pill.ok .dot { background: var(--ok); }
.pill.warn { background: var(--warn-50); color: var(--warn); } .pill.warn .dot { background: var(--warn); }
.pill.danger { background: var(--danger-50); color: var(--danger); } .pill.danger .dot { background: var(--danger); }
.pill.info { background: var(--info-50); color: var(--info); } .pill.info .dot { background: var(--info); }
.pill.purple { background: var(--purple-50); color: var(--purple); } .pill.purple .dot { background: var(--purple); }
.pill.orange { background: var(--orange-50); color: var(--orange); } .pill.orange .dot { background: var(--orange); }
.pill.neutral { background: var(--neutral-50); color: var(--ink-700); } .pill.neutral .dot { background: var(--neutral); }
.pill.outline { background: transparent; color: var(--ink-700); border: 1px solid var(--ink-200); }

.id-chip { font-family: var(--font-mono); font-size: 12px; color: var(--ink-700); background: var(--ink-50); padding: 2px 8px; border-radius: 4px; font-feature-settings: "tnum" 1; white-space: nowrap; display: inline-block; }

/* ========== Table ========== */
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: start; padding: 10px 12px; font-size: 11px; color: var(--ink-500); font-weight: 500; text-transform: uppercase; letter-spacing: 0.05em; background: var(--ink-50); border-bottom: 1px solid var(--ink-200); white-space: nowrap; }
.table td { padding: 12px; color: var(--ink-800); vertical-align: middle; border-bottom: 1px solid var(--ink-100); }
.table tr:hover td { background: var(--ink-50); }
.table .num { text-align: end; font-family: var(--font-mono); font-feature-settings: "tnum" 1; }
.table .id { font-weight: 500; color: var(--ink-900); }
.bilingual { display: flex; flex-direction: column; gap: 1px; line-height: 1.3; }
.bilingual .ar { font-family: var(--font-arabic); font-size: 12px; color: var(--ink-500); direction: rtl; text-align: start; }

/* ========== KPI tile ========== */
.kpi { background: #fff; border: 1px solid var(--ink-100); border-radius: 8px; box-shadow: var(--shadow-1); padding: 18px 20px; display: flex; flex-direction: column; gap: 6px; }
.kpi .label { font-size: 12px; font-weight: 500; color: var(--ink-500); display: flex; align-items: center; gap: 8px; }
.kpi .label .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--saaed-red); }
.kpi .val { font-family: var(--font-mono); font-size: 28px; line-height: 34px; font-weight: 500; color: var(--ink-900); letter-spacing: -0.01em; font-feature-settings: "tnum" 1; }
.kpi .val .unit { font-size: 14px; color: var(--ink-500); margin-left: 4px; }
.kpi .sub { font-family: var(--font-mono); font-size: 12px; color: var(--ink-500); }
.kpi .delta.pos { color: var(--ok); }
.kpi .delta.neg { color: var(--saaed-red); }

/* ========== Misc ========== */
.divider-h { height: 1px; background: var(--ink-100); margin: 24px 0; }
.empty { color: var(--ink-400); }

  .live-rail { background: #fff; border-left: 1px solid var(--ink-100); display: grid; grid-template-rows: auto 1fr; overflow: hidden; max-height: calc(100vh - 56px); }
  .live-head { padding: 16px 20px; border-bottom: 1px solid var(--ink-100); display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; }
  .live-head h3 { margin: 0; font-size: 14px; font-weight: 600; color: var(--ink-900); }
  .live-head .live-pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; background: var(--ok-50); color: var(--ok); font-size: 11px; font-weight: 500; }
  .live-head .live-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--ok); animation: pulse 2s infinite; }
  @keyframes pulse { 50% { opacity: 0.4; } }

  .feed-list { overflow-y: auto; min-height: 0; }
  .feed-item { padding: 14px 20px; border-bottom: 1px solid var(--ink-100); display: grid; grid-template-columns: 36px 1fr; gap: 12px; cursor: pointer; transition: background 120ms; min-width: 0; }
  .feed-item:hover { background: var(--ink-50); }
  .feed-item.unread { background: linear-gradient(90deg, var(--saaed-red-50) 0%, transparent 16px); }
  .feed-icon { width: 32px; height: 32px; border-radius: 6px; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
  .feed-icon.wo { background: var(--saaed-red-50); color: var(--saaed-red); }
  .feed-icon.rfr { background: var(--info-50); color: var(--info); }
  .feed-icon.gps { background: var(--ok-50); color: var(--ok); }
  .feed-icon.warn { background: var(--warn-50); color: var(--warn); }
  .feed-icon.acc { background: var(--saaed-red-50); color: var(--saaed-red); }
  .feed-icon.doc { background: var(--purple-50); color: var(--purple); }
  .feed-body { min-width: 0; overflow: hidden; }
  .feed-body .text { font-size: 13px; color: var(--ink-800); line-height: 1.45; overflow-wrap: break-word; }
  .feed-body .text .id-link { color: var(--saaed-red); font-weight: 500; white-space: nowrap; }
  .feed-body .meta { font-size: 11px; color: var(--ink-500); margin-top: 4px; display: flex; gap: 8px; flex-wrap: wrap; }
  .feed-section-divider { padding: 10px 20px 6px; font-size: 10px; color: var(--ink-400); text-transform: uppercase; letter-spacing: 0.08em; font-weight: 600; background: var(--ink-50); border-bottom: 1px solid var(--ink-100); }

  .ico { width: 16px; height: 16px; stroke-width: 1.75; }

/* ========== Empty / error / loading states ========== */
.empty-state { padding: 48px 24px; text-align: center; color: var(--ink-500); }
.empty-state .ic { width: 48px; height: 48px; margin: 0 auto 12px; background: var(--ink-50); border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; color: var(--ink-400); }
.empty-state h4 { margin: 0 0 6px; font-size: 16px; color: var(--ink-700); }
.empty-state p { margin: 0 0 16px; font-size: 13px; line-height: 1.5; }

.skeleton { background: linear-gradient(90deg, var(--ink-50) 0%, var(--ink-100) 50%, var(--ink-50) 100%); background-size: 200% 100%; animation: sk-shimmer 1.4s linear infinite; border-radius: 4px; }
@keyframes sk-shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ========== Print styles ========== */
/* ========== Dark mode ========== */
html[data-theme="dark"] {
  --ink-900: #F5F7FA;
  --ink-800: #E4E9F0;
  --ink-700: #C5CCD6;
  --ink-600: #9AA4B0;
  --ink-500: #7C8590;
  --ink-400: #5E6770;
  --ink-300: #424A53;
  --ink-200: #2A323B;
  --ink-100: #1E252D;
  --ink-50: #161B22;
  --ink-0: #0D1117;

  --bg-app: #0B0F14;
  --bg-card: #161B22;
  --bg-tinted: #1E252D;

  --saaed-red: #E63950;
  --saaed-red-600: #C8102E;
  --saaed-red-700: #A60E26;
  --saaed-red-50: #2D0E16;
  --saaed-red-100: #3D1820;

  --ok-50: #0D2A20;
  --warn-50: #2A1E0A;
  --danger-50: #2D0E16;
  --info-50: #0A1C2E;
  --purple-50: #1D1230;
  --orange-50: #2A1A0F;
  --neutral-50: #1E252D;

  --shadow-1: 0 1px 0 rgba(0,0,0,0.4), 0 1px 2px rgba(0,0,0,0.3);
  --shadow-pop: 0 12px 40px rgba(0,0,0,0.8), 0 2px 8px rgba(0,0,0,0.4);
}
html[data-theme="dark"] body { background: var(--bg-app); color: var(--ink-800); }
html[data-theme="dark"] .topbar,
html[data-theme="dark"] .sidebar,
html[data-theme="dark"] .card,
html[data-theme="dark"] .kpi,
html[data-theme="dark"] .kpi-large,
html[data-theme="dark"] .main-card,
html[data-theme="dark"] .live-rail,
html[data-theme="dark"] .toolbar,
html[data-theme="dark"] .info-card,
html[data-theme="dark"] .vehicle-hero,
html[data-theme="dark"] .pm-list,
html[data-theme="dark"] .section,
html[data-theme="dark"] .grid-card,
html[data-theme="dark"] .veh-card,
html[data-theme="dark"] .vehicle-detail-card,
html[data-theme="dark"] .acc-list,
html[data-theme="dark"] .detail,
html[data-theme="dark"] .claim-list,
html[data-theme="dark"] .claim-detail,
html[data-theme="dark"] .profile-card,
html[data-theme="dark"] .section-card,
html[data-theme="dark"] .v-card { background: var(--bg-card); }
html[data-theme="dark"] .topbar { border-bottom-color: var(--ink-200); }
html[data-theme="dark"] .sidebar { border-right-color: var(--ink-200); }
html[data-theme="dark"] .card, html[data-theme="dark"] .kpi, html[data-theme="dark"] .kpi-large { border-color: var(--ink-200); }
html[data-theme="dark"] .table th { background: var(--bg-tinted); border-bottom-color: var(--ink-300); color: var(--ink-500); }
html[data-theme="dark"] .table td { border-bottom-color: var(--ink-200); color: var(--ink-800); }
html[data-theme="dark"] .table tr:hover td { background: var(--ink-100); }
html[data-theme="dark"] .id-chip { background: var(--ink-100); color: var(--ink-700); }
html[data-theme="dark"] .topbar .search-input { background: var(--ink-100); }
html[data-theme="dark"] .iconbtn:hover { background: var(--ink-100); }
html[data-theme="dark"] .user-chip:hover { background: var(--ink-100); }
html[data-theme="dark"] .nav-item:hover { background: var(--ink-100); }
html[data-theme="dark"] .nav-item.active { background: var(--saaed-red-50); color: var(--saaed-red); }
html[data-theme="dark"] .nav-item .count { background: var(--ink-200); color: var(--ink-500); }
html[data-theme="dark"] .btn-secondary { background: var(--ink-100); border-color: var(--ink-200); color: var(--ink-800); }
html[data-theme="dark"] .btn-secondary:hover { background: var(--ink-200); }
html[data-theme="dark"] .btn-ghost:hover { background: var(--ink-100); }
html[data-theme="dark"] .btn-danger { background: var(--ink-100); }
html[data-theme="dark"] input, html[data-theme="dark"] select, html[data-theme="dark"] textarea { background: var(--bg-card); color: var(--ink-800); border-color: var(--ink-200); }
html[data-theme="dark"] .logo-mark, html[data-theme="dark"] .user-chip .av { background: var(--saaed-red); color: #fff; }
html[data-theme="dark"] .nav-section-title { color: var(--ink-500); }
html[data-theme="dark"] .feed-item:hover { background: var(--ink-100); }
html[data-theme="dark"] .feed-section-divider { background: var(--bg-tinted); color: var(--ink-500); }
html[data-theme="dark"] .feed-item { border-bottom-color: var(--ink-200); }
html[data-theme="dark"] .live-rail { border-left-color: var(--ink-200); }
html[data-theme="dark"] .live-head { border-bottom-color: var(--ink-200); }
html[data-theme="dark"] .divider { background: var(--ink-200); }
html[data-theme="dark"] .veh-search, html[data-theme="dark"] .map-toolbar, html[data-theme="dark"] .left-panel, html[data-theme="dark"] .left-pane { background: var(--bg-card); border-color: var(--ink-200); }

@media print {
  body { background: #fff; }
  .app { display: block; }
  .topbar, .sidebar, .actions, .toolbar, .iconbtn, [data-action], .btn { display: none !important; }
  .app-body { display: block; }
  .content { padding: 0; overflow: visible; }
  .page-head { border-bottom: 2px solid var(--ink-900); margin-bottom: 24px; padding-bottom: 12px; }
  .page-head h1 { font-size: 24px; }
  .page-head::after { content: "Saaed FMS · printed " attr(data-printed); display: block; font-family: var(--font-mono); font-size: 10px; color: var(--ink-500); margin-top: 6px; }
  .card { box-shadow: none; border: 1px solid var(--ink-300); break-inside: avoid; }
  table { font-size: 11px; }
  .table th, .table td { padding: 6px 8px; }
  .pill { border: 1px solid currentColor; }
  a { text-decoration: none; color: var(--ink-900); }
  @page { margin: 18mm 14mm; size: A4 portrait; }
}
