/* =========================================================================
   MaintenancePro Cloud — DuckDeals design system
   ========================================================================= */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  --brand:        #000080;
  --brand-dark:   #0a0a3d;
  --accent:       #F5B301;
  --ink:          #0E2A47;
  --muted:        #475569;
  --soft-muted:   #64748B;
  --bg:           #FFFFFF;
  --bg-alt:       #F8FAFC;
  --bg-soft:      #F7FAFC;
  --surface:      #FFFFFF;
  --surface-2:    #F1F5F9;
  --line:         #E2E8F0;
  --shadow:       0 4px 18px rgba(0, 0, 0, 0.06);
  --shadow-lg:    0 12px 40px rgba(0, 0, 0, 0.12);
  --success:      #15803D;
  --warn:         #F59E0B;
  --danger:       #DC2626;
  --info:         #2563EB;
  --radius-sm:    8px;
  --radius:       14px;
  --radius-lg:    20px;
  --text:         var(--ink);
  --card:         var(--surface);
  --border:       var(--line);
}

[data-theme="dark"] {
  /* Backgrounds — layered from darkest body to lightest surface */
  --bg:           #07072a;
  --bg-alt:       #0b0b3d;
  --bg-soft:      #131354;
  --surface:      #161669;
  --surface-2:    #1f1f86;
  /* Text */
  --ink:          #F1F5FF;
  --text:         #F1F5FF;
  --muted:        #C7D2FE;
  --soft-muted:   #94A3D5;
  /* Borders */
  --line:         #2a2a8a;
  --border:       #2a2a8a;
  --card:         var(--surface);
  /* Shadows for dark — softer */
  --shadow:       0 4px 18px rgba(0, 0, 0, 0.45);
  --shadow-lg:    0 12px 40px rgba(0, 0, 0, 0.55);
}

/* ===== Dark-mode component patches — fix the spots that hardcoded light colors ===== */

/* Form inputs need explicit dark colors for browser autofill resistance */
[data-theme="dark"] input[type="text"],
[data-theme="dark"] input[type="email"],
[data-theme="dark"] input[type="password"],
[data-theme="dark"] input[type="number"],
[data-theme="dark"] input[type="tel"],
[data-theme="dark"] input[type="url"],
[data-theme="dark"] input[type="date"],
[data-theme="dark"] input[type="datetime-local"],
[data-theme="dark"] input[type="time"],
[data-theme="dark"] input[type="search"],
[data-theme="dark"] input[type="month"],
[data-theme="dark"] input[type="week"],
[data-theme="dark"] input[type="file"],
[data-theme="dark"] select,
[data-theme="dark"] textarea {
  background: #1f1f86;
  color: #F1F5FF;
  border-color: #353599;
}
[data-theme="dark"] input:focus,
[data-theme="dark"] select:focus,
[data-theme="dark"] textarea:focus {
  border-color: #F5B301;
  box-shadow: 0 0 0 3px rgba(245, 179, 1, 0.18);
}
[data-theme="dark"] input::placeholder,
[data-theme="dark"] textarea::placeholder { color: #8c98ce; }
[data-theme="dark"] input:disabled,
[data-theme="dark"] select:disabled,
[data-theme="dark"] textarea:disabled { background: #131354; color: #94A3D5; }

/* Ghost / secondary buttons */
[data-theme="dark"] .btn-ghost { color: #F1F5FF; border-color: #353599; background: transparent; }
[data-theme="dark"] .btn-ghost:hover { background: #1f1f86; color: #fff; border-color: #F5B301; }
[data-theme="dark"] .btn-secondary { color: #0E2A47; } /* gold bg stays, text dark for contrast */
[data-theme="dark"] .btn-primary { background: #F5B301; color: #0E2A47; }
[data-theme="dark"] .btn-primary:hover { background: #FFC940; color: #0E2A47; box-shadow: 0 8px 22px rgba(245,179,1,0.35); }

/* Cards explicit (some inline styles use #fff) */
[data-theme="dark"] .card { background: var(--surface); border-color: var(--border); color: var(--text); }
[data-theme="dark"] .card h3, [data-theme="dark"] .card h4 { color: #F1F5FF; }
[data-theme="dark"] .card .muted, [data-theme="dark"] .muted, [data-theme="dark"] small.muted { color: #C7D2FE; }
[data-theme="dark"] .lede, [data-theme="dark"] p.lede { color: #C7D2FE; }
[data-theme="dark"] .eyebrow { color: #F5B301; }
[data-theme="dark"] h1, [data-theme="dark"] h2, [data-theme="dark"] h3, [data-theme="dark"] h4 { color: #F1F5FF; }

/* Tables */
[data-theme="dark"] .tbl { background: var(--surface); }
[data-theme="dark"] .tbl th { background: #1f1f86; color: #F1F5FF; }
[data-theme="dark"] .tbl td { color: #F1F5FF; border-bottom-color: #2a2a8a; }
[data-theme="dark"] .tbl tbody tr:hover { background: rgba(245, 179, 1, 0.06); }
[data-theme="dark"] .tbl a { color: #FFD96A; }
[data-theme="dark"] .tbl strong { color: #F1F5FF; }

/* Row-actions buttons */
[data-theme="dark"] .tbl .row-actions a, [data-theme="dark"] .tbl .row-actions button {
  background: #1f1f86; color: #F1F5FF; border-color: #353599;
}
[data-theme="dark"] .tbl .row-actions a:hover, [data-theme="dark"] .tbl .row-actions button:hover {
  background: #2a2a8a; border-color: #F5B301; color: #F5B301;
}

/* Filter bar */
[data-theme="dark"] .filter-bar { background: var(--surface); border-color: var(--border); }
[data-theme="dark"] .filter-bar .field-lbl { color: #C7D2FE; }

/* Pagination */
[data-theme="dark"] .pgr { border-top-color: var(--border); }
[data-theme="dark"] .pgr__btn { background: var(--surface); color: #F1F5FF; border-color: #353599; }
[data-theme="dark"] .pgr__btn:hover:not(.is-disabled) { background: #1f1f86; border-color: #F5B301; color: #F5B301; }
[data-theme="dark"] .pgr__btn.active { background: #F5B301; color: #0E2A47; border-color: #F5B301; }
[data-theme="dark"] .pgr__pp select { background: var(--surface); color: #F1F5FF; border-color: #353599; }

/* Searchable combobox */
[data-theme="dark"] .combo__panel { background: var(--surface); border-color: var(--border); box-shadow: 0 12px 32px rgba(0,0,0,0.6); }
[data-theme="dark"] .combo__opt { color: #F1F5FF; }
[data-theme="dark"] .combo__opt:hover, [data-theme="dark"] .combo__opt.is-active { background: rgba(245,179,1,0.12); color: #F5B301; }
[data-theme="dark"] .combo__empty { color: #94A3D5; }

/* Modal */
[data-theme="dark"] .modal { background: var(--surface); color: var(--text); }
[data-theme="dark"] .modal__head h3 { color: #F1F5FF; }

/* KPI tiles */
[data-theme="dark"] .kpi-tile { background: var(--surface); border-color: var(--border); }
[data-theme="dark"] .kpi-tile .kpi__value { color: #F1F5FF; }
[data-theme="dark"] .kpi-tile .kpi__label, [data-theme="dark"] .kpi-tile .kpi__sub { color: #C7D2FE; }
[data-theme="dark"] .kpi-tile .kpi__icon { color: #C7D2FE; opacity: 0.45; }

/* Chart cards */
[data-theme="dark"] .chart-card { background: var(--surface); border-color: var(--border); }
[data-theme="dark"] .chart-card h3 { color: #F1F5FF; }

/* Feed / activity */
[data-theme="dark"] .feed__item { border-bottom-color: rgba(255,255,255,0.08); }
[data-theme="dark"] .feed__title { color: #F1F5FF; }
[data-theme="dark"] .feed__meta { color: #94A3D5; }

/* Tech KPI cards */
[data-theme="dark"] .tech-kpi-card { background: var(--surface); border-color: var(--border); }
[data-theme="dark"] .tech-kpi-card .tech-numbers div { background: rgba(245,179,1,0.08); }
[data-theme="dark"] .tech-kpi-card .tech-numbers strong { color: #F1F5FF; }
[data-theme="dark"] .tech-kpi-card .tech-numbers small { color: #C7D2FE; }

/* Compliance bar */
[data-theme="dark"] .compbar { background: rgba(255,255,255,0.08); }

/* Calendar */
[data-theme="dark"] .cal-day { background: var(--surface); border-color: var(--border); color: #F1F5FF; }
[data-theme="dark"] .cal-day:hover { box-shadow: 0 6px 20px rgba(0,0,0,0.5); border-color: #F5B301; }
[data-theme="dark"] .cal-day.empty { background: rgba(255,255,255,0.02); }
[data-theme="dark"] .cal-day.today { box-shadow: 0 0 0 2px rgba(245,179,1,0.5); border-color: #F5B301; }
[data-theme="dark"] .cal-day__num { color: #F1F5FF; }
[data-theme="dark"] .cal-day.today .cal-day__num { color: #F5B301; }
[data-theme="dark"] .cal-day__count { background: #F5B301; color: #0E2A47; }
[data-theme="dark"] .cal-tabs { background: var(--surface); border-color: var(--border); }
[data-theme="dark"] .cal-tabs a { color: #C7D2FE; border-right-color: var(--border); }
[data-theme="dark"] .cal-tabs a.active { background: #F5B301; color: #0E2A47; }
[data-theme="dark"] .cal-event { background: var(--surface); border-color: var(--border); }
[data-theme="dark"] .cal-event .cal-time { color: #F5B301; }
[data-theme="dark"] .cal-event .cal-meta { color: #94A3D5; }
[data-theme="dark"] .cal-week-grid { background: var(--border); }
[data-theme="dark"] .cal-week-grid > .cal-week-head, [data-theme="dark"] .cal-week-grid > .cal-week-cell, [data-theme="dark"] .cal-week-grid > .cal-week-hour { background: var(--surface); color: #F1F5FF; }
[data-theme="dark"] .cal-wd { color: #C7D2FE; }

/* Toast */
[data-theme="dark"] .toast { background: var(--surface); color: #F1F5FF; border: 1px solid var(--border); }

/* Code/pre */
[data-theme="dark"] code, [data-theme="dark"] pre { background: #0a0a3d; color: #FFD96A; border-color: #2a2a8a; }
[data-theme="dark"] pre { color: #C7D2FE; }

/* Dropdown menu */
[data-theme="dark"] .dd__menu { background: var(--surface); border-color: var(--border); box-shadow: 0 12px 32px rgba(0,0,0,0.5); }
[data-theme="dark"] .dd__item { color: #F1F5FF; }
[data-theme="dark"] .dd__item:hover { background: rgba(245,179,1,0.12); color: #F5B301; }
[data-theme="dark"] .dd__sep { border-color: var(--border); }

/* QR box, signature card */
[data-theme="dark"] .qr-box { background: #fff; }
/* Keep the actual QR box white — barcodes need contrast — but add a light frame */

/* Form hints / labels */
[data-theme="dark"] .form-hint { color: #94A3D5; }
[data-theme="dark"] label { color: #F1F5FF; }
[data-theme="dark"] .checkbox-row { color: #F1F5FF; }

/* Divider lines */
[data-theme="dark"] .divider { background: var(--border); }

/* Empty state */
[data-theme="dark"] .empty { color: #94A3D5; }
[data-theme="dark"] .empty .muted { color: #C7D2FE; }

/* Definition list (dl) */
[data-theme="dark"] .dl dt { color: #C7D2FE; }
[data-theme="dark"] .dl dd { color: #F1F5FF; }
[data-theme="dark"] .dl > div { border-bottom-color: rgba(255,255,255,0.08); }
[data-theme="dark"] .kv > div { border-bottom-color: rgba(255,255,255,0.08); }

/* Badges — keep colors but ensure base slate badge legible */
[data-theme="dark"] .badge { background: rgba(255,255,255,0.08); color: #F1F5FF; border-color: rgba(255,255,255,0.15); }
[data-theme="dark"] .badge-slate { background: rgba(255,255,255,0.10); color: #C7D2FE; }
[data-theme="dark"] .badge-green { background: rgba(22,163,74,0.20); color: #86EFAC; border-color: rgba(22,163,74,0.40); }
[data-theme="dark"] .badge-red { background: rgba(220,38,38,0.20); color: #FCA5A5; border-color: rgba(220,38,38,0.40); }
[data-theme="dark"] .badge-amber { background: rgba(245,179,1,0.20); color: #FCD34D; border-color: rgba(245,179,1,0.40); }
[data-theme="dark"] .badge-blue { background: rgba(59,130,246,0.20); color: #93C5FD; border-color: rgba(59,130,246,0.40); }
[data-theme="dark"] .badge-indigo { background: rgba(99,102,241,0.20); color: #A5B4FC; border-color: rgba(99,102,241,0.40); }
[data-theme="dark"] .badge-violet { background: rgba(139,92,246,0.20); color: #C4B5FD; border-color: rgba(139,92,246,0.40); }

/* Topbar / search */
[data-theme="dark"] .topbar { background: var(--surface); border-bottom-color: var(--border); }
[data-theme="dark"] .topbar__search input { background: #1f1f86; color: #F1F5FF; border-color: #353599; }
[data-theme="dark"] .iconbtn { color: #F1F5FF; }
[data-theme="dark"] .iconbtn:hover { background: rgba(245,179,1,0.10); color: #F5B301; }

/* Workflow + sites cards-specific overrides */
[data-theme="dark"] .wf-card { background: var(--surface); }
[data-theme="dark"] .wf-stat { background: rgba(245,179,1,0.08); color: #F1F5FF; }
[data-theme="dark"] .wf-chip { background: rgba(255,255,255,0.08); color: #F1F5FF; border-color: var(--border); }
[data-theme="dark"] .wf-chip--start { background: #F5B301; color: #0E2A47; border-color: #F5B301; }

/* SVG flow diagram — text + boxes need lift on dark */
[data-theme="dark"] .wf-diagram svg text { fill: #F1F5FF; }
[data-theme="dark"] .wf-diagram svg rect[fill="#FFFFFF"] { fill: #1f1f86; }
[data-theme="dark"] .wf-diagram svg rect[fill="#EEF2FF"] { fill: #131354; }
[data-theme="dark"] .wf-diagram svg rect[fill="#FFFBEB"] { fill: #2a2310; }
[data-theme="dark"] .wf-diagram svg rect[fill="#ECFDF5"] { fill: #0e2a1f; }

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Tahoma, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg-alt);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Width guard — keep wide children from forcing horizontal scroll WITHOUT breaking
   `position: sticky` on the sidebar. We deliberately do NOT use overflow-x:hidden
   on html/body/main because that would create a new scroll context and prevent
   the sidebar from sticking to the viewport. Instead we constrain children. */
.app-shell, .main, .content, .card, .stat { max-width: 100%; min-width: 0; }
.tbl-wrap, .photo-grid { max-width: 100%; }
.tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
code, pre { overflow-wrap: anywhere; word-break: break-word; max-width: 100%; }
pre { overflow-x: auto; }
.dl dt, .dl dd { min-width: 0; overflow-wrap: anywhere; }
.row, .grid { min-width: 0; }
.row > *, .grid > * { min-width: 0; }
.flex-1 { min-width: 0; }
.topbar__inner { max-width: 100%; min-width: 0; }
.topbar__search { min-width: 0; }
table { table-layout: auto; max-width: 100%; }
/* Long URLs/emails inside tables and cards shouldn't bust width */
td, th { overflow-wrap: anywhere; word-break: break-word; }
html[dir="rtl"] body { font-family: 'Inter', Tahoma, Arial, -apple-system, sans-serif; }

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; height: auto; display: block; }
hr { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }

/* Typography ------------------------------------------------------------- */
h1, h2, h3, h4 { color: var(--ink); margin: 0 0 12px; line-height: 1.2; }
h1 { font-size: clamp(2rem, 4.6vw, 3.6rem); font-weight: 800; letter-spacing: -0.02em; line-height: 1.1; }
h2 { font-size: clamp(1.6rem, 3.2vw, 2.5rem); font-weight: 800; letter-spacing: -0.02em; }
h3 { font-size: 1.18rem; font-weight: 800; }
h4 { font-size: 1rem; font-weight: 700; }
p { margin: 0 0 12px; }
.lede { font-size: 1.08rem; color: var(--muted); max-width: 720px; }
.muted { color: var(--muted); }
.soft-muted { color: var(--soft-muted); }
.nowrap { white-space: nowrap; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.mt-sm { margin-top: 8px; }
.mt { margin-top: 16px; }
.mt-lg { margin-top: 28px; }
.mb-sm { margin-bottom: 8px; }
.mb { margin-bottom: 16px; }
.mb-lg { margin-bottom: 28px; }

.grad {
  background: linear-gradient(90deg, var(--brand), var(--accent));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 0.78rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--brand);
  background: rgba(0, 0, 128, 0.07);
  padding: 6px 12px; border-radius: 999px; margin-bottom: 14px;
}

/* Layout containers ------------------------------------------------------ */
.container { max-width: 1180px; margin: 0 auto; padding: 0 24px; }
.section { padding: 80px 0; }
.section--alt { background: var(--bg-alt); }
.section__head { text-align: center; max-width: 760px; margin: 0 auto 50px; }

.grid { display: grid; gap: 22px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-auto-sm { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }

@media (max-width: 960px) {
  .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 600px) {
  .grid-2, .grid-3, .grid-4, .grid-auto-sm { grid-template-columns: 1fr; }
  .section { padding: 50px 0; }
  .container { padding: 0 18px; }
}

/* Cards ------------------------------------------------------------------ */
.card {
  background: var(--surface); border-radius: var(--radius-lg);
  padding: 24px; border: 1px solid var(--line);
  box-shadow: var(--shadow); transition: transform .2s, box-shadow .2s;
}
.card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.card--flat { box-shadow: none; }
.card--flat:hover { transform: none; box-shadow: none; }

/* Buttons ---------------------------------------------------------------- */
.btn, button.btn, a.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 22px; border-radius: 999px; font-weight: 600;
  font-size: 0.96rem; border: 1.5px solid transparent;
  cursor: pointer; transition: all .15s; text-decoration: none;
  font-family: inherit;
}
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: #0a0a8a; transform: translateY(-1px); box-shadow: 0 8px 22px rgba(0, 0, 128, 0.25); color: #fff; text-decoration: none; }
.btn-secondary { background: var(--accent); color: var(--ink); }
.btn-secondary:hover { background: #e0a200; color: var(--ink); text-decoration: none; }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; color: #fff; text-decoration: none; }
.btn-success { background: var(--success); color: #fff; }
.btn-lg { padding: 14px 28px; font-size: 1.02rem; }
.btn-sm { padding: 7px 14px; font-size: 0.84rem; }
.btn-block { width: 100%; }
.btn[disabled], .btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-group { display: inline-flex; gap: 8px; flex-wrap: wrap; }

/* Icon button */
.iconbtn {
  width: 38px; height: 38px; border-radius: 999px;
  background: transparent; border: 0; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--ink); position: relative;
}
.iconbtn:hover { background: rgba(0, 0, 128, 0.06); }
.iconbtn .dot {
  position: absolute; top: 4px; right: 4px; width: 16px; height: 16px;
  background: var(--danger); color: #fff; border-radius: 999px;
  font-size: 0.65rem; font-weight: 700; display: inline-flex; align-items: center; justify-content: center;
}

/* Topbar (sticky, glass) ------------------------------------------------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: saturate(180%) blur(10px);
  -webkit-backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar__inner {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 24px; gap: 14px;
}
.topbar__left { display: flex; align-items: center; gap: 12px; flex: 1; }
.topbar__brand { display: flex; align-items: center; gap: 10px; font-weight: 800; color: var(--brand); }
.topbar__brand small { display: block; font-size: 0.66rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.topbar__search {
  display: flex; align-items: center; gap: 8px; flex: 0 1 320px;
  background: var(--surface-2); border-radius: 999px; padding: 8px 14px;
}
.topbar__search input {
  flex: 1; border: 0; background: transparent; font-family: inherit; font-size: 0.9rem; outline: none; color: var(--ink);
}
.topbar__actions { display: flex; align-items: center; gap: 4px; }
.topbar__user { display: flex; align-items: center; gap: 8px; padding: 0 8px; }
.topbar__user .avatar { width: 32px; height: 32px; border-radius: 999px; background: var(--brand); color: #fff; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; font-size: 0.78rem; }
@media (max-width: 768px) {
  .topbar__search { display: none; }
  .topbar__brand small { display: none; }
}

/* App shell -------------------------------------------------------------- */
.app-shell { display: grid; grid-template-columns: 256px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--brand-dark); color: #cbd5e1;
  padding: 18px 0 16px; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.sidebar__brand {
  display: flex; align-items: center; gap: 10px; padding: 4px 18px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07); margin-bottom: 12px;
  color: #fff; font-weight: 800;
}
.sidebar__brand .logo {
  width: 38px; height: 38px; border-radius: 10px;
  background: var(--brand); display: inline-flex; align-items: center; justify-content: center;
  color: var(--accent); font-weight: 800; font-size: 1.2rem;
}
.sidebar__brand small { display: block; font-weight: 500; font-size: 0.7rem; color: #9aa9d8; text-transform: uppercase; letter-spacing: 0.06em; margin-top: 2px; }

.nav { padding: 0 10px; }
.nav__section {
  font-size: 0.66rem; font-weight: 700; color: #7e93c4;
  text-transform: uppercase; letter-spacing: 0.1em;
  padding: 14px 10px 6px;
}
.nav__item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 10px; color: #cbd5e1;
  font-size: 0.88rem; font-weight: 500;
  text-decoration: none; margin-bottom: 2px; position: relative;
}
.nav__item:hover { background: rgba(255, 255, 255, 0.06); color: #fff; text-decoration: none; }
.nav__item.active { background: rgba(245, 179, 1, 0.13); color: var(--accent); }
.nav__item.active::before { content: ''; position: absolute; left: -10px; top: 8px; bottom: 8px; width: 3px; background: var(--accent); border-radius: 3px; }
html[dir="rtl"] .nav__item.active::before { left: auto; right: -10px; }
.nav__item .badge-count {
  margin-inline-start: auto; background: var(--accent); color: var(--ink); font-size: 0.68rem; padding: 1px 6px; border-radius: 999px; font-weight: 700;
}

.sidebar-backdrop { display: none; }
.sidebar-foot { padding: 12px 16px; margin-top: 16px; border-top: 1px solid rgba(255, 255, 255, 0.07); font-size: 0.7rem; color: #7e93c4; }

@media (max-width: 960px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0;
    width: 270px; transform: translateX(-100%);
    transition: transform .2s; z-index: 100;
  }
  html[dir="rtl"] .sidebar { left: auto; right: 0; transform: translateX(100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop.open {
    display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, 0.4); z-index: 99;
  }
}

.main { display: flex; flex-direction: column; min-height: 100vh; }
.content { flex: 1; padding: 24px; }
@media (max-width: 600px) { .content { padding: 16px; } }

/* Page head ------------------------------------------------------------- */
.page-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
  margin-bottom: 22px; flex-wrap: wrap;
}
.page-head h1 { font-size: 1.6rem; margin: 0; }
.page-head .lede { font-size: 0.95rem; margin-top: 4px; }
.page-head__actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Stat / KPI cards ------------------------------------------------------ */
.stat {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 6px;
}
.stat__label { font-size: 0.78rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.stat__value { font-size: 1.9rem; font-weight: 800; color: var(--brand); line-height: 1.1; }
.stat__value span.unit { font-size: 1rem; color: var(--accent); font-weight: 700; margin-inline-start: 4px; }
.stat__meta { font-size: 0.82rem; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.stat__icon { width: 36px; height: 36px; border-radius: 10px; background: rgba(0, 0, 128, 0.08); color: var(--brand); display: inline-flex; align-items: center; justify-content: center; }

.kpi-card .kpi-num { font-size: 2.4rem; font-weight: 800; color: var(--brand); line-height: 1; }
.kpi-card .kpi-num span { font-size: 1.2rem; color: var(--accent); }
.kpi-bar { height: 8px; background: var(--bg-alt); border-radius: 999px; overflow: hidden; margin-top: 12px; }
.kpi-bar__fill { height: 100%; background: linear-gradient(90deg, var(--brand), var(--accent)); border-radius: 999px; }

/* Forms ---------------------------------------------------------------- */
.form-group { margin-bottom: 14px; }
.form-row { display: grid; gap: 14px; grid-template-columns: 1fr 1fr; }
@media (max-width: 600px) { .form-row { grid-template-columns: 1fr; } }
label { display: block; font-size: 0.84rem; font-weight: 600; color: var(--ink); margin-bottom: 6px; }
label .req { color: var(--danger); margin-inline-start: 3px; }
.form-control,
input:not([type]),
input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="tel"], input[type="url"],
input[type="date"], input[type="datetime-local"], input[type="time"],
input[type="search"], input[type="month"], input[type="week"],
input[type="color"], input[type="file"],
select, textarea {
  width: 100%; padding: 10px 14px; border: 1px solid var(--line); border-radius: 10px;
  font-family: inherit; font-size: 16px; background: var(--surface); color: var(--ink); outline: none;
  transition: border-color .15s, box-shadow .15s;
  box-sizing: border-box;
}
textarea { min-height: 90px; resize: vertical; }
.form-control:focus,
input:not([type]):focus,
input[type="text"]:focus, input[type="email"]:focus, input[type="password"]:focus,
input[type="number"]:focus, input[type="tel"]:focus, input[type="url"]:focus,
input[type="date"]:focus, input[type="datetime-local"]:focus, input[type="time"]:focus,
input[type="search"]:focus, input[type="month"]:focus, input[type="week"]:focus,
select:focus, textarea:focus {
  border-color: var(--brand); box-shadow: 0 0 0 3px rgba(0, 0, 128, 0.1);
}
input[disabled], select[disabled], textarea[disabled],
input:disabled, select:disabled, textarea:disabled {
  background: var(--surface-2); color: var(--muted); cursor: not-allowed;
}
input[type="file"] { padding: 8px 10px; line-height: 1.2; }
input[type="checkbox"], input[type="radio"] {
  width: 16px; height: 16px; padding: 0; margin: 0;
  accent-color: var(--brand);
}
.form-hint { font-size: 0.78rem; color: var(--muted); margin-top: 4px; }
.form-error { font-size: 0.78rem; color: var(--danger); margin-top: 4px; }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 22px; }
.checkbox-row { display: flex; align-items: center; gap: 8px; font-size: 0.9rem; }
.checkbox-row input { width: auto; }

/* Tables --------------------------------------------------------------- */
.tbl { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.tbl th, .tbl td { padding: 12px 14px; text-align: start; border-bottom: 1px solid var(--line); font-size: 0.9rem; }
.tbl th { background: var(--surface-2); font-weight: 700; color: var(--ink); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover { background: rgba(0, 0, 128, 0.03); }
/* Action column — stay a proper table cell so it lines up with the row */
.tbl .row-actions {
  text-align: end;
  white-space: nowrap;
  vertical-align: middle;
  width: 1%;
}
.tbl .row-actions a, .tbl .row-actions button {
  width: 32px; height: 32px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  vertical-align: middle;
  margin-inline-start: 4px;
  padding: 0;
  flex-shrink: 0;
}
.tbl .row-actions a:first-child, .tbl .row-actions button:first-child,
.tbl .row-actions form:first-child a, .tbl .row-actions form:first-child button { margin-inline-start: 0; }
.tbl .row-actions a:hover, .tbl .row-actions button:hover { background: var(--surface-2); text-decoration: none; border-color: var(--brand); color: var(--brand); }
.tbl .row-actions .danger { color: var(--danger); }
.tbl .row-actions .danger:hover { border-color: var(--danger); color: var(--danger); background: rgba(220,38,38,0.05); }
.tbl .row-actions form { display: inline-block; margin: 0; padding: 0; vertical-align: middle; }

.tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

@media (max-width: 640px) {
  .tbl.responsive thead { display: none; }
  .tbl.responsive, .tbl.responsive tbody, .tbl.responsive tr, .tbl.responsive td { display: block; width: 100%; }
  .tbl.responsive tr { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 12px; padding: 6px 0; box-shadow: var(--shadow); }
  .tbl.responsive td { display: flex; justify-content: space-between; align-items: center; gap: 14px; border-bottom: 1px dashed var(--line); padding: 9px 14px; }
  .tbl.responsive td::before {
    content: attr(data-label); font-weight: 700; color: var(--muted); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em;
  }
  .tbl.responsive td:last-child { border-bottom: 0; }
  .tbl.responsive .row-actions { justify-content: flex-end; }
}

/* Badges -------------------------------------------------------------- */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px; border-radius: 999px; font-size: 0.74rem; font-weight: 700;
  background: var(--surface-2); color: var(--ink); border: 1px solid var(--line);
}
.badge .icon { width: 13px; height: 13px; }
.badge-blue   { background: #DBEAFE; color: #1E40AF; border-color: #BFDBFE; }
.badge-amber  { background: #FEF3C7; color: #92400E; border-color: #FDE68A; }
.badge-green  { background: #D1FAE5; color: #065F46; border-color: #A7F3D0; }
.badge-red    { background: #FEE2E2; color: #991B1B; border-color: #FECACA; }
.badge-violet { background: #EDE9FE; color: #5B21B6; border-color: #DDD6FE; }
.badge-slate  { background: #E2E8F0; color: #334155; border-color: #CBD5E1; }

/* Filters bar --------------------------------------------------------- */
.filter-bar {
  display: flex; gap: 10px; flex-wrap: wrap; align-items: center;
  background: var(--surface); padding: 14px; border-radius: var(--radius);
  border: 1px solid var(--line); margin-bottom: 18px; box-shadow: var(--shadow);
}
.filter-bar .form-control, .filter-bar select { padding: 8px 12px; font-size: 0.86rem; max-width: 220px; }
.filter-bar .spacer { flex: 1; }

/* Empty / no data ---------------------------------------------------- */
.empty {
  text-align: center; padding: 40px 20px; color: var(--muted);
  background: var(--surface); border-radius: var(--radius); border: 1px dashed var(--line);
}
.empty .icon { color: var(--soft-muted); }

/* Dropdowns ---------------------------------------------------------- */
.dd { position: relative; display: inline-block; }
.dd__menu {
  position: absolute; top: 100%; inset-inline-end: 0; margin-top: 6px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.12); min-width: 200px; padding: 6px;
  display: none; z-index: 80;
}
.dd.open .dd__menu { display: block; }
.dd__item {
  display: flex; align-items: center; gap: 8px; padding: 9px 12px; border-radius: 8px;
  color: var(--ink); text-decoration: none; font-size: 0.88rem; cursor: pointer;
}
.dd__item:hover { background: var(--surface-2); text-decoration: none; }
.dd__item.danger { color: var(--danger); }
.dd__sep { border-top: 1px solid var(--line); margin: 4px 0; }

/* Toast ---------------------------------------------------------------- */
.toast-host { position: fixed; bottom: 24px; inset-inline-end: 24px; z-index: 9999; display: flex; flex-direction: column; gap: 10px; pointer-events: none; }
.toast {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px 14px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.16); min-width: 280px; max-width: 380px;
  pointer-events: auto; display: flex; gap: 10px; align-items: flex-start;
  animation: toastIn .25s;
}
@keyframes toastIn {
  from { transform: translateY(8px); opacity: 0; }
  to { transform: none; opacity: 1; }
}
.toast__icon { width: 28px; height: 28px; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; }
.toast__title { font-weight: 700; }
.toast__msg { font-size: 0.86rem; color: var(--muted); }
.toast.success .toast__icon { background: #D1FAE5; color: var(--success); }
.toast.error   .toast__icon { background: #FEE2E2; color: var(--danger); }
.toast.info    .toast__icon { background: #DBEAFE; color: var(--info); }
.toast.warn    .toast__icon { background: #FEF3C7; color: var(--warn); }

/* Modal ---------------------------------------------------------------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15, 23, 42, 0.5);
  display: flex; align-items: center; justify-content: center; z-index: 200; padding: 16px;
}
.modal {
  background: var(--surface); border-radius: var(--radius-lg); padding: 22px;
  max-width: 600px; width: 100%; max-height: 90vh; overflow-y: auto;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.2);
}
.modal__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.modal__head h3 { margin: 0; }

/* Footer (marketing pages) -------------------------------------------- */
.footer {
  background: var(--brand-dark); color: #e2e8f0; padding: 60px 0 30px;
}
.footer .container { max-width: 1180px; }
.footer h4 { color: #fff; margin-bottom: 14px; }
.footer a { color: #cbd5e1; }
.footer a:hover { color: var(--accent); }
.footer .trust-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 22px; }
.trust-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 999px; font-size: 0.78rem;
}

/* Sticky bottom mobile CTA --------------------------------------------- */
.stick-cta {
  position: fixed; bottom: 0; left: 0; right: 0; padding: 12px;
  background: rgba(255, 255, 255, 0.98);
  border-top: 1px solid var(--line); z-index: 40; display: none;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
@media (max-width: 768px) {
  .stick-cta { display: block; }
  body.has-stick-cta { padding-bottom: 80px; }
}

/* Logo letter --------------------------------------------------------- */
.brand-logo {
  width: 40px; height: 40px; border-radius: 12px;
  background: var(--brand); color: var(--accent);
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 1.4rem; flex: 0 0 auto;
}

/* Auth pages ---------------------------------------------------------- */
.auth-wrap {
  min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr;
  background: linear-gradient(135deg, #000080 0%, #1e1e8e 100%);
}
.auth-wrap__hero {
  display: flex; flex-direction: column; justify-content: center; padding: 60px;
  color: #fff;
}
.auth-wrap__hero h1 { color: #fff; font-size: 2.5rem; line-height: 1.15; margin-bottom: 16px; }
.auth-wrap__hero h1 .grad { background: linear-gradient(90deg, #fff, var(--accent)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.auth-wrap__hero p { color: #cbd5e1; font-size: 1.06rem; max-width: 480px; }
.auth-wrap__hero .features { display: grid; gap: 14px; margin-top: 30px; max-width: 460px; }
.auth-wrap__hero .features li { display: flex; align-items: center; gap: 10px; list-style: none; color: #cbd5e1; }
.auth-wrap__hero .features li .icon { color: var(--accent); }

.auth-wrap__form {
  background: var(--bg); display: flex; align-items: center; justify-content: center; padding: 40px;
}
.auth-card {
  width: 100%; max-width: 420px;
}
.auth-card h2 { font-size: 1.6rem; margin-bottom: 6px; }
.auth-card .sub { color: var(--muted); font-size: 0.96rem; margin-bottom: 24px; }
.auth-card .auth-footer { margin-top: 18px; text-align: center; font-size: 0.84rem; color: var(--muted); }
.auth-card .lang-switch { margin-top: 24px; text-align: center; font-size: 0.82rem; }

@media (max-width: 900px) {
  .auth-wrap { grid-template-columns: 1fr; }
  .auth-wrap__hero { padding: 40px 24px 20px; text-align: center; }
  .auth-wrap__hero .features { margin: 24px auto 0; }
  .auth-wrap__hero h1 { font-size: 1.6rem; }
  .auth-wrap__form { padding: 24px; }
}

/* Misc ------------------------------------------------------------------ */
.hide { display: none !important; }
.row { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.gap-sm { gap: 6px; }
.flex-1 { flex: 1; }

/* Avatar */
.avatar { width: 36px; height: 36px; border-radius: 999px; background: var(--brand); color: #fff; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }
.avatar-sm { width: 26px; height: 26px; font-size: 0.7rem; }
.avatar-lg { width: 56px; height: 56px; font-size: 1.05rem; }

/* Section dividers */
.divider { height: 1px; background: var(--line); margin: 24px 0; }

/* Status pills (status timeline / progress) */
.timeline { display: flex; flex-direction: column; gap: 10px; }
.timeline__item { display: flex; gap: 12px; padding: 10px; border-radius: 12px; background: var(--surface-2); }
.timeline__icon { width: 36px; height: 36px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); display: inline-flex; align-items: center; justify-content: center; color: var(--brand); flex: 0 0 auto; }
.timeline__body strong { display: block; }
.timeline__body small { color: var(--muted); }

/* Step flow (numbered) */
.step-flow { display: grid; grid-template-columns: repeat(5, 1fr); gap: 18px; position: relative; }
.step-flow::before {
  content: ''; position: absolute; top: 24px; left: 8%; right: 8%; height: 2px;
  background-image: radial-gradient(circle, var(--accent) 1px, transparent 1px);
  background-size: 8px 2px; background-repeat: repeat-x;
}
.step-card { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px 14px 14px; box-shadow: var(--shadow); text-align: center; }
.step-card .num { position: absolute; top: -16px; left: 50%; transform: translateX(-50%); width: 32px; height: 32px; background: var(--accent); color: var(--ink); border-radius: 999px; font-weight: 800; display: inline-flex; align-items: center; justify-content: center; }
@media (max-width: 960px) {
  .step-flow { grid-template-columns: repeat(2, 1fr); }
  .step-flow::before { display: none; }
}
@media (max-width: 600px) { .step-flow { grid-template-columns: 1fr; } }

/* QR display */
.qr-box { padding: 14px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); display: inline-block; }
.qr-box svg { display: block; }

/* Photo grid */
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
.photo-grid .ph { aspect-ratio: 1/1; background: var(--surface-2); border-radius: 12px; overflow: hidden; }
.photo-grid .ph img { width: 100%; height: 100%; object-fit: cover; }

/* Tabs ----------------------------------------------------------------- */
.tabs { display: flex; gap: 8px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tabs a {
  padding: 10px 16px; color: var(--muted); font-weight: 600; font-size: 0.9rem;
  border-bottom: 3px solid transparent; margin-bottom: -1px; white-space: nowrap;
}
.tabs a:hover { color: var(--ink); text-decoration: none; }
.tabs a.active { color: var(--brand); border-bottom-color: var(--brand); }

/* Pagination ---------------------------------------------------------- */
.pager { display: flex; gap: 6px; justify-content: center; margin-top: 22px; }
.pager a, .pager span {
  padding: 8px 12px; border-radius: 8px; background: var(--surface); border: 1px solid var(--line);
  color: var(--ink); font-size: 0.86rem; min-width: 36px; text-align: center; text-decoration: none;
}
.pager a:hover { background: var(--surface-2); text-decoration: none; }
.pager .active { background: var(--brand); color: #fff; border-color: var(--brand); }
.pager .disabled { opacity: 0.5; pointer-events: none; }

/* Definition list */
.dl { display: grid; grid-template-columns: 1fr 2fr; gap: 10px 14px; }
.dl dt { font-weight: 600; color: var(--muted); font-size: 0.85rem; }
.dl dd { margin: 0; color: var(--ink); font-size: 0.9rem; }
@media (max-width: 600px) { .dl { grid-template-columns: 1fr; gap: 4px 0; } .dl dd { margin-bottom: 8px; } }

/* Tooltip helper */
[data-tip] { position: relative; }

/* Skeleton loaders */
@keyframes shimmer { 0% { background-position: -400px 0 } 100% { background-position: 400px 0 } }
.skel {
  background: linear-gradient(90deg, var(--bg-alt) 0%, var(--surface-2) 50%, var(--bg-alt) 100%);
  background-size: 800px 100%;
  animation: shimmer 1.4s infinite linear;
  border-radius: 8px;
  display: inline-block;
}
.skel-line { height: 14px; width: 100%; margin: 6px 0; }
.skel-line.w-50 { width: 50%; }
.skel-line.w-70 { width: 70%; }
.skel-card { background: var(--surface); padding: 20px; border-radius: var(--radius); border: 1px solid var(--line); }

/* Page transition fade-in */
.content > * { animation: fadeIn .25s ease-out; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* Top progress bar (NProgress-style) */
.topbar-progress { position: fixed; top: 0; left: 0; height: 3px; background: linear-gradient(90deg, var(--brand), var(--accent)); z-index: 9999; transition: width .25s, opacity .3s; opacity: 0; pointer-events: none; }
.topbar-progress.active { opacity: 1; }

/* Mobile show/hide helpers */
.show-mobile { display: none; }
@media (max-width: 768px) {
  .hide-mobile { display: none !important; }
  .show-mobile { display: initial; }
}

/* ===== Pagination bar ===== */
.pgr { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 12px 4px; margin-top: 10px; border-top: 1px solid var(--border); }
.pgr__count { font-size: 0.82rem; flex: 0 0 auto; }
.pgr__links { display: flex; gap: 4px; align-items: center; flex: 1 1 auto; justify-content: center; flex-wrap: wrap; }
.pgr__btn { display: inline-flex; align-items: center; justify-content: center; min-width: 32px; height: 32px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--card); color: var(--text); font-size: 0.85rem; font-weight: 600; text-decoration: none; transition: background .15s, border-color .15s; }
.pgr__btn:hover:not(.is-disabled) { background: var(--brand-50, #EEF2FF); border-color: var(--brand); color: var(--brand); }
.pgr__btn.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.pgr__btn.is-disabled { opacity: 0.4; cursor: not-allowed; }
.pgr__ellipsis { padding: 0 4px; color: var(--muted); }
.pgr__pp { display: flex; align-items: center; gap: 6px; }
.pgr__pp select { padding: 4px 8px; border: 1px solid var(--border); border-radius: 8px; background: var(--card); color: var(--text); font-size: 0.82rem; }

/* ===== Searchable combobox ===== */
.combo { position: relative; display: block; }
.combo__hidden { position: absolute; opacity: 0; pointer-events: none; height: 0; width: 0; }
.combo__input { width: 100%; padding-right: 32px; background-image: linear-gradient(to bottom right, transparent 50%, var(--muted) 50%, var(--muted) 60%, transparent 60%); }
.combo__panel { position: absolute; top: calc(100% + 4px); left: 0; right: 0; max-height: 280px; overflow: auto; background: var(--card); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 12px 32px rgba(0,0,0,0.12); z-index: 100; display: none; }
.combo.is-open .combo__panel { display: block; }
.combo__opt { padding: 8px 12px; cursor: pointer; font-size: 0.88rem; display: flex; gap: 6px; align-items: center; line-height: 1.35; }
.combo__opt:hover, .combo__opt.is-active { background: var(--brand-50, rgba(0,0,128,0.06)); color: var(--brand); }
.combo__opt.is-disabled { color: var(--muted); cursor: default; }
.combo__opt small { color: var(--muted); font-size: 0.74rem; margin-left: auto; }
.combo__empty { padding: 14px; text-align: center; color: var(--muted); font-size: 0.82rem; }

/* ===== Dashboard KPI tiles (richer) ===== */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.kpi-tile { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 14px; position: relative; overflow: hidden; }
.kpi-tile::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px; background: var(--brand); }
.kpi-tile.kpi--accent::before { background: var(--accent, #F5B301); }
.kpi-tile.kpi--ok::before { background: #16A34A; }
.kpi-tile.kpi--warn::before { background: #F59E0B; }
.kpi-tile.kpi--danger::before { background: #DC2626; }
.kpi-tile .kpi__label { color: var(--muted); font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.05em; }
.kpi-tile .kpi__value { font-size: 1.7rem; font-weight: 800; color: var(--text); margin-top: 4px; }
.kpi-tile .kpi__sub { color: var(--muted); font-size: 0.78rem; margin-top: 2px; }
.kpi-tile .kpi__icon { position: absolute; top: 12px; right: 12px; color: var(--muted); opacity: 0.4; }

/* Sprint 19.4 — short-form KPI tile naming (used by ISO, DSAR, Budgets, Scorecards, Devices, Vendor invoices, Sessions, Workforce, Softservices, Monthlyreports, etc.) */
/* Coexists with the BEM long-form `.kpi__label`/`__value` defined above */
.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; }
.kpi-tile__lbl { font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 700; }
.kpi-tile__val { font-size: 1.6rem; font-weight: 800; color: var(--text); margin-top: 4px; line-height: 1.1; }
[data-theme="dark"] .kpi-tile__val { color: #F1F5FF; }
[data-theme="dark"] .kpi-tile__lbl { color: #C7D2FE; }

/* ========================================================================== */
/* Sprint 19.5 — UI polish: dark mode + responsive grids + print                */
/* ========================================================================== */

/* Acceptance / ISO score hero block — hoisted (was inline in 4 pages) */
.acc-score { background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 22px 26px; margin-top: 14px; display: flex; gap: 24px; align-items: center; flex-wrap: wrap; }
.acc-score--pass { background: linear-gradient(135deg, rgba(22,163,74,0.06), rgba(22,163,74,0.02)); border-color: #16A34A; }
.acc-score--fail { background: linear-gradient(135deg, rgba(245,158,11,0.06), rgba(245,158,11,0.02)); border-color: #F59E0B; }
.acc-score__num { font-size: 3.4rem; font-weight: 800; line-height: 1; color: var(--text); }
.acc-score--pass .acc-score__num { color: #16A34A; }
.acc-score--fail .acc-score__num { color: #F59E0B; }
.acc-score__meta { display: flex; flex-direction: column; gap: 4px; }
.acc-score__meta strong { font-size: 1.1rem; }
[data-theme="dark"] .acc-score { background: var(--surface); }
[data-theme="dark"] .acc-score__num, [data-theme="dark"] .acc-score__meta strong { color: #F1F5FF; }

/* Dark mode for Sprint 18/19 components */
[data-theme="dark"] .iso-chip { background: rgba(199, 210, 254, 0.12); color: #E0E7FF; }
[data-theme="dark"] .iso-chip--evidence { background: rgba(34,197,94,0.18); color: #BBF7D0; }
[data-theme="dark"] .iso-flow-badge { box-shadow: 0 0 0 1px rgba(255,255,255,0.15); }
[data-theme="dark"] .iso-map { background: var(--surface); }
[data-theme="dark"] .iso-map__q { background: rgba(255,255,255,0.04); color: #CBD5E1; }
[data-theme="dark"] .iso-tab.is-active { background: rgba(199,210,254,0.12); }
[data-theme="dark"] .band, [data-theme="dark"] .readiness { opacity: 0.92; }
[data-theme="dark"] .iso-auto-evidence { background: rgba(34,197,94,0.2); color: #BBF7D0; }

/* Universal responsive grid drop-to-1-col under 600px */
@media (max-width: 600px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr !important; }
  .kpi-row, .kpi-grid { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)) !important; }
  .page-head { flex-direction: column !important; align-items: flex-start !important; }
  .page-head__actions { flex-wrap: wrap; }
  .acc-score { padding: 16px 18px; flex-direction: column; align-items: flex-start; }
  .acc-score__num { font-size: 2.4rem; }
}

/* ========================================================================== */
/* Print CSS — applies to every page, hides chrome, prints clean content        */
/* ========================================================================== */
@media print {
  /* Hide app chrome */
  .sidebar, .sidebar-backdrop, .topbar, .page-head__actions,
  .filter-bar, .pagination, .btn, .empty .btn, .nav__item, nav,
  .feed, .notification-dot, button, .toggle, .iconbtn,
  .iso-tabs, .modal, .dd, .dd-menu { display: none !important; }

  /* Reset layout to full width */
  body { background: #fff !important; color: #000 !important; }
  .content, main { margin-left: 0 !important; margin-right: 0 !important; padding: 0 !important; max-width: 100% !important; }
  .card { box-shadow: none !important; border: 1px solid #ddd !important; page-break-inside: avoid; }

  /* Strip backgrounds + heavy colours */
  .badge, .chip { background: transparent !important; color: #000 !important; border: 1px solid #999 !important; }
  .kpi-tile, .acc-score, .iso-map, .amend, .flow-card, .req-card, .example-card {
    box-shadow: none !important; border: 1px solid #ccc !important; page-break-inside: avoid;
  }
  .kpi-tile__val, .kpi-tile__lbl, .acc-score__num { color: #000 !important; }

  /* Tables print cleanly */
  table.tbl { width: 100%; border-collapse: collapse; }
  table.tbl th, table.tbl td { border: 1px solid #ccc !important; padding: 4px 6px !important; font-size: 0.78rem !important; }
  table.tbl thead { display: table-header-group; }
  tr { page-break-inside: avoid; }

  /* Links — show URL inline for reference */
  a[href^="http"]:after, a[href^="https"]:after { content: " [" attr(href) "]"; font-size: 0.7rem; color: #555; }

  /* Page setup */
  @page { size: A4; margin: 12mm; }
  h1 { font-size: 1.4rem; }
  h2 { font-size: 1.1rem; }
  h3 { font-size: 0.95rem; }
}

/* Compliance bars */
.compbar { background: rgba(0,0,0,0.05); border-radius: 100px; height: 10px; overflow: hidden; }
.compbar > span { display: block; height: 100%; background: linear-gradient(90deg, #22C55E, #15803D); border-radius: 100px; transition: width .4s; }
.compbar.is-warn > span { background: linear-gradient(90deg, #F59E0B, #B45309); }
.compbar.is-danger > span { background: linear-gradient(90deg, #EF4444, #B91C1C); }

/* Chart card */
.chart-card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 14px; }
.chart-card h3 { margin: 0 0 10px; font-size: 0.96rem; }
.chart-card canvas { max-height: 280px; }

/* ===== Calendar tabs ===== */
.cal-tabs { display: inline-flex; gap: 0; background: var(--card); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.cal-tabs a { padding: 6px 14px; font-size: 0.85rem; font-weight: 600; color: var(--muted); text-decoration: none; border-right: 1px solid var(--border); }
.cal-tabs a:last-child { border-right: none; }
.cal-tabs a.active { background: var(--brand); color: #fff; }

/* Sprint 19.4 — Calendar month-view grid (FIXED: min-width:0 + minmax(0,1fr)) */
/* Without min-width:0 grid items default to min-content and long titles blow the row width */
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 1px; background: var(--border); border-radius: 12px; overflow: hidden; }
.cal-grid > .cal-head { background: var(--brand); color: #fff; padding: 8px 6px; text-align: center; font-weight: 700; font-size: 0.78rem; letter-spacing: 0.04em; }
.cal-day { background: var(--card); border: 0; min-height: 96px; min-width: 0; overflow: hidden; padding: 6px 8px; display: flex; flex-direction: column; gap: 4px; position: relative; transition: box-shadow .12s ease; }
.cal-day:hover { box-shadow: inset 0 0 0 2px var(--brand); cursor: pointer; }
.cal-day.empty { background: rgba(0,0,128,0.02); opacity: 0.6; cursor: default; }
.cal-day.today { box-shadow: inset 0 0 0 2px var(--brand); }
.cal-day__num { font-weight: 700; color: var(--text); font-size: 0.86rem; }
.cal-day.today .cal-day__num { color: var(--brand); }
.cal-day__count { display: inline-flex; align-items: center; justify-content: center; min-width: 22px; height: 18px; padding: 0 6px; border-radius: 999px; font-size: 0.66rem; font-weight: 700; background: var(--brand); color: #fff; }
.cal-day__pills { display: flex; flex-direction: column; gap: 2px; overflow: hidden; }
.cal-day__pill { display: block; padding: 2px 6px; border-radius: 4px; background: rgba(0,0,128,0.08); color: var(--text); font-size: 0.7rem; text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; min-width: 0; }
.cal-day__pill.prio-emergency { background: #FEE2E2; color: #7F1D1D; }
.cal-day__pill.prio-high { background: #FEF3C7; color: #92400E; }
.cal-day__pill.prio-low { background: #F1F5F9; color: #475569; }
.cal-day__more { font-size: 0.7rem; color: var(--muted); padding: 0 6px; }
@media (max-width: 700px) {
  .cal-day { min-height: 60px; padding: 4px; }
  .cal-day__pill { font-size: 0.64rem; padding: 1px 4px; }
}

/* Calendar day-view list */
.cal-day-list { display: flex; flex-direction: column; gap: 8px; }
.cal-day-list .cal-event { padding: 10px 12px; border-radius: 8px; background: var(--card); border: 1px solid var(--border); border-left: 4px solid var(--brand); display: flex; gap: 10px; align-items: center; }
.cal-day-list .cal-event.prio-emergency { border-left-color: #DC2626; }
.cal-day-list .cal-event.prio-high { border-left-color: #F59E0B; }
.cal-day-list .cal-event.prio-low { border-left-color: #94A3B8; }
.cal-day-list .cal-event .cal-time { font-weight: 700; color: var(--brand); min-width: 60px; }
.cal-day-list .cal-event .cal-meta { font-size: 0.78rem; color: var(--muted); }

/* Week view: 7 columns */
.cal-week-grid { display: grid; grid-template-columns: 70px repeat(7, 1fr); gap: 1px; background: var(--border); border-radius: 12px; overflow: hidden; }
.cal-week-grid > .cal-week-head, .cal-week-grid > .cal-week-cell, .cal-week-grid > .cal-week-hour { background: var(--card); padding: 4px; min-height: 36px; font-size: 0.74rem; }
.cal-week-grid > .cal-week-head { background: var(--brand); color: #fff; text-align: center; padding: 8px 4px; font-weight: 700; }
.cal-week-grid > .cal-week-cell .cal-pill { background: var(--brand); color: #fff; padding: 2px 6px; border-radius: 6px; font-size: 0.72rem; margin: 2px 0; display: block; text-decoration: none; }
.cal-week-grid > .cal-week-cell .cal-pill.prio-emergency { background: #DC2626; }
.cal-week-grid > .cal-week-cell .cal-pill.prio-high { background: #F59E0B; }

/* Activity feed */
.feed { display: flex; flex-direction: column; gap: 0; }
.feed__item { display: flex; gap: 12px; padding: 10px 4px; border-bottom: 1px dashed var(--border); align-items: flex-start; }
.feed__item:last-child { border-bottom: none; }
.feed__dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 7px; flex: 0 0 8px; background: var(--brand); }
.feed__dot.dot--ok { background: #16A34A; }
.feed__dot.dot--warn { background: #F59E0B; }
.feed__dot.dot--danger { background: #DC2626; }
.feed__body { flex: 1; min-width: 0; }
.feed__title { font-weight: 600; font-size: 0.88rem; display: block; }
.feed__meta { font-size: 0.75rem; color: var(--muted); margin-top: 2px; }

/* Tech KPI cards */
.tech-kpi-card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 14px; display: flex; gap: 12px; }
.tech-kpi-card .tech-avatar { width: 48px; height: 48px; border-radius: 50%; background: var(--brand); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 800; flex: 0 0 48px; }
.tech-kpi-card .tech-meta strong { display: block; font-size: 0.94rem; }
.tech-kpi-card .tech-meta small { color: var(--muted); font-size: 0.74rem; }
.tech-kpi-card .tech-numbers { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 8px; }
.tech-kpi-card .tech-numbers div { background: rgba(0,0,128,0.05); border-radius: 6px; padding: 6px; text-align: center; }
.tech-kpi-card .tech-numbers strong { font-size: 1rem; }
.tech-kpi-card .tech-numbers small { font-size: 0.66rem; color: var(--muted); text-transform: uppercase; }

/* Filter row variant for date range */
.filter-bar .field { display: flex; flex-direction: column; gap: 2px; }
.filter-bar label.field-lbl { font-size: 0.7rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }

/* Quick date-range pill row (above the main filter bar) */
.quick-range { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; padding: 6px 2px; }
.quick-range__lbl { font-size: 0.74rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; margin-right: 4px; }
.qr-pill { display: inline-flex; align-items: center; gap: 5px; padding: 5px 11px; border-radius: 999px; border: 1px solid var(--border); background: var(--card); color: var(--text); font-size: 0.8rem; font-weight: 600; text-decoration: none; transition: background .12s, border-color .12s, color .12s; }
.qr-pill:hover { background: rgba(0,0,128,0.06); border-color: var(--brand); color: var(--brand); text-decoration: none; }
.qr-pill.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.qr-pill--clear { color: var(--muted); border-style: dashed; }
[data-theme="dark"] .qr-pill { background: var(--surface); color: var(--text); border-color: var(--border); }
[data-theme="dark"] .qr-pill:hover { background: rgba(245,179,1,0.10); border-color: var(--accent, #F5B301); color: var(--accent, #F5B301); }
[data-theme="dark"] .qr-pill.active { background: var(--accent, #F5B301); color: #0E2A47; border-color: var(--accent, #F5B301); }
[data-theme="dark"] .qr-pill--clear { color: var(--muted); }

/* QR-encoded URL display under QR codes on view pages */
.qr-url { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.74rem; word-break: break-all; padding: 6px 10px; background: rgba(0,0,128,0.04); border: 1px dashed var(--border); border-radius: 6px; line-height: 1.35; }
.qr-url a { color: #000080; text-decoration: none; }
.qr-url a:hover { text-decoration: underline; }
[data-theme="dark"] .qr-url { background: rgba(59,130,246,0.06); }
[data-theme="dark"] .qr-url a { color: #93c5fd; }

/* T7: Accessibility polish — visible focus rings, screen-reader live regions, label binding */
*:focus-visible { outline: 2px solid #000080; outline-offset: 2px; border-radius: 4px; }
[data-theme="dark"] *:focus-visible { outline-color: #93c5fd; }
.sr-only { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0,0,0,0) !important; white-space: nowrap !important; border: 0 !important; }
.skip-link { position: absolute; left: 0; top: -40px; background: #000080; color: #fff; padding: 8px 14px; z-index: 1000; transition: top 0.2s; }
.skip-link:focus { top: 0; }
/* Forced-contrast helpers */
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; } }
@media (prefers-contrast: more) { :root { --border: #000; --muted: #1f2937; } }

/* T8: Bulk-action toolbar that appears when items are selected */
.bulk-bar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; background: rgba(0,0,128,0.06); border: 1px solid var(--border); border-left: 4px solid #000080; border-radius: 10px; padding: 10px 14px; margin: 0 0 12px; position: sticky; top: 8px; z-index: 6; }
[data-theme="dark"] .bulk-bar { background: rgba(59,130,246,0.08); }
.bulk-bar strong { color: #000080; font-size: 0.9rem; }
[data-theme="dark"] .bulk-bar strong { color: #93c5fd; }
.bulk-bar .field { margin: 0; }
.bulk-bar .field-lbl { display: block; }
