/* ==========================================================================
   سِدرة · design system («هوية المركز»)
   RTL first, calm institutional look: white cards on cream, thin lines, green accents.
   ========================================================================== */

:root {
  /* palette (NCVC template) */
  --c-primary: #76BC21;
  --c-green: #119853;
  --c-green-600: #0E8448;
  --c-green-700: #0B6E3C;
  --c-forest: #2C5F2D;
  --c-teal: #035859;
  --c-orange: #F15922;
  --c-orange-700: #C9441A;
  --c-gold: #9C7A32;
  --c-sand: #C2B69C;
  --c-cream: #FBFBF3;
  --c-tint: #EAF3E4;
  --c-mint: #BAD9A1;
  --c-ink: #2B2B2B;
  --c-muted: #888888;
  --c-muted-strong: #666666;
  --c-line: #DADADA;
  --c-line-soft: #ECECE3;
  --c-white: #FFFFFF;
  --c-zebra: #FAFAF5;
  --c-teal-tint: #E3EFEF;
  --c-orange-tint: #FDEDE6;
  --c-gold-tint: #F5EFE1;
  --c-gray-tint: #F1F1EC;

  /* type */
  --font: "IBM Plex Sans Arabic", "Geeza Pro", Tahoma, sans-serif;
  --fs-xs: 12px;
  --fs-sm: 13px;
  --fs-base: 15px;
  --fs-md: 17px;
  --fs-lg: 20px;
  --fs-xl: 24px;
  --fs-2xl: 30px;
  --fs-3xl: 40px;
  --lh: 1.6;

  /* shape & depth */
  --radius: 14px;
  --radius-sm: 10px;
  --radius-xs: 6px;
  --radius-pill: 999px;
  --shadow-sm: 0 1px 2px rgba(43, 43, 43, .05);
  --shadow: 0 1px 2px rgba(43, 43, 43, .04), 0 4px 16px rgba(43, 43, 43, .05);
  --shadow-lg: 0 12px 40px rgba(20, 40, 25, .18);
  --ring: 0 0 0 3px rgba(118, 188, 33, .35);

  /* layout */
  --sidebar-w: 264px;
  --topbar-h: 64px;
  --bottomnav-h: 64px;
  --content-max: 1360px;
  --gap: 16px;
  --pad: 24px;

  /* motif: two thin diagonal lines from the template */
  --motif: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='140' viewBox='0 0 180 140'%3E%3Cg stroke='%2376BC21' stroke-width='1.2' fill='none' stroke-linecap='round'%3E%3Cpath d='M8 132 L150 8'/%3E%3Cpath d='M58 132 L176 30' stroke-opacity='.55'/%3E%3C/g%3E%3C/svg%3E");
}

/* ------------------------------------------------------------------ reset */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: var(--fs-base);
  line-height: var(--lh);
  color: var(--c-ink);
  background: var(--c-cream);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img, svg { display: block; max-width: 100%; }
svg.icon { display: inline-block; width: 20px; height: 20px; flex: none; vertical-align: middle; }
[dir="rtl"] .icon-dir { transform: scaleX(-1); }
a { color: var(--c-green); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, h4, h5, p { margin: 0; }
h1, h2, h3, h4 { font-weight: 700; line-height: 1.35; }
hr { border: 0; border-top: 1px solid var(--c-line-soft); margin: 16px 0; }
:focus-visible { outline: 2px solid var(--c-green); outline-offset: 2px; }
::selection { background: var(--c-mint); }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
[hidden] { display: none !important; }
.noscript { padding: 24px; text-align: center; }

/* ------------------------------------------------------------------ utilities */
.num, .tabular { font-variant-numeric: tabular-nums; }
.ltr { direction: ltr; unicode-bidi: isolate; }
.muted { color: var(--c-muted-strong); }
.text-sm { font-size: var(--fs-sm); }
.text-xs { font-size: var(--fs-xs); }
.text-lg { font-size: var(--fs-lg); }
.text-center { text-align: center; }
.text-start { text-align: start; }
.text-end { text-align: end; }
.fw-500 { font-weight: 500; } .fw-600 { font-weight: 600; } .fw-700 { font-weight: 700; }
.c-green { color: var(--c-green); } .c-orange { color: var(--c-orange); } .c-gold { color: var(--c-gold); } .c-teal { color: var(--c-teal); } .c-muted { color: var(--c-muted); }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.w-100 { width: 100%; }
.mt-0 { margin-top: 0; } .mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; } .mb-16 { margin-bottom: 16px; } .mb-24 { margin-bottom: 24px; }
.stack { display: flex; flex-direction: column; gap: var(--gap); }
.stack-sm { display: flex; flex-direction: column; gap: 8px; }
.stack-lg { display: flex; flex-direction: column; gap: 24px; }
.row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.row-sm { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.spacer { flex: 1 1 auto; }
.grid { display: grid; gap: var(--gap); grid-template-columns: minmax(0, 1fr); }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.cols-2-1 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.grid.cols-1-2 { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); }
.span-2 { grid-column: span 2; }
.span-all { grid-column: 1 / -1; }
.divider { height: 1px; background: var(--c-line-soft); margin: 12px 0; }
.motif { position: relative; }
.motif::after {
  content: ""; position: absolute; inset-inline-end: 0; bottom: 0; width: 180px; height: 140px;
  background: var(--motif) no-repeat left bottom / contain; opacity: .5; pointer-events: none;
}

/* ------------------------------------------------------------------ boot */
.boot { min-height: 100vh; display: grid; place-content: center; justify-items: center; gap: 14px; }
.boot-emblem { width: 72px; height: 72px; }
.boot-name { font-size: var(--fs-xl); font-weight: 700; color: var(--c-forest); }

/* ------------------------------------------------------------------ app shell */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
  min-height: 100dvh;
}
.sidebar {
  position: sticky; top: 0; height: 100vh; height: 100dvh;
  display: flex; flex-direction: column;
  background: var(--c-white);
  border-inline-end: 1px solid var(--c-line-soft);
  overflow: hidden;
  z-index: 40;
}
.sb-brand { padding: 22px 20px 16px; border-bottom: 1px solid var(--c-line-soft); }
.sb-logo { width: 100%; max-width: 208px; height: auto; }
.sb-product { display: flex; flex-direction: column; gap: 2px; margin-top: 14px; }
.sb-name { font-size: 26px; font-weight: 700; color: var(--c-forest); letter-spacing: 0; line-height: 1.1; }
.sb-tag { font-size: var(--fs-xs); color: var(--c-muted-strong); line-height: 1.4; }
.sb-nav { flex: 1 1 auto; overflow-y: auto; padding: 14px 12px; display: flex; flex-direction: column; gap: 2px; }
.sb-section { font-size: var(--fs-xs); color: var(--c-muted); font-weight: 600; padding: 12px 12px 6px; }
.nav-item {
  position: relative;
  display: flex; align-items: center; gap: 12px;
  min-height: 44px; padding: 8px 12px;
  border-radius: var(--radius-sm);
  color: #474747; font-weight: 500;
  text-decoration: none;
  transition: background-color .15s, color .15s;
}
.nav-item .icon { width: 20px; height: 20px; color: #7A7A7A; transition: color .15s; }
.nav-item:hover { background: #F5F7F0; text-decoration: none; color: var(--c-ink); }
.nav-item.is-active { background: var(--c-tint); color: var(--c-forest); font-weight: 600; }
.nav-item.is-active .icon { color: var(--c-green); }
.nav-item.is-active::before {
  content: ""; position: absolute; inset-inline-start: -12px; top: 10px; bottom: 10px; width: 3px;
  border-radius: 0 3px 3px 0; background: var(--c-green);
}
[dir="rtl"] .nav-item.is-active::before { border-radius: 3px 0 0 3px; }
.nav-badge { margin-inline-start: auto; min-width: 22px; height: 22px; padding: 0 7px; border-radius: var(--radius-pill); background: var(--c-orange); color: #fff; font-size: 11px; font-weight: 700; display: inline-grid; place-items: center; }
.sb-foot {
  position: relative;
  padding: 14px 20px 18px;
  border-top: 1px solid var(--c-line-soft);
  font-size: var(--fs-xs); color: var(--c-muted-strong);
  min-height: 96px;
}
.sb-foot::after {
  content: ""; position: absolute; inset-inline-end: -18px; bottom: -22px; width: 150px; height: 118px;
  background: var(--motif) no-repeat center / contain; opacity: .55; pointer-events: none;
}
.sb-contract-no { font-weight: 600; color: var(--c-forest); direction: ltr; unicode-bidi: isolate; }
.sb-social { margin-top: 6px; color: var(--c-green); font-weight: 600; direction: ltr; unicode-bidi: isolate; display: inline-block; }
.sidebar .sb-close { display: none; }

.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 var(--pad);
  background: rgba(251, 251, 243, .9);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--c-line-soft);
}
.topbar .tb-menu { display: none; }
.tb-brand { display: none; align-items: center; gap: 8px; font-weight: 700; color: var(--c-forest); font-size: var(--fs-md); }
.tb-brand img { width: 30px; height: 30px; }
.tb-title { font-size: var(--fs-md); font-weight: 600; color: var(--c-ink); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tb-spacer { flex: 1 1 auto; }
.tb-user { display: flex; align-items: center; gap: 8px; }
.tb-operator { display: flex; align-items: center; gap: 8px; padding-inline-start: 12px; margin-inline-start: 4px; border-inline-start: 1px solid var(--c-line-soft); }
.tb-operator img { width: 40px; height: auto; flex: none; }
.tb-operator-text { display: flex; flex-direction: column; line-height: 1.3; font-size: 11px; color: var(--c-muted-strong); white-space: nowrap; }
.tb-operator-text b { font-size: 11px; color: var(--c-ink); font-weight: 600; }
@media (max-width: 1100px) { .tb-operator-text { display: none; } }
@media (max-width: 420px) { .tb-operator { padding-inline-start: 8px; } .tb-operator img { width: 32px; } }
.user-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 6px 4px 12px; border-radius: var(--radius-pill);
  background: var(--c-white); border: 1px solid var(--c-line-soft);
}
[dir="rtl"] .user-chip { padding: 4px 12px 4px 6px; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--c-tint); color: var(--c-forest); font-weight: 700; font-size: var(--fs-sm);
  flex: none;
}
.user-meta { display: flex; flex-direction: column; line-height: 1.25; }
.user-name { font-weight: 600; font-size: var(--fs-sm); }
.user-role { font-size: 11px; color: var(--c-muted-strong); }
.content { flex: 1 1 auto; width: 100%; max-width: var(--content-max); margin: 0 auto; padding: var(--pad); }
.page { display: flex; flex-direction: column; gap: 20px; animation: page-in .22s ease-out; }
@keyframes page-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.bottom-nav { display: none; }
.sb-backdrop { display: none; }

/* ------------------------------------------------------------------ page header */
.page-header {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap;
}
.page-heading { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.page-kicker { font-size: var(--fs-xs); font-weight: 600; color: var(--c-green); }
.page-title { font-size: var(--fs-2xl); font-weight: 700; color: var(--c-ink); line-height: 1.3; }
.page-subtitle { color: var(--c-muted-strong); font-size: var(--fs-base); }
.page-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.page-back { display: inline-flex; align-items: center; gap: 4px; color: var(--c-muted-strong); font-size: var(--fs-sm); width: fit-content; }
.page-back:hover { color: var(--c-green); text-decoration: none; }
.page-back .icon { width: 16px; height: 16px; }
.section-title { font-size: var(--fs-md); font-weight: 700; color: var(--c-ink); display: flex; align-items: center; gap: 8px; }
.section-title::before { content: ""; width: 4px; height: 18px; border-radius: 2px; background: var(--c-primary); }

/* toolbar (filters above content) */
.toolbar {
  display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap;
  padding: 12px 14px; background: var(--c-white); border: 1px solid var(--c-line-soft); border-radius: var(--radius);
}
.toolbar .field { margin: 0; min-width: 150px; }
.toolbar .field-label { font-size: var(--fs-xs); }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 34px; padding: 4px 14px; border-radius: var(--radius-pill);
  border: 1px solid var(--c-line); background: var(--c-white); color: #4A4A4A; font-size: var(--fs-sm); font-weight: 500;
}
.chip:hover { border-color: var(--c-mint); }
.chip.is-active { background: var(--c-tint); border-color: var(--c-mint); color: var(--c-forest); font-weight: 600; }

/* ------------------------------------------------------------------ cards */
.card {
  background: var(--c-white);
  border: 1px solid var(--c-line-soft);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  min-width: 0;
}
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 16px 20px 0;
}
.card-heading { display: flex; align-items: center; gap: 10px; min-width: 0; }
.card-icon { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--c-tint); color: var(--c-green); flex: none; }
.card-title { font-size: var(--fs-md); font-weight: 700; }
.card-subtitle { font-size: var(--fs-sm); color: var(--c-muted-strong); }
.card-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.card-body { padding: 16px 20px 20px; }
.card-body-flush { padding: 12px 0 0; }
.card-body-flush > .table-wrap { border: 0; border-radius: 0 0 var(--radius) var(--radius); }
.card-foot { padding: 12px 20px; border-top: 1px solid var(--c-line-soft); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.card.is-accent { border-top: 3px solid var(--c-primary); }
.card.card-tint { background: var(--c-tint); border-color: #DCEBD0; }
.card.card-motif { position: relative; overflow: hidden; }
.card.card-motif::after {
  content: ""; position: absolute; inset-inline-end: -10px; bottom: -16px; width: 160px; height: 124px;
  background: var(--motif) no-repeat center / contain; opacity: .45; pointer-events: none;
}

/* ------------------------------------------------------------------ KPI tiles */
.kpi-grid { display: grid; gap: var(--gap); grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.kpi {
  position: relative;
  display: flex; flex-direction: column; gap: 6px;
  padding: 16px 18px 14px;
  background: var(--c-white);
  border: 1px solid var(--c-line-soft);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  min-width: 0;
  --tone: var(--c-green);
}
.kpi::before { content: ""; position: absolute; inset-inline-start: 0; top: 16px; bottom: 16px; width: 3px; border-radius: 3px; background: var(--tone); }
.kpi.tone-green { --tone: var(--c-green); }
.kpi.tone-primary { --tone: var(--c-primary); }
.kpi.tone-teal { --tone: var(--c-teal); }
.kpi.tone-orange { --tone: var(--c-orange); }
.kpi.tone-gold { --tone: var(--c-gold); }
.kpi.tone-forest { --tone: var(--c-forest); }
.kpi.tone-sand { --tone: var(--c-sand); }
.kpi.is-clickable { cursor: pointer; transition: border-color .15s, box-shadow .15s; }
.kpi.is-clickable:hover { border-color: var(--c-mint); box-shadow: var(--shadow); }
.kpi-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.kpi-label { font-size: var(--fs-sm); color: var(--c-muted-strong); font-weight: 500; }
.kpi-icon { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; color: var(--tone); background: color-mix(in srgb, var(--tone) 10%, white); flex: none; }
.kpi-icon .icon { width: 18px; height: 18px; }
.kpi-value { display: flex; align-items: baseline; gap: 6px; font-size: 28px; font-weight: 700; line-height: 1.2; color: var(--c-ink); font-variant-numeric: tabular-nums; }
.kpi-unit { font-size: var(--fs-sm); font-weight: 500; color: var(--c-muted-strong); }
.kpi-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: var(--fs-xs); }
.kpi-delta { display: inline-flex; align-items: center; gap: 3px; font-weight: 600; padding: 1px 8px 1px 6px; border-radius: var(--radius-pill); }
.kpi-delta .icon { width: 13px; height: 13px; stroke-width: 2.4; }
.kpi-delta.is-good { color: var(--c-green-700); background: var(--c-tint); }
.kpi-delta.is-bad { color: var(--c-orange-700); background: var(--c-orange-tint); }
.kpi-delta.is-flat { color: var(--c-muted-strong); background: var(--c-gray-tint); }
.kpi-delta-label { font-weight: 400; color: var(--c-muted-strong); }
.kpi-hint { color: var(--c-muted-strong); }
.kpi-spark { margin-top: 4px; height: 32px; }
.kpi-spark svg { width: 100%; height: 32px; }

/* ------------------------------------------------------------------ buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 42px; padding: 8px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-weight: 600; font-size: var(--fs-base); line-height: 1.2;
  white-space: nowrap; text-decoration: none; user-select: none;
  transition: background-color .15s, border-color .15s, color .15s, box-shadow .15s;
  position: relative;
}
.btn:hover { text-decoration: none; }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn .icon { width: 18px; height: 18px; }
.btn[disabled], .btn.is-disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--c-green); color: #fff; }
.btn-primary:hover:not([disabled]) { background: var(--c-green-600); }
.btn-primary:active:not([disabled]) { background: var(--c-green-700); }
.btn-secondary { background: var(--c-white); color: var(--c-forest); border-color: #CFE3BF; }
.btn-secondary:hover:not([disabled]) { background: var(--c-tint); border-color: var(--c-mint); }
.btn-ghost { background: transparent; color: #4A4A4A; }
.btn-ghost:hover:not([disabled]) { background: rgba(43, 43, 43, .05); color: var(--c-ink); }
.btn-danger { background: var(--c-orange); color: #fff; }
.btn-danger:hover:not([disabled]) { background: var(--c-orange-700); }
.btn-link { background: none; border: 0; padding: 0 2px; min-height: 0; color: var(--c-green); font-weight: 600; }
.btn-link:hover { text-decoration: underline; }
.btn-sm { min-height: 34px; padding: 5px 12px; font-size: var(--fs-sm); border-radius: 8px; }
.btn-sm .icon { width: 16px; height: 16px; }
.btn-lg { min-height: 52px; padding: 12px 24px; font-size: var(--fs-md); border-radius: 12px; }
.btn-icon { padding: 0; width: 42px; min-width: 42px; }
.btn-icon.btn-sm { width: 34px; min-width: 34px; }
.btn-block { width: 100%; }
.btn.is-busy { color: transparent !important; pointer-events: none; }
.btn.is-busy > * { visibility: hidden; }
.btn.is-busy::after {
  content: ""; position: absolute; inset: 0; margin: auto; width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid currentColor; border-color: rgba(255, 255, 255, .5); border-top-color: #fff;
  animation: spin .7s linear infinite;
}
.btn-secondary.is-busy::after, .btn-ghost.is-busy::after { border-color: rgba(17, 152, 83, .25); border-top-color: var(--c-green); }
.btn-group { display: inline-flex; gap: 8px; flex-wrap: wrap; }

.spinner { display: inline-block; width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--c-tint); border-top-color: var(--c-green); animation: spin .8s linear infinite; }
.spinner-sm { width: 18px; height: 18px; border-width: 2px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------------------------ badges */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  height: 24px; padding: 0 10px;
  border-radius: var(--radius-pill);
  font-size: var(--fs-xs); font-weight: 600; line-height: 1;
  white-space: nowrap;
  background: var(--c-gray-tint); color: #555;
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.badge-green { background: var(--c-tint); color: var(--c-green-700); }
.badge-primary { background: #EEF6E2; color: #4E8A12; }
.badge-teal { background: var(--c-teal-tint); color: var(--c-teal); }
.badge-gold { background: var(--c-gold-tint); color: #7E6127; }
.badge-orange { background: var(--c-orange-tint); color: var(--c-orange-700); }
.badge-gray { background: var(--c-gray-tint); color: #5C5C5C; }
.badge-forest { background: #E4ECE4; color: var(--c-forest); }
.badge-sand { background: #F3F0E8; color: #7A6D52; }
.badge-mint { background: #EFF7E8; color: #4F7F2E; }
/* status badges */
.st-draft { background: var(--c-gray-tint); color: #5C5C5C; }
.st-submitted { background: var(--c-teal-tint); color: var(--c-teal); }
.st-approved { background: var(--c-tint); color: var(--c-green-700); }
.st-returned { background: var(--c-orange-tint); color: var(--c-orange-700); }
.st-open { background: var(--c-gold-tint); color: #7E6127; }
.st-in_progress { background: var(--c-teal-tint); color: var(--c-teal); }
.st-done { background: var(--c-tint); color: var(--c-green-700); }
.st-cancelled { background: var(--c-gray-tint); color: #7A7A7A; text-decoration: line-through; text-decoration-color: rgba(0, 0, 0, .25); }
.st-high { background: var(--c-orange-tint); color: var(--c-orange-700); }
.st-medium { background: var(--c-gold-tint); color: #7E6127; }
.st-low { background: #EFF7E8; color: #4F7F2E; }
.st-overdue { background: var(--c-orange); color: #fff; }
.st-legacy { background: #F3F0E8; color: #7A6D52; }
.st-active { background: var(--c-tint); color: var(--c-green-700); }
.st-inactive, .st-missing { background: var(--c-gray-tint); color: #7A7A7A; }

/* ------------------------------------------------------------------ notes / callouts */
.note {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 12px 14px; border-radius: var(--radius-sm);
  border: 1px solid; font-size: var(--fs-sm); line-height: 1.7;
}
.note > .icon { margin-top: 2px; }
.note-title { display: block; font-weight: 700; margin-bottom: 2px; }
.note-info { background: var(--c-teal-tint); border-color: #C9DEDE; color: #1F4D4E; }
.note-info > .icon { color: var(--c-teal); }
.note-success { background: var(--c-tint); border-color: #D2E7C2; color: #22502A; }
.note-success > .icon { color: var(--c-green); }
.note-warning { background: var(--c-gold-tint); border-color: #E8DCC0; color: #5E4A1E; }
.note-warning > .icon { color: var(--c-gold); }
.note-danger { background: var(--c-orange-tint); border-color: #F7CDBC; color: #7A2B10; }
.note-danger > .icon { color: var(--c-orange); }

/* key/value lists */
.kv { margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px 24px; }
.kv-row { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.kv dt { font-size: var(--fs-xs); color: var(--c-muted-strong); }
.kv dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }

/* ------------------------------------------------------------------ tables */
.table-wrap {
  position: relative;
  overflow: auto;
  border: 1px solid var(--c-line-soft);
  border-radius: var(--radius);
  background: var(--c-white);
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
}
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--fs-sm); }
.table caption { caption-side: top; text-align: start; padding: 10px 14px; font-weight: 600; }
.table th, .table td { padding: 11px 14px; text-align: start; vertical-align: middle; border-bottom: 1px solid var(--c-line-soft); }
.table thead th {
  position: sticky; top: 0; z-index: 2;
  background: #F6F7F0; color: #555; font-weight: 600; font-size: var(--fs-xs);
  white-space: nowrap; border-bottom: 1px solid var(--c-line);
}
.table tbody tr:nth-child(even) td { background: var(--c-zebra); }
.table tbody tr:hover td { background: #F1F6EA; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tfoot td { position: sticky; bottom: 0; background: var(--c-tint); font-weight: 700; border-top: 1px solid var(--c-mint); border-bottom: 0; }
.table td.align-end, .table th.align-end { text-align: end; }
.table td.align-center, .table th.align-center { text-align: center; }
.table td.align-end, .table td.align-center { font-variant-numeric: tabular-nums; }
.table-compact th, .table-compact td { padding: 7px 10px; }
.table-clickable tbody tr { cursor: pointer; }
.table-clickable tbody tr:focus-visible { outline: 2px solid var(--c-green); outline-offset: -2px; }
.table .th-sort { display: inline-flex; align-items: center; gap: 4px; border: 0; background: none; padding: 0; font: inherit; color: inherit; }
.table .th-sort .icon { width: 14px; height: 14px; opacity: .35; }
.table th.is-sorted-asc .th-sort .icon, .table th.is-sorted-desc .th-sort .icon { opacity: 1; color: var(--c-green); }
.table th.align-end .th-sort { flex-direction: row-reverse; }
.table-empty td { padding: 0; background: var(--c-white) !important; }
.table tr.is-muted td { color: var(--c-muted); }
.table tr.is-warn td { background: #FFF8F4; }
.table tr.is-total td { font-weight: 700; background: var(--c-tint); }

/* ------------------------------------------------------------------ forms */
.form-grid { display: grid; gap: 14px 16px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.form-grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid .field-full, .form-grid .span-all { grid-column: 1 / -1; }
.form-section { display: flex; flex-direction: column; gap: 12px; }
.form-section + .form-section { padding-top: 16px; border-top: 1px dashed var(--c-line); }
.form-section-title { font-weight: 700; font-size: var(--fs-base); color: var(--c-forest); display: flex; align-items: center; gap: 8px; }
.form-actions { display: flex; gap: 10px; align-items: center; justify-content: flex-start; flex-wrap: wrap; padding-top: 4px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-label { font-size: var(--fs-sm); font-weight: 600; color: #444; }
.field-label .req { color: var(--c-orange); margin-inline-start: 3px; }
.field-hint { font-size: var(--fs-xs); color: var(--c-muted-strong); }
.field-error { font-size: var(--fs-xs); color: var(--c-orange-700); min-height: 0; }
.field-error:empty { display: none; }
.input {
  width: 100%;
  min-height: 44px;
  padding: 9px 12px;
  border: 1px solid var(--c-line);
  border-radius: var(--radius-sm);
  background: var(--c-white);
  font-size: var(--fs-base);
  line-height: 1.4;
  transition: border-color .15s, box-shadow .15s;
  -webkit-appearance: none; appearance: none;
}
.input::placeholder { color: #A5A5A5; }
.input:hover { border-color: #C8C8C0; }
.input:focus { outline: none; border-color: var(--c-primary); box-shadow: var(--ring); }
.input[disabled], .input[readonly] { background: #F6F6F1; color: #6A6A6A; }
.has-error .input { border-color: var(--c-orange); }
textarea.input { min-height: 88px; resize: vertical; line-height: 1.7; }
select.input {
  padding-inline-end: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: left 12px center; background-size: 16px;
}
[dir="ltr"] select.input { background-position: right 12px center; }
select.input[multiple] { background-image: none; padding-inline-end: 12px; min-height: 120px; }
.field-num .input, input[data-num] { font-variant-numeric: tabular-nums; text-align: right; }
input[type="date"].input, input[type="month"].input, input[type="time"].input { direction: ltr; text-align: right; }

/* checkbox */
.field-check { justify-content: center; }
.check { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; min-height: 40px; user-select: none; }
.check input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.check-box { width: 22px; height: 22px; border: 1.5px solid #BDBDB5; border-radius: 6px; display: grid; place-items: center; background: #fff; transition: all .15s; flex: none; }
.check-box .icon { width: 15px; height: 15px; color: #fff; opacity: 0; stroke-width: 3; }
.check input:checked + .check-box { background: var(--c-green); border-color: var(--c-green); }
.check input:checked + .check-box .icon { opacity: 1; }
.check input:focus-visible + .check-box { box-shadow: var(--ring); }
.check-label { font-weight: 500; }

/* segmented radios */
.segmented { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px; background: #F2F3EC; border-radius: 12px; width: fit-content; max-width: 100%; }
.seg { position: relative; cursor: pointer; }
.seg input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.seg span { display: inline-flex; align-items: center; justify-content: center; min-height: 38px; min-width: 44px; padding: 6px 14px; border-radius: 9px; font-weight: 500; color: #555; transition: all .15s; }
.seg input:checked + span { background: #fff; color: var(--c-forest); font-weight: 700; box-shadow: 0 1px 3px rgba(0, 0, 0, .1); }
.seg input:focus-visible + span { box-shadow: var(--ring); }
.segmented-sm .seg span { min-height: 30px; padding: 3px 10px; font-size: var(--fs-sm); }

/* stepper (big tap) */
.stepper-field .field-label { font-size: var(--fs-sm); }
.stepper {
  display: grid; grid-template-columns: 52px minmax(0, 1fr) 52px; align-items: stretch;
  height: 52px; border: 1px solid var(--c-line); border-radius: 12px; background: #fff; overflow: hidden;
}
.stepper:focus-within { border-color: var(--c-primary); box-shadow: var(--ring); }
.stepper-btn {
  border: 0; background: #F4F6EF; color: var(--c-forest);
  display: grid; place-items: center; touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
.stepper-btn .icon { width: 22px; height: 22px; stroke-width: 2.4; }
.stepper-btn:active:not([disabled]) { background: var(--c-mint); }
.stepper-btn[disabled] { color: #C2C2BA; cursor: not-allowed; }
.stepper-btn.is-plus { border-inline-end: 1px solid var(--c-line-soft); }
.stepper-btn.is-minus { border-inline-start: 1px solid var(--c-line-soft); }
.stepper-input {
  width: 100%; border: 0; text-align: center; font-size: 22px; font-weight: 700;
  font-variant-numeric: tabular-nums; background: transparent; padding: 0 4px; min-width: 0;
}
.stepper-input:focus { outline: none; }
.stepper .stepper-input { text-align: center; }
.stepper-grid { display: grid; gap: 12px 16px; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }

/* ------------------------------------------------------------------ tabs */
.tabs {
  display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none;
  border-bottom: 1px solid var(--c-line); max-width: 100%;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  position: relative; display: inline-flex; align-items: center; gap: 8px;
  min-height: 44px; padding: 8px 16px; border: 0; background: none;
  color: var(--c-muted-strong); font-weight: 500; white-space: nowrap;
}
.tab .icon { width: 18px; height: 18px; }
.tab:hover { color: var(--c-ink); }
.tab.is-active { color: var(--c-forest); font-weight: 700; }
.tab.is-active::after { content: ""; position: absolute; inset-inline: 10px; bottom: -1px; height: 3px; border-radius: 3px 3px 0 0; background: var(--c-green); }
.tab-count { min-width: 22px; height: 20px; padding: 0 6px; border-radius: var(--radius-pill); background: var(--c-gray-tint); font-size: 11px; font-weight: 700; display: inline-grid; place-items: center; }
.tab.is-active .tab-count { background: var(--c-tint); color: var(--c-green-700); }

/* ------------------------------------------------------------------ overlays */
.overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(24, 36, 28, .42);
  opacity: 0; transition: opacity .18s ease;
}
.overlay.open { opacity: 1; }
body.has-overlay { overflow: hidden; }
.modal-backdrop { display: grid; place-items: center; padding: 24px; overflow-y: auto; }
.modal {
  width: 100%; max-width: 560px; max-height: calc(100vh - 48px); max-height: calc(100dvh - 48px);
  display: flex; flex-direction: column;
  background: var(--c-white); border-radius: 18px; box-shadow: var(--shadow-lg);
  transform: translateY(10px) scale(.985); transition: transform .2s ease;
  outline: none;
}
.overlay.open .modal { transform: none; }
.modal-wide { max-width: 920px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 22px 12px; border-bottom: 1px solid var(--c-line-soft); }
.modal-title { font-size: var(--fs-lg); font-weight: 700; }
.modal-x { margin-inline-end: -8px; }
.modal-body { padding: 18px 22px; overflow-y: auto; flex: 1 1 auto; }
.modal-foot { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; padding: 14px 22px 18px; border-top: 1px solid var(--c-line-soft); }
[dir="rtl"] .modal-foot { flex-direction: row-reverse; justify-content: flex-end; }
.modal-confirm { max-width: 440px; }
.confirm-text { font-size: var(--fs-base); line-height: 1.8; }

.drawer-backdrop { display: block; }
.drawer {
  position: absolute; top: 0; bottom: 0; inset-inline-end: 0;
  width: min(var(--drawer-w, 480px), 100vw);
  background: var(--c-white); box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; outline: none;
  transform: translateX(-100%); transition: transform .24s ease;
}
[dir="ltr"] .drawer { transform: translateX(100%); }
.overlay.open .drawer { transform: none; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--c-line-soft); }
.drawer-title { font-size: var(--fs-lg); font-weight: 700; }
.drawer-body { padding: 18px 20px; overflow-y: auto; flex: 1 1 auto; }
.drawer-foot { display: flex; gap: 10px; flex-wrap: wrap; padding: 14px 20px; border-top: 1px solid var(--c-line-soft); }

/* toasts */
.toast-stack {
  position: fixed; z-index: 200; bottom: 20px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 8px; align-items: center;
  width: min(460px, calc(100vw - 24px)); pointer-events: none;
}
.toast {
  pointer-events: auto; width: 100%;
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 12px 12px 14px; border-radius: 12px;
  background: #1F2A22; color: #fff; box-shadow: var(--shadow-lg);
  font-size: var(--fs-sm); line-height: 1.6; cursor: pointer;
  opacity: 0; transform: translateY(8px); transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: none; }
.toast.hide { opacity: 0; transform: translateY(8px); }
.toast > .icon { margin-top: 1px; }
.toast-msg { flex: 1 1 auto; }
.toast-x { border: 0; background: none; color: rgba(255, 255, 255, .6); padding: 0; display: grid; place-items: center; }
.toast-x .icon { width: 16px; height: 16px; }
.toast-success > .icon { color: #9BD66A; }
.toast-error { background: #5A1F0C; }
.toast-error > .icon { color: #FFB08F; }
.toast-warning > .icon { color: #F0CE7E; }
.toast-info > .icon { color: #8FD3D3; }

/* ------------------------------------------------------------------ empty & loading */
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; padding: 40px 20px; color: var(--c-muted-strong); }
.empty-icon { width: 60px; height: 60px; border-radius: 50%; display: grid; place-items: center; background: var(--c-tint); color: var(--c-green); margin-bottom: 4px; }
.empty-icon .icon { width: 28px; height: 28px; }
.empty-title { font-size: var(--fs-md); font-weight: 700; color: var(--c-ink); }
.empty-text { max-width: 440px; font-size: var(--fs-sm); line-height: 1.8; }
.empty-action { margin-top: 8px; }
.empty-compact { padding: 24px 16px; }
.empty-compact .empty-icon { width: 44px; height: 44px; }
.empty-compact .empty-icon .icon { width: 22px; height: 22px; }
.empty-compact .empty-title { font-size: var(--fs-base); font-weight: 600; }

.loading-inline { display: flex; align-items: center; gap: 10px; color: var(--c-muted-strong); padding: 16px; }
.skel {
  height: 12px; border-radius: 6px;
  background: linear-gradient(90deg, #EFEFE8 0%, #F7F7F2 40%, #EFEFE8 80%);
  background-size: 300% 100%; animation: shimmer 1.3s ease-in-out infinite;
}
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }
.skel-page { display: flex; flex-direction: column; gap: 20px; }
.skel-head { display: flex; flex-direction: column; gap: 10px; }
.skel-h1 { height: 28px; }
.skel-kpi { gap: 12px; }
.skel-big { height: 26px; }
.skel-card { padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.skel-title { height: 16px; }
.skel-chart { height: 180px; border-radius: 10px; }
.skel-table { display: flex; flex-direction: column; gap: 14px; padding: 16px; background: #fff; border: 1px solid var(--c-line-soft); border-radius: var(--radius); }
.skel-row { display: flex; gap: 16px; }

/* error card (page error boundary / 404) */
.error-card { max-width: 560px; margin: 40px auto; text-align: center; padding: 32px 24px; }
.error-card .empty-icon { background: var(--c-orange-tint); color: var(--c-orange); }
.error-detail { margin-top: 10px; font-size: var(--fs-xs); color: var(--c-muted); direction: ltr; unicode-bidi: isolate; word-break: break-word; }
.big-code { font-size: 64px; font-weight: 700; color: var(--c-mint); line-height: 1; font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------------ photos */
.uploader { display: flex; flex-direction: column; gap: 12px; }
.uploader-drop {
  display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center;
  padding: 18px; border: 1.5px dashed #CFDCC4; border-radius: var(--radius); background: #FAFCF7;
  transition: border-color .15s, background-color .15s;
}
.uploader-drop.is-drag { border-color: var(--c-green); background: var(--c-tint); }
.uploader-hint { display: flex; align-items: center; gap: 8px; color: var(--c-muted-strong); font-size: var(--fs-sm); }
.uploader-hint .icon { color: var(--c-green); }
.uploader-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; align-items: center; }
.uploader-thumbs { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }
.uploader-thumbs:empty { display: none; }
.uploader-tile { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: #EEE; border: 1px solid var(--c-line-soft); }
.uploader-tile img { width: 100%; height: 100%; object-fit: cover; }
.uploader-tile[data-status="uploading"] img, .uploader-tile[data-status="pending"] img { opacity: .7; }
.uploader-tile[data-status="error"] { border-color: var(--c-orange); }
.uploader-progress { position: absolute; inset-inline: 6px; bottom: 6px; height: 5px; border-radius: 3px; background: rgba(255, 255, 255, .7); overflow: hidden; }
.uploader-progress span { display: block; height: 100%; background: var(--c-green); transition: width .2s; }
.uploader-tile:not([data-status="uploading"]) .uploader-progress { display: none; }
.uploader-state { position: absolute; inset-inline: 0; bottom: 0; display: flex; justify-content: center; padding: 4px; }
.uploader-note { font-size: 11px; background: rgba(0, 0, 0, .55); color: #fff; padding: 1px 8px; border-radius: 6px; }
.uploader-ok { position: absolute; inset-inline-start: 6px; bottom: 6px; width: 22px; height: 22px; border-radius: 50%; background: var(--c-green); color: #fff; display: grid; place-items: center; }
.uploader-ok .icon { width: 14px; height: 14px; stroke-width: 3; }
.uploader-retry { display: inline-flex; align-items: center; gap: 4px; border: 0; border-radius: 6px; background: var(--c-orange); color: #fff; font-size: 11px; padding: 3px 8px; }
.uploader-retry .icon { width: 13px; height: 13px; }
.uploader-rm, .gallery-rm {
  position: absolute; top: 6px; inset-inline-end: 6px; width: 28px; height: 28px; border-radius: 50%;
  border: 0; background: rgba(0, 0, 0, .55); color: #fff; display: grid; place-items: center;
}
.uploader-rm .icon, .gallery-rm .icon { width: 15px; height: 15px; }
.photo-kind { position: absolute; top: 6px; inset-inline-start: 6px; padding: 1px 8px; border-radius: 6px; font-size: 11px; font-weight: 700; background: rgba(255, 255, 255, .92); color: var(--c-forest); }
.photo-kind.kind-before { color: var(--c-gold); }
.photo-kind.kind-after { color: var(--c-green); }

.gallery { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.gallery-tile { position: relative; margin: 0; border-radius: 12px; overflow: hidden; background: #EEE; aspect-ratio: 4 / 3; }
.gallery-open { display: block; width: 100%; height: 100%; padding: 0; border: 0; background: none; cursor: zoom-in; }
.gallery-open img { width: 100%; height: 100%; object-fit: cover; transition: transform .3s; }
.gallery-open:hover img { transform: scale(1.04); }
.gallery-tile figcaption {
  position: absolute; inset-inline: 0; bottom: 0; padding: 18px 10px 6px; font-size: var(--fs-xs); color: #fff;
  background: linear-gradient(to top, rgba(0, 0, 0, .65), transparent); pointer-events: none;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.gallery-empty { grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; color: var(--c-muted); font-size: var(--fs-sm); padding: 12px 0; }
.gallery-empty .icon { width: 18px; height: 18px; }

.lightbox {
  position: fixed; inset: 0; z-index: 150; background: rgba(10, 16, 12, .94);
  display: flex; flex-direction: column; opacity: 0; transition: opacity .18s; outline: none;
}
.lightbox.open { opacity: 1; }
.lb-top { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; color: #fff; }
.lb-count { font-size: var(--fs-sm); opacity: .8; }
.lb-close, .lb-nav { border: 0; background: rgba(255, 255, 255, .12); color: #fff; width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; }
.lb-close:hover, .lb-nav:hover { background: rgba(255, 255, 255, .22); }
.lb-stage { flex: 1 1 auto; display: grid; place-items: center; padding: 0 64px; min-height: 0; }
.lb-img { max-width: 100%; max-height: calc(100vh - 150px); max-height: calc(100dvh - 150px); object-fit: contain; border-radius: 6px; }
.lb-nav { position: absolute; top: 50%; transform: translateY(-50%); }
.lb-prev { right: 12px; }
.lb-next { left: 12px; }
.lb-caption { min-height: 56px; padding: 12px 20px 20px; color: #fff; text-align: center; display: flex; justify-content: center; align-items: center; gap: 10px; font-size: var(--fs-sm); }
.lb-caption .photo-kind { position: static; }

/* ------------------------------------------------------------------ charts */
.chart { position: relative; width: 100%; min-width: 0; }
.chart-svg { width: 100%; height: auto; overflow: visible; }
.chart-axis { font-size: 11px; fill: #6F6F6F; font-family: var(--font); }
.chart-label { font-size: 12px; fill: #444; font-family: var(--font); }
.chart-value { font-size: 11px; fill: #444; font-weight: 600; font-family: var(--font); font-variant-numeric: tabular-nums; }
.chart-center-value { fill: var(--c-ink); font-family: var(--font); }
.chart-center-label { fill: #6F6F6F; font-family: var(--font); }
.chart-hit { cursor: default; }
.chart-tip {
  position: absolute; z-index: 5; top: 0; left: 0; pointer-events: none;
  min-width: 120px; max-width: 260px; padding: 8px 10px; border-radius: 10px;
  background: #fff; border: 1px solid var(--c-line); box-shadow: var(--shadow);
  font-size: var(--fs-xs); line-height: 1.6; opacity: 0; transition: opacity .12s;
}
.chart-tip.show { opacity: 1; }
.chart-tip-title { font-weight: 700; margin-bottom: 2px; color: var(--c-ink); }
.chart-tip-row { display: flex; align-items: center; gap: 6px; color: #555; }
.chart-tip-name { flex: 1 1 auto; }
.chart-tip-val { font-weight: 700; color: var(--c-ink); font-variant-numeric: tabular-nums; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 8px; font-size: var(--fs-xs); color: #555; }
.chart-legend-item { display: inline-flex; align-items: center; gap: 6px; }
.chart-swatch { width: 10px; height: 10px; border-radius: 3px; flex: none; display: inline-block; }
.chart-swatch.is-line { height: 3px; width: 14px; border-radius: 2px; }
.chart-donut { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.chart-donut-fig { position: relative; flex: none; }
.chart-donut-legend { flex: 1 1 160px; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.chart-donut-row { display: grid; grid-template-columns: 10px minmax(0, 1fr) auto auto; align-items: center; gap: 8px; font-size: var(--fs-sm); }
.chart-donut-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chart-donut-val { font-weight: 700; font-variant-numeric: tabular-nums; }
.chart-donut-pct { color: var(--c-muted-strong); font-size: var(--fs-xs); min-width: 44px; text-align: end; font-variant-numeric: tabular-nums; }
.chart-seg { transition: opacity .15s; cursor: default; }
.chart-donut svg:hover .chart-seg { opacity: .55; }
.chart-donut svg .chart-seg:hover { opacity: 1; }
.sparkline { display: inline-block; }

.chart-heatmap { max-width: 520px; }
.heat-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.heat-dow { font-size: 11px; color: var(--c-muted-strong); text-align: center; padding-bottom: 2px; overflow: hidden; text-overflow: clip; white-space: nowrap; }
.heat-cell {
  position: relative; aspect-ratio: 1; border-radius: 7px; border: 0; padding: 0;
  display: grid; place-items: center; background: #F1F4EC; font: inherit;
}
.heat-cell.is-pad { background: transparent; }
.heat-cell.is-missing {
  background: repeating-linear-gradient(135deg, #F4F1EA 0 5px, #E6E0D2 5px 6px);
  outline: 1px dashed #D2C9B5; outline-offset: -1px;
}
.heat-cell.is-future { opacity: .45; background: #F6F6F1; outline: 0; }
.heat-day { font-size: 11px; font-weight: 600; color: #4A4A4A; font-variant-numeric: tabular-nums; }
.heat-cell.is-dark .heat-day { color: #fff; }
button.heat-cell { cursor: pointer; }
button.heat-cell:hover { box-shadow: inset 0 0 0 2px var(--c-forest); }
.heat-legend { display: flex; align-items: center; gap: 4px; margin-top: 10px; font-size: 11px; color: var(--c-muted-strong); flex-wrap: wrap; }
.heat-swatch { width: 14px; height: 14px; border-radius: 4px; display: inline-block; }
.heat-swatch.is-missing { margin-inline-start: 12px; background: repeating-linear-gradient(135deg, #F4F1EA 0 3px, #E6E0D2 3px 4px); outline: 1px dashed #D2C9B5; outline-offset: -1px; }
.heat-legend-text { margin: 0 4px; }

.meter { display: flex; flex-direction: column; gap: 6px; --meter-color: var(--c-green); }
.meter-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: var(--fs-sm); }
.meter-label { color: #555; font-weight: 500; }
.meter-value { font-weight: 700; font-variant-numeric: tabular-nums; }
.meter-track { position: relative; height: 10px; border-radius: 6px; background: color-mix(in srgb, var(--meter-color) 14%, white); overflow: visible; }
.meter-fill { height: 100%; border-radius: 6px; background: var(--meter-color); transition: width .5s ease; }
.meter-marker { position: absolute; top: -4px; bottom: -4px; width: 2px; margin-inline-start: -1px; background: var(--c-ink); border-radius: 1px; }
.meter-hint { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; font-size: var(--fs-xs); color: var(--c-muted-strong); }
.meter-marker-key { display: inline-flex; align-items: center; gap: 6px; }
.meter-marker-swatch { width: 2px; height: 12px; background: var(--c-ink); display: inline-block; }

/* ------------------------------------------------------------------ login */
.login {
  position: relative; min-height: 100vh; min-height: 100dvh; overflow: hidden;
  display: grid; place-items: center; padding: 24px 16px 64px;
  background: #0D3B2A;
}
/* the hero asset is a full template slide (white margins, logo); crop to its photo area */
.login-media { position: absolute; inset: 0; overflow: hidden; }
.login-media-inner {
  position: absolute; top: 50%; left: 50%;
  width: max(100vw, calc(100vh * 2.533)); height: max(100vh, calc(100vw / 2.533));
  transform: translate(-50%, -50%);
}
.login-media-inner img {
  position: absolute; max-width: none;
  width: 105.26%; height: auto; /* 1600 / 1520 */
  left: -2.63%; /* 40 / 1520 */
  top: -36.67%; /* 220 / 600 */
}
.login-media::after {
  content: ""; position: absolute; inset: 0;
  background:
    linear-gradient(160deg, rgba(3, 88, 89, .55) 0%, rgba(17, 60, 40, .35) 45%, rgba(10, 40, 26, .75) 100%);
}
.login-lines { position: absolute; left: 3%; bottom: 0; width: 280px; height: 220px; background: var(--motif) no-repeat left bottom / contain; opacity: .9; filter: brightness(1.4); pointer-events: none; }
.login-card {
  position: relative; z-index: 1; width: min(440px, 100%);
  padding: 34px 30px 26px; border-radius: 22px; overflow: hidden;
  background: linear-gradient(180deg, rgba(255, 255, 255, .97) 0%, rgba(251, 251, 243, .94) 100%);
  -webkit-backdrop-filter: blur(20px) saturate(1.05);
  backdrop-filter: blur(20px) saturate(1.05);
  border: 1px solid rgba(255, 255, 255, .75);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .9), 0 2px 8px rgba(0, 0, 0, .10), 0 32px 80px rgba(4, 32, 22, .45);
  animation: login-in .5s cubic-bezier(.2, .8, .2, 1) both;
}
/* brand accent strip across the top of the card */
.login-card::before {
  content: ""; position: absolute; top: 0; inset-inline: 0; height: 4px;
  background: linear-gradient(90deg, var(--c-teal) 0%, var(--c-green) 45%, var(--c-primary) 100%);
}
@keyframes login-in { from { opacity: 0; transform: translateY(12px) scale(.985); } to { opacity: 1; transform: none; } }
.login-logo { width: 100%; max-width: 280px; height: auto; margin: 0 auto 18px; }
/* NCVC logo and the operator's logo on opposite sides of the login card header */
.login-logos { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 18px; }
.login-logos .login-logo { margin: 0; max-width: 230px; flex: 1 1 auto; min-width: 0; }
.login-logos-sep { width: 1px; align-self: stretch; background: var(--c-line); }
.login-operator { margin: 0; display: flex; flex-direction: column; align-items: center; gap: 4px; flex: none; }
.login-operator img { width: 64px; height: auto; }
.login-operator figcaption { font-size: 11px; color: var(--c-muted-strong); white-space: nowrap; }
.login-title { text-align: center; font-size: 40px; font-weight: 700; color: var(--c-forest); line-height: 1.15; }
.login-sub { text-align: center; color: #555; font-size: var(--fs-sm); margin-top: 6px; line-height: 1.7; }
.login-form { display: flex; flex-direction: column; gap: 14px; margin-top: 22px; }
.login-form .input { background: rgba(255, 255, 255, .95); min-height: 48px; }
.login-error { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 10px; background: var(--c-orange-tint); color: var(--c-orange-700); font-size: var(--fs-sm); font-weight: 500; }
.login-error:empty { display: none; }
.login-pass { position: relative; }
.login-pass .input { padding-inline-end: 48px; }
.login-eye { position: absolute; inset-inline-end: 4px; top: 50%; transform: translateY(-50%); }
.login-demo { margin-top: 18px; padding-top: 14px; border-top: 1px dashed rgba(0, 0, 0, .14); }
.login-demo-title { font-size: var(--fs-xs); color: var(--c-muted-strong); margin-bottom: 8px; }
.login-demo-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.demo-acc {
  display: flex; flex-direction: column; align-items: flex-start; gap: 0; text-align: start;
  padding: 7px 10px; border-radius: 10px; border: 1px solid rgba(0, 0, 0, .08); background: rgba(255, 255, 255, .7);
  font-size: var(--fs-xs); line-height: 1.5;
}
.demo-acc:hover { border-color: var(--c-mint); background: #fff; }
.demo-acc b { font-weight: 600; color: var(--c-forest); }
.demo-acc span { color: var(--c-muted-strong); direction: ltr; unicode-bidi: isolate; }
.login-foot { position: absolute; z-index: 1; bottom: 18px; inset-inline: 0; display: flex; justify-content: space-between; padding: 0 28px; color: rgba(255, 255, 255, .88); font-size: var(--fs-sm); font-weight: 500; }
.login-foot .ltr { font-weight: 600; }

/* ------------------------------------------------------------------ print route (screen) */
body.print-mode { background: #E9EAE3; }
.print-root { padding: 24px 12px 96px; display: flex; flex-direction: column; align-items: center; gap: 24px; }
.print-fab {
  position: fixed; z-index: 60; bottom: 24px; left: 24px;
  display: flex; gap: 8px;
}
.print-fab .btn { box-shadow: var(--shadow-lg); }

/* ------------------------------------------------------------------ responsive */
@media (max-width: 1200px) {
  .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1024px) {
  .grid.cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.cols-2-1, .grid.cols-1-2 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 900px) {
  :root { --pad: 16px; }
  .app-shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; top: 0; bottom: 0; inset-inline-start: 0; height: auto;
    width: min(300px, 86vw);
    transform: translateX(100%); transition: transform .25s ease;
    box-shadow: none;
  }
  [dir="ltr"] .sidebar { transform: translateX(-100%); }
  .app-shell.nav-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
  .sb-backdrop {
    display: block; position: fixed; inset: 0; z-index: 35; background: rgba(24, 36, 28, .4);
    opacity: 0; pointer-events: none; transition: opacity .2s;
  }
  .app-shell.nav-open .sb-backdrop { opacity: 1; pointer-events: auto; }
  .sidebar .sb-close { display: inline-flex; position: absolute; top: 10px; inset-inline-end: 10px; z-index: 1; }
  .topbar .tb-menu { display: inline-flex; }
  .tb-brand { display: flex; }
  .tb-title { display: none; }
  .topbar { height: 58px; }
  .user-meta { display: none; }
  .user-chip { padding: 3px !important; border: 0; background: transparent; }
  .content { padding: 16px var(--pad) calc(var(--bottomnav-h) + 24px + env(safe-area-inset-bottom)); }
  .bottom-nav {
    display: grid; grid-template-columns: repeat(5, minmax(0, 1fr));
    position: fixed; z-index: 30; inset-inline: 0; bottom: 0;
    height: calc(var(--bottomnav-h) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: rgba(255, 255, 255, .96);
    -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
    border-top: 1px solid var(--c-line-soft);
  }
  .bn-item {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    border: 0; background: none; color: #7A7A7A; font-size: 11px; font-weight: 500; text-decoration: none;
    -webkit-tap-highlight-color: transparent; min-width: 0; padding: 4px 2px;
  }
  .bn-item span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .bn-item .icon { width: 22px; height: 22px; }
  .bn-item:hover { text-decoration: none; }
  .bn-item.is-active { color: var(--c-green); font-weight: 700; }
  .bn-item.is-active .icon { stroke-width: 2.2; }
  .toast-stack { bottom: calc(var(--bottomnav-h) + 14px + env(safe-area-inset-bottom)); }
  body.has-overlay .toast-stack { bottom: auto; top: calc(12px + env(safe-area-inset-top)); }
  .page-title { font-size: var(--fs-xl); }
  .grid.cols-2, .grid.cols-3 { grid-template-columns: minmax(0, 1fr); }
  .form-grid.cols-2, .form-grid.cols-3 { grid-template-columns: minmax(0, 1fr); }
  .span-2 { grid-column: auto; }
  .print-fab { left: 16px; bottom: 16px; }
}
@media (max-width: 600px) {
  body { font-size: 15px; }
  .page { gap: 16px; }
  .page-header { align-items: stretch; }
  .page-actions { width: 100%; }
  .page-actions > .btn { flex: 1 1 auto; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi { padding: 12px 14px; }
  .kpi-value { font-size: 22px; }
  .kpi-icon { display: none; }
  .grid.cols-4 { grid-template-columns: minmax(0, 1fr); }
  .card-head { padding: 14px 14px 0; }
  .card-body { padding: 12px 14px 16px; }
  .card-foot { padding: 12px 14px; }
  .toolbar { padding: 10px; }
  .toolbar .field { flex: 1 1 140px; min-width: 0; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .stepper-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stepper { grid-template-columns: 46px minmax(0, 1fr) 46px; }
  .form-actions.is-sticky {
    position: sticky; bottom: calc(var(--bottomnav-h) + env(safe-area-inset-bottom)); z-index: 5;
    margin: 0 calc(var(--pad) * -1); padding: 10px var(--pad);
    background: var(--c-cream); border-top: 1px solid var(--c-line-soft); box-shadow: 0 -6px 16px rgba(43, 43, 43, .06);
  }
  .form-actions.is-sticky .btn { flex: 1 1 auto; }
  .modal-backdrop { padding: 0; place-items: end stretch; }
  .modal, .modal-wide {
    max-width: none; border-radius: 18px 18px 0 0; max-height: 92vh; max-height: 92dvh;
    transform: translateY(24px);
  }
  .modal-foot { padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
  .modal-foot .btn { flex: 1 1 auto; }
  .drawer { width: 100vw; }
  .lb-stage { padding: 0 8px; }
  .lb-nav { top: auto; bottom: 16px; transform: none; }
  .login-card { padding: 24px 20px 20px; border-radius: 20px; }
  .login-title { font-size: 34px; }
  .login-foot { flex-direction: column; align-items: center; gap: 2px; font-size: var(--fs-xs); }
  .login-lines { left: -40px; width: 170px; height: 130px; opacity: .6; }
  .kv { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .table th, .table td { padding: 9px 10px; }
}
@media (max-width: 380px) {
  .kpi-grid { grid-template-columns: minmax(0, 1fr); }
  .login-demo-list { grid-template-columns: minmax(0, 1fr); }
  .stepper-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (hover: none) {
  .table tbody tr:hover td { background: inherit; }
  .table tbody tr:nth-child(even):hover td { background: var(--c-zebra); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ---------------------------------------------------------------------------
   Map (public/js/lib/map.js): OpenStreetMap tiles, pins, geofence circles */
.map {
  position: relative; overflow: hidden; border-radius: 12px; border: 1px solid var(--c-line);
  background-color: #eef1ea;
  background-image: linear-gradient(rgba(0,0,0,.04) 1px, transparent 1px), linear-gradient(90deg, rgba(0,0,0,.04) 1px, transparent 1px);
  background-size: 32px 32px; touch-action: none; user-select: none; cursor: grab;
}
.map.is-dragging { cursor: grabbing; }
.map-tiles, .map-shapes, .map-pins { position: absolute; inset: 0; }
.map-shapes, .map-pins { pointer-events: none; }
.map-tile { position: absolute; left: 0; top: 0; width: 256px; height: 256px; max-width: none; filter: saturate(.85); }
.map-tile.is-failed { visibility: hidden; }
.map-circle { position: absolute; left: 0; top: 0; border-radius: 50%; border: 2px dashed rgba(17, 152, 83, .55); background: rgba(118, 188, 33, .10); }
.map-pin { position: absolute; left: 0; top: 0; pointer-events: auto; border: 0; background: none; padding: 0; cursor: pointer; display: flex; flex-direction: column; align-items: center; margin: 0; }
.map-pin > .map-pin-body, .map-pin > .map-pin-dot { transform: translate(-50%, -50%); }
.map-pin-dot { width: 14px; height: 14px; border-radius: 50%; background: var(--c-green); border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.35); }
.map-pin-label {
  transform: translate(-50%, -2px); white-space: nowrap; font: 600 11.5px/1.2 "IBM Plex Sans Arabic", Tahoma, sans-serif;
  color: var(--c-ink); background: rgba(255,255,255,.92); padding: 2px 6px; border-radius: 6px; box-shadow: 0 1px 3px rgba(0,0,0,.18); margin-top: 2px;
}
.map-zoom { position: absolute; top: 10px; left: 10px; display: flex; flex-direction: column; gap: 4px; z-index: 2; }
.map-btn { width: 34px; height: 34px; border-radius: 9px; border: 1px solid var(--c-line); background: #fff; display: grid; place-items: center; cursor: pointer; color: var(--c-forest); box-shadow: 0 1px 4px rgba(0,0,0,.12); }
.map-btn svg { width: 18px; height: 18px; }
.map-attr { position: absolute; bottom: 4px; right: 6px; font-size: 10.5px; color: #555; background: rgba(255,255,255,.8); padding: 1px 6px; border-radius: 4px; z-index: 2; pointer-events: none; }
.pin-pick .map-pin-dot { width: 18px; height: 18px; background: var(--c-orange); }
