:root {
  /* Christmas palette: evergreen, holly red, gold, warm cream */
  --bg: #f7f1e6;
  --surface: #fffdf8;
  --surface-2: #efe6d6;
  --ink: #1c2a21;
  --ink-2: #47554b;
  --muted: #7d8379;
  --line: #e6dccb;

  --green: #1d5a3b;
  --green-ink: #ffffff;
  --red: #b3202e;
  --red-dark: #941a26;
  --red-ink: #ffffff;
  --red-soft: #f9e2e4;
  --gold: #c09336;
  --bar-gray: #cbc3b4;

  --band: #173f2b;
  --band-ink: #fbf6ec;
  --band-muted: #c8d6c9;
  --band-line: rgba(251, 246, 236, 0.35);

  --shadow: 0 1px 2px rgba(28, 42, 33, 0.05), 0 6px 18px rgba(28, 42, 33, 0.05);

  --pill-ordered-bg: #eee9e0;   --pill-ordered: #5d584e;
  --pill-packed-bg: #f6ead0;    --pill-packed: #7c5a12;
  --pill-shipped-bg: #e0ece3;   --pill-shipped: #1d5a3b;
  --pill-out-bg: #f9e2e4;       --pill-out: #9a1c28;
  --pill-delivered-bg: #1d5a3b; --pill-delivered: #ffffff;
  --pill-done-bg: #ece9e4;      --pill-done: #78736b;
  --pill-late-bg: #b3202e;      --pill-late: #ffffff;

  --serif: "Fraunces", Georgia, "Times New Roman", serif;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1511;
    --surface: #161e18;
    --surface-2: #1f2a22;
    --ink: #f0ede4;
    --ink-2: #bec7bd;
    --muted: #8c968c;
    --line: #2a362d;

    --green: #7cc29a;
    --green-ink: #0e1a12;
    --red: #e0606d;
    --red-dark: #c94b58;
    --red-ink: #1a0d0f;
    --red-soft: #3b1d21;
    --gold: #dcb767;
    --bar-gray: #4a534b;

    --band: #0f2a1c;
    --band-ink: #f4efe3;
    --band-muted: #a9bcac;
    --band-line: rgba(244, 239, 227, 0.3);

    --shadow: none;

    --pill-ordered-bg: #2a2d29;   --pill-ordered: #c9c6bd;
    --pill-packed-bg: #3a2f17;    --pill-packed: #ecc977;
    --pill-shipped-bg: #1b3526;   --pill-shipped: #9dd6b3;
    --pill-out-bg: #3b1d21;       --pill-out: #f2a3ab;
    --pill-delivered-bg: #7cc29a; --pill-delivered: #0e1a12;
    --pill-done-bg: #2a2a28;      --pill-done: #a29e96;
    --pill-late-bg: #e0606d;      --pill-late: #1a0d0f;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.wrap {
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px 24px 64px;
  display: grid;
  gap: 20px;
}

h1, h2 { font-family: var(--serif); font-weight: 500; margin: 0; }
h1 { font-size: 46px; line-height: 1.05; letter-spacing: -0.01em; }
h2 { font-size: 21px; color: var(--green); }

.hint { color: var(--muted); font-size: 13px; }

/* Header band: red ribbon on top, evergreen band, gold line under */
.band {
  background: var(--band);
  color: var(--band-ink);
  border-top: 6px solid var(--red);
  border-bottom: 3px solid var(--gold);
}
.top {
  max-width: 1180px;
  margin: 0 auto;
  padding: 34px 24px 30px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 24px;
  flex-wrap: wrap;
}
.eyebrow {
  margin: 0 0 6px;
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold);
  font-weight: 600;
}
.countdown { margin: 8px 0 0; color: var(--band-muted); }
.countdown::before { content: "\2605"; color: var(--gold); margin-right: 8px; font-size: 13px; }

.scan { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.accounts {
  display: grid; grid-template-columns: 8px auto auto auto;
  column-gap: 8px; row-gap: 6px; align-items: center;
  font-size: 13px; color: var(--band-muted);
}
.account { display: contents; }
.account .act { justify-self: start; }
.account .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--band-line); }
.account.connected .dot { background: #8fd3a8; }
.account.needs .dot { background: var(--red); }
.account .email { font-weight: 500; color: var(--band-ink); overflow-wrap: anywhere; }
.account .when { color: var(--band-muted); }
.band .btn.small { background: transparent; color: var(--band-ink); border-color: var(--band-line); }
.band .btn.small:hover { border-color: var(--band-ink); }

.btn {
  font: inherit;
  font-weight: 500;
  font-size: 14px;
  border-radius: 999px;
  padding: 9px 18px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}
.btn.primary { background: var(--red); color: var(--red-ink); border-color: var(--red); padding: 10px 22px; }
.btn.primary:hover { background: var(--red-dark); border-color: var(--red-dark); }
.btn.small { padding: 3px 10px; font-size: 12px; }
.btn:disabled { opacity: 0.6; cursor: default; }
.btn:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 20px 22px;
  box-shadow: var(--shadow);
  min-width: 0;
}
.card-head {
  display: flex; justify-content: space-between; align-items: baseline;
  gap: 12px; flex-wrap: wrap; margin-bottom: 12px;
}
.two-col { display: grid; grid-template-columns: 1.25fr 1fr; gap: 20px; }

/* KPI tiles */
.kpis { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; }
.kpi {
  background: var(--surface);
  border: 1px solid var(--line);
  border-top: 3px solid var(--green);
  border-radius: 14px;
  padding: 14px 16px 14px;
  box-shadow: var(--shadow);
  min-width: 0;
}
.kpi:nth-child(even) { border-top-color: var(--red); }
.kpi .label { font-size: 12px; color: var(--muted); font-weight: 500; }
.kpi .value {
  font-family: var(--serif);
  font-size: 28px;
  line-height: 1.2;
  margin-top: 6px;
  color: var(--green);
  font-variant-numeric: lining-nums tabular-nums;
  white-space: nowrap;
}
.kpi .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.kpi.bad .value { color: var(--red); }

/* Progress */
.progress { display: grid; gap: 10px; }
.progress-text { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: 14px; color: var(--ink-2); }
.progress-text strong { color: var(--green); font-weight: 600; }
.bar { height: 12px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.bar-fill {
  height: 100%; border-radius: 999px; width: 0; transition: width 0.6s ease;
  background: var(--green);
}
.bar-fill.over { background: var(--red); }

/* Tables */
.table-scroll { overflow-x: auto; margin: 0 -22px; padding: 0 22px; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th {
  text-align: left; font-size: 12px; font-weight: 500; color: var(--muted);
  padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
th:first-child, td:first-child { padding-left: 0; }
th:last-child, td:last-child { padding-right: 0; }
.num { text-align: right; white-space: nowrap; }
.center { text-align: center; }
.muted { color: var(--muted); }

.people td.name { font-weight: 500; white-space: nowrap; }
.check {
  display: inline-grid; place-items: center;
  width: 22px; height: 22px; border-radius: 6px; padding: 0;
  border: 1.5px solid var(--bar-gray); background: var(--surface); color: var(--green-ink);
  cursor: pointer;
}
.check:hover { border-color: var(--green); }
.check:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.check.on { background: var(--green); border-color: var(--green); }
.check.on::after { content: "\2713"; font-size: 13px; line-height: 1; }

/* Ideas and notes: looks like text until you click it */
.people td.ideas { min-width: 220px; width: 40%; padding-top: 6px; padding-bottom: 6px; }
.people td.ideas textarea {
  display: block; width: 100%; resize: none; overflow: hidden;
  font: inherit; font-size: 14px; line-height: 1.4; color: var(--ink);
  padding: 4px 8px; margin-left: -8px; border-radius: 8px;
  border: 1px solid transparent; background: transparent;
}
.people td.ideas textarea::placeholder { color: var(--muted); }
.people td.ideas textarea:hover { border-color: var(--line); }
.people td.ideas textarea:focus { outline: none; border-color: var(--gold); background: var(--surface); }

.orders th[data-sort] { cursor: pointer; user-select: none; }
.orders th[data-sort]:hover { color: var(--ink); }
.orders th .arrow { font-size: 10px; margin-left: 4px; color: var(--red); }
.orders td.items { min-width: 240px; }
.orders td.store { font-weight: 500; white-space: nowrap; }
.orders .ordnum { display: block; font-size: 12px; color: var(--muted); font-weight: 400; }
.orders td.date, .orders td.for, .orders td.email { white-space: nowrap; }
.link { color: var(--red); text-decoration: none; font-weight: 500; white-space: nowrap; }
.link:hover { text-decoration: underline; }

/* Budgets */
.money-input {
  display: inline-flex; align-items: center; gap: 2px;
  border: 1px solid var(--line); border-radius: 8px; padding: 3px 8px;
  background: var(--surface); color: var(--muted);
}
.money-input:focus-within { border-color: var(--gold); box-shadow: 0 0 0 2px color-mix(in srgb, var(--gold) 25%, transparent); }
.money-input input {
  width: 58px; border: 0; background: transparent; color: var(--ink);
  font: inherit; font-size: 14px; text-align: right; padding: 0; outline: none;
  font-variant-numeric: tabular-nums;
}
.money-input input::placeholder { color: var(--muted); }
.people td.budget { white-space: nowrap; }

/* Order totals: look like plain numbers until you point at them */
.total-input { border-color: transparent; background: transparent; padding: 3px 6px; color: var(--ink); }
.total-input input { width: 72px; }
.total-input:hover { border-color: var(--line); background: var(--surface); }
.total-input:focus-within { background: var(--surface); }
.total-input.missing { border-color: var(--red); background: var(--red-soft); color: var(--red); }
.total-input.missing input::placeholder { color: var(--red); font-weight: 600; }
.people td.spent, .g-spent { white-space: nowrap; min-width: 92px; }
.amount { font-variant-numeric: tabular-nums; }
.sub { font-size: 11px; color: var(--muted); margin-top: 2px; }
.sub.over { color: var(--red); font-weight: 600; }
.mini { height: 4px; border-radius: 999px; background: var(--surface-2); margin-top: 6px; overflow: hidden; width: 88px; }
.mini > div { height: 100%; background: var(--green); border-radius: 999px; }
.mini > div.over { background: var(--red); }
.hint.warn { color: var(--red); }

/* Group gifts */
.groups { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); }
.groups-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 8px; }
.groups-head h3 { font-family: var(--serif); font-weight: 500; font-size: 17px; color: var(--green); margin: 0; }
.groups-head .hint { margin: 2px 0 0; }
.group-list { list-style: none; margin: 0; padding: 0; }
.group-row {
  display: grid; grid-template-columns: 1fr auto auto auto; gap: 16px; align-items: start;
  padding: 12px 0; border-bottom: 1px solid var(--line);
}
.group-row:last-child { border-bottom: 0; }
.group-list li.empty { color: var(--muted); font-size: 14px; padding: 6px 0; }
.g-members { font-size: 13px; color: var(--ink-2); margin-top: 2px; }
.group-form {
  background: var(--surface-2); border-radius: 12px; padding: 16px; margin: 8px 0 12px;
  display: grid; gap: 14px;
}
.field { display: grid; gap: 6px; border: 0; margin: 0; padding: 0; min-width: 0; }
.field > span, .field > legend { font-size: 13px; font-weight: 500; color: var(--ink-2); padding: 0; }
.field input[type="text"] {
  font: inherit; padding: 8px 12px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); max-width: 320px;
}
.field input[type="text"]:focus { outline: 2px solid var(--gold); outline-offset: 1px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { position: relative; cursor: pointer; }
.chip input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.chip span {
  display: inline-block; padding: 5px 12px; border-radius: 999px; font-size: 13px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-2);
}
.chip input:checked + span { background: var(--green); border-color: var(--green); color: var(--green-ink); }
.chip input:checked + span::before { content: "\2713  "; }
.chip input:focus-visible + span { outline: 2px solid var(--gold); outline-offset: 2px; }
.form-error { color: var(--red); font-size: 13px; margin: 0; min-height: 0; }
.form-error:empty { display: none; }
.form-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.btn.danger { color: var(--red); border-color: var(--red); background: transparent; margin-left: auto; }

/* Small text buttons (Split, Hide, ...) */
.linkish {
  background: none; border: 0; padding: 0; cursor: pointer;
  font: inherit; font-size: 12px; font-weight: 500; color: var(--red);
}
.linkish:hover { text-decoration: underline; }
.linkish:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; border-radius: 4px; }
.row-actions { display: flex; gap: 14px; margin-top: 4px; flex-wrap: wrap; }
.tag {
  display: inline-block; margin-left: 6px; padding: 1px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 500; background: var(--pill-packed-bg); color: var(--pill-packed);
  vertical-align: 1px;
}
.orders tr.is-split td { background: color-mix(in srgb, var(--gold) 6%, transparent); }

/* Split panel */
.orders tr.split-row td { padding: 14px 16px; background: var(--surface-2); border-radius: 0 0 10px 10px; }
/* Stay in view even when the table is wider than the window. */
.split-panel { position: sticky; left: 0; width: min(680px, calc(100vw - 96px)); }
.split-intro { margin: 0 0 12px; font-size: 13px; color: var(--ink-2); max-width: 640px; }
.split-part { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; flex-wrap: wrap; }
.split-name {
  flex: 1; min-width: 200px; max-width: 460px; font: inherit; font-size: 14px;
  padding: 6px 10px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink);
}
.split-name:focus { outline: 2px solid var(--gold); outline-offset: 1px; }
.split-tools { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; margin: 6px 0 10px; max-width: 640px; }
.split-left { margin-left: auto; font-size: 13px; font-weight: 600; }
.split-left.ok { color: var(--green); }
.split-left.bad { color: var(--red); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* Add a gift by hand */
.head-actions { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.gift-form {
  background: var(--surface-2); border-radius: 12px; padding: 16px; margin: 0 0 16px;
  display: grid; gap: 14px;
}
.gift-grid { display: grid; grid-template-columns: 2fr 1.4fr 1fr 1.3fr 1.1fr; gap: 12px; align-items: end; }
.field em { font-style: normal; font-weight: 400; color: var(--muted); }
.gift-form .field input[type="text"], .gift-form .field input[type="date"], .gift-form .field select {
  font: inherit; font-size: 14px; padding: 8px 10px; border-radius: 8px; width: 100%; max-width: none;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink); min-width: 0;
}
.gift-form .field .money-input { padding: 8px 10px; width: 100%; }
.gift-form .field .money-input input { border: 0; padding: 0; width: 100%; background: transparent; text-align: left; }
.gift-form .field input:focus, .gift-form .field select:focus { outline: 2px solid var(--gold); outline-offset: 1px; }
.gift-form .field .money-input input:focus { outline: none; } /* the box around it shows the focus */
.gift-form .eta-field { max-width: 220px; }
.pill.s-in-hand { background: var(--pill-delivered-bg); color: var(--pill-delivered); }

/* Hidden orders */
.hidden-orders { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.hidden-list { margin-top: 8px; }
.hidden-list .num { display: flex; align-items: center; gap: 10px; }

/* "For" picker in the orders table */
.for-select {
  font: inherit; font-size: 13px; color: var(--ink);
  border: 1px solid var(--line); border-radius: 8px; padding: 4px 6px;
  background: var(--surface); max-width: 150px;
}
.for-select.unset { color: var(--muted); }
.for-select:focus { outline: 2px solid var(--gold); outline-offset: 1px; }

/* Status pills */
.pill {
  display: inline-block; padding: 2px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 500; white-space: nowrap;
  background: var(--pill-ordered-bg); color: var(--pill-ordered);
}
.pill.s-being-packed { background: var(--pill-packed-bg); color: var(--pill-packed); }
.pill.s-shipped { background: var(--pill-shipped-bg); color: var(--pill-shipped); }
.pill.s-out-for-delivery { background: var(--pill-out-bg); color: var(--pill-out); }
.pill.s-delivered { background: var(--pill-delivered-bg); color: var(--pill-delivered); }
.pill.s-returned, .pill.s-cancelled { background: var(--pill-done-bg); color: var(--pill-done); }
.pill.late { background: var(--pill-late-bg); color: var(--pill-late); }

/* Lists */
.list { list-style: none; margin: 0; padding: 0; }
.list li {
  display: grid; grid-template-columns: 76px 1fr auto; gap: 12px; align-items: start;
  padding: 10px 0; border-bottom: 1px solid var(--line);
}
.list li:last-child { border-bottom: 0; }
.list .day { font-weight: 600; font-size: 13px; white-space: nowrap; color: var(--red); }
.list .day span { display: block; font-weight: 400; color: var(--muted); }
.list .what { min-width: 0; }
.list .what .store { font-weight: 500; }
.list .what .desc { color: var(--ink-2); font-size: 13px; overflow-wrap: anywhere; }
.list li.empty { display: block; color: var(--muted); }
.list .why { color: var(--red); font-size: 12px; margin-top: 2px; }
.list .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }

/* Chart */
.chart-box { position: relative; width: 100%; }
.chart-note { margin: 8px 0 0; }

.foot { color: var(--muted); font-size: 13px; text-align: center; padding-top: 8px; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px);
  background: var(--band); color: var(--band-ink);
  border: 1px solid var(--gold);
  padding: 10px 18px; border-radius: 20px; font-size: 14px; text-align: center; width: max-content;
  opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s;
  max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 1000px) {
  .kpis { grid-template-columns: repeat(3, 1fr); }
  .gift-grid { grid-template-columns: 1fr 1fr; }
  .two-col { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .wrap { padding: 20px 16px 48px; gap: 16px; }
  .top { padding: 26px 16px 24px; }
  h1 { font-size: 36px; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .kpi .value { font-size: 23px; }
  .card { padding: 16px; }
  .table-scroll { margin: 0 -16px; padding: 0 16px; }
  .scan { width: 100%; justify-content: space-between; }
  .accounts { grid-template-columns: 1fr; }
  .account { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
  .group-row { grid-template-columns: 1fr auto; }
  .g-spent { grid-column: 1; }
  .g-actions { grid-column: 2; grid-row: 1; justify-self: end; }
  .groups-head { flex-direction: column; }
}
