:root {
  --bg: #fbfaf7; --panel: #ffffff; --ink: #1d1c1a; --muted: #6b675f; --line: #e2ddd3; --line-strong: #cfc8bb;
  --accent: #8a4b14; --accent-ink: #fff; --ok: #2f6b3a; --warn: #9a5b00; --bad: #a3322a; --chip: #f1ece3;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #161513; --panel: #1e1d1a; --ink: #ece8e1; --muted: #a39e94; --line: #34312c; --line-strong: #4a463f;
          --accent: #e0a46a; --accent-ink: #1a1208; --ok: #7cc48a; --warn: #e8b35a; --bad: #ef8a80; --chip: #2a2824; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; }
a { color: var(--accent); }
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 1.25rem; padding: .7rem 1.25rem;
       background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(6px); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; letter-spacing: .28em; text-decoration: none; color: var(--ink); }
#nav { display: flex; gap: .25rem; flex: 1; flex-wrap: wrap; }
#nav a { text-decoration: none; color: var(--muted); padding: .3rem .65rem; border-radius: 6px; }
#nav a.on { color: var(--ink); background: var(--chip); }
#who { font-size: .85rem; text-align: right; }
main { max-width: 72rem; margin: 0 auto; padding: 1.5rem 1.25rem 4rem; }
h1 { font-size: 1.5rem; margin: 0 0 .25rem; }
h2 { font-size: 1.05rem; margin: 1.75rem 0 .6rem; }
h3 { font-size: .95rem; margin: 1.25rem 0 .4rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.spread { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; }
.grid { display: grid; gap: .75rem 1rem; grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr)); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 1rem 1.1rem; }
.cards { display: grid; gap: .8rem; grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr)); }
a.card { text-decoration: none; color: inherit; display: block; }
a.card:hover { border-color: var(--line-strong); }
.stat { font-size: 1.35rem; font-weight: 650; font-variant-numeric: tabular-nums; }
label { display: block; font-size: .85rem; color: var(--muted); }
label > input, label > select, label > textarea { margin-top: .25rem; }
input, select, textarea { display: block; width: 100%; padding: .5rem .6rem; border: 1px solid var(--line-strong); border-radius: 7px;
  background: var(--panel); color: var(--ink); font: inherit; }
textarea { min-height: 6rem; resize: vertical; }
textarea.code { font: 12.5px/1.45 ui-monospace, Menlo, monospace; min-height: 14rem; }
input[type=checkbox] { display: inline; width: auto; margin-right: .4rem; }
label.check { display: flex; align-items: center; color: var(--ink); font-size: .95rem; margin-top: 1.3rem; }
button, .button { display: inline-flex; align-items: center; gap: .35rem; padding: .48rem .95rem; border: 1px solid var(--accent); border-radius: 7px;
  background: var(--accent); color: var(--accent-ink); font: inherit; font-weight: 550; cursor: pointer; text-decoration: none; }
button.ghost, .button.ghost { background: transparent; color: var(--accent); }
button.danger { background: transparent; color: var(--bad); border-color: var(--bad); }
button:disabled { opacity: .5; cursor: not-allowed; }
.tabs { display: flex; flex-wrap: wrap; gap: .1rem .2rem; border-bottom: 1px solid var(--line); margin: 1.25rem 0 1rem; }
.tabs a { padding: .55rem .9rem; text-decoration: none; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a.on { color: var(--ink); border-color: var(--accent); }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: .5rem .55rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; }
td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.total td { font-weight: 700; border-top: 2px solid var(--ink); }
tr.group td { background: var(--chip); font-weight: 600; }
td input { padding: .25rem .4rem; min-width: 5.5rem; }
td.n input { text-align: right; }
.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; cursor: pointer; }
.clamp.open { display: block; }
.scroll { overflow-x: auto; }
.chip { display: inline-block; padding: .1rem .55rem; border-radius: 999px; background: var(--chip); font-size: .78rem; font-weight: 600; color: var(--muted); }
.chip.ok { color: var(--ok); } .chip.warn { color: var(--warn); } .chip.bad { color: var(--bad); }
.desc { max-width: 34rem; }
.log { font: 12px/1.4 ui-monospace, Menlo, monospace; white-space: pre-wrap; background: var(--chip); border-radius: 8px; padding: .75rem; max-height: 18rem; overflow: auto; }
.empty { padding: 2rem 1rem; text-align: center; color: var(--muted); border: 1px dashed var(--line-strong); border-radius: 10px; }
.form { display: grid; gap: .8rem 1rem; grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr)); align-items: end; }
.form .wide { grid-column: 1 / -1; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: 1rem; }
.signin { max-width: 26rem; margin: 4rem auto; }
#toast { position: fixed; bottom: 1.25rem; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: .6rem 1rem;
  border-radius: 8px; max-width: min(36rem, calc(100% - 2rem)); box-shadow: 0 6px 24px rgba(0,0,0,.18); z-index: 10; }
#toast.bad { background: var(--bad); color: #fff; }
dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: .3rem 1rem; margin: 0; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; }
@media (max-width: 640px) {
  .top { gap: .6rem; padding: .6rem 1rem; flex-wrap: wrap; }
  #who { width: 100%; text-align: left; }
  main { padding: 1rem 1rem 3rem; }
}
/* site */
.pre { white-space: pre-wrap; }
.bad-text { color: var(--bad); }
.button.big, button.big { padding: .85rem 1.2rem; font-size: 1.05rem; justify-content: center; }
.site-projects { display: grid; gap: .8rem; grid-template-columns: repeat(auto-fill, minmax(18rem, 1fr)); margin-top: 1rem; }
.site-projects .button.big { width: 100%; }
.site-queue { margin-top: 1rem; border-color: var(--warn); }
.site-queue ul { margin: .4rem 0 0; padding-left: 1.1rem; }
.site-queue li { margin-bottom: .4rem; }
.site-form h3 { margin-top: 1.4rem; }
.site-form .form { margin-top: .8rem; }
.site-labour { display: grid; gap: .5rem .8rem; grid-template-columns: repeat(auto-fill, minmax(7.5rem, 1fr)); }
.sub-row { margin: .4rem 0; flex-wrap: nowrap; }
.sub-row select, .sub-row input { width: auto; min-width: 0; flex: 1; }
.site-photos { display: grid; gap: .6rem; grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr)); margin-top: .6rem; }
.site-photo { display: grid; gap: .3rem; }
.site-photo img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 7px; border: 1px solid var(--line); }
.sticky-actions { position: sticky; bottom: 0; background: var(--bg); padding: .7rem 0; border-top: 1px solid var(--line); }
.gantt { display: grid; gap: .25rem; }
.gantt-row { display: grid; grid-template-columns: minmax(9rem, 16rem) 1fr; gap: .8rem; align-items: center; }
.gantt-head { border-bottom: 1px solid var(--line); padding-bottom: .2rem; }
.gantt-name { font-size: .88rem; line-height: 1.3; }
.gantt-track { position: relative; height: 1.9rem; background: var(--chip); border-radius: 5px; }
.gantt-head .gantt-track { background: none; height: auto; }
.gantt-bar { position: absolute; border-radius: 4px; }
.gantt-bar.planned { top: .2rem; height: .6rem; background: var(--line-strong); }
.gantt-bar.actual { top: .95rem; height: .7rem; background: color-mix(in srgb, var(--accent) 30%, transparent); overflow: hidden; }
.gantt-fill { height: 100%; background: var(--accent); }
.gantt-today { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--bad); opacity: .7; }
.gantt-key { display: inline-block; width: .9rem; height: .55rem; border-radius: 2px; margin-left: .5rem; }
.gantt-key.planned { background: var(--line-strong); } .gantt-key.actual { background: var(--accent); } .gantt-key.today { background: var(--bad); width: 2px; }
.check-item { margin-bottom: .5rem; padding: .7rem .9rem; }
.check-item.not_ok { border-color: var(--bad); }
.pill { display: inline-flex; align-items: center; gap: .3rem; padding: .35rem .7rem; border: 1px solid var(--line-strong); border-radius: 999px; color: var(--ink); font-size: .9rem; cursor: pointer; }
.pill input { margin: 0; }
.pill.ok:has(input:checked) { border-color: var(--ok); color: var(--ok); }
.pill.not_ok:has(input:checked) { border-color: var(--bad); color: var(--bad); }
.pill.na:has(input:checked) { border-color: var(--muted); }
.accept.pass { border-color: var(--ok); } .accept.fail { border-color: var(--bad); }
@media (max-width: 640px) {
  .gantt-row { grid-template-columns: 7.5rem 1fr; gap: .5rem; }
  .site-projects { grid-template-columns: 1fr; }
/* buy */
.buy-lines { display: grid; gap: .6rem; }
.buy-line { padding: .8rem .9rem; }
.buy-line + .buy-line { margin-top: .6rem; }
.buy-lines .buy-line + .buy-line { margin-top: 0; }
@media (max-width: 640px) {
  .buy-big { width: 100%; justify-content: center; padding: .8rem 1rem; font-size: 1.05rem; }
  .buy-line input, .buy-line select { font-size: 16px; } /* no zoom-on-focus on phones */
}

/* portal */
.portal-bar { height: 8px; background: var(--chip); border-radius: 99px; overflow: hidden; margin: .4rem 0; }
.portal-bar span { display: block; height: 100%; background: var(--accent); }
.portal-files { display: grid; gap: .2rem; grid-template-columns: repeat(auto-fill, minmax(18rem, 1fr)); }
.portal-files label.check { margin-top: 0; font-size: .88rem; }
.portal-3d { display: block; width: 100%; height: min(70vh, 640px); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; margin-top: .6rem; background: var(--panel); }
/* bill */
.bill-stats .stat { font-size: 1.15rem; }
.bill-more { margin-top: .8rem; }
.bill-more > summary { cursor: pointer; color: var(--accent); font-weight: 550; padding: .3rem 0; }
.bill-more > .bill-form { margin-top: .5rem; }
.bill-forms { margin-top: 1rem; border-top: 1px solid var(--line); padding-top: .4rem; }
.bill-cert:empty { display: none; }
@media (max-width: 640px) {
  .bill-form input, .bill-form select, .bill-form textarea { font-size: 16px; } /* no zoom-on-focus on phones */
}
