:root {
  --bg: #f6f7f5;
  --card: #ffffff;
  --ink: #23281f;
  --muted: #6b7365;
  --line: #dcdfd6;
  --accent: #4a7c4e;
  --accent-soft: #e8f0e6;
  --warn: #8a5a1a;
  --warn-soft: #fbf1df;
  --alert: #9b2c2c;
  --alert-soft: #fbe9e9;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 1rem;
  padding: 0.9rem 1.2rem;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}

.topbar h1 { font-size: 1.15rem; margin: 0; letter-spacing: 0.02em; }

nav { display: flex; gap: 0.4rem; }

nav button {
  border: 1px solid transparent;
  background: none;
  padding: 0.35rem 0.8rem;
  border-radius: 999px;
  font: inherit;
  color: var(--muted);
  cursor: pointer;
}

nav button.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

main {
  max-width: 46rem;
  margin: 0 auto;
  padding: 1.2rem;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 1rem 1.1rem;
  margin-bottom: 1rem;
}

.card h2 { margin: 0 0 0.6rem; font-size: 1rem; }
.card h3 { margin: 1rem 0 0.4rem; font-size: 0.9rem; color: var(--muted); }

label { display: block; margin-bottom: 0.7rem; font-size: 0.88rem; }
label span { display: block; color: var(--muted); margin-bottom: 0.2rem; }

input, select, textarea {
  width: 100%;
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
  background: #fff;
  color: inherit;
}

textarea { min-height: 5.5rem; resize: vertical; }

.row { display: flex; gap: 0.7rem; flex-wrap: wrap; }
.row > * { flex: 1 1 8rem; }

button.primary, button.secondary, button.ghost {
  font: inherit;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  border: 1px solid var(--line);
}

button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
button.secondary { background: var(--card); color: var(--ink); }
button.ghost { background: none; border-color: transparent; color: var(--muted); padding: 0.3rem 0.5rem; }
button:disabled { opacity: 0.5; cursor: not-allowed; }

.actions { display: flex; gap: 0.6rem; flex-wrap: wrap; margin-top: 0.8rem; }

.hint {
  font-size: 0.82rem;
  color: var(--muted);
  background: var(--accent-soft);
  border-radius: 6px;
  padding: 0.5rem 0.7rem;
}

.note-estimate {
  font-size: 0.82rem;
  color: var(--warn);
  background: var(--warn-soft);
  border-radius: 6px;
  padding: 0.5rem 0.7rem;
  margin-bottom: 0.8rem;
}

.badge {
  display: inline-block;
  font-size: 0.72rem;
  padding: 0.05rem 0.45rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  white-space: nowrap;
}

.badge.estimate { background: var(--warn-soft); color: var(--warn); border-color: #e0c58f; }
.badge.known { background: var(--accent-soft); color: var(--accent); border-color: #b8cdb5; }
.badge.unknown { background: var(--alert-soft); color: var(--alert); border-color: #e0b4b4; }

.item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.7rem 0.8rem;
  margin-bottom: 0.7rem;
}

.item-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}

.item-head strong { font-weight: 600; }

.question {
  font-size: 0.84rem;
  color: var(--warn);
  margin: 0.3rem 0 0.5rem;
}

table { width: 100%; border-collapse: collapse; font-size: 0.86rem; }
th, td { text-align: left; padding: 0.32rem 0.4rem; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 500; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

tr.over-limit td { background: var(--alert-soft); }

.bar {
  height: 6px;
  background: var(--line);
  border-radius: 3px;
  overflow: hidden;
  min-width: 4rem;
}
.bar > i { display: block; height: 100%; background: var(--accent); }
.bar > i.over { background: var(--warn); }

.muted { color: var(--muted); }
.small { font-size: 0.82rem; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 1.2rem;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  padding: 0.55rem 1rem;
  border-radius: 6px;
  font-size: 0.88rem;
  max-width: 90vw;
  z-index: 10;
}
.toast.error { background: var(--alert); }

.footer {
  max-width: 46rem;
  margin: 0 auto;
  padding: 0 1.2rem 2rem;
  font-size: 0.78rem;
  color: var(--muted);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171a15;
    --card: #1f231d;
    --ink: #e6e9e2;
    --muted: #9aa392;
    --line: #333829;
    --accent: #8bbd87;
    --accent-soft: #26301f;
    --warn: #e0b872;
    --warn-soft: #302819;
    --alert: #e08a8a;
    --alert-soft: #331e1e;
  }
  input, select, textarea { background: #171a15; }
  .toast { background: #000; }
}
