/* =====================================================================
   ADB World — Facility Management System
   Brand: ADB blue #2D64B0 + charcoal #404040 (from the company logo)
   ===================================================================== */
@font-face { font-family: "Figtree"; font-weight: 400; font-display: swap; src: url(../vendor/figtree/figtree-latin-400-normal.woff2) format("woff2"); }
@font-face { font-family: "Figtree"; font-weight: 500; font-display: swap; src: url(../vendor/figtree/figtree-latin-500-normal.woff2) format("woff2"); }
@font-face { font-family: "Figtree"; font-weight: 600; font-display: swap; src: url(../vendor/figtree/figtree-latin-600-normal.woff2) format("woff2"); }
@font-face { font-family: "Figtree"; font-weight: 700; font-display: swap; src: url(../vendor/figtree/figtree-latin-700-normal.woff2) format("woff2"); }

:root {
  --brand: #2d64b0;
  --brand-dark: #234f8c;
  --brand-soft: #eaf1fb;
  --charcoal: #404040;
  --bg: #f3f5f8;
  --surface: #ffffff;
  --surface-2: #f7f8fa;
  --ink: #23272b;
  --ink-2: #4a4f56;
  --muted: #6c727a;
  --line: #e3e6ea;
  --line-2: #cfd4da;
  --side-bg: #ffffff;
  --side-ink: #404040;
  --side-muted: #8a9099;
  --side-hover: #f3f6fa;
  --accent: var(--brand);
  --accent-ink: #ffffff;
  --accent-soft: var(--brand-soft);
  --link: var(--brand);
  --focus: #2d64b0;
  --red: #b3261e; --red-bg: #fce8e6;
  --amber: #8a5a00; --amber-bg: #fff1d6;
  --blue: #1d4f91; --blue-bg: #e3edfa;
  --green: #1c6b3f; --green-bg: #e2f3e8;
  --grey: #4a5866; --grey-bg: #edf0f3;
  --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a; --series-4: #eda100;
  --grid: #e8ebef;
  --shadow: 0 1px 2px rgba(35, 39, 43, .06), 0 1px 1px rgba(35, 39, 43, .03);
  --shadow-lg: 0 12px 32px rgba(35, 39, 43, .16);
  --r-card: 12px; --r-ctl: 8px;
  --side: 264px;
  --font: "Figtree", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111418; --surface: #191d22; --surface-2: #1f242a; --ink: #e8eaed; --ink-2: #b9bfc6; --muted: #8b929a;
    --line: #2a3037; --line-2: #39414a; --side-bg: #15181c; --side-ink: #d6dadf; --side-muted: #7d848c; --side-hover: #1f242a;
    --brand-soft: #1b2a40; --accent: #5b93dd; --accent-ink: #0b1626; --link: #7eaaea; --focus: #7eaaea;
    --red: #ff9a91; --red-bg: #43201d; --amber: #f4c56b; --amber-bg: #3a2d10; --blue: #9cc2f5; --blue-bg: #1b2f4a;
    --green: #8fd6a9; --green-bg: #173726; --grey: #b4c1cd; --grey-bg: #262c33;
    --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500; --grid: #262c33;
    --shadow: 0 1px 2px rgba(0,0,0,.4); --shadow-lg: 0 12px 32px rgba(0,0,0,.5);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #111418; --surface: #191d22; --surface-2: #1f242a; --ink: #e8eaed; --ink-2: #b9bfc6; --muted: #8b929a;
  --line: #2a3037; --line-2: #39414a; --side-bg: #15181c; --side-ink: #d6dadf; --side-muted: #7d848c; --side-hover: #1f242a;
  --brand-soft: #1b2a40; --accent: #5b93dd; --accent-ink: #0b1626; --link: #7eaaea; --focus: #7eaaea;
  --red: #ff9a91; --red-bg: #43201d; --amber: #f4c56b; --amber-bg: #3a2d10; --blue: #9cc2f5; --blue-bg: #1b2f4a;
  --green: #8fd6a9; --green-bg: #173726; --grey: #b4c1cd; --grey-bg: #262c33;
  --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500; --grid: #262c33;
  --shadow: 0 1px 2px rgba(0,0,0,.4); --shadow-lg: 0 12px 32px rgba(0,0,0,.5);
  color-scheme: dark;
}
/* logo swap for dark mode */
.logo-dark { display: none !important; }
:root[data-theme="dark"] .logo-light { display: none !important; }
:root[data-theme="dark"] .logo-dark { display: block !important; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .logo-light { display: none !important; }
  :root:not([data-theme="light"]) .logo-dark { display: block !important; }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: 14.5px; -webkit-font-smoothing: antialiased; line-height: 1.5; color: var(--ink); background: var(--bg); }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; margin: 0; }
h1 { font-size: 1.6rem; font-weight: 600; letter-spacing: -.01em; }
h3 { font-size: 1rem; font-weight: 600; margin: 1rem 0 .4rem; }
code { font-size: .86em; background: var(--surface-2); border: 1px solid var(--line); padding: 1px 5px; border-radius: 4px; }
img { max-width: 100%; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.muted { color: var(--muted); }
.text-danger { color: var(--red) !important; }
.text-success { color: var(--green) !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.skip { position: absolute; left: -999px; top: 8px; background: var(--accent); color: var(--accent-ink); padding: 8px 12px; z-index: 100; border-radius: 6px; }
.skip:focus { left: 8px; }
[hidden] { display: none !important; }

/* ---------------- App shell ---------------- */
.app { min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--side); z-index: 40;
  background: var(--side-bg); border-right: 1px solid var(--line);
  color: var(--side-ink); display: flex; flex-direction: column; overflow: hidden;
}
.brand { padding: 18px 20px 14px; border-bottom: 1px solid var(--line); }
.brand-logo { display: block; }
.brand-logo img { height: 46px; width: auto; display: block; }
.brand-sub { display: block; margin-top: 6px; font-size: .74rem; color: var(--side-muted); letter-spacing: .02em; }
.nav { overflow-y: auto; padding: 10px 10px 20px; flex: 1; scrollbar-width: thin; }
.nav-list { list-style: none; margin: 0; padding: 0; }
.nav-list a { display: flex; align-items: center; gap: 11px; padding: 7px 10px; border-radius: 8px; color: var(--side-ink); font-size: .9rem; position: relative; }
.nav-list a i { font-size: 1.02rem; width: 18px; text-align: center; color: var(--side-muted); }
.nav-list a:hover { background: var(--side-hover); text-decoration: none; }
.nav-list a.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.nav-list a.active i { color: var(--brand); }
:root[data-theme="dark"] .nav-list a.active, :root[data-theme="dark"] .nav-list a.active i { color: var(--link); }
.nav-list a.active::before { content: ""; position: absolute; left: -10px; top: 7px; bottom: 7px; width: 3px; background: var(--brand); border-radius: 0 3px 3px 0; }
.nav-group { margin-top: 6px; }
.nav-group summary { list-style: none; cursor: pointer; display: flex; justify-content: space-between; align-items: center; padding: 8px 10px 6px; font-size: .78rem; font-weight: 600; color: var(--side-muted); border-radius: 6px; }
.nav-group summary::-webkit-details-marker { display: none; }
.nav-group summary:hover { color: var(--side-ink); }
.nav-group summary i { font-size: .7rem; transition: transform .15s; }
.nav-group[open] summary i { transform: rotate(180deg); }
.nav-company { display: flex; align-items: center; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--line); font-size: .82rem; color: var(--side-muted); }
.nav-company:hover { color: var(--brand); text-decoration: none; }
.content { margin-left: var(--side); min-height: 100vh; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 12px; padding: 10px 24px; background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar .menu-btn { display: none; }
.global-search { flex: 1; max-width: 560px; position: relative; }
.global-search i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.global-search input { width: 100%; padding-left: 36px; background: var(--surface); }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.bell { position: relative; }
.bell .dot { position: absolute; top: 1px; right: 0; background: var(--red); color: #fff; font-size: .64rem; font-weight: 600; border-radius: 999px; padding: 0 5px; min-width: 16px; text-align: center; line-height: 16px; }
.user-menu { position: relative; }
.user-menu summary { list-style: none; display: flex; align-items: center; gap: 9px; cursor: pointer; padding: 4px 6px; border-radius: 8px; }
.user-menu summary::-webkit-details-marker { display: none; }
.user-menu summary:hover { background: var(--surface); }
.user-menu summary > span:last-child { display: flex; flex-direction: column; line-height: 1.2; font-size: .88rem; font-weight: 500; }
.user-menu small { color: var(--muted); font-weight: 400; font-size: .76rem; }
.dropdown { position: absolute; right: 0; top: calc(100% + 6px); background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow-lg); min-width: 200px; padding: 6px; z-index: 50; }
.dropdown a { display: flex; gap: 10px; padding: 8px 10px; border-radius: 6px; color: var(--ink); }
.dropdown a:hover { background: var(--surface-2); text-decoration: none; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--brand); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: .78rem; font-weight: 600; flex: none; }
.avatar.sm { width: 28px; height: 28px; font-size: .7rem; }
.main { padding: 22px 24px 40px; flex: 1; width: 100%; max-width: 1480px; }
.foot { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding: 14px 24px; font-size: .8rem; color: var(--muted); border-top: 1px solid var(--line); }
.scrim { display: none; }

/* ---------------- Controls ---------------- */
input, select, textarea { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r-ctl); padding: 8px 10px; min-height: 38px; width: 100%; transition: border-color .12s, box-shadow .12s; }
textarea { resize: vertical; min-height: 80px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
input[type=checkbox], input[type=radio] { width: auto; min-height: 0; accent-color: var(--brand); }
input:disabled, select:disabled { background: var(--surface-2); color: var(--muted); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; font: inherit; font-weight: 500; font-size: .9rem; padding: 8px 14px; min-height: 38px; border-radius: 8px; border: 1px solid transparent; cursor: pointer; white-space: nowrap; text-decoration: none !important; background: var(--surface); color: var(--ink); line-height: 1.2; }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
:root[data-theme="dark"] .btn-primary:hover { background: #7eaaea; }
.btn-ghost { background: var(--surface); border-color: var(--line-2); color: var(--ink); }
.btn-ghost:hover { background: var(--surface-2); border-color: var(--ink-2); }
.btn-ghost.danger, .btn-link.danger { color: var(--red); }
.btn-link { background: none; border: none; color: var(--link); padding: 6px 8px; min-height: 0; }
.btn-sm { padding: 5px 10px; min-height: 32px; font-size: .84rem; }
.btn-block { width: 100%; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 8px; border: none; background: none; color: var(--ink-2); cursor: pointer; font-size: 1.05rem; }
.icon-btn:hover { background: var(--surface); color: var(--ink); text-decoration: none; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.switch { position: relative; display: inline-block; width: 42px; height: 24px; }
.switch input[type=checkbox] { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; background: var(--line-2); border-radius: 999px; cursor: pointer; transition: background .15s; }
.switch span::after { content: ""; position: absolute; left: 3px; top: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(18px); }
.switch input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; }
.check { display: inline-flex; align-items: center; gap: 7px; font-size: .9rem; cursor: pointer; }
.checks { display: flex; flex-wrap: wrap; gap: 8px 18px; padding: 6px 0; }

/* ---------------- Page structure ---------------- */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head p { margin: 4px 0 0; }
.page-head .back { display: inline-flex; gap: 6px; align-items: center; font-size: .86rem; color: var(--muted); margin-bottom: 6px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.actions form { margin: 0; }
.actions select { width: auto; min-width: 180px; }
.meta-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 8px; font-size: .86rem; }
.ref { font-weight: 600; color: var(--ink-2); background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 1px 8px; font-variant-numeric: tabular-nums; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); padding: 18px 20px; margin-bottom: 16px; box-shadow: var(--shadow); }
.card-title { font-size: 1rem; font-weight: 600; margin: 0 0 12px; display: flex; align-items: center; gap: 8px; }
.card-title .count { margin-left: auto; font-size: .82rem; font-weight: 500; color: var(--muted); }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 10px; }
.card-head .card-title { margin: 0; }
.card-head a, .card-head span { font-size: .84rem; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.grid-2 > .card, .grid-3 > .card { margin-bottom: 0; }
.grid-2, .grid-3 { margin-bottom: 16px; }

/* alerts */
.alert { position: relative; padding: 11px 40px 11px 14px; border-radius: 8px; margin-bottom: 14px; border: 1px solid; font-size: .92rem; }
.alert ul { margin: 6px 0 0; padding-left: 18px; }
.alert-success { background: var(--green-bg); border-color: color-mix(in srgb, var(--green) 30%, transparent); color: var(--green); }
.alert-danger { background: var(--red-bg); border-color: color-mix(in srgb, var(--red) 30%, transparent); color: var(--red); }
.alert-warning { background: var(--amber-bg); border-color: color-mix(in srgb, var(--amber) 30%, transparent); color: var(--amber); }
.alert-info { background: var(--blue-bg); border-color: color-mix(in srgb, var(--blue) 25%, transparent); color: var(--blue); }
.alert-x { position: absolute; right: 8px; top: 6px; background: none; border: none; font-size: 1.3rem; color: inherit; cursor: pointer; opacity: .6; }

/* pills */
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 1px 9px; border-radius: 999px; font-size: .76rem; font-weight: 600; white-space: nowrap; line-height: 1.6; }
.pill-red { background: var(--red-bg); color: var(--red); }
.pill-amber { background: var(--amber-bg); color: var(--amber); }
.pill-blue { background: var(--blue-bg); color: var(--blue); }
.pill-green { background: var(--green-bg); color: var(--green); }
.pill-grey { background: var(--grey-bg); color: var(--grey); }
.chip { display: inline-block; padding: 1px 8px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--line); font-size: .78rem; margin: 1px 2px 1px 0; }

/* ---------------- Stats ---------------- */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { display: flex; flex-direction: column; gap: 2px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); padding: 14px 16px 13px; color: var(--ink); box-shadow: var(--shadow); position: relative; overflow: hidden; }
a.stat:hover { text-decoration: none; border-color: var(--line-2); }
.stat::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--line-2); }
.stat-alert::before { background: var(--red); }
.stat-warn::before { background: #e8a317; }
.stat::before { background: var(--brand); opacity: .35; }
.stat-alert::before, .stat-warn::before { opacity: 1; }
.stat-label { font-size: .82rem; color: var(--muted); }
.stat-value { font-size: 1.85rem; font-weight: 600; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.15; }
.stat-sub { font-size: .8rem; color: var(--ink-2); }
.mini-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.mini-stats div { background: var(--surface-2); border-radius: 8px; padding: 10px 12px; display: flex; flex-direction: column; }
.mini-stats strong { font-size: 1.1rem; font-variant-numeric: tabular-nums; }
.mini-stats span { font-size: .78rem; color: var(--muted); }

/* ---------------- Lists ---------------- */
.list { list-style: none; margin: 0; padding: 0; }
.list li { border-top: 1px solid var(--line); }
.list li:first-child { border-top: none; }
.list li > a, .list li > .l-main { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 9px 2px; color: var(--ink); }
.list li > a:hover { text-decoration: none; background: var(--surface-2); margin: 0 -8px; padding: 9px 10px; border-radius: 6px; }
.l-main { display: flex; flex-direction: column; min-width: 0; }
.l-main strong { font-weight: 500; font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.l-main small { font-size: .78rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.l-side { flex: none; font-size: .82rem; white-space: nowrap; }
.notif li.unread strong::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--brand); margin-right: 8px; vertical-align: middle; }
.plain { padding-left: 18px; margin: 0; }
.plain li { margin: 4px 0; }
.linked { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 8px 10px; margin: 0 -10px; border-radius: 6px; color: var(--ink); }
.linked:hover { background: var(--surface-2); text-decoration: none; }
.linked strong { color: var(--link); font-weight: 600; }

/* ---------------- Filters & tables ---------------- */
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding: 12px; }
.filters select, .filters input[type=date] { width: auto; min-width: 140px; max-width: 220px; }
.search-field { position: relative; flex: 1 1 240px; min-width: 200px; }
.search-field i { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search-field input { padding-left: 34px; }
.inline-label { display: inline-flex; align-items: center; gap: 6px; font-size: .86rem; color: var(--muted); }
.inline-label input { width: auto; }
.filter-toggle { display: none !important; }
.table-card { padding: 0; overflow: hidden; }
.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th { text-align: left; font-weight: 600; font-size: .8rem; color: var(--ink-2); background: var(--surface-2); padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table th a { color: inherit; }
.table td { padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr[data-href] { cursor: pointer; }
.table tbody tr:hover td { background: color-mix(in srgb, var(--surface-2) 70%, transparent); }
.table td.act, .table th.act { width: 1%; white-space: nowrap; text-align: right; }
.table td.act form { display: inline; }
.table .chk { width: 36px; }
.table.compact th, .table.compact td { padding: 7px 10px; }
.table tfoot td { font-weight: 500; background: var(--surface-2); }
.table tfoot tr.total td { font-weight: 700; font-size: 1rem; }
.card .table-wrap { border-radius: 8px; }
.card:not(.table-card) .table { border: 1px solid var(--line); border-radius: 8px; }
.row-link { color: var(--ink); font-weight: 500; }
.user-cell { display: inline-flex; align-items: center; gap: 10px; }
.user-cell > span:last-child { display: flex; flex-direction: column; line-height: 1.3; }
.table-foot { padding: 10px 14px; margin: 0; font-size: .82rem; border-top: 1px solid var(--line); }
.perm-matrix td, .perm-matrix th { text-align: center; }
.perm-matrix td:first-child, .perm-matrix th:first-child { text-align: left; }
.perm-matrix select { width: auto; min-height: 32px; padding: 4px 8px; }
.perm-matrix tr.grp th { background: var(--bg); text-align: left; color: var(--ink); }
.audit .det { font-size: .82rem; max-width: 460px; word-break: break-word; }
.pager { display: flex; gap: 4px; justify-content: center; margin: 14px 0; flex-wrap: wrap; }
.pager a, .pager span { min-width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); padding: 0 8px; }
.pager .cur { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.bulk-bar { position: sticky; bottom: 12px; display: flex; gap: 10px; align-items: center; background: var(--charcoal); color: #fff; padding: 10px 14px; border-radius: 10px; box-shadow: var(--shadow-lg); margin: 10px 0; flex-wrap: wrap; }
.bulk-bar select { width: auto; }
.empty { text-align: center; padding: 44px 20px; }
.empty i { font-size: 2.2rem; color: var(--muted); }
.empty h2, .empty h3 { margin: 10px 0 6px; }
.empty p { color: var(--muted); margin: 0 0 16px; }

/* ---------------- Forms ---------------- */
.form-card { padding: 22px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 18px; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field.span-2 { grid-column: span 2; }
.field > label { font-size: .85rem; font-weight: 500; color: var(--ink-2); }
.req { color: var(--red); }
.help { color: var(--muted); font-size: .78rem; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.sticky-actions { position: sticky; bottom: 0; background: var(--bg); padding: 12px 0; border: none; }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--line); }
.inline-form input, .inline-form select { width: auto; flex: 1 1 140px; min-width: 110px; }
.inline-form input[type=number] { flex: 0 1 100px; }
.reject-form { display: flex; gap: 6px; align-items: center; }
.reject-form input, .reject-form select { width: auto; min-width: 150px; }
.sel-filter { min-height: 32px; padding: 5px 9px; font-size: .85rem; border-bottom-left-radius: 0; border-bottom-right-radius: 0; border-bottom-style: dashed; background: var(--surface-2); }
.sel-filter + select { border-top-left-radius: 0; border-top-right-radius: 0; border-top: none; }
.upload-form { display: flex; gap: 8px; align-items: center; margin-top: 10px; flex-wrap: wrap; }
.upload-form input[type=file] { padding: 5px; font-size: .82rem; flex: 1 1 160px; min-width: 0; width: auto; }

/* ---------------- Record view ---------------- */
.view-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.details { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px 18px; margin: 0; }
.details div { min-width: 0; }
.details dt { font-size: .76rem; color: var(--muted); margin-bottom: 2px; }
.details dd { margin: 0; font-size: .92rem; word-break: break-word; }
.long-text { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.long-text h3 { margin-top: 0; font-size: .85rem; color: var(--ink-2); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 7px 14px; margin: 0; font-size: .9rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.comments { list-style: none; padding: 0; margin: 0 0 14px; }
.comments li { display: flex; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.comments li:first-child { border-top: none; }
.comments li.internal { background: var(--amber-bg); margin: 0 -10px; padding: 10px; border-radius: 8px; border-top: none; }
.c-head { font-size: .86rem; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.c-body { font-size: .92rem; margin-top: 2px; word-break: break-word; }
.comment-form textarea { min-height: 70px; }
.comment-actions { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 8px; flex-wrap: wrap; }
.timeline { list-style: none; margin: 0; padding: 0 0 0 4px; }
.timeline li { display: flex; gap: 10px; padding-bottom: 12px; position: relative; font-size: .86rem; }
.timeline li::before { content: ""; position: absolute; left: 4px; top: 12px; bottom: 0; width: 1px; background: var(--line-2); }
.timeline li:last-child::before { display: none; }
.t-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--surface); border: 2px solid var(--accent); margin-top: 5px; flex: none; position: relative; }
.t-detail { font-size: .8rem; color: var(--ink-2); margin: 2px 0; word-break: break-word; }
.files { list-style: none; margin: 0; padding: 0; }
.files li { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-top: 1px solid var(--line); font-size: .86rem; }
.files li:first-child { border-top: none; }
.files li > div { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.files li > div a { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.files .thumb img { width: 44px; height: 44px; object-fit: cover; border-radius: 6px; display: block; }
.files li > i { font-size: 1.4rem; color: var(--muted); width: 44px; text-align: center; }
.tasklist { list-style: none; margin: 0; padding: 0; }
.tasklist li { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-top: 1px solid var(--line); flex-wrap: wrap; }
.tasklist li:first-child { border-top: none; }
.tasklist li span { flex: 1; }
.tasklist li.done span { color: var(--muted); text-decoration: line-through; }
.tasklist form { margin: 0; }
.tick { background: none; border: none; font-size: 1.2rem; cursor: pointer; color: var(--accent); padding: 0; }
.tasklist .bi-check-square-fill { color: var(--green); }
.sla-card { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.sla { margin-bottom: 8px; }
.sla-head { display: flex; justify-content: space-between; gap: 10px; font-size: .86rem; margin-bottom: 6px; }
.sla-ok { color: var(--green); } .sla-warn { color: var(--amber); } .sla-bad { color: var(--red); }
.bar { height: 8px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.bar.sm { height: 6px; min-width: 100px; }
.bar span { display: block; height: 100%; border-radius: 999px; }
.bar-ok { background: var(--green); } .bar-warn { background: #e8a317; } .bar-bad { background: var(--red); }
.qr-card { text-align: center; }
.qr { display: inline-block; padding: 10px; background: #fff; border-radius: 8px; border: 1px solid var(--line); }
.qr img, .qr canvas { display: block; width: 150px; height: 150px; }
.qr-tag { font-weight: 700; font-size: 1.1rem; margin: 8px 0 2px; letter-spacing: .04em; }
.rating-form { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.rating-form textarea { min-height: 60px; }
.stars { display: inline-flex; flex-direction: row-reverse; gap: 2px; }
.stars input { position: absolute; opacity: 0; width: 1px; }
.stars label { font-size: 1.9rem; color: var(--line-2); cursor: pointer; line-height: 1; }
.stars label:hover, .stars label:hover ~ label, .stars input:checked ~ label { color: var(--accent); }
.stars input:focus-visible + label { outline: 2px solid var(--focus); }
.stars-show { font-size: 1.4rem; color: var(--accent); margin: 0; }
.inspect-item { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin: 0 0 10px; display: grid; grid-template-columns: 1fr auto; gap: 8px 14px; align-items: center; }
.inspect-item legend { padding: 0 4px; font-weight: 500; font-size: .92rem; }
.inspect-item > input { grid-column: span 2; }
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: 8px; overflow: hidden; }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; }
.seg span { display: block; padding: 6px 14px; font-size: .86rem; cursor: pointer; border-left: 1px solid var(--line-2); }
.seg label:first-child span { border-left: none; }
.seg input:checked + span { background: var(--accent); color: var(--accent-ink); }
.seg label:nth-child(2) input:checked + span { background: var(--red); }
.seg input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: -2px; }
.seg-links { display: inline-flex; border: 1px solid var(--line-2); border-radius: 8px; overflow: hidden; }
.seg-links a { padding: 7px 14px; color: var(--ink); font-size: .88rem; }
.seg-links a.on { background: var(--accent); color: var(--accent-ink); }
.seg-links a:hover { text-decoration: none; }

/* ---------------- Charts ---------------- */
.chart-card .chart-box { position: relative; height: 260px; }
.chart-card .chart-box.tall { height: 340px; }
.chart-card.wide .chart-box { height: 320px; }
.chart-empty { padding: 60px 0; text-align: center; }
.table-view { margin-top: 8px; font-size: .84rem; }
.table-view summary { cursor: pointer; color: var(--muted); }
.table-view .table { margin-top: 8px; }

/* ---------------- Dispatch board ---------------- */
.board { display: grid; grid-template-columns: repeat(6, minmax(220px, 1fr)); gap: 12px; overflow-x: auto; padding-bottom: 10px; margin-bottom: 16px; }
.lane { background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; display: flex; flex-direction: column; min-height: 300px; }
.lane header { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.lane header h2 { font-size: .88rem; }
.lane header .count { font-size: .8rem; color: var(--muted); background: var(--surface); border-radius: 999px; padding: 0 8px; }
.lane-body { padding: 8px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.lane.drop { outline: 2px dashed var(--accent); outline-offset: -4px; }
.lane-empty { color: var(--muted); font-size: .82rem; text-align: center; margin: 20px 0; }
.job { background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--line-2); border-radius: 8px; padding: 9px 10px; font-size: .82rem; cursor: grab; box-shadow: var(--shadow); }
.job.dragging { opacity: .5; }
.job a { color: var(--ink); display: block; margin-bottom: 4px; font-size: .88rem; line-height: 1.3; }
.job.prio-emergency, .job.prio-critical { border-left-color: var(--red); }
.job.prio-high { border-left-color: var(--accent); }
.job-meta { display: flex; justify-content: space-between; gap: 6px; color: var(--muted); margin-top: 3px; flex-wrap: wrap; }

/* ---------------- Calendar ---------------- */
.cal-card { padding: 0; overflow-x: auto; }
.cal { min-width: 980px; }
.cal-head, .cal-row { display: grid; grid-template-columns: 210px 1fr; }
.cal-head { background: var(--surface-2); border-bottom: 1px solid var(--line); font-size: .78rem; color: var(--ink-2); font-weight: 600; }
.cal-head .cal-res { padding: 10px 14px; }
.cal-hours { display: grid; grid-template-columns: repeat(var(--hours), 1fr); }
.cal-hours span { padding: 10px 0 10px 6px; border-left: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.cal-row { border-bottom: 1px solid var(--line); min-height: 58px; }
.cal-row:last-child { border-bottom: none; }
.cal-head .cal-res, .cal-row .cal-res { position: sticky; left: 0; z-index: 3; background: inherit; }
.cal-head { background: var(--surface-2); } .cal-row { background: var(--surface); }
.cal-row .cal-res { padding: 8px 14px; display: flex; flex-direction: column; justify-content: center; border-right: 1px solid var(--line); }
.cal-row .cal-res a { color: var(--ink); font-size: .88rem; }
.cal-res small { font-size: .74rem; }
.cal-track { position: relative; background-image: linear-gradient(90deg, var(--line) 1px, transparent 1px); background-size: calc(100% / var(--hours)) 100%; }
.cal-track[data-new-url] { cursor: copy; }
.cal-track[data-new-url]:hover { background-color: color-mix(in srgb, var(--accent-soft) 40%, transparent); }
.now-line { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--red); z-index: 2; }
.bk { position: absolute; top: 6px; bottom: 6px; border-radius: 6px; padding: 4px 8px; overflow: hidden; font-size: .76rem; line-height: 1.25; background: var(--blue-bg); color: var(--blue); border: 1px solid color-mix(in srgb, var(--blue) 35%, transparent); display: flex; flex-direction: column; z-index: 1; cursor: pointer; }
.bk:hover { text-decoration: none; filter: brightness(.97); }
.bk strong, .bk small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bk-pending { background: var(--amber-bg); color: var(--amber); border-style: dashed; border-color: var(--amber); }
.bk-checkedin { background: var(--green-bg); color: var(--green); border-color: color-mix(in srgb, var(--green) 40%, transparent); }
.bk-completed { background: var(--grey-bg); color: var(--grey); }
.bk.mine { box-shadow: inset 3px 0 0 #e8a317; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; align-items: center; font-size: .82rem; color: var(--muted); }
.bk-key { display: inline-block; width: 14px; height: 10px; border-radius: 3px; vertical-align: middle; margin-right: -10px; }
.bk-key.confirmed { background: var(--blue-bg); border: 1px solid var(--blue); }
.bk-key.pending { background: var(--amber-bg); border: 1px dashed var(--amber); }
.bk-key.checkedin { background: var(--green-bg); border: 1px solid var(--green); }
.bk-key.mine-key { background: var(--surface); box-shadow: inset 3px 0 0 #e8a317; border: 1px solid var(--line-2); }
.table.week td, .table.week th { vertical-align: top; min-width: 120px; }
.table.week tbody th { background: var(--surface); display: table-cell; white-space: normal; }
.table.week tbody th small { display: block; font-weight: 400; }
.table.week th.today { background: var(--brand-soft); }
.bkchip { display: block; margin-bottom: 4px; font-size: .76rem; color: var(--blue); background: var(--blue-bg); border-color: transparent; }
.bkchip.mine { box-shadow: inset 3px 0 0 #e8a317; }
.add-slot { display: inline-flex; width: 24px; height: 24px; border-radius: 6px; border: 1px dashed var(--line-2); align-items: center; justify-content: center; color: var(--muted); font-size: .9rem; }
.add-slot:hover { border-color: var(--accent); color: var(--ink); text-decoration: none; }

/* ---------------- Portal ---------------- */
.portal-hero { display: grid; grid-template-columns: 1fr; gap: 18px; padding: 26px; background-color: var(--brand); background-image: linear-gradient(rgba(255,255,255,.06) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.06) 1px, transparent 1px), linear-gradient(135deg, #2d64b0, #234f8c); background-size: 24px 24px, 24px 24px, auto; color: #fff; border: none; }
:root[data-theme="dark"] .portal-hero { background-color: #1b2a40; background-image: linear-gradient(rgba(255,255,255,.04) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.04) 1px, transparent 1px); }
.portal-hero h1 { font-size: 1.7rem; margin-bottom: 14px; color: #fff; }
.kb-search { position: relative; max-width: 620px; }
.kb-search i { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.kb-search input { padding: 12px 14px 12px 40px; font-size: 1rem; min-height: 46px; border: none; }
.quick { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.quick-tile { min-width: 0; display: flex; flex-direction: column; gap: 2px; padding: 14px 16px; border-radius: 10px; background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.2); color: #fff; }
.quick-tile:hover { background: rgba(255,255,255,.18); text-decoration: none; }
.quick-tile i { font-size: 1.4rem; color: #fff; margin-bottom: 4px; }
.quick-tile small { color: rgba(255,255,255,.75); }
.kb-suggest { margin-top: 8px; background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent); border-radius: 8px; padding: 10px 12px; font-size: .88rem; }
.kb-suggest ul { margin: 4px 0 0; padding-left: 18px; }

/* reports */
.report-groups { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; align-items: start; }
.report-groups .card { margin: 0; }
.report-list { list-style: none; padding: 0; margin: 0; }
.report-list a { display: flex; flex-direction: column; padding: 9px 10px; margin: 0 -10px; border-radius: 6px; color: var(--ink); }
.report-list a:hover { background: var(--surface-2); text-decoration: none; }
.report-list strong { font-weight: 500; }
.report-list small { font-size: .8rem; }
.freshness { margin-left: auto; font-size: .8rem; }

/* ---------------- Auth ---------------- */
.auth-main { min-height: 100vh; }
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-art { background-color: var(--brand); background-image: linear-gradient(rgba(255,255,255,.06) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.06) 1px, transparent 1px), linear-gradient(150deg, #2d64b0 0%, #234f8c 60%, #404040 140%); background-size: 24px 24px, 24px 24px, auto; color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; gap: 24px; position: relative; overflow: hidden; }
.auth-brand img { height: 64px; width: auto; display: block; }
.auth-copy { max-width: 460px; position: relative; z-index: 1; }
.auth-copy h2 { font-size: 2.1rem; font-weight: 700; line-height: 1.15; letter-spacing: -.02em; margin-bottom: 14px; color: #fff; }
.auth-copy p { color: rgba(255,255,255,.82); font-size: 1.02rem; }
.auth-plan { color: rgba(255,255,255,.35); width: 100%; max-width: 460px; }
.auth-site { color: #fff; font-size: .9rem; display: inline-flex; gap: 8px; align-items: center; opacity: .85; }
.auth-site:hover { opacity: 1; color: #fff; }
.auth-logo { height: 44px; width: auto; margin-bottom: 18px; }
.powered { margin: 18px 0 0; text-align: center; font-size: .8rem; color: var(--muted); }
.auth-form { display: flex; align-items: center; justify-content: center; padding: 32px 20px; }
.auth-form .card { width: 100%; max-width: 400px; padding: 30px; }
.auth-form h1 { margin-bottom: 4px; }
.auth-form .field { margin: 14px 0; }
.demo-logins { margin-top: 18px; font-size: .85rem; }
.demo-logins summary { cursor: pointer; color: var(--link); }
.demo-logins ul { list-style: none; padding: 0; margin: 6px 0 0; }
.demo-logins li { padding: 3px 0; }

/* ---------------- Responsive ---------------- */
@media (max-width: 1280px) {
  .view-grid { grid-template-columns: minmax(0, 1fr) 300px; }
  .details { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1100px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .quick { grid-template-columns: 1fr 1fr; }
  .view-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 1024px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--shadow-lg); }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(10, 19, 28, .45); z-index: 35; }
  .content { margin-left: 0; }
  .topbar .menu-btn { display: inline-flex; }
  .auth { grid-template-columns: 1fr; }
  .auth-art { padding: 28px 24px; min-height: auto; }
  .auth-plan, .auth-copy p, .auth-site { display: none; }
  .auth-brand img { height: 44px; }
  .auth-copy h2 { font-size: 1.4rem; margin: 18px 0 0; }
}
@media (max-width: 760px) {
  body { font-size: 14px; }
  .main { padding: 16px 16px 32px; }
  .topbar { padding: 8px 12px; gap: 6px; }
  .hide-sm { display: none !important; }
  h1 { font-size: 1.35rem; }
  .grid-2, .grid-3, .sla-card { grid-template-columns: minmax(0, 1fr); }
  .stats { gap: 8px; }
  .stat { padding: 12px; }
  .stat-value { font-size: 1.5rem; }
  .mini-stats { grid-template-columns: 1fr 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .field.span-2 { grid-column: auto; }
  .details { grid-template-columns: 1fr 1fr; }
  .card { padding: 14px; }
  .form-card { padding: 16px; }
  .page-head { align-items: flex-start; }
  .page-head .actions { width: 100%; }
  .actions .btn { flex: 1 1 auto; }
  .actions form { flex: 1 1 auto; }
  .actions form .btn { width: 100%; }
  .actions select { width: 100%; }
  .reject-form { flex-wrap: wrap; width: 100%; }
  .reject-form input, .reject-form select { flex: 1 1 100%; }
  .filters select, .filters input[type=date] { flex: 1 1 45%; max-width: none; min-width: 0; }
  .filters .btn { flex: 1 1 auto; }
  .filters.collapsed > :not(.search-field):not(input[type=hidden]):not(.filter-toggle):not(.seg-links):not(.icon-btn) { display: none !important; }
  .filter-toggle { display: inline-flex !important; }
  .quick { grid-template-columns: 1fr 1fr; }
  .portal-hero { padding: 18px; }
  .portal-hero h1 { font-size: 1.3rem; }
  .inspect-item { grid-template-columns: 1fr; }
  .inspect-item > input { grid-column: auto; }
  /* stacked tables */
  .table.responsive thead { display: none; }
  .table.responsive, .table.responsive tbody, .table.responsive tr, .table.responsive td { display: block; width: 100%; }
  .table.responsive tr { padding: 10px 14px; border-bottom: 1px solid var(--line); position: relative; }
  .table.responsive tbody tr:last-child { border-bottom: none; }
  .table.responsive td { border: none; padding: 3px 0; display: flex; justify-content: space-between; gap: 12px; text-align: right; }
  .table.responsive td::before { content: attr(data-label); color: var(--muted); font-size: .8rem; text-align: left; flex: none; }
  .table.responsive td:first-of-type:not(.chk), .table.responsive td.chk + td { font-size: 1rem; font-weight: 500; text-align: left; justify-content: flex-start; padding-right: 40px; }
  .table.responsive td:first-of-type:not(.chk)::before, .table.responsive td.chk + td::before { display: none; }
  .table.responsive td.chk { position: absolute; right: 12px; top: 12px; width: auto; padding: 0; }
  .table.responsive td.chk::before { display: none; }
  .table.responsive td.act { position: absolute; right: 8px; top: 8px; width: auto; }
  .table.responsive td.act::before { display: none; }
  .table.responsive tbody tr:hover td { background: none; }
  .bulk-bar { bottom: 8px; }
  .foot { padding: 12px 16px; }
}
@media (max-width: 420px) {
  .stats { grid-template-columns: 1fr 1fr; }
  .stat-value { font-size: 1.3rem; }
  .details { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------------- Print (job sheets, reports) ---------------- */
@media print {
  body { background: #fff; color: #000; font-size: 11pt; }
  .sidebar, .topbar, .foot, .actions, .filters, .comment-form, .upload-form, .inline-form, .bulk-bar, .pager, .back, .alert-x, .rating-form, .table-view, form[data-confirm] { display: none !important; }
  .content { margin: 0; }
  .main { padding: 0; max-width: none; }
  .card { box-shadow: none; border: 1px solid #bbb; break-inside: avoid; }
  .view-grid { grid-template-columns: minmax(0, 1fr); }
  a { color: #000; }
  .chart-box { height: 220px !important; }
}
.view-main, .view-side { min-width: 0; }
