/* Avertec SMS — shared styles.
   Visual language: the "Industrial Field Service Operations" design system from
   the Stitch project "Forklift Service Management System" (2026-09-10).
   Corporate / modern industrial: obsidian navy chrome, slate canvas, hairline
   white surfaces, dense data tables, squared status chips, cobalt actions.

   DENSITY NOTE (deliberate deviation — see problem.md 2026-09-10):
   Stitch density is applied to EVERY screen, technician phone views included.
   That overrides the earlier §12.3 constraint of >=48px tap targets. Every
   touch surface is sized from --touch-min / --touch-sm below; uncomment the
   technician override to restore §12.3 without touching anything else.

   CONTRACT: class names in this file are also behavioural hooks used by
   public/assets/app.js and by the inline scripts in app/views/*.php —
   .toast / .toast.err (assigned by replacing className), .modal-backdrop > .modal,
   the .b-* badge classes emitted by badge(), .tabs button.active, .mainnav.open,
   and the [hidden] attribute on tab panels and #bellCount. Restyle them freely;
   never rename or remove them. */

/* ---------- Self-hosted fonts (no CDN — works offline / on the LAN box) ----
   url() is relative to this stylesheet, so it resolves correctly under a
   sub-folder mount as well. Inter is a variable font: one file, all weights. */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url(fonts/inter-latin.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
    U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 100 800;
  font-display: swap;
  src: url(fonts/jetbrains-mono-latin.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
    U+2212, U+2215, U+FEFF, U+FFFD;
}

* { box-sizing: border-box; }

/* app.js toggles the `hidden` attribute on #bellCount and the view scripts do
   the same on tab panels. Author display rules would out-rank the UA
   [hidden] rule, so pin it here. */
[hidden] { display: none !important; }

:root {
  /* Ink & structure */
  --ink: #0f172a;           /* primary text            */
  --ink-soft: #64748b;      /* metadata, labels        */
  --line: #e2e8f0;          /* hairline border         */
  --line-strong: #cbd5e1;   /* input border, dividers  */
  --band: #f1f5f9;          /* table head, utility band*/
  --bg: #f8fafc;            /* app canvas              */
  --card: #ffffff;          /* surfaces                */

  /* Brand & action */
  --navy: #0b192c;          /* header chrome           */
  --navy-soft: #1e3e62;     /* steel navy, secondary   */
  --brand: #2563eb;         /* primary action, cobalt  */
  --brand-dark: #1d4ed8;
  --brand-ink: #1e40af;

  /* Semantic */
  --ok: #059669;   --ok-bg: #ecfdf5;   --ok-ink: #065f46;
  --warn: #d97706; --warn-bg: #fffbeb; --warn-ink: #92400e;
  --bad: #dc2626;  --bad-bg: #fef2f2;  --bad-ink: #991b1b;
  --info-bg: #eff6ff;

  /* Shape & rhythm */
  --radius: 8px;            /* cards, tables           */
  --radius-sm: 4px;         /* buttons, inputs, chips  */

  /* Minimum height of a touchable control. Stitch density = 40px / 32px.
     Every touch surface below is sized from these two, so the technician
     override further down lifts all of them together. */
  --touch-min: 40px;   /* primary controls, inputs, tabs */
  --touch-sm: 32px;    /* compact in-table actions       */

  --font: 'Inter', -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* Restore the §12.3 field constraint (>=48px tap targets) by uncommenting: */
/* body.role-technician { --touch-min: 48px; --touch-sm: 48px; } */

html, body { margin: 0; padding: 0; }
body {
  font: 13px/1.55 var(--font);
  background: var(--bg); color: var(--ink);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; line-height: 30px; font-weight: 600; letter-spacing: -.015em; margin: 0 0 14px; color: #0b1c30; }
h2 { font-size: 15px; line-height: 22px; font-weight: 600; letter-spacing: -.01em; margin: 20px 0 10px; color: #0b1c30; }
h3 { font-size: 13px; font-weight: 600; margin: 14px 0 6px; }

/* Identifiers — job refs, part numbers, serials, VINs (opt-in) */
.mono, td .mono { font-family: var(--font-mono); font-weight: 500; letter-spacing: -.01em; }

/* Focus — the previous stylesheet had none at all. */
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 3px; }
.topbar :focus-visible { outline-color: #7db4ff; }
label.f input:focus-visible, label.f select:focus-visible, label.f textarea:focus-visible {
  outline: none; border-color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand);
}

/* ---------- Topbar ---------- */
.topbar { background: var(--navy); color: #fff; position: sticky; top: 0; z-index: 50; border-bottom: 1px solid #1e293b; }
.topbar-inner { display: flex; align-items: center; gap: 20px; padding: 0 20px; min-height: 54px; flex-wrap: wrap; max-width: 1720px; margin: 0 auto; }

.brand { color: #f1f5f9; font-weight: 700; letter-spacing: .06em; font-size: 14px; text-transform: uppercase; display: inline-flex; align-items: center; gap: 9px; }
.brand:hover { text-decoration: none; }
.brand span { color: #94a3b8; font-weight: 400; margin-left: 0; letter-spacing: .06em; }
/* Square brand tile with the initial */
.brand-tile {
  width: 28px; height: 28px; border-radius: 6px; background: var(--brand); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 900; letter-spacing: -.05em; flex: none;
}
.chip {
  padding: 2px 7px; border-radius: var(--radius-sm); font-size: 10px; font-weight: 600;
  letter-spacing: .08em; background: #1e293b; border: 1px solid #334155; color: #cbd5e1;
  text-transform: uppercase;
}
/* The tile and the chip are both <span> inside .brand, so they need to out-rank
   the `.brand span` rule above on specificity, not merely on source order. */
.brand .brand-tile { color: #fff; font-weight: 900; letter-spacing: -.05em; }
.brand .chip { color: #cbd5e1; font-weight: 600; letter-spacing: .08em; }

.mainnav { display: flex; gap: 2px; flex-wrap: wrap; flex: 1; }
.mainnav a {
  color: #cbd5e1; padding: 6px 11px; font-size: 12px; font-weight: 500;
  border-radius: 6px; border-bottom: 0; transition: background .12s, color .12s;
}
.mainnav a.active, .mainnav a:hover {
  color: #fff; border-bottom-color: transparent; text-decoration: none;
  background: rgba(30, 41, 59, .85);
}
.mainnav a.active { background: var(--brand); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.18); }

.topbar-right { display: flex; align-items: center; gap: 12px; }
.whoami { font-size: 12px; color: #e2e8f0; display: inline-flex; align-items: center; gap: 8px; line-height: 1.25; }
.whoami em { color: #94a3b8; font-style: normal; font-size: 11px; display: block; }
.whoami .who-name { font-weight: 600; }
.avatar {
  width: 28px; height: 28px; border-radius: 50%; background: var(--brand); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; border: 1px solid #60a5fa; flex: none;
}
.bell { position: relative; color: #94a3b8; display: inline-flex; padding: 5px; border-radius: 50%; }
.bell:hover { color: #fff; background: #1e293b; }
.bell svg { width: 18px; height: 18px; display: block; }
.bell-count {
  position: absolute; top: -2px; right: -4px; background: var(--warn); color: #fff;
  font-size: 10px; border-radius: 9px; padding: 1px 5px; font-weight: 700; line-height: 1.3;
  border: 1px solid var(--navy);
}
.hamburger { display: none; background: none; border: 0; color: #fff; font-size: 20px; padding: 6px 8px; cursor: pointer; }

/* Context strip under the header */
.crumbs {
  background: var(--card); border-bottom: 1px solid var(--line); font-size: 11px;
  padding: 7px 20px; color: var(--ink-soft);
}
.crumbs .crumbs-inner { max-width: 1720px; margin: 0 auto; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.crumbs span { text-transform: uppercase; letter-spacing: .06em; font-weight: 500; }
.crumbs .sep { color: var(--line-strong); }
.crumbs .here { color: #0b1c30; font-weight: 600; }
.crumbs .meta { margin-left: auto; font-family: var(--font-mono); color: var(--ink-soft); text-transform: none; letter-spacing: 0; }

.page { max-width: 1720px; margin: 0 auto; padding: 22px 20px 60px; }
.login-main { display: flex; align-items: center; justify-content: center; min-height: 100vh; }

/* Page title row (opt-in) */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h1 { margin: 0; }
.page-head .sub { margin: 3px 0 0; font-size: 12px; color: var(--ink-soft); }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Cards & tables ---------- */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; margin-bottom: 16px;
}
.grid { display: grid; gap: 12px; }
.grid-kpi { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }

.kpi {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 13px 14px; cursor: pointer; transition: box-shadow .12s, border-color .12s;
}
.kpi:hover { box-shadow: 0 1px 3px rgba(11, 25, 44, .07); }
.kpi b { display: block; font-size: 24px; line-height: 1.15; font-weight: 700; letter-spacing: -.02em; color: #0b1c30; }
.kpi span { font-size: 12px; color: var(--ink-soft); font-weight: 500; margin-top: 3px; display: block; }
/* Exception tiles — a metric that needs someone to act (opt-in) */
.kpi.alert-amber { border-color: #fcd34d; }
.kpi.alert-amber b { color: var(--warn); }
.kpi.alert-amber span { color: #334155; font-weight: 600; }
.kpi.alert-rose { border-color: #fca5a5; }
.kpi.alert-rose b { color: var(--bad); }
.kpi.alert-rose span { color: #334155; font-weight: 600; }

.table-wrap { overflow-x: auto; border-radius: var(--radius); }
table.data { width: 100%; border-collapse: collapse; background: var(--card); font-size: 13px; }
table.data th, table.data td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--band); vertical-align: top; }
table.data th {
  background: var(--band); font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .05em; color: #475569; white-space: nowrap;
  border-bottom: 1px solid var(--line-strong);
}
table.data tr:hover td { background: var(--bg); }
/* Deactivated records — replaces inline opacity in store.php / users.php */
.row-inactive td { opacity: .55; }

/* ---------- Badges — squared status chips ---------- */
.badge {
  display: inline-block; padding: 2px 8px; border-radius: var(--radius-sm);
  font-size: 11px; font-weight: 600; white-space: nowrap; letter-spacing: .02em;
  text-transform: uppercase; line-height: 1.5;
}
.b-grey  { background: var(--band);     color: #475569; }
.b-blue  { background: var(--info-bg);  color: var(--brand-ink); }
.b-green { background: var(--ok-bg);    color: var(--ok-ink); }
.b-amber { background: var(--warn-bg);  color: var(--warn-ink); }
.b-red   { background: var(--bad-bg);   color: var(--bad-ink); }

/* ---------- Forms ---------- */
label.f { display: block; margin-bottom: 12px; font-size: 11px; font-weight: 600; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .05em; }
label.f input, label.f select, label.f textarea {
  display: block; width: 100%; margin-top: 5px; padding: 8px 10px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  font: 13px/1.5 var(--font); color: var(--ink); background: #fff;
  text-transform: none; letter-spacing: 0; min-height: var(--touch-min);
}
label.f select { cursor: pointer; }
textarea { min-height: 74px; resize: vertical; }
.f-unparsed input, .f-unparsed textarea { border-color: var(--warn); background: var(--warn-bg); }
.form-cols { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 0 16px; }
.inline-note { font-size: 12px; color: var(--ink-soft); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid transparent; border-radius: var(--radius-sm); padding: 8px 16px;
  font: 600 13px/1.4 var(--font); cursor: pointer; min-height: var(--touch-min);
  background: var(--brand); color: #fff; transition: background .12s;
}
.btn:hover { background: var(--brand-dark); text-decoration: none; color: #fff; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-ok { background: var(--ok); } .btn-ok:hover { background: var(--ok-ink); }
.btn-warn { background: var(--warn); } .btn-warn:hover { background: var(--warn-ink); }
.btn-bad { background: var(--bad); } .btn-bad:hover { background: var(--bad-ink); }
.btn-ghost { background: transparent; border-color: var(--line-strong); color: inherit; font-weight: 600; }
.btn-ghost:hover { background: rgba(255,255,255,.12); color: inherit; }
.page .btn-ghost { background: #fff; color: var(--navy-soft); }
.page .btn-ghost:hover { background: var(--band); color: var(--navy-soft); }
.btn-sm { min-height: var(--touch-sm); padding: 4px 11px; font-size: 12px; }
.btn-block { display: flex; width: 100%; min-height: calc(var(--touch-min) + 8px); font-size: 14px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  background: #0b1c30; color: #fff; padding: 11px 20px; border-radius: var(--radius);
  font-weight: 600; font-size: 13px; z-index: 200; max-width: 90vw;
  box-shadow: 0 8px 20px -6px rgba(11, 25, 44, .35);
}
.toast.err { background: var(--bad); }

/* ---------- Modal ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(11, 25, 44, .45); z-index: 100; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal {
  background: #fff; border: 1px solid var(--line-strong); border-radius: var(--radius);
  max-width: 620px; width: 100%; max-height: 90vh; overflow: auto; padding: 20px;
  box-shadow: 0 20px 25px -5px rgba(11, 25, 44, .12);
}

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 16px; flex-wrap: wrap; }
.tabs button {
  background: none; border: 0; padding: 9px 14px; font: 600 12px/1.4 var(--font);
  color: var(--ink-soft); cursor: pointer; border-bottom: 2px solid transparent;
  margin-bottom: -1px; min-height: var(--touch-min); text-transform: uppercase; letter-spacing: .04em;
}
.tabs button:hover { color: var(--ink); }
.tabs button.active { color: var(--brand); border-bottom-color: var(--brand); }

/* ---------- Technician / job cards ---------- */
.jobcard {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; margin-bottom: 12px;
}
.jobcard .jc-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.jobcard .jc-ref { font-family: var(--font-mono); font-weight: 700; font-size: 14px; letter-spacing: -.01em; }
.jobcard .jc-cust { font-weight: 600; margin: 5px 0 2px; font-size: 13px; }
.jobcard .jc-addr { font-size: 12px; color: var(--ink-soft); }
.jobcard .jc-problem { font-size: 13px; margin: 8px 0; }
.jobcard .btn { margin-top: 8px; }
.am-note { background: var(--bad-bg); border: 1px solid #fecaca; border-radius: var(--radius-sm); padding: 10px; margin: 8px 0; font-size: 12px; color: var(--bad-ink); }
.statline { display: flex; gap: 8px; flex-wrap: wrap; margin: 7px 0; align-items: center; }

.myday-nums { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; text-align: center; }
.myday-nums .kpi b { font-size: 28px; }
.incentive-box { background: #0b192c; color: #ecfdf5; border-radius: var(--radius); padding: 16px; margin: 14px 0; border: 1px solid #1e293b; }
.incentive-box b { font-size: 26px; font-weight: 700; letter-spacing: -.02em; }
.incentive-box .pending { color: #fcd34d; }

/* ---------- Timeline ---------- */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: 6px 0 6px 18px; border-left: 2px solid var(--line); position: relative; font-size: 12px; }
.timeline li::before { content: ''; position: absolute; left: -5px; top: 12px; width: 8px; height: 8px; border-radius: 50%; background: var(--brand); }

/* ---------- Login ---------- */
.login-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 32px; width: 100%; max-width: 380px; box-shadow: 0 4px 12px -2px rgba(11, 25, 44, .08);
}
.login-card h1 { text-align: center; letter-spacing: .04em; }
.login-sub { text-align: center; color: var(--ink-soft); font-size: 12px; margin: 0 0 20px; }
/* <small> subtitle inside the login <h1> */
.login-sub-inline { display: block; font-weight: 400; font-size: 12px; color: var(--ink-soft); letter-spacing: 0; margin-top: 4px; }

/* ---------- Photos ---------- */
.photo-strip { display: flex; gap: 8px; flex-wrap: wrap; }
.photo-strip img { width: 110px; height: 110px; object-fit: cover; border-radius: var(--radius-sm); border: 1px solid var(--line-strong); cursor: pointer; }
.photo-big { max-width: 100%; border-radius: var(--radius-sm); border: 1px solid var(--line-strong); }

/* ---------- Semantic text helpers ---------- */
/* Age colour coding (FR-SP-06) */
.age-ok { color: var(--ok); font-weight: 600; }
.age-warn { color: var(--warn); font-weight: 600; }
.age-bad { color: var(--bad); font-weight: 700; }
/* Section headings inside cards — replaces inline colours in dashboard.php */
.h-bad { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--bad); margin: 12px 0 4px; }
.h-warn { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--warn); margin: 12px 0 4px; }
.err-text { color: var(--bad); font-weight: 600; }

/* Accent cards — replace inline border-left colours */
.card-wa { border-left: 3px solid #25d366; }
.card-unread { border-left: 3px solid var(--brand); background: #fbfdff; }
.card-read { opacity: .72; }
.wa-body { margin: 6px 0 10px; white-space: pre-wrap; font-size: 13px; }
.row-between { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; }

/* =====================================================================
   Stitch screen components (2026-09-10 fidelity pass) — structures used
   by the rebuilt dashboard / jobs / intake / store / settings screens.
   ===================================================================== */

/* Page fills the viewport so the site footer sits at the bottom */
body { min-height: 100vh; display: flex; flex-direction: column; }
main.page { flex: 1; width: 100%; }

/* Inline SVG icon sizing */
.ic { width: 16px; height: 16px; flex: none; display: inline-block; vertical-align: -3px; }
.ic-sm { width: 14px; height: 14px; }
.ic-lg { width: 20px; height: 20px; }

/* Status dots + pulse */
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--line); flex: none; display: inline-block; }
.dot-sm { width: 6px; height: 6px; }
.dot-amber { background: #f59e0b; } .dot-rose { background: #f43f5e; }
.dot-green { background: #10b981; } .dot-blue { background: #3b82f6; }
.dot-grey { background: #94a3b8; } .dot-indigo { background: #6366f1; }
.pulse { animation: avx-pulse 2s ease-in-out infinite; }
@keyframes avx-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

/* KPI tile foot row (number above, label + dot below — Stitch dashboard) */
.kpi { position: relative; overflow: hidden; }
.kpi .kpi-foot { display: flex; justify-content: space-between; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-soft); font-weight: 500; margin-top: 3px; }
.kpi.alert-amber .kpi-foot, .kpi.alert-rose .kpi-foot { color: #334155; font-weight: 600; }
.kpi.alert-amber::after, .kpi.alert-rose::after {
  content: ''; position: absolute; top: -16px; right: -16px; width: 40px; height: 40px;
  border-radius: 50%; opacity: .6;
}
.kpi.alert-amber::after { background: #fef3c7; }
.kpi.alert-rose::after { background: #ffe4e6; }

/* Panels — cards with distinct head / body / foot bands */
.panel { background: var(--card); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; margin-bottom: 16px; display: flex; flex-direction: column; }
.panel-head { padding: 15px 20px; border-bottom: 1px solid var(--band); display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.panel-head h2 { margin: 0; font-size: 15px; }
.panel-head .hgroup { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.panel-head.band { background: rgba(241, 245, 249, .6); border-bottom: 0; }
.panel-body { padding: 16px 20px; }
.panel-foot {
  padding: 12px 16px; background: var(--bg); border-top: 1px solid var(--band); margin-top: auto;
  display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap;
  font-size: 12px; color: var(--ink-soft);
}
.fr-chip { font-family: var(--font-mono); font-size: 11px; font-weight: 600; color: #475569; background: var(--band); border: 1px solid var(--line); border-radius: 4px; padding: 1px 8px; white-space: nowrap; }
.link-arrow { font-size: 12px; font-weight: 600; display: inline-flex; align-items: center; gap: 2px; }
.link-arrow.rose { color: #be123c; }

/* Commercial pipeline */
.pipe-bar { width: 100%; height: 10px; background: var(--band); border-radius: 5px; overflow: hidden; display: flex; }
.pipe-bar div { height: 100%; }
.seg-grey { background: #94a3b8; } .seg-amber { background: #fbbf24; } .seg-rose { background: #f43f5e; }
.seg-blue { background: #3b82f6; } .seg-indigo { background: #6366f1; } .seg-green { background: #10b981; }
.pipe-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 11px; color: var(--ink-soft); font-weight: 500; margin-bottom: 6px; }
.stage-row { padding: 13px 8px; margin: 0 -8px; display: flex; align-items: center; justify-content: space-between; gap: 8px; border-bottom: 1px solid var(--band); border-radius: 4px; font-size: 13px; color: #334155; }
.stage-row:hover { background: rgba(248, 250, 252, .7); }
.stage-row:last-child { border-bottom: 0; }
.stage-row .sr-l { display: flex; align-items: center; gap: 12px; }
.count-chip { display: inline-flex; align-items: center; justify-content: center; min-width: 24px; height: 24px; padding: 0 8px; font-size: 12px; font-weight: 700; border-radius: 6px; border: 1px solid var(--line); background: var(--band); color: #334155; }
.count-chip.c-amber { background: var(--warn-bg); border-color: #fde68a; color: #92400e; }
.count-chip.c-rose { background: #fff1f2; border-color: #fecdd3; color: #be123c; }
.count-chip.c-blue { background: var(--info-bg); border-color: #bfdbfe; color: #1d4ed8; }
.count-chip.c-indigo { background: #eef2ff; border-color: #c7d2fe; color: #4338ca; }
.count-chip.c-green { background: var(--ok-bg); border-color: #a7f3d0; color: #047857; }
.mini-chip { padding: 1px 6px; border-radius: 4px; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: -.01em; }
.mini-chip.rose { background: #ffe4e6; color: #be123c; }

/* Needs-attention lists */
.sec-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; display: flex; align-items: center; gap: 6px; margin: 0; }
.sec-label.rose { color: #be123c; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.pill-rose { background: #ffe4e6; color: #9f1239; }
.pill-green { background: var(--ok-bg); color: #047857; border: 1px solid #a7f3d0; font-weight: 600; }
.pill-grey { background: var(--band); color: #475569; }
.pill-blue { background: #dbeafe; color: var(--brand-ink); }
.att-list { list-style: none; margin: 0; padding: 0; border: 1px solid rgba(226, 232, 240, .7); border-radius: 8px; overflow: hidden; font-size: 12px; }
.att-list li { padding: 10px; background: #fff; display: flex; align-items: center; justify-content: space-between; gap: 8px; border-bottom: 1px solid var(--band); }
.att-list li:hover { background: rgba(248, 250, 252, .8); }
.att-list li:last-child { border-bottom: 0; }
.att-list .trunc { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.alert-part { padding: 12px; border-radius: 8px; display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; font-size: 12px; border: 1px solid; }
.alert-part.rose { background: rgba(255, 241, 242, .5); border-color: rgba(254, 205, 211, .8); }
.alert-part.rose:hover { background: rgba(255, 241, 242, .8); }
.alert-part.amber { background: rgba(255, 251, 235, .5); border-color: #fde68a; }
.alert-part.amber:hover { background: rgba(255, 251, 235, .8); }
.chip-solid { color: #fff; font-weight: 700; font-size: 12px; border-radius: 6px; padding: 4px 10px; white-space: nowrap; box-shadow: 0 1px 2px rgba(0,0,0,.12); }
.chip-solid.rose { background: #e11d48; }
.chip-solid.amber { background: #d97706; }
.part-tag { font-family: var(--font-mono); background: #fff; border: 1px solid var(--line); border-radius: 4px; padding: 1px 6px; color: #0b1c30; }

/* Rich KPI ribbon cards (Jobs / Store) */
.grid-kpi-rich { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.kpi-rich { position: relative; overflow: hidden; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 16px; display: flex; flex-direction: column; gap: 8px; transition: box-shadow .12s; }
.kpi-rich:hover { box-shadow: 0 2px 6px rgba(11, 25, 44, .08); }
.kpi-rich .bubble { position: absolute; right: -16px; top: -16px; width: 96px; height: 96px; border-radius: 0 0 0 100%; background: var(--band); }
.bubble.amber { background: #fffbeb; } .bubble.rose { background: #fff1f2; }
.bubble.blue { background: #eff6ff; } .bubble.green { background: #ecfdf5; } .bubble.indigo { background: #eef2ff; }
.kpi-rich .kr-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; position: relative; z-index: 1; }
.kpi-rich .kr-label { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-soft); }
.kr-label.amber { color: #92400e; } .kr-label.rose { color: #9f1239; }
.kpi-rich .kr-ic { width: 36px; height: 36px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; background: var(--band); color: var(--ink-soft); flex: none; }
.kr-ic.amber { background: #fffbeb; color: #92400e; } .kr-ic.rose { background: #fff1f2; color: #9f1239; }
.kr-ic.blue { background: #eff6ff; color: var(--brand-ink); } .kr-ic.green { background: #ecfdf5; color: #047857; }
.kr-ic.indigo { background: #eef2ff; color: #4338ca; }
.kpi-rich .kr-num { font-size: 28px; font-weight: 700; letter-spacing: -.02em; color: #0b1c30; line-height: 1.2; position: relative; z-index: 1; display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.kpi-rich .kr-delta { font-size: 11px; font-weight: 700; border-radius: 4px; padding: 2px 6px; }
.kr-delta.green { background: #ecfdf5; color: #047857; } .kr-delta.amber { background: #fef3c7; color: #92400e; }
.kr-delta.rose { background: #ffe4e6; color: #be123c; } .kr-delta.blue { background: #dbeafe; color: #1e40af; }
.kpi-rich .kr-sub { font-size: 12px; color: var(--ink-soft); position: relative; z-index: 1; margin: 0; }

/* Generic space-between bar */
.bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }

/* Pagination (Stitch table footer) */
.pagination { display: flex; align-items: center; gap: 4px; }
.pagination button {
  min-height: 30px; min-width: 30px; padding: 2px 8px; border: 1px solid var(--line);
  background: #fff; border-radius: 4px; font: 600 12px/1.4 var(--font); cursor: pointer; color: #334155;
}
.pagination button:hover:not(:disabled):not(.cur) { background: var(--band); }
.pagination button:disabled { color: #cbd5e1; cursor: not-allowed; background: var(--band); }
.pagination .cur { background: var(--brand); color: #fff; border-color: var(--brand); font-family: var(--font-mono); }
.rows-per-page { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--navy-soft); }
.rows-per-page select { border: 1px solid var(--line); border-radius: 4px; padding: 3px 6px; font: 600 12px var(--font-mono); background: #fff; }

/* Tab count pills */
.tabs .cnt { background: var(--band); color: #475569; font-size: 11px; font-weight: 700; padding: 1px 8px; border-radius: 999px; margin-left: 6px; letter-spacing: 0; text-transform: none; }
.tabs button.active .cnt { background: #dbeafe; color: var(--brand-ink); }

/* Low-stock rows (Parts Master) */
tr.row-low td { background: rgba(255, 251, 235, .4); }
tr.row-low:hover td { background: rgba(255, 251, 235, .7); }
tr.row-low td:first-child { box-shadow: inset 3px 0 0 #f59e0b; }
.subline { font-size: 11px; color: #94a3b8; font-weight: 400; }

/* Info banner */
.info-banner { background: rgba(239, 246, 255, .6); border: 1px solid #dbeafe; border-radius: 10px; padding: 14px 16px; display: flex; gap: 10px; font-size: 12px; color: #475569; margin-bottom: 16px; line-height: 1.6; }
.info-banner .ib-ic { color: var(--brand); flex: none; margin-top: 1px; }
.info-banner b { color: #1f2937; }

/* Settings — section headers, parameter cards, tier table, templates */
.sec-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 10px; margin: 26px 0 12px; }
.sec-head h2 { margin: 4px 0 2px; font-size: 17px; }
.sec-head .sub { margin: 0; font-size: 12px; color: var(--ink-soft); }
.sec-kicker { display: flex; align-items: center; gap: 6px; font-family: var(--font-mono); font-size: 11px; font-weight: 700; letter-spacing: .06em; color: var(--navy-soft); text-transform: uppercase; }
.sec-kicker::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--brand); }
.key-chip { font-family: var(--font-mono); font-size: 10px; padding: 2px 6px; border-radius: 4px; background: var(--band); color: var(--navy-soft); white-space: nowrap; }
.param-box { background: var(--bg); border-radius: 8px; padding: 10px 12px; margin-bottom: 10px; }
.param-box .ph { display: flex; justify-content: space-between; gap: 8px; align-items: center; flex-wrap: wrap; }
.param-box .ph b { font-size: 12px; }
.param-box p { margin: 4px 0 8px; font-size: 12px; color: var(--ink-soft); }
.param-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.param-foot .pv { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-soft); }
.param-foot input, .param-foot select { border: 1px solid var(--line-strong); border-radius: 4px; padding: 4px 8px; font: 600 12px var(--font-mono); min-height: 30px; background: #fff; }
.param-foot input[type=number], .param-foot input[type=text] { width: 76px; text-align: center; }
.link-btn { background: none; border: 0; color: var(--navy-soft); font: 700 11px var(--font); cursor: pointer; padding: 4px; text-transform: uppercase; letter-spacing: .04em; }
.link-btn:hover { color: var(--ink); }
.link-btn.danger:hover { color: var(--bad); }

.tier-chip { display: inline-flex; padding: 4px 10px; border-radius: 4px; background: var(--band); font: 700 12px var(--font-mono); color: #0b1c30; white-space: nowrap; }
.tier-chip.mid { background: var(--navy-soft); color: #fff; }
.tier-chip.top { background: var(--navy); color: #fff; }
.rm-input { display: inline-flex; align-items: center; gap: 4px; background: var(--bg); padding: 4px 8px; border-radius: 4px; font: 700 12px var(--font-mono); color: var(--navy-soft); }
.rm-input input { width: 72px; border: 0; background: transparent; font: 700 12px var(--font-mono); outline: none; color: #0b1c30; }
.pill-active { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 999px; background: var(--band); color: var(--navy-soft); font: 700 10px var(--font-mono); white-space: nowrap; }
.pill-active::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--brand); }

.switch { width: 48px; height: 24px; border-radius: 999px; background: #cbd5e1; padding: 2px; display: inline-flex; align-items: center; cursor: pointer; border: 0; transition: background .15s; flex: none; }
.switch .knob { width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .15s; }
.switch.on { background: var(--ok); }
.switch.on .knob { transform: translateX(24px); }
.mini-bar { width: 100%; height: 6px; border-radius: 3px; background: var(--band); overflow: hidden; margin-top: 4px; }
.mini-bar div { height: 100%; background: var(--brand); }

.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.tpl-card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.tpl-card .th { display: flex; justify-content: space-between; gap: 8px; align-items: center; flex-wrap: wrap; }
.tpl-key { font-family: var(--font-mono); font-size: 11px; font-weight: 700; background: var(--band); color: var(--navy-soft); border-radius: 4px; padding: 2px 8px; }
.tpl-role { font-family: var(--font-mono); font-size: 10px; font-weight: 700; text-transform: uppercase; background: var(--band); color: var(--navy-soft); border-radius: 999px; padding: 2px 8px; white-space: nowrap; }
.tpl-role.rose { background: #ffe4e6; color: #9f1239; }
.tpl-card h3 { margin: 0; font-size: 14px; }
.tpl-card .td { font-size: 12px; color: var(--ink-soft); margin: 0; }
.tpl-body { background: var(--bg); border-radius: 8px; padding: 10px; font-family: var(--font-mono); font-size: 12px; line-height: 1.7; min-height: 60px; white-space: pre-wrap; word-break: break-word; }
.tpl-body .tag { background: #dbeafe; color: #1e40af; border-radius: 3px; padding: 0 3px; }
.tpl-body textarea { width: 100%; border: 0; background: transparent; font: 500 12px/1.7 var(--font-mono); resize: vertical; outline: none; min-height: 60px; }
.tpl-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: auto; }
.filter-pills { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 12px; color: var(--ink-soft); }
.filter-pills button { border: 0; background: none; padding: 4px 10px; border-radius: 4px; font: 600 12px var(--font); color: var(--ink-soft); cursor: pointer; }
.filter-pills button:hover { background: var(--band); color: var(--ink); }
.filter-pills button.on { background: var(--navy); color: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.15); }

/* Sparkbar (settings Rule Engine Health) */
.sparkbar { width: 100%; height: 36px; color: var(--navy-soft); display: block; }
.kv-rows { font-size: 12px; }
.kv-rows .kv { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 9px 0; border-bottom: 1px solid var(--band); }
.kv-rows .kv:last-child { border-bottom: 0; }
.kv-rows .kv .k { color: var(--ink-soft); }
.kv-rows .kv .v { font-family: var(--font-mono); font-weight: 700; color: #0b1c30; }
.kv-rows .kv .v.blue { color: var(--navy-soft); } .kv-rows .kv .v.red { color: var(--bad); }

/* Crumbs live pill */
.crumbs .live { display: inline-flex; align-items: center; gap: 6px; background: var(--ok-bg); color: #047857; border: 1px solid #a7f3d0; border-radius: 999px; padding: 2px 10px; font-size: 11px; font-weight: 600; text-transform: none; letter-spacing: 0; }

/* ---------- Dialogs (replace native alert/prompt/confirm) ---------- */
.dlg { max-width: 420px; padding: 0; overflow: hidden; }
.dlg-head { display: flex; align-items: center; gap: 12px; }
.dlg .dlg-head { padding: 18px 20px 0; }
.dlg-ic {
  width: 38px; height: 38px; border-radius: 10px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--info-bg); color: var(--brand);
}
.dlg.danger .dlg-ic { background: var(--bad-bg); color: var(--bad); }
.dlg.warn .dlg-ic { background: var(--warn-bg); color: var(--warn); }
.dlg-head h3 { margin: 0; font-size: 15px; font-weight: 600; color: #0b1c30; }
.dlg .dlg-msg { padding: 6px 20px 0 70px; font-size: 12px; color: var(--ink-soft); line-height: 1.6; }
.dlg .dlg-body { padding: 12px 20px 0 70px; }
.dlg .dlg-body input, .dlg .dlg-body textarea {
  width: 100%; border: 1px solid var(--line-strong); border-radius: 6px;
  padding: 9px 11px; font: 13px/1.5 var(--font); color: var(--ink); background: #fff;
  min-height: var(--touch-sm);
}
.dlg .dlg-body input.mono { font-family: var(--font-mono); font-weight: 600; }
.dlg .dlg-body textarea { min-height: 74px; resize: vertical; }
.dlg .dlg-body input:focus, .dlg .dlg-body textarea:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(37, 99, 235, .15);
}
.dlg.danger .dlg-body input:focus, .dlg.danger .dlg-body textarea:focus {
  border-color: var(--bad); box-shadow: 0 0 0 3px rgba(220, 38, 38, .12);
}
.dlg-err { font-size: 11px; font-weight: 600; color: var(--bad); }
.dlg .dlg-err { padding: 6px 20px 0 70px; }
.dlg .dlg-actions {
  display: flex; justify-content: flex-end; gap: 8px; padding: 16px 20px;
  margin-top: 16px; background: var(--bg); border-top: 1px solid var(--band);
}
@media (max-width: 480px) {
  .dlg .dlg-msg, .dlg .dlg-body, .dlg .dlg-err { padding-left: 20px; }
}

/* ---------- In-table inputs (approve qty, quotation lines) ---------- */
.cell-input, select.cell-input {
  border: 1px solid var(--line-strong); border-radius: 6px; background: #fff;
  padding: 6px 9px; font: 13px/1.4 var(--font); color: var(--ink);
  min-height: var(--touch-sm); transition: border-color .12s, box-shadow .12s;
}
.cell-input:hover { border-color: #94a3b8; }
.cell-input:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(37, 99, 235, .15);
}
.cell-input.num { font-family: var(--font-mono); font-weight: 600; text-align: right; }
.cell-input.num::-webkit-inner-spin-button { opacity: 1; }
/* Qty stepper: input flanked by − / + buttons */
.qty-wrap { display: inline-flex; align-items: stretch; border: 1px solid var(--line-strong); border-radius: 6px; overflow: hidden; background: #fff; }
.qty-wrap:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(37, 99, 235, .15); }
.qty-wrap button {
  border: 0; background: var(--band); color: var(--navy-soft); width: 28px; cursor: pointer;
  font: 700 14px var(--font); min-height: var(--touch-sm);
}
.qty-wrap button:hover { background: var(--line); }
.qty-wrap input {
  border: 0; width: 58px; text-align: center; font: 600 13px var(--font-mono);
  color: var(--ink); outline: none; -moz-appearance: textfield; appearance: textfield;
}
.qty-wrap input::-webkit-inner-spin-button, .qty-wrap input::-webkit-outer-spin-button { -webkit-appearance: none; }

/* ---------- Sortable table headers ---------- */
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--brand-ink); }
th.sortable .arrow { opacity: .35; font-size: 9px; margin-left: 4px; }
th.sortable.sorted .arrow { opacity: 1; color: var(--brand); }

/* Clickable data rows (drill-down) */
tr.rowlink { cursor: pointer; }
tr.rowlink:hover td { background: var(--info-bg); }

/* ---------- Password show/hide toggle ---------- */
.pw-wrap { position: relative; display: block; }
.pw-wrap input { width: 100%; padding-right: 40px !important; }
.pw-eye {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  background: none; border: 0; cursor: pointer; padding: 6px; border-radius: 6px;
  color: var(--ink-soft); display: inline-flex; align-items: center; justify-content: center;
}
.pw-eye:hover { color: var(--ink); background: var(--band); }
.pw-eye svg { width: 18px; height: 18px; display: block; }

/* Site footer (all authenticated pages) */
.site-footer { background: var(--card); border-top: 1px solid var(--line); color: var(--ink-soft); font-size: 11px; padding: 14px 20px; margin-top: auto; }
.site-footer .inner { max-width: 1720px; margin: 0 auto; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.site-footer .l, .site-footer .r { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.site-footer b { color: #334155; }
.site-footer .ok { display: inline-flex; align-items: center; gap: 5px; color: #059669; font-weight: 500; }
.site-footer .sep { color: var(--line-strong); }

@media (max-width: 860px) {
  .mainnav { display: none; flex-basis: 100%; flex-direction: column; }
  .mainnav.open { display: flex; }
  .mainnav a { padding: 11px 10px; border-radius: var(--radius-sm); min-height: var(--touch-min); display: flex; align-items: center; }
  .hamburger { display: block; margin-left: auto; }
  .topbar-right { margin-left: auto; }
  .whoami { display: none; }
  .crumbs { display: none; }
  .page { padding: 16px 14px 60px; }
}
