/* =====================================================================
   AutoPulse Garage Suite — design system
   Concept: "instrument cluster" — a night-navy cockpit topbar, warning-lamp
   status colours, signage-style Barlow type, one colour per module.
   ===================================================================== */
:root {
  --ink: #13203B;          /* cockpit navy */
  --ink-2: #1C2D52;
  --ink-3: #2A3F6C;
  --canvas: #F2F5FA;
  --surface: #FFFFFF;
  --surface-2: #F7F9FC;
  --line: #E2E8F2;
  --line-2: #CBD5E4;
  --text: #17223A;
  --muted: #5E6B85;
  --faint: #8A96AD;
  --primary: #2F5BEA;      /* ignition blue  */
  --primary-soft: #E8EEFE;
  --amber: #F5A524;        /* warning lamp   */
  --amber-soft: #FEF4E2;
  --teal: #12B5A5;         /* coolant        */
  --teal-soft: #E1F7F4;
  --red: #E5484D;          /* brake lamp     */
  --red-soft: #FDECEC;
  --violet: #7C5CFF;       /* ledger         */
  --violet-soft: #EFEBFF;
  --green: #22A861;        /* go             */
  --green-soft: #E4F6EC;
  --sky: #0EA5E9;
  --sky-soft: #E2F4FD;
  --magenta: #D946EF;
  --magenta-soft: #FBEAFE;
  --slate: #64748B;
  --slate-soft: #EEF1F6;
  --module: var(--primary);
  --radius-lg: 18px;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-1: 0 1px 2px rgba(19, 32, 59, .06), 0 1px 1px rgba(19, 32, 59, .04);
  --shadow-2: 0 10px 30px -12px rgba(19, 32, 59, .25);
  --topbar-h: 64px;
  --font: 'Barlow', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-num: 'Barlow Semi Condensed', 'Barlow', system-ui, sans-serif;
  --bs-body-font-family: var(--font);
  --bs-body-color: var(--text);
  --bs-body-bg: var(--canvas);
  --bs-primary: #2F5BEA;
  --bs-primary-rgb: 47, 91, 234;
  --bs-border-color: var(--line);
  --bs-link-color: #2F5BEA;
  --bs-link-color-rgb: 47, 91, 234;
}
:root:not([data-theme="light"]) { color-scheme: light; }
[data-theme="dark"] {
  color-scheme: dark;
  --canvas: #0D1424;
  --surface: #141D33;
  --surface-2: #19243F;
  --line: #24314F;
  --line-2: #334466;
  --text: #E6ECF7;
  --muted: #9AA8C4;
  --faint: #6F7E9C;
  --primary-soft: #1D2B59;
  --amber-soft: #3A2C10;
  --teal-soft: #0E3330;
  --red-soft: #3D1A1E;
  --violet-soft: #2A2152;
  --green-soft: #12301F;
  --sky-soft: #0D2C3E;
  --magenta-soft: #3A1640;
  --slate-soft: #1E2944;
  --bs-body-color: var(--text);
  --bs-body-bg: var(--canvas);
  --bs-border-color: var(--line);
  --bs-secondary-color: var(--muted);
  --bs-tertiary-bg: var(--surface-2);
  --bs-emphasis-color: #fff;
}

html { font-size: 17px; }               /* slightly larger base type everywhere */
body { font-family: var(--font); background: var(--canvas); color: var(--text); -webkit-font-smoothing: antialiased; min-height: 100vh; }
.num, .kpi-value, .money { font-family: var(--font-num); font-variant-numeric: tabular-nums; }
a { text-decoration: none; }
h1, h2, h3, h4, h5 { font-weight: 700; letter-spacing: -0.01em; color: var(--text); }
.text-muted, .text-secondary { color: var(--muted) !important; }
.small, small { font-size: .86rem; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--primary) 45%, transparent); outline-offset: 2px; }
::selection { background: color-mix(in srgb, var(--primary) 25%, transparent); }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* module colours (set on <body data-module="...">) */
body[data-module="workshop"]  { --module: var(--primary); --module-soft: var(--primary-soft); }
body[data-module="purchase"]  { --module: #E8890C; --module-soft: var(--amber-soft); }
body[data-module="inventory"] { --module: var(--teal); --module-soft: var(--teal-soft); }
body[data-module="sales"]     { --module: var(--green); --module-soft: var(--green-soft); }
body[data-module="accounts"]  { --module: var(--violet); --module-soft: var(--violet-soft); }
body[data-module="reports"]   { --module: var(--magenta); --module-soft: var(--magenta-soft); }
body[data-module="setup"]     { --module: var(--slate); --module-soft: var(--slate-soft); }
body[data-module="dashboard"] { --module: var(--primary); --module-soft: var(--primary-soft); }

/* ------------------------------------------------------------ topbar */
.ap-topbar {
  position: sticky; top: 0; z-index: 1030; height: var(--topbar-h);
  background: linear-gradient(180deg, var(--ink) 0%, #101B33 100%);
  color: #DCE4F5; display: flex; align-items: center; gap: .75rem; padding: 0 1rem;
  box-shadow: 0 1px 0 rgba(255,255,255,.04), 0 6px 20px -10px rgba(0,0,0,.5);
}
.ap-topbar::after { content: ""; position: absolute; left: 0; right: 0; bottom: -3px; height: 3px; background: var(--module); transition: background .3s; }
.ap-brand { display: flex; align-items: center; gap: .55rem; color: #fff; font-weight: 800; font-size: 1.2rem; letter-spacing: -.02em; white-space: nowrap; }
.ap-brand:hover { color: #fff; }
.ap-brand-mark { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: conic-gradient(from 210deg, #2F5BEA, #12B5A5, #F5A524, #E5484D, #2F5BEA); }
.ap-brand-mark i { color: #fff; font-size: 1.15rem; background: var(--ink); width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; }
.ap-brand small { display: block; font-weight: 500; font-size: .68rem; color: #8FA0C4; letter-spacing: .02em; line-height: 1; margin-top: 2px; }
.ap-nav { display: flex; align-items: stretch; height: 100%; margin-left: .5rem; }
.ap-nav > .nav-item { position: relative; display: flex; }
.ap-nav .nav-top {
  display: flex; align-items: center; gap: .4rem; padding: 0 .8rem; color: #C3CEE6; font-weight: 600; font-size: .95rem;
  border: 0; background: none; height: 100%; position: relative; white-space: nowrap;
}
.ap-nav .nav-top:hover, .ap-nav .nav-top.show { color: #fff; background: rgba(255,255,255,.05); }
.ap-nav .nav-top.active { color: #fff; }
.ap-nav .nav-top.active::before { content: ""; position: absolute; left: .8rem; right: .8rem; bottom: 10px; height: 2px; border-radius: 2px; background: var(--dot, #fff); }
.ap-nav .nav-top .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--dot); box-shadow: 0 0 0 3px color-mix(in srgb, var(--dot) 25%, transparent); }
.ap-mega { border: 0; border-radius: 16px; padding: .75rem; min-width: 520px; box-shadow: 0 24px 60px -20px rgba(9, 18, 40, .45); margin-top: 6px !important; background: var(--surface); }
.ap-mega.narrow { min-width: 300px; }
.ap-mega .mega-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .25rem; }
.ap-mega.narrow .mega-grid { grid-template-columns: 1fr; }
.ap-mega .mega-title { font-size: .78rem; color: var(--faint); font-weight: 600; padding: .25rem .6rem .4rem; grid-column: 1 / -1; }
.mega-link { display: flex; gap: .7rem; align-items: flex-start; padding: .6rem .65rem; border-radius: 12px; color: var(--text); }
.mega-link:hover { background: var(--surface-2); color: var(--text); }
.mega-link .mi { width: 36px; height: 36px; flex: none; border-radius: 10px; display: grid; place-items: center; background: color-mix(in srgb, var(--c) 14%, transparent); color: var(--c); font-size: 1.05rem; }
.mega-link b { display: block; font-weight: 600; font-size: .95rem; }
.mega-link span { display: block; font-size: .8rem; color: var(--muted); line-height: 1.25; }
.ap-tools { margin-left: auto; display: flex; align-items: center; gap: .4rem; }
.ap-iconbtn { width: 42px; height: 42px; border-radius: 12px; border: 1px solid rgba(255,255,255,.08); background: rgba(255,255,255,.04); color: #DCE4F5; display: grid; place-items: center; position: relative; font-size: 1.1rem; }
.ap-iconbtn:hover { background: rgba(255,255,255,.1); color: #fff; }
.ap-iconbtn .badge-dot { position: absolute; top: 6px; right: 6px; min-width: 18px; height: 18px; border-radius: 9px; background: var(--red); color: #fff; font-size: .66rem; font-weight: 700; display: grid; place-items: center; padding: 0 4px; border: 2px solid var(--ink); }
.ap-search { display: flex; align-items: center; gap: .5rem; height: 42px; padding: 0 .8rem; border-radius: 12px; min-width: 150px; white-space: nowrap; border: 1px solid rgba(255,255,255,.1); background: rgba(255,255,255,.05); color: #9DAACA; font-size: .92rem; }
.ap-search:hover { color: #fff; background: rgba(255,255,255,.09); }
.ap-search kbd { margin-left: auto; background: rgba(255,255,255,.1); color: #C3CEE6; font-size: .72rem; padding: .1rem .4rem; border-radius: 6px; }
.ap-ai-btn { height: 42px; padding: 0 .9rem; border-radius: 12px; border: 0; color: #fff; font-weight: 600; display: flex; align-items: center; gap: .45rem;
  background: linear-gradient(135deg, #7C5CFF, #2F5BEA 60%, #12B5A5); box-shadow: 0 6px 18px -6px rgba(124, 92, 255, .7); }
.ap-ai-btn:hover { filter: brightness(1.08); color: #fff; }
.ap-user { display: flex; align-items: center; gap: .55rem; background: none; border: 0; color: #DCE4F5; padding: .25rem .4rem; border-radius: 12px; }
.ap-user:hover { background: rgba(255,255,255,.06); }
.ap-avatar { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; font-weight: 700; color: #fff; background: linear-gradient(135deg, #F5A524, #E5484D); font-size: .9rem; flex: none; }
.ap-user .who { text-align: left; line-height: 1.1; }
.ap-user .who b { display: block; font-size: .88rem; color: #fff; }
.ap-user .who span { font-size: .72rem; color: #8FA0C4; }
.ap-burger { display: none; }

/* ------------------------------------------------------------ page */
.ap-main { padding: 1.25rem 1.5rem 3rem; max-width: 1680px; margin: 0 auto; }
.page-head { display: flex; align-items: center; gap: 1rem; margin: .25rem 0 1.25rem; flex-wrap: wrap; }
.page-head .ph-icon { width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; font-size: 1.45rem; color: var(--module); background: var(--module-soft); flex: none; }
.page-head h1 { font-size: 1.6rem; margin: 0; line-height: 1.15; }
.page-head .crumbs { font-size: .84rem; color: var(--muted); margin-bottom: .1rem; }
.page-head .crumbs a { color: var(--muted); }
.page-head .crumbs a:hover { color: var(--primary); }
.page-head .ph-title { flex: 1 1 260px; min-width: 0; }
.page-head .ph-actions { margin-left: auto; display: flex; gap: .5rem; flex-wrap: wrap; }

.card-x { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-1); }
.card-x > .cx-head { display: flex; align-items: center; gap: .6rem; padding: 1rem 1.15rem .4rem; }
.card-x > .cx-head h3 { font-size: 1.05rem; margin: 0; }
.card-x > .cx-head .cx-sub { font-size: .82rem; color: var(--muted); }
.card-x > .cx-head .cx-actions { margin-left: auto; display: flex; gap: .35rem; align-items: center; }
.card-x > .cx-body { padding: .6rem 1.15rem 1.1rem; }
.cx-icon { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: color-mix(in srgb, var(--c, var(--primary)) 14%, transparent); color: var(--c, var(--primary)); flex: none; }

/* buttons */
.btn { border-radius: 11px; font-weight: 600; padding: .5rem 1rem; display: inline-flex; align-items: center; gap: .4rem; justify-content: center; }
.btn-sm { border-radius: 9px; padding: .3rem .65rem; font-size: .85rem; }
.btn-lg { border-radius: 14px; }
.btn-primary { --bs-btn-bg: var(--primary); --bs-btn-border-color: var(--primary); --bs-btn-hover-bg: #2149CF; --bs-btn-hover-border-color: #2149CF; --bs-btn-active-bg: #1C3FB6; box-shadow: 0 6px 16px -8px rgba(47, 91, 234, .8); }
.btn-module { background: var(--module); border-color: var(--module); color: #fff; box-shadow: 0 6px 16px -8px color-mix(in srgb, var(--module) 80%, transparent); }
.btn-module:hover { filter: brightness(1.07); color: #fff; background: var(--module); }
.btn-soft { background: var(--surface); border: 1px solid var(--line); color: var(--text); }
.btn-soft:hover { background: var(--surface-2); border-color: var(--line-2); color: var(--text); }
.btn-ghost { background: transparent; border: 0; color: var(--muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-success { --bs-btn-bg: var(--green); --bs-btn-border-color: var(--green); --bs-btn-hover-bg: #1B9152; --bs-btn-hover-border-color: #1B9152; }
.btn-danger { --bs-btn-bg: var(--red); --bs-btn-border-color: var(--red); }
.btn-wa { background: #25D366; border-color: #25D366; color: #fff; }
.btn-wa:hover { background: #1EBE5B; color: #fff; }
.btn-icon { width: 36px; height: 36px; padding: 0; border-radius: 10px; }

/* status chips — the warning-lamp palette */
.chip { display: inline-flex; align-items: center; gap: .35rem; padding: .18rem .6rem; border-radius: 999px; font-size: .8rem; font-weight: 600; white-space: nowrap; background: var(--cs, var(--slate-soft)); color: var(--cc, var(--slate)); }
.chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.chip.plain::before { display: none; }
.st-open, .st-draft, .st-pending, .st-unknown, .st-none { --cs: var(--slate-soft); --cc: #55657F; }
.st-estimated, .st-sent, .st-partial, .st-suggested, .st-medium, .st-info { --cs: var(--sky-soft); --cc: #0284C7; }
.st-approved, .st-contract { --cs: var(--violet-soft); --cc: var(--violet); }
.st-in_progress, .st-job, .st-active { --cs: var(--primary-soft); --cc: var(--primary); }
.st-qc, .st-attention, .st-due_soon, .st-expiring, .st-low, .st-unpaid, .st-high, .st-warning { --cs: var(--amber-soft); --cc: #C27803; }
.st-completed, .st-ok, .st-pass, .st-issued, .st-counter, .st-received { --cs: var(--teal-soft); --cc: #0E8F83; }
.st-invoiced, .st-posted, .st-paid, .st-delivered, .st-matched, .st-positive { --cs: var(--green-soft); --cc: #188A4E; }
.st-cancelled, .st-rejected, .st-overdue, .st-fail, .st-urgent, .st-out, .st-expired, .st-critical { --cs: var(--red-soft); --cc: var(--red); }
.st-ignored, .st-inactive { --cs: var(--slate-soft); --cc: var(--faint); }

/* ------------------------------------------------------------ KPI tiles */
.kpi { position: relative; overflow: hidden; padding: 1rem 1.1rem; min-height: 118px; display: flex; flex-direction: column; gap: .2rem; cursor: default; }
.kpi[data-href] { cursor: pointer; }
.kpi[data-href]:hover { border-color: var(--line-2); box-shadow: var(--shadow-2); }
.kpi .kpi-label { font-size: .86rem; color: var(--muted); font-weight: 600; display: flex; align-items: center; gap: .45rem; }
.kpi .kpi-label i { color: var(--c); }
.kpi .kpi-value { font-size: 1.9rem; font-weight: 700; line-height: 1.1; letter-spacing: -.01em; }
.kpi .kpi-value small { font-size: .9rem; color: var(--muted); font-weight: 600; margin-right: .2rem; }
.kpi .kpi-foot { font-size: .8rem; color: var(--muted); margin-top: auto; }
.kpi::after { content: ""; position: absolute; right: -24px; top: -24px; width: 96px; height: 96px; border-radius: 50%; background: color-mix(in srgb, var(--c) 10%, transparent); }
.trend-up { color: var(--green); font-weight: 600; }
.trend-down { color: var(--red); font-weight: 600; }

/* ------------------------------------------------------------ instrument cluster (dashboard hero) */
.cluster { background: radial-gradient(120% 140% at 50% 0%, #22366A 0%, var(--ink) 55%, #0B1428 100%); border-radius: 22px; color: #DCE4F5; padding: 1.1rem 1.25rem 1.2rem; position: relative; overflow: hidden; border: 1px solid #22355F; }
.cluster::before { content: ""; position: absolute; inset: 0; background: repeating-linear-gradient(90deg, rgba(255,255,255,.02) 0 1px, transparent 1px 64px); pointer-events: none; }
.cluster h2 { color: #fff; font-size: 1.15rem; margin: 0; }
.cluster .cl-sub { color: #8FA0C4; font-size: .85rem; }
.cluster .gauge { height: 210px; }
.cluster .gauge-cap { text-align: center; margin-top: -14px; }
.cluster .gauge-cap b { display: block; color: #fff; font-family: var(--font-num); font-size: 1.15rem; }
.cluster .gauge-cap span { font-size: .8rem; color: #8FA0C4; }
.lamps { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .6rem; }
.lamp { display: flex; align-items: center; gap: .45rem; background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.08); padding: .35rem .65rem; border-radius: 10px; font-size: .84rem; color: #C3CEE6; cursor: pointer; }
.lamp:hover { background: rgba(255,255,255,.1); color: #fff; }
.lamp .l { width: 10px; height: 10px; border-radius: 50%; background: var(--lc); box-shadow: 0 0 10px var(--lc); }
.lamp.off .l { box-shadow: none; opacity: .35; }
.lamp b { color: #fff; font-family: var(--font-num); }

/* workshop floor board */
.bays { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .7rem; }
.bay { border: 1px dashed var(--line-2); border-radius: 14px; padding: .7rem .8rem; min-height: 122px; background: var(--surface-2); position: relative; display: flex; flex-direction: column; gap: .2rem; }
.bay.busy { border-style: solid; background: var(--surface); cursor: pointer; border-color: var(--line); box-shadow: var(--shadow-1); }
.bay.busy:hover { border-color: var(--bc, var(--primary)); }
.bay .bay-no { font-size: .74rem; font-weight: 700; color: var(--faint); }
.bay .plate { font-family: var(--font-num); font-weight: 700; font-size: 1.1rem; letter-spacing: .02em; background: #FFF; color: #111; border: 2px solid #1d1d1d; border-radius: 6px; padding: 0 .4rem; display: inline-block; align-self: flex-start; }
[data-theme="dark"] .bay .plate { background: #F4F6FA; }
.bay .veh { font-size: .84rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bay .bar { height: 5px; border-radius: 4px; background: var(--line); overflow: hidden; margin-top: auto; }
.bay .bar > i { display: block; height: 100%; background: var(--bc, var(--primary)); border-radius: 4px; }
.bay .lampdot { position: absolute; top: .7rem; right: .7rem; width: 11px; height: 11px; border-radius: 50%; background: var(--bc); box-shadow: 0 0 0 4px color-mix(in srgb, var(--bc) 22%, transparent); }
.bay.empty { align-items: center; justify-content: center; color: var(--faint); font-size: .85rem; }
.plate-sm { font-family: var(--font-num); font-weight: 700; letter-spacing: .02em; border: 1.5px solid #1d1d1d; border-radius: 5px; padding: 0 .35rem; background: #fff; color: #111; font-size: .9rem; white-space: nowrap; }

/* insights */
.insight { display: flex; gap: .8rem; padding: .75rem .8rem; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--line); }
.insight .ii { width: 38px; height: 38px; flex: none; border-radius: 11px; display: grid; place-items: center; font-size: 1.1rem; color: var(--cc); background: var(--cs); }
.insight b { display: block; font-size: .95rem; }
.insight p { margin: .1rem 0 0; font-size: .85rem; color: var(--muted); }
.insight a.ins-act { font-size: .84rem; font-weight: 600; }
.ai-tag { display: inline-flex; align-items: center; gap: .3rem; font-size: .74rem; font-weight: 700; color: var(--violet); background: var(--violet-soft); padding: .12rem .5rem; border-radius: 999px; }

/* list rows (dashboard side lists) */
.mini-list { list-style: none; margin: 0; padding: 0; }
.mini-list li { display: flex; align-items: center; gap: .7rem; padding: .55rem 0; border-bottom: 1px solid var(--line); }
.mini-list li:last-child { border-bottom: 0; }
.mini-list .ml-main { min-width: 0; flex: 1; }
.mini-list .ml-main b { display: block; font-size: .93rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-list .ml-main span { display: block; font-size: .8rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.feed-dot { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; flex: none; background: var(--cs); color: var(--cc); }
.leader-bar { height: 7px; background: var(--line); border-radius: 4px; overflow: hidden; }
.leader-bar i { display: block; height: 100%; border-radius: 4px; background: linear-gradient(90deg, var(--primary), var(--teal)); }

/* ------------------------------------------------------------ data tables */
.dt-toolbar { display: flex; gap: .55rem; align-items: center; flex-wrap: wrap; padding: .9rem 1rem; border-bottom: 1px solid var(--line); }
.dt-search { position: relative; flex: 1 1 260px; max-width: 420px; }
.dt-search i { position: absolute; left: .8rem; top: 50%; transform: translateY(-50%); color: var(--faint); }
.dt-search input { padding-left: 2.3rem; }
.dt-filters { display: flex; gap: .45rem; flex-wrap: wrap; align-items: center; }
.dt-filters .form-select, .dt-filters .form-control { width: auto; min-width: 140px; }
.dt-actions { margin-left: auto; display: flex; gap: .4rem; }
.dt-wrap { overflow-x: auto; }
table.dt { width: 100%; margin: 0; border-collapse: separate; border-spacing: 0; }
table.dt thead th { position: sticky; top: 0; background: var(--surface-2); font-size: .8rem; font-weight: 700; color: var(--muted); padding: .65rem .8rem; border-bottom: 1px solid var(--line); white-space: nowrap; user-select: none; }
table.dt thead th.sortable { cursor: pointer; }
table.dt thead th.sortable:hover { color: var(--text); }
table.dt thead th .si { opacity: .35; margin-left: .2rem; }
table.dt thead th.sorted .si { opacity: 1; color: var(--primary); }
table.dt tbody td { padding: .7rem .8rem; border-bottom: 1px solid var(--line); vertical-align: middle; font-size: .95rem; }
table.dt tbody tr { transition: background .12s; }
table.dt tbody tr.clickable { cursor: pointer; }
table.dt tbody tr:hover td { background: color-mix(in srgb, var(--module) 4%, var(--surface)); }
table.dt tfoot td { padding: .65rem .8rem; font-weight: 700; background: var(--surface-2); font-family: var(--font-num); }
.td-main { font-weight: 600; }
.td-sub { display: block; font-size: .8rem; color: var(--muted); }
.ta-r { text-align: right; }
.ta-c { text-align: center; }
.dt-foot { display: flex; align-items: center; gap: .8rem; padding: .7rem 1rem; flex-wrap: wrap; font-size: .88rem; color: var(--muted); }
.dt-foot .pagination { margin: 0 0 0 auto; }
.pagination .page-link { border-radius: 9px !important; margin: 0 2px; border: 1px solid var(--line); color: var(--text); background: var(--surface); }
.pagination .active .page-link { background: var(--module); border-color: var(--module); color: #fff; }
.dt-empty { padding: 3rem 1rem; text-align: center; color: var(--muted); }
.dt-empty i { font-size: 2.4rem; display: block; color: var(--faint); margin-bottom: .5rem; }
.row-actions { display: flex; gap: .25rem; justify-content: flex-end; }
.sum-strip { display: flex; gap: 1.3rem; flex-wrap: wrap; padding: .55rem 1rem; background: var(--surface-2); border-bottom: 1px solid var(--line); font-size: .86rem; color: var(--muted); }
.sum-strip b { color: var(--text); font-family: var(--font-num); font-size: 1rem; margin-left: .25rem; }

/* tabs inside pages */
.tabs-x { display: flex; gap: .3rem; overflow-x: auto; border-bottom: 1px solid var(--line); margin-bottom: 1rem; scrollbar-width: none; }
.tabs-x::-webkit-scrollbar { display: none; }
.tabs-x button, .tabs-x a { border: 0; background: none; padding: .65rem .9rem; font-weight: 600; color: var(--muted); border-bottom: 3px solid transparent; white-space: nowrap; display: flex; align-items: center; gap: .4rem; }
.tabs-x button.active, .tabs-x a.active { color: var(--text); border-bottom-color: var(--module); }
.tabs-x .cnt { background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; font-size: .74rem; padding: 0 .45rem; }

/* forms */
.form-control, .form-select { border-radius: 10px; border-color: var(--line-2); padding: .5rem .75rem; font-size: .97rem; background-color: var(--surface); color: var(--text); }
.form-control:focus, .form-select:focus { border-color: var(--primary); box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 16%, transparent); background-color: var(--surface); color: var(--text); }
.form-control-sm, .form-select-sm { border-radius: 8px; font-size: .88rem; }
.form-label { font-weight: 600; font-size: .86rem; color: var(--muted); margin-bottom: .3rem; }
.form-label .req { color: var(--red); }
.form-text { font-size: .8rem; }
.input-group-text { border-radius: 10px; background: var(--surface-2); border-color: var(--line-2); color: var(--muted); }
.form-check-input:checked { background-color: var(--primary); border-color: var(--primary); }
.form-switch .form-check-input { width: 2.6em; height: 1.4em; }
.is-invalid { border-color: var(--red) !important; }
.fieldset-title { font-size: .82rem; font-weight: 700; color: var(--faint); margin: .6rem 0 .1rem; display: flex; align-items: center; gap: .5rem; }
.fieldset-title::after { content: ""; height: 1px; background: var(--line); flex: 1; }

/* lookup combobox */
.lk { position: relative; }
.lk .lk-menu { position: absolute; left: 0; right: 0; top: calc(100% + 4px); background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-2); z-index: 1065; max-height: 320px; overflow-y: auto; display: none; min-width: 260px; }
.lk.open .lk-menu { display: block; }
.lk .lk-item { padding: .5rem .75rem; cursor: pointer; border-bottom: 1px solid var(--line); }
.lk .lk-item:last-child { border-bottom: 0; }
.lk .lk-item b { display: block; font-weight: 600; font-size: .93rem; }
.lk .lk-item span { display: block; font-size: .78rem; color: var(--muted); }
.lk .lk-item.hl, .lk .lk-item:hover { background: var(--primary-soft); }
.lk .lk-item.lk-new { color: var(--primary); font-weight: 600; }
.lk .lk-clear { position: absolute; right: .5rem; top: 50%; transform: translateY(-50%); border: 0; background: none; color: var(--faint); display: none; }
.lk.has-value .lk-clear { display: block; }

/* line items editor */
.li-table { width: 100%; border-collapse: separate; border-spacing: 0; }
.li-table th { font-size: .78rem; font-weight: 700; color: var(--muted); padding: .45rem .4rem; border-bottom: 1px solid var(--line); background: var(--surface-2); white-space: nowrap; }
.li-table td { padding: .35rem .3rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.li-table td .form-control, .li-table td .form-select { padding: .38rem .5rem; font-size: .92rem; }
.li-table .li-total { font-family: var(--font-num); font-weight: 700; text-align: right; padding-top: .6rem; white-space: nowrap; }
.li-table .li-del { color: var(--faint); border: 0; background: none; padding: .45rem; }
.li-table .li-del:hover { color: var(--red); }
.li-wrap { border: 1px solid var(--line); border-radius: 14px; overflow-x: auto; }
.li-foot { display: flex; gap: 1rem; justify-content: space-between; align-items: flex-start; padding: .7rem .8rem; flex-wrap: wrap; }
.totals-box { min-width: 260px; margin-left: auto; }
.totals-box .tr { display: flex; justify-content: space-between; gap: 1.5rem; padding: .2rem 0; font-size: .93rem; color: var(--muted); }
.totals-box .tr b { font-family: var(--font-num); color: var(--text); font-size: 1rem; }
.totals-box .tr.grand { border-top: 2px solid var(--line); margin-top: .3rem; padding-top: .45rem; color: var(--text); font-weight: 700; }
.totals-box .tr.grand b { font-size: 1.35rem; color: var(--module); }

/* modals */
.modal-content { border: 0; border-radius: 20px; background: var(--surface); color: var(--text); box-shadow: 0 30px 80px -20px rgba(9, 18, 40, .5); }
.modal-header { border-bottom: 1px solid var(--line); padding: 1rem 1.3rem; gap: .7rem; }
.modal-header .mh-icon { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--module-soft); color: var(--module); font-size: 1.15rem; flex: none; }
.modal-title { font-weight: 700; font-size: 1.15rem; }
.modal-title small { display: block; font-size: .8rem; color: var(--muted); font-weight: 500; }
.modal-body { padding: 1.1rem 1.3rem; }
.modal-footer { border-top: 1px solid var(--line); padding: .8rem 1.3rem; gap: .5rem; }
.modal-backdrop.show { opacity: .45; }
.btn-close { filter: none; }
[data-theme="dark"] .btn-close { filter: invert(1) grayscale(100%) brightness(200%); }

/* document view */
.doc-meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .75rem 1.25rem; margin-bottom: 1rem; }
.doc-meta .dm-label { font-size: .78rem; color: var(--faint); font-weight: 600; }
.doc-meta .dm-value { font-weight: 600; }
table.doc-lines { width: 100%; border-collapse: collapse; font-size: .93rem; }
table.doc-lines th { font-size: .78rem; color: var(--muted); font-weight: 700; padding: .45rem .5rem; border-bottom: 2px solid var(--line); text-align: left; }
table.doc-lines td { padding: .5rem; border-bottom: 1px solid var(--line); }
.journal-box { background: var(--surface-2); border: 1px dashed var(--line-2); border-radius: 12px; padding: .6rem .8rem; }

/* kanban */
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(270px, 1fr); gap: .8rem; overflow-x: auto; padding-bottom: .5rem; }
.kb-col { background: var(--surface-2); border: 1px solid var(--line); border-radius: 16px; display: flex; flex-direction: column; min-height: 420px; }
.kb-col.drop { outline: 3px dashed color-mix(in srgb, var(--kc) 55%, transparent); }
.kb-head { padding: .7rem .8rem; display: flex; align-items: center; gap: .5rem; font-weight: 700; border-bottom: 1px solid var(--line); }
.kb-head .l { width: 10px; height: 10px; border-radius: 50%; background: var(--kc); box-shadow: 0 0 8px var(--kc); }
.kb-head .n { margin-left: auto; font-family: var(--font-num); background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 0 .55rem; font-size: .82rem; }
.kb-body { padding: .6rem; display: flex; flex-direction: column; gap: .55rem; flex: 1; }
.kb-card { background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--kc); border-radius: 12px; padding: .6rem .7rem; cursor: grab; box-shadow: var(--shadow-1); }
.kb-card:hover { box-shadow: var(--shadow-2); }
.kb-card.dragging { opacity: .5; }
.kb-card .t1 { display: flex; align-items: center; gap: .5rem; }
.kb-card .t1 b { font-size: .86rem; color: var(--muted); }
.kb-card .t2 { font-size: .86rem; color: var(--muted); margin-top: .25rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kb-card .t3 { display: flex; gap: .4rem; align-items: center; margin-top: .4rem; font-size: .78rem; color: var(--muted); flex-wrap: wrap; }
.prio-urgent { color: var(--red); font-weight: 700; }
.prio-high { color: #C27803; font-weight: 700; }

/* timeline (back-track) */
.timeline { list-style: none; margin: 0; padding: 0 0 0 .4rem; position: relative; }
.timeline::before { content: ""; position: absolute; left: 1.15rem; top: .3rem; bottom: .3rem; width: 2px; background: var(--line); }
.timeline li { position: relative; display: flex; gap: .8rem; padding: .45rem 0; }
.timeline .tl-dot { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--cs); color: var(--cc); flex: none; z-index: 1; border: 3px solid var(--surface); font-size: .9rem; }
.timeline .tl-body b { display: block; font-size: .93rem; }
.timeline .tl-body span { font-size: .8rem; color: var(--muted); }
.timeline .tl-body a { font-size: .82rem; font-weight: 600; }

/* job workspace */
.job-hero { display: grid; grid-template-columns: 1.3fr 1fr 1fr; gap: 1rem; }
.stepper { display: flex; gap: .25rem; overflow-x: auto; padding: .2rem 0; }
.stepper .step { flex: 1; min-width: 92px; text-align: center; font-size: .78rem; font-weight: 600; color: var(--faint); position: relative; padding-top: 1.6rem; }
.stepper .step::before { content: ""; position: absolute; top: .55rem; left: 0; right: 0; height: 4px; background: var(--line); border-radius: 4px; }
.stepper .step::after { content: ""; position: absolute; top: .2rem; left: 50%; transform: translateX(-50%); width: 14px; height: 14px; border-radius: 50%; background: var(--surface); border: 3px solid var(--line-2); }
.stepper .step.done { color: var(--text); }
.stepper .step.done::before { background: var(--green); }
.stepper .step.done::after { border-color: var(--green); background: var(--green); }
.stepper .step.current { color: var(--primary); }
.stepper .step.current::before { background: linear-gradient(90deg, var(--green), var(--primary)); }
.stepper .step.current::after { border-color: var(--primary); box-shadow: 0 0 0 5px var(--primary-soft); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: .25rem .9rem; font-size: .92rem; }
.kv dt { color: var(--muted); font-weight: 500; }
.kv dd { margin: 0; font-weight: 600; }

/* inspection grid */
.insp-cat { font-weight: 700; font-size: .9rem; margin: .7rem 0 .3rem; color: var(--muted); }
.insp-row { display: flex; align-items: center; gap: .6rem; padding: .4rem .5rem; border-radius: 10px; }
.insp-row:nth-child(odd) { background: var(--surface-2); }
.insp-row .nm { flex: 1; font-size: .93rem; }
.insp-opts { display: flex; gap: .25rem; }
.insp-opts label { cursor: pointer; }
.insp-opts input { display: none; }
.insp-opts span { display: inline-block; padding: .2rem .55rem; border-radius: 8px; font-size: .78rem; font-weight: 700; border: 1px solid var(--line-2); color: var(--muted); }
.insp-opts input:checked + span.o-ok { background: var(--green); border-color: var(--green); color: #fff; }
.insp-opts input:checked + span.o-attention { background: var(--amber); border-color: var(--amber); color: #3b2500; }
.insp-opts input:checked + span.o-urgent { background: var(--red); border-color: var(--red); color: #fff; }
.insp-opts input:checked + span.o-na { background: var(--slate); border-color: var(--slate); color: #fff; }
.health-ring { --p: 0; --hc: var(--green); width: 92px; height: 92px; border-radius: 50%; background: conic-gradient(var(--hc) calc(var(--p) * 1%), var(--line) 0); display: grid; place-items: center; }
.health-ring > div { width: 72px; height: 72px; border-radius: 50%; background: var(--surface); display: grid; place-items: center; font-family: var(--font-num); font-weight: 700; font-size: 1.35rem; }

/* AI panels */
.ai-panel { border: 1px solid color-mix(in srgb, var(--violet) 30%, var(--line)); background: linear-gradient(180deg, color-mix(in srgb, var(--violet) 6%, var(--surface)), var(--surface)); border-radius: 16px; padding: .9rem 1rem; }
.ai-drawer .offcanvas-body { display: flex; flex-direction: column; padding: 0; }
.ai-drawer { width: 460px !important; background: var(--surface); color: var(--text); }
.ai-head { background: linear-gradient(135deg, #2A1F6B, var(--ink)); color: #fff; padding: 1rem 1.1rem; }
.ai-head h5 { color: #fff; margin: 0; }
.ai-msgs { flex: 1; overflow-y: auto; padding: 1rem; display: flex; flex-direction: column; gap: .7rem; }
.ai-msg { max-width: 88%; padding: .6rem .8rem; border-radius: 14px; font-size: .93rem; line-height: 1.45; }
.ai-msg.user { align-self: flex-end; background: var(--primary); color: #fff; border-bottom-right-radius: 4px; }
.ai-msg.bot { align-self: flex-start; background: var(--surface-2); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.ai-msg.bot ul { padding-left: 1.1rem; margin: .3rem 0; }
.ai-msg.bot p { margin: 0 0 .3rem; }
.ai-suggest { display: flex; flex-wrap: wrap; gap: .4rem; padding: 0 1rem .6rem; }
.ai-suggest button { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; font-size: .8rem; padding: .25rem .65rem; color: var(--text); }
.ai-suggest button:hover { border-color: var(--violet); color: var(--violet); }
.ai-input { border-top: 1px solid var(--line); padding: .75rem; display: flex; gap: .5rem; }
.typing span { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--faint); margin: 0 1px; animation: blink 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: .2s; } .typing span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .2; } 40% { opacity: 1; } }

/* command palette */
.cmdk .modal-dialog { max-width: 640px; margin-top: 10vh; }
.cmdk input { border: 0; font-size: 1.15rem; padding: 1rem 1.2rem; box-shadow: none !important; border-bottom: 1px solid var(--line); border-radius: 0; }
.cmdk .res { max-height: 60vh; overflow-y: auto; padding: .4rem; }
.cmdk .res a { display: flex; gap: .7rem; align-items: center; padding: .55rem .7rem; border-radius: 10px; color: var(--text); }
.cmdk .res a.hl, .cmdk .res a:hover { background: var(--primary-soft); }
.cmdk .res a i { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; background: var(--surface-2); color: var(--primary); flex: none; }
.cmdk .res a .rt { margin-left: auto; font-size: .74rem; color: var(--faint); }
.cmdk .res .grp { font-size: .76rem; font-weight: 700; color: var(--faint); padding: .5rem .7rem .2rem; }

/* report hub */
.rep-tile { display: flex; gap: .8rem; align-items: flex-start; padding: 1rem; height: 100%; color: var(--text); }
.rep-tile:hover { border-color: var(--line-2); box-shadow: var(--shadow-2); color: var(--text); }
.rep-tile .ri { width: 44px; height: 44px; border-radius: 13px; display: grid; place-items: center; font-size: 1.25rem; color: var(--c); background: color-mix(in srgb, var(--c) 13%, transparent); flex: none; }
.rep-tile b { display: block; }
.rep-tile span { font-size: .85rem; color: var(--muted); }
.fin-table { width: 100%; font-size: .95rem; }
.fin-table td { padding: .4rem .6rem; border-bottom: 1px solid var(--line); }
.fin-table .grp td { font-weight: 700; background: var(--surface-2); }
.fin-table .tot td { font-weight: 700; border-top: 2px solid var(--line-2); font-size: 1.02rem; }
.fin-table .grand td { font-weight: 800; font-size: 1.12rem; color: var(--module); border-top: 3px double var(--line-2); }
.fin-table td.amt { text-align: right; font-family: var(--font-num); white-space: nowrap; }

/* dropzone */
.dropzone { border: 2px dashed var(--line-2); border-radius: 16px; padding: 2rem 1rem; text-align: center; background: var(--surface-2); cursor: pointer; transition: border-color .15s, background .15s; }
.dropzone:hover, .dropzone.over { border-color: var(--module); background: var(--module-soft); }
.dropzone i { font-size: 2.4rem; color: var(--module); }

/* skeleton loading */
.skel { background: linear-gradient(90deg, var(--line) 25%, var(--surface-2) 50%, var(--line) 75%); background-size: 200% 100%; animation: skel 1.2s infinite; border-radius: 8px; }
@keyframes skel { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.page-loading { padding: 3rem; text-align: center; color: var(--muted); }

/* mobile bottom bar */
.ap-bottom { display: none; }

/* dropdown in dark mode */
.dropdown-menu { background: var(--surface); border-color: var(--line); border-radius: 14px; box-shadow: var(--shadow-2); }
.dropdown-item { color: var(--text); border-radius: 8px; padding: .45rem .8rem; }
.dropdown-item:hover { background: var(--surface-2); color: var(--text); }
.table { --bs-table-bg: transparent; --bs-table-color: var(--text); }

/* ------------------------------------------------------------ responsive */
@media (max-width: 1799.98px) {
  .ap-user .who { display: none; }
  .ap-ai-btn span { display: none; }
  .ap-ai-btn { width: 42px; padding: 0; justify-content: center; }
  .ap-search { min-width: 0; width: 42px; padding: 0; justify-content: center; }
  .ap-search span, .ap-search kbd { display: none; }
}
@media (max-width: 1499.98px) {
  .ap-brand small { display: none; }
  .ap-nav { margin-left: .2rem; }
  .ap-nav .nav-top { padding: 0 .55rem; font-size: .9rem; gap: .3rem; }
  .ap-nav .nav-top .dot { display: none; }
  .ap-nav .nav-top .bi-chevron-down { display: none; }
}
@media (max-width: 1199.98px) {
  .ap-nav { display: none; }
  .ap-burger { display: grid; }
  .job-hero { grid-template-columns: 1fr; }
}
@media (max-width: 767.98px) {
  html { font-size: 16.5px; }
  :root { --topbar-h: 58px; }
  .ap-topbar { padding: 0 .6rem; gap: .4rem; }
  .ap-brand small { display: none; }
  .ap-ai-btn span { display: none; }
  .ap-ai-btn { width: 42px; padding: 0; justify-content: center; }
  .ap-search { width: 42px; padding: 0; justify-content: center; }
  .ap-main { padding: .9rem .75rem 6.5rem; }
  .page-head h1 { font-size: 1.3rem; }
  .page-head .ph-icon { width: 42px; height: 42px; font-size: 1.2rem; border-radius: 13px; }
  .page-head .ph-actions { width: 100%; margin-left: 0; }
  .page-head { gap: .7rem; align-items: flex-start; }
  .page-head .ph-title { flex: 1 1 0; }
  .page-head .ph-actions .btn { flex: 1 1 auto; white-space: nowrap; font-size: .92rem; padding-left: .6rem; padding-right: .6rem; }
  .dt-search { max-width: none; }
  .dt-actions { margin-left: 0; width: 100%; }
  .dt-actions .btn { flex: 1; }
  /* tables become cards */
  table.dt.responsive thead { display: none; }
  table.dt.responsive tbody tr { display: block; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; margin: .6rem .6rem; padding: .35rem .2rem; box-shadow: var(--shadow-1); }
  table.dt.responsive tbody td { display: flex; justify-content: space-between; gap: 1rem; border: 0; padding: .3rem .75rem; text-align: right; }
  table.dt.responsive tbody td::before { content: attr(data-label); font-size: .8rem; color: var(--muted); font-weight: 600; text-align: left; flex: none; }
  table.dt.responsive tbody td.td-hide-m { display: none; }
  table.dt.responsive tbody td.td-first { font-size: 1.02rem; border-bottom: 1px solid var(--line); margin-bottom: .2rem; padding-bottom: .5rem; }
  table.dt.responsive tbody td.td-first::before { display: none; }
  table.dt.responsive tbody td.td-first { justify-content: flex-start; text-align: left; }
  table.dt.responsive tfoot { display: none; }
  .dt-foot .pagination { margin: 0 auto; }
  .ap-bottom { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 1035; background: var(--surface); border-top: 1px solid var(--line);
               padding: .35rem .4rem calc(.35rem + env(safe-area-inset-bottom)); box-shadow: 0 -8px 24px -12px rgba(19,32,59,.25); }
  .ap-bottom a, .ap-bottom button { flex: 1; display: flex; flex-direction: column; align-items: center; gap: .1rem; font-size: .72rem; font-weight: 600; color: var(--muted); background: none; border: 0; padding: .2rem 0; }
  .ap-bottom a i, .ap-bottom button i { font-size: 1.3rem; }
  .ap-bottom a.active { color: var(--primary); }
  .ap-bottom .fab { width: 54px; height: 54px; border-radius: 18px; background: linear-gradient(135deg, var(--primary), var(--violet)); color: #fff; margin-top: -24px; flex: none; justify-content: center; box-shadow: 0 10px 22px -8px rgba(47,91,234,.8); }
  .ap-bottom .fab i { font-size: 1.6rem; }
  .ai-drawer { width: 100% !important; }
  .kpi .kpi-value { font-size: 1.55rem; }
  .cluster .gauge { height: 180px; }
  .modal-footer { flex-wrap: nowrap; }
  .li-table .hide-m { display: none; }
  .fin-table { font-size: .84rem; }
  .fin-table td, .fin-table th { padding: .35rem .3rem; }
  .fin-table td:first-child { word-break: break-word; }
}
@media (max-width: 479.98px) {
  .ap-topbar { gap: .3rem; padding: 0 .5rem; }
  .ap-tools { gap: .3rem; }
  .ap-iconbtn, .ap-search, .ap-ai-btn { width: 38px !important; height: 38px; border-radius: 11px; }
  .ap-brand { font-size: 1.08rem; gap: .4rem; min-width: 0; }
  .ap-brand-mark { width: 32px; height: 32px; }
  .ap-brand-mark i { width: 25px; height: 25px; font-size: 1rem; }
  .ap-brand .bn2 { display: none; }
  .ap-user { padding: .2rem; }
  .ap-avatar { width: 34px !important; height: 34px !important; }
}
@media print {
  .ap-topbar, .ap-bottom, .no-print, .ph-actions, .dt-toolbar, .dt-foot { display: none !important; }
  body { background: #fff; }
  .card-x { box-shadow: none; border: 0; }
}
