:root {
  --accent: #ad5a2c;
  --accent-ink: #ffffff;
  --accent-soft: #fbeee7;
  --ink: #263241;
  --muted: #6b7689;
  --line: #e3e6ec;
  --bg: #f4f5f7;
  --card: #ffffff;
  --ok: #1f7a4d;
  --ok-soft: #e6f4ec;
  --bad: #a3322a;
  --bad-soft: #fbe9e7;
  --done: #3b5b7a;
  --done-soft: #e8eef5;
  --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #e7eaf0;
    --muted: #9aa4b5;
    --line: #2c3442;
    --bg: #141a23;
    --card: #1b2230;
    --accent-soft: #3a2a20;
    --ok-soft: #173424;
    --bad-soft: #3a1f1c;
    --done-soft: #1f2d3d;
  }
}
:root[data-theme="dark"] {
  --ink: #e7eaf0;
  --muted: #9aa4b5;
  --line: #2c3442;
  --bg: #141a23;
  --card: #1b2230;
  --accent-soft: #3a2a20;
  --ok-soft: #173424;
  --bad-soft: #3a1f1c;
  --done-soft: #1f2d3d;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
h1, h2, h3 { margin: 0 0 6px; line-height: 1.2; }
h1 { font-size: 30px; }
h2 { font-size: 20px; }
h3 { font-size: 16px; }
p { margin: 0 0 10px; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.loading { padding: 40px; color: var(--muted); }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
}
.note {
  background: var(--accent-soft);
  border-left: 3px solid var(--accent);
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 13px;
  margin-top: 12px;
}
.err { color: var(--bad); min-height: 1.2em; font-size: 14px; }

/* header and layout */
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px 24px; background: var(--card); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
}
.brand { display: flex; flex-direction: column; }
.brand b { font-size: 20px; }
.brand b span { color: var(--accent); }
.brand small { color: var(--muted); font-size: 11px; letter-spacing: .04em; }
.top-right { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.who { font-weight: 600; font-size: 14px; }
.layout { display: grid; grid-template-columns: 220px 1fr; min-height: calc(100vh - 62px); }
.side {
  background: var(--card); border-right: 1px solid var(--line); padding: 18px 12px;
  display: flex; flex-direction: column; gap: 4px;
}
.side-label { color: var(--muted); font-size: 11px; letter-spacing: .08em; padding: 0 10px 6px; }
.nav {
  color: var(--ink); padding: 9px 12px; border-radius: 8px; font-size: 14px;
  display: flex; align-items: center; gap: 10px;
}
.nav::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--line); }
.nav:hover { background: var(--bg); text-decoration: none; }
.nav.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav.on::before { background: var(--accent); }
.side-foot { margin-top: auto; padding: 14px 10px 0; border-top: 1px solid var(--line); font-size: 13px; display: flex; flex-direction: column; gap: 2px; }
.main { padding: 26px 30px 60px; min-width: 0; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head p { color: var(--muted); margin: 0; }
.grid-2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 18px; align-items: start; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.stack { display: flex; flex-direction: column; gap: 18px; }
.kpi .label { color: var(--muted); font-size: 13px; }
.kpi .value { font-size: 26px; font-weight: 700; margin: 4px 0; }

/* controls */
.btn {
  appearance: none; border: 1px solid var(--line); background: var(--card); color: var(--ink);
  padding: 9px 16px; border-radius: 8px; font: inherit; font-weight: 600; cursor: pointer;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.05); }
.btn.danger { color: var(--bad); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--accent); padding-left: 8px; padding-right: 8px; }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--ink); margin-bottom: 12px; }
input, select, textarea {
  font: inherit; font-weight: 400; color: var(--ink); background: var(--card);
  border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
textarea { min-height: 84px; resize: vertical; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 14px; }
.actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; margin-top: 8px; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* tables and pills */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; color: var(--muted); font-size: 12px; font-weight: 600; padding: 8px 10px; background: var(--bg); }
td { padding: 11px 10px; border-top: 1px solid var(--line); vertical-align: top; }
td.num, th.num { text-align: right; white-space: nowrap; }
.pill { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--bg); color: var(--muted); white-space: nowrap; }
.pill.warn { background: var(--accent-soft); color: var(--accent); }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.done { background: var(--done-soft); color: var(--done); }
.bar { height: 10px; background: var(--bg); border-radius: 6px; overflow: hidden; border: 1px solid var(--line); }
.bar > span { display: block; height: 100%; background: var(--accent); }
.kv { display: grid; grid-template-columns: 150px 1fr; gap: 8px 14px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.timeline { list-style: none; padding: 0; margin: 0; font-size: 13px; }
.timeline li { padding: 8px 0; border-top: 1px solid var(--line); }
.totals { margin-left: auto; min-width: 260px; font-size: 14px; }
.totals div { display: flex; justify-content: space-between; padding: 4px 0; }
.totals .grand { font-size: 20px; font-weight: 700; border-top: 1px solid var(--line); margin-top: 6px; padding-top: 8px; }
.steps { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.step { padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); color: var(--muted); font-weight: 600; font-size: 13px; }
.step.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.empty { color: var(--muted); padding: 22px; text-align: center; }
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; max-width: 980px; width: 100%; }
.login-grid .card { min-height: 420px; }
.eyebrow { color: var(--accent); font-weight: 700; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; }
.hero h1 { font-size: 34px; margin-top: 12px; }
.lede { color: var(--muted); font-size: 16px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin: 16px 0; }
.chip { background: var(--bg); border: 1px solid var(--line); padding: 5px 10px; border-radius: 999px; font-size: 13px; color: var(--muted); }
.form h2 { margin-bottom: 4px; }
.form form { margin-top: 18px; }
.upload-box { border: 1px dashed var(--line); border-radius: 8px; padding: 14px; background: var(--bg); margin-bottom: 12px; }
.sum-list { font-size: 14px; }
.sum-list div { display: flex; justify-content: space-between; padding: 5px 0; border-bottom: 1px dashed var(--line); }
#toast {
  position: fixed; bottom: 22px; right: 22px; max-width: 420px; background: var(--ink); color: var(--card);
  padding: 12px 16px; border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.2);
  opacity: 0; transform: translateY(8px); transition: .2s; pointer-events: none; font-size: 14px;
}
#toast.show { opacity: 1; transform: none; }
#toast.bad { background: var(--bad); }

/* phone width: no horizontal scroll, 16px gutter */
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .side { flex-direction: row; flex-wrap: wrap; border-right: none; border-bottom: 1px solid var(--line); padding: 10px 12px; }
  .side-label, .side-foot { display: none; }
  .nav { padding: 7px 10px; font-size: 13px; }
  .main { padding: 18px 16px 48px; }
  .grid-2, .grid-3, .login-grid { grid-template-columns: 1fr; }
  .row, .row3 { grid-template-columns: 1fr; }
  .top { padding: 12px 16px; }
  .hero h1 { font-size: 26px; }
  .kv { grid-template-columns: 1fr; }
  table { display: block; overflow-x: auto; }
}
