:root {
  color-scheme: light;
  --bg: #ece9df; --face: #ece9df; --desktop: #3a6ea5; --surface: #ffffff; --surface-2: #dfdfdf; --border: #c0c0c0; --border-strong: #808080;
  --text: #000000; --text-2: #111111; --muted: #333333;
  --accent: #000080; --accent-hover: #0000a8; --accent-soft: #dfdfdf; --on-accent: #ffffff;
  --good: #006400; --good-soft: #e3f4e0; --warn: #6b4e00; --warn-soft: #fff2c2;
  --bad: #a00000; --bad-soft: #fde3de; --info: #000080; --info-soft: #e0e6fa;
  --series-1: #2a78d6; --series-2: #eb6834;
  --shadow: 2px 2px 0 rgba(0,0,0,.5);
  --radius: 0px;
  --raised: inset -1px -1px #3d3a30, inset 1px 1px #ffffff, inset -2px -2px #a39f8f, inset 2px 2px #f6f4ec;
  --sunken: inset -1px -1px #ffffff, inset 1px 1px #a39f8f, inset -2px -2px #f6f4ec, inset 2px 2px #3d3a30;
  --etched: inset 0 0 0 1px #a39f8f, inset 1px 1px 0 1px #ffffff;
  --titlebar: linear-gradient(90deg, #000080 0%, #1084d0 100%);
  --ui: Verdana, Tahoma, "Segoe UI", Geneva, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 22px; } h2 { font-size: 15px; } h3 { font-size: 13px; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.muted { color: var(--muted); } .small { font-size: 12px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
.pre { white-space: pre-line; }

/* ---- shell */
#shell { display: grid; grid-template-columns: 224px 1fr; min-height: 100vh; }
#sidebar {
  background: var(--surface); border-right: 1px solid var(--border); padding: 16px 10px;
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; overflow-y: auto;
}
.brand { display: flex; gap: 8px; align-items: center; padding: 4px 10px 16px; font-weight: 700; font-size: 15px; }
.brand-mark { color: var(--accent); }
#nav { display: flex; flex-direction: column; gap: 1px; }
.nav-section { display: flex; flex-direction: column; gap: 1px; }
.nav-section.folded .nav-link { display: none; }
.nav-group { display: flex; align-items: center; gap: 6px; width: 100%; margin: 14px 0 4px; padding: 0 10px; border: 0; background: transparent; cursor: pointer; text-align: left; font: inherit; font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.nav-group > span:first-child { flex: 1; }
.nav-chev { width: 0; height: 0; border-left: 4px solid transparent; border-right: 4px solid transparent; border-top: 5px solid currentColor; opacity: .55; }
.nav-section.folded .nav-chev { border-top: 0; border-bottom: 5px solid currentColor; }
/* work waiting: a plain count at the right of the line, no badge */
.nav-n { margin-left: auto; font-weight: 700; font-size: 11px; color: #000080; font-variant-numeric: tabular-nums; }
.nav-link.active .nav-n { color: #fff; }
body[data-company="forbecome"] .nav-n { color: #0b5d3b; } body[data-company="forbecome"] .nav-link.active .nav-n { color: #fff; }
.nav-group .nav-n { display: none; margin-left: 0; } .nav-section.folded .nav-group .nav-n:not([hidden]) { display: inline; }
body.layout-side #nav { flex: 1; padding-bottom: 28px; } body.layout-side .nav-section.nav-last { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border-strong); }
.nav-link {
  display: flex; align-items: center; justify-content: space-between; padding: 7px 10px; border-radius: 7px;
  color: var(--text-2); font-weight: 500;
}
.nav-link:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }
.nav-link.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-count { font-size: 11px; background: var(--surface-2); color: var(--text-2); border-radius: 99px; padding: 0 7px; font-weight: 600; }
.sidebar-foot { margin-top: auto; padding: 10px; font-size: 11.5px; color: var(--muted); }
#main { min-width: 0; }
.page { max-width: 1560px; margin: 0; padding: 24px 28px 64px; }

/* ---- page header */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); margin-top: 2px; }
.page-title { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.back { display: inline-block; font-size: 12.5px; color: var(--muted); margin-bottom: 6px; }

/* ---- buttons & inputs */
button { font: inherit; }
.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font-weight: 550; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.danger { color: var(--bad); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { padding: 4px 9px; font-size: 12.5px; }
.btn:disabled { opacity: .5; cursor: default; }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: 7px; padding: 7px 9px; width: 100%; min-width: 0;
}
textarea { resize: vertical; min-height: 62px; }
input:focus, select:focus, textarea:focus, .btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
input[type=checkbox] { width: auto; }
label.field { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; font-weight: 550; color: var(--text-2); }
label.field .hint { font-weight: 400; color: var(--muted); font-size: 12px; }
label.field.check { flex-direction: row; align-items: center; gap: 8px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; }
.form-grid.three { grid-template-columns: repeat(3, 1fr); }
.form-grid .span-2 { grid-column: 1 / -1; }
.form-section { font-size: 12px; font-weight: 650; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); grid-column: 1 / -1; margin-top: 6px; }

/* ---- cards & tables */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.card-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--border); gap: 10px; }
.card-body { padding: 14px 16px; }
.toolbar { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.toolbar .search { max-width: 260px; }
.toolbar .spacer { flex: 1; }
.tabs { display: flex; gap: 2px; flex-wrap: wrap; }
.tab { border: 0; background: transparent; color: var(--text-2); padding: 5px 10px; border-radius: 7px; cursor: pointer; font-weight: 550; }
.tab:hover { background: var(--surface-2); }
.tab.active { background: var(--accent-soft); color: var(--accent); }
.tab .n { color: var(--muted); font-weight: 500; margin-left: 4px; font-size: 12px; }
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; }
th { text-align: left; font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 9px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; user-select: none; }
th.sortable { cursor: pointer; } th.sortable:hover { color: var(--text); }
th.num { text-align: right; }
td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--surface-2); }
.empty { padding: 40px 16px; text-align: center; color: var(--muted); }
.cell-main { font-weight: 600; } .cell-sub { color: var(--muted); font-size: 12px; }

.badge { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: 11.5px; font-weight: 600; white-space: nowrap; background: var(--surface-2); color: var(--text-2); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.good { background: var(--good-soft); color: var(--good); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }

/* ---- dashboard */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 14px; }
.kpi { padding: 14px 16px; display: block; color: inherit; }
a.kpi:hover { text-decoration: none; border-color: var(--border-strong); }
.kpi .label { font-size: 12px; color: var(--muted); font-weight: 550; }
.kpi .value { font-size: 24px; font-weight: 680; letter-spacing: -.02em; margin: 2px 0; font-variant-numeric: tabular-nums; }
.kpi .note { font-size: 12px; color: var(--text-2); }
.kpi .note.bad { color: var(--bad); } .kpi .note.good { color: var(--good); }
.grid-2 { display: grid; grid-template-columns: 1.6fr 1fr; gap: 14px; margin-bottom: 14px; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--text-2); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; }
.chart text { fill: var(--muted); font-size: 10.5px; }
.chart .grid { stroke: var(--border); stroke-width: 1; }
.chart .band { fill: transparent; } .chart .band:hover { fill: var(--surface-2); }
.tip { position: absolute; pointer-events: none; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 8px; padding: 8px 10px; font-size: 12px; box-shadow: var(--shadow); min-width: 150px; z-index: 5; }
.tip .row { display: flex; justify-content: space-between; gap: 14px; }
.tip .t { font-weight: 650; margin-bottom: 4px; }
.list-row { display: flex; justify-content: space-between; gap: 12px; padding: 9px 16px; border-bottom: 1px solid var(--border); align-items: center; color: inherit; }
.list-row:last-child { border-bottom: 0; }
a.list-row:hover { background: var(--surface-2); text-decoration: none; }

/* ---- email editor: the form beside a live preview of the finished email */
.email-editor { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.email-frame { background: #f3f4f6; }
.email-preview { display: block; width: 100%; height: 720px; border: 0; background: #f3f4f6; }
.email-frame-foot { padding: 6px 10px; font-size: 12px; text-align: right; border-top: 1px solid var(--border); background: var(--surface); }
@media (max-width: 1100px) { .email-editor { grid-template-columns: 1fr; } }

/* ---- "how is this made up?" info button */
.info-btn { display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px; margin-left: 6px; border-radius: 50%; border: 1px solid var(--accent); background: var(--surface); color: var(--accent); font: italic 700 11px Georgia, serif; cursor: pointer; vertical-align: middle; padding: 0; }
.info-btn:hover { background: var(--accent); color: var(--on-accent); }

.warn-text { color: var(--bad); font-weight: 600; }

/* ---- buying catalog */
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--border-strong); background: var(--surface); padding: 3px 10px; border-radius: 12px; cursor: pointer; font: inherit; color: inherit; }
.chip.active { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.chip .n { margin-left: 5px; opacity: .7; font-size: 11px; }
.catalog-totals { display: flex; gap: 18px; flex-wrap: wrap; align-items: center; padding: 8px 12px; border-bottom: 1px solid var(--border); font-size: 13px; }
.catalog-totals .spacer { flex: 1; }
.catalog { width: 100%; } .catalog .qty-in { width: 76px; text-align: right; }
.catalog tr.picked td { background: var(--info-soft); }
.catalog td.warn, .catalog-totals .warn { color: var(--bad); font-weight: 600; }

/* ---- detail pages & documents */
.detail { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
.side { display: flex; flex-direction: column; gap: 14px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; text-align: right; }
.doc { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 36px 40px; }
.doc-top { display: flex; justify-content: space-between; gap: 24px; margin-bottom: 28px; }
.doc-kind { font-size: 22px; font-weight: 700; letter-spacing: .02em; text-align: right; }
.doc-number { text-align: right; color: var(--text-2); font-weight: 600; }
.doc-company { font-weight: 700; font-size: 16px; margin-bottom: 4px; }
.doc-logo { display: block; height: 34px; max-width: 280px; width: auto; margin-bottom: 8px; }
.doc-parties { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 24px; margin-bottom: 24px; }
.doc-label { font-size: 11px; font-weight: 650; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 4px; }
.doc table th { border-bottom: 2px solid var(--text); color: var(--text); padding-left: 0; padding-right: 8px; }
.doc table td { padding-left: 0; padding-right: 8px; vertical-align: top; }
.doc table th:last-child, .doc table td:last-child { padding-right: 0; }
.doc-totals { margin: 16px 0 0 auto; width: 280px; }
.doc-totals div { display: flex; justify-content: space-between; padding: 4px 0; }
.doc-totals .grand { border-top: 2px solid var(--text); margin-top: 6px; padding-top: 8px; font-weight: 700; font-size: 16px; }
.doc-foot { margin-top: 28px; padding-top: 14px; border-top: 1px solid var(--border); color: var(--text-2); font-size: 12.5px; display: grid; gap: 10px; }
.progress { height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; min-width: 70px; }
.progress i { display: block; height: 100%; background: var(--good); border-radius: 99px; }

/* ---- line editor */
.lines th, .lines td { padding: 5px 4px; border: 0; }
.lines th { padding-bottom: 6px; }
.lines input { padding: 6px 7px; }
.lines .num input { text-align: right; }
.lines .x { border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 16px; padding: 2px 6px; border-radius: 6px; }
.lines .x:hover { background: var(--bad-soft); color: var(--bad); }
.lines-foot { display: flex; justify-content: space-between; align-items: flex-start; margin-top: 8px; gap: 16px; }
.totals-box { width: 260px; display: grid; gap: 6px; }
.totals-box div { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.totals-box input { width: 100px; text-align: right; }
.totals-box .grand { font-weight: 700; font-size: 15px; border-top: 1px solid var(--border); padding-top: 8px; }

/* ---- modal & toast */
.overlay { position: fixed; inset: 0; background: rgba(10,10,10,.45); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px; overflow-y: auto; z-index: 50; }
.modal { background: var(--surface); border-radius: 12px; box-shadow: var(--shadow); width: 100%; max-width: 560px; border: 1px solid var(--border); }
.modal.wide { max-width: 980px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.modal-body { padding: 16px 18px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--border); }
.modal-foot .left { margin-right: auto; }
#toasts { position: fixed; bottom: 18px; right: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast { background: var(--text); color: var(--bg); padding: 10px 14px; border-radius: 9px; box-shadow: var(--shadow); max-width: 380px; font-weight: 500; }
.toast.error { background: var(--bad); color: #fff; }

.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login { width: 100%; max-width: 340px; padding: 24px; display: grid; gap: 14px; }
.login .btn { justify-content: center; padding: 9px 12px; }
.sidebar-foot a { display: inline-block; margin-top: 2px; }

@media (max-width: 1000px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .grid-2, .detail { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  #shell { grid-template-columns: 1fr; }
  #sidebar { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--border); }
  #nav { flex-direction: row; flex-wrap: wrap; } .nav-group, .sidebar-foot { display: none; }
  .page { padding: 16px; } .form-grid, .form-grid.three, .doc-parties { grid-template-columns: 1fr; }
  .doc { padding: 20px; }
}

@media print {
  :root { color-scheme: light; --surface: #fff; --bg: #fff; --text: #000; --text-2: #222; --muted: #555; --border: #ccc; }
  #sidebar, #topbar, #tabbar, .tabs, .page-head, .side, #toasts, .no-print { display: none !important; }
  #shell, .detail { display: block; } .page { padding: 0; max-width: none; }
  #main, body.layout-top #main { padding: 0 !important; }
  body { padding: 0 !important; }
  .doc { border: 0; padding: 0; border-radius: 0; }
  thead { display: table-header-group; } tr { page-break-inside: avoid; }
  .print-only { display: block; }
  @page { margin: 16mm; }
}
.print-only { display: none; }

/* ---- Windows 95/98-inspired look: grey bevels, navy title bars, teal desktop */
body { font-family: var(--ui); font-size: 14px; line-height: 1.5; background: var(--desktop); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font-family: var(--ui); font-size: 14px; }
a { color: #0000a8; text-decoration: underline; }
h1, h2, h3 { letter-spacing: 0; font-family: var(--ui); }
h2 { font-size: 13px; font-weight: 700; }
.mono { font-family: "Courier New", Courier, monospace; font-size: 13px; }
.muted { color: var(--muted); }

/* top status bar: company, switcher and sign-in details across the top of the window */
:root { --topbar-h: 36px; }
#topbar { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; min-height: var(--topbar-h); box-sizing: border-box; margin: 0; padding: 4px 8px 4px 6px; background: var(--face); border-bottom: 1px solid var(--border-strong); box-shadow: inset 0 1px #fff; position: static; z-index: 31; }   /* scrolls away with the page */
#topbar[hidden] { display: none; }
#topbar .top-brand { display: flex; align-items: center; gap: 6px; align-self: stretch; padding: 0 10px; background: var(--titlebar); color: #fff; font-weight: 700; font-size: 13px; }
#topbar .top-brand .brand-mark { color: #ffff00; }
#topbar #company-switch { padding: 0; display: flex; align-items: center; gap: 8px; }
#topbar #company-switch select { width: auto; }
#topbar .other-waiting { margin: 0; }
#topbar .sidebar-foot { margin: 0 0 0 auto; padding: 0 4px; box-shadow: none; background: transparent; display: flex; gap: 12px; align-items: center; font-size: 12px; white-space: nowrap; }
#topbar .co-tab { max-width: 260px; } #topbar .co-tab > :first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#topbar .sidebar-foot a { display: inline; }
body.has-topbar #sidebar { height: calc(100vh - 16px - var(--topbar-h)); height: calc(100dvh - 16px - var(--topbar-h)); top: 8px; }   /* --topbar-h follows the bar's real height (app.js) */
/* with the bar, the sidebar is only the menu: its heading row goes, the collapse button sits at the left of the bar,
   and a collapsed menu disappears altogether */
body.has-topbar .brand { display: none; }
#topbar #nav-toggle { margin: 0; }
body.has-topbar.nav-collapsed #shell { grid-template-columns: 1fr; }
body.has-topbar.nav-collapsed #sidebar { display: none; }
body.has-topbar.nav-collapsed #topbar .sidebar-foot, body.has-topbar.nav-collapsed #topbar #company-switch { display: flex; }
body.has-topbar.layout-side #panel { height: calc(100vh - var(--topbar-h)); top: 0; }

/* sidebar: a tool window */
#shell { grid-template-columns: 208px 1fr; gap: 0; }
#sidebar { background: var(--face); border: 0; box-shadow: var(--raised); padding: 3px; margin: 8px 0 8px 8px; height: calc(100vh - 16px); top: 8px; }
.brand { background: var(--titlebar); color: #fff; font-size: 13px; font-weight: 700; padding: 4px 6px; margin-bottom: 6px; gap: 6px; }
.brand-mark { color: #ffff00; }
#nav { gap: 0; padding: 0 5px; }
.nav-group { margin: 10px 0 2px; padding: 0 2px 3px; font-size: 13px; font-weight: 700; letter-spacing: 0; text-transform: none; color: #000;
  border-bottom: 1px solid #808080; box-shadow: 0 1px 0 #fff; }
.nav-link { color: #000; border-radius: 0; padding: 4px 8px; font-weight: 400; text-decoration: none; border: 1px dotted transparent; display: flex; align-items: center; gap: 6px; }
.nav-group:hover { text-decoration: underline; }
.nav-link:hover { background: transparent; color: #000; border-color: #000; text-decoration: none; }
.nav-link.active { background: #000080; color: #fff; font-weight: 400; }
.sidebar-foot { color: #000; font-size: 12px; margin: auto 5px 5px; padding: 6px 8px; box-shadow: var(--sunken); background: var(--face); }
.sidebar-foot a { display: block; }

/* each page is a window */
#main { padding: 8px 10px; }
.page { max-width: 1560px; margin: 0 0 24px; padding: 3px 3px 12px; background: var(--face); box-shadow: var(--raised); }   /* left-aligned: no idle gap beside the menu */
.page-head { background: var(--titlebar); margin: 0 0 10px; padding: 4px 4px 4px 8px; align-items: center; }
.page-head h1 { color: #fff; font-size: 14px; font-weight: 700; }
.page-head .sub, .page-head .sub a, .page-head .back { color: #fff; font-size: 12px; margin: 0; }
.page-head .back { display: block; margin-bottom: 1px; }
.page > div > *:not(.page-head) { margin-left: 9px; margin-right: 9px; }

/* controls */
.btn { border: 0; border-radius: 0; background: var(--face); color: #000; font-weight: 400; padding: 4px 14px; min-height: 24px; box-shadow: var(--raised); text-decoration: none; }
.btn:hover { background: var(--face); }
.btn:active { box-shadow: var(--sunken); padding: 5px 13px 3px 15px; }
.btn:focus-visible { outline: 1px dotted #000; outline-offset: -5px; }
.btn.primary { background: var(--face); color: #000; font-weight: 700; box-shadow: var(--raised), 0 0 0 1px #000; }
.btn.primary:hover { background: var(--face); }
.btn.danger { color: #a00000; }
.btn.ghost { box-shadow: none; background: transparent; color: #0000a8; text-decoration: underline; padding: 2px 6px; }
.btn.ghost:hover { background: transparent; }
.btn.sm { padding: 1px 9px; font-size: 12px; min-height: 20px; }
.btn:disabled { color: #808080; text-shadow: 1px 1px #fff; opacity: 1; }
input, select, textarea { border: 0; border-radius: 0; background: #fff; padding: 4px 6px; box-shadow: var(--sunken); }
input:focus, select:focus, textarea:focus { outline: 1px dotted #000; outline-offset: -4px; }
input[type=checkbox] { box-shadow: none; }
label.field { font-size: 13px; font-weight: 400; color: #000; gap: 3px; }
label.field .hint { font-size: 12px; }
.form-section { color: #000; text-transform: none; letter-spacing: 0; font-size: 13px; font-weight: 700; border-bottom: 1px solid #808080; box-shadow: 0 1px 0 #fff; padding-bottom: 2px; }

/* group boxes and list views */
.card { background: var(--face); border: 0; border-radius: 0; box-shadow: var(--etched); padding: 2px; }
.card-head { background: transparent; border-bottom: 1px solid #808080; box-shadow: 0 1px 0 #fff; padding: 6px 10px; }
.card-body { padding: 10px; }
.toolbar { background: transparent; border-bottom: 0; padding: 6px 6px 0; align-items: flex-end; }
.toolbar .search, .toolbar select, .toolbar .btn { margin-bottom: 6px; }
.table-wrap { background: #fff; box-shadow: var(--sunken); padding: 2px; margin: 0 4px 4px; }
.tabs { gap: 0; align-self: flex-end; }
.tab { border: 0; border-radius: 3px 3px 0 0; background: var(--face); color: #000; font-weight: 400; padding: 4px 10px 3px; margin-top: 2px;
  box-shadow: inset 1px 1px #fff, inset -1px 0 #0a0a0a, inset -2px 0 #808080, inset 2px 2px #dfdfdf; }
.tab:hover { background: var(--face); }
.tab.active { background: var(--face); color: #000; font-weight: 700; margin-top: 0; padding: 5px 11px 4px; position: relative; z-index: 1; }
.tab .n { font-weight: 400; color: var(--muted); }
.page > div > .tabs { border-bottom: 1px solid #fff; margin-bottom: 10px; }
th { background: var(--face); color: #000; font-size: 13px; font-weight: 400; text-transform: none; letter-spacing: 0; padding: 4px 8px; border: 0; box-shadow: var(--raised); }
th.sortable:hover { color: #000; }
th.sortable:active { box-shadow: var(--sunken); }
td { padding: 5px 8px; border-bottom: 1px solid #e4e4e4; }
tr.clickable:hover td, tr.clickable:hover td * { background: #000080; color: #fff; }
tr.clickable:hover td .badge { border-color: #fff; }
tr.clickable:hover td .btn { background: var(--face); color: #000; }
.badge { border-radius: 0; border: 1px solid currentColor; background: #fff; font-size: 12px; font-weight: 400; padding: 0 5px; color: #000; }
.empty { background: #fff; color: #000; }
.card.empty { box-shadow: var(--sunken); }

.kpis { gap: 10px; }
.kpi { padding: 8px 12px 10px; text-decoration: none; color: #000; }
.kpi .label { color: #000; font-weight: 700; font-size: 13px; }
.kpi .value { font-size: 22px; font-weight: 700; letter-spacing: 0; background: #fff; box-shadow: var(--sunken); padding: 4px 8px; margin: 6px 0; text-align: right; font-family: "Courier New", Courier, monospace; }
.kpi .note { font-size: 12px; }
.list-row { padding: 6px 10px; border-bottom: 1px solid #808080; box-shadow: 0 1px 0 #fff; text-decoration: none; color: #000; }
.list-row:last-child { box-shadow: none; }
a.list-row:hover, a.list-row:hover * { background: #000080; color: #fff; }
a.list-row:hover .badge { border-color: #fff; }
.chart { background: #fff; box-shadow: var(--sunken); padding: 8px; }
.chart .band:hover { fill: #e4e4e4; }
.tip { border: 1px solid #000; border-radius: 0; background: #ffffe1; box-shadow: var(--shadow); }
.progress { height: 16px; background: #fff; border: 0; border-radius: 0; padding: 3px; box-shadow: var(--sunken); min-width: 90px; }
.progress i { border-radius: 0; background: repeating-linear-gradient(90deg, #000080 0 9px, transparent 9px 11px); }
.kv dt { color: #000; }

/* dialogs */
.overlay { background: rgba(0,0,0,.2); }
.modal { border: 0; border-radius: 0; background: var(--face); box-shadow: var(--raised), 3px 3px 0 rgba(0,0,0,.4); padding: 3px; }
.modal-head { background: var(--titlebar); border-bottom: 0; padding: 3px 3px 3px 8px; }
.modal-head h2 { color: #fff; font-size: 13px; }
.modal-head .btn { background: var(--face); color: #000; font-weight: 700; width: 20px; min-height: 18px; height: 18px; padding: 0; justify-content: center; box-shadow: var(--raised); text-decoration: none; font-size: 11px; }
.modal-body { padding: 12px; }
.modal-foot { border-top: 0; padding: 2px 12px 12px; }
.toast { background: #ffffe1; color: #000; border: 1px solid #000; border-radius: 0; box-shadow: var(--shadow); font-weight: 400; }
.toast.error { background: #ffffe1; color: #a00000; }
.lines th { background: transparent; box-shadow: none; padding: 5px 4px; }
.lines .x { border-radius: 0; }
.totals-box .grand { border-top: 1px solid #808080; box-shadow: inset 0 1px 0 #fff; }

.doc { border: 0; border-radius: 0; background: #fff; box-shadow: var(--sunken); }
.doc table th { background: transparent; box-shadow: none; font-weight: 700; border-bottom: 2px solid #000; padding-left: 0; }
.doc-kind, .doc-company { font-family: "Times New Roman", Times, serif; }
.doc-kind { font-size: 24px; }

.login-wrap { background: var(--desktop); }
.login { border: 0; border-radius: 0; background: var(--face); box-shadow: var(--raised), 3px 3px 0 rgba(0,0,0,.4); padding: 3px 3px 16px; gap: 12px; }
.login > *:not(.brand) { margin-left: 14px; margin-right: 14px; }
.login .brand { margin: 0 0 6px; }
.login .btn { justify-content: center; }

.mono, td:first-child .cell-main { white-space: nowrap; }
/* details panels: long values (parent product names, suppliers, addresses) wrap inside the box; only the
   short meta values on printed documents stay on one line */
.kv { grid-template-columns: minmax(70px, auto) minmax(0, 1fr); }
.kv dd { min-width: 0; overflow-wrap: anywhere; white-space: normal; }
.doc .kv dd { white-space: nowrap; }
@media (max-width: 760px) { #shell { grid-template-columns: 1fr; } #sidebar { height: auto; margin: 6px; position: static; } #main { padding: 0 6px 6px; } }
@media print { body { background: #fff; } .page { box-shadow: none; padding: 0; margin: 0; background: #fff; } .page > div > *:not(.page-head) { margin: 0; } .doc { box-shadow: none; } }

/* readability pass: larger, smoother type and roomier rows, same bevels */
h2 { font-size: 14px; }
.mono { font-family: Menlo, Consolas, "Lucida Console", "Courier New", monospace; font-size: 13px; }
.small, .cell-sub, .kpi .note, label.field .hint, .sidebar-foot, .btn.sm, .tab .n { font-size: 12.5px; }
.brand { font-size: 14px; padding: 5px 8px; }
.nav-group { font-size: 14px; margin-top: 14px; }
.nav-link { padding: 5px 8px; font-size: 14px; }
.page-head { padding: 6px 6px 6px 10px; }
.page-head h1 { font-size: 16px; }
.page-head .sub, .page-head .sub a, .page-head .back { font-size: 12.5px; }
.btn { padding: 5px 15px; min-height: 28px; }
.btn:active { padding: 6px 14px 4px 16px; }
.btn.sm { padding: 2px 10px; min-height: 22px; }
input, select, textarea { padding: 5px 7px; }
label.field, .form-section, .kpi .label { font-size: 13.5px; }
th { font-size: 13.5px; padding: 6px 10px; font-weight: 700; }
td { padding: 8px 10px; }
.badge { font-size: 12.5px; padding: 1px 7px; }
.tab { padding: 5px 12px 4px; font-size: 13.5px; }
.tab.active { padding: 6px 13px 5px; }
.list-row { padding: 8px 12px; }
.kpi .value { font-family: var(--ui); font-size: 24px; padding: 6px 10px; }
.modal-head h2 { font-size: 14px; }
.modal-head .btn { width: 22px; height: 20px; min-height: 20px; padding: 0; font-size: 12px; }
.chart text { font-size: 11.5px; fill: #222; }
.doc { font-size: 14px; }

/* less grey: ivory window face, white panels, tinted status tags, a little colour */
.card { background: #fff; }
.card-head { background: linear-gradient(90deg, #e0e6fa 0%, #ffffff 100%); border-bottom: 1px solid #a39f8f; box-shadow: none; }
.card-head h2, .kpi .label, .nav-group { color: #000080; }
.toolbar { background: var(--face); }
.table-wrap { margin: 0; box-shadow: none; padding: 0; border-top: 1px solid #a39f8f; }
.chart { box-shadow: none; padding: 0; }
.kpi .value { background: #f7f9ff; color: #000080; }
.list-row { border-bottom: 1px solid #e3e0d4; box-shadow: none; }
td { border-bottom: 1px solid #ebe8de; }
tr.clickable:hover td, tr.clickable:hover td *, a.list-row:hover, a.list-row:hover * { background: #000080; color: #fff; }
.badge { background: #f4f2ea; }
.badge.info { background: var(--info-soft); } .badge.good { background: var(--good-soft); }
.badge.warn { background: var(--warn-soft); } .badge.bad { background: var(--bad-soft); }
.nav-link.active { background: #000080; color: #fff; }
.sidebar-foot { background: #fff; }
.modal-foot { background: transparent; }
td:nth-child(2) { white-space: nowrap; }

/* collapsible side menu */
#brand-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#nav-toggle { margin-left: auto; width: 22px; height: 20px; min-height: 20px; padding: 0; justify-content: center; font-size: 13px; font-weight: 700; line-height: 1; flex: none; }
#nav-toggle:active { padding: 0; }
body.nav-collapsed #nav, body.nav-collapsed .sidebar-foot, body.nav-collapsed #brand-name, body.nav-collapsed .brand-mark { display: none; }
body.nav-collapsed .brand { padding: 4px 3px; margin: 0; justify-content: center; }
body.nav-collapsed #nav-toggle { margin: 0; }
@media (min-width: 761px) {
  body.nav-collapsed #shell { grid-template-columns: 42px 1fr; }
  body.nav-collapsed #sidebar { overflow: hidden; }
}
@media print { #nav-toggle { display: none; } }

/* slightly smaller type */
body, button, input, select, textarea, .nav-link, .nav-group, .doc { font-size: 12px; }
h2, .brand, .modal-head h2 { font-size: 12.5px; }
.page-head h1 { font-size: 14px; }
th, .tab, label.field, .form-section, .kpi .label { font-size: 12px; }
.mono { font-size: 11.5px; }
.small, .cell-sub, .kpi .note, label.field .hint, .sidebar-foot, .btn.sm, .tab .n, .badge, .page-head .sub, .page-head .sub a, .page-head .back { font-size: 11px; }
.kpi .value { font-size: 20px; }
#nav-toggle { font-size: 11px; }
.chart text { font-size: 10.5px; }
td { padding: 7px 10px; }

/* company switcher; the second company gets its own title-bar colour so the two are hard to mix up */
#company-switch { padding: 0 5px 4px; }
/* company tabs: the open company is a pressed navy (or green) tab; the others are raised buttons with a count of waiting work */
.co-tabs { display: flex; gap: 3px; flex-wrap: wrap; }
.co-tab { display: flex; align-items: center; gap: 7px; font: inherit; font-size: 12px; font-weight: 700; padding: 3px 11px; border: 0; cursor: pointer; color: #000; background: var(--face); box-shadow: var(--raised); }
.co-tab:hover { text-decoration: underline; }
.co-tab.active { background: #000080; color: #fff; box-shadow: var(--sunken); cursor: default; }
.co-tab.active[data-key="forbecome"] { background: #0b5d3b; }
.co-n { color: var(--bad); font-size: 11px; font-weight: 700; font-variant-numeric: tabular-nums; }
#topbar #company-switch { margin-left: 2px; }
body.nav-collapsed #company-switch { display: none; }
body[data-company="forbecome"] { --titlebar: linear-gradient(90deg, #0b5d3b 0%, #2f9e6b 100%); --desktop: #4d7a66; }
body[data-company="forbecome"] .nav-link.active, body[data-company="forbecome"] tr.clickable:hover td, body[data-company="forbecome"] tr.clickable:hover td *,
body[data-company="forbecome"] a.list-row:hover, body[data-company="forbecome"] a.list-row:hover * { background: #0b5d3b; }

/* shipping label: hidden on screen, the only thing on paper while a label prints */
#label-print { display: none; }
.ship-label { width: 100mm; height: 150mm; box-sizing: border-box; padding: 5mm; background: #fff; color: #000; font: 10pt/1.3 Arial, Helvetica, sans-serif;
  display: flex; flex-direction: column; gap: 3mm; page: label; break-after: page; overflow: hidden; }
.ship-label:last-child { break-after: auto; }
.ship-label .pre { white-space: pre-line; }
.sl-cap { font-size: 7pt; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: #000; margin-bottom: .5mm; }
.sl-from { font-size: 8.5pt; padding-bottom: 3mm; border-bottom: 1pt solid #000; }
.sl-to { flex: 1; border: 1.5pt solid #000; padding: 4mm; }
.sl-name { font-size: 17pt; font-weight: 700; line-height: 1.15; margin-bottom: 1.5mm; }
.sl-addr { font-size: 14pt; line-height: 1.25; }
.sl-phone { font-size: 10pt; margin-top: 2mm; }
.sl-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 3mm; font-size: 9pt; border-top: 1pt solid #000; padding-top: 2.5mm; }
.sl-meta b { font-size: 11pt; }
.sl-parcel { font-size: 15pt !important; }
.sl-carrier { display: flex; justify-content: space-between; gap: 3mm; font-size: 11pt; font-weight: 700; border-top: 1pt solid #000; padding-top: 2.5mm; }
.sl-carrier .mono { font-family: "Courier New", monospace; font-size: 11pt; }
.sl-note { font-size: 8.5pt; border-top: 1pt dashed #000; padding-top: 2mm; }
@page label { size: 100mm 150mm; margin: 0; }
@media print {
  body.printing-label #shell, body.printing-label .overlay { display: none !important; }
  body.printing-label #label-print { display: block; }
  body.printing-label { background: #fff; padding: 0; margin: 0; }
}

/* 3PL report: laid out as a document so it prints cleanly */
.doc.report { padding: 22px 24px; }
.doc.report .doc-top { margin-bottom: 16px; border-bottom: 2px solid #000080; padding-bottom: 12px; align-items: flex-end; }
@media (max-width: 760px) { .doc.report .doc-top { flex-wrap: wrap; } .doc.report .doc-top > .no-print { justify-content: flex-start; } }
.doc.report table th { padding-left: 8px; }
.doc.report table td { padding-left: 8px; }
.doc.report .kpi { box-shadow: var(--etched); }
@media print { .doc.report .kpis { display: grid; } .doc.report .kpi { border: 1px solid #999; box-shadow: none; } }
.doc.report { overflow-x: auto; }
.doc.report table td:first-child { white-space: nowrap; }
@media print { .doc.report { overflow: visible; } }
.doc.report .doc-foot { margin-top: 18px; padding-top: 8px; border-top: 1px solid #999; font-size: 11px; color: #333; }
@media print {
  .doc.report .doc-top { margin-bottom: 12px; }
  .doc.report .kpis { gap: 10px; margin-bottom: 14px; }
  .doc.report .kpi .value { font-size: 20px; }
  .doc.report table { width: 100%; font-size: 11.5px; }
  .doc.report table th, .doc.report table td { padding: 4px 6px; }
  .doc.report a { color: #000; text-decoration: none; }
}

/* product search suggestions (sits above dialogs) */
.suggest { position: fixed; z-index: 200; max-width: 520px; max-height: 320px; overflow-y: auto; background: #fff; color: #000; border: 1px solid #000; box-shadow: var(--shadow); }
.suggest-item { padding: 5px 9px; cursor: pointer; border-bottom: 1px solid #ebe8de; }
.suggest-item:last-child { border-bottom: 0; }
.suggest-item.active, .suggest-item.active * { background: #000080; color: #fff; }
.suggest-empty { padding: 8px 9px; color: var(--muted); }

/* horizontal bar chart (online orders by state): thin single-colour bars, value labelled on each row */
.bars { display: grid; gap: 7px; }
.bar-row { display: grid; grid-template-columns: 62px 1fr 92px; align-items: center; gap: 10px; padding: 2px 0; }
.bar-row:hover { background: var(--surface-2); }
.bar-label { font-weight: 700; color: var(--text); }
.bar-track { height: 14px; border-left: 1px solid var(--border-strong); }
.bar-fill { height: 100%; background: var(--series-1); border-radius: 0 4px 4px 0; min-width: 2px; }
.bar-fill.muted-fill { background: #9aa0a8; }
.bar-value { text-align: right; font-variant-numeric: tabular-nums; color: var(--text); font-weight: 700; white-space: nowrap; }
.bar-value .muted { font-weight: 400; }

/* a form cell holding a field plus a small option under it */
.field-cell { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field-cell .field.check { font-size: 12px; gap: 6px; }

/* CRM pipeline board */
.board { display: grid; grid-template-columns: repeat(4, minmax(190px, 1fr)); gap: 10px; overflow-x: auto; align-items: start; }
.board-col { background: #fff; box-shadow: var(--etched); padding: 2px; min-height: 120px; }
.board-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; padding: 6px 9px; background: linear-gradient(90deg, #e0e6fa 0%, #ffffff 100%); border-bottom: 1px solid #a39f8f; color: #000080; }
.board-head .small { color: var(--text-2); }
.board-empty { padding: 18px 9px; color: var(--muted); text-align: center; }
.deal { margin: 6px; padding: 8px 9px; background: var(--face); box-shadow: var(--raised); display: grid; gap: 3px; }
.deal-title { font-weight: 700; color: var(--text); text-decoration: none; overflow-wrap: anywhere; }
.deal-title:hover { text-decoration: underline; }
.deal-foot { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-top: 2px; }
.deal-actions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; }
@media (max-width: 900px) { .board { grid-template-columns: repeat(4, 220px); } }

/* prospect line: stage steps across the top of a prospect, and note previews on the board cards */
.deal-note { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.stage-line { display: flex; flex-wrap: wrap; gap: 0; margin: 0 9px 12px; }
.stage-step { flex: 1 1 130px; padding: 6px 10px; border: 0; background: var(--face); box-shadow: var(--raised); cursor: pointer; color: var(--text); text-align: left; }
.stage-step.done { color: var(--good); }
.stage-step.current { background: #000080; color: #fff; font-weight: 700; box-shadow: var(--sunken); }
body[data-company="forbecome"] .stage-step.current { background: #0b5d3b; }

/* red count used in the other-company notice */
.nav-count { background: var(--bad); color: #fff; font-size: 11px; line-height: 16px; min-width: 18px; text-align: center; padding: 0 5px; border-radius: 9px; font-weight: 700; }

/* work waiting in the company you are not looking at */
.other-waiting { margin: 4px 0 2px; display: grid; gap: 3px; }
.other-waiting a { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; color: var(--bad); text-decoration: none; padding: 3px 4px; background: #fff; box-shadow: var(--sunken); }
.other-waiting a:hover { text-decoration: underline; }
body.nav-collapsed .other-waiting { display: none; }

/* product hero images */
.thumb { width: 40px; height: 40px; object-fit: contain; background: #fff; border: 1px solid var(--border-strong); flex: none; display: inline-block; vertical-align: middle; }
.thumb-empty { background: var(--surface-2); }
.doc .thumb { border-color: #bbb; }
@media print { .thumb-empty { display: none; } }
/* a picture button: thumbnails and the product page picture open the image viewer */
.thumb-btn { display: inline-flex; padding: 0; border: 0; background: none; cursor: zoom-in; flex: none; vertical-align: middle; line-height: 0; font: inherit; color: inherit; box-shadow: none; }
.thumb-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
/* ---- image viewer: one picture over the whole window; click/tap, wheel or pinch to zoom, drag to pan */
.overlay.viewer { background: rgba(0,0,0,.9); padding: 0; overflow: hidden; align-items: stretch; z-index: 60; }
.viewer-stage { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; overflow: hidden; touch-action: none; cursor: zoom-out; overscroll-behavior: contain; }
.viewer-img { display: block; max-width: calc(100vw - 16px); max-height: calc(100vh - 72px); width: auto; height: auto; object-fit: contain; background: #fff; user-select: none; -webkit-user-select: none; -webkit-user-drag: none; transform-origin: center center; will-change: transform; cursor: zoom-in; transition: transform .15s ease-out; }
.viewer.is-drag .viewer-img, .viewer.is-pinch .viewer-img { transition: none; }
.viewer.is-zoomed .viewer-img { cursor: grab; }
.viewer.is-drag .viewer-img { cursor: grabbing; }
.viewer-bar { position: absolute; left: 50%; bottom: max(12px, env(safe-area-inset-bottom)); transform: translateX(-50%); display: flex; align-items: center; gap: 5px; padding: 4px 5px; background: var(--face); box-shadow: var(--raised); max-width: calc(100vw - 12px); }
.viewer-bar .btn { min-width: 30px; justify-content: center; }
.viewer-title { max-width: 34ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin: 0 6px 0 4px; font-size: 12.5px; }
.viewer-zoom { font-variant-numeric: tabular-nums; min-width: 4.5ch; text-align: right; font-size: 12.5px; margin-right: 2px; }
@media (max-width: 760px) { .viewer-title { display: none; } }
@media (prefers-reduced-motion: reduce) { .viewer-img { transition: none; } }
@media print { .overlay.viewer { display: none; } }

/* Settings: recent Shopify deliveries, three rows unless opened */
.log-box { border-top: 1px solid var(--border); max-height: 132px; overflow: hidden; }
.log-box.open { max-height: 360px; overflow-y: auto; }
/* Inventory: parent rows */
.group-row { cursor: pointer; background: var(--surface-2); }
.group-row:hover td { background: #e6eefc; }
.caret { display: inline-block; width: 14px; color: var(--muted); font-size: 11px; }

/* ---- top-menu layout: menu bar across the top, full-width content, footer bar */
body.layout-top { padding-bottom: 34px; }
body.layout-top #shell { display: block; }
body.layout-top #sidebar { position: sticky; top: 0; height: auto; margin: 0; padding: 0 8px; box-shadow: var(--raised); display: flex; flex-direction: row; align-items: center; gap: 4px; flex-wrap: wrap; z-index: 30; overflow: visible; }
body.layout-top .brand { margin: 0 8px 0 0; padding: 4px 10px; align-self: stretch; display: flex; align-items: center; }
body.layout-top #nav-toggle { display: none; }
body.layout-top #company-switch { padding: 0; margin-right: 6px; display: flex; align-items: center; gap: 8px; }
body.layout-top #company-switch select { width: auto; }
body.layout-top .other-waiting { margin: 0; }
body.layout-top #nav { flex-direction: row; align-items: center; padding: 0; gap: 2px; flex: 1; flex-wrap: wrap; }
body.layout-top #nav > .nav-link { padding: 5px 10px; border: 0; }
body.layout-top #nav > .nav-link.active { background: #000080; color: #fff; }
body.layout-top .menu { position: relative; }
body.layout-top .menu-btn { border: 0; background: transparent; padding: 5px 10px; cursor: pointer; color: var(--text); font: inherit; }
body.layout-top .menu-btn:hover, body.layout-top .menu.open .menu-btn { background: #000080; color: #fff; }
body.layout-top .menu-list { display: none; position: absolute; left: 0; top: 100%; min-width: 190px; background: var(--face); box-shadow: var(--raised); padding: 3px; z-index: 40; }
body.layout-top .menu.open .menu-list { display: block; }
body.layout-top .menu-list .nav-link { display: flex; align-items: center; gap: 8px; padding: 5px 12px; min-width: 0; }
body.layout-top .menu-btn .nav-n { margin-left: 4px; } body.layout-top .menu-btn:hover .nav-n, body.layout-top .menu.open .menu-btn .nav-n { color: #fff; }
body.layout-top .menu-list .nav-link.active { background: #000080; color: #fff; }
body.layout-top .sidebar-foot { margin: 0 0 0 auto; padding: 4px 8px; box-shadow: none; background: transparent; font-size: 12px; display: flex; gap: 8px; align-items: center; }
body.layout-top .sidebar-foot a { display: inline; }
body.layout-top #main { padding: 10px 12px; }
body.layout-top .page { max-width: none; margin: 0; }
body.layout-top .detail { grid-template-columns: minmax(0, 1fr) 360px; }
body[data-company="forbecome"].layout-top #nav > .nav-link.active, body[data-company="forbecome"].layout-top .menu-btn:hover, body[data-company="forbecome"].layout-top .menu.open .menu-btn, body[data-company="forbecome"].layout-top .menu-list .nav-link.active { background: #0b5d3b; }
#footer[hidden] { display: none !important; }   /* the footer bar belongs to the top-menu layout only */
#footer { position: fixed; left: 0; right: 0; bottom: 0; height: 30px; z-index: 30; display: flex; align-items: center; gap: 0; padding: 0 6px; background: var(--face); box-shadow: var(--raised); font-size: 12px; }
#footer > span { padding: 3px 10px; box-shadow: var(--sunken); margin: 0 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#footer .foot-alert { color: var(--bad); font-weight: 700; }
#footer .foot-right { margin-left: auto; }
@media (max-width: 760px) { body.layout-top .detail { grid-template-columns: 1fr; } #footer > span:not(:first-child):not(.foot-alert) { display: none; } }
@media print { #footer { display: none; } body.layout-top #sidebar { display: none; } }

/* ---- phones and small tablets: one column, a menu drawer behind the ☰ button, full-screen dialogs,
   tables that scroll sideways, and inputs large enough that iOS does not zoom into them */
@media (max-width: 760px) {
  html { -webkit-text-size-adjust: 100%; }
  body { padding-bottom: 0; }
  #shell { display: block; }
  #sidebar, body.layout-top #sidebar { position: sticky; top: 0; z-index: 35; height: auto; margin: 0; padding: 4px 6px; display: flex; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 4px 8px; box-shadow: var(--raised); overflow: visible; }
  .brand, body.layout-top .brand { flex: 1 1 auto; margin: 0; padding: 3px 6px; min-width: 0; align-self: auto; }
  #nav-toggle, body.layout-top #nav-toggle { display: inline-flex; width: 34px; height: 30px; min-height: 30px; font-size: 16px; margin: 0; order: 2; }
  #brand-name { font-size: 13px; }
  #company-switch, body.layout-top #company-switch { flex: 1 1 100%; order: 3; padding: 0; margin: 0; display: none; }
  body.nav-open #company-switch { display: block; }
  .co-tabs { gap: 4px; padding: 4px 4px 2px; } .co-tab { flex: 1 1 40%; justify-content: center; padding: 8px 10px; font-size: 13px; }
  #nav, body.layout-top #nav { display: none; flex: 1 1 100%; order: 4; flex-direction: column; flex-wrap: nowrap; padding: 4px 0 6px; max-height: calc(100vh - 60px); overflow-y: auto; }
  body.nav-open #nav { align-items: stretch; }
  body.layout-top .menu, body.layout-top #nav > .nav-link { width: 100%; }
  body.layout-top .menu-btn { text-align: left; }
  body.nav-open #nav { display: flex; }
  body.nav-collapsed #nav, body.nav-collapsed .sidebar-foot, body.nav-collapsed #brand-name, body.nav-collapsed .brand-mark { display: revert; }
  body.nav-open.nav-collapsed #nav { display: flex; }
  /* the drawer shows every page: group headings become plain labels and desktop folding does not apply */
  .nav-group { display: flex; margin: 8px 0 2px; padding: 6px 10px 3px; font-weight: 700; color: #000080; border-bottom: 1px solid var(--border-strong); pointer-events: none; }
  .nav-chev, .nav-group .nav-n { display: none; }
  .nav-section.folded .nav-link { display: flex; }
  body.layout-side .nav-section.nav-last { margin-top: 0; padding-top: 0; }
  .nav-link, body.layout-top #nav > .nav-link, body.layout-top .menu-list .nav-link { padding: 10px 10px; font-size: 14px; border: 0; }
  /* in the top-menu layout the drop-downs become plain sections of the drawer */
  body.layout-top .menu { position: static; }
  body.layout-top .menu-btn { display: block; width: 100%; text-align: left; padding: 8px 10px; margin-top: 8px; font-weight: 700; color: #000080; border-bottom: 1px solid var(--border-strong); background: transparent; pointer-events: none; }
  body.layout-top .menu-list { display: block; position: static; box-shadow: none; padding: 0; min-width: 0; }
  .sidebar-foot, body.layout-top .sidebar-foot { display: none; flex: 1 1 100%; order: 5; margin: 0; }
  body.nav-open .sidebar-foot { display: flex; gap: 10px; align-items: center; }
  .other-waiting { margin: 0; }
  #main, body.layout-top #main { padding: 8px; }
  .page, body.layout-top .page { max-width: none; margin: 0; padding: 0 0 20px; box-shadow: none; }
  .page > div > *:not(.page-head) { margin-left: 0; margin-right: 0; }
  .page-head { margin: 0 0 10px; padding: 8px 8px; flex-direction: column; align-items: stretch; }
  .page-head h1 { font-size: 16px; }
  .page-head .actions { justify-content: flex-start; }
  .page-head .actions .btn, .page-head .actions select { flex: 1 1 auto; justify-content: center; }
  .kpis { grid-template-columns: 1fr 1fr; gap: 8px; }
  .kpi { padding: 8px 10px; }
  .kpi .value { font-size: 18px; }
  .grid-2, .detail, body.layout-top .detail { grid-template-columns: 1fr; gap: 10px; }
  .toolbar { padding: 6px; gap: 6px; }
  .toolbar .tabs { width: 100%; overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; }
  .tab { white-space: nowrap; }
  .toolbar .search { max-width: none; flex: 1 1 100%; margin-bottom: 6px; }
  .toolbar .spacer { display: none; }
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0; }
  table { min-width: 560px; }
  th, td { padding: 6px 7px; }
  .doc { padding: 14px 12px; min-width: 0; overflow-x: auto; }
  .doc-parties { grid-template-columns: 1fr; gap: 12px; }
  .doc table { min-width: 420px; }
  .doc table th, .doc table td { padding-right: 6px; }
  .doc-totals { width: 100%; }
  .doc.report { padding: 12px; }
  .board { grid-template-columns: repeat(4, 82vw); }
  .bars .bar-row { grid-template-columns: 48px 1fr 80px; }
  .overlay { padding: 0; align-items: stretch; }
  .modal, .modal.wide { max-width: none; width: 100%; min-height: 100vh; border-radius: 0; padding: 0; box-shadow: none; }
  .modal-head { position: sticky; top: 0; z-index: 2; }
  .modal-body { padding: 10px; }
  .modal-foot { position: sticky; bottom: 0; background: var(--face); flex-wrap: wrap; }
  .modal-foot .btn { flex: 1 1 auto; justify-content: center; }
  .form-grid, .form-grid.three { grid-template-columns: 1fr; }
  .lines { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .lines table, table.lines { min-width: 640px; }
  .lines-foot { flex-direction: column; }
  .totals-box { width: 100%; }
  input, select, textarea, button, .btn { font-size: 16px; }
  .btn.sm, .tab, .badge { font-size: 13px; }
  .list-row { padding: 8px 10px; }
  .login-wrap { padding: 12px; align-items: flex-start; }
  #toasts { left: 10px; right: 10px; bottom: 10px; }
  .toast { max-width: none; }
  #footer { display: none; }
  .stage-line { margin: 0 0 10px; }
  .stage-step { flex: 1 1 46%; }
  .suggest { max-width: calc(100vw - 20px); }
}


/* ---- split view: on a wide window a detail opens in a panel beside the list it came from */
body.split #main { display: grid; grid-template-columns: minmax(0, 1fr) minmax(460px, 44%); column-gap: 6px; align-items: start; }
body.split #page { max-width: none; margin-right: 0; }
#panel { position: sticky; top: 0; height: 100vh; overflow: auto; background: var(--bg); min-width: 0; }
#panel[hidden] { display: none; }
#panel .panel-bar { display: flex; justify-content: flex-end; gap: 6px; }
#panel .panel-bar:empty { display: none; }
#panel-page { max-width: none; margin-left: 0; }
#panel .detail, #panel .email-editor, #panel .grid-2 { grid-template-columns: 1fr; }
#panel .kpis { grid-template-columns: repeat(2, 1fr); }
#panel .doc { padding: 24px 26px; }
#panel .doc-parties { grid-template-columns: 1fr 1fr; }
body.layout-side #panel { height: 100vh; }
body.layout-top #panel { top: 42px; height: calc(100vh - 42px - 34px); }
@media print { body.split #page { display: none; } body.split #main { display: block; } #panel { position: static; height: auto; overflow: visible; border: 0; } #panel .panel-bar { display: none; } }

/* ---- phones: the tab bar along the bottom, the install steps, and a first table column that stays put
   while a wide table scrolls sideways. Also the installed (home screen) app's safe areas. */
#tabbar { display: none; }
.install-steps { margin: 0; padding-left: 20px; } .install-steps li { margin: 0 0 8px; }
@media (max-width: 760px) {
  #tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; display: flex; align-items: stretch; background: var(--face); box-shadow: var(--raised); padding: 3px 3px calc(3px + env(safe-area-inset-bottom)); }
  #tabbar a, #tabbar button { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; min-height: 48px; padding: 4px 2px; margin: 0; border: 0; background: transparent; color: #000; font: inherit; font-size: 11px; line-height: 1.15; text-decoration: none; position: relative; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; -webkit-tap-highlight-color: transparent; }
  #tabbar .tab-icon { display: block; width: 22px; height: 22px; }
  #tabbar svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
  #tabbar a.active { color: var(--accent); font-weight: 700; box-shadow: var(--sunken); background: var(--surface-2); }
  #tabbar a:hover, #tabbar button:hover { text-decoration: none; }
  #tabbar .tab-count { position: absolute; top: 3px; left: calc(50% + 4px); min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px; background: var(--bad); color: #fff; font-size: 10.5px; font-weight: 700; line-height: 17px; text-align: center; }
  #main, body.layout-top #main { padding-bottom: calc(72px + env(safe-area-inset-bottom)); }
  #toasts { bottom: calc(72px + env(safe-area-inset-bottom)); }
  #nav, body.layout-top #nav { max-height: calc(100vh - 130px - env(safe-area-inset-bottom)); }
  .sidebar-foot { padding-bottom: 6px; }
  body.nav-open .sidebar-foot { flex-wrap: wrap; }
  .table-wrap td:first-child, .table-wrap th:first-child { position: sticky; left: 0; z-index: 1; background: var(--surface); box-shadow: 1px 0 0 var(--border); }
  .table-wrap th:first-child { background: var(--face); z-index: 2; }
  .modal-foot { padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
}
@media (display-mode: standalone) {
  /* no browser chrome: keep the header clear of the notch on a phone held sideways */
  #sidebar { padding-left: max(6px, env(safe-area-inset-left)); padding-right: max(6px, env(safe-area-inset-right)); }
}

/* ---- phones: list rows as cards (see dataTable in core.js) and the sort control that replaces column headings */
.card-sort { display: none; }
@media (max-width: 760px) {
  .card-sort { display: flex; gap: 6px; align-items: center; flex: 1 1 100%; margin-bottom: 6px; }
  .card-sort select { flex: 1 1 auto; margin: 0; }
  .card-sort .btn { margin: 0; min-width: 36px; justify-content: center; }
  .toolbar .search { margin-bottom: 6px; }
  .cards { display: block; }
  .card-row { padding: 9px 10px; border-bottom: 1px solid var(--border); background: var(--surface); }
  .card-row:last-child { border-bottom: 0; }
  .card-row.clickable { cursor: pointer; }
  .card-row.clickable:active { background: var(--surface-2); }
  .card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
  .card-title { min-width: 0; overflow-wrap: anywhere; font-weight: 650; display: flex; flex-direction: column; gap: 2px; }
  .card-title .cell-main, .card-title .mono { font-weight: 650; }
  .card-amount { flex: none; font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }
  .card-meta { margin-top: 3px; display: flex; flex-wrap: wrap; align-items: center; gap: 2px 0; color: var(--muted); font-size: 12.5px; min-width: 0; }
  .card-meta > * { min-width: 0; overflow-wrap: anywhere; }
  .card-meta > *:not(:last-child)::after { content: "·"; margin: 0 6px; color: var(--border-strong); }
  .card-meta .cell-sub { display: inline; }
  .card-meta .thumb { width: 28px; height: 28px; }
  .card-tags { margin-top: 6px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
  .cards .empty { padding: 20px 10px; }
}
