/* PSC Books — the shop's buying ledger and accounts.
   Light working surface, PSC gold for the brand, one colour per buying channel. */
:root {
  --bg: #eef0f3;
  --panel: #ffffff;
  --ink: #1d2128;
  --dim: #5f6875;
  --faint: #8b93a0;
  --line: #dde1e7;
  --line2: #eceff3;
  --gold: #c9962b;
  --gold-ink: #7a5610;
  --gold-tint: #faf1dc;
  --side: #20242b;
  --side-ink: #c6ccd5;
  --good: #11804a;
  --bad: #c0352b;
  --focus: #2f6fdf;
  /* buying channels */
  --c-customer: #0f7b6c;
  --c-distributor: #3b4cc0;
  --c-show: #9b3d8f;
  --c-online: #c2410c;
  --c-retail: #4d7c0f;
  --c-other: #6b7280;
  --r: 8px;
  --shadow: 0 1px 2px rgba(20, 24, 31, .06), 0 2px 8px rgba(20, 24, 31, .04);
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink);
  font: 400 15px/1.45 "Archivo", system-ui, sans-serif;
  font-variation-settings: "wdth" 100;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
.muted { color: var(--dim); }
.faint { color: var(--faint); }
.num, td.num, th.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.good { color: var(--good); }
.bad { color: var(--bad); }
a { color: inherit; }
h1, h2, h3 { margin: 0; font-variation-settings: "wdth" 112; letter-spacing: -.01em; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ---------- sign in ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-box { width: 100%; max-width: 360px; background: var(--panel); border-radius: 12px; padding: 28px; box-shadow: var(--shadow); }
.login-box h1 { font-size: 26px; margin: 12px 0 4px; }
.login-box img { border-radius: 12px; }
.login-box label { display: block; margin-top: 14px; font-weight: 600; font-size: 13px; }
.login-box input { margin-top: 5px; }
.msg { color: var(--bad); min-height: 20px; margin-top: 10px; font-size: 14px; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 228px 1fr; min-height: 100vh; background: linear-gradient(to right, var(--side) 228px, transparent 228px); }
.side { min-width: 0; background: var(--side); color: var(--side-ink); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; padding: 18px 12px; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-weight: 800; font-size: 18px; font-variation-settings: "wdth" 115; padding: 0 8px 18px; }
.brand img { border-radius: 8px; }
#nav { display: flex; flex-direction: column; gap: 2px; }
#nav a { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 9px 10px; border-radius: 7px; color: var(--side-ink); text-decoration: none; font-weight: 500; }
#nav a:hover { background: rgba(255, 255, 255, .06); color: #fff; }
#nav a.on { background: rgba(201, 150, 43, .16); color: #f3d38d; font-weight: 700; }
#nav .nav-gap { height: 14px; }
#nav .lock { font-size: 11px; color: #8d95a1; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 2px; border-top: 1px solid rgba(255, 255, 255, .08); padding-top: 12px; }
.who { font-size: 13px; color: #fff; padding: 0 10px 6px; }
.who small { display: block; color: #8d95a1; }
.side-link { background: none; border: 0; text-align: left; color: var(--side-ink); font: inherit; font-size: 13px; padding: 6px 10px; border-radius: 6px; cursor: pointer; text-decoration: none; }
.side-link:hover { color: #fff; background: rgba(255, 255, 255, .06); }

.main { min-width: 0; }
.top { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; padding: 18px 32px 0; }
.top h1 { font-size: 28px; flex: 1 1 auto; }
.view { padding: 18px 32px 60px; max-width: 1280px; }

/* ---------- controls ---------- */
input, select, textarea {
  font: inherit; color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: 7px;
  padding: 8px 10px; width: 100%; min-width: 0;
}
input:focus, select:focus, textarea:focus { border-color: var(--focus); outline: none; box-shadow: 0 0 0 3px rgba(47, 111, 223, .15); }
textarea { resize: vertical; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 600; font-size: 14px; color: var(--ink); background: #fff;
  border: 1px solid var(--line); border-radius: 7px; padding: 8px 14px; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { border-color: #c4cad3; background: #fafbfc; }
.btn.primary { background: var(--gold); border-color: var(--gold); color: #1f1504; }
.btn.primary:hover { background: #b98a25; }
.btn.danger { color: var(--bad); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn.wide { width: 100%; margin-top: 18px; padding: 11px; }
.btn:disabled { opacity: .5; cursor: default; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1 1 auto; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > span { font-size: 13px; font-weight: 600; color: var(--dim); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }

/* period picker */
.period { display: flex; align-items: center; gap: 6px; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 3px; }
.period button { border: 0; background: none; font: inherit; padding: 6px 9px; border-radius: 6px; cursor: pointer; color: var(--dim); font-weight: 600; }
.period button.on { background: var(--ink); color: #fff; }
.period .lbl { font-weight: 700; min-width: 128px; text-align: center; font-variant-numeric: tabular-nums; }
.period .arr { font-size: 16px; padding: 4px 10px; color: var(--ink); }

/* ---------- panels ---------- */
.panel { background: var(--panel); border-radius: var(--r); box-shadow: var(--shadow); padding: 18px 20px; margin-bottom: 18px; }
.panel h2 { font-size: 17px; margin-bottom: 12px; }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.panel-head h2 { margin: 0; }
.note { font-size: 13px; color: var(--dim); }

/* the headline figures on Overview: a strip, not four cards */
.figures { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); background: var(--panel); border-radius: var(--r); box-shadow: var(--shadow); margin-bottom: 18px; overflow: hidden; }
.fig { padding: 16px 20px; border-left: 1px solid var(--line2); }
.fig:first-child { border-left: 0; }
.fig b { display: block; font-size: 26px; font-weight: 800; font-variation-settings: "wdth" 88; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.fig span { font-size: 13px; color: var(--dim); }
.fig small { display: block; font-size: 12px; color: var(--faint); margin-top: 2px; }

/* channel colour chips — the one bit of colour in the tables */
.ch { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; white-space: nowrap; }
.ch::before { content: ""; width: 9px; height: 9px; border-radius: 2px; background: var(--c); flex: none; }
.ch-customer { --c: var(--c-customer); } .ch-distributor { --c: var(--c-distributor); } .ch-show { --c: var(--c-show); }
.ch-online { --c: var(--c-online); } .ch-retail { --c: var(--c-retail); } .ch-other { --c: var(--c-other); }
.tag { display: inline-block; font-size: 11px; font-weight: 600; color: var(--dim); background: var(--line2); border-radius: 4px; padding: 1px 6px; margin-left: 6px; vertical-align: 1px; }
.tag.warn { color: #8a4b00; background: #fdecc8; }

/* spend by channel bars */
.bars { display: flex; flex-direction: column; gap: 9px; }
.bar { display: grid; grid-template-columns: 170px 1fr 110px; gap: 12px; align-items: center; font-size: 14px; }
.bar .track { height: 10px; background: var(--line2); border-radius: 5px; overflow: hidden; }
.bar .fill { height: 100%; background: var(--c); border-radius: 5px; }
.stack { display: flex; height: 14px; border-radius: 4px; overflow: hidden; background: var(--line2); }
.stack i { display: block; height: 100%; background: var(--c); }

/* ---------- tables ---------- */
.tablewrap { overflow-x: auto; margin: 0 -20px; padding: 0 20px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12px; font-weight: 600; color: var(--dim); padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 9px 10px; border-bottom: 1px solid var(--line2); vertical-align: middle; }
tbody tr.click { cursor: pointer; }
tbody tr.click:hover td { background: #f7f8fa; }
tfoot td { font-weight: 700; border-bottom: 0; border-top: 2px solid var(--ink); }
td.desc { max-width: 380px; }
td .sub { display: block; font-size: 12px; color: var(--faint); }
.empty { padding: 34px 10px; text-align: center; color: var(--dim); }

.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.filters input[type=search] { max-width: 300px; }
.filters select { width: auto; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { font: inherit; font-size: 13px; font-weight: 600; border: 1px solid var(--line); background: #fff; color: var(--dim); border-radius: 999px; padding: 5px 12px; cursor: pointer; }
.chip.on { background: var(--ink); color: #fff; border-color: var(--ink); }

/* ---------- the purchase form ---------- */
/* channel picker: graded-slab labels — the site's one memorable element */
.slabs { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; margin-bottom: 18px; }
.slab {
  font: inherit; text-align: left; cursor: pointer; background: #fff; border: 2px solid var(--line); border-radius: 9px;
  padding: 0; overflow: hidden; display: flex; flex-direction: column; color: var(--ink);
}
.slab .lbl { background: var(--c); color: #fff; font-weight: 800; font-size: 14px; padding: 7px 11px; font-variation-settings: "wdth" 118; letter-spacing: .01em; }
.slab .sub { font-size: 12.5px; color: var(--dim); padding: 8px 11px 10px; line-height: 1.35; }
.slab:hover { border-color: var(--c); }
.slab.on { border-color: var(--c); box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 22%, transparent); }
.slab:not(.on) .lbl { background: color-mix(in srgb, var(--c) 82%, #fff); }

.lines td { padding: 5px 6px; border-bottom: 1px solid var(--line2); }
.lines th { padding: 6px; }
.lines input, .lines select { padding: 6px 8px; font-size: 14px; }
.lines .c-kind { width: 120px; } .lines .c-cat { width: 140px; } .lines .c-qty { width: 70px; }
.lines .c-unit { width: 110px; } .lines .c-line { width: 110px; } .lines .c-x { width: 36px; }
.lines .x { border: 0; background: none; color: var(--faint); font-size: 18px; cursor: pointer; padding: 2px 6px; }
.lines .x:hover { color: var(--bad); }
.totals { margin-left: auto; width: 100%; max-width: 360px; }
.totals .t { display: grid; grid-template-columns: 1fr 140px; gap: 10px; align-items: center; padding: 5px 0; }
.totals .t input { text-align: right; font-variant-numeric: tabular-nums; }
.totals .t.big { border-top: 2px solid var(--ink); margin-top: 6px; padding-top: 10px; font-weight: 800; font-size: 18px; }
.totals .t.big .num { font-variation-settings: "wdth" 90; }

.drop { display: block; border: 2px dashed var(--line); border-radius: 9px; padding: 18px; text-align: center; color: var(--dim); cursor: pointer; }
.drop.over { border-color: var(--gold); background: var(--gold-tint); }
.files { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.file { width: 120px; font-size: 12px; position: relative; }
.file .thumb { width: 120px; height: 120px; border-radius: 7px; border: 1px solid var(--line); background: #f5f6f8 center/cover no-repeat; display: grid; place-items: center; font-size: 30px; color: var(--faint); text-decoration: none; }
.file .nm { display: block; margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--dim); }
.file .rm { position: absolute; top: 4px; right: 4px; border: 0; background: rgba(0, 0, 0, .6); color: #fff; border-radius: 50%; width: 22px; height: 22px; cursor: pointer; line-height: 1; }

.callout { border-left: 3px solid var(--gold); background: var(--gold-tint); padding: 10px 14px; border-radius: 0 7px 7px 0; font-size: 14px; margin-bottom: 14px; }
.callout.info { border-color: var(--c-distributor); background: #eef0fb; }
.pics { display: flex; gap: 8px; flex-wrap: wrap; }
.pics img { width: 64px; height: 88px; object-fit: cover; border-radius: 5px; border: 1px solid var(--line); background: #f5f6f8; }

/* ---------- modal + toast ---------- */
.modal { position: fixed; inset: 0; background: rgba(20, 24, 31, .45); display: grid; place-items: center; padding: 16px; z-index: 50; }
.modal-box { background: #fff; border-radius: 12px; width: 100%; max-width: 560px; max-height: calc(100vh - 32px); overflow: auto; padding: 22px 24px; box-shadow: 0 20px 60px rgba(0, 0, 0, .25); }
.modal-box h2 { font-size: 20px; margin-bottom: 14px; }
.modal-box .field { margin-bottom: 12px; }
.modal-foot { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translate(-50%, 20px); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 8px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 60; max-width: calc(100vw - 32px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.spin { width: 28px; height: 28px; border: 3px solid var(--line); border-top-color: var(--gold); border-radius: 50%; animation: spin .8s linear infinite; margin: 40px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spin { animation-duration: 2.4s; } .toast { transition: none; } }

/* ---------- smaller screens ---------- */
@media (max-width: 980px) {
  .slabs { grid-template-columns: repeat(3, 1fr); }
  .grid4 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: minmax(0, 1fr); background: none; }
  .side { position: static; height: auto; padding: 10px 12px; }
  .brand { padding-bottom: 8px; }
  #nav { flex-direction: row; overflow-x: auto; gap: 4px; padding-bottom: 4px; }
  #nav a { white-space: nowrap; }
  #nav .nav-gap, #nav .lock { display: none; }
  .side-foot { display: none; }
  .top { padding: 14px 16px 0; }
  .top h1 { font-size: 23px; }
  .view { padding: 14px 16px 50px; }
  .grid2, .grid3, .grid4 { grid-template-columns: 1fr; }
  .slabs { grid-template-columns: 1fr 1fr; }
  .bar { grid-template-columns: 110px 1fr 90px; }
  .panel { padding: 16px; }
  .tablewrap { margin: 0 -16px; padding: 0 16px; }
}
