/* Sized for a 65-year-old holding a phone in a shop, not for a designer's
   screenshot. Body text is 18px, buttons are 20px and at least 60px tall,
   contrast is near-maximum, and nothing important is conveyed by colour
   alone — every red line also carries a symbol and a word. */

:root {
  --ink: #111418;
  --ink-soft: #4a5560;
  --line: #d4dae0;
  --bg: #ffffff;
  --bg-soft: #f4f6f8;
  --brand: #14532d;
  --brand-ink: #ffffff;
  --danger: #a8121b;
  --danger-bg: #fdeced;
  --warn: #8a5300;
  --warn-bg: #fdf3e2;
  --ok: #14532d;
  --ok-bg: #e8f3ec;
  --radius: 12px;
  --tap: 60px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", "PingFang SC",
               "Microsoft YaHei", "Noto Sans SC", sans-serif;
  font-size: 18px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--bg-soft);
  /* Room for the phone's home indicator so the last button is never cut off. */
  padding-bottom: env(safe-area-inset-bottom);
}

/* ── Chrome ──────────────────────────────────────────────────────────── */

#topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  padding-top: calc(8px + env(safe-area-inset-top));
  background: var(--brand);
  color: var(--brand-ink);
}

#title {
  flex: 1;
  min-width: 0;
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.icon-btn {
  min-width: 48px;
  min-height: 48px;
  font-size: 24px;
  border: 0;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.14);
  color: inherit;
  cursor: pointer;
}
.icon-btn:active { background: rgba(255, 255, 255, 0.3); }
.icon-btn[hidden] { display: none; }

main { padding: 12px; max-width: 720px; margin: 0 auto; }

.pad { padding: 16px; }

/* ── Type ────────────────────────────────────────────────────────────── */

h2 { font-size: 22px; margin: 4px 0 12px; }
h3 { font-size: 19px; margin: 18px 0 8px; }

.cn { display: block; }
.en { display: block; font-size: 0.78em; opacity: 0.75; font-weight: 400; }

.muted { color: var(--ink-soft); }
.small { font-size: 15px; }
.right { text-align: right; }
.mono { font-variant-numeric: tabular-nums; }
.big-money { font-size: 30px; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ── Home grid ───────────────────────────────────────────────────────── */

.grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.tile {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 4px;
  min-height: 104px;
  padding: 12px 8px;
  font-size: 19px;
  font-weight: 600;
  text-align: center;
  color: var(--ink);
  background: var(--bg);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
}
.tile:active { background: var(--bg-soft); }
.tile .emoji { font-size: 30px; line-height: 1; }

/* Count of things that need attention, on the tile itself. Sized to be
   readable at arm's length by someone who is not looking for it — this is a
   number that has to be noticed without being sought. `position: relative`
   goes on the tile so the badge hangs off its own corner. */
.tile { position: relative; }
.tile .badge {
  position: absolute;
  top: -10px;
  right: -6px;
  min-width: 34px;
  padding: 4px 9px;
  font-size: 18px;
  font-weight: 700;
  line-height: 1.2;
  color: #fff;
  background: var(--danger);
  border: 2px solid var(--bg);
  border-radius: 999px;
}
.tile .badge[hidden] { display: none; }

/* ── Cards and lists ─────────────────────────────────────────────────── */

.card {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
}

.row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  padding: 6px 0;
}
.row + .row { border-top: 1px solid var(--line); }

.list { list-style: none; margin: 0; padding: 0; }

.list-item {
  display: block;
  width: 100%;
  min-height: var(--tap);
  padding: 12px 14px;
  margin-bottom: 8px;
  font-size: 18px;
  text-align: left;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
}
.list-item:active { background: var(--bg-soft); }
.list-item strong { display: block; font-size: 19px; }

/* ── Buttons ─────────────────────────────────────────────────────────── */

.btn {
  display: block;
  width: 100%;
  min-height: var(--tap);
  padding: 14px;
  margin-top: 12px;
  font-size: 20px;
  font-weight: 600;
  font-family: inherit;
  color: var(--brand-ink);
  background: var(--brand);
  border: 0;
  border-radius: var(--radius);
  cursor: pointer;
}
.btn:active { filter: brightness(1.2); }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }

.btn.secondary { color: var(--ink); background: var(--bg); border: 2px solid var(--line); }
.btn.danger { background: var(--danger); }

.btn-row { display: flex; gap: 10px; }
.btn-row .btn { flex: 1; }

.chip-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }

.chip {
  min-width: 62px;
  min-height: 52px;
  padding: 8px 14px;
  font-size: 19px;
  font-family: inherit;
  color: var(--ink);
  background: var(--bg);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
}
.chip[aria-pressed="true"] { color: var(--brand-ink); background: var(--brand); border-color: var(--brand); }

/* ── Forms ───────────────────────────────────────────────────────────── */

label { display: block; margin: 14px 0 6px; font-weight: 600; }

input, select, textarea {
  width: 100%;
  min-height: var(--tap);
  padding: 12px;
  font-size: 19px;
  font-family: inherit;
  color: var(--ink);
  background: var(--bg);
  border: 2px solid var(--line);
  border-radius: var(--radius);
}
input:focus, select:focus, textarea:focus {
  outline: 3px solid var(--brand);
  outline-offset: 1px;
}

/* ── Status lines ────────────────────────────────────────────────────── */

.note {
  display: flex;
  gap: 8px;
  padding: 12px;
  margin: 8px 0;
  border-radius: var(--radius);
  border-left: 6px solid;
}
.note.blocker { color: var(--danger); background: var(--danger-bg); border-color: var(--danger); }
.note.warning { color: var(--warn);   background: var(--warn-bg);   border-color: var(--warn); }
.note.info    { color: var(--ink);    background: var(--bg-soft);   border-color: var(--ink-soft); }
.note.ok      { color: var(--ok);     background: var(--ok-bg);     border-color: var(--ok); }

.pill {
  display: inline-block;
  padding: 3px 10px;
  font-size: 14px;
  font-weight: 600;
  border-radius: 999px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
}
.pill.bad { color: var(--danger); background: var(--danger-bg); border-color: var(--danger); }
.pill.good { color: var(--ok); background: var(--ok-bg); border-color: var(--ok); }

/* Section headings inside a long list — "Overdue", "Today", "Tomorrow".
   The rule above the heading is what stops one pile running into the next
   on a phone, where the whole list is one narrow column. */
.group-heading {
  margin-top: 24px;
  padding-top: 12px;
  border-top: 2px solid var(--line);
  align-items: center;
}
.group-heading h3 { margin: 0; }

/* ── Toast ───────────────────────────────────────────────────────────── */

#toast {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(16px + env(safe-area-inset-bottom));
  z-index: 50;
  padding: 16px;
  font-size: 18px;
  color: #fff;
  background: #1d2733;
  border-radius: var(--radius);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.3);
}
#toast[hidden] { display: none; }
#toast.bad { background: var(--danger); }

.spinner { padding: 30px; text-align: center; color: var(--ink-soft); }

@media (prefers-reduced-motion: no-preference) {
  .list-item, .tile, .btn { transition: background 90ms linear; }
}
