/* ---------------------------------------------------------------------------
   ServiceFlow — interface tokens and shell.
   Direction A (Ledger): fixed sidebar, bordered cards, status pills.
   Neutral surfaces; the accent is reserved for actions and active state.

   Theming has three states, not two. An explicit choice stamps
   data-theme on <html>; the default "system" setting stamps nothing, so
   prefers-color-scheme has to carry it. Every colour is a token declared
   here first, then redefined in the two dark blocks.
--------------------------------------------------------------------------- */

:root {
  --bg:            #F4F6F9;
  --surface:       #FFFFFF;
  --surface-2:     #FAFBFD;
  --sidebar:       #111722;
  --sidebar-ink:   #9AA5B4;
  --sidebar-on-bg: #1E2A3E;
  --sidebar-on-ink:#FFFFFF;
  --sidebar-badge: #2A3648;

  --ink:      #141A22;
  --ink-2:    #48525F;
  --muted:    #78828F;
  --rule:     #E2E6EC;
  --rule-2:   #EEF1F5;

  --accent:      #4C7DF0;
  --accent-ink:  #FFFFFF;
  --accent-soft: #EDF2FE;
  --accent-line: #C9D9FB;
  --navy:        #1E2A4A;

  --ok:        #0B7A4B;
  --ok-soft:   #E6F4ED;
  --warn:      #A65A00;
  --warn-soft: #FDF1E0;
  --stop:      #B42318;
  --stop-soft: #FDECEA;
  --info:        #2F5FC7;
  --violet:      #6D4AD6;
  --violet-soft: #F1ECFD;

  --shadow: 0 1px 2px rgba(16, 22, 32, .05), 0 8px 24px -14px rgba(16, 22, 32, .2);
  --radius: 9px;
  --sidebar-w: 196px;

  --font: "Segoe UI", Roboto, system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: "Cascadia Mono", "SF Mono", Consolas, "Liberation Mono", Menlo, monospace;

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:            #0E1116;
    --surface:       #161A21;
    --surface-2:     #1B2029;
    --sidebar:       #0A0D12;
    --sidebar-ink:   #8A93A0;
    --sidebar-on-bg: #1E2A3E;
    --sidebar-on-ink:#FFFFFF;
    --sidebar-badge: #232C3A;

    --ink:    #E7EAEF;
    --ink-2:  #B4BCC7;
    --muted:  #8A93A0;
    --rule:   #272D36;
    --rule-2: #1E242C;

    --accent:      #7FA3F5;
    --accent-ink:  #0B1220;
    --accent-soft: #17243C;
    --accent-line: #2B3F63;
    --navy:        #C7D3EE;

    --ok:        #4ADE9A;
    --ok-soft:   #10261D;
    --warn:      #F0B357;
    --warn-soft: #2A1F0E;
    --stop:      #F98077;
    --stop-soft: #2B1512;
    --info:        #9DB8F7;
    --violet:      #B59CFA;
    --violet-soft: #231B3A;

    --shadow: 0 1px 2px rgba(0, 0, 0, .5), 0 8px 24px -14px rgba(0, 0, 0, .8);

    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg:            #0E1116;
  --surface:       #161A21;
  --surface-2:     #1B2029;
  --sidebar:       #0A0D12;
  --sidebar-ink:   #8A93A0;
  --sidebar-on-bg: #1E2A3E;
  --sidebar-on-ink:#FFFFFF;
  --sidebar-badge: #232C3A;

  --ink:    #E7EAEF;
  --ink-2:  #B4BCC7;
  --muted:  #8A93A0;
  --rule:   #272D36;
  --rule-2: #1E242C;

  --accent:      #7FA3F5;
  --accent-ink:  #0B1220;
  --accent-soft: #17243C;
  --accent-line: #2B3F63;
  --navy:        #C7D3EE;

  --ok:        #4ADE9A;
  --ok-soft:   #10261D;
  --warn:      #F0B357;
  --warn-soft: #2A1F0E;
  --stop:      #F98077;
  --stop-soft: #2B1512;
  --info:        #9DB8F7;
  --violet:      #B59CFA;
  --violet-soft: #231B3A;

  --shadow: 0 1px 2px rgba(0, 0, 0, .5), 0 8px 24px -14px rgba(0, 0, 0, .8);

  color-scheme: dark;
}

/* --------------------------------------------------------------- base */

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

.mono, .num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.num { text-align: right; }

/* ------------------------------------------------------------ sign-in */

.auth-wrap {
  min-height: 100vh;
  box-sizing: border-box;
  display: grid;
  grid-template-rows: 1fr auto;
  place-items: center;
  padding: 24px 24px 12px;
}

.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 30px 28px 26px;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 22px;
}
.auth-brand svg { width: 26px; height: 26px; display: block; }
.auth-brand span { font-size: 19px; font-weight: 600; letter-spacing: -.02em; color: var(--navy); }
.auth-brand span i { font-style: normal; font-weight: 400; opacity: .8; }

.auth-card h1 { font-size: 16px; margin: 0 0 4px; font-weight: 600; }
.auth-card .sub { font-size: 13px; color: var(--muted); margin: 0 0 20px; }

/* ------------------------------------------------------------- forms */

.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-2);
  margin-bottom: 5px;
}
/* Every text box, number box, dropdown and text area looks the same wherever
   it sits: in a form, a table cell or a filter bar. :where() gives these rules
   no weight, so a place that needs a smaller or wider control only sets its
   size and still inherits the rest. */
:where(input:not([type]), input[type="text"], input[type="email"], input[type="password"],
       input[type="search"], input[type="number"], input[type="tel"], input[type="url"],
       input[type="date"], input[type="time"], input[type="datetime-local"], input[type="month"],
       select, textarea) {
  box-sizing: border-box;
  max-width: 100%;
  padding: 9px 11px;
  font-family: inherit;
  font-size: 14px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 7px;
}
:where(input:not([type]), input[type="text"], input[type="email"], input[type="password"],
       input[type="search"], input[type="number"], input[type="tel"], input[type="url"],
       input[type="date"], input[type="time"], input[type="datetime-local"], input[type="month"],
       select, textarea):focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-soft);
}
:where(input, select, textarea):disabled { background: var(--surface-2); color: var(--muted); cursor: not-allowed; }

/* In a labelled form field a control fills its column. */
.field :where(input:not([type="checkbox"]):not([type="radio"]):not([type="file"]), select, textarea) { width: 100%; }

.btn {
  display: inline-block;
  padding: 9px 16px;
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  border: 1px solid transparent;
  border-radius: 7px;
  cursor: pointer;
}
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { filter: brightness(1.05); text-decoration: none; }
.btn-block { display: block; width: 100%; }

/* ------------------------------------------------------------ alerts */

.alert {
  padding: 10px 12px;
  border-radius: 7px;
  font-size: 13px;
  margin-bottom: 16px;
  border: 1px solid transparent;
}
.alert-error   { background: var(--stop-soft); color: var(--stop); border-color: var(--stop); }
.alert-success { background: var(--ok-soft);   color: var(--ok);   border-color: var(--ok); }
.alert-warning { background: var(--warn-soft); color: var(--warn); border-color: var(--warn); }

/* ------------------------------------------------------------- pills */

.pill {
  display: inline-block;
  font-size: 11px;
  font-weight: 500;
  padding: 3px 9px;
  border-radius: 20px;
  white-space: nowrap;
}
.pill-ok   { background: var(--ok-soft);   color: var(--ok); }
.pill-warn { background: var(--warn-soft); color: var(--warn); }
.pill-stop { background: var(--stop-soft); color: var(--stop); }
.pill-flat { background: var(--rule-2);    color: var(--ink-2); }

/* ------------------------------------------------------- theme toggle */

.theme-toggle {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 1px solid var(--rule);
  border-radius: 7px;
  background: var(--surface);
  color: var(--ink-2);
  cursor: pointer;
}
.theme-toggle:hover { border-color: var(--muted); }
.theme-toggle .icon-dark { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-dark { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-light { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-dark { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .icon-light { display: none; }
}

@media (prefers-reduced-motion: no-preference) {
  .btn, .theme-toggle, :where(input, select, textarea) { transition: all .15s ease; }
}

/* ------------------------------------------------------------- shell */

.shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }

.sidebar { background: var(--sidebar); padding: 16px 12px; display: flex; flex-direction: column; gap: 3px; }
.sidebar-brand { display: flex; align-items: center; gap: 9px; padding: 4px 8px 18px; }
.sidebar-brand svg { width: 22px; height: 22px; display: block; flex: none; }
.sidebar-brand span { font-size: 16px; font-weight: 600; color: #fff; letter-spacing: -.02em; }
.sidebar-brand span i { font-style: normal; font-weight: 400; opacity: .82; }

.nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 10px; border-radius: 7px;
  color: var(--sidebar-ink); font-size: 13px; text-decoration: none;
}
.nav-item:hover { background: var(--sidebar-on-bg); color: var(--sidebar-on-ink); text-decoration: none; }
.nav-item.is-active { background: var(--sidebar-on-bg); color: var(--sidebar-on-ink); font-weight: 500; }
.nav-count {
  margin-left: auto; font-family: var(--mono); font-size: 11px; font-style: normal;
  background: var(--sidebar-badge); color: #C4CEDC; padding: 1px 7px; border-radius: 20px;
}
.nav-item.is-active .nav-count { background: var(--accent); color: #fff; }

.main { display: flex; flex-direction: column; min-width: 0; }

.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 10px 22px; background: var(--surface); border-bottom: 1px solid var(--rule);
}
.crumb { font-size: 13px; color: var(--muted); margin-right: auto; }

.content { padding: 22px; flex: 1; }

/* "Powered by NuraV Tech": foot of every back-office page, and under the sign-in card. */
.powered { margin: 0; font-size: 12px; color: var(--muted); text-align: center; }
.powered b { color: var(--ink-2); font-weight: 600; }
.main > .powered { padding: 14px 22px; border-top: 1px solid var(--rule); }

.page-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h1 { font-size: 20px; margin: 0; font-weight: 600; letter-spacing: -.015em; }
.page-head p { margin: 0; color: var(--muted); font-size: 13px; }

.card {
  background: var(--surface); border: 1px solid var(--rule);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.card-head { padding: 12px 15px; border-bottom: 1px solid var(--rule-2); font-weight: 600; font-size: 13.5px; }
.card-body { padding: 15px; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; }
.tile { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); padding: 15px 16px; }
.tile .n { font-family: var(--mono); font-size: 26px; font-weight: 600; letter-spacing: -.02em; }
.tile .l { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.tile.is-warn .n { color: var(--warn); }
.tile.is-stop .n { color: var(--stop); }

.empty { padding: 34px 18px; text-align: center; color: var(--muted); font-size: 13.5px; }

@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { flex-direction: row; flex-wrap: wrap; align-items: center; }
  .sidebar-brand { padding: 4px 8px; }
}

/* -------------------------------------------------------- master data */

.tile-link { text-decoration: none; color: inherit; display: block; }
.tile-link:hover { border-color: var(--accent); text-decoration: none; }
.tile-title { font-size: 15px; font-weight: 600; letter-spacing: -.01em; }

.filters { display: flex; gap: 9px; margin-bottom: 14px; flex-wrap: wrap; }
.filters :where(input, select) { padding: 7px 11px; font-size: 13px; }
.filters input[type="search"] { min-width: 240px; }
.btn-ghost { background: var(--surface); border-color: var(--rule); color: var(--ink-2); }
.btn-ghost:hover { border-color: var(--muted); text-decoration: none; }
.btn-danger { color: var(--stop); border-color: var(--rule); }
.btn-danger:hover { border-color: var(--stop); }

.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th {
  text-align: left; font-family: var(--mono); font-size: 10px; letter-spacing: .08em;
  text-transform: uppercase; color: var(--muted); font-weight: 400;
  padding: 9px 14px; background: var(--surface-2); border-bottom: 1px solid var(--rule-2);
  white-space: nowrap;
}
table.data th.num, table.data td.num { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; }
table.data td { padding: 10px 14px; border-bottom: 1px solid var(--rule-2); }
table.data tr:last-child td { border-bottom: 0; }
table.data tr.is-inactive td { color: var(--muted); }
.row-actions { text-align: right; white-space: nowrap; }

.pager { display: flex; gap: 5px; margin-top: 14px; flex-wrap: wrap; }
.pager a {
  padding: 5px 11px; border: 1px solid var(--rule); border-radius: 6px;
  font-size: 12.5px; color: var(--ink-2); background: var(--surface);
}
.pager a:hover { border-color: var(--muted); text-decoration: none; }
.pager a.is-current { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0 18px; }
.field-wide { grid-column: 1 / -1; }
.field .req { color: var(--stop); }
.field-help { margin: 4px 0 0; font-size: 12px; color: var(--muted); }
.field-error { margin: 4px 0 0; font-size: 12px; color: var(--stop); }
.field.has-error input, .field.has-error select, .field.has-error textarea { border-color: var(--stop); }
.check { display: flex; align-items: center; gap: 8px; font-weight: 400; font-size: 13.5px; }
.check input { width: auto; }

.form-actions {
  display: flex; align-items: center; gap: 9px;
  padding: 14px 15px; border-top: 1px solid var(--rule-2); background: var(--surface-2);
  border-radius: 0 0 var(--radius) var(--radius);
}
.form-actions-right { margin-left: auto; }
.form-actions-right form { display: inline; }
.footnote { margin-top: 14px; font-size: 12.5px; color: var(--muted); }

/* ------------------------------------------------------ ticket detail */

.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) 288px; gap: 18px; align-items: start; }
.detail-main { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.detail-rail { display: flex; flex-direction: column; gap: 16px; }
@media (max-width: 960px) { .detail-grid { grid-template-columns: 1fr; } }

.page-head .pill { align-self: center; }
.muted-note { display: block; color: var(--muted); font-size: 11.5px; font-weight: 400; }
td .muted-note { margin-top: 2px; }

.card-head { display: flex; align-items: baseline; gap: 10px; }
.card-head-sub { margin-left: auto; font-weight: 400; font-size: 11.5px; color: var(--muted); }
.card-note {
  padding: 10px 15px; font-size: 12.5px; color: var(--muted);
  border-top: 1px solid var(--rule-2); background: var(--surface-2);
}
.card-note.note-warn { color: var(--warn); background: var(--warn-soft); border-color: transparent; }
.card-actions { display: flex; gap: 9px; padding: 13px 15px; border-top: 1px solid var(--rule-2); flex-wrap: wrap; }
.card-actions form { display: inline; }

.kv-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px 18px; }
.kv-grid > div span { display: block; font-size: 11px; color: var(--muted); margin-bottom: 2px; }
.kv-grid > div b { font-weight: 500; font-size: 13.5px; }

.complaint { margin: 0; font-size: 14px; line-height: 1.6; }

.totals-strip {
  display: flex; justify-content: flex-end; gap: 26px; flex-wrap: wrap;
  padding: 13px 15px; border-top: 1px solid var(--rule-2); background: var(--surface-2);
}
.totals-strip > div { text-align: right; }
.totals-strip span { display: block; font-size: 11px; color: var(--muted); }
.totals-strip b { font-size: 14px; font-weight: 600; }
.totals-strip .is-warn b { color: var(--warn); }
.totals-strip .is-total b { font-size: 17px; color: var(--accent); }

tr.line-declined td { color: var(--muted); }
tr.line-declined td:first-child { text-decoration: line-through; text-decoration-color: var(--stop); }
tr.line-short td { background: var(--stop-soft); }

.rail-note { margin: 0 0 12px; font-size: 12.5px; color: var(--muted); line-height: 1.55; }
.rail-note:last-child { margin-bottom: 0; }

.timeline { display: flex; flex-direction: column; }
.tl { display: flex; gap: 10px; padding: 6px 0; font-size: 12px; }
.tl i { width: 7px; height: 7px; border-radius: 50%; background: var(--rule); margin-top: 5px; flex: none; }
.tl b { display: block; font-weight: 500; font-size: 12.5px; }
.tl span { color: var(--muted); font-size: 11px; font-family: var(--mono); }
.tl em { display: block; color: var(--muted); font-size: 11.5px; font-style: normal; margin-top: 2px; }

.history { display: flex; flex-direction: column; gap: 2px; }
.hist { display: block; padding: 7px 0; border-bottom: 1px solid var(--rule-2); text-decoration: none; color: inherit; font-size: 12px; }
.hist:last-child { border-bottom: 0; }
.hist:hover { text-decoration: none; }
.hist span:first-child { color: var(--accent); }
.hist span + span { color: var(--muted); margin-left: 8px; }
.hist em { display: block; color: var(--muted); font-style: normal; margin-top: 2px; }

.notes { display: flex; flex-direction: column; gap: 12px; }
.note { font-size: 13px; }
.note-meta { font-size: 11px; color: var(--muted); margin-bottom: 3px; }
.note-photo { display: inline-block; margin-top: 7px; border-radius: 6px; overflow: hidden; border: 1px solid var(--rule-2); line-height: 0; }
.note-photo img { display: block; width: auto; height: auto; max-width: min(260px, 100%); max-height: 195px; object-fit: cover; }
.note-photo:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.clock-flag { color: var(--warn); }

.dispatch-block { border-top: 1px solid var(--rule-2); }
.dispatch-block:first-of-type { border-top: 0; }
.dispatch-head {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 11px 15px; font-size: 12.5px;
}
.inline-form { display: inline-flex; gap: 6px; align-items: center; }
.inline-form :where(input, select) { padding: 4px 8px; font-size: 12px; border-radius: 6px; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.fit-row { display: flex; align-items: center; gap: 12px; padding: 6px 0; font-size: 13px; }
.fit-row label { flex: 1; }
.fit-row input { width: 110px; padding: 6px 9px; border-radius: 6px; }

/* A quantity typed into a table row. */
table.data input[type="number"] { width: 110px; padding: 6px 9px; font-size: 13px; text-align: right; font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------- callouts */

.callout { border-radius: var(--radius); padding: 14px 16px; margin-bottom: 16px; border: 1px solid; }
.callout h3 { margin: 0 0 6px; font-size: 14px; font-weight: 600; }
.callout p { margin: 0 0 6px; font-size: 13px; }
.callout p:last-child { margin-bottom: 0; }
.callout-note { color: var(--muted); font-size: 12.5px; }
.callout-warn { background: var(--warn-soft); border-color: var(--warn); color: var(--warn); }
.callout-warn .callout-note { color: var(--warn); opacity: .85; }
.callout-stop { background: var(--stop-soft); border-color: var(--stop); color: var(--stop); }
.callout-stop .callout-note { color: var(--stop); opacity: .85; }
.callout .table-wrap { margin-top: 10px; background: var(--surface); border-radius: 7px; }

/* ----------------------------------------------------- approvals queue */

.queue-grid { display: grid; grid-template-columns: 264px minmax(0, 1fr); gap: 18px; align-items: start; }
@media (max-width: 960px) { .queue-grid { grid-template-columns: 1fr; } }
.queue { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); overflow: hidden; }
.queue-head {
  font-family: var(--mono); font-size: 10px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--muted); padding: 12px 14px 8px;
}
.queue-item {
  display: block; padding: 10px 14px; border-top: 1px solid var(--rule-2);
  border-left: 3px solid transparent; text-decoration: none; color: inherit;
}
.queue-item:hover { background: var(--surface-2); text-decoration: none; }
.queue-item.is-open { background: var(--accent-soft); border-left-color: var(--accent); }
.queue-item .qn { display: block; font-size: 12px; font-weight: 500; }
.queue-item .qc { display: block; font-size: 12px; color: var(--ink-2); margin-top: 1px; }
.queue-item .qv { display: block; font-size: 11px; color: var(--muted); margin-top: 3px; }

.approve-bar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 13px 15px; border-top: 1px solid var(--rule-2); background: var(--surface-2);
}
.approve-lead { font-size: 12.5px; color: var(--muted); margin-right: auto; }
.form-note { font-size: 12px; color: var(--muted); margin-left: auto; }

.radio { display: inline-flex; align-items: center; gap: 5px; margin-right: 12px; font-size: 12.5px; }
.radio input { width: auto; }
.out-line { font-size: 12px; padding: 1px 0; }

/* ----------------------------------------------------------- invoice */

.invoice-doc .invoice-head {
  display: flex; justify-content: space-between; gap: 20px; flex-wrap: wrap;
  padding: 20px; border-bottom: 1px solid var(--rule-2);
}
.inv-title { font-size: 18px; font-weight: 600; letter-spacing: -.02em; margin-bottom: 8px; }
.inv-seller { font-size: 12.5px; line-height: 1.6; color: var(--ink-2); }
.inv-meta { text-align: right; }
.inv-meta > div { margin-bottom: 5px; }
.inv-meta span { display: block; font-size: 10.5px; color: var(--muted); }
.inv-meta b { font-size: 13px; }
.invoice-parties {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 20px;
  padding: 18px 20px; border-bottom: 1px solid var(--rule-2); font-size: 12.5px; line-height: 1.6;
}
.inv-label {
  font-family: var(--mono); font-size: 10px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 4px;
}

/* Destinations in the agreed design that this phase has not built. Shown so
   the product's shape is honest, but plainly not yet clickable. */
.nav-item.is-pending { color: #5C6675; cursor: default; }
.nav-item.is-pending:hover { background: transparent; color: #5C6675; }
.nav-soon {
  margin-left: auto; font-family: var(--mono); font-size: 9px; font-style: normal;
  letter-spacing: .08em; text-transform: uppercase; color: #5C6675;
  border: 1px solid #2A3648; padding: 0 5px; border-radius: 20px;
}

/* -------------------------------------------------- reports and workforce */

.group-head {
  font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
  color: var(--muted); margin: 0 0 10px;
}
.report-tile { display: flex; flex-direction: column; gap: 5px; }
.report-blurb { font-size: 12.5px; color: var(--muted); line-height: 1.5; }

.report-bar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px;
}
.report-bar .btn-primary { margin-left: auto; }
.inline-label { font-size: 12.5px; color: var(--muted); }

table.data tfoot td {
  border-top: 1px solid var(--rule); background: var(--surface-2);
  font-size: 13px; padding: 10px 14px;
}

.leave-row {
  display: flex; align-items: flex-start; gap: 14px; flex-wrap: wrap;
  padding: 12px 15px; border-top: 1px solid var(--rule-2);
}
.leave-row:first-of-type { border-top: 0; }
.leave-main { flex: 1; min-width: 240px; }
.leave-main b { display: block; font-size: 13.5px; }
.leave-reason { display: block; font-size: 12.5px; margin-top: 3px; }
.leave-actions { display: flex; gap: 7px; align-items: center; }

.tile-link.is-warn .n { color: var(--warn); }
.tile-link.is-stop .n { color: var(--stop); }

/* --------------------------------------------------------- dashboard
   Figures first, then the lists behind them. A figure's coloured edge is
   its kind of work, and the same colour marks that work in the pills.
--------------------------------------------------------------------- */

.pill-info   { background: var(--accent-soft); color: var(--info); }
.pill-violet { background: var(--violet-soft); color: var(--violet); }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }
.stat {
  --stripe: var(--accent);
  display: flex; flex-direction: column; gap: 1px;
  padding: 13px 16px 14px;
  background: var(--surface); color: inherit; text-decoration: none;
  border: 1px solid var(--rule); border-left: 4px solid var(--stripe); border-radius: var(--radius);
}
a.stat:hover { border-color: var(--stripe); text-decoration: none; }
.stat-warn   { --stripe: var(--warn); }
.stat-violet { --stripe: var(--violet); }
.stat-ok     { --stripe: var(--ok); }
.stat-stop   { --stripe: var(--stop); }
.stat-label { font-size: 12.5px; font-weight: 500; color: var(--ink-2); }
.stat-n {
  font-family: var(--mono); font-size: 28px; font-weight: 600; line-height: 1.2;
  letter-spacing: -.02em; font-variant-numeric: tabular-nums;
}
.stat-sub { font-size: 11.5px; color: var(--muted); }

.alert-strip { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.alert-chip {
  display: inline-flex; align-items: baseline; gap: 6px;
  padding: 6px 11px; border-radius: 7px; border: 1px solid transparent;
  font-size: 12.5px; text-decoration: none;
}
.alert-chip b { font-family: var(--mono); font-weight: 600; }
.alert-chip:hover { border-color: currentColor; text-decoration: none; }
.chip-stop   { background: var(--stop-soft);   color: var(--stop); }
.chip-warn   { background: var(--warn-soft);   color: var(--warn); }
.chip-violet { background: var(--violet-soft); color: var(--violet); }

.dash-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; margin-top: 16px; }
.dash-rail { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
@media (max-width: 1080px) { .dash-grid { grid-template-columns: minmax(0, 1fr); } }

.avatar {
  display: inline-grid; place-items: center; flex: none;
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--accent); color: var(--accent-ink);
  font-size: 12px; font-weight: 600; letter-spacing: .02em;
}

.people { display: flex; flex-direction: column; }
.person { display: flex; align-items: center; gap: 11px; padding: 10px 15px; border-bottom: 1px solid var(--rule-2); }
.person:last-child { border-bottom: 0; }
.person-main { min-width: 0; }
.person-main b { display: block; font-size: 13.5px; font-weight: 600; }
.person-main b a { color: inherit; }
.person-line { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.person-line a { color: inherit; }
.person-line a:hover { color: var(--accent); }
.dot { width: 7px; height: 7px; border-radius: 50%; flex: none; background: var(--muted); }
.dot-ok     { background: var(--ok); }
.dot-warn   { background: var(--warn); }
.dot-violet { background: var(--violet); }

.att-figure { font-family: var(--mono); font-size: 30px; font-weight: 600; line-height: 1.15; letter-spacing: -.02em; }
.att-figure small { font-size: 20px; font-weight: 500; color: var(--muted); }
.meter { height: 8px; margin: 14px 0 10px; border-radius: 8px; background: var(--rule-2); overflow: hidden; }
.meter i { display: block; height: 100%; border-radius: 8px; background: var(--ok); }
.kv-rows { list-style: none; margin: 12px 0 0; padding: 0; border-top: 1px solid var(--rule-2); }
.kv-rows li { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; font-size: 12.5px; color: var(--ink-2); }
.kv-rows li b { font-family: var(--mono); font-weight: 600; color: var(--ink); }
.kv-rows .kv-rows-head { padding-top: 10px; font-size: 11px; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }

/* ------------------------------------------------ top bar: search, account */

.topsearch { position: relative; display: flex; align-items: center; }
.topsearch svg { position: absolute; left: 9px; color: var(--muted); pointer-events: none; }
.topsearch input {
  width: 280px; padding: 6px 10px 6px 30px;
  font: inherit; font-size: 13px; color: var(--ink);
  background: var(--surface-2); border: 1px solid var(--rule); border-radius: 7px;
}
.topsearch input::placeholder { color: var(--muted); }
.topsearch input:focus { outline: none; border-color: var(--accent); background: var(--surface); box-shadow: 0 0 0 3px var(--accent-soft); }
@media (max-width: 820px) { .topsearch input { width: 160px; } }

.usermenu { position: relative; }
.usermenu summary { display: block; list-style: none; cursor: pointer; border-radius: 50%; }
.usermenu summary::-webkit-details-marker { display: none; }
.usermenu[open] .avatar { box-shadow: 0 0 0 3px var(--accent-soft); }
.usermenu-panel {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 30; min-width: 210px;
  display: flex; flex-direction: column; padding: 6px;
  background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); box-shadow: var(--shadow);
}
.usermenu-who { padding: 7px 10px 10px; margin-bottom: 4px; border-bottom: 1px solid var(--rule-2); line-height: 1.35; }
.usermenu-who b { display: block; font-size: 13px; font-weight: 600; }
.usermenu-who span { font-size: 11.5px; color: var(--muted); }
.usermenu-panel a { padding: 7px 10px; border-radius: 6px; font-size: 13px; color: var(--ink-2); }
.usermenu-panel a:hover { background: var(--rule-2); color: var(--ink); text-decoration: none; }

/* A temporary password: the menus are shown, but locked until it is replaced. */
.nav-item.is-locked { opacity: .45; cursor: not-allowed; }
.nav-item.is-locked:hover { background: transparent; color: var(--sidebar-ink); }
.nav-locked-note { margin: 0 10px 10px; font-size: 11.5px; line-height: 1.4; color: var(--sidebar-ink); }
.card-attention { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* -------------------------------------------------------------- bell */

.bellmenu { position: relative; }
.bellmenu summary {
  position: relative; display: inline-grid; place-items: center; list-style: none; cursor: pointer;
  width: 30px; height: 30px; border: 1px solid var(--rule); border-radius: 50%;
  background: var(--surface); color: var(--ink-2);
}
.bellmenu summary::-webkit-details-marker { display: none; }
.bellmenu summary:hover, .bellmenu[open] summary { border-color: var(--muted); color: var(--ink); }
.bell-count {
  position: absolute; top: -5px; right: -7px; min-width: 17px; height: 17px; padding: 0 4px; box-sizing: border-box;
  border-radius: 9px; background: var(--stop); color: #fff;
  font: 600 10.5px/17px var(--font); font-style: normal; text-align: center; font-variant-numeric: tabular-nums;
}
.bellmenu-panel {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 30; width: min(360px, 90vw);
  display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); box-shadow: var(--shadow);
}
.bellmenu-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--rule-2); }
.bellmenu-head b { font-size: 13px; font-weight: 600; }
.bellmenu-head form { margin: 0; }
.bellmenu-head button { border: 0; background: none; padding: 0; font: inherit; font-size: 12px; color: var(--accent); cursor: pointer; }
.bellmenu-head button:hover { text-decoration: underline; }
.bell-list { max-height: 380px; overflow-y: auto; }
.bell-item {
  position: relative; display: grid; gap: 2px; padding: 9px 14px 9px 26px;
  border-bottom: 1px solid var(--rule-2); color: var(--ink-2); text-decoration: none;
}
.bell-item:hover { background: var(--rule-2); text-decoration: none; }
.bell-item b { font-size: 13px; font-weight: 500; color: var(--ink); }
.bell-item span { font-size: 12.5px; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.bell-item time { font-size: 11.5px; color: var(--muted); }
.bell-item.is-unread b { font-weight: 600; }
.bell-item.is-unread::before {
  content: ""; position: absolute; left: 11px; top: 15px; width: 7px; height: 7px; border-radius: 50%; background: var(--accent);
}
.bell-empty { margin: 0; padding: 18px 14px; font-size: 13px; color: var(--muted); }
.bellmenu-all { padding: 9px 14px; font-size: 12.5px; text-align: center; color: var(--accent); }

.bell-page .bell-item { padding: 12px 18px 12px 32px; }
.bell-page .bell-item:last-child { border-bottom: 0; }
.bell-page .bell-item.is-unread::before { left: 15px; top: 18px; }
.bell-page .bell-item span { display: block; }

/* Admin → Notifications: the template editor. */
.email-preview { display: block; width: 100%; height: 600px; border: 0; border-top: 1px solid var(--rule); background: #fff; }
.notice-preview { padding: 12px 14px; border: 1px solid var(--rule); border-radius: var(--radius); background: var(--surface); }
.notice-preview p { margin: 4px 0 0; color: var(--ink-2); }
.placeholder-list { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 0; padding: 0; list-style: none; }
.placeholder-list code { padding: 2px 6px; border-radius: 5px; background: var(--rule-2); font-size: 12px; }
.template-body { min-height: 90px; }
.template-body.mono { min-height: 420px; font-size: 12.5px; line-height: 1.5; }

/* One-line person rows truncate the tail, never the name or the ticket. */
.person-main { flex: 1; }
.person-line.is-single { flex-wrap: nowrap; }
.person-trail { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Codes and ticket numbers read as one token; the table scrolls instead. */
table.data td.mono { white-space: nowrap; }
.person-line.is-single > a, .person-line.is-single > .mono { flex: none; white-space: nowrap; }

.nav-heading {
  margin: 16px 10px 4px; font-size: 10.5px; font-weight: 600;
  letter-spacing: .08em; text-transform: uppercase; color: var(--sidebar-ink); opacity: .75;
}

/* ------------------------------------------------------------ audit log */

.audit-change summary { cursor: pointer; font-size: 12px; color: var(--accent); }
.audit-cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 6px; min-width: 360px; }
.audit-cols span { display: block; font-size: 10.5px; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.audit-json {
  margin: 2px 0 0; padding: 8px 10px; max-height: 260px; overflow: auto;
  font-family: var(--mono); font-size: 11.5px; white-space: pre-wrap; word-break: break-word;
  background: var(--surface-2); border: 1px solid var(--rule-2); border-radius: 6px; color: var(--ink-2);
}

/* ----------------------------------------------------------- follow-ups */

.followup-form { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.followup-form :where(select, input) { padding: 5px 8px; font-size: 12.5px; border-radius: 6px; }
.followup-form input[type="text"] { min-width: 170px; }
.followup-form input.is-overdue { border-color: var(--stop); color: var(--stop); }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }

/* ------------------------------------------- model troubleshooting setup */

.symptom { padding: 12px 15px; border-top: 1px solid var(--rule-2); }
.symptom-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.symptom-order {
  display: inline-grid; place-items: center; flex: none; width: 24px; height: 24px;
  border-radius: 50%; background: var(--rule-2); color: var(--ink-2); font-size: 11.5px;
}
.symptom-title { flex: 1; min-width: 220px; }
.symptom-title b { display: block; font-size: 14px; font-weight: 600; }
.symptom.is-inactive .symptom-title b, .step.is-inactive .step-body { color: var(--muted); }
.inline-actions { display: flex; gap: 4px; }
.inline-edit summary { margin-top: 6px; cursor: pointer; font-size: 12.5px; color: var(--accent); }
.inline-edit form { margin-top: 8px; }
.steps { margin: 10px 0 0; padding-left: 58px; }
.step { margin-bottom: 8px; }
.step::marker { color: var(--muted); font-family: var(--mono); font-size: 12px; }
.step-row {
  display: flex; align-items: flex-start; gap: 12px; padding: 8px 10px;
  background: var(--surface-2); border: 1px solid var(--rule-2); border-radius: 7px;
}
.step-body { flex: 1; min-width: 0; font-size: 13px; }
.step-body p { margin: 3px 0 0; line-height: 1.5; color: var(--ink-2); }
.step-body .step-ta { margin-top: 6px; padding-top: 5px; border-top: 1px dashed var(--rule); }
.step-add, .steps-empty { margin-left: 34px; }
.symptom-new { border-top: 1px solid var(--rule); }

/* ------------------------------------------------------------ customer PIN */

.pin-display { margin: 16px 0; font-size: 38px; font-weight: 600; letter-spacing: .25em; color: var(--ink); text-align: center; }

.locked-value { margin: 6px 0 0; font-size: 14px; color: var(--ink); }
