:root {
  color-scheme: light;
  --bg: #ffffff;
  --panel: #ffffff;
  --subtle: #fafafa;
  --ink: #1b1b1b;
  --muted: #6d6d6d;
  --line: #e6e6e6;
  --accent: #b8860b;
  --accent-soft: #fdf6e3;
  --added: #6b9bd1;
  --danger: #b3402c;
  --pos: #3f7d3f;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .04);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

/* header */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding: .85rem clamp(1rem, 4vw, 2.5rem);
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.brand {
  font-weight: 700;
  font-size: 1.1rem;
  text-decoration: none;
  color: var(--ink);
}
.topbar nav { display: flex; align-items: center; gap: 1.1rem; flex-wrap: wrap; }
.topbar nav a { color: var(--muted); text-decoration: none; font-size: .95rem; }
.topbar nav a:hover { color: var(--accent); }
.who { font-size: .95rem; color: var(--ink); font-weight: 600; }

main {
  max-width: 1000px;
  margin: 0 auto;
  padding: clamp(1rem, 4vw, 2.25rem) clamp(1rem, 4vw, 2.5rem) 3rem;
}

h1 { font-size: 1.6rem; margin: 0 0 1.25rem; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; margin: 0 0 1rem; letter-spacing: .01em; }
h2.section-head {
  margin: 2rem 0 1rem;
  padding-bottom: .5rem;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: .95rem;
  text-transform: uppercase;
  letter-spacing: .06em;
}

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

/* admin tabs */
.tabs {
  display: flex;
  gap: .25rem;
  flex-wrap: wrap;
  margin: 0 0 1.25rem;
  border-bottom: 1px solid var(--line);
}
.tab {
  text-decoration: none;
  color: var(--muted);
  font-size: .95rem;
  font-weight: 600;
  padding: .55rem .95rem;
  border: 1px solid transparent;
  border-bottom: none;
  border-radius: 8px 8px 0 0;
  margin-bottom: -1px;
}
.tab:hover { color: var(--ink); background: var(--subtle); }
.tab.active {
  color: var(--accent);
  background: var(--panel);
  border-color: var(--line);
  border-bottom: 1px solid var(--panel);
}

/* cards */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow);
}
.card.narrow { max-width: 26rem; margin: 3rem auto; }

/* alerts */
.alert {
  padding: .7rem 1rem;
  border-radius: var(--radius);
  margin: 0 0 1.25rem;
  font-size: .95rem;
  border: 1px solid var(--line);
}
.alert.notice { background: var(--accent-soft); border-color: #f0e4c2; }
.alert.error {
  background: #fdf1ef;
  color: var(--danger);
  border-color: #f3d9d3;
}
.alert.inline-alert { margin: .9rem 0 0; }

/* filters */
.filters { padding-bottom: 1rem; }
.filters .clear { font-size: .85rem; color: var(--muted); text-decoration: underline; padding-bottom: .6rem; }
.presets { display: flex; gap: .45rem; flex-wrap: wrap; margin-top: .9rem; }
.preset {
  font-size: .82rem;
  text-decoration: none;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: .25rem .75rem;
  background: var(--subtle);
}
.preset:hover { border-color: var(--accent); color: var(--accent); }
.preset.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}

/* stats */
.stats { display: flex; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.stat {
  flex: 1 1 11rem;
  display: flex;
  align-items: center;
  gap: .9rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
  box-shadow: var(--shadow);
}
.stat-icon { font-size: 1.6rem; }
.stat-value { font-size: 1.9rem; font-weight: 700; line-height: 1.1; letter-spacing: -.02em; }
.stat.big .stat-value { font-size: 2.6rem; color: var(--accent); }
.stat.warn .stat-value { color: var(--danger); }
.stat-label { color: var(--muted); font-size: .85rem; }

/* inventory */
.inv-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.inv-head p { margin: -.6rem 0 0; }
.inv-figure { text-align: right; }
.inv-value { font-size: 2.8rem; font-weight: 700; line-height: 1; letter-spacing: -.03em; color: var(--accent); }
.inv-figure.negative .inv-value { color: var(--danger); }
.inv-label { color: var(--muted); font-size: .85rem; }
.inv-math {
  display: flex;
  align-items: center;
  gap: .6rem;
  flex-wrap: wrap;
  margin: 1rem 0 0;
  padding: .7rem .9rem;
  background: var(--subtle);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: .9rem;
  color: var(--muted);
}
.inv-math .op { color: var(--muted); font-weight: 700; }
.inv-math .strong { color: var(--ink); font-weight: 700; }
.negneg { color: var(--danger); font-weight: 700; }
.pos { color: var(--pos); }
.inventory form.row { margin-top: 1.1rem; }
.inventory table { margin-top: 1.1rem; }
.csv { font-size: .85rem; text-decoration: none; white-space: nowrap; }
.csv:hover { text-decoration: underline; }

/* forms */
form.stack { display: flex; flex-direction: column; gap: .9rem; }
form.row { display: flex; gap: .9rem; flex-wrap: wrap; align-items: flex-end; }
form.row .grow { flex: 1 1 14rem; }
form.inline { display: inline; }

label { display: flex; flex-direction: column; gap: .3rem; font-size: .85rem; color: var(--muted); }
label.checkbox { flex-direction: row; align-items: center; gap: .4rem; padding-bottom: .55rem; white-space: nowrap; }
label.checkbox input { width: auto; }

/* password field + save button sitting on one line inside a table cell */
.inline-form { display: flex; align-items: center; gap: .4rem; }
.inline-form input { font-size: .85rem; padding: .35rem .5rem; min-width: 8rem; }

.users form.row { margin: 1rem 0 1.25rem; }
.users p { margin-top: -.5rem; }

input {
  font: inherit;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: .55rem .7rem;
  min-width: 0;
  width: 100%;
}
input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

button {
  font: inherit;
  cursor: pointer;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: .55rem 1.1rem;
  background: #f0f0f0;
  color: var(--ink);
}
button.primary { background: var(--accent); color: #fff; font-weight: 600; }
button.primary:hover { filter: brightness(1.08); }
/* an <a> that should read as a button */
.button-link {
  display: inline-block;
  white-space: nowrap;
  font-weight: 600;
  font-size: .95rem;
  text-decoration: none;
  background: var(--accent);
  color: #fff;
  border-radius: 8px;
  padding: .55rem 1.1rem;
}
.button-link:hover { filter: brightness(1.08); }
.backup .inv-head { align-items: center; }
.backup p { margin: -.4rem 0 0; max-width: 46ch; }

button.link {
  background: none;
  padding: 0;
  color: var(--muted);
  font-size: .85rem;
  text-decoration: underline;
}
button.link:hover { color: var(--ink); }
button.link.danger:hover { color: var(--danger); }

/* tables */
table { width: 100%; border-collapse: collapse; font-size: .95rem; }
thead th {
  text-align: left;
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  font-weight: 600;
  padding: 0 .6rem .5rem;
  border-bottom: 1px solid var(--line);
}
tbody td { padding: .65rem .6rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
.numeric { text-align: right; font-variant-numeric: tabular-nums; }
.strong { font-weight: 700; }
.shrink { width: 1%; white-space: nowrap; }
.note { color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: .8rem; }
.empty { margin: 0; }
.badge {
  display: inline-block;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid #f0e4c2;
  border-radius: 999px;
  padding: .05rem .5rem;
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  vertical-align: middle;
}

/* share + dual bars */
.sharecell { display: flex; align-items: center; gap: .5rem; min-width: 9rem; }
.bar { flex: 1; height: 7px; background: #f0f0f0; border-radius: 999px; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.dualbar { flex: 1; display: flex; flex-direction: column; gap: 3px; min-width: 6rem; }
.dualbar span { display: block; height: 7px; border-radius: 999px; min-width: 2px; }
.dualbar .taken { background: var(--accent); }
.dualbar .added { background: var(--added); }
.legend { display: flex; align-items: center; gap: .4rem; font-size: .78rem; color: var(--muted); margin: .9rem 0 0; }
.legend .key { display: inline-block; width: 12px; height: 7px; border-radius: 999px; margin-left: .6rem; }
.legend .key:first-child { margin-left: 0; }
.legend .key.taken { background: var(--accent); }
.legend .key.added { background: var(--added); }

/* daily chart */
.chart {
  display: flex;
  align-items: flex-end;
  gap: .5rem;
  height: 170px;
  overflow-x: auto;
  padding-top: .5rem;
}
.chart .col {
  flex: 1 0 2.4rem;
  max-width: 5rem; /* keep a 2-bar range from stretching into slabs */
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  height: 100%;
  gap: .25rem;
}
.colval { font-size: .75rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.colbar { width: 100%; background: var(--accent); border-radius: 5px 5px 0 0; min-height: 4px; }
.collabel { font-size: .7rem; color: var(--muted); white-space: nowrap; }

footer {
  text-align: center;
  color: var(--muted);
  font-size: .8rem;
  padding: 1.5rem;
  border-top: 1px solid var(--line);
}
