@font-face { font-family: "Open Sans"; font-weight: 400; font-display: swap;
  src: url("../fonts/OpenSans-Regular.ttf") format("truetype"); }
@font-face { font-family: "Open Sans"; font-weight: 700; font-display: swap;
  src: url("../fonts/OpenSans-Bold.ttf") format("truetype"); }

:root {
  --green: #036928; --green-dark: #025420; --green-900: #04321a; --green-light: #7CC68D; --mint-100: #e6f4ea;
  --bg: #f5f6f7; --text: #24292d; --muted: #59636b; --border: #dce0e3; --card: #fff;
  --shadow: none;
  --tint-good-bg: #d9f0df; --tint-good-fg: #03521f;
  --tint-warn-bg: #fdecc4; --tint-warn-fg: #6b4a00;
  --tint-bad-bg: #f8d3d0; --tint-bad-fg: #8a1c14;
  --tint-info-bg: #d6e6f7; --tint-info-fg: #11467a;
  --tint-neutral-bg: #e6eae7; --tint-neutral-fg: #3a463e;
  --chip-bad-bg: #8a1c14; --chip-bad-fg: #ffffff;
  --chip-good-bg: #167a36; --chip-good-fg: #ffffff;
  --chip-info-bg: #9ec5f0; --chip-info-fg: #0b2a4a;
  --chip-neutral-bg: #d9dedb; --chip-neutral-fg: #17221B;
  --chip-warn-bg: #fff0c2; --chip-warn-fg: #5c4000;
  --danger: #8a1c14; --warn-edge: #8a5a00;
  --radius: 4px; --radius-sm: 3px; --sidebar: 216px;
}
* { box-sizing: border-box; }
html { font-size: 14px; }
body { margin: 0; font-family: "Open Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg); color: var(--text); line-height: 1.5; }
h1 { font-size: 1.65rem; margin: 0 0 1.4rem; font-weight: 700; letter-spacing: -.025em; }
h2 { font-size: 1.05rem; margin: 0 0 .75rem; }
a { color: var(--green); }
.muted { color: var(--muted); }
.skip { position: absolute; left: -999px; } .skip:focus { left: 8px; top: 8px; background: #fff; padding: 8px; z-index: 99; }
:focus-visible { outline: 3px solid #1a5fb4; outline-offset: 2px; }

.shell { display: flex; min-height: 100vh; }
.sidebar { width: var(--sidebar); background: #fff; color: var(--text); padding: 0;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
  flex-shrink: 0; border-right: 1px solid var(--border); }
.sidebar ul { list-style: none; margin: 1rem 0; padding: 0 12px; flex: 1; }
.sidebar a { color: var(--text); text-decoration: none; }
.sidebar ul a, .sidebar-foot > a { display: flex; align-items: center; min-height: 44px;
  padding: 10px 14px; border-radius: 3px; }
.sidebar ul a:hover, .sidebar-foot > a:hover { background: #f0f2f3; }
.sidebar ul a[aria-current="page"] { background: #e6f4ea; color: var(--green-dark);
  box-shadow: inset 3px 0 0 var(--green); font-weight: 700; }
.brand { font-weight: 700; font-size: 1.15rem; padding: 0 1.25rem; }
.brand span { color: #fff; font-weight: 400; }
.brand-dark { padding: 0; color: var(--green); margin-bottom: 1rem; } .brand-dark span { color: var(--green); font-weight: 400; }
.sidebar-foot { padding: 0 0 0 0; border-top: 1px solid var(--border); }
.sidebar-foot .who { padding: .75rem 1.25rem 0; } .sidebar-foot small { color: var(--muted); font-size: .8rem; }
.sidebar-foot form { padding: 0 1rem 0; }
.content { flex: 1; padding: 2rem 2.25rem; min-width: 0; max-width: 1680px; }
.topbar { display: none; }

.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.25rem; margin-bottom: 1rem; }
.card.narrow { max-width: 440px; }
.grid { display: grid; gap: 1rem; }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.kpi .num { font-size: 2rem; font-weight: 700; color: var(--green); line-height: 1.1; }
.kpi .label { color: var(--muted); font-size: .9rem; }

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; }
table { border-collapse: collapse; width: 100%; font-size: .95rem; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { background: #f1f3f4; font-size: .8rem; color: var(--muted); font-weight: 700; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

.chip { display: inline-flex; gap: .35em; align-items: center; padding: 2px 10px; border-radius: 3px;
  font-size: .78rem; font-weight: 600; border: 1px solid transparent; white-space: nowrap; }
.chip-good { background: var(--chip-good-bg); color: var(--chip-good-fg); border-color: var(--chip-good-bg); }
.chip-warn { background: var(--chip-warn-bg); color: var(--chip-warn-fg); border-color: #d9b45a; }
.chip-bad { background: var(--chip-bad-bg); color: var(--chip-bad-fg); border-color: var(--chip-bad-bg); }
.chip-info { background: var(--chip-info-bg); color: var(--chip-info-fg); border-color: #5b8fc9; }
.chip-neutral { background: var(--chip-neutral-bg); color: var(--chip-neutral-fg); border-color: #9aa59e; }

.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; min-width: 44px;
  padding: 0 1.1rem; border-radius: 3px; border: 1px solid #a4adb3; background: #fff; color: var(--green);
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn-primary { background: var(--green); border-color: var(--green); color: #fff; }
.btn-primary:hover { background: var(--green-dark); }
.btn-danger { background: #fff; color: var(--danger); border-color: var(--danger); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border); width: 100%; margin: .5rem 0; }

.field { margin-bottom: 1rem; }
label { display: block; font-weight: 600; margin-bottom: .25rem; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=search],
input[type=date], select, textarea, input:not([type]) {
  width: 100%; min-height: 44px; padding: 8px 12px; border: 1px solid #a4adb3; border-radius: 3px;
  font: inherit; color: var(--text); background: #fff; }

.flashes { margin-bottom: 1rem; }
.flash { padding: 10px 14px; border-radius: 8px; border: 1px solid var(--border); background: #fff; margin-bottom: .5rem; }
.flash-error { background: var(--tint-bad-bg); color: var(--tint-bad-fg); border-color: #e7a39d; }
.flash-success { background: var(--tint-good-bg); color: var(--tint-good-fg); border-color: #a9d9b5; }
.flash-info { background: var(--tint-info-bg); color: var(--tint-info-fg); border-color: #9ec1e6; }

.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.auth-card { background: #fff; border: 1px solid var(--border); border-radius: 4px; padding: 2rem; width: 100%; max-width: 420px; }
.qr { display: block; margin: 1rem auto; }
.codes { columns: 2; list-style: none; padding: 0; font-size: 1.1rem; }
code { background: #eef3ef; padding: 1px 6px; border-radius: 4px; }

@media (max-width: 900px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2 { grid-template-columns: 1fr; }
  .topbar { display: flex; align-items: center; gap: 1rem; background: var(--green); color: #fff; padding: 6px 12px; position: sticky; top: 0; z-index: 20; }
  .menu-btn { min-height: 44px; min-width: 44px; background: transparent; border: 1px solid rgba(255,255,255,.6); color: #fff; border-radius: 8px; font: inherit; font-weight: 600; padding: 0 14px; }
  .shell { display: block; }
  .sidebar { display: none; position: static; width: 100%; height: auto; }
  .sidebar.open { display: flex; }
  .content { padding: 1rem; }
}
@media (max-width: 480px) { .grid-4 { grid-template-columns: 1fr 1fr; } .codes { columns: 1; } }

.tabs { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: .75rem; }
.tab { display: inline-flex; align-items: center; min-height: 44px; padding: 0 14px; border: 1px solid var(--border); border-radius: 3px; text-decoration: none; background: #fff; }
.tab[aria-current="true"] { background: var(--green); color: #fff; border-color: var(--green); font-weight: 600; }
ul.plain { list-style: none; margin: 0 0 1rem; padding: 0; }
ul.plain li { padding: 8px 0; border-bottom: 1px solid var(--border); }
ul.plain li:last-child { border-bottom: 0; }
.attn { display: flex; justify-content: space-between; align-items: center; gap: .75rem; border-left: 4px solid var(--warn-edge); padding-left: 10px !important; }
.attn-critical { border-left-color: var(--danger); }
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: .75rem; align-items: end; }
.filters .field { margin: 0; }
.pager { display: flex; gap: .4rem; flex-wrap: wrap; margin: 1rem 0; }
dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; margin: 0; }
dl.kv dt { color: var(--muted); } dl.kv dd { margin: 0; }
.check { display: flex; align-items: center; gap: .5rem; min-height: 44px; font-weight: 400; }
.check input { width: 22px; height: 22px; }
fieldset { border: 1px solid var(--border); border-radius: 8px; margin: 0 0 1rem; padding: .5rem .75rem; }

.row-low { background: #fff8e6; }
form.inline { display: flex; gap: .5rem; flex-wrap: wrap; }

.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.head-row { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
@media (max-width: 900px) { .grid-3 { grid-template-columns: 1fr; } }

.suggestion { border: 1px solid var(--border); border-left: 4px solid var(--warn-edge); border-radius: 8px; padding: .75rem 1rem; margin-bottom: 1rem; background: #fff; }
.suggestion-high { border-left-color: var(--danger); }
.suggestion h3 { margin: 0 0 .5rem; font-size: 1rem; }
pre.mail { white-space: pre-wrap; word-break: break-word; background: #f4f7f5; padding: .75rem; border-radius: 6px; max-height: 300px; overflow: auto; }

.portal { max-width: 860px; margin: 0 auto; padding: 1rem; }


/* ---- touch, motion and phone layout ---- */
a.row-link, .table-wrap td a { display: inline-block; padding: 4px 0; min-height: 30px; }
tbody tr:hover { background: #f8faf9; }
td .chip { margin: 3px 0; }
.table-wrap { -webkit-overflow-scrolling: touch; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; scroll-behavior: auto !important; } }
@media (max-width: 900px) {
  .content { padding: 1rem 1rem 5rem; }
  h1 { font-size: 1.4rem; }
  .sidebar.open { position: fixed; inset: 58px 0 0 0; z-index: 30; overflow-y: auto; }
  .sidebar a { padding: 14px 1.25rem; }
}
@media (max-width: 600px) {
  /* Orders, stock and today: each row becomes a small card, so nothing scrolls sideways. */
  table.stack, table.stack tbody, table.stack tr, table.stack td { display: block; width: 100%; }
  table.stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  table.stack tr { border-bottom: 8px solid var(--bg); padding: .5rem .75rem; background: #fff; }
  table.stack td { border: 0; padding: 4px 0; display: flex; justify-content: space-between; gap: 1rem; text-align: right; }
  table.stack td::before { content: attr(data-label); font-weight: 600; color: var(--muted); text-align: left; flex-shrink: 0; }
  table.stack td.num { text-align: right; }
  .table-wrap { border-radius: 0; margin: 0 -1rem; border-left: 0; border-right: 0; }
  .btn, .actions .btn { width: 100%; }
  .actions, form.inline { flex-direction: column; align-items: stretch; }
  .head-row { align-items: flex-start; }
  .filters { grid-template-columns: 1fr 1fr; }
  .pager .btn { width: auto; min-width: 44px; }
  .tabs { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; }
  .tab { white-space: nowrap; }
  .flash { font-size: .95rem; }
}
@media (max-width: 400px) { .filters { grid-template-columns: 1fr; } .kpi .num { font-size: 1.6rem; } }
code.secret { display: block; padding: 10px 12px; background: #eef3ef; border-radius: 6px; word-break: break-all; font-size: 1rem; user-select: all; }


/* Brand and shared page furniture. Keep the logo separate from navigation links. */
.sidebar .brand-logo { display: block; padding: 20px 26px 8px; margin: 0;
  border-radius: 0; background: #fff; box-shadow: none; }
.brand-logo img { display: block; width: 164px; max-width: 100%; height: auto; }
.brand-sub { margin: 0; padding: 0 26px 16px; border-bottom: 1px solid var(--border);
  color: var(--muted); font-size: .8rem; }
.sidebar-foot { padding: 4px 12px 12px; font-size: .9rem; }
.sidebar-foot .who { padding: 10px 14px 4px; }
.sidebar-foot form { padding: 0; }
.sidebar-foot .btn { justify-content: flex-start; padding-left: 14px; }
.btn:hover { background: #f0f2f3; }
.btn-primary:hover { background: var(--green-dark); }
input:focus, select:focus, textarea:focus { border-color: var(--green); }
.kpi { border-top: 2px solid var(--border); }
.kpi .num { color: var(--text); font-size: 1.85rem; }
.kpi .label { margin-top: .4rem; }
.auth-logo { display: block; margin: 0 auto 1.75rem; width: 180px; max-width: 75%; height: auto; }
.topbar { background: #fff; color: var(--text); border-bottom: 1px solid var(--border); }
.topbar .menu-btn { color: var(--text); border-color: var(--border); border-radius: 3px; }
.topbar .topbar-logo { display: block; padding: 0; }
.topbar .topbar-logo img { display: block; height: 46px; width: auto; }
.portal-header { display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .75rem 0 1rem; border-bottom: 1px solid var(--border); margin-bottom: 1.25rem; }
.portal-header img { height: 56px; width: auto; display: block; }
.portal-header span { color: var(--muted); font-size: .9rem; }
.filters { background: #fff; border-radius: 4px; }
.filters label { font-size: .85rem; }
.filters:has(#q) { grid-template-columns: minmax(220px, 2fr) repeat(4, minmax(100px, 1fr)) auto; }
.chip-business { background: #fff; color: var(--muted); border-color: #c4ccd1; font-weight: 400; }
@media (min-width: 901px) { .sidebar { align-self: flex-start; } }
@media (max-width: 1200px) { .filters:has(#q) { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 900px) {
  .sidebar .brand-logo, .sidebar .brand-sub { display: none; }
  .topbar-title { display: none; }
  .sidebar.open { inset: 58px 0 0; height: calc(100dvh - 58px); }
  .sidebar ul a { font-size: 1rem; }
}
@media (max-width: 600px) {
  .filters:has(#q) { grid-template-columns: 1fr 1fr; }
  .filters:has(#q) .field:first-child { grid-column: 1 / -1; }
  a.row-link, .table-wrap td a { min-height: 44px; padding: 10px 0; }
  .sidebar-foot .btn { width: 100%; }
}
@media (max-width: 360px) { .filters:has(#q) { grid-template-columns: 1fr; } }

/* ---- charts (see bx_ops/charts.py). Series colours: brand green, then orange (validated as a pair). ---- */
:root { --viz-1: #036928; --viz-2: #eb6834; --viz-grid: #e3ebe6; --viz-ink: var(--text); --viz-muted: #5b6f63;
  --viz-seg-1: #6fbb82; --viz-seg-2: #3f9a5a; --viz-seg-3: #036928; --viz-seg-4: #04321a; --viz-seg-x: #9aa59e; }
.viz { margin: 0 0 1.5rem; }
.viz-title { font-weight: 700; color: var(--green-900); margin-bottom: .5rem; }
.viz-card .viz:last-child { margin-bottom: 0; }
.table-heading { margin-top: 1.5rem; }
.viz-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .75rem; margin-bottom: 1.25rem; }
.viz-tile { background: var(--mint-100); border-radius: var(--radius-sm); padding: .75rem 1rem; }
.viz-tile-label { color: var(--muted); font-size: .85rem; }
.viz-tile-value { font-size: 1.6rem; font-weight: 800; color: var(--green-900); line-height: 1.15; }
.viz-hero { grid-column: 1 / -1; background: var(--green-900); color: #fff; }
.viz-hero .viz-tile-label, .viz-hero .viz-tile-note { color: #e6f4ea; }
.viz-hero .viz-tile-value { color: #fff; font-size: 3rem; letter-spacing: -0.02em; }
.viz-tile-note { color: var(--muted); font-size: .8rem; }
.viz-legend { display: flex; gap: 1rem; flex-wrap: wrap; list-style: none; margin: 0 0 .5rem; padding: 0; font-size: .9rem; }
.viz-key { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: .4rem; vertical-align: -1px; background: var(--viz-1); }
.viz-mark { cursor: default; transition: filter .12s; }
.viz-mark:hover, .viz-mark:focus-visible { filter: brightness(1.15) saturate(1.1); }
.viz-mark:focus-visible { outline: 3px solid var(--bx-focus, #0a58ca); outline-offset: 2px; }
/* columns over time */
.viz-columns { display: grid; grid-template-columns: 3.4rem 1fr; gap: .25rem; height: 15rem; padding-bottom: 1.6rem; }
.viz-axis { position: relative; }
.viz-tick { position: absolute; left: 0; right: 0; height: 0; text-align: right; font-size: .75rem; color: var(--viz-muted); }
.viz-tick span { position: relative; top: .55em; padding-right: .3rem; }
.viz-cols { position: relative; display: flex; align-items: stretch; gap: 2px; border-bottom: 1px solid #b9c8bf;
  background: linear-gradient(var(--viz-grid) 1px, transparent 1px) 0 0 / 100% 50%, linear-gradient(var(--viz-grid) 1px, transparent 1px) 0 100% / 100% 1px no-repeat; }
.viz-col { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; }
.viz-plot { flex: 1; display: flex; align-items: flex-end; justify-content: center; position: relative; }
.viz-bar { width: min(24px, 80%); min-height: 2px; background: var(--viz-1); border-radius: 4px 4px 0 0; position: relative; }
.viz-peak { position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); font-size: .75rem; font-weight: 700; color: var(--viz-ink); white-space: nowrap; padding-bottom: 2px; }
.viz-x { position: absolute; bottom: -1.5rem; font-size: .72rem; color: var(--viz-muted); white-space: nowrap; transform: translateX(-35%); }
.viz-col { position: relative; }
/* ranked and grouped horizontal bars */
.viz-hbars { display: grid; gap: .55rem; }
.viz-row, .viz-group { display: grid; grid-template-columns: minmax(7rem, 14rem) 1fr; gap: .75rem; align-items: center; }
.viz-name { font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viz-track { display: flex; align-items: center; gap: .5rem; min-height: 24px; }
.viz-hbar { height: 20px; min-width: 2px; background: var(--viz-1); border-radius: 0 4px 4px 0; flex: 0 1 auto; }
.viz-pair { display: grid; gap: 4px; }
.viz-val { font-size: .85rem; font-weight: 600; white-space: nowrap; color: var(--viz-ink); }
.viz-meter { background: var(--mint-100); border-radius: 999px; height: 12px; min-height: 12px; position: relative; }
.viz-meter .viz-val { position: absolute; right: -3.2rem; }
.viz-meter { margin-right: 3.4rem; }
.viz-fill { height: 12px; background: var(--viz-1); border-radius: 999px; }
/* one whole split into parts */
.viz-segbar { display: flex; gap: 2px; height: 28px; }
.viz-seg { display: flex; align-items: center; padding: 0 .6rem; font-size: .8rem; font-weight: 700; color: #fff; border-radius: 4px; min-width: 6px; overflow: visible; white-space: nowrap; }
.viz-seg-1 { background: var(--viz-seg-1); color: #04321a; } .viz-seg-2 { background: var(--viz-seg-2); }
.viz-seg-3 { background: var(--viz-seg-3); } .viz-seg-4 { background: var(--viz-seg-4); } .viz-seg-x { background: var(--viz-seg-x); color: #04321a; }
.viz-legend .viz-seg-1 { background: var(--viz-seg-1); } .viz-legend .viz-seg-2 { background: var(--viz-seg-2); }
.viz-legend .viz-seg-3 { background: var(--viz-seg-3); } .viz-legend .viz-seg-4 { background: var(--viz-seg-4); } .viz-legend .viz-seg-x { background: var(--viz-seg-x); }
/* hover readout */
.viz-tip { position: absolute; z-index: 60; pointer-events: none; background: #04321a; color: #fff; border-radius: 10px; padding: .5rem .75rem; font-size: .8rem; box-shadow: 0 8px 24px rgb(0 0 0 / 25%); max-width: 16rem; }
.viz-tip[hidden] { display: none; }
.viz-tip-value { font-size: 1rem; font-weight: 800; }
.viz-tip-title { color: #d6e4db; } .viz-tip-note { color: #b5cdbf; margin-top: 2px; }
@media (max-width: 600px) {
  .viz-hero .viz-tile-value { font-size: 2.2rem; }
  .viz-row, .viz-group { grid-template-columns: 1fr; gap: .15rem; }
  .viz-columns { height: 12rem; }
  .viz-name { white-space: normal; }
}
@media print { .viz-mark { filter: none !important; } .viz-tip { display: none; } }
@media (forced-colors: active) { .viz-bar, .viz-hbar, .viz-fill, .viz-seg { forced-color-adjust: none; border: 1px solid CanvasText; } }

/* List controls share one grid; the search field gets space on wide screens. */
.filters:has(#sort) { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.filters .check { margin-bottom: 0; }
.sort-link { color: inherit; text-decoration: none; }
.sort-link:hover { text-decoration: underline; }
.table-note { font-size: .85rem; }
@media (max-width: 600px) {
  .filters:has(#sort) { grid-template-columns: 1fr 1fr; }
  .filters:has(#sort) .field:first-child { grid-column: 1 / -1; }
}
@media (max-width: 360px) { .filters:has(#sort) { grid-template-columns: 1fr; } }

.company-description { max-width: 80ch; white-space: pre-line; }
details > summary { cursor: pointer; margin: .75rem 0; font-weight: 700; }
