:root {
  --ink: #1f2937; --muted: #6b7280; --line: #e5e7eb; --bg: #f6f7fb; --card: #fff;
  --brand: #14375f; --accent: #2c3e7a; --bad: #b42318; --good: #067647;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Arial, sans-serif; }
main { max-width: 900px; margin: 0 auto; padding: 24px 16px 48px; }
header { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 16px; }
h1 { margin: 0; font-size: 26px; color: var(--brand); }
nav a { color: var(--muted); margin-left: 12px; text-decoration: none; font-size: 13px; }
nav a.on { color: var(--brand); font-weight: 600; }
fieldset { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 16px; margin: 0 0 16px;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px 16px; }
legend { font-weight: 600; color: var(--accent); padding: 0 6px; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
label.wide, fieldset > .scroll, fieldset > #addLine { grid-column: 1 / -1; }
input, textarea { font: inherit; color: var(--ink); border: 1px solid #d0d5dd; border-radius: 6px; padding: 8px 10px; background: #fff; width: 100%; }
input:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 620px; }
th { text-align: left; font-size: 12px; color: var(--accent); padding: 6px; border-bottom: 1px solid var(--line); }
td { padding: 6px; vertical-align: top; }
td.num, th.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
td input { padding: 6px 8px; }
td:nth-child(1) { width: 90px; } td:nth-child(3) { width: 80px; } td:nth-child(4) { width: 120px; }
button { font: inherit; border: 0; border-radius: 6px; padding: 10px 16px; background: var(--brand); color: #fff; cursor: pointer; }
button.ghost { background: #fff; color: var(--brand); border: 1px solid #d0d5dd; justify-self: start; }
button.x { background: none; color: var(--muted); padding: 4px 8px; }
button:disabled { opacity: .6; cursor: wait; }
.totals dl { margin: 0; display: grid; grid-template-columns: auto auto; gap: 6px 16px; align-self: end; justify-content: end; font-variant-numeric: tabular-nums; }
.totals dd { margin: 0; text-align: right; }
.grand { font-weight: 700; color: var(--brand); font-size: 18px; }
.actions { display: flex; gap: 12px; justify-content: flex-end; flex-wrap: wrap; }
.hint { color: var(--muted); font-size: 12px; }
.msg { min-height: 1.4em; }
.msg.bad { color: var(--bad); } .msg.good { color: var(--good); }
#gate .gatebox { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 20px; display: grid; gap: 12px; max-width: 420px; }
a.btn { display: inline-block; background: var(--brand); color: #fff; text-decoration: none; border-radius: 6px; padding: 10px 16px; justify-self: start; }
.who { margin: 0; width: 100%; font-size: 13px; color: var(--muted); }
button.link { background: none; color: var(--accent); padding: 0 4px; text-decoration: underline; }
button.small { padding: 4px 10px; font-size: 13px; }
#history h2 { font-size: 18px; color: var(--accent); margin: 24px 0 8px; }
#history table { min-width: 720px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; }
#history td { font-size: 13px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
#templates h2 { font-size: 18px; color: var(--accent); margin: 24px 0 8px; }
#templates table { min-width: 720px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; }
#templates td { font-size: 13px; }
#templates select { font: inherit; padding: 4px 6px; border: 1px solid #d0d5dd; border-radius: 6px; background: #fff; }
#templates .acts { display: flex; gap: 6px; flex-wrap: wrap; }
#templates .err { color: var(--bad); font-size: 12px; }
#templates details { margin-top: 8px; } #templates summary { cursor: pointer; }
#templates code { background: #eef0f5; padding: 1px 4px; border-radius: 4px; }
.actions.left { justify-content: flex-start; align-items: center; }
.tpl-on td:first-child { font-weight: 600; }
.banner { width: 100%; margin: 0; background: #fff4e5; border: 1px solid #f0c27a; color: #7a4a00; border-radius: 8px; padding: 8px 12px; font-size: 13px; }
#viewAs { font: inherit; font-size: 13px; padding: 2px 6px; border: 1px solid #d0d5dd; border-radius: 6px; background: #fff; }
body[data-form="upproj"] { --brand: #0f766e; --accent: #0d9488; --bg: #f3faf8; }
.formnote { font-weight: 600; color: var(--brand); }
nav a.on { border-bottom: 2px solid var(--brand); padding-bottom: 2px; }
