:root {
  --bg: #ECE7DD;
  --surface: #F6F2E9;
  --surface-2: #FBF9F3;
  --ink: #2A2823;
  --muted: #6E6A60;
  --line: #D9D2C0;
  --accent: #B7873E;
  --accent-ink: #6B4E23;
  --accent-contrast: #FFFFFF;
  --good: #5E7F49;
  --warn: #B7873E;
  --bad: #A0503F;
  --shadow: 0 1px 2px rgba(30, 25, 15, 0.06), 0 8px 24px -12px rgba(30, 25, 15, 0.18);
  --radius: 12px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1B1917;
    --surface: #232019;
    --surface-2: #292520;
    --ink: #ECE6D8;
    --muted: #A69E8C;
    --line: #3A352C;
    --accent: #D9A855;
    --accent-ink: #F2D8A3;
    --accent-contrast: #201A0E;
    --good: #93BC77;
    --warn: #D9A855;
    --bad: #D98F7C;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 28px -12px rgba(0, 0, 0, 0.55);
  }
}
:root[data-theme="dark"] {
  --bg: #1B1917; --surface: #232019; --surface-2: #292520; --ink: #ECE6D8; --muted: #A69E8C; --line: #3A352C;
  --accent: #D9A855; --accent-ink: #F2D8A3; --accent-contrast: #201A0E;
  --good: #93BC77; --warn: #D9A855; --bad: #D98F7C;
  --shadow: 0 1px 2px rgba(0,0,0,0.3), 0 8px 28px -12px rgba(0,0,0,0.55);
}
:root[data-theme="light"] {
  --bg: #ECE7DD; --surface: #F6F2E9; --surface-2: #FBF9F3; --ink: #2A2823; --muted: #6E6A60; --line: #D9D2C0;
  --accent: #B7873E; --accent-ink: #6B4E23; --accent-contrast: #FFFFFF;
  --good: #5E7F49; --warn: #B7873E; --bad: #A0503F;
  --shadow: 0 1px 2px rgba(30,25,15,0.06), 0 8px 24px -12px rgba(30,25,15,0.18);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
h1, h2, h3 {
  font-family: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, "Noto Serif", serif;
  font-weight: 600;
  text-wrap: balance;
  margin: 0 0 4px;
}
a { color: var(--accent-ink); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 14px clamp(14px, 3vw, 28px);
  background: var(--surface); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.topbar .brand { display: flex; align-items: baseline; gap: 8px; }
.topbar .brand strong { font-family: "Iowan Old Style", Georgia, serif; font-size: 1.05rem; }
.topbar .brand span { font-size: 0.72rem; color: var(--muted); letter-spacing: 0.06em; text-transform: uppercase; }
nav.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
nav.tabs a {
  text-decoration: none; color: var(--muted); font-size: 0.86rem;
  padding: 6px 12px; border-radius: 999px; border: 1px solid transparent;
}
nav.tabs a.active { background: var(--surface-2); border-color: var(--line); color: var(--ink); font-weight: 600; }
nav.tabs a:hover { color: var(--ink); }

main { max-width: 900px; margin: 0 auto; padding: 28px clamp(14px, 3vw, 28px) 60px; display: flex; flex-direction: column; gap: 24px; }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px clamp(14px, 2.5vw, 26px); box-shadow: var(--shadow);
}
.card > header { display: flex; flex-direction: column; gap: 4px; margin-bottom: 14px; }
.card > header p { margin: 0; color: var(--muted); font-size: 0.9rem; }

.eyebrow { font-size: 0.72rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--accent-ink); font-weight: 700; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 0.86rem; font-weight: 600; }
.field .hint { font-size: 0.78rem; color: var(--muted); }
.field input[type="text"], .field input[type="date"], .field input[type="time"], .field input[type="number"],
.field input[type="password"], .field select, .field textarea {
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px;
  padding: 9px 11px; color: var(--ink); width: 100%;
}
.field textarea { min-height: 64px; resize: vertical; font-family: inherit; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--accent); color: var(--accent-contrast); border: none; border-radius: 9px;
  padding: 10px 18px; font-weight: 700; font-size: 0.92rem; cursor: pointer;
}
.btn:hover { filter: brightness(1.05); }
.btn.secondary { background: var(--surface-2); color: var(--ink); border: 1px solid var(--line); }
.btn.danger { background: var(--bad); color: #fff; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
table th, table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); }
table th { color: var(--muted); font-weight: 600; font-size: 0.76rem; text-transform: uppercase; letter-spacing: 0.04em; }
.table-wrap { overflow-x: auto; }
.num { font-variant-numeric: tabular-nums; }

.pill { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px; font-size: 0.76rem; font-weight: 600; }
.pill.good { background: color-mix(in srgb, var(--good) 18%, transparent); color: var(--good); }
.pill.warn { background: color-mix(in srgb, var(--warn) 20%, transparent); color: var(--accent-ink); }
.pill.bad { background: color-mix(in srgb, var(--bad) 18%, transparent); color: var(--bad); }
.pill.muted { background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }

.section-title { font-size: 1.05rem; font-weight: 700; margin: 22px 0 10px; padding-top: 14px; border-top: 1px solid var(--line); }
.section-title:first-child { border-top: none; padding-top: 0; margin-top: 0; }

.empty { color: var(--muted); font-size: 0.88rem; padding: 10px 0; }

.stack { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row.between { justify-content: space-between; }

.list-item {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 12px;
  padding: 12px 0; border-bottom: 1px solid var(--line);
}
.list-item:last-child { border-bottom: none; }
.list-item .meta { font-size: 0.78rem; color: var(--muted); }

.banner { border-radius: 9px; padding: 10px 14px; font-size: 0.86rem; }
.banner.warn { background: color-mix(in srgb, var(--warn) 14%, var(--surface)); border: 1px solid var(--warn); color: var(--accent-ink); }
.banner.bad { background: color-mix(in srgb, var(--bad) 14%, var(--surface)); border: 1px solid var(--bad); color: var(--bad); }

.center-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.center-page .card { max-width: 380px; width: 100%; }

::-webkit-scrollbar { height: 8px; width: 8px; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }
