/* Stock Book — styled to match the Black Cats sales workspace (DM Sans + Manrope).
   Stock status colours (green / yellow / red) are the Excel stock book colours and stay unchanged. */
:root {
  --ok: #00B050; --ok-fg: #fff;
  --restock: #FFFF00; --restock-fg: #000;
  --critical: #FF0000; --critical-fg: #fff;

  --ink: #19201e; --ink-2: #273228;
  --bg: #f5f6f5; --card: #fff;
  --dark: #18211d; --dark-2: #19251e; --dark-hover: #33473b;
  --lime: #d5f66b; --lime-ink: #162014;
  --line: #e0e5df; --line-2: #e4e7e3; --row: #edf0e9; --field: #dce2d9; --btn-line: #dde1dd;
  --muted: #7a827d; --muted-2: #90978f; --label: #9ba19c;
  --soft: #f3f5f1; --hover: #f0f2ef;
  --head: 'Manrope', sans-serif;
}
* { box-sizing: border-box; }
html { font-family: 'DM Sans', sans-serif; color: var(--ink); background: var(--bg); font-synthesis: none; }
body { margin: 0; font-size: 14px; line-height: 1.5; background: var(--bg); }
button, input, select, textarea { font: inherit; }
a { color: #305d3f; }
h1 { font: 800 30px/1.2 var(--head); margin: 0 0 7px; letter-spacing: -1px; }
h2 { font: 750 17px var(--head); margin: 0 0 14px; }
h3 { font: 750 15px var(--head); margin: 26px 0 10px; }
p { line-height: 1.6; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* ---------- sidebar ---------- */
.sidebar { position: fixed; inset: 0 auto 0 0; width: 238px; background: #fff; border-right: 1px solid var(--line-2); padding: 30px 20px 22px; display: flex; flex-direction: column; z-index: 30; overflow-y: auto; }
.brand-link { text-decoration: none; color: inherit; }
.brand { display: flex; align-items: center; gap: 12px; font: 800 20px var(--head); letter-spacing: -.8px; color: var(--ink); line-height: 1.1; }
.brand img { width: 53px; height: 48px; object-fit: contain; }
.brand small { display: block; font: 500 10px 'DM Sans', sans-serif; letter-spacing: 2px; margin-top: 5px; color: #7b827e; }
.nav-label { font-size: 11px; letter-spacing: 1.8px; color: var(--label); margin: 34px 14px 12px; }
.brand-link + .nav-label { margin-top: 44px; }
.nav { display: flex; flex-direction: column; gap: 5px; }
.nav a { display: flex; align-items: center; gap: 13px; color: #6b746e; font-size: 14px; font-weight: 500; padding: 12px 15px; border-radius: 8px; text-decoration: none; }
.nav a:hover { background: var(--hover); color: var(--ink); }
.nav a.active { background: var(--dark); color: #fff; }
.nav svg { width: 19px; height: 19px; flex: none; }
.nav .count { margin-left: auto; background: var(--lime); color: var(--dark); padding: 2px 6px; border-radius: 4px; font-size: 11px; font-weight: 600; }
.sidebar-bottom { margin-top: auto; padding-top: 20px; }
.workspace-card { border: 1px solid var(--line-2); border-radius: 10px; padding: 15px; margin: 0 0 22px; font-size: 13px; color: var(--muted); }
.workspace-card strong { display: block; margin-bottom: 6px; color: var(--ink); }
.profile { display: flex; align-items: center; gap: 10px; border-top: 1px solid #e6e9e5; padding-top: 20px; }
.profile strong { font-size: 13px; }
.profile small { display: block; color: #858c86; font-size: 12px; margin-top: 3px; }
.profile small a { color: #858c86; }
.profile .icon-btn { margin-left: auto; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: #eaf0e6; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; flex-shrink: 0; color: var(--ink); }
.icon-btn { padding: 6px; color: var(--ink); text-decoration: none; font-size: 16px; border-radius: 6px; }
.icon-btn:hover { background: var(--hover); }

/* ---------- main / topbar ---------- */
.main { margin-left: 238px; min-height: 100vh; }
.topbar { height: 80px; border-bottom: 1px solid #e3e6e2; display: flex; align-items: center; justify-content: space-between; padding: 0 38px; background: #fff; font-size: 13px; position: sticky; top: 0; z-index: 20; }
.topbar .right { display: flex; align-items: center; gap: 18px; }
.topbar .muted { color: var(--muted); }
.menu-btn, .mobile-brand { display: none; }
.content { max-width: 1540px; margin: auto; padding: 33px 38px 60px; }
.scrim { display: none; }

/* ---------- page heading ---------- */
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 27px; }
.page-head h1 { margin-bottom: 7px; }
.sub-title { margin: 0; color: #7e867f; font-size: 14px; }
.head-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--btn-line); background: #fff; color: var(--ink); padding: 11px 16px; border-radius: 8px; font-weight: 600; font-size: 14px; cursor: pointer; text-decoration: none; white-space: nowrap; line-height: 1.2; }
.btn:hover { background: var(--hover); }
.btn.primary { background: var(--dark); border-color: var(--dark); color: #fff; }
.btn.primary:hover { background: var(--dark-hover); }
.btn.accent { background: var(--lime); border-color: var(--lime); color: var(--lime-ink); }
.btn.sm { padding: 7px 10px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: wait; }
.btn svg { width: 17px; height: 17px; }
button.link { background: none; border: 0; padding: 0; color: #647357; font-size: 13px; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.danger { color: #b42318 !important; }

/* ---------- cards, notices ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 23px; margin-bottom: 24px; }
.card.narrow { max-width: 440px; }
.card > h2:first-child { margin-top: 0; }
.flash { border-radius: 8px; padding: 13px 15px; font-size: 13px; margin-bottom: 20px; border: 1px solid; }
.flash.ok { background: #f0f5e9; border-color: #dce7cc; color: #3f5f30; }
.flash.err { background: #fff0ee; border-color: #efbbb6; color: #b42318; }
.flash.info { background: #f3f5f1; border-color: var(--line); color: var(--ink-2); }
.empty { background: #fff; border: 1px dashed #d3d9d1; border-radius: 12px; padding: 50px; text-align: center; color: #7c857e; margin-bottom: 24px; }

/* ---------- forms ---------- */
label { display: block; font-size: 13px; font-weight: 550; color: var(--ink); }
label > span { display: inline-flex; gap: 6px; align-items: center; flex-wrap: wrap; }
input, select, textarea { display: block; width: 100%; padding: 12px; border: 1px solid var(--field); border-radius: 7px; background: #fff; color: var(--ink-2); margin-top: 7px; font-size: 14px; }
input:focus, select:focus { outline: 2px solid #466b51; outline-offset: 1px; }
input[type=color] { padding: 3px; height: 46px; width: 80px; }
label.check { display: flex; align-items: center; gap: 9px; font-weight: 500; }
label.check input { width: 18px; height: 18px; margin: 0; accent-color: var(--dark); }
.form-row { display: flex; gap: 18px; flex-wrap: wrap; margin-bottom: 18px; }
.form-row > label { min-width: 170px; }
.form-row .grow { flex: 1; min-width: 240px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 18px; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 25px; }
form.inline { display: flex; gap: 6px; align-items: center; }
form.inline input { width: 150px; padding: 8px 10px; margin: 0; font-size: 13px; }
.row-actions { display: flex; gap: 14px; align-items: center; white-space: nowrap; }
.row-actions form { margin: 0; }

/* ---------- stock status colours (unchanged — same as the Excel stock book) ---------- */
.st-ok { background: var(--ok); color: var(--ok-fg); }
.st-restock { background: var(--restock); color: var(--restock-fg); }
.st-critical { background: var(--critical); color: var(--critical-fg); }
.badge { display: inline-block; padding: 4px 9px; border-radius: 5px; font-size: 11px; font-weight: 600; white-space: nowrap; line-height: 1.3; }
.badge.st-restock { box-shadow: inset 0 0 0 1px #d6d600; }

/* ---------- dashboard ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; margin-bottom: 25px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 22px; }
.kpi-label { display: flex; justify-content: space-between; align-items: center; font-size: 13px; color: #7c857e; }
.kpi-value { font: 750 28px var(--head); letter-spacing: -1px; margin: 16px 0 10px; }
.kpi-note { font-size: 12px; color: #838c85; }
.kpi.dark { background: var(--dark-2); border-color: var(--dark-2); color: #fff; }
.kpi.dark .kpi-label { color: #c2cdc4; }
.kpi.dark .kpi-note { color: #b6c6b9; }
.chip { display: inline-block; background: #edf5e7; color: #4a713b; padding: 4px 7px; border-radius: 4px; font-size: 11px; font-weight: 600; margin-right: 6px; }
.kpi.dark .chip { background: #334d33; color: var(--lime); }
.kpi .swatch { width: 12px; height: 12px; border-radius: 3px; box-shadow: inset 0 0 0 1px rgba(0,0,0,.15); }
.section-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.section-head h2 { margin: 0; }
.section-head p { margin: 6px 0 0; font-size: 12px; color: #8a918b; }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 18px; }
.tile { border-radius: 12px; padding: 18px 18px 16px; min-height: 150px; display: flex; flex-direction: column; border: 3px solid rgba(0,0,0,.18); position: relative; overflow: hidden; transition: background .4s; }
.tile::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 8px; background: var(--item); border-right: 1px solid rgba(0,0,0,.15); }
.tile > * { padding-left: 6px; }
.tile-name { font: 800 15px var(--head); text-transform: uppercase; letter-spacing: .01em; }
.tile-qty { margin: auto 0 4px; }
.tile-qty .q { font: 800 44px/1 var(--head); letter-spacing: -1.5px; }
.tile-qty small { font-size: 14px; font-weight: 600; opacity: .85; margin-left: 2px; }
.tile-status { font-weight: 700; font-size: 14px; }
.dash-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 24px; border-top: 1px solid #eef0eb; padding-top: 18px; font-size: 12px; color: #7d877f; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table.grid { border-collapse: collapse; width: 100%; text-align: left; font-size: 13px; }
.grid th { font-size: 11px; font-weight: 500; color: var(--muted-2); padding: 14px 12px; border-bottom: 1px solid #e9ede6; white-space: nowrap; }
.grid td { padding: 15px 12px; border-bottom: 1px solid var(--row); vertical-align: middle; }
.grid td:first-child, .grid th:first-child { padding-left: 0; white-space: nowrap; }
.grid td:first-child small { display: block; color: #8b938b; margin: 3px 0 0 21px; font-size: 11px; }
.grid tfoot th { color: var(--ink); font-weight: 650; font-size: 13px; border-bottom: 0; }
.grid .num { text-align: right; }
.grid td.num input { width: 100px; text-align: right; margin: 0; padding: 9px 10px; margin-left: auto; }
.grid td.new { font: 750 16px var(--head); }
.grid td.new.neg { color: #b42318; }
.grid tr.inactive td { opacity: .5; }
.dot { display: inline-block; width: 11px; height: 11px; border-radius: 3px; margin-right: 10px; vertical-align: -1px; box-shadow: inset 0 0 0 1px rgba(0,0,0,.18); }
.type { font-size: 11px; border-radius: 5px; padding: 5px 8px; font-weight: 600; }
.t-in { background: #edf5e9; color: #5b7a46; }
.t-out { background: #fff5e0; color: #a17d2c; }
.t-adjust { background: #eaf1fa; color: #597a9c; }
.tabs { display: inline-flex; padding: 3px; background: var(--soft); border-radius: 6px; margin-bottom: 14px; }
.tab { font-size: 12px; font-weight: 600; padding: 7px 12px; border-radius: 6px; color: var(--ink); text-decoration: none; }
.tab.on { background: #fff; box-shadow: 0 1px 4px #0001; }

/* ---------- reports ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end; }
.filters label { min-width: 160px; }
.report { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 23px; }
.report-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; border-bottom: 1px solid #eef0eb; padding-bottom: 18px; }
.report-head h2 { margin: 0 0 6px; }
.report-head .muted { font-size: 13px; }
.print-only { display: none; }

/* ---------- login / install ---------- */
body.auth { min-height: 100dvh; display: grid; grid-template-columns: 1fr 1fr; background: #fff; }
.auth-art { background: #17241b; color: #fff; padding: 9vw 6vw; display: flex; flex-direction: column; justify-content: center; }
.auth-art .brand, .auth-art .brand small { color: #fff; }
.auth-art .brand small { color: #b7c5b7; }
.auth-art h1 { font-size: 52px; line-height: 1.2; margin: 60px 0 25px; }
.auth-art p { color: #b7c5b7; max-width: 360px; margin: 0; }
.auth-form { display: flex; align-items: center; justify-content: center; padding: 25px; }
.auth-card { width: 350px; max-width: 100%; display: flex; flex-direction: column; gap: 18px; }
.auth-card h1 { font-size: 28px; margin: 0; }
.auth-card > p { margin: -10px 0 0; color: var(--muted); }
.auth-card .btn { width: 100%; margin-top: 4px; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .sidebar { width: 210px; padding: 25px 14px; }
  .main { margin-left: 210px; }
  .content { padding: 28px 22px 50px; }
  .topbar { padding: 0 22px; }
  .kpis { gap: 12px; }
  .kpi { padding: 17px; }
  .kpi-value { font-size: 24px; }
}
@media (max-width: 760px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s; width: 260px; box-shadow: 0 0 60px #0003; }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .scrim { display: block; position: fixed; inset: 0; background: #101b1777; z-index: 25; }
  .main { margin: 0; }
  .topbar { height: 64px; padding: 0 16px; gap: 10px; }
  .menu-btn { display: block; background: none; border: 0; font-size: 22px; padding: 4px; color: var(--ink); cursor: pointer; }
  .breadcrumb, .topbar .date { display: none; }
  .mobile-brand { display: block; font: 800 16px var(--head); margin-right: auto; }
  .content { padding: 24px 16px 50px; }
  h1 { font-size: 26px; }
  .page-head { display: block; margin-bottom: 22px; }
  .page-head .head-actions { margin-top: 16px; }
  .kpis { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi { padding: 16px; }
  .kpi-value { font-size: 24px; margin: 12px 0 8px; }
  .kpi-label { font-size: 12px; }
  .kpi-note { font-size: 10px; }
  .tiles { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .tile { min-height: 130px; padding: 14px 12px 12px; }
  .tile-name { font-size: 13px; }
  .tile-qty .q { font-size: 34px; }
  .card, .report { padding: 18px 16px; }
  body.auth { grid-template-columns: 1fr; }
  .auth-art { display: none; }
  .auth-form { min-height: 100dvh; }
  .form-actions { justify-content: stretch; }
  .form-actions .btn { flex: 1; }
}

/* ---------- print ---------- */
@media print {
  @page { size: A4 landscape; margin: 12mm; }
  html, body { background: #fff; }
  .sidebar, .topbar, .no-print, .flash, .scrim { display: none !important; }
  .main { margin: 0; }
  .content { padding: 0; max-width: none; }
  .report { border: 0; padding: 0; }
  .print-only { display: block; }
  table.grid { font-size: 10px; }
  .grid th, .grid td { padding: 6px; }
  .table-wrap { overflow: visible; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  tr { page-break-inside: avoid; }
}
.legend { display: flex; gap: 6px; flex-wrap: wrap; }
.kpi-label svg { width: 16px; height: 16px; opacity: .7; }
.profile .who { color: inherit; text-decoration: none; min-width: 0; }
.profile .who:hover strong { text-decoration: underline; }
