:root {
  --ink: #1d2b26;
  --muted: #5d6b66;
  --line: #dfe5e2;
  --bg: #f6f8f7;
  --panel: #ffffff;
  --brand: #1f6f4a;
  --brand-dark: #154f35;
  --brand-soft: #e6f2ec;
  --warn: #9a5b00;
  --warn-soft: #fff3df;
  --bad: #a3271f;
  --bad-soft: #fdeceb;
  --good: #1f6f4a;
  --radius: 8px;
}
* { box-sizing: border-box; }
html { font-size: 15px; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.45;
}
a { color: var(--brand); }
a:hover { color: var(--brand-dark); }
h1 { font-size: 1.6rem; margin: 0 0 .25rem; }
h2 { font-size: 1.15rem; margin: 1.75rem 0 .6rem; }
h3 { font-size: 1rem; margin: 1.25rem 0 .5rem; }
p { margin: .4rem 0 .8rem; }
.muted { color: var(--muted); }
.small { font-size: .87rem; }

/* layout */
.topbar { background: var(--brand-dark); color: #fff; }
.topbar .inner { max-width: 1240px; margin: 0 auto; display: flex; align-items: center; gap: 1.5rem; padding: .7rem 1.25rem; flex-wrap: wrap; }
.topbar .logo { font-weight: 700; color: #fff; text-decoration: none; letter-spacing: .01em; }
.topbar nav { display: flex; gap: 1rem; flex: 1; flex-wrap: wrap; }
.topbar nav a { color: #d6eadf; text-decoration: none; font-size: .95rem; }
.topbar nav a:hover, .topbar nav a.active { color: #fff; }
.topbar .who { font-size: .87rem; color: #d6eadf; display: flex; align-items: center; gap: .75rem; }
.topbar .who form { margin: 0; }
.topbar .who button { background: transparent; border: 1px solid #5c8f76; color: #fff; padding: .25rem .6rem; border-radius: 6px; cursor: pointer; font-size: .85rem; }
main { max-width: 1240px; margin: 0 auto; padding: 1.5rem 1.25rem 4rem; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.page-head .actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.breadcrumb { font-size: .87rem; color: var(--muted); margin-bottom: .4rem; }
.breadcrumb a { color: var(--muted); }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.25rem; margin-bottom: 1rem; }
.grid { display: grid; gap: 1rem; }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }

/* stat cards */
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; }
.stat .label { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.stat .value { font-size: 1.5rem; font-weight: 650; font-variant-numeric: tabular-nums; margin-top: .2rem; }
.stat .sub { font-size: .85rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.bar { height: 6px; background: #e8ecea; border-radius: 3px; margin-top: .6rem; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--brand); }
.bar.over > span { background: var(--bad); }

/* tables */
table { width: 100%; border-collapse: collapse; background: var(--panel); }
th, td { padding: .5rem .6rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; background: #fafbfa; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.subtotal td { font-weight: 600; background: #fafbfa; }
tr.total td { font-weight: 700; border-top: 2px solid var(--ink); background: #f3f6f4; }
tr.section td { background: var(--brand-soft); font-weight: 600; color: var(--brand-dark); }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
.table-wrap table { border: none; }
.neg { color: var(--bad); }
.pos { color: var(--good); }

/* forms */
label { display: block; font-size: .87rem; font-weight: 600; margin-bottom: .25rem; }
input[type=text], input[type=email], input[type=number], select, textarea {
  font: inherit; padding: .45rem .6rem; border: 1px solid #c8d1cd; border-radius: 6px; width: 100%; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid #9bd0b5; border-color: var(--brand); }
input.money { text-align: right; font-variant-numeric: tabular-nums; min-width: 110px; }
input.changed { background: #fffbe8; border-color: #d9b44a; }
.field { margin-bottom: .85rem; }
.form-row { display: flex; gap: .75rem; flex-wrap: wrap; align-items: flex-end; }
.form-row .field { flex: 1; min-width: 150px; }
.check { display: flex; align-items: center; gap: .4rem; font-weight: 500; }
.check input { width: auto; }

.btn { display: inline-flex; align-items: center; gap: .35rem; padding: .48rem .9rem; border-radius: 6px; border: 1px solid var(--brand); background: var(--brand); color: #fff; font: inherit; font-size: .93rem; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--brand-dark); color: #fff; }
.btn.secondary { background: #fff; color: var(--brand); }
.btn.secondary:hover { background: var(--brand-soft); }
.btn.danger { background: #fff; color: var(--bad); border-color: #e3b4b0; }
.btn.danger:hover { background: var(--bad-soft); }
.btn.small { padding: .25rem .55rem; font-size: .83rem; }
.btn.link { background: none; border: none; color: var(--bad); padding: 0; font-weight: 500; }
.sticky-save { position: sticky; bottom: 0; background: rgba(246,248,247,.95); border-top: 1px solid var(--line); padding: .75rem 0; display: flex; gap: .75rem; align-items: center; margin-top: 1rem; }

/* badges & messages */
.badge { display: inline-block; padding: .12rem .55rem; border-radius: 999px; font-size: .78rem; font-weight: 650; letter-spacing: .02em; border: 1px solid transparent; }
.badge.draft { background: #eef0f3; color: #3f4a57; border-color: #d8dde3; }
.badge.proposed { background: var(--warn-soft); color: var(--warn); border-color: #f0d6a8; }
.badge.accepted { background: #e7eefb; color: #2a4f8f; border-color: #c4d4f0; }
.badge.working { background: var(--brand-soft); color: var(--brand-dark); border-color: #bcdcca; }
.badge.role { background: #f1f3f2; color: var(--muted); border-color: var(--line); }
.flash { padding: .65rem .9rem; border-radius: 6px; margin-bottom: .6rem; border: 1px solid; }
.flash.success { background: var(--brand-soft); border-color: #bcdcca; color: var(--brand-dark); }
.flash.error { background: var(--bad-soft); border-color: #efc2be; color: var(--bad); }
.flash.info { background: #eef3fa; border-color: #c9d8ee; color: #2a4f8f; }
.callout { padding: .75rem 1rem; border-left: 4px solid var(--brand); background: var(--brand-soft); border-radius: 0 6px 6px 0; margin: .5rem 0 1rem; }
.callout.warn { border-color: #d9a441; background: var(--warn-soft); }
ul.errors { margin: .25rem 0 0; padding-left: 1.2rem; }

/* stage stepper */
.stepper { display: flex; gap: 0; margin: .5rem 0 1rem; flex-wrap: wrap; }
.stepper .step { flex: 1; min-width: 140px; padding: .6rem .8rem; border: 1px solid var(--line); background: #fff; font-size: .87rem; }
.stepper .step:first-child { border-radius: 6px 0 0 6px; }
.stepper .step:last-child { border-radius: 0 6px 6px 0; }
.stepper .step + .step { border-left: none; }
.stepper .step .name { font-weight: 650; }
.stepper .step.done { background: #f3f6f4; color: var(--muted); }
.stepper .step.current { background: var(--brand-soft); border-color: #bcdcca; color: var(--brand-dark); }

/* login */
.login { max-width: 420px; margin: 8vh auto; text-align: center; }
.login .panel { padding: 2rem; }
.google-btn { display: inline-flex; align-items: center; gap: .6rem; padding: .65rem 1.1rem; border: 1px solid #c8d1cd; border-radius: 6px; background: #fff; color: var(--ink); text-decoration: none; font-weight: 600; }
.google-btn:hover { background: #f5f7f6; color: var(--ink); }

details summary { cursor: pointer; color: var(--brand); font-weight: 600; }
.inline-form { display: inline; margin: 0; }
code { background: #eef2f0; padding: .05rem .3rem; border-radius: 4px; font-size: .9em; }

@media (max-width: 700px) {
  html { font-size: 14px; }
  main { padding: 1rem .75rem 3rem; }
  .stepper .step { min-width: 50%; }
}
@media print {
  .topbar, .actions, .sticky-save, form { display: none !important; }
  body { background: #fff; }
  .panel, .table-wrap { border: none; }
}

/* project sheet: column chooser */
body.hide-desc .col-desc, body.hide-budget .col-budget, body.hide-projected .col-projected,
body.hide-var .col-var, body.hide-actual .col-actual, body.hide-pct .col-pct, body.hide-notes .col-notes { display: none; }
.desc-inline { display: none; }
body.desc-inline-on .desc-inline { display: block; }
.colpicker { margin: 0 0 .6rem; }
.colpicker-body { display: flex; gap: 1rem; flex-wrap: wrap; padding: .5rem .75rem; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; margin-top: .4rem; }
table.sheet th.year-head { text-align: center; border-left: 1px solid var(--line); }
table.sheet th.focus-year { background: var(--brand-soft); }
table.sheet input.money { min-width: 92px; }
table.sheet td input[type=text]:not(.money) { min-width: 140px; }
th.sortable a { color: inherit; text-decoration: none; }
th.sortable a:hover { color: var(--brand); }
.filter-bar { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; margin: .5rem 0 1rem; }
.filter-bar a.active { background: var(--brand); color: #fff; }
