:root {
  --ink: #1f2328;
  --muted: #6b7280;
  --line: #e5e7eb;
  --bg: #f6f7f8;
  --panel: #ffffff;
  --accent: #9a5b34;      /* warm timber */
  --accent-dk: #7c4826;
  --good: #1a7f4b;
  --bad: #c0392b;
  --resi: #2563eb;
  --comm: #9a5b34;
}
* { box-sizing: border-box; }
body {
  margin: 0; font-family: -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink); background: var(--bg); font-size: 15px; line-height: 1.5;
}
a { color: var(--accent-dk); }

/* Top bar */
.topbar {
  display: flex; align-items: center; gap: 1.5rem;
  background: #fff; border-bottom: 1px solid var(--line);
  padding: 0 1.5rem; height: 56px;
}
.brand { font-weight: 700; letter-spacing: .2px; }
.brand .mark, .login-brand .mark {
  background: var(--accent); color: #fff; padding: 2px 7px; border-radius: 5px;
  font-weight: 800; margin-right: 4px;
}
.topbar nav { display: flex; gap: .25rem; margin-right: auto; }
.topbar nav a {
  text-decoration: none; color: var(--muted); padding: .4rem .7rem; border-radius: 6px; font-weight: 600;
}
.topbar nav a:hover { background: var(--bg); color: var(--ink); }
.topbar nav a.on { background: var(--accent); color: #fff; }
.who { display: flex; align-items: center; gap: .6rem; font-size: .9rem; }
.who .name { font-weight: 600; }
.role { text-transform: uppercase; font-size: .68rem; font-weight: 700; padding: 2px 6px; border-radius: 4px; }
.role-manager { background: #fdeee4; color: var(--accent-dk); }
.role-worker { background: #e8f0fe; color: #2563eb; }

/* Layout */
.wrap { max-width: 1000px; margin: 0 auto; padding: 1.75rem 1.5rem 3rem; }
.wrap.wide { max-width: 1720px; }
h1 { font-size: 1.5rem; margin: .2rem 0 .3rem; }
h2 { font-size: 1.1rem; margin: 2rem 0 .6rem; }
.muted { color: var(--muted); }
.back { text-decoration: none; color: var(--muted); font-weight: 600; }

/* Cards */
.cards { display: flex; gap: 1rem; flex-wrap: wrap; margin: 1.25rem 0; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 1rem 1.15rem; min-width: 210px; flex: 1; }
.card-head { text-transform: capitalize; color: var(--muted); font-weight: 700; font-size: .8rem; letter-spacing: .3px; display: flex; justify-content: space-between; }
.stat { font-size: 1.7rem; font-weight: 800; margin-top: .3rem; }
.stat-sub { display: block; font-size: .72rem; font-weight: 600; color: var(--muted); }
.card.seg-residential { border-top: 3px solid var(--resi); }
.card.seg-commercial { border-top: 3px solid var(--comm); }
.pill { background: var(--bg); color: var(--muted); border-radius: 20px; padding: 1px 8px; font-size: .7rem; }
table.mini { width: 100%; margin-top: .6rem; font-size: .85rem; }
table.mini td { padding: 2px 0; }

/* Grid tables */
table.grid { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
table.grid th { text-align: left; background: #fafafa; font-size: .75rem; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); padding: .55rem .7rem; border-bottom: 1px solid var(--line); }
table.grid td { padding: .55rem .7rem; border-bottom: 1px solid var(--line); }
table.grid tr:last-child td { border-bottom: none; }
table.grid tr.done { color: var(--muted); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.good { color: var(--good); font-weight: 700; }
.bad { color: var(--bad); font-weight: 700; }

.tag { display: inline-block; background: var(--bg); border: 1px solid var(--line); border-radius: 5px; padding: 1px 7px; font-size: .74rem; font-weight: 600; text-transform: capitalize; }
.tag-residential { background: #e8f0fe; border-color: #cfe0fd; color: #1d4ed8; }
.tag-commercial { background: #fdeee4; border-color: #f6d8c4; color: var(--accent-dk); }
.tag-active { background: #e6f4ec; border-color: #cfe8da; color: var(--good); }

/* Forms */
.row-form { display: flex; flex-wrap: wrap; gap: .75rem; align-items: end; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 1rem; }
.row-form.card-form { background: #fffdfb; }
.row-form label, .login-card label { display: flex; flex-direction: column; font-size: .78rem; font-weight: 700; color: var(--muted); gap: .25rem; }
.row-form .grow { flex: 1; }
input, select { font: inherit; padding: .45rem .55rem; border: 1px solid var(--line); border-radius: 7px; background: #fff; }
input:focus, select:focus { outline: 2px solid #f0d9c8; border-color: var(--accent); }
.inline { display: flex; gap: .4rem; align-items: center; }

.btn { border: 1px solid var(--line); background: #fff; padding: .5rem .9rem; border-radius: 7px; font-weight: 700; cursor: pointer; color: var(--ink); }
.btn:hover { background: var(--bg); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-dk); }
.btn.small { padding: .3rem .6rem; font-size: .8rem; }
.btn.danger { color: var(--bad); border-color: #f5c6c6; }
.btn.danger:hover { background: #fdeaea; }
button.link { background: none; border: none; color: var(--muted); cursor: pointer; font: inherit; font-weight: 600; padding: 0; }
button.link:hover { color: var(--ink); text-decoration: underline; }

/* Login */
.login-card { max-width: 360px; margin: 8vh auto; background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 2rem; box-shadow: 0 8px 30px rgba(0,0,0,.05); }
.login-brand { font-size: 1.4rem; font-weight: 800; }
.login-card form { display: flex; flex-direction: column; gap: .9rem; margin-top: 1.2rem; }
.login-card .btn { margin-top: .3rem; }
.hint { font-size: .78rem; margin-top: 1rem; }
.alert { background: #fdeaea; color: var(--bad); border: 1px solid #f5c6c6; padding: .6rem .8rem; border-radius: 8px; font-size: .85rem; }

/* Runsheet board */
.sheet-wrap { overflow-x: auto; }
table.sheet { font-size: .84rem; min-width: 1100px; }
table.sheet th, table.sheet td { padding: .45rem .5rem; white-space: nowrap; }
th.stepcell, td.stepcell { text-align: center; }
.stepbtn {
  font: inherit; font-size: .78rem; font-weight: 700; border-radius: 6px; cursor: pointer;
  padding: .25rem .45rem; min-width: 3.6rem;
}
.stepbtn.open { background: #fff; color: var(--muted); border: 1px dashed var(--line); }
.stepbtn.open:hover { border-color: var(--accent); color: var(--accent-dk); }
.stepbtn.done { background: #e6f4ec; color: var(--good); border: 1px solid #cfe8da; }
.stepbtn.done.as-text { cursor: default; display: inline-block; }
.rs-edit { text-decoration: none; color: var(--muted); margin-left: .2rem; }
.rs-edit:hover { color: var(--accent-dk); }
.rs-note { max-width: 14rem; overflow: hidden; text-overflow: ellipsis; }
.st { font-size: .72rem; font-weight: 700; padding: 2px 7px; border-radius: 5px; white-space: nowrap; }
.st-none { background: var(--bg); color: var(--muted); border: 1px solid var(--line); }
.st-progress { background: #e8f0fe; color: #1d4ed8; }
.st-complete { background: #e6f4ec; color: var(--good); }
.st-hold { background: #fdf3e0; color: #b45309; }
tr.rs-hold td { background: #fffaf0; }
tr.rs-complete td { background: #f7fcf9; }
.rs-legend { margin-left: .6rem; }
.notes-link { display: block; font-size: .74rem; font-weight: 600; text-decoration: none; }
td.cl-label { white-space: normal; }
.meter { height: 10px; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; overflow: hidden; max-width: 64rem; }
.meter span { display: block; height: 100%; background: var(--good); }
.cap-meter { margin-bottom: .25rem; }
.cap-meter span.tight { background: #d97706; }
.cap-meter span.over { background: var(--bad); }
tr.cap-over td { background: #fdf6f5; }
.cap-due { font-size: .74rem; color: var(--accent-dk); font-weight: 600; margin-top: .2rem; }
.tag-issue { background: #fdeaea; border-color: #f5c6c6; color: var(--bad); }
.tag-lock { background: #fdf3e0; border-color: #f2ddb3; color: #b45309; }
td.note-body { white-space: normal; }
tr.note-issue td:first-child { border-left: 3px solid var(--bad); }
.inline-tags form { display: inline-block; margin: 0 .15rem .3rem 0; }
.small-note { font-size: .74rem; }
tr.mat-cat td { background: #fafafa; font-size: .78rem; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); }
.mat-plan { flex-wrap: wrap; }
.mat-plan label { display: inline-flex; flex-direction: column; font-size: .68rem; font-weight: 700; color: var(--muted); }
.mat-plan input { width: 4.6rem; padding: .25rem .4rem; font-size: .84rem; }
.mat-plan input[type=date] { width: 8.2rem; }

/* Kiosk clock-on — big targets for phones/tablets on the floor */
.kiosk { max-width: 560px; margin: 0 auto; text-align: center; }
.bigbtns { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; margin-top: 1.2rem; }
.bigbtn {
  display: block; width: 100%; padding: 1.1rem .9rem; font: inherit; font-size: 1.05rem; font-weight: 800;
  border-radius: 12px; border: 2px solid var(--line); background: #fff; color: var(--ink);
  text-decoration: none; cursor: pointer;
}
.bigbtn:hover { border-color: var(--accent); }
.bigbtn .sub { display: block; font-size: .78rem; color: var(--muted); font-weight: 600; margin-top: .15rem; }
.bigbtn.go { background: var(--good); border-color: var(--good); color: #fff; }
.bigbtn.go:hover { filter: brightness(1.08); }
.bigbtn.off { background: var(--bad); border-color: var(--bad); color: #fff; font-size: 1.3rem; padding: 1.4rem; margin-top: 1rem; }
.bigbtn.off:hover { filter: brightness(1.08); }
.status-card { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 1.6rem; margin-top: 1.2rem; }
.status-card .status-job { margin: .3rem 0; }
.elapsed { font-size: 2.6rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.pulse { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--good); margin-right: .3rem; }
.bigbtn.lit { border-color: var(--good); background: #f2faf5; }
.pin-form { display: flex; gap: .8rem; justify-content: center; margin-top: 1.2rem; }
.pin-input {
  font-size: 2rem; text-align: center; letter-spacing: .6rem; width: 9.5rem;
  padding: .7rem; border: 2px solid var(--line); border-radius: 12px;
}
.pin-form .bigbtn { width: auto; padding: .9rem 1.6rem; }
.bigtick { font-size: 3.4rem; color: var(--good); font-weight: 800; }

@media (max-width: 560px) {
  .bigbtns { grid-template-columns: 1fr; }
  .wrap { padding: 1rem .8rem 2.5rem; }
  .topbar { padding: 0 .8rem; gap: .8rem; flex-wrap: wrap; height: auto; min-height: 56px; }
}

/* Client-facing quote document */
.quote-doc { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 2.5rem 3rem; max-width: 760px; margin: 0 auto; }
.qd-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; flex-wrap: wrap; }
.quote-doc h1 { margin: 1.2rem 0 .8rem; }
.qd-meta { max-width: 22rem; margin-bottom: 1.2rem; }
.qd-lines { margin-top: .5rem; }
.qd-total { text-align: right; font-size: 1.25rem; margin-top: 1rem; }
.qd-fine { font-size: .78rem; margin-top: 2rem; }
@media print {
  .topbar, .foot, .no-print { display: none !important; }
  body { background: #fff; }
  .wrap { padding: 0; max-width: none; }
  .quote-doc { border: none; padding: 0; }
}

.notice { text-align: center; margin-top: 8vh; }
.foot { text-align: center; color: var(--muted); font-size: .78rem; padding: 1.5rem; }

/* Schedule board */
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.wk-nav { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.sched td.sc { vertical-align: top; min-width: 7.2rem; }
.sched .sc-idle { background: #f6f3ef; }
.sched .sc-over { background: #fbe4e1; box-shadow: inset 0 0 0 2px #d9534f; }
.sched .sc-today { background: #fdf6ec; }
.sched th.sc-today { background: var(--accent, #9a5b34); color: #fff; }
.sched .sc-group td { background: #efe6dd; font-weight: 700; letter-spacing: .02em; }
.sched .sc-me td { background: #fbf8f4; }
.chip { display: inline-flex; align-items: center; gap: .25rem; background: #fff; border: 1px solid var(--line, #e5e7eb);
  border-radius: 999px; padding: .1rem .5rem; margin: .1rem .15rem .1rem 0; font-size: .85rem; white-space: nowrap; }
.chip a { text-decoration: none; font-weight: 700; }
.chip small { color: var(--muted, #6b7280); }
.chip .x { border: none; background: none; color: #d9534f; font-weight: 700; cursor: pointer; padding: 0 .1rem; font-size: .95rem; }
.sc-add { display: inline-block; color: var(--muted, #6b7280); border: 1px dashed var(--line, #cbd5e1);
  border-radius: 6px; padding: 0 .45rem; margin-top: .15rem; text-decoration: none; font-weight: 700; }
.sc-add:hover { color: var(--accent, #9a5b34); border-color: var(--accent, #9a5b34); }

/* Install pack panel on job notes */
.site-pack { background: #fdf6ec; border: 1px solid #ecd9c0; border-radius: 12px; padding: .9rem 1.1rem; margin: 1rem 0; }
.site-pack h2 { margin: 0 0 .4rem; }
.site-pack td:first-child { color: var(--muted, #6b7280); white-space: nowrap; padding-right: .8rem; }
.row-form textarea { width: 100%; font: inherit; padding: .45rem .6rem; border: 1px solid var(--line, #cbd5e1); border-radius: 8px; }

/* Traffic-light job board */
.bd-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: .8rem; margin-top: .8rem; }
.bd-tile { display: block; background: #fff; border: 1px solid var(--line, #e5e7eb); border-top: 6px solid #94a3b8;
  border-radius: 12px; padding: .7rem .85rem; text-decoration: none; color: inherit; }
.bd-tile:hover { box-shadow: 0 2px 10px rgba(0,0,0,.08); }
.bd-top { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; }
.bd-code { font-size: 1.35rem; font-weight: 800; }
.bd-light { font-size: .7rem; font-weight: 800; letter-spacing: .06em; padding: .15rem .45rem; border-radius: 999px; background: #eef1f4; white-space: nowrap; }
.bd-name { font-weight: 600; margin-top: .15rem; }
.bd-client { font-size: .85rem; }
.bd-due { font-size: .85rem; margin: .3rem 0 .35rem; font-weight: 600; }
.bd-foot { display: flex; justify-content: space-between; align-items: center; margin-top: .4rem; }
.bd-late   { border-top-color: #b91c1c; background: #fdf0ee; }
.bd-late .bd-light   { background: #b91c1c; color: #fff; }
.bd-late .bd-due     { color: #b91c1c; }
.bd-urgent { border-top-color: #d9534f; background: #fef5f4; }
.bd-urgent .bd-light { background: #d9534f; color: #fff; }
.bd-urgent .bd-due   { color: #c0392b; }
.bd-soon   { border-top-color: #e8a13c; background: #fdf9f0; }
.bd-soon .bd-light   { background: #e8a13c; color: #fff; }
.bd-ok     { border-top-color: #3e8e5a; }
.bd-ok .bd-light     { background: #e2f2e8; color: #2f6e46; }
.bd-none   { border-top-color: #94a3b8; }
.bd-hold   { border-top-color: #94a3b8; opacity: .6; }
.bd-key { font-size: .75rem; font-weight: 700; padding: .2rem .55rem; border-radius: 999px; border: 1px solid var(--line, #e5e7eb); margin-left: .25rem; white-space: nowrap; }
.bd-key.bd-late { background: #b91c1c; color: #fff; } .bd-key.bd-urgent { background: #d9534f; color: #fff; }
.bd-key.bd-soon { background: #e8a13c; color: #fff; } .bd-key.bd-ok { background: #e2f2e8; color: #2f6e46; }

/* Quote document terms/notes */
.qd-terms { margin-top: .8rem; font-size: .92rem; }
