:root {
  --bg: #f4f6fa;
  --card: #ffffff;
  --text: #16213a;
  --muted: #5d6b85;
  --faint: #8b97ad;
  --border: #e3e8f0;
  --border-strong: #cbd5e3;
  --accent: #2458e6;
  --accent-soft: #e8eefc;
  --green: #0d8a5f;
  --green-soft: #e3f5ee;
  --amber: #b45309;
  --amber-soft: #fdf1e0;
  --red: #c22f3e;
  --shadow: 0 1px 2px rgba(22, 33, 58, 0.05), 0 6px 20px rgba(22, 33, 58, 0.06);
  --radius: 14px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1524;
    --card: #171f33;
    --text: #e8edf7;
    --muted: #9aa7bf;
    --faint: #6d7a93;
    --border: #26314b;
    --border-strong: #35425f;
    --accent: #6a92ff;
    --accent-soft: #1d2a4d;
    --green: #3ecf95;
    --green-soft: #12352a;
    --amber: #e8a44b;
    --amber-soft: #3a2c14;
    --red: #ef6a77;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.35);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.45;
}

.wrap {
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 24px 64px;
}

/* ------------------------------------------------------------- header */

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 26px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-right: auto;
}

.logo {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 700;
  font-size: 17px;
  letter-spacing: 0.02em;
  background: linear-gradient(135deg, #2458e6, #6a3de8);
  box-shadow: var(--shadow);
  flex: none;
}

.brand h1 {
  font-size: 21px;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.01em;
}

.brand .sub {
  color: var(--muted);
  font-size: 13px;
  margin-top: 1px;
}

.round-badge {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 18px;
  box-shadow: var(--shadow);
}

.round-badge .label {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
}

.round-badge .value {
  font-size: 20px;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}

/* ------------------------------------------------------------- buttons */

.actions { display: flex; gap: 10px; }

button {
  font: inherit;
  font-weight: 620;
  border-radius: 10px;
  padding: 10px 20px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: transform 0.06s ease, box-shadow 0.12s ease, background 0.12s ease;
}

button:active { transform: translateY(1px); }
button:disabled { opacity: 0.55; cursor: default; }

.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 2px 10px rgba(36, 88, 230, 0.35);
}
.btn-primary:hover:not(:disabled) { filter: brightness(1.07); }

.btn-secondary {
  background: var(--card);
  color: var(--text);
  border-color: var(--border-strong);
}
.btn-secondary:hover:not(:disabled) { border-color: var(--faint); }

.btn-secondary.armed {
  background: var(--red);
  color: #fff;
  border-color: var(--red);
}

/* --------------------------------------------------------------- cards */

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 22px;
  overflow: hidden;
}

.card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
}

.card-head h2 {
  font-size: 14px;
  font-weight: 700;
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
}

.card-head .hint { margin-left: auto; font-size: 12.5px; color: var(--faint); }

/* --------------------------------------------------------- status tiles */

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}

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

.tile .product {
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 8px;
}

.tile .price {
  font-size: 24px;
  font-weight: 750;
  margin-top: 6px;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

.tile .meta {
  margin-top: 3px;
  font-size: 12.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.chip {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-radius: 999px;
  padding: 2.5px 9px;
  margin-left: auto;
}
.chip.cleared { background: var(--green-soft); color: var(--green); }
.chip.active { background: var(--amber-soft); color: var(--amber); }

/* --------------------------------------------------------------- tables */

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

table {
  border-collapse: collapse;
  width: 100%;
  font-variant-numeric: tabular-nums;
}

th, td {
  padding: 9px 16px;
  text-align: right;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

th {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  background: color-mix(in srgb, var(--card) 60%, var(--bg));
}

th.rowhead, td.rowhead {
  text-align: left;
  font-weight: 650;
  color: var(--text);
  position: sticky;
  left: 0;
  background: var(--card);
}

tr:last-child td { border-bottom: none; }

tr.current td { background: color-mix(in srgb, var(--accent-soft) 55%, var(--card)); }
tr.current td.rowhead { background: color-mix(in srgb, var(--accent-soft) 55%, var(--card)); font-weight: 750; }

td.cleared { color: var(--green); font-weight: 650; }
td.zero { color: var(--faint); }
td.drop { color: var(--accent); }
td.price-drop { color: var(--accent); }

thead th.group {
  text-align: center;
  border-bottom: none;
  padding-bottom: 2px;
  color: var(--text);
}
thead tr.subhead th { padding-top: 2px; }

/* --------------------------------------------------------------- footer */

.nav-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.nav-links a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 7px 15px 7px 8px;
  font-size: 13.5px;
  font-weight: 600;
  box-shadow: var(--shadow);
  transition: border-color 0.12s ease;
}
.nav-links a:hover { border-color: var(--accent); }

.dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 10px;
  font-weight: 800;
  color: #fff;
}

.footer-note {
  margin-top: 26px;
  color: var(--faint);
  font-size: 12.5px;
  text-align: center;
}

.flash { animation: flash 0.7s ease; }
@keyframes flash {
  0% { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 45%, transparent); }
  100% { box-shadow: var(--shadow); }
}
