/* Layout: one centred column. Summary strip, toolbar, then each group as a rounded card of rows.
   Ember orange (the Fire Crystal colour) is the only accent against cold slate. Follows the Windows light/dark setting. */
:root {
  color-scheme: light;
  --bg: #EDF1F6;
  --surface: #FFFFFF;
  --surface-2: #E6ECF3;
  --line: #D3DCE7;
  --fg: #132033;
  --muted: #566679;
  --accent: #C2410C;
  --accent-ink: #FFFFFF;
  --up: #17754A;
  --down: #B42318;
  --shadow: 0 1px 2px rgba(19, 32, 51, 0.06), 0 6px 18px rgba(19, 32, 51, 0.05);
  --font-display: "Bahnschrift", "Segoe UI Variable Display", "Segoe UI", system-ui, sans-serif;
  --font-body: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #0B131C;
    --surface: #121D29;
    --surface-2: #1A2837;
    --line: #28394B;
    --fg: #E5EDF5;
    --muted: #8DA0B4;
    --accent: #FF8A4C;
    --accent-ink: #1B0D04;
    --up: #4CC38A;
    --down: #FF8178;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.45;
  padding-inline: 24px;
  padding-block: 28px 40px;
}
.wrap { max-width: 820px; margin-inline: auto; display: flex; flex-direction: column; gap: 20px; }
h1, h2 { font-family: var(--font-display); margin: 0; text-wrap: balance; }
h1 { font-size: 2.3rem; font-weight: 700; line-height: 1.05; font-stretch: 75%; letter-spacing: 0.005em; }
h2 { font-size: 0.95rem; font-weight: 600; font-stretch: 75%; letter-spacing: 0.12em; text-transform: uppercase; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

header { display: flex; flex-direction: column; gap: 6px; }
.today { font-family: var(--font-display); font-size: 0.95rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--accent); font-weight: 600; font-stretch: 75%; }
.lede { margin: 0; color: var(--muted); max-width: 62ch; }
.lede code { font-family: inherit; font-weight: 600; color: var(--fg); background: var(--surface-2); padding: 0 6px; border-radius: 5px; white-space: nowrap; }

.strip { position: relative; display: grid; grid-template-columns: repeat(3, 1fr); background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); overflow: hidden; }
.stat { padding: 16px 20px 18px; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.stat + .stat { border-left: 1px solid var(--line); }
.stat b { font-family: var(--font-display); font-size: 2.2rem; line-height: 1; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat span { font-size: 0.74rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.prog { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: var(--surface-2); }
.prog i { display: block; height: 100%; width: 100%; background: var(--accent); transform-origin: left; transform: scaleX(0); transition: transform 0.3s ease; }

.bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.bar .search { flex: 1 1 220px; min-width: 0; }
.field, .search input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 13px;
  min-height: 42px;
}
.search input:focus, .field:focus, .qty:focus { border-color: var(--accent); outline: 2px solid color-mix(in srgb, var(--accent) 35%, transparent); outline-offset: 0; }
.btn {
  min-height: 42px;
  padding: 0 18px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  cursor: pointer;
  font-weight: 600;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.07); }
.btn[disabled] { opacity: 0.5; cursor: default; filter: none; }

.add { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 18px; display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; align-items: end; }
.add label { display: flex; flex-direction: column; gap: 5px; font-size: 0.74rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); min-width: 0; }
.add label .field { text-transform: none; letter-spacing: 0; font-size: 1rem; color: var(--fg); }
.add .actions { display: flex; gap: 10px; grid-column: 1 / -1; }

main { display: flex; flex-direction: column; gap: 16px; }
.group { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 4px 18px 6px; }
.group h2 { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 14px 0 10px; border-bottom: 2px solid var(--fg); }
.group h2 small { font-family: var(--font-body); font-size: 0.8rem; letter-spacing: 0.03em; text-transform: none; color: var(--muted); font-weight: 500; font-stretch: 100%; }
ul { list-style: none; margin: 0; padding: 0; }
.row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto 34px; align-items: center; column-gap: 14px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: 0; }
.who { min-width: 0; display: flex; flex-direction: column; }
.name { font-weight: 600; overflow-wrap: anywhere; }
.name .unit { font-weight: 400; color: var(--muted); font-size: 0.85rem; margin-left: 5px; }
.meta { font-size: 0.82rem; color: var(--muted); }
.d { font-weight: 600; font-variant-numeric: tabular-nums; }
.d.up { color: var(--up); }
.d.down { color: var(--down); }
.spark { width: 60px; height: 24px; display: block; }
.spark .ln { fill: none; stroke: var(--muted); stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round; }
.spark .end { fill: var(--accent); }
.spark .base { stroke: var(--line); stroke-width: 1.5; stroke-dasharray: 2 4; }
.qty {
  width: 9.5rem;
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  font-size: 1.05rem;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 12px;
  min-height: 42px;
}
.qty[aria-invalid="true"] { border-color: var(--down); }
.del { width: 34px; height: 34px; border: 0; background: none; color: var(--muted); font-size: 1.3rem; line-height: 1; cursor: pointer; border-radius: 8px; }
.del:hover { color: var(--down); background: var(--surface-2); }
.confirm { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding-top: 8px; font-size: 0.92rem; }
.confirm .btn { min-height: 36px; padding: 0 14px; }
.confirm .btn.danger { background: var(--down); border-color: var(--down); color: var(--bg); }

.empty { padding: 28px 0; color: var(--muted); display: flex; flex-direction: column; gap: 12px; align-items: flex-start; }
footer { display: flex; flex-direction: column; gap: 2px; }
.status { font-size: 0.85rem; color: var(--muted); min-height: 1.3em; }
.status.warn { color: var(--down); }
.path { font-size: 0.75rem; color: var(--muted); opacity: 0.8; overflow-wrap: anywhere; user-select: text; }

@media (max-width: 560px) {
  body { padding-inline: 14px; }
  h1 { font-size: 1.8rem; }
  .spark { display: none; }
  .row { grid-template-columns: minmax(0, 1fr) auto 34px; }
  .qty { width: 7.75rem; }
  .stat { padding: 12px 12px 16px; }
  .stat b { font-size: 1.7rem; }
  .bar .btn { flex: 1 1 auto; }
}
@media (prefers-reduced-motion: no-preference) {
  .btn, .qty, .del { transition: border-color 0.15s, background-color 0.15s, filter 0.15s; }
}
@media (prefers-reduced-motion: reduce) {
  .prog i { transition: none; }
}

/* Backup row (web version) */
.btn.small { min-height: 34px; padding: 0 14px; font-size: 0.9rem; }
.btn.danger { background: var(--down); border-color: var(--down); color: var(--bg); }
footer { gap: 10px; }
.backup { display: flex; align-items: center; gap: 8px; font-size: 0.82rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.backup span { margin-right: 4px; }
.import-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; font-size: 0.92rem; }
.import-bar span { flex: 1 1 260px; min-width: 0; overflow-wrap: anywhere; }
