/* Tokens and rules from docs/07-ui-style-guide.md. Do not add colours or fonts that are not there. */

@font-face { font-family: "Inter"; font-weight: 400; font-display: block; src: url("../fonts/inter-400.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-weight: 500; font-display: block; src: url("../fonts/inter-500.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-weight: 600; font-display: block; src: url("../fonts/inter-600.woff2") format("woff2"); }

:root {
  --canvas:#F5F6F8; --surface:#FFFFFF; --border:#E2E5E9; --line:#EDEFF2; --table-head:#F8F9FB;
  --text:#1D2430; --text-muted:#636D7A; --text-subtle:#98A1AD;
  --accent:#2457A6; --accent-soft:#E9EFF9;
  --sidebar:#1B2430; --sidebar-active:#2C394B; --sidebar-text:#B9C2CD; --sidebar-muted:#6E7B8A; --sidebar-icon:#7F8C9C;
  --checkbox-border:#C5CBD3; --chart-secondary:#B9C5D6;
  --green-bg:#E6F3EC; --green:#1D7A4C; --amber-bg:#FCF1DE; --amber:#935F00;
  --red-bg:#FBEAE8; --red:#B0281C; --gray-bg:#EEF0F3; --gray:#4B5563;
  --info-bg:#F3F6FB; --info-border:#D6E0F0; --info-text:#2B3E5C; --warn-bg:#FFF8EC; --warn-border:#F1DDB5; --warn-text:#6B4A0A;
  --scale-1:#2457A6; --scale-2:#7FA3D9; --scale-3:#D99A2B; --scale-4:#D9534A; --scale-5:#9E2A20;
  --radius-card:8px; --radius-control:6px; --radius-badge:4px;
  --font: "Inter", "Segoe UI", Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--font); font-size: 13px; color: var(--text); background: var(--canvas); }
button, input, select { font: inherit; color: inherit; }
h1 { margin: 0; font-size: 22px; font-weight: 600; }
.muted { color: var(--text-muted); }
a { color: var(--accent); }
.subtle { color: var(--text-subtle); }
.icon { flex: none; }

/* Shell */
.shell { display: flex; height: 100vh; }
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.content { flex: 1; overflow: auto; padding: 20px 24px 24px; display: flex; flex-direction: column; gap: 16px; }

/* Sidebar */
.sidebar { width: 232px; flex: none; background: var(--sidebar); color: var(--sidebar-text); padding: 16px 12px; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 4px 12px; }
.brand-logo { width: 30px; height: 30px; border-radius: var(--radius-control); background: var(--accent); color: var(--surface); display: grid; place-items: center; }
.brand-name { color: var(--surface); font-weight: 600; font-size: 14px; }
.brand-sub { color: var(--sidebar-muted); font-size: 11.5px; }
.nav-group { margin-top: 12px; }
.nav-label { color: var(--sidebar-muted); font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; padding: 0 10px 4px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 5px 10px; border-radius: var(--radius-control); color: var(--sidebar-text); font-size: 12.5px; text-decoration: none; }
.nav-item .icon { color: var(--sidebar-icon); }
.nav-item:hover, .nav-item.active { background: var(--sidebar-active); }
.nav-item.active { color: var(--surface); }
.nav-item.active .icon { color: var(--surface); }

/* Top bar */
.topbar { height: 56px; flex: none; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 0 24px; background: var(--surface); border-bottom: 1px solid var(--border); }
.breadcrumb { display: flex; gap: 6px; font-size: 13px; font-weight: 500; white-space: nowrap; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.business-date { display: flex; align-items: center; gap: 6px; color: var(--text-muted); font-size: 12.5px; white-space: nowrap; }

/* Page header */
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.page-header p { margin: 4px 0 0; color: var(--text-muted); font-size: 12px; }

/* Inputs and dropdowns */
.select, .search { height: 34px; border: 1px solid var(--border); border-radius: var(--radius-control); background-color: var(--surface); }
.select { padding: 0 30px 0 10px; appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23636D7A' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 8px center; background-size: 15px; }
.search { width: 300px; display: flex; align-items: center; gap: 8px; padding: 0 10px; color: var(--text-subtle); }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; color: var(--text); }
.search input::placeholder { color: var(--text-subtle); }
.select:focus-visible, .search:focus-within { outline: 2px solid var(--accent-soft); border-color: var(--accent); }

/* Segmented tabs */
.seg { display: inline-flex; gap: 2px; padding: 3px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-control); }
.seg button { border: 0; background: none; padding: 4px 10px; border-radius: 4px; font-size: 12.5px; color: var(--text-muted); cursor: pointer; }
.seg button.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.page-header .actions { display: flex; gap: 8px; }

/* Grids */
.kpi-row { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 16px; }
.grid-2-1 { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 16px; }
.grid-1-1 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }

/* Card */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); padding: 16px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.card.flush { padding: 0; gap: 0; }
.card.flush .card-head { padding: 14px 16px; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.card-head h2 { margin: 0; font-size: 14px; font-weight: 600; }
.card-head p { margin: 2px 0 0; font-size: 12px; color: var(--text-muted); }

/* KPI tile */
.kpi { gap: 6px; }
.kpi-label { font-size: 12.5px; color: var(--text-muted); }
.kpi-value { font-size: 22px; font-weight: 600; white-space: nowrap; }
.kpi-sub { font-size: 12px; font-weight: 500; color: var(--text-muted); }

/* Tones: KPI sub-lines and badges */
.kpi-sub.green { color: var(--green); } .kpi-sub.amber { color: var(--amber); } .kpi-sub.red { color: var(--red); }
.kpi-sub.blue { color: var(--accent); } .kpi-sub.gray { color: var(--gray); }
.badge { display: inline-block; padding: 3px 8px; border-radius: var(--radius-badge); font-size: 11px; font-weight: 500; white-space: nowrap; }
.badge.green { background: var(--green-bg); color: var(--green); } .badge.amber { background: var(--amber-bg); color: var(--amber); }
.badge.red { background: var(--red-bg); color: var(--red); } .badge.blue { background: var(--accent-soft); color: var(--accent); }
.badge.gray { background: var(--gray-bg); color: var(--gray); }

/* Buttons */
.btn { display: inline-block; text-decoration: none; padding: 8px 14px; border-radius: var(--radius-control); border: 1px solid var(--border); background: var(--surface); color: var(--text); font-size: 13px; font-weight: 500; cursor: pointer; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--surface); }
.btn.small { padding: 6px 12px; font-size: 12.5px; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.link { border: 0; background: none; padding: 0; color: var(--accent); }
.btn:focus-visible, .seg button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* Table (inside a flush card) */
.table { width: 100%; border-collapse: collapse; }
.table th { height: 34px; padding: 0 16px; background: var(--table-head); color: var(--text-muted); font-size: 11.5px; font-weight: 500; text-align: left; }
.table td { height: 40px; padding: 0 16px; border-top: 1px solid var(--line); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .name { font-weight: 500; }
.table .total td { font-weight: 600; }

/* Alert list */
.alert-list { list-style: none; margin: 0; padding: 0; }
.alert-list li { display: flex; align-items: flex-start; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); }
.alert-list li:first-child { border-top: 0; padding-top: 0; }
.alert-list .badge { width: 74px; text-align: center; flex: none; }
.alert-title { font-size: 12.5px; font-weight: 500; }
.alert-detail { font-size: 11.5px; color: var(--text-muted); }

/* Charts (inline SVG, D-040) */
.plot { position: relative; height: 180px; margin: 8px 0 0 36px; }
.plot svg { display: block; width: 100%; height: 100%; overflow: visible; }
.plot polyline { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.y-label, .x-labels, .bars { font-size: 11px; color: var(--text-subtle); }
.y-label { position: absolute; left: -36px; width: 28px; text-align: right; }
.y-max { top: -7px; } .y-min { bottom: -7px; }
.x-labels { position: relative; height: 14px; margin: 8px 0 0 36px; }
.x-labels span { position: absolute; transform: translateX(-50%); white-space: nowrap; }
.x-labels span:first-child { transform: none; }
.x-labels span:last-child:not(:first-child) { transform: translateX(-100%); }
.chart .series-0 { stroke: var(--accent); background: var(--accent); }
.chart .series-1 { stroke: var(--chart-secondary); background: var(--chart-secondary); }
.bars { display: flex; gap: 16px; height: 200px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0; }
.bar-track { flex: 1; width: 100%; display: flex; align-items: flex-end; justify-content: center; }
.bar { width: min(48px, 60%); background: var(--accent); border-radius: 3px 3px 0 0; }
.legend { display: flex; justify-content: flex-end; gap: 14px; font-size: 11.5px; color: var(--text-muted); }
.legend span { display: flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 3px; border-radius: 2px; }

.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.kpi-row.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.toolbar { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.banner .toolbar, .card-foot .toolbar { align-items: center; }
.toolbar .spacer { flex: 1; }

/* Forms */
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field > span { font-size: 12px; font-weight: 500; color: var(--text-muted); }
.input { height: 34px; padding: 0 10px; border: 1px solid var(--border); border-radius: var(--radius-control); background: var(--surface); min-width: 0; }
textarea.input { height: auto; padding: 8px 10px; resize: vertical; }
.input:focus-visible, .qty:focus-visible { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.input:disabled, .qty:disabled { background: var(--table-head); color: var(--text-muted); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; }
.form-grid .wide { grid-column: 1 / -1; }
.qty.wide { width: 96px; }
.qty { width: 64px; height: 28px; padding: 0 6px; text-align: right; border: 1px solid var(--border); border-radius: 4px; background: var(--surface); }
.check { display: flex; align-items: center; gap: 8px; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); width: 15px; height: 15px; margin: 0; }

/* Callouts */
.banner { display: flex; align-items: flex-start; gap: 10px; padding: 10px 14px; border: 1px solid; border-radius: var(--radius-control); font-size: 12.5px; }
.banner.info { background: var(--info-bg); border-color: var(--info-border); color: var(--info-text); }
.banner.warn { background: var(--warn-bg); border-color: var(--warn-border); color: var(--warn-text); }
.banner .icon { margin-top: 1px; }

/* Table extras */
.table-scroll { overflow-x: auto; }
.table.dense td { height: 36px; }
.table tr.attention td { background: var(--warn-bg); }
.table tr.selected td { background: var(--info-bg); }
.table td small { display: block; font-size: 11.5px; color: var(--text-muted); font-weight: 400; }
.table tfoot td { height: 40px; padding: 0 16px; border-top: 1px solid var(--border); font-weight: 600; }
.table .muted { color: var(--text-muted); }
.table th.check-col, .table td.check-col { width: 36px; padding-right: 0; }
.card-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--line); font-size: 12px; color: var(--text-muted); }
.empty { padding: 24px 16px; text-align: center; color: var(--text-muted); }

/* Figures in a card: label left, value right */
.stats { display: grid; grid-template-columns: 1fr auto; row-gap: 8px; margin: 0; }
.stats dt { color: var(--text-muted); }
.stats dd { margin: 0; padding-left: 16px; text-align: right; font-weight: 500; font-variant-numeric: tabular-nums; }
.stats .total { font-weight: 600; color: var(--text); padding-top: 8px; border-top: 1px solid var(--line); }
.big { font-size: 20px; font-weight: 600; }
.card-sub { margin: 4px 0 0; font-size: 12.5px; font-weight: 600; }

/* Ageing bar (ordered scale) */
.ageing { display: flex; height: 8px; min-width: 120px; border-radius: 4px; overflow: hidden; background: var(--line); }
.ageing span:nth-child(1) { background: var(--scale-1); } .ageing span:nth-child(2) { background: var(--scale-2); }
.ageing span:nth-child(3) { background: var(--scale-3); } .ageing span:nth-child(4) { background: var(--scale-4); }
.legend .age-1 { background: var(--scale-1); } .legend .age-2 { background: var(--scale-2); }
.legend .age-3 { background: var(--scale-3); } .legend .age-4 { background: var(--scale-4); }

/* Modal */
.modal-backdrop { position: fixed; inset: 0; z-index: 800; display: grid; place-items: center; background: color-mix(in srgb, var(--text) 45%, transparent); }
.modal { width: min(560px, calc(100vw - 48px)); max-height: calc(100vh - 48px); overflow: auto; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); outline: none; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font-size: 14px; font-weight: 600; }
.modal-body { padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line); }
.icon-btn { display: grid; place-items: center; padding: 4px; border: 0; border-radius: 4px; background: none; color: var(--text-muted); cursor: pointer; }
.icon-btn:hover { background: var(--gray-bg); }

/* Start PIN screen */
.pin-screen { min-height: 100vh; display: grid; place-items: center; background: var(--canvas); }
.pin-card { width: 340px; align-items: stretch; text-align: center; }
.pin-card .brand-logo { margin: 0 auto; }
.pin-card .input { text-align: center; font-size: 18px; letter-spacing: .3em; }

/* Toast */
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 900; padding: 10px 16px; border-radius: var(--radius-control); background: var(--sidebar); color: var(--surface); font-size: 13px; }

/* Blazor error bar (shown by the framework) */
#blazor-error-ui { display: none; position: fixed; left: 0; right: 0; bottom: 0; z-index: 1000; padding: 10px 24px; background: var(--red-bg); color: var(--red); border-top: 1px solid var(--border); }
#blazor-error-ui a { color: var(--red); font-weight: 500; margin-left: 12px; cursor: pointer; }
