:root {
  --bg: #faf7f2;
  --card: #ffffff;
  --ink: #2b2b2b;
  --muted: #7a7a72;
  --line: #e7e1d8;
  --accent: #b5643c;        /* warm terracotta */
  --accent-soft: #f0e0d6;
  --confirmed: #3f7a5a;
  --proposed: #c8923a;
  --danger: #b23b3b;
  --radius: 14px;
  --pad: 16px;
}

* { box-sizing: border-box; }

/* The `hidden` attribute must win over component display rules. Without this,
   `.gate { display: grid }` (and any future `display:` on a toggled element)
   overrides `[hidden]`'s display:none, leaving the gate visible over the board
   after login. */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  -webkit-text-size-adjust: 100%;
}

h1 { font-size: 1.3rem; margin: 0; }
h2 { font-size: 1.05rem; margin: 0 0 12px; }
.muted { color: var(--muted); font-weight: normal; font-size: 0.85em; }

/* Gate */
.gate {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: var(--pad);
}
.gate .card { width: 100%; max-width: 360px; text-align: center; }
input, button {
  font: inherit;
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  margin-top: 10px;
}
button {
  background: var(--accent);
  color: #fff;
  border: none;
  cursor: pointer;
  font-weight: 600;
}
button:active { transform: translateY(1px); }
button.ghost { background: none; color: var(--ink); border: 1px solid var(--line); width: auto; padding: 6px 12px; margin: 0; }
button.secondary { background: var(--accent-soft); color: var(--accent); }
button.danger { background: none; color: var(--danger); border: 1px solid var(--line); }
.error { color: var(--danger); font-size: 0.9rem; }

/* Layout */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(var(--pad) + env(safe-area-inset-top)) var(--pad) var(--pad);
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.panel { padding: var(--pad); }
.card, .panel .item {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--pad);
}

/* Balance bars */
.balance { display: grid; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 7.5rem 1fr; gap: 8px; align-items: center; }
.bar-label { font-size: 0.85rem; }
.bar-track { position: relative; height: 18px; background: var(--accent-soft); border-radius: 9px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--accent); border-radius: 9px; }
.bar-target { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--ink); opacity: 0.5; }
.bar-num { font-size: 0.78rem; color: var(--muted); }

/* Calendar */
.legend { margin: -4px 0 12px; }
.chip { font-size: 0.72rem; padding: 2px 8px; border-radius: 999px; }
.chip.confirmed { background: var(--confirmed); color: #fff; }
.chip.proposed { background: transparent; color: var(--proposed); border: 1px dashed var(--proposed); }
.calendar { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.cal-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; }
.cal-item.proposed { border-style: dashed; }
.cal-date { font-variant-numeric: tabular-nums; font-weight: 600; min-width: 5.5rem; }
.cal-title { flex: 1; }

/* Pipeline */
.pipeline { display: grid; gap: 16px; }
.column h3 { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); margin: 0 0 8px; }
.column .items { display: grid; gap: 10px; }
.item .title { font-weight: 600; }
.item .meta { font-size: 0.8rem; color: var(--muted); margin: 2px 0 8px; }
.item .actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.item .actions input[type=date] { width: auto; margin: 0; padding: 8px; }
.item .actions button { width: auto; padding: 8px 12px; }
.item a { color: var(--accent); }
.empty { color: var(--muted); font-size: 0.85rem; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 999px;
  font-size: 0.9rem; max-width: 90%;
}

/* Wider screens: pipeline becomes columns */
@media (min-width: 720px) {
  .pipeline { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); align-items: start; }
  .panel, .topbar { max-width: 1100px; margin-inline: auto; }
}
