:root {
  --ink: #1c2430;
  --muted: #5c6570;
  --paper: #f3efe7;
  --card: #fffcf7;
  --line: #e3d9cc;
  --nav: #161d27;
  --nav-ink: #e7e1d6;
  --accent: #0c6b58;
  --accent-soft: #e5f3ef;
  --banner: #f4e2c4;
  --banner-ink: #6a3d09;
  --bad: #8d2f2f;
  --bad-soft: #f8e8e6;
  --shadow: 0 1px 0 rgba(28, 36, 48, 0.04);
  --sans: "Segoe UI", Candara, "Helvetica Neue", Arial, sans-serif;
  --serif: "Iowan Old Style", Palatino, "Palatino Linotype", Georgia, serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--sans);
  color: var(--ink);
  background: var(--paper);
  font-size: 15px;
  line-height: 1.45;
}
button, input, select { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.banner {
  background: var(--banner);
  color: var(--banner-ink);
  padding: 0.55rem 1.25rem;
  font-size: 0.82rem;
  letter-spacing: 0.01em;
  border-bottom: 1px solid #e2c48a;
}
.app { display: flex; min-height: calc(100vh - 2.4rem); }
.nav {
  width: 228px;
  flex: none;
  background: var(--nav);
  color: var(--nav-ink);
  padding: 1.25rem 0.9rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.brand {
  font-family: var(--serif);
  color: white;
  font-size: 1.35rem;
  letter-spacing: -0.02em;
  text-decoration: none;
  padding: 0 0.45rem;
}
.brand:hover { text-decoration: none; }
.brand-sub {
  margin: 0.15rem 0 0.9rem;
  padding: 0 0.45rem;
  color: #b7c0cb;
  font-size: 0.75rem;
}
.nav a.item {
  color: var(--nav-ink);
  padding: 0.42rem 0.55rem;
  border-radius: 6px;
  text-decoration: none;
}
.nav a.item:hover { background: rgba(255,255,255,0.06); text-decoration: none; }
.nav a.item.on { background: rgba(255,255,255,0.12); color: white; }
.nav .spacer { flex: 1; }
.logout { margin: 0.8rem 0.35rem 0; }
.logout button, .btn, button.btn {
  background: var(--accent);
  color: white;
  border: 0;
  border-radius: 6px;
  padding: 0.45rem 0.75rem;
  cursor: pointer;
}
.logout button { background: transparent; color: #c5d0da; padding: 0.3rem 0.2rem; }
.btn.secondary, button.secondary {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}
.btn.ghost { background: transparent; color: var(--accent); border: 1px solid var(--accent); }

main { flex: 1; padding: 1.4rem 1.6rem 3rem; min-width: 0; max-width: 100%; }
h1 {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.85rem;
  margin: 0 0 0.25rem;
  letter-spacing: -0.02em;
}
.lede { color: var(--muted); margin: 0 0 1.1rem; max-width: 62rem; }
h2 {
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 1.4rem 0 0.55rem;
  font-weight: 650;
}

.kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.7rem;
}
.kpi {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.75rem 0.85rem 0.7rem;
  box-shadow: var(--shadow);
}
.kpi .label { color: var(--muted); font-size: 0.75rem; letter-spacing: 0.02em; }
.kpi .value {
  font-variant-numeric: tabular-nums;
  font-size: 1.22rem;
  font-weight: 650;
  margin-top: 0.15rem;
  letter-spacing: -0.02em;
  white-space: nowrap;
}
.kpi .hint { color: var(--muted); font-size: 0.75rem; margin-top: 0.15rem; }

.grid-2 { display: grid; grid-template-columns: 1.1fr 0.9fr; gap: 0.9rem; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.9rem 1rem 1rem;
  box-shadow: var(--shadow);
}
.card h2 { margin-top: 0; }

.bar-row { display: grid; grid-template-columns: 7.5rem 1fr 6.5rem; gap: 0.55rem; align-items: center; margin: 0.35rem 0; }
.bar-track { background: #efe8dc; border-radius: 99px; height: 0.55rem; overflow: hidden; }
.bar-fill { background: var(--accent); height: 100%; border-radius: 99px; }
.bar-fill.alt { background: #b4532a; }
.bar-val { text-align: right; font-variant-numeric: tabular-nums; font-size: 0.85rem; }

.table-wrap { overflow-x: auto; max-width: 100%; border: 1px solid var(--line); border-radius: 10px; background: var(--card); }
table { border-collapse: collapse; width: 100%; }
table.tri {
  width: 100%;
  table-layout: fixed;
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
}
table.tri th, table.tri td { padding: 0.28rem 0.12rem; overflow: hidden; }
table.tri th.sticky, table.tri td.sticky { width: 5.8rem; }
table.tri.months th.sticky, table.tri.months td.sticky { width: 8.4rem; white-space: nowrap; }
table.tri th.sticky, table.tri td.sticky {
  position: sticky;
  left: 0;
  z-index: 1;
  background: var(--card);
  box-shadow: 1px 0 0 var(--line);
}
table.tri th.sticky { z-index: 2; background: #f7f3ec; }
table.prose td:nth-child(3) { white-space: normal; min-width: 18rem; max-width: 42rem; }
td input { width: 7.5rem; max-width: 100%; }
th, td { padding: 0.42rem 0.65rem; border-bottom: 1px solid var(--line); vertical-align: top; }
td:first-child { white-space: nowrap; }
th {
  text-align: left;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 650;
  background: #f7f3ec;
  white-space: nowrap;
}
th.num, td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #fbf8f3; }
tr.total td { font-weight: 650; background: #f7f3ec; }
tr.mark td { background: var(--accent-soft); }
.pill {
  display: inline-block;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  padding: 0.12rem 0.4rem;
  border-radius: 99px;
  font-weight: 650;
}
.pill.ok { background: var(--accent-soft); color: var(--accent); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }

.notice, .error {
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 8px;
  padding: 0.45rem 0.7rem;
  margin: 0 0 0.8rem;
}
.error { background: var(--bad-soft); color: var(--bad); }

form.stack { display: grid; gap: 0.9rem; }
fieldset {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  margin: 0;
  padding: 0.8rem 0.9rem 0.9rem;
  min-width: 0;
  max-width: 100%;
}
legend { padding: 0 0.35rem; font-weight: 650; }
.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 0.65rem 0.8rem; }
label.field { display: flex; flex-direction: column; gap: 0.2rem; font-size: 0.78rem; color: var(--muted); }
label.field input, label.field select {
  border: 1px solid var(--line);
  background: white;
  border-radius: 6px;
  padding: 0.38rem 0.45rem;
  color: var(--ink);
}
label.field input:focus { outline: 2px solid #b7ddd3; border-color: var(--accent); }
.inline { display: flex; gap: 0.8rem; align-items: center; flex-wrap: wrap; }
.choice { display: flex; gap: 0.4rem; align-items: center; background: white; border: 1px solid var(--line); border-radius: 8px; padding: 0.45rem 0.6rem; }
.actions { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.footnote { color: var(--muted); font-size: 0.8rem; }

.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 2rem 1rem; }
.login-card { width: min(420px, 100%); background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 1.4rem 1.3rem 1.2rem; }
.login-card h1 { font-size: 1.7rem; }
.login-card form { display: grid; gap: 0.7rem; margin-top: 0.6rem; }

@media (max-width: 960px) {
  .app { flex-direction: column; }
  .nav { width: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 0.2rem 0.15rem; padding: 0.7rem; }
  .brand-sub, .nav .spacer { display: none; }
  .logout { margin: 0 0 0 auto; }
  .kpis, .grid-2 { grid-template-columns: 1fr 1fr; }
  main { padding: 1rem; }
}
@media (max-width: 640px) {
  .kpis { grid-template-columns: 1fr; }
  .bar-row { grid-template-columns: 5.5rem 1fr 5.2rem; }
}
