:root {
  --paper: #f6f3ec;
  --paper-deep: #efe6d4;
  --ink: #17212b;
  --ink-soft: #5c6b73;
  --forest: #0e3b34;
  --mint: #1f8a70;
  --leaf: #ddf3ea;
  --card: #fffcf8;
  --line: #e4ddd2;
  --amber: #8a5a12;
  --amber-bg: #f8efd8;
  --seal: #8e2416;
  --shadow: 0 12px 32px rgba(23, 33, 43, 0.06);
  --sans: "Be Vietnam Pro", sans-serif;
  --side: 268px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: var(--sans);
  line-height: 1.55;
  min-height: 100vh;
}
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--forest); }
:focus-visible { outline: 2px solid var(--mint); outline-offset: 3px; }
.skip {
  position: absolute;
  left: 12px;
  top: -48px;
  background: var(--ink);
  color: white;
  padding: 8px 12px;
  z-index: 80;
  border-radius: 8px;
}
.skip:focus { top: 12px; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.noscript {
  max-width: 40rem;
  margin: 24px auto;
  padding: 16px;
}

.shell {
  display: grid;
  grid-template-columns: var(--side) 1fr;
  min-height: 100vh;
}
.side {
  background: var(--forest);
  color: var(--paper);
  padding: 22px 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  text-decoration: none;
  color: inherit;
  padding: 0 8px;
}
.brand img {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--paper);
}
.brand span { font-weight: 700; letter-spacing: -0.02em; }
.brand small, .center-name {
  display: block;
  font-weight: 500;
  color: rgba(246, 243, 236, 0.78);
  letter-spacing: 0;
  font-size: 0.82rem;
}
.center-name { padding: 0 8px; margin: -10px 0 0; }
.side nav { display: flex; flex-direction: column; gap: 4px; }
.side nav a {
  color: var(--paper);
  text-decoration: none;
  padding: 10px 12px;
  border-radius: 12px;
  font-weight: 500;
}
.side nav a:hover { background: rgba(246, 243, 236, 0.08); }
.side nav a[aria-current="page"] {
  background: var(--mint);
  color: white;
}
.side-foot {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 12px;
}
.side-foot .btn { width: 100%; }
.side-foot .btn.ghost {
  color: var(--paper);
  border-color: rgba(246, 243, 236, 0.45);
}
.side-foot .btn.soft { background: var(--mint); color: white; }
.mode-chip {
  margin: 0;
  font-size: 0.82rem;
  color: var(--leaf);
  padding: 0 8px;
}
.main { min-width: 0; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 28px 0;
}
.who { margin: 0; color: var(--ink-soft); font-weight: 500; }
.btn.menu-btn { display: none; }
.content { padding: 8px 28px 48px; max-width: 1180px; }
.page-head { margin: 12px 0 18px; }
.page-head h1 { margin: 0 0 8px; font-size: 2rem; letter-spacing: -0.03em; line-height: 1.2; }
.lede { margin: 0; color: var(--ink-soft); max-width: 46rem; }
.banner {
  background: var(--leaf);
  color: var(--forest);
  border-radius: 16px;
  padding: 12px 14px;
  margin: 0 0 18px;
}
.banner strong { font-weight: 700; }
.toast {
  background: white;
  border: 1px solid var(--line);
  border-left: 4px solid var(--mint);
  border-radius: 14px;
  padding: 12px 14px;
  margin: 0 0 16px;
}
.toast[data-kind="error"] { border-left-color: var(--seal); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 16px;
  border-radius: 14px;
  border: 1px solid transparent;
  background: var(--forest);
  color: white;
  font-weight: 700;
  text-decoration: none;
  gap: 8px;
}
.btn.ghost {
  background: transparent;
  color: var(--forest);
  border-color: rgba(14, 59, 52, 0.28);
}
.btn.soft { background: var(--leaf); color: var(--forest); }
.btn.danger { background: var(--seal); }
.btn.small { min-height: 40px; padding: 0 12px; font-size: 0.92rem; white-space: nowrap; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-row, .toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.toolbar { justify-content: space-between; margin-bottom: 14px; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; margin-bottom: 14px; }
.filters .field { margin: 0; min-width: 220px; }
.filters a, .seg a {
  text-decoration: none;
  color: var(--forest);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 12px;
  font-weight: 500;
  min-height: 40px;
  display: inline-flex;
  align-items: center;
}
.filters a[aria-current="true"], .seg a[aria-current="true"] {
  background: var(--forest);
  color: white;
  border-color: var(--forest);
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}
.stat, .panel, .card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}
.stat {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 16px 16px 14px;
  text-decoration: none;
  color: inherit;
  min-height: 148px;
}
.stat:hover { border-color: var(--mint); }
.stat span { color: var(--ink-soft); font-weight: 500; }
.stat strong {
  font-size: 1.7rem;
  letter-spacing: -0.03em;
  color: var(--forest);
  font-variant-numeric: tabular-nums;
}
.stat small { color: var(--ink-soft); }
.stat-go { margin-top: auto; color: var(--mint) !important; font-weight: 700 !important; }
.defs { padding: 16px 18px 6px; margin-bottom: 16px; }
.defs div { display: grid; grid-template-columns: 180px 1fr; gap: 8px 16px; padding: 8px 0 12px; border-top: 1px solid var(--line); }
.defs div:first-child { border-top: 0; }
.defs dt { font-weight: 700; }
.defs dd { margin: 0; color: var(--ink-soft); }
.month-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; margin-bottom: 14px; }
.month-bar label { font-weight: 500; display: flex; flex-direction: column; gap: 6px; }

.panel { padding: 18px; }
.empty { padding: 28px 8px; text-align: center; }
.empty .btn-row { justify-content: center; }
.empty h2 { margin: 0 0 8px; font-size: 1.35rem; }
.empty p { margin: 0 auto 16px; max-width: 36rem; color: var(--ink-soft); }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 18px; background: var(--card); }
table { width: 100%; border-collapse: collapse; min-width: 720px; }
th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 0.86rem; color: var(--ink-soft); font-weight: 700; background: #fbf8f3; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.person { font-weight: 700; }
.muted { color: var(--ink-soft); }
.pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 700;
  background: var(--leaf);
  color: var(--forest);
}
.pill.wait { background: var(--amber-bg); color: var(--amber); }
.pill.lock, .pill.stop { background: #f3e4df; color: var(--seal); }
.pill.transfer { background: #e7f0ee; color: var(--forest); }
.actions-cell { display: flex; flex-wrap: wrap; gap: 6px; }

.field { display: flex; flex-direction: column; gap: 6px; margin: 0 0 14px; font-weight: 500; }
.field input, .field select, .field textarea {
  background: white;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  min-height: 48px;
}
.field textarea { min-height: 140px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid var(--mint); border-color: transparent; }
.field input[aria-invalid="true"], .field select[aria-invalid="true"], .field textarea[aria-invalid="true"] { border-color: var(--seal); }
.hint { color: var(--ink-soft); font-weight: 400; font-size: 0.88rem; }
.field-error { min-height: 1.1em; color: var(--seal); font-weight: 400; font-size: 0.88rem; }
.days { display: flex; flex-wrap: wrap; gap: 8px; border: 0; margin: 0 0 14px; padding: 0; }
.days legend { font-weight: 700; margin-bottom: 8px; }
.days label {
  display: flex;
  gap: 6px;
  align-items: center;
  background: white;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 10px;
  font-weight: 500;
}
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.sheet {
  width: min(560px, calc(100vw - 28px));
  border: 0;
  border-radius: 20px;
  padding: 22px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: var(--shadow);
}
.sheet::backdrop { background: rgba(23, 33, 43, 0.46); }
.sheet h2 { margin: 0 0 8px; font-size: 1.4rem; }
.sheet p { margin: 0 0 14px; }
.sheet .btn-row { justify-content: flex-end; }
.sheet-wide { width: min(760px, calc(100vw - 28px)); }
.preview { width: 100%; min-width: 0; }
.preview td.bad { color: var(--seal); }
.callout {
  background: var(--amber-bg);
  color: var(--amber);
  border-radius: 14px;
  padding: 12px 14px;
  margin: 0 0 14px;
}
.plan-list { margin: 0; padding-left: 18px; }
.plan-list li { margin: 6px 0; }
.sums { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 18px; }
.sum { padding: 14px 16px; }
.sum span { display: block; color: var(--ink-soft); }
.sum strong { display: block; margin-top: 4px; font-size: 1.35rem; color: var(--forest); font-variant-numeric: tabular-nums; }
.section-title { margin: 22px 0 10px; font-size: 1.2rem; }
.note { color: var(--ink-soft); margin: 8px 0 0; }

.gate {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
}
.gate.gate-stack {
  grid-template-columns: 1fr;
  align-content: start;
}
.gate.gate-stack .gate-copy {
  justify-content: flex-start;
  padding: 32px 24px 20px;
}
.gate.gate-stack .gate-copy h1 {
  font-size: clamp(1.8rem, 4vw, 2.4rem);
  line-height: 1.15;
  max-width: 12em;
}
.gate.gate-stack .gate-card {
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  width: min(520px, 100%);
  margin: 0 auto;
  padding: 8px 24px 40px;
}
.gate.gate-stack .gate-card h2 {
  margin: 0 0 8px;
  font-size: 1.45rem;
  line-height: 1.25;
}
.gate.gate-stack .gate-card > p { margin: 0 0 16px; }
.gate-copy {
  background: var(--forest);
  color: var(--paper);
  padding: 48px 56px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.gate-copy h1 { font-size: 2.6rem; line-height: 1.15; letter-spacing: -0.03em; margin: 12px 0; }
.gate-copy p { color: rgba(246, 243, 236, 0.86); max-width: 34rem; }
.gate-brand { display: flex; align-items: center; gap: 12px; font-weight: 700; font-size: 1.2rem; }
.gate-brand img { width: 56px; height: 56px; border-radius: 16px; background: var(--paper); }
.gate-points { padding-left: 18px; }
.gate-points li { margin: 8px 0; }
.gate-card {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 24px;
}
.gate-card form, .public-card {
  width: min(440px, 100%);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 28px 24px;
  box-shadow: var(--shadow);
}
.links { display: flex; gap: 16px; margin-top: 14px; }
.public-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 24px;
}
.public-top .brand { color: var(--ink); }
.public-wrap { max-width: 760px; margin: 0 auto; padding: 12px 24px 48px; }

@media (max-width: 1080px) {
  .stats, .sums { grid-template-columns: 1fr 1fr; }
  .gate { grid-template-columns: 1fr; }
  .gate-copy { padding: 32px 24px; }
  .gate-copy h1 { font-size: 2rem; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side {
    position: fixed;
    z-index: 30;
    transform: translateX(-105%);
    width: min(300px, 88vw);
    transition: transform 0.2s ease;
  }
  .shell.nav-open .side { transform: none; }
  .btn.menu-btn { display: inline-flex; }
  .content, .topbar { padding-left: 16px; padding-right: 16px; }
  .defs div, .two { grid-template-columns: 1fr; }
  .backdrop {
    position: fixed;
    inset: 0;
    background: rgba(23, 33, 43, 0.4);
    z-index: 20;
    border: 0;
    padding: 0;
  }
}
@media (min-width: 861px) {
  .backdrop { display: none !important; }
}
@media (max-width: 640px) {
  .stats, .sums { grid-template-columns: 1fr; }
  table.stack { min-width: 0; }
  table.stack thead { display: none; }
  table.stack tr { display: block; padding: 8px 0; border-bottom: 1px solid var(--line); }
  table.stack td {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    border: 0;
    padding: 6px 12px;
  }
  table.stack td::before { content: attr(data-label); color: var(--ink-soft); font-weight: 500; }
  .sheet .btn-row, .toolbar { align-items: stretch; }
  .sheet .btn, .toolbar .btn { width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  .side { transition: none; }
  html { scroll-behavior: auto; }
}
