/* ERP interface. One stylesheet, no build step, no external requests. */

:root {
  --paper: #f6f7f5;
  --surface: #ffffff;
  --ink: #1e2933;
  --ink-2: #4d5965;
  --ink-3: #75808b;
  --rule: #d8dde2;
  --rule-soft: #e9ecef;
  --blue: #1d5fa8;
  --blue-dark: #164b85;
  --blue-wash: #e8f0f9;
  --green: #2e7d4f;
  --green-wash: #e5f2ea;
  --amber: #8f5600;
  --amber-wash: #fbf0dc;
  --red: #b42318;
  --red-wash: #fbe9e7;
  --focus: 0 0 0 3px rgba(29, 95, 168, .35);
  --radius: 6px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", Arial, sans-serif;
  /* Strand colours: each location in a strand bar gets the next one. */
  --s1: #1d5fa8; --s2: #2e7d4f; --s3: #b26a00; --s4: #6b4fa0; --s5: #0f7c86; --s6: #9b3d55; --s7: #5c6b78;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 15px/1.5 var(--font); font-variant-numeric: tabular-nums;
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 3px; }
h1, h2, h3 { line-height: 1.25; margin: 0; }
h1 { font-size: 1.5rem; font-weight: 650; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; font-weight: 650; }
p { margin: 0 0 .75rem; }
.muted { color: var(--ink-3); }
.num { text-align: right; white-space: nowrap; }
.nowrap { white-space: nowrap; }

/* --- Shell ---------------------------------------------------------------- */

.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh;
  background: linear-gradient(to right, var(--ink) 232px, transparent 232px); }
.sidebar {
  background: var(--ink); color: #c9d2da; padding: 20px 14px 24px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 700; font-size: 1.05rem; padding: 0 8px 18px; }
.brand-mark { width: 26px; height: 26px; border-radius: 50%; background:
  conic-gradient(var(--s1) 0 25%, var(--s2) 0 50%, var(--s3) 0 75%, var(--s4) 0); border: 3px solid #fff; }
.nav-group { margin-top: 14px; }
.nav-group-title { color: #8995a1; font-size: .78rem; font-weight: 600; padding: 0 8px 4px; }
.nav a { display: block; color: #dfe5ea; padding: 6px 8px; border-radius: 5px; font-size: .93rem; }
.nav a:hover { background: rgba(255,255,255,.07); text-decoration: none; }
.nav a[aria-current="page"] { background: rgba(255,255,255,.12); color: #fff; box-shadow: inset 3px 0 0 #6fa3dc; }
.sidebar-foot { margin-top: 24px; padding: 14px 8px 0; border-top: 1px solid rgba(255,255,255,.1); font-size: .85rem; }
.sidebar-foot a { color: #b9c4ce; }
.sidebar-foot form { display: inline; }
.linklike { background: none; border: 0; padding: 0; color: #b9c4ce; font: inherit; cursor: pointer; }
.linklike:hover { text-decoration: underline; }

.main { min-width: 0; padding: 28px 36px 64px; max-width: 1320px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head .sub { color: var(--ink-2); margin-top: 4px; }
.crumb { font-size: .88rem; color: var(--ink-3); margin-bottom: 6px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.mobile-bar { display: none; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; background: none; }
  .sidebar { display: none; position: static; height: auto; }
  .nav-toggle:checked ~ .shell .sidebar { display: block; }
  .mobile-bar { display: flex; align-items: center; justify-content: space-between; background: var(--ink); color: #fff; padding: 10px 16px; }
  .mobile-bar label { cursor: pointer; border: 1px solid rgba(255,255,255,.3); border-radius: 5px; padding: 4px 10px; font-size: .9rem; }
  .main { padding: 20px 16px 48px; }
}
.nav-toggle { position: absolute; opacity: 0; pointer-events: none; }

/* --- Panels and sections ------------------------------------------------------ */

.panel { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); }
.panel + .panel, .section + .section { margin-top: 20px; }
.cols > .panel, .cols-3-1 > .panel { margin-top: 0; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--rule-soft); }
.panel-body { padding: 18px; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.cols-3-1 { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 20px; }
@media (max-width: 1000px) { .cols, .cols-3-1 { grid-template-columns: 1fr; } }

/* Key facts strip on dashboard and detail pages: one ruled band, not separate cards. */
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); background: var(--surface);
  border: 1px solid var(--rule); border-radius: var(--radius); margin-bottom: 20px; }
.fact { padding: 14px 18px; border-left: 1px solid var(--rule-soft); }
.fact:first-child { border-left: 0; }
.fact-value { font-size: 1.45rem; font-weight: 650; letter-spacing: -.01em; }
.fact-label { color: var(--ink-2); font-size: .88rem; }
.fact-value.bad { color: var(--red); }
@media (max-width: 700px) {
  .facts { grid-template-columns: 1fr 1fr; }
  .fact { border-left: 0; border-top: 1px solid var(--rule-soft); }
  .fact:nth-child(-n+2) { border-top: 0; }
  .fact:nth-child(even) { border-left: 1px solid var(--rule-soft); }
  .fact-value { font-size: 1.2rem; }
}

dl.meta { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; margin: 0; }
dl.meta dt { color: var(--ink-3); }
dl.meta dd { margin: 0; }

/* --- Buttons ------------------------------------------------------------------- */

.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--rule); background: var(--surface);
  color: var(--ink); font: inherit; font-size: .92rem; font-weight: 550; padding: 7px 14px; border-radius: var(--radius);
  cursor: pointer; line-height: 1.3; text-decoration: none; }
.btn:hover { border-color: #b8c1c9; text-decoration: none; }
.btn-primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-dark); border-color: var(--blue-dark); }
.btn-danger { color: var(--red); border-color: #e7b4ae; }
.btn-danger:hover { background: var(--red-wash); border-color: var(--red); }
.btn-small { padding: 4px 10px; font-size: .85rem; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* --- Tables --------------------------------------------------------------------------- */

.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th { text-align: left; font-weight: 600; color: var(--ink-2); padding: 9px 14px; border-bottom: 1px solid var(--rule);
  background: #fafbfa; white-space: nowrap; }
.table td { padding: 9px 14px; border-bottom: 1px solid var(--rule-soft); vertical-align: top; }
.table td.nowrap { white-space: nowrap; }
.table tbody tr:hover td { background: #fafcfe; }
.table tfoot td { font-weight: 650; border-top: 1px solid var(--rule); border-bottom: 0; }
.table th.num, .table td.num { text-align: right; }
.table .void td { color: var(--ink-3); text-decoration: line-through; }
.empty { padding: 36px 18px; text-align: center; color: var(--ink-2); }
.empty p { margin-bottom: 12px; }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; padding: 14px 18px; border-bottom: 1px solid var(--rule-soft); }
.toolbar .field { margin: 0; }
.toolbar .field label { font-size: .82rem; }
.toolbar .field label .muted { display: none; }
.toolbar input, .toolbar select { min-width: 150px; }
.toolbar input[type=checkbox] { min-width: 0; }
.toolbar .checkbox { align-self: center; }
.table-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 18px; font-size: .9rem; color: var(--ink-2); }
.pager { display: flex; gap: 6px; align-items: center; }

/* --- Status chips ------------------------------------------------------------------------- */

.status { display: inline-block; padding: 1px 9px; border-radius: 999px; font-size: .8rem; font-weight: 600; white-space: nowrap;
  border: 1px solid transparent; }
.status-ok { background: var(--green-wash); color: var(--green); }
.status-warn { background: var(--amber-wash); color: var(--amber); }
.status-bad { background: var(--red-wash); color: var(--red); }
.status-info { background: var(--blue-wash); color: var(--blue); }
.status-neutral { background: #eef0f2; color: var(--ink-2); }
.status-muted { background: transparent; color: var(--ink-3); border-color: var(--rule); }

/* --- Forms ---------------------------------------------------------------------------------- */

.form { max-width: 760px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
.form-grid .wide { grid-column: 1 / -1; }
@media (max-width: 700px) { .form-grid { grid-template-columns: 1fr; } }
.field { margin-bottom: 14px; }
.field label { display: block; font-weight: 550; font-size: .9rem; margin-bottom: 4px; }
.field .help { color: var(--ink-3); font-size: .83rem; margin-top: 3px; }
.field .error, .errorlist { color: var(--red); font-size: .85rem; margin: 3px 0 0; padding: 0; list-style: none; }
.field.has-error input, .field.has-error select, .field.has-error textarea { border-color: var(--red); }
input[type=text], input[type=number], input[type=date], input[type=email], input[type=password], input[type=search],
input[type=file], select, textarea {
  width: 100%; font: inherit; font-size: .95rem; color: var(--ink); background: #fff; border: 1px solid #c3cbd2;
  border-radius: 5px; padding: 7px 10px; }
textarea { min-height: 72px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--blue); box-shadow: var(--focus); }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--blue); vertical-align: -3px; }
.radio-list { display: grid; gap: 6px; }
.radio { display: flex; gap: 8px; align-items: center; font-weight: 450 !important; margin: 0 !important; }
.radio input { accent-color: var(--blue); width: 16px; height: 16px; }
.checkbox label { display: flex; gap: 8px; align-items: center; font-weight: 500; }
.form-actions { display: flex; gap: 10px; padding-top: 6px; }
.nonfield { background: var(--red-wash); color: var(--red); border: 1px solid #f1c4bf; border-radius: var(--radius);
  padding: 10px 14px; margin-bottom: 16px; }

/* Line editors (purchase lines, receipts, counts, allocations). */
.lines td { vertical-align: middle; padding: 6px 8px; }
.lines input, .lines select { padding: 5px 8px; }
.lines .col-qty { width: 120px; }
.lines .col-money { width: 150px; }
.lines .col-del { width: 44px; text-align: center; }

/* --- Messages ----------------------------------------------------------------------------- */

.messages { list-style: none; padding: 0; margin: 0 0 18px; }
.messages li { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 8px; border: 1px solid; }
.messages .success { background: var(--green-wash); border-color: #b9dcc6; color: #1f5c39; }
.messages .error { background: var(--red-wash); border-color: #f1c4bf; color: var(--red); }
.messages .warning, .messages .info { background: var(--blue-wash); border-color: #c2d6ee; color: var(--blue-dark); }

/* --- Strand bar: how an item's stock is split across locations ---------------------------- */

.strand { display: flex; height: 14px; border-radius: 7px; overflow: hidden; background: var(--rule-soft); }
.strand span { display: block; height: 100%; min-width: 3px; }
.strand span + span { box-shadow: -2px 0 0 #fff; }
.strand-legend { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 6px; }
.strand-legend li { display: grid; grid-template-columns: 12px 1fr auto auto; gap: 10px; align-items: center; font-size: .92rem; }
.strand-legend .sw { width: 12px; height: 12px; border-radius: 3px; }
.strand-legend .pct { color: var(--ink-3); min-width: 3.5em; text-align: right; }
.strand.small { height: 8px; min-width: 90px; }
.c1 { background: var(--s1); } .c2 { background: var(--s2); } .c3 { background: var(--s3); } .c4 { background: var(--s4); }
.c5 { background: var(--s5); } .c6 { background: var(--s6); } .c7 { background: var(--s7); }

/* --- Login -------------------------------------------------------------------------------- */

.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: 100%; max-width: 380px; }
.login-card .brand { color: var(--ink); padding: 0 0 20px; }
.login-card .brand-mark { border-color: var(--paper); }
.login-card h1 { font-size: 1.3rem; margin-bottom: 18px; }

.attribution { font-size: .8rem; color: var(--ink-3); margin-top: 32px; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* --- Two-factor setup ------------------------------------------------------------------- */
.steps { margin: 0; padding-left: 1.2em; display: grid; gap: 18px; }
.qr-box { margin: 12px 0; }
.qr-box svg { width: 210px; height: 210px; border: 1px solid var(--rule); border-radius: var(--radius); background: #fff; }
code.key, .codes code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .95rem;
  background: #eef1f3; padding: 2px 6px; border-radius: 4px; }
.codes { list-style: none; padding: 0; margin: 14px 0 18px; display: grid; grid-template-columns: repeat(2, max-content); gap: 8px 24px; }

/* Show/hide password button inside the password box */
.pw-field { position: relative; display: block; }
.pw-field input { width: 100%; padding-right: 42px; }
.pw-toggle { position: absolute; top: 50%; right: 4px; transform: translateY(-50%); display: grid; place-items: center;
  width: 34px; height: 34px; padding: 0; border: 0; border-radius: 6px; background: transparent; color: var(--ink-3); cursor: pointer; }
.pw-toggle:hover { color: var(--ink); background: var(--paper-2, rgba(0,0,0,.05)); }
.pw-toggle:focus-visible { outline: none; box-shadow: var(--focus); }
