@font-face {
  font-family: "Bricolage";
  src: url("../fonts/bricolage.woff2") format("woff2");
  font-weight: 400 800;
  font-display: swap;
}

:root {
  --bg: #f3f5fa;
  --card: #ffffff;
  --ink: #0b1530;
  --muted: #5a6684;
  --line: #e2e7f1;
  --field: #f6f8fc;
  --blue: #1f4fd6;
  --blue-deep: #163aa3;
  --blue-soft: #eaf0ff;
  --navy: #0a1a44;
  --gold: #f2b544;
  --ok: #117a4a;
  --ok-bg: #e5f5ec;
  --bad: #a1261d;
  --bad-bg: #fdeceb;
  --warn-bg: #fff4dc;
  --warn: #7a5200;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #060c1d;
    --card: #0e1833;
    --ink: #edf1fb;
    --muted: #93a0c2;
    --line: #1c2849;
    --field: #0a1329;
    --blue: #4a7bff;
    --blue-deep: #3565ea;
    --blue-soft: #14224a;
    --navy: #050b1c;
    --ok: #5fd39c;
    --ok-bg: #11301f;
    --bad: #ffb1a8;
    --bad-bg: #3b1715;
    --warn-bg: #3a2c0b;
    --warn: #f5cf7a;
  }
}

:root[data-theme="dark"] {
  --bg: #060c1d;
  --card: #0e1833;
  --ink: #edf1fb;
  --muted: #93a0c2;
  --line: #1c2849;
  --field: #0a1329;
  --blue: #4a7bff;
  --blue-deep: #3565ea;
  --blue-soft: #14224a;
  --navy: #050b1c;
  --ok: #5fd39c;
  --ok-bg: #11301f;
  --bad: #ffb1a8;
  --bad-bg: #3b1715;
  --warn-bg: #3a2c0b;
  --warn: #f5cf7a;
}

:root { color-scheme: light dark; }
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Bricolage", -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--blue); }

/* Layout */

main {
  max-width: 880px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}

h1 {
  margin: 0 0 16px;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

h2 {
  margin: 0 0 12px;
  font-size: 17px;
  font-weight: 700;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px;
  margin-bottom: 16px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.tile {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
}

.tile small { display: block; color: var(--muted); font-size: 13px; }

.tile b {
  display: block;
  margin-top: 4px;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.tile .sub { font-size: 13px; color: var(--muted); }
.tile.low { border-color: var(--gold); }

.muted { color: var(--muted); }

/* Messages */

.flash, .error, .warn {
  padding: 11px 14px;
  border-radius: 12px;
  margin-bottom: 16px;
  font-size: 15px;
}

.flash { background: var(--ok-bg); color: var(--ok); }
.error { background: var(--bad-bg); color: var(--bad); }
.warn { background: var(--warn-bg); color: var(--warn); }

/* Forms */

label { display: block; font-size: 14px; font-weight: 600; margin: 0 0 6px; }

input[type=text], input[type=password], input[type=number], select {
  width: 100%;
  height: 46px;
  padding: 0 12px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: var(--field);
  color: var(--ink);
  font: inherit;
  outline: none;
}

input:focus, select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-soft); }

.field { margin-bottom: 14px; }

.row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.row > .field { flex: 1 1 160px; margin-bottom: 0; }

.btn {
  display: inline-block;
  height: 46px;
  padding: 0 18px;
  border: 0;
  border-radius: 12px;
  background: linear-gradient(180deg, var(--blue), var(--blue-deep));
  color: #fff;
  font: inherit;
  font-weight: 700;
  line-height: 46px;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}

.btn.small { height: 36px; line-height: 36px; padding: 0 12px; font-size: 14px; }
.btn.ghost { background: transparent; border: 1.5px solid var(--line); color: var(--ink); line-height: 43px; }
.btn.ghost.small { line-height: 33px; }
.btn.danger { background: transparent; border: 1.5px solid var(--bad); color: var(--bad); line-height: 43px; }
.btn.danger.small { line-height: 33px; }
.btn.block { display: block; width: 100%; text-align: center; }

.check { display: flex; align-items: center; gap: 8px; font-weight: 400; }

/* Tables */

.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: 15px; }

th {
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
}

td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
td form { margin: 0; }

.inline { display: flex; gap: 6px; align-items: center; }
.inline input { height: 36px; max-width: 170px; }

.pill {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  background: var(--blue-soft);
  color: var(--blue);
}

.pill.off { background: var(--bad-bg); color: var(--bad); }
.pill.gold { background: var(--warn-bg); color: var(--warn); }

.code { font-weight: 700; letter-spacing: 0.08em; font-variant-numeric: tabular-nums; }

.codes {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px;
}

.codes div {
  padding: 10px;
  border: 1px dashed var(--line);
  border-radius: 10px;
  text-align: center;
}

/* Login */

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background: radial-gradient(120% 70% at 100% 0%, #16358f 0%, var(--navy) 60%);
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--card);
  border-radius: 20px;
  padding: 26px 22px;
  box-shadow: 0 24px 60px -20px rgba(0, 0, 0, 0.6);
}

.login-card .brand { color: var(--ink); margin-bottom: 18px; }
.login-card .brand span { color: var(--muted); opacity: 1; }

/* Stacked list items (staff, packages) */

.item { padding: 16px; margin-bottom: 12px; }
.item-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.item-head .right { text-align: right; font-size: 14px; }
.item-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.item-actions .inline { flex: 1 1 200px; }
.item-actions .inline input { max-width: none; }
.item-actions .check { margin: 0; }

.grid.three { grid-template-columns: repeat(3, 1fr); }
.grid.three .tile { padding: 12px; }
.grid.three .tile b { font-size: 22px; }

.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: var(--field);
  color: var(--ink);
  font: inherit;
  letter-spacing: 0.06em;
  outline: none;
  resize: vertical;
}
textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-soft); }
input[type=tel] {
  width: 100%; height: 46px; padding: 0 12px; border: 1.5px solid var(--line); border-radius: 12px;
  background: var(--field); color: var(--ink); font: inherit; outline: none;
}
input[type=tel]:focus { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-soft); }

.spaced { margin-top: 16px; }

/* Sell */

.sell-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }

.sell-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 18px 16px;
  border: 1.5px solid var(--line);
  border-radius: 16px;
  background: var(--card);
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.sell-btn:hover, .sell-btn:focus { border-color: var(--blue); outline: none; box-shadow: 0 0 0 3px var(--blue-soft); }
.sell-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.sell-name { font-size: 18px; font-weight: 700; }
.sell-price { font-size: 26px; font-weight: 800; letter-spacing: -0.02em; color: var(--blue); }
.sell-stock { font-size: 13px; color: var(--muted); }
.sell-stock.low { color: var(--warn); font-weight: 700; }

.sold { text-align: center; padding: 26px 18px; }
.big-code {
  margin: 10px 0;
  font-size: clamp(30px, 10vw, 44px);
  font-weight: 800;
  letter-spacing: 0.1em;
  font-variant-numeric: tabular-nums;
  user-select: all;
  word-break: break-all;
}
.sold-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin: 16px 0 6px; }
.sold-actions .btn { flex: 1 1 150px; text-align: center; }
.sms-preview { margin-top: 12px; font-size: 14px; color: var(--muted); text-align: left; }
.sms-preview summary { cursor: pointer; }

/* Printable slips (A4, 3 x 7 = 21 per page) */

.print-bar {
  display: flex; align-items: center; gap: 12px; justify-content: space-between;
  max-width: 820px; margin: 16px auto; padding: 0 16px; flex-wrap: wrap;
}
.print-empty { max-width: 820px; margin: 0 auto; padding: 0 16px; }

.sheet {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0;
  max-width: 820px;
  margin: 0 auto 32px;
  background: #fff;
  color: #000;
}

.slip {
  height: 38.5mm;
  padding: 3mm 3.5mm;
  border: 0.3mm dashed #999;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  font-size: 9pt;
  line-height: 1.25;
  break-inside: avoid;
  color: #000;
  background: #fff;
}
.slip-top { display: flex; justify-content: space-between; font-size: 9pt; }
.slip-top span { font-weight: 800; }
.slip-pkg { font-size: 8.5pt; color: #333; }
.slip-code { font-size: 15pt; font-weight: 800; letter-spacing: 0.12em; text-align: center; font-variant-numeric: tabular-nums; }
.slip-steps { margin: 0; padding-left: 4mm; font-size: 7.5pt; color: #222; }
.slip-foot { font-size: 7.5pt; color: #333; }

@page { size: A4; margin: 10mm; }

@media print {
  html, body { background: #fff !important; color: #000 !important; }
  .no-print { display: none !important; }
  main { padding: 0; max-width: none; }
  .sheet { max-width: none; margin: 0; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

.table-wrap th, .table-wrap td { white-space: nowrap; }

/* Phase 5–6 */

.inline-form { display: inline; margin-left: 8px; }
.push-right { margin-left: auto; }
.small-print { font-size: 13px; margin: 18px 0 8px; }
.big-code.left { font-size: 26px; margin: 0; text-align: left; }
.facts { margin-top: 12px; }
.facts td:first-child { color: var(--muted); width: 42%; }
input[type=date] {
  height: 36px; padding: 0 8px; border: 1.5px solid var(--line); border-radius: 10px;
  background: var(--field); color: var(--ink); font: inherit;
}
.hero-number { font-size: 30px; font-weight: 800; letter-spacing: -0.02em; margin: 4px 0 12px; }
.hero-number .muted { font-size: 15px; font-weight: 400; letter-spacing: 0; }

.bars { display: block; width: 100%; height: 140px; overflow: visible; }
.bars .fill { fill: var(--blue); }
.bars .hit { fill: transparent; }
.bars .bar:hover .fill { fill: var(--blue-deep); }
.bars .bar:hover .hit { fill: var(--blue-soft); opacity: 0.5; }
.bars .baseline { stroke: var(--line); stroke-width: 1; vector-effect: non-scaling-stroke; }
.axis { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-top: 6px; }

/* Sidebar shell */

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #fff;
  text-decoration: none;
  font-weight: 700;
  font-size: 17px;
}
.brand svg { width: 28px; height: 28px; flex: none; }
.brand span { font-weight: 400; opacity: 0.7; }

.side {
  position: fixed;
  inset: 0 auto 0 0;
  width: 248px;
  display: flex;
  flex-direction: column;
  background: var(--navy);
  border-right: 1px solid rgba(255, 255, 255, 0.07);
  color: #fff;
  z-index: 30;
  overflow-y: auto;
}
.side-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 16px 10px; }
.side-nav { flex: 1; padding: 4px 10px 12px; }
.side-label {
  margin: 16px 10px 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.45);
}
.side-nav a {
  display: block;
  padding: 9px 12px;
  border-radius: 10px;
  color: rgba(255, 255, 255, 0.8);
  text-decoration: none;
  font-size: 15px;
  font-weight: 600;
}
.side-nav a:hover { background: rgba(255, 255, 255, 0.07); color: #fff; }
.side-nav a.on { background: rgba(255, 255, 255, 0.14); color: #fff; box-shadow: inset 3px 0 0 var(--gold); }
.side-foot { padding: 14px 16px 18px; border-top: 1px solid rgba(255, 255, 255, 0.1); }
.side-foot form { margin: 0; }
.who-name { font-weight: 700; margin-bottom: 10px; }
.who-name span { display: block; font-size: 12px; font-weight: 400; opacity: 0.6; }
.side-btn {
  display: block;
  width: 100%;
  margin-top: 8px;
  padding: 8px 12px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 10px;
  background: transparent;
  color: #fff;
  font: inherit;
  font-size: 14px;
  text-align: left;
  cursor: pointer;
}
.side-btn:hover { background: rgba(255, 255, 255, 0.07); }

.menu-btn {
  display: none;
  width: 40px;
  height: 40px;
  padding: 8px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #fff;
  cursor: pointer;
}
.menu-btn svg { width: 24px; height: 24px; fill: none; }

.mobile-top { display: none; }
.scrim { display: none; }

@media (min-width: 900px) {
  body.has-side main { margin-left: 248px; max-width: none; padding: 32px 40px 56px; }
  body.has-side main > * { max-width: 880px; }
}

@media (max-width: 899px) {
  .mobile-top {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: var(--navy);
  }
  .menu-btn { display: inline-flex; }
  .side { transform: translateX(-100%); transition: transform 0.2s ease; box-shadow: 0 0 40px rgba(0, 0, 0, 0.4); }
  body.menu-open .side { transform: none; }
  body.menu-open .scrim { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, 0.45); z-index: 25; }
  body.menu-open { overflow: hidden; }
}

@media (prefers-reduced-motion: reduce) { .side { transition: none; } }
@media print { body.has-side main { margin-left: 0; } }

@media (max-width: 480px) {
  .grid.three { gap: 8px; }
  .grid.three .tile { padding: 10px; }
  .grid.three .tile b { font-size: 18px; }
  .grid.three .tile small, .grid.three .tile .sub { font-size: 12px; }
}

.notice-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; }
.notice-actions { display: flex; gap: 8px; }
.notice-actions form { margin: 0; }

/* Packages */
.add-package summary { cursor: pointer; list-style: none; }
.add-package summary::-webkit-details-marker { display: none; }
.add-package summary h2 { display: inline; margin: 0; }
.add-package summary h2::before { content: "+ "; color: var(--blue); }
.add-package[open] summary { margin-bottom: 14px; }
.add-package .inline select { height: 46px; max-width: 110px; }
.pkg-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin-top: 14px; }
.pkg-grid .field { margin: 0; }
.item.retired { opacity: 0.7; }
.delete-form { margin-top: 10px; }
.add-package .inline input { height: 46px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
