/* HV RMS base styles: tokens, theme and the shared controls (docs/design-direction.md). One style per kind of control. */
:root {
  color-scheme: light dark;
  --bg: #fafafa; --surface: #ffffff; --line: #ececec; --line-strong: #dedede; --line-input: #8e8e96; --hover: #f6f6f6;
  --text: #18181b; --text-2: #52525b; --muted: #6e6e77;
  --accent: #0b7a73; --accent-bg: #e9f6f5; --accent-hover: #09645e; --on-accent: #ffffff; --seg-on: #ffffff;
  --green: #15803d; --green-bg: #eaf7ef; --amber: #b45309; --amber-bg: #fef5e6; --red: #b91c1c; --red-bg: #fdf0f0;
  --violet: #6d28d9; --violet-bg: #f3effd;
  /* warehouse stages (reserved, allocated, prepared, booked out, checked in): grey, yellow, green, light teal, sky blue; used only for stages
     (red is kept for what is wrong: late, damaged, lost).
     Pastel backgrounds with dark text (4.5:1 or more); -fill = the softer colour for progress bars (the numbers beside them carry the value) */
  --st-res: #6e6e77; --st-res-bg: #f3f3f4; --st-al: #876b00; --st-al-bg: #fcf5d6; --st-pr: #15803d; --st-pr-bg: #eaf7ef;
  --st-out: #0f766e; --st-out-bg: #e6f6f4; --st-in: #0b6a9e; --st-in-bg: #e8f4fa;
  --st-al-fill: #e3c55a; --st-pr-fill: #7cc79a; --st-out-fill: #7fcfc6; --st-in-fill: #82c3e3; --accent-fill: #5bb8b0;
  --late-edge: #ef9b95; --soon-edge: #f2c46b;   /* the dashboard card's left edge: late / due soon (the pill says which in words) */
  --inv-bg: #18181b; --inv-text: #fafafa; --inv-line: rgba(255,255,255,.22); --inv-muted: rgba(255,255,255,.6);   /* dark bars: toasts, bulk actions */
  --font: Archivo, system-ui, sans-serif; --mono: "JetBrains Mono", ui-monospace, monospace; --r: 8px;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 8px 24px rgba(0,0,0,.06);
}
:root[data-theme="light"] { color-scheme: light; }
/* dark theme: follows the system unless the user picked Light; data-theme="dark" forces it */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0f0f10; --surface: #161618; --line: #232326; --line-strong: #2e2e32; --line-input: #6a6a72; --hover: #1d1d20;
    --text: #ededef; --text-2: #b4b4bb; --muted: #8e8e97; --accent: #2dd4bf; --accent-bg: #10302d; --accent-hover: #5eead4; --on-accent: #042f2e; --seg-on: #34343a;
    --green: #4ade80; --green-bg: #0f2a1a; --amber: #fbbf24; --amber-bg: #2d2310; --red: #f87171; --red-bg: #321515;
    --violet: #a78bfa; --violet-bg: #231b3a;
    --st-res: #a1a1aa; --st-res-bg: #232327; --st-al: #fde047; --st-al-bg: #2a2608; --st-pr: #4ade80; --st-pr-bg: #0f2a1a;
    --st-out: #5eead4; --st-out-bg: #10302d; --st-in: #7dd3fc; --st-in-bg: #0f2a3a;
    --st-al-fill: var(--st-al); --st-pr-fill: var(--st-pr); --st-out-fill: var(--st-out); --st-in-fill: var(--st-in); --accent-fill: var(--accent); --late-edge: var(--red); --soon-edge: var(--amber);
    --inv-bg: #2c2c31; --inv-text: #ededef; --inv-line: rgba(255,255,255,.2); --inv-muted: rgba(255,255,255,.55);
    --shadow: 0 8px 24px rgba(0,0,0,.4);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f0f10; --surface: #161618; --line: #232326; --line-strong: #2e2e32; --line-input: #6a6a72; --hover: #1d1d20;
  --text: #ededef; --text-2: #b4b4bb; --muted: #8e8e97; --accent: #2dd4bf; --accent-bg: #10302d; --accent-hover: #5eead4; --on-accent: #042f2e; --seg-on: #34343a;
  --green: #4ade80; --green-bg: #0f2a1a; --amber: #fbbf24; --amber-bg: #2d2310; --red: #f87171; --red-bg: #321515;
  --violet: #a78bfa; --violet-bg: #231b3a;
  --st-res: #a1a1aa; --st-res-bg: #232327; --st-al: #fde047; --st-al-bg: #2a2608; --st-pr: #4ade80; --st-pr-bg: #0f2a1a;
  --st-out: #5eead4; --st-out-bg: #10302d; --st-in: #7dd3fc; --st-in-bg: #0f2a3a;
  --st-al-fill: var(--st-al); --st-pr-fill: var(--st-pr); --st-out-fill: var(--st-out); --st-in-fill: var(--st-in); --accent-fill: var(--accent); --late-edge: var(--red); --soon-edge: var(--amber);
  --inv-bg: #2c2c31; --inv-text: #ededef; --inv-line: rgba(255,255,255,.2); --inv-muted: rgba(255,255,255,.55);
  --shadow: 0 8px 24px rgba(0,0,0,.4);
}
/* the logo is dark grey on transparent: lighten it on dark surfaces */
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .logo-img { filter: invert(.88); } }
:root[data-theme="dark"] .logo-img { filter: invert(.88); }
* { box-sizing: border-box; }
[hidden] { display: none !important; }   /* hidden wins over a component's own display */
html, body { margin: 0; }
html { scrollbar-color: var(--line-strong) transparent; }
body { background: var(--bg); color: var(--text); font: 13px/1.45 var(--font); -webkit-font-smoothing: antialiased; font-feature-settings: "tnum" 1; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
input[type=checkbox], input[type=radio] { accent-color: var(--accent); }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
/* the page area and other script-only focus targets (tabindex -1) take focus after navigation for screen readers: no ring around them */
[tabindex="-1"]:focus, [tabindex="-1"]:focus-visible { outline: none; }

/* pills (status) and small badges: one definition for the workspace and the job screen */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 500; white-space: nowrap; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.p-ok { background: var(--green-bg); color: var(--green); } .p-low, .p-wh { background: var(--amber-bg); color: var(--amber); }
.p-out { background: var(--red-bg); color: var(--red); } .p-na, .p-incl { background: var(--hover); color: var(--muted); }
.p-quote, .p-note { background: var(--accent-bg); color: var(--accent); } .p-sub { background: var(--violet-bg); color: var(--violet); }
.p-na::before, .p-incl::before, .p-note::before, .p-wh::before { display: none; }
/* invoiced (an issued invoice): a document mark instead of the dot; links to the invoice */
.p-inv { background: var(--accent-bg); color: var(--accent); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 35%, transparent); }
a.invpill { text-decoration: none; } a.invpill:hover { filter: brightness(.96); text-decoration: underline; }
/* warehouse stage pills (js/core.js stagePill); a half dot = only part of it done; reserved: a hollow dot (nothing physical yet) */
.s-res { background: var(--st-res-bg); color: var(--st-res); --stc: var(--st-res); } .s-al { background: var(--st-al-bg); color: var(--st-al); --stc: var(--st-al); }
.s-pr { background: var(--st-pr-bg); color: var(--st-pr); --stc: var(--st-pr); } .s-out { background: var(--st-out-bg); color: var(--st-out); --stc: var(--st-out); }
.s-in { background: var(--st-in-bg); color: var(--st-in); --stc: var(--st-in); }
.pill.s-res::before { background: transparent; box-shadow: inset 0 0 0 1.5px currentColor; }
.pill.pt::before { background: linear-gradient(90deg, currentColor 50%, transparent 50%); box-shadow: inset 0 0 0 1.5px currentColor; }
/* part done: a ring in the stage colour on a plain background, so it stands apart from the filled 'all done' pill at a glance */
.pill.pt { background: color-mix(in srgb, var(--surface) 55%, transparent); box-shadow: inset 0 0 0 1px color-mix(in srgb, currentColor 40%, transparent); }
/* the test system: a small pill floating at the bottom right of every page (the full text on hover) */
.envbadge { position: fixed; right: 14px; bottom: 14px; z-index: 900; display: inline-block; padding: 3px 10px; border-radius: 999px; background: var(--amber-bg); color: var(--amber);
  border: 1px solid color-mix(in srgb, var(--amber) 30%, transparent); box-shadow: 0 2px 8px rgba(0,0,0,.08); font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; cursor: default; }
.envbadge[hidden] { display: none; }
@media print { .envbadge { display: none; } }
/* clear of bottom action bars (warehouse Book out, selected lines); on a phone small, bottom left, and never in the way of a tap */
body:has(.whbar, .whbulk, .bulkbar) .envbadge { bottom: calc(76px + env(safe-area-inset-bottom)); }
@media (max-width: 640px) { .envbadge { right: auto; left: 8px; padding: 1px 8px; opacity: .85; pointer-events: none; } }
@media (max-width: 640px) { body:has(.whbar, .whbulk, .bulkbar) .envbadge { bottom: calc(132px + env(safe-area-inset-bottom)); } }
body:has(#view .chat) .envbadge, body:has(#view .agtarget) .envbadge, body:has(#view .askbox) .envbadge { bottom: calc(78px + env(safe-area-inset-bottom)); }   /* above the chat's message box and the Agent's create bar */ body.hvwall .envbadge { display: none; }

/* buttons: .btn, .btn.sm (job screen and tables), .btn.primary (teal), .btn.danger */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 32px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: var(--r);
  background: var(--surface); color: var(--text); font-weight: 500; line-height: 1.2; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: var(--text-2); }
.btn.sm, .jv .btn { min-height: 28px; padding: 0 10px; border-radius: 6px; font-size: 12.5px; }
/* primary: light teal with teal text, like the menu's highlighted item (the dark bulk bars keep solid teal) */
.btn.primary { background: var(--accent-bg); border-color: transparent; color: var(--accent); font-weight: 500; }
.btn.primary:hover { background: color-mix(in srgb, var(--accent) 16%, var(--accent-bg)); border-color: transparent; }
.btn.danger { color: var(--red); } .btn.danger:hover { border-color: var(--red); background: var(--red-bg); }
.btn.primary.danger { background: var(--red-bg); border-color: transparent; color: var(--red); font-weight: 500; }   /* pastel like .btn.primary: no solid colour buttons */
.btn.primary.danger:hover { background: color-mix(in srgb, var(--red) 14%, var(--red-bg)); border-color: transparent; }
.btn:disabled, .btn[disabled] { opacity: .55; cursor: default; pointer-events: none; }
/* text-style action inside tables and cards (remove ×, retry, Cancel) */
.lnk { border: 0; background: none; padding: 2px 4px; border-radius: 4px; color: var(--accent); font-weight: 500; text-decoration: none; }
.lnk:hover { background: var(--hover); }
.lnk:disabled { color: var(--muted); cursor: default; }

/* segmented control: one choice of a few (also used as toggles, e.g. departments) */
/* .seg2: alias kept for the dashboard/warehouse pages of other branches until they move to .seg */
.seg, .seg2 { display: inline-flex; flex-wrap: wrap; background: var(--hover); border-radius: var(--r); padding: 2px; gap: 1px; }
.seg button, .seg2 button { border: 0; background: transparent; padding: 5px 11px; border-radius: 6px; color: var(--text-2); font-weight: 500; white-space: nowrap; }
.seg button:hover, .seg2 button:hover { color: var(--text); }
.seg button.on, .seg2 button.on { background: var(--seg-on); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.12), 0 0 0 1px var(--line); }
.seg.sm button { padding: 3px 9px; font-size: 12.5px; }
.field > .seg { justify-self: start; }

/* text boxes: one look everywhere (not tick boxes or radio buttons inside a form field) (workspace forms, tables, the job drawer and panels) */
.input, .sel, .field input:where(:not([type=checkbox], [type=radio])), .field select, .field textarea, .jv .fd input, .jv .fd select, .jv .fd textarea, .jv .supin, .jv .substin, .jv .panel textarea,
.jv .apreply textarea, .jv .subcostrow input, .tfield {
  min-height: 34px; border: 1px solid var(--line-input); border-radius: var(--r); padding: 7px 10px; background: var(--surface); color: var(--text); }
.input:focus, .sel:focus, .field input:where(:not([type=checkbox], [type=radio])):focus, .field select:focus, .field textarea:focus, .jv .fd input:focus, .jv .fd select:focus, .jv .fd textarea:focus,
.jv .supin:focus, .jv .substin:focus, .jv .panel textarea:focus, .jv .apreply textarea:focus, .jv .subcostrow input:focus, .tfield:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg); }
.input:disabled, .sel:disabled, .field input:where(:not([type=checkbox], [type=radio])):disabled, .field select:disabled, .field textarea:disabled { color: var(--text-2); background: var(--hover); }
textarea.input, .field textarea { resize: vertical; min-height: 60px; }
::placeholder { color: var(--muted); opacity: 1; }
.field { display: grid; gap: 5px; margin-bottom: 12px; }
.field > span { font-size: 12.5px; font-weight: 500; color: var(--text-2); }
.field input:where(:not([type=checkbox], [type=radio])), .field select, .field textarea { width: 100%; }
/* drop-downs: one look in every browser (Safari's native up/down button and grey pill replaced by the text-box look + a thin chevron).
   :where() keeps it at zero weight, so each place's own box (.input, .sel, table cells) still decides size and border. */
:where(select:not([multiple]):not([size])) {
  -webkit-appearance: none; appearance: none; min-height: 34px; border: 1px solid var(--line-strong); border-radius: var(--r); background-color: var(--surface);
  padding: 7px 10px; color: var(--text); cursor: pointer; }
select:not([multiple]):not([size]) {
  -webkit-appearance: none; appearance: none; padding-right: 30px !important; text-overflow: ellipsis;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5 6 7.5 9 4.5' fill='none' stroke='%238a8a93' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 12px 12px; }
select:not([multiple]):not([size]):hover:not(:disabled) { border-color: var(--muted); }
select:not([multiple]):not([size]):focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg); }
/* inline-edit cell: no box until hovered or focused (order grid, invoice lines) */
.cell { width: 100%; border: 0; border-radius: 5px; background: transparent; padding: 4px; outline: none; }
.cell.r, .jv .cell { text-align: right; }
.cell:hover { box-shadow: inset 0 0 0 1px var(--line-strong); background: var(--surface); }
.cell:focus { box-shadow: inset 0 0 0 1.5px var(--accent); background: var(--surface); }
/* time: a text box that takes 9, 930, 9.30 or 09:30 (core.js normTime) */
.tfield, .field .tfield { width: 96px; font-family: var(--mono); font-size: 12.5px; text-align: center; }

/* date field: one control for every date (core.js dateField), opens the calendar used by the job's date picker */
.datebtn { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 34px; text-align: left; border: 1px solid var(--line-strong); border-radius: var(--r); padding: 6px 10px;
  background: var(--surface); color: var(--text); font-weight: 500; }
.datebtn:hover:not(:disabled) { border-color: var(--accent); } .datebtn svg { color: var(--muted); flex: none; } .datebtn .arr { color: var(--muted); }
.datebtn.empty { color: var(--muted); font-weight: 400; border-style: dashed; }
.datebtn:disabled { color: var(--text-2); background: var(--hover); cursor: default; }
.datebtn.dfield { width: auto; min-width: 150px; } .field .datebtn.dfield { width: 100%; }
td .datebtn.dfield { min-height: 30px; padding: 4px 8px; min-width: 140px; }

.note { padding: 9px 11px; border-radius: 8px; font-size: 12.5px; background: var(--hover); color: var(--text-2); }
.note.err { background: var(--red-bg); color: var(--red); } .note.ok { background: var(--green-bg); color: var(--green); }
/* sign-in pages */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth .card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 26px 24px; }
.auth .logo { display: block; height: 34px; margin-bottom: 18px; }
.auth h1 { margin: 0 0 4px; font-size: 18px; } .auth p.sub { margin: 0 0 18px; color: var(--muted); }
.auth .btn.primary { width: 100%; min-height: 38px; }
.auth .code { font-family: var(--mono); font-size: 22px; letter-spacing: .3em; text-align: center; }
.auth .qr { display: grid; place-items: center; padding: 12px; background: #fff; border-radius: 8px; border: 1px solid var(--line); margin: 6px 0 10px; }
.auth .secret { font-family: var(--mono); font-size: 12px; word-break: break-all; color: var(--text-2); }
.auth ol { padding-left: 18px; color: var(--text-2); margin: 0 0 12px; } .auth li { margin-bottom: 4px; }
.auth .foot { margin-top: 14px; text-align: center; color: var(--muted); font-size: 12px; }
