/* Elegant minimal, mobile first. One warm accent, serif display type, hairline
   rules instead of boxes, and tables that become cards on a phone.

   Chart colours are a single-hue ordinal ramp (--c1…--c8) rather than a set of
   categorical hues: "where the money goes" is ordered magnitude, so one hue
   stepped light→dark reads correctly and stays calm. The ramp is validated for
   monotone lightness, adjacent-step separation and contrast against --paper. */
:root {
  --ink: #241f1b;
  --ink-soft: #6a6058;
  --ink-faint: #9a9088;
  --line: #e7e0d5;
  --line-soft: #f0ebe3;
  --paper: #fbf9f6;
  --card: #ffffff;
  --accent: #92692e;
  --accent-deep: #6e4a1e;
  --accent-wash: #f6efe2;
  --good: #4f6b4a;
  --bad: #a8443c;

  /* Validated ordinal ramp — do not reorder. */
  --c1: #cbaa66; --c2: #b8944f; --c3: #a67e3c; --c4: #92692e;
  --c5: #7d5624; --c6: #67451b; --c7: #513614; --c8: #3b260e;

  --radius: 12px;
  --pad: 18px;
  --shadow: 0 1px 2px rgba(60, 46, 28, 0.04), 0 6px 18px rgba(60, 46, 28, 0.05);
  --serif: 'Iowan Old Style', 'Palatino Linotype', Palatino, Georgia, 'Times New Roman', serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  font-family: var(--serif);
  font-weight: 400;
  margin: 0 0 12px;
  letter-spacing: 0.005em;
}
h2 { font-size: 1.4rem; }
h3 { font-size: 1.08rem; }
.section-gap { margin-top: 40px; }

/* A small-caps label, used for section and column headings. */
.eyebrow, .grid th, .stat-label, .total span, .mark {
  font-size: 0.7rem;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--ink-faint);
  font-weight: 500;
}

/* Money and counts line up in columns. */
.stat-value, .total strong, .bar-value, .cal-amount,
.col--money input, .col--num input, .countdown strong {
  font-variant-numeric: tabular-nums;
}

/* ---------- chrome ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(251, 249, 246, 0.88);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
  padding: 12px var(--pad) 0;
}
.mark { display: block; color: var(--accent); }
.tabs {
  display: flex;
  gap: 2px;
  overflow-x: auto;
  scrollbar-width: none;
  margin-top: 10px;
}
.tabs::-webkit-scrollbar { display: none; }
.tab-btn {
  flex: 0 0 auto;
  border: 0;
  background: none;
  padding: 10px 14px 12px;
  font-size: 0.94rem;
  color: var(--ink-soft);
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: color 0.15s;
}
.tab-btn:hover { color: var(--ink); }
.tab-btn.is-active { color: var(--accent); border-bottom-color: var(--accent); }

.main { padding: var(--pad) var(--pad) 64px; max-width: 1180px; margin: 0 auto; }
.main[aria-busy='true'] { opacity: 0.45; transition: opacity 0.15s; }

.hint { color: var(--ink-soft); font-size: 0.87rem; margin: 0 0 16px; max-width: 68ch; }
.empty { color: var(--ink-faint); font-style: italic; }
.error { color: var(--bad); }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- buttons ---------- */
.btn {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  padding: 10px 20px;
  border-radius: 999px;
  font-size: 0.92rem;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.btn:hover { background: var(--accent-deep); border-color: var(--accent-deep); }
.btn--quiet { background: none; color: var(--accent); }
.btn--quiet:hover { background: var(--accent-wash); border-color: var(--accent); color: var(--accent-deep); }
.btn--add {
  background: none;
  color: var(--accent);
  border-style: dashed;
  border-radius: var(--radius);
  width: 100%;
  margin-top: 12px;
}
.btn--add:hover { background: var(--accent-wash); }
.btn-icon {
  border: 0; background: none; color: var(--ink-faint);
  font-size: 1.15rem; line-height: 1; padding: 6px 10px; cursor: pointer; border-radius: 8px;
}
.btn-icon:hover { background: var(--line-soft); color: var(--bad); }
.cal-head .btn-icon:hover { color: var(--accent); }
.btn-link {
  border: 0; background: none; color: var(--accent);
  font-size: 0.82rem; cursor: pointer; padding: 4px 6px; border-radius: 6px;
  white-space: nowrap;
}
.btn-link:hover { background: var(--accent-wash); }

/* ---------- forms ---------- */
input, select {
  font: inherit;
  color: inherit;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 8px;
  padding: 8px;
  width: 100%;
  min-width: 0;
  transition: border-color 0.12s, background 0.12s;
}
input:hover:not(:disabled), select:hover:not(:disabled) { border-color: var(--line); background: #fff; }
input:focus, select:focus { outline: 0; border-color: var(--accent); background: #fff; }
input:disabled, select:disabled { color: var(--ink); opacity: 1; cursor: default; }
input::placeholder { color: var(--ink-faint); }
input[type='checkbox'] { width: 18px; height: 18px; accent-color: var(--accent); cursor: pointer; }

.field { display: block; margin-bottom: 16px; }
.field span { display: block; font-size: 0.82rem; color: var(--ink-soft); margin-bottom: 5px; }
.field input { border-color: var(--line); background: #fff; }
.form { max-width: 440px; }

/* ---------- tables ---------- */
.table-wrap {
  overflow-x: auto;
  padding-bottom: 4px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 4px 12px 12px;
}
.grid { width: 100%; border-collapse: collapse; font-size: 0.9rem; table-layout: auto; }
.grid th {
  text-align: left;
  padding: 12px 8px 8px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.grid td { padding: 2px 4px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.grid tbody tr:last-child td { border-bottom: 0; }
.grid tbody tr:hover td { background: var(--paper); }
.col--money input, .col--num input { text-align: right; }
.col--money { min-width: 104px; }
.col--num { min-width: 92px; }
.col--select { min-width: 116px; }
.col--bool, .col--action { width: 60px; text-align: center; }
.col--date { min-width: 146px; }
.col--text, .col--combo { min-width: 130px; }

.totals {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}
.total {
  flex: 1 1 150px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.total strong { font-family: var(--serif); font-size: 1.22rem; font-weight: 400; }
.total small { color: var(--ink-faint); font-size: 0.76rem; }
.total--flag { border-color: #e3d3b4; background: var(--accent-wash); }
.total--flag strong { color: var(--accent-deep); }

/* ---------- to-do ---------- */
.bucket { margin-bottom: 30px; }
.bucket h3 {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
  margin-bottom: 4px;
}
.bucket h3 small {
  color: var(--ink-faint); font-size: 0.75rem;
  font-family: system-ui, sans-serif; letter-spacing: 0.08em;
}
.tasks { list-style: none; margin: 0; padding: 0; }
.task {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 0;
  border-bottom: 1px solid var(--line-soft);
}
.task:last-child { border-bottom: 0; }
.task .task-title { flex: 1 1 auto; }
.task .task-due { flex: 0 0 150px; color: var(--ink-soft); font-size: 0.84rem; }
.task.is-done .task-title { text-decoration: line-through; color: var(--ink-faint); }

/* ---------- dashboard ---------- */
.hero { text-align: center; padding: 34px 0 34px; }
.hero h1 { font-size: clamp(1.6rem, 4.4vw, 2.4rem); line-height: 1.2; margin-bottom: 18px; }
/* Hairline rule with a centred diamond. */
.ornament {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  margin: 0 auto 18px; max-width: 260px; color: var(--accent);
}
.ornament::before, .ornament::after {
  content: ''; flex: 1 1 auto; height: 1px;
  background: linear-gradient(to right, transparent, var(--line), transparent);
}
.ornament span { font-size: 0.6rem; transform: rotate(45deg); display: block; width: 6px; height: 6px; background: currentColor; }
.countdown { margin: 0; color: var(--ink-soft); font-size: 0.9rem; letter-spacing: 0.1em; text-transform: uppercase; }
.countdown strong {
  font-family: var(--serif);
  font-size: clamp(2.6rem, 9vw, 3.6rem);
  font-weight: 400;
  color: var(--accent);
  display: block;
  line-height: 1;
  letter-spacing: -0.01em;
  margin-bottom: 6px;
}
.hero-date { color: var(--ink-faint); font-size: 0.86rem; margin: 14px 0 0; }

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(158px, 1fr));
  gap: 1px;
  margin-bottom: 26px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.stat { background: var(--card); padding: 15px 16px; }
.stat-label { display: block; }
/* 1.3 rather than a tight 1.15: the serif's ascenders and descenders overflow a
   line box sized to the cap height. */
.stat-value {
  display: block; font-family: var(--serif); font-size: 1.32rem;
  font-weight: 400; margin-top: 6px; line-height: 1.3;
}
.stat-hint { display: block; color: var(--ink-faint); font-size: 0.75rem; margin-top: 4px; }
.stat--flag .stat-value { color: var(--accent-deep); }

.cards { display: grid; grid-template-columns: 1fr; gap: 16px; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.card h3 { margin-bottom: 16px; }

.donut-wrap { display: flex; flex-wrap: wrap; gap: 22px; align-items: center; }
.donut-holder { position: relative; flex: 0 0 auto; width: 172px; height: 172px; }
.donut { width: 172px; height: 172px; display: block; }
.donut circle { transition: opacity 0.15s; }
.donut-wrap:hover .donut circle { opacity: 0.45; }
.donut circle:hover { opacity: 1; }
.donut-center {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  pointer-events: none; text-align: center;
}
.donut-center small { color: var(--ink-faint); font-size: 0.66rem; letter-spacing: 0.12em; text-transform: uppercase; }
.donut-center strong { font-family: var(--serif); font-weight: 400; font-size: 1.05rem; font-variant-numeric: tabular-nums; }

.legend { list-style: none; margin: 0; padding: 0; flex: 1 1 240px; font-size: 0.87rem; }
.legend li {
  display: flex; align-items: center; gap: 9px;
  padding: 5px 0; border-bottom: 1px solid var(--line-soft);
}
.legend li:last-child { border-bottom: 0; }
.swatch { width: 10px; height: 10px; border-radius: 2px; flex: 0 0 auto; }
.legend-label { flex: 1 1 auto; }
.legend-value { color: var(--ink); font-variant-numeric: tabular-nums; }
.legend-pct { color: var(--ink-faint); width: 42px; text-align: right; font-variant-numeric: tabular-nums; }

.bars { list-style: none; margin: 0; padding: 0; }
.bars li { padding: 9px 0; font-size: 0.86rem; border-bottom: 1px solid var(--line-soft); }
.bars li:last-child { border-bottom: 0; }
.bar-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 5px; }
.bar-label { color: var(--ink); }
.bar-value { color: var(--ink-soft); font-size: 0.79rem; white-space: nowrap; }
.bar-track, .bar {
  position: relative; height: 14px;
  background: var(--line-soft); border-radius: 7px; overflow: hidden;
}
.bar--inline { display: inline-block; width: 110px; vertical-align: middle; height: 7px; }
.bar-fill { position: absolute; left: 0; top: 0; height: 100%; border-radius: 7px; background: var(--accent); }
.bar-fill--expected { background: #e3d3b4; }
.bar-fill--actual { height: 7px; top: 3.5px; background: var(--accent); }
.bar-fill--actual.is-over { background: var(--bad); }
.over-flag { color: var(--bad); font-size: 0.75rem; }

.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.cal-head h3 { margin: 0; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; margin: 12px 0 18px; }
.dow { text-align: center; font-size: 0.66rem; letter-spacing: 0.1em; color: var(--ink-faint); padding-bottom: 6px; }
.day {
  aspect-ratio: 1;
  border-radius: 8px;
  font-size: 0.82rem;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  color: var(--ink-soft);
}
.day--blank { visibility: hidden; }
.day.has-events { background: var(--accent-wash); color: var(--ink); font-weight: 600; }
.day.is-today { box-shadow: inset 0 0 0 1.5px var(--accent); color: var(--accent-deep); }
.dots { display: flex; gap: 3px; height: 5px; }
.dot { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); display: inline-block; flex: 0 0 auto; }
.dot--todo { background: var(--good); }
.dot.is-done { opacity: 0.28; }

.cal-list { list-style: none; margin: 0; padding: 0; font-size: 0.87rem; }
.cal-list li {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 0; border-top: 1px solid var(--line-soft);
}
.cal-list li.is-done { color: var(--ink-faint); text-decoration: line-through; }
.cal-date { width: 22px; color: var(--ink-faint); text-align: right; font-variant-numeric: tabular-nums; }
.cal-label { flex: 1 1 auto; }
.cal-amount { color: var(--ink-soft); font-size: 0.8rem; white-space: nowrap; }

/* ---------- login ---------- */
.login-body { display: grid; place-items: center; min-height: 100vh; padding: var(--pad); background: var(--paper); }
.login { text-align: center; max-width: 320px; width: 100%; }
.login h1 { font-size: 1.7rem; margin-bottom: 6px; }
.login .hint { margin-bottom: 22px; }
.login input {
  border-color: var(--line);
  background: #fff;
  text-align: center;
  letter-spacing: 0.35em;
  margin-bottom: 14px;
  padding: 13px;
  border-radius: 10px;
}
.login .btn { width: 100%; }
.login .error { margin-top: 14px; font-size: 0.88rem; }

/* ---------- toast ---------- */
.toast {
  position: fixed;
  left: 50%; bottom: 26px;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  padding: 11px 20px;
  border-radius: 999px;
  font-size: 0.87rem;
  z-index: 100;
  box-shadow: var(--shadow);
  transition: opacity 0.35s;
}
.toast--bad { background: var(--bad); }
.toast.is-out { opacity: 0; }

/* ---------- phone: tables become cards ---------- */
@media (max-width: 700px) {
  :root { --pad: 14px; }
  .table-wrap { background: none; border: 0; box-shadow: none; padding: 0; }
  .grid, .grid tbody, .grid tr, .grid td { display: block; width: 100%; }
  .grid thead { display: none; }
  .grid tr {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    margin-bottom: 12px;
    padding: 8px 12px;
    box-shadow: var(--shadow);
  }
  /* Cards, not columns — the desktop min-widths must not apply here. */
  .grid td {
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 0;
    padding: 3px 0;
    min-width: 0;
    width: auto;
  }
  .grid tbody tr:hover td { background: none; }
  .grid td::before {
    content: attr(data-label);
    flex: 0 0 42%;
    font-size: 0.68rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--ink-faint);
  }
  .grid td.col--action, .grid td.col--extra { justify-content: flex-end; }
  .grid td.col--action::before, .grid td.col--extra::before { content: none; }
  .col--money input, .col--num input { text-align: left; }
  .task .task-due { flex: 0 0 128px; }
  .donut-wrap { justify-content: center; }
}

@media (min-width: 920px) {
  .cards { grid-template-columns: 1fr 1fr; }
  .cards .card:last-child { grid-column: 1 / -1; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
