/* Quantum One web UI. Visual language from the QuantumOne ERP demo shell:
   dark aubergine rail, violet→cyan accent, Outfit headings, Source Sans 3 body, IBM Plex Mono codes. */
:root {
  color-scheme: light;
  --ink: #241C2E;
  --ink-2: #4A4458;
  --mute: #56697A;
  --bg: #F6F4F9;
  --surface: #FFFFFF;
  --surface-2: #FAF9FC;
  --line: #DDD6E4;
  --line-soft: #EDE9F2;
  --rail: #241C2E;
  --rail-line: #3A2E48;
  --rail-text: #DDD6E4;
  --rail-mute: #B9ADC6;
  --violet: #9C44DE;
  --violet-deep: #7A2FB8;
  --violet-soft: #F1E7FB;
  --cyan: #04CEEC;
  --cyan-deep: #0A8FA6;
  --ok: #157F5B;   --ok-bg: #E3F4EC;
  --warn: #9A5E06; --warn-bg: #FBF0DC;
  --crit: #B3261E; --crit-bg: #FBE7E5;
  --info: #0A4D8C; --info-bg: #E7EFF7;
  --radius: 6px;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;
  --display: "Outfit", "Source Sans 3", system-ui, sans-serif;
}
* { box-sizing: border-box }
html, body { margin: 0 }
body {
  font: 15px/1.45 "Source Sans 3", system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink); background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--violet-deep) }
a:hover { color: var(--ink) }
h1, h2, h3 { font-family: var(--display); font-weight: 600; letter-spacing: -.01em; margin: 0 }
.mono, code { font-family: var(--mono); font-variant-numeric: tabular-nums }
.skip { position: absolute; left: -999px; top: 8px; background: #fff; padding: 8px 12px; z-index: 10 }
.skip:focus { left: 8px }
:focus-visible { outline: 2px solid var(--violet); outline-offset: 2px }

/* ---------- shell ---------- */
.app { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh }
.rail {
  background: var(--rail); color: #fff; display: flex; flex-direction: column;
  padding: 16px 12px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.rail .logo { padding: 4px 6px 2px; margin: 0 2px 6px; line-height: 0 }
.rail .logo img { width: 100%; height: auto }
.rail .tagline { font: 600 11.5px/1.3 var(--display); letter-spacing: .06em; text-transform: uppercase; color: var(--rail-mute); padding: 0 10px 10px }
.rail .org { font-size: 12px; color: var(--rail-mute); padding: 0 10px 10px; border-bottom: 1px solid var(--rail-line); margin-bottom: 4px }
.rail .org b { display: block; color: #fff; font-size: 14px }
.rail .sec { font: 600 11px/1 var(--display); text-transform: uppercase; letter-spacing: .05em; color: var(--rail-mute); padding: 14px 10px 6px }
/* Collapsible module groups: the header is a button; a closed group hides its links. */
.rail button.sec { display: flex; align-items: center; justify-content: space-between; width: 100%; background: none; border: 0; border-radius: 6px; cursor: pointer; text-align: left; margin: 0 }
.rail button.sec:hover { color: #fff }
.rail button.sec:focus-visible { outline: 2px solid #fff; outline-offset: -2px }
.rail button.sec .chev { flex: none; transition: transform .15s ease; opacity: .8 }
.rail button.sec[aria-expanded="false"] .chev { transform: rotate(-90deg) }
.rail .nav-items[hidden] { display: none }
@media (prefers-reduced-motion: reduce) { .rail button.sec .chev { transition: none } }
.rail a.nav {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 4px;
  color: var(--rail-text); text-decoration: none; font-size: 14px;
}
.rail a.nav svg { flex: none }
.rail a.nav:hover { background: #2E2438; color: #fff }
.rail a.nav[aria-current="page"] { background: linear-gradient(90deg, var(--violet), var(--cyan)); color: #fff; font-weight: 600 }
.rail a.nav:focus-visible { outline: 2px solid #fff; outline-offset: -2px }
.rail .me { margin-top: auto; border-top: 1px solid var(--rail-line); padding: 12px 8px 0; display: flex; gap: 10px; align-items: center; font-size: 12px; color: var(--rail-mute) }
.rail .me i { width: 32px; height: 32px; border-radius: 50%; background: #A864F9; color: #fff; display: grid; place-items: center; font-style: normal; font-weight: 600; flex: none }
.rail .me b { display: block; color: #fff; font-size: 13px }
.rail .me form { margin: 0 }
.rail .me button { background: none; border: 0; padding: 0; color: var(--rail-text); font: inherit; font-size: 12px; text-decoration: underline; cursor: pointer }

.main { display: flex; flex-direction: column; min-width: 0 }
.topbar {
  height: 60px; flex: none; background: var(--surface); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 16px; padding: 0 24px; position: sticky; top: 0; z-index: 5;
}
.crumb { font-size: 13px; color: var(--mute); white-space: nowrap }
.crumb b { color: var(--ink) }
.scan {
  flex: 1; max-width: 540px; display: flex; align-items: center; gap: 10px;
  border: 1.5px solid #B9C7D2; border-radius: 4px; padding: 0 12px; height: 40px; color: var(--mute); margin: 0;
}
.scan:focus-within { border-color: var(--violet); outline: 3px solid #D9C3F5 }
.scan input, .scan input:not([type]) { border: 0; outline: 0; padding: 0; box-shadow: none; border-radius: 0; flex: 1; font: 14px var(--mono); background: transparent; color: var(--ink); min-width: 0 }
.topbar .who { margin-left: auto; font-size: 13px; color: var(--mute); white-space: nowrap }
.content { padding: 24px; max-width: 1320px; width: 100% }

/* ---------- page furniture ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap }
.page-head h1 { font-size: 26px }
.page-head p { margin: 4px 0 0; color: var(--mute); max-width: 72ch }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 18px }
.card > h2, .card-head { padding: 12px 16px; font-size: 15px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 12px }
.card-head h2 { font-size: 15px }
.card-body { padding: 16px }
.note { padding: 12px 16px; font-size: 13px; color: var(--mute); border-top: 1px solid var(--line); background: var(--surface-2); margin: 0 }
.note b { color: var(--ink) }
.grid { display: grid; gap: 18px }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)) }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)) }
.grid-main-side { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) }
.grid-label-preview { grid-template-columns: minmax(0, 1fr) 340px }
.split { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 18px; align-items: start }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 18px }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px }
.kpi span { display: block; font-size: 12.5px; color: var(--mute) }
.kpi b { display: block; font: 600 24px/1.2 var(--display); margin-top: 4px; font-variant-numeric: tabular-nums }
.kpi small { color: var(--mute) }
.kpi.alert b { color: var(--crit) }
a.kpi { color: inherit; text-decoration: none }
a.kpi:hover { border-color: var(--violet) }
.empty { padding: 28px 16px; text-align: center; color: var(--mute) }
.muted { color: var(--mute) }
.right { text-align: right }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto }
table.data { width: 100%; border-collapse: collapse; font-size: 14px }
table.data th { text-align: left; font-weight: 600; font-size: 12.5px; color: var(--mute); padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--surface) }
table.data td { padding: 10px 12px; border-bottom: 1px solid var(--line-soft); vertical-align: middle }
table.data tbody tr:last-child td { border-bottom: 0 }
table.data tbody tr:hover { background: var(--surface-2) }
table.data .num, table.data th.num { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums }
table.data tr.hit { background: #E6F9FD }
table.data .sub { display: block; font-size: 12px; color: var(--mute); font-family: var(--mono) }
table.kv td:first-child { color: var(--mute); width: 200px }

.tag { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 3px; white-space: nowrap }
.t-ok { background: var(--ok-bg); color: var(--ok) }
.t-warn { background: var(--warn-bg); color: var(--warn) }
.t-crit { background: var(--crit-bg); color: var(--crit) }
.t-info { background: var(--info-bg); color: var(--info) }
.t-mute { background: var(--line-soft); color: var(--ink-2) }

/* ---------- forms & buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px; font: 600 14px/1 "Source Sans 3", sans-serif;
  padding: 10px 14px; border-radius: 4px; border: 1px solid var(--line); background: var(--surface);
  color: var(--ink); cursor: pointer; text-decoration: none; min-height: 40px;
}
.btn:hover { background: var(--surface-2); color: var(--ink) }
.btn-primary { background: linear-gradient(100deg, var(--violet), var(--cyan-deep)); border-color: transparent; color: #fff }
.btn-primary:hover { background: linear-gradient(100deg, var(--violet-deep), var(--cyan-deep)); color: #fff }
.btn-danger { border-color: #E8B4AF; color: var(--crit) }
.btn-sm { min-height: 32px; padding: 6px 10px; font-size: 13px }
.inline { display: inline }
form.stack, .stack { display: grid; gap: 14px }
.field { display: flex; flex-direction: column; gap: 5px }
.field label, .label { font-size: 13px; font-weight: 600; color: var(--ink-2) }
.field .hint { font-size: 12.5px; color: var(--mute) }
fieldset.field { border: 0; padding: 0; margin: 0; min-width: 0 }
fieldset.field legend { font-size: 13px; font-weight: 600; margin-bottom: 6px; padding: 0 }
input:not([type]), input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=datetime-local], input[type=search], input[type=file], input[type=tel], input[type=url], input[type=month], input[type=time], select, textarea {
  font: inherit; font-size: 14px; padding: 9px 11px; border: 1px solid #B9C7D2; border-radius: 4px; background: #fff; color: var(--ink); width: 100%; min-height: 40px;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--violet); box-shadow: 0 0 0 3px #E6D6F7 }
input.qty { width: 96px; text-align: right; font-family: var(--mono) }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(180px, 100%), 1fr)); gap: 12px }
.form-row > * { min-width: 0 }
.filters { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; padding: 12px 16px; border-bottom: 1px solid var(--line) }
.filters .field { min-width: min(160px, 100%) }
.error { color: var(--crit); font-size: 13px }
.flash { border-radius: var(--radius); padding: 12px 14px; margin-bottom: 16px; border: 1px solid }
.flash-ok { background: var(--ok-bg); border-color: #B8E0CC; color: #0F5E43 }
.flash-err { background: var(--crit-bg); border-color: #F1C2BD; color: #8A1C16 }
.flash ul { margin: 6px 0 0; padding-left: 18px }

.menu-toggle { position: absolute; opacity: 0; width: 1px; height: 1px }
.menu-btn { display: none; color: #fff; border: 1px solid var(--rail-line); border-radius: 4px; padding: 7px 12px; font-weight: 600; cursor: pointer }
td.mono { white-space: nowrap }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); padding: 0 8px; flex-wrap: wrap }
.tabs a { padding: 11px 14px; text-decoration: none; color: var(--mute); border-bottom: 2px solid transparent; margin-bottom: -1px; font-size: 14px }
.tabs a[aria-current="page"] { color: var(--ink); font-weight: 600; border-bottom-color: var(--violet) }

.list-nav { list-style: none; margin: 0; padding: 6px }
.list-nav a { display: flex; justify-content: space-between; gap: 8px; padding: 9px 10px; border-radius: 4px; text-decoration: none; color: var(--ink) }
.list-nav a:hover { background: var(--surface-2) }
.list-nav a[aria-current="true"] { background: var(--ink); color: #fff }
.list-nav small { display: block; color: var(--mute); font-size: 12px }
.list-nav a[aria-current="true"] small { color: var(--rail-mute) }

.bar-track { height: 8px; background: var(--line-soft); border-radius: 4px; overflow: hidden; min-width: 80px }
.bar-fill { height: 100%; background: linear-gradient(90deg, var(--violet), var(--cyan)) }
.bar-fill.over { background: var(--crit) }

.pagination { display: flex; gap: 6px; padding: 12px 16px; align-items: center; justify-content: flex-end; font-size: 13px }

/* ---------- labels ---------- */
.label-preview { width: 288px; height: 144px; background: #fff; border: 1px solid #C3CED6; padding: 8px 10px; display: flex; flex-direction: column; margin: 0 auto 12px }
.label-preview .ldesc { font-size: 14px; font-weight: 700; line-height: 1.15 }
.label-preview .lrow { display: flex; justify-content: space-between; font: 9.5px var(--mono); color: #333; margin-top: 3px }
.label-preview .lbar { flex: 1; display: flex; align-items: center; justify-content: center; padding: 3px 0 }
.label-preview .lbar svg { max-width: 100%; height: 38px }
.label-preview .leq { text-align: center; font: 600 11px var(--mono); letter-spacing: .14em }
.label-preview .lminmax { display: flex; justify-content: space-between; border-top: 1px solid #DDE4E9; margin-top: 4px; padding-top: 3px; font: 10px var(--mono) }
pre.zpl { background: var(--ink); color: #C9E6F0; font: 11px/1.5 var(--mono); padding: 10px; border-radius: 4px; overflow-x: auto; margin: 0 }

/* ---------- sign-in ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: linear-gradient(160deg, #F6F4F9 0%, #EEE6F8 55%, #E3F7FB 100%) }
.auth-card { width: 100%; max-width: 420px; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 28px; box-shadow: 0 10px 40px rgba(36, 28, 46, .08) }
.auth-card img { width: 220px; height: auto; display: block; margin-bottom: 18px }
.auth-card h1 { font-size: 22px; margin-bottom: 6px }
.auth-card p.lead { color: var(--mute); margin: 0 0 18px }
.qr svg { width: 192px; height: 192px; display: block; margin: 8px auto }
.codes { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; font-family: var(--mono); background: var(--surface-2); border: 1px solid var(--line); padding: 12px; border-radius: 4px }

@media (max-width: 960px) {
  .app { grid-template-columns: 1fr }
  .rail { position: static; height: auto; display: grid; grid-template-columns: 1fr auto; align-items: center; padding: 10px 12px }
  .rail .logo { margin: 0; max-width: 190px }
  .rail .tagline, .rail .org, .rail nav, .rail .me { display: none; grid-column: 1 / -1 }
  .menu-btn { display: inline-block }
  .menu-toggle:checked ~ .tagline, .menu-toggle:checked ~ .org, .menu-toggle:checked ~ nav { display: block }
  .menu-toggle:checked ~ .me { display: flex }
  .menu-toggle:focus-visible + .menu-btn { outline: 2px solid var(--cyan) }
  .app { grid-template-columns: minmax(0, 1fr) }
  .split, .grid-2, .grid-3, .grid-main-side, .grid-label-preview { grid-template-columns: minmax(0, 1fr) }
  .topbar { height: auto; flex-wrap: wrap; padding: 10px 12px }
  .crumb, .topbar .who { display: none }
  .scan { max-width: none; width: 100% }
  .content { padding: 14px }
}
@media print {
  .rail, .topbar, .no-print { display: none !important }
  .app { display: block }
  .content { padding: 0 }
}

/* CRM pipeline board */
.kanban { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px }
.kanban-col { margin: 0 }
.kanban-col h2 { display: flex; justify-content: space-between; gap: 8px; font-size: 14px }
.kanban-card { display: grid; gap: 2px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; color: var(--ink); background: var(--surface) }
.kanban-card:hover { border-color: var(--violet) }
.kanban-card span { font-size: 12.5px; color: var(--mute) }
.timeline { list-style: none; margin: 0; padding: 0 }
.timeline li { padding: 10px 16px; border-bottom: 1px solid var(--line-soft); display: grid; grid-template-columns: 110px 1fr auto; gap: 10px }
.timeline li time { color: var(--mute); font-size: 12.5px }
@media (max-width: 960px) { .kanban { grid-template-columns: minmax(0, 1fr) } .timeline li { grid-template-columns: minmax(0, 1fr) } }
/* Grid children may shrink below their content, so wide tables scroll inside .table-wrap instead of widening the page. */
.app > *, .split > *, .grid > *, .kanban > *, .kpis > *, .stack > * { min-width: 0 }
/* PO intake: the email as received, beside the order being built from it */
pre.email { white-space: pre-wrap; word-break: break-word; font: 12px/1.5 var(--mono); background: var(--surface-2); border: 1px solid var(--line); border-radius: 4px; padding: 12px; margin: 0; max-height: 640px; overflow: auto }
tr.unmatched td { background: var(--warn-bg) }
.flash-warn { background: var(--warn-bg); border-color: #EBD3A4; color: var(--warn) }
/* Overview */
.bars { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 6px; height: 160px; align-items: end }
.bar { display: flex; flex-direction: column; justify-content: flex-end; height: 100%; text-align: center }
.bar span { display: block; background: var(--violet); border-radius: 3px 3px 0 0; min-height: 2px }
.bar small { font-size: 11px; color: var(--mute); margin-top: 4px }
.meter { height: 6px; background: var(--surface-2); border-radius: 3px; margin-top: 10px; overflow: hidden }
.meter span { display: block; height: 100%; background: var(--ok) }
.section-title { font: 600 15px/1.3 var(--display); margin: 22px 0 10px }
/* Narrow screens: form controls and long codes never push the page wider than the screen. */
input, select, textarea { max-width: 100% }
/* Inside a scrolling table, controls keep a usable width; the table scrolls instead. */
.table-wrap input, .table-wrap select, .table-wrap textarea { max-width: none }
.table-wrap select { min-width: 9rem }
.sub, code { overflow-wrap: anywhere }
