:root {
  --bg: #f4f5f3; --panel: #fff; --ink: #1d2422; --muted: #5d6965; --line: #d9dedb; --line-strong: #b8c1bd;
  --accent: #1f5f4f; --accent-ink: #fff; --accent-soft: #e4f0ec; --err: #a8281c; --err-soft: #fbeae7;
  --warn: #8a5a00; --warn-soft: #fbf2dc; --ok: #1f6b45; --focus: #1b74c9;
  font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--ink);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); }
h1 { font-size: 20px; margin: 0; } h2 { font-size: 15px; margin: 0 0 8px; } h3 { font-size: 13px; margin: 0 0 6px; }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
button { border: 1px solid var(--line-strong); background: var(--panel); border-radius: 5px; padding: 5px 11px; cursor: pointer; }
button:hover:not(:disabled) { background: #eef1ef; }
button:disabled { opacity: .5; cursor: default; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button.primary:hover:not(:disabled) { background: #184d40; }
button.danger { color: var(--err); border-color: #dcb1ab; }
button.link { border: 0; background: none; color: var(--accent); padding: 0; text-decoration: underline; }
button.icon { padding: 2px 6px; border-color: transparent; background: none; color: var(--muted); }
input, select, textarea { border: 1px solid var(--line-strong); border-radius: 4px; padding: 5px 7px; background: #fff; width: 100%; }
input:disabled, select:disabled, textarea:disabled { background: #f3f4f3; color: var(--ink); border-color: var(--line); }
input[type=checkbox] { width: auto; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
label { display: block; font-size: 12px; color: var(--muted); }
label > input, label > select, label > textarea { margin-top: 2px; color: var(--ink); font-size: 14px; }
label.check { display: flex; gap: 6px; align-items: center; font-size: 13px; color: var(--ink); }

.topbar { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; background: #17352d; color: #fff; padding: 7px 16px; }
.brand { font-weight: 650; margin-right: 6px; }
.topbar select { width: auto; background: #254a40; color: #fff; border-color: #3f6a5e; }
.topbar nav { display: flex; flex-wrap: wrap; gap: 2px; flex: 1; }
.topbar nav a { color: #d7e6e1; text-decoration: none; padding: 5px 9px; border-radius: 4px; }
.topbar nav a:hover { background: #254a40; }
.topbar nav a.active { background: #fff; color: #17352d; font-weight: 600; }
.topbar .who { font-size: 12px; color: #c4d6d0; display: flex; gap: 8px; align-items: center; }
.topbar .who button { color: #fff; }
.badge { display: inline-block; font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 9px; background: #e7eae8; color: var(--muted); white-space: nowrap; }
.badge.open { background: var(--accent-soft); color: var(--accent); } .badge.final { background: #dfe4f2; color: #2c3f77; }
.badge.err { background: var(--err-soft); color: var(--err); } .badge.warn { background: var(--warn-soft); color: var(--warn); }

main { padding: 16px; max-width: 1500px; margin: 0 auto; }
.head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-bottom: 12px; }
.head .spacer { flex: 1; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 7px; padding: 14px; margin-bottom: 12px; }
.muted { color: var(--muted); } .small { font-size: 12px; } .num { text-align: right; font-variant-numeric: tabular-nums; }
.neg { color: var(--err); }
.notice { padding: 8px 12px; border-radius: 5px; background: var(--warn-soft); color: #5e4000; margin-bottom: 12px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin-bottom: 12px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: 7px; padding: 10px 12px; }
.tile b { display: block; font-size: 21px; font-weight: 620; font-variant-numeric: tabular-nums; }
.tile span { font-size: 12px; color: var(--muted); }
.scroll { overflow-x: auto; }
table.data { border-collapse: collapse; width: 100%; font-size: 13px; }
table.data th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; border-bottom: 1px solid var(--line-strong); padding: 5px 7px; position: sticky; top: 0; background: var(--panel); white-space: nowrap; }
table.data th.num { text-align: right; }
table.data td { border-bottom: 1px solid #edf0ee; padding: 4px 7px; }
table.data tr.click { cursor: pointer; } table.data tr.click:hover td { background: #f3f7f5; }
table.data tr.group td { background: #eef2f0; font-weight: 600; border-top: 1px solid var(--line-strong); }
table.data tr.sub td { font-weight: 600; border-top: 1px solid var(--line-strong); }
.problem { display: flex; gap: 8px; align-items: baseline; padding: 4px 0; border-bottom: 1px solid #edf0ee; }
.problem:last-child { border: 0; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; }
.grid-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; }
.grid-form .wide { grid-column: 1 / -1; }

.login { max-width: 340px; margin: 12vh auto; padding: 24px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; }
.login form { display: grid; gap: 12px; margin-top: 14px; }
.error { color: var(--err); font-size: 13px; }

.entry { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 12px; align-items: start; }
.people { background: var(--panel); border: 1px solid var(--line); border-radius: 7px; position: sticky; top: 8px; }
.people .filters { padding: 8px; border-bottom: 1px solid var(--line); display: grid; gap: 6px; }
.people ul { list-style: none; margin: 0; padding: 0; max-height: calc(100vh - 170px); overflow-y: auto; }
.people li a { display: flex; gap: 6px; justify-content: space-between; align-items: center; padding: 5px 9px; color: inherit; text-decoration: none; border-bottom: 1px solid #f0f2f0; }
.people li a:hover { background: #f3f7f5; }
.people li a.active { background: var(--accent-soft); font-weight: 600; }
.people .hrs { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.people .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: transparent; }
.people .dot.err { background: var(--err); } .people .dot.warn { background: #d29a1c; }
.sheet-head { display: flex; flex-wrap: wrap; gap: 8px 22px; align-items: flex-start; }
.sheet-head .id { flex: 1; min-width: 220px; }
.facts { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--muted); margin-top: 3px; }
.facts b { color: var(--ink); font-weight: 600; }
.bank-box { display: flex; gap: 14px; font-size: 12px; color: var(--muted); }
.bank-box div b { display: block; font-size: 16px; color: var(--ink); font-variant-numeric: tabular-nums; }
.notes { white-space: pre-wrap; font-size: 13px; background: #fbf8ec; border: 1px solid #eadfb8; border-radius: 5px; padding: 7px 10px; margin: 10px 0 0; max-height: 120px; overflow-y: auto; }
table.lines { border-collapse: collapse; width: 100%; min-width: 1060px; font-size: 13px; }
table.lines th { font-size: 11px; font-weight: 600; color: var(--muted); padding: 3px 2px; text-align: center; white-space: nowrap; border-bottom: 1px solid var(--line-strong); }
table.lines td { padding: 2px; vertical-align: middle; }
table.lines input, table.lines select { padding: 3px 4px; font-size: 13px; border-color: var(--line); }
table.lines input.n { text-align: right; font-variant-numeric: tabular-nums; }
table.lines input:not(:disabled):hover, table.lines select:not(:disabled):hover { border-color: var(--line-strong); }
table.lines input::-webkit-calendar-picker-indicator { display: none !important; }
table.lines tr.has-error > td:first-child { box-shadow: inset 3px 0 var(--err); }
table.lines tr.has-warn > td:first-child { box-shadow: inset 3px 0 #d29a1c; }
table.lines .c-code { width: 136px; } table.lines .c-job { width: 72px; } table.lines .c-cost { width: 54px; } table.lines .c-eq { width: 58px; }
table.lines .c-rep { width: 46px; } table.lines .c-wo { width: 62px; } table.lines .c-amt { width: 72px; } table.lines .c-sm { width: 48px; }
table.lines .c-day { width: 46px; } table.lines .c-tot { width: 52px; } table.lines .c-act { width: 74px; white-space: nowrap; }
table.lines .tot { text-align: right; font-weight: 600; padding-right: 5px; font-variant-numeric: tabular-nums; }
table.lines tfoot td { border-top: 1px solid var(--line-strong); padding: 5px 2px; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; padding-right: 6px; }
table.lines tr.note-row td { padding: 0 2px 4px; }
table.lines tr.note-row input { font-size: 12px; background: #fcfcfa; }
.toolbar { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; align-items: center; }
.save-state { font-size: 12px; color: var(--muted); margin-left: auto; }
dialog { border: 1px solid var(--line-strong); border-radius: 8px; padding: 18px; width: min(680px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(20, 30, 26, .4); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
#toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: #1d2422; color: #fff; padding: 8px 14px; border-radius: 6px; max-width: 90vw; z-index: 20; }
#toast.error { background: var(--err); }
.tabs { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 10px; }
.tabs button.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.print-title { display: none; }

@media (max-width: 800px) {
  .entry { grid-template-columns: minmax(0, 1fr); }
  .people { position: static; } .people ul { max-height: 190px; }
}
@media print {
  .topbar, .no-print, #toast { display: none !important; }
  body { background: #fff; } main { padding: 0; max-width: none; }
  .panel { border: 0; padding: 0; }
  .print-title { display: block; margin-bottom: 8px; }
  table.data { font-size: 10px; } table.data th { position: static; } table.data td, table.data th { padding: 2px 4px; }
  .scroll { overflow: visible; }
}
