:root {
  --bg: #ffffff;
  --fg: #16181d;
  --muted: #5c6370;
  --line: #e3e6ea;
  --accent: #1f5fd0;
  --accent-fg: #ffffff;
  --soft: #f6f8fa;
  --radius: 10px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14161a;
    --fg: #e8eaed;
    --muted: #9aa2ad;
    --line: #2a2e35;
    --accent: #5b94f0;
    --accent-fg: #0d0f12;
    --soft: #1b1e24;
  }
}

:root[data-theme="dark"] {
  --bg: #14161a;
  --fg: #e8eaed;
  --muted: #9aa2ad;
  --line: #2a2e35;
  --accent: #5b94f0;
  --accent-fg: #0d0f12;
  --soft: #1b1e24;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

.wrap { max-width: 860px; margin: 0 auto; padding: 0 16px; }

header.site {
  border-bottom: 1px solid var(--line);
  padding: 14px 0;
  margin-bottom: 28px;
}
header.site .wrap { display: flex; gap: 20px; align-items: baseline; flex-wrap: wrap; }
header.site a { color: var(--fg); text-decoration: none; }
header.site .brand { font-weight: 700; }
header.site nav { display: flex; gap: 16px; flex-wrap: wrap; }
header.site nav a { color: var(--muted); font-size: 15px; }
header.site nav a:hover, header.site nav a[aria-current="page"] { color: var(--accent); }

h1 { font-size: 30px; line-height: 1.25; margin: 0 0 10px; }
h2 { font-size: 21px; margin: 36px 0 12px; }
.lede { color: var(--muted); margin: 0 0 28px; }

form { margin: 0; }

fieldset {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin: 0 0 18px;
}
legend { font-weight: 600; padding: 0 8px; font-size: 15px; }

.grid { display: grid; gap: 14px; grid-template-columns: 1fr 1fr; }
@media (max-width: 640px) { .grid { grid-template-columns: 1fr; } }

label { display: block; font-size: 14px; color: var(--muted); margin-bottom: 5px; }

input, textarea, select {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--bg);
  color: var(--fg);
  font: inherit;
  font-size: 15px;
}
input:focus, textarea:focus, select:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
  border-color: var(--accent);
}
textarea { resize: vertical; min-height: 76px; }

.tablewrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 15px; }
th {
  text-align: left;
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
  padding: 0 6px 8px;
  white-space: nowrap;
}
td { padding: 4px 6px; vertical-align: middle; }
td input { min-width: 70px; }
.it-desc { min-width: 160px; }
.it-sum { text-align: right; white-space: nowrap; color: var(--muted); }
.it-del {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 6px;
}
.it-del:hover { color: #d33; }

button.secondary {
  background: var(--soft);
  color: var(--fg);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px 14px;
  font: inherit;
  font-size: 14px;
  cursor: pointer;
  margin-top: 10px;
}
button.secondary:hover { border-color: var(--accent); color: var(--accent); }

.totals {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  display: grid;
  gap: 6px;
  justify-content: end;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.totals div { display: grid; grid-template-columns: auto 130px; gap: 18px; }
.totals .grand { font-size: 19px; font-weight: 700; padding-top: 6px; }

.actions { margin: 24px 0 8px; }
button.primary {
  background: var(--accent);
  color: var(--accent-fg);
  border: none;
  border-radius: 8px;
  padding: 13px 26px;
  font: inherit;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}
button.primary:hover { filter: brightness(1.08); }

.hint { font-size: 14px; color: var(--muted); margin: 10px 0 0; }

details {
  border-bottom: 1px solid var(--line);
  padding: 13px 0;
}
details summary { cursor: pointer; font-weight: 600; font-size: 15px; }
details p { color: var(--muted); margin: 10px 0 2px; font-size: 15px; }

.cards { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); margin: 24px 0; }
.card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  text-decoration: none;
  color: var(--fg);
  display: block;
}
.card:hover { border-color: var(--accent); }
.card strong { display: block; margin-bottom: 5px; font-size: 17px; }
.card span { color: var(--muted); font-size: 14px; }

footer.site {
  border-top: 1px solid var(--line);
  margin-top: 56px;
  padding: 22px 0 40px;
  color: var(--muted);
  font-size: 14px;
}
footer.site a { color: var(--muted); }
footer.site p { margin: 0 0 8px; }
