:root {
  --paper: #f3efe6;
  --paper-2: #fffdf8;
  --ink: #241c16;
  --muted: #6d6258;
  --line: #e3d8c8;
  --pine: #1c3f38;
  --pine-2: #2f6a5d;
  --seal: #8d2e2e;
  --gold: #8d6b32;
  --amber: #f8efd8;
  --amber-2: #f4e3cc;
  --good: #e7f2ec;
  --shadow: 0 16px 40px rgba(48, 32, 16, 0.06);
  --serif: "Shippori Mincho", "Yu Mincho", "Hiragino Mincho ProN", serif;
  --sans: "Zen Kaku Gothic New", "Yu Gothic", "Hiragino Sans", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(141, 107, 50, 0.08), transparent 32%),
    var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }

.site-header {
  display: flex;
  align-items: center;
  gap: 28px;
  padding: 18px 28px;
  background: var(--pine);
  color: #f6f1e7;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  margin-right: auto;
}
.brand strong {
  display: block;
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: 0.04em;
}
.brand small { display: block; color: rgba(246, 241, 231, 0.72); font-size: 12px; }
.seal {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 2px solid #e7c2c2;
  border-radius: 50%;
  color: #f0d2d2;
  font-family: var(--serif);
  font-size: 20px;
}
.global-nav { display: flex; gap: 8px; }
.global-nav a {
  text-decoration: none;
  padding: 8px 14px;
  border-radius: 999px;
  color: rgba(246, 241, 231, 0.8);
}
.global-nav a.active { background: rgba(255, 253, 248, 0.14); color: white; }
.nav-menu { position: relative; display: flex; align-items: center; }
.nav-sub {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 11em;
  padding: 8px;
  background: #14312c;
  border-radius: 14px;
  box-shadow: var(--shadow);
  z-index: 5;
}
.nav-menu:hover .nav-sub,
.nav-menu:focus-within .nav-sub { display: grid; }
.nav-sub a { border-radius: 10px; }
.nav-sub a.active,
.nav-sub a:hover { background: rgba(255, 253, 248, 0.14); color: white; }
.unit-switch {
  display: flex;
  padding: 3px;
  border-radius: 999px;
  background: rgba(255, 253, 248, 0.1);
}
.unit-switch button {
  border: 0;
  background: transparent;
  color: rgba(246, 241, 231, 0.75);
  border-radius: 999px;
  padding: 6px 12px;
}
.unit-switch button.active { background: var(--paper-2); color: var(--pine); }
.account {
  display: flex;
  align-items: center;
  gap: 10px;
  color: rgba(246, 241, 231, 0.9);
  font-size: 14px;
}
.account span { max-width: 12em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account button {
  border: 1px solid rgba(246, 241, 231, 0.35);
  background: transparent;
  color: #f6f1e7;
  border-radius: 999px;
  padding: 6px 12px;
}
[hidden] { display: none !important; }
.auth-wrap { display: grid; place-items: center; min-height: 62vh; }
.auth-card { width: min(440px, 100%); padding: 28px; }
.auth-card h1 { font-size: 30px; }
.auth-card .button, .google-button { width: 100%; margin-top: 8px; }
.google-button { background: white; color: var(--ink); border: 1px solid var(--line); }
.google-button:disabled { opacity: 0.65; cursor: not-allowed; }
.auth-switch {
  display: block;
  margin: 14px auto 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--pine-2);
  text-decoration: underline;
}
.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
  margin: 18px 0 8px;
}
.auth-divider::before, .auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; word-break: break-all; }

#app { width: min(1180px, calc(100% - 32px)); margin: 28px auto 48px; }
.site-footer {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto 32px;
  color: var(--muted);
  font-size: 12px;
}

.page-head, .row-between { display: flex; justify-content: space-between; gap: 16px; align-items: flex-end; }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; letter-spacing: 0.03em; }
h1 { font-size: 34px; margin: 0 0 6px; }
h2 { font-size: 26px; margin: 0 0 8px; }
h3 { font-size: 20px; margin: 0 0 8px; }
.lead { margin: 0; color: var(--muted); }

.card, .panel {
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; margin-top: 22px; }
.case-card, .regime-card { padding: 20px; display: flex; flex-direction: column; gap: 8px; text-decoration: none; }
.case-card strong, .regime-card strong { font-size: 20px; font-family: var(--serif); }
.meta { color: var(--muted); font-size: 13px; }
.payable { font-variant-numeric: tabular-nums; font-size: 28px; font-weight: 700; color: var(--seal); }
.payable span { font-size: 13px; font-weight: 500; color: var(--muted); margin-right: 6px; }

.button, .button-ghost, .button-seal {
  border-radius: 999px;
  padding: 10px 16px;
  border: 1px solid transparent;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
  flex-shrink: 0;
}
.button { background: var(--pine); color: white; }
.button-seal { background: var(--seal); color: white; }
.button-ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.button:disabled { opacity: 0.6; cursor: wait; }

.tabs { display: flex; gap: 6px; margin: 18px 0; overflow-x: auto; }
.tabs a {
  text-decoration: none;
  padding: 8px 14px;
  border-radius: 999px;
  color: var(--muted);
  white-space: nowrap;
}
.tabs a.active { background: var(--pine); color: white; }

.panel { padding: 22px; margin-top: 8px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 12px; }
input[type="text"], input[type="email"], input[type="password"], input[type="date"], input[type="number"], input.money, select, textarea {
  width: 100%;
  margin-top: 4px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fff;
}
textarea { min-height: 88px; resize: vertical; }
.checks { display: flex; flex-wrap: wrap; gap: 12px 18px; margin: 8px 0 12px; }
.checks label { display: flex; align-items: center; gap: 6px; margin: 0; color: var(--ink); }
.checks input { width: auto; margin: 0; }

.member, .asset {
  border-top: 1px solid var(--line);
  padding: 16px 0;
}
.member-head, .asset { display: grid; grid-template-columns: 160px 1fr auto; gap: 12px; align-items: end; }
.member-head { margin-bottom: 8px; }

.hint {
  background: var(--amber);
  border-radius: 14px;
  padding: 12px 14px;
  color: #5c4520;
  font-size: 14px;
}
.banner {
  border-radius: 14px;
  padding: 12px 14px;
  margin-bottom: 14px;
}
.banner.error { background: #fdecec; color: #7a2424; }
.banner.ok { background: var(--good); color: #1d4a3c; }
.banner.warn { background: var(--amber); color: #5c4520; }

.actionbar {
  position: sticky;
  bottom: 12px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
  padding: 12px;
  background: rgba(255, 253, 248, 0.92);
  border: 1px solid var(--line);
  border-radius: 16px;
  backdrop-filter: blur(8px);
}

.table-wrap { overflow-x: auto; margin-top: 12px; }
.table-wrap a { color: var(--pine-2); }
.readonly input,
.readonly select,
.readonly textarea,
.readonly button:not([data-action="print"]) { pointer-events: none; }
.readonly input,
.readonly select,
.readonly textarea { background: #f7f4ee; }
table { border-collapse: collapse; width: 100%; }
th, td { border-bottom: 1px solid var(--line); padding: 8px; text-align: left; vertical-align: top; font-variant-numeric: tabular-nums; }
th { font-size: 12px; color: var(--muted); font-weight: 500; }
.remit { min-width: 980px; }
.remit th, .remit td { min-width: 132px; }
.remit td:first-child, .remit th:first-child {
  position: sticky;
  left: 0;
  background: var(--paper-2);
  min-width: 140px;
  z-index: 1;
}
.remit input { padding: 7px 8px; border-radius: 8px; }
.cell.full { background: var(--amber); }
.cell.extension { background: var(--amber-2); }
.cell-note { display: block; min-height: 1.2em; font-size: 12px; color: var(--seal); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--muted); margin-top: 8px; }
.swatch { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 4px; vertical-align: -1px; border: 1px solid var(--line); }
.swatch.full { background: var(--amber); }
.swatch.extension { background: var(--amber-2); }

.metrics { display: grid; grid-template-columns: 1.4fr repeat(4, 1fr); gap: 12px; margin: 16px 0; }
.metric { padding: 16px; }
.metric b { display: block; font-size: 24px; font-variant-numeric: tabular-nums; }
.metric.hero { background: var(--pine); color: white; }
.metric.hero span, .metric span { color: var(--muted); font-size: 12px; }
.metric.hero span { color: rgba(255, 253, 248, 0.72); }
.steps { display: grid; gap: 14px; }
.step { padding-top: 8px; }
.step ol { margin: 8px 0 0; padding: 0; list-style: none; }
.step li { display: flex; justify-content: space-between; gap: 16px; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.step li.strong { font-weight: 700; }
.banner ul { margin: 0; padding-left: 1.2em; }
.person-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.person { padding: 16px; }
.person .payable { font-size: 24px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0 16px; }
.compare { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 12px 0; }
.compare article { padding: 16px; }

.bracket-row, .inline-actions { display: flex; gap: 8px; align-items: end; }
.bracket-row label { flex: 1; }
.section-gap { margin-top: 22px; }
.rule {
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  margin: 12px 0 16px;
}
.rule p { margin: 0 0 8px; }
.rule p:last-child { margin-bottom: 0; }
.housing { border-top: 1px solid var(--line); padding: 16px 0; }
.check-stack { display: grid; gap: 8px; margin-top: 8px; }
.check-stack label { display: flex; align-items: flex-start; gap: 8px; margin: 0; }
.check-stack input { width: auto; margin-top: 4px; }
.housing-results { display: grid; gap: 12px; }
.housing-result { padding: 16px; }
.housing-result p { margin: 6px 0; }
.housing-result ul { margin: 8px 0 0; padding-left: 1.2em; }
.version-card, .version-detail { padding: 16px; }
.version-card p, .version-detail p { margin: 6px 0; }
.row-between { display: flex; justify-content: space-between; gap: 12px; align-items: center; }

@media (max-width: 860px) {
  .site-header { flex-wrap: wrap; padding: 14px; width: 100%; }
  .page-head { flex-wrap: wrap; align-items: flex-start; }
  .grid-2, .grid-3, .metrics, .person-grid, .compare, .member-head, .asset { grid-template-columns: 1fr; }
  h1 { font-size: 28px; }
  .metrics { grid-template-columns: 1fr 1fr; }
  .step li { flex-wrap: wrap; }
}

@media print {
  .site-header, .site-footer, .actionbar, .tabs, .global-nav, .unit-switch, .account { display: none !important; }
  body { background: white; }
  #app { width: auto; margin: 0; }
  .panel, .card { box-shadow: none; }
}
