:root {
  --bg: #f1f5f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --accent: #d97706;
  --accent-ink: #ffffff;
  --primary: #1e293b;
  --primary-ink: #ffffff;
  --ok: #16a34a;
  --ok-bg: #dcfce7;
  --warn: #b45309;
  --warn-bg: #fef3c7;
  --bad: #dc2626;
  --bad-bg: #fee2e2;
  --info: #2563eb;
  --info-bg: #dbeafe;
  --hold: #7c3aed;
  --hold-bg: #ede9fe;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 2px 8px rgba(15, 23, 42, .06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1120;
    --surface: #111827;
    --surface-2: #1a2333;
    --border: #273449;
    --text: #e5e7eb;
    --muted: #94a3b8;
    --primary: #e2e8f0;
    --primary-ink: #0f172a;
    --ok-bg: #052e16;
    --warn-bg: #3a2604;
    --bad-bg: #3b0a0a;
    --info-bg: #0c1f45;
    --hold-bg: #23164a;
    --ok: #4ade80;
    --warn: #fbbf24;
    --bad: #f87171;
    --info: #60a5fa;
    --hold: #a78bfa;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
a { color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }
.grow { flex: 1; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
[hidden] { display: none !important; }

/* ---------- top bar ---------- */
#topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px;
  padding: calc(env(safe-area-inset-top) + 8px) 16px 8px;
  background: #1e293b; color: #f8fafc;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; text-decoration: none; font-size: 1.05rem; white-space: nowrap; }
.logo { color: #f59e0b; font-size: 1.3rem; }
#nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
#nav a { padding: 10px 14px; border-radius: 8px; text-decoration: none; color: #cbd5e1; font-weight: 600; white-space: nowrap; }
#nav a.active, #nav a:hover { background: rgba(255, 255, 255, .1); color: #fff; }
.top-right { display: flex; align-items: center; gap: 8px; }
.icon-btn { position: relative; background: transparent; border: 0; font-size: 1.3rem; padding: 8px; cursor: pointer; color: inherit; min-width: 44px; min-height: 44px; }
#bell-count { position: absolute; top: 2px; right: 0; background: #ef4444; color: #fff; border-radius: 999px; font-size: .7rem; font-weight: 700; padding: 1px 6px; }
.user-chip { background: rgba(255, 255, 255, .12); color: #f8fafc; border: 0; border-radius: 999px; padding: 8px 14px; font-weight: 600; cursor: pointer; min-height: 40px; font-size: .95rem; }

#stale { position: sticky; top: 60px; z-index: 15; display: flex; justify-content: center; padding: 6px; }
#stale button { background: var(--info); color: #fff; border: 0; border-radius: 999px; padding: 8px 16px; font-weight: 600; box-shadow: var(--shadow); cursor: pointer; }

main { max-width: 1280px; margin: 0 auto; padding: 16px 16px calc(env(safe-area-inset-bottom) + 40px); }

/* ---------- controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 16px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { filter: brightness(.97); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--primary); color: var(--primary-ink); border-color: transparent; }
.btn.accent { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.ok { background: var(--ok); color: #fff; border-color: transparent; }
.btn.danger { background: var(--bad); color: #fff; border-color: transparent; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.pay-got { cursor: default; }
.pay-state { display: inline-flex; flex-direction: column; align-items: center; gap: 2px; vertical-align: middle; }
.pay-state [data-unreceive], .pay-state [data-unbuy] { background: none; border: 0; padding: 0; color: var(--muted); text-decoration: underline; cursor: pointer; font-size: .78rem; }
.btn.big { min-height: 56px; font-size: 1.05rem; padding: 12px 22px; }
.btn.sm { min-height: 34px; padding: 6px 10px; font-size: .85rem; }

input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; min-height: 44px; width: 100%;
}
textarea { min-height: 90px; resize: vertical; }
input[type="checkbox"], input[type="radio"] { width: 22px; height: 22px; min-height: 0; accent-color: var(--accent); }
input[type="color"] { padding: 4px; width: 60px; }
.field { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: .9rem; }
.field .hint { display: block; font-weight: 400; color: var(--muted); font-size: .8rem; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(220px, 100%), 1fr)); gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.check { display: flex; align-items: center; gap: 10px; cursor: pointer; }

/* ---------- surfaces ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.card.flush { padding: 0; overflow: hidden; }
.section-title { display: flex; align-items: center; gap: 10px; margin: 24px 0 10px; }
.section-title .count, .tgroup .count { background: var(--border); border-radius: 999px; padding: 1px 9px; font-size: .8rem; font-weight: 700; }
.empty { padding: 24px; text-align: center; color: var(--muted); border: 2px dashed var(--border); border-radius: var(--radius); }

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; font-size: .78rem; font-weight: 700; white-space: nowrap; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.badge.ok { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.badge.warn { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.badge.bad { background: var(--bad-bg); color: var(--bad); border-color: transparent; }
.badge.info { background: var(--info-bg); color: var(--info); border-color: transparent; }
.badge.hold { background: var(--hold-bg); color: var(--hold); border-color: transparent; }
.dept-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex: none; }

.progress { height: 8px; background: var(--border); border-radius: 999px; overflow: hidden; }
.progress > div { height: 100%; background: var(--accent); border-radius: 999px; transition: width .3s; }
.progress.lg { height: 14px; }

/* ---------- project cards ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.pcard { display: flex; flex-direction: column; gap: 10px; text-decoration: none; background: var(--surface); border: 1px solid var(--border); border-left: 6px solid var(--dept, var(--border)); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); cursor: pointer; }
.pcard:active { transform: scale(.99); }
.pcard .title { font-weight: 700; font-size: 1.05rem; }
.pcard .job { color: var(--muted); font-weight: 600; font-size: .85rem; }
.route { display: flex; gap: 3px; }
.route span { flex: 1; height: 6px; border-radius: 3px; background: var(--border); }
.route span.approved { background: var(--ok); }
.route span.in_progress, .route span.review { background: var(--accent); }
.route span.ready { background: var(--info); }
.route span.blocked { background: var(--bad); }
.route span.skipped { background: transparent; border: 1px dashed var(--border); }

/* ---------- department picker ---------- */
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; -webkit-overflow-scrolling: touch; }
.chip { display: inline-flex; align-items: center; gap: 8px; padding: 10px 14px; min-height: 44px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); font-weight: 600; cursor: pointer; white-space: nowrap; color: var(--text); font-size: .95rem; }
.chip.active { background: var(--primary); color: var(--primary-ink); border-color: transparent; }
.chip .n { background: var(--border); color: var(--text); border-radius: 999px; padding: 0 7px; font-size: .75rem; }
.chip.active .n { background: rgba(127, 127, 127, .35); color: inherit; }

/* ---------- project page ---------- */
.phead { display: grid; grid-template-columns: 1fr auto; gap: 16px; align-items: start; }
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; margin-top: 14px; }
.fact .k { font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; font-weight: 700; }
.fact .v { font-weight: 700; }
.big-pct { font-size: 2.2rem; font-weight: 800; line-height: 1; text-align: right; }

.timeline { display: flex; gap: 0; overflow-x: auto; padding: 4px 2px 10px; -webkit-overflow-scrolling: touch; }
.tstep { flex: 1 0 120px; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; position: relative; cursor: pointer; padding: 6px 4px; border-radius: 10px; border: 0; background: transparent; color: var(--text); font: inherit; }
.tstep::before { content: ""; position: absolute; top: 25px; left: -50%; width: 100%; height: 3px; background: var(--border); z-index: 0; }
.tstep:first-child::before { display: none; }
.tstep.done::before, .tstep.cur::before { background: var(--ok); }
.tstep .circle { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; background: var(--surface); border: 3px solid var(--border); z-index: 1; position: relative; }
.tstep.done .circle { background: var(--ok); border-color: var(--ok); color: #fff; }
.tstep.cur .circle { border-color: var(--accent); color: var(--accent); box-shadow: 0 0 0 4px rgba(217, 119, 6, .2); }
.tstep.blocked .circle { border-color: var(--bad); color: var(--bad); }
.tstep.skipped { opacity: .45; }
.tstep.sel { background: var(--surface-2); outline: 2px solid var(--border); }
.tstep .name { font-weight: 700; font-size: .85rem; }
.tstep .st { font-size: .75rem; color: var(--muted); }

.layout-2 { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 16px; margin-top: 16px; }
@media (max-width: 900px) { .layout-2 { grid-template-columns: 1fr; } }

.stage-panel { border-top: 6px solid var(--dept, var(--accent)); }
.checklist { display: flex; flex-direction: column; gap: 2px; }
.checklist label { display: flex; gap: 12px; align-items: center; padding: 10px; border-radius: 10px; cursor: pointer; min-height: 48px; }
.checklist label:hover { background: var(--surface-2); }
.checklist .done span.t { text-decoration: line-through; color: var(--muted); }
.actions { display: flex; flex-wrap: wrap; gap: 10px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 12px; overflow-x: auto; }
.tabs button { background: transparent; border: 0; border-bottom: 3px solid transparent; padding: 12px 14px; font: inherit; font-weight: 700; color: var(--muted); cursor: pointer; white-space: nowrap; min-height: 44px; }
.tabs button.active { color: var(--text); border-color: var(--accent); }

.feed { display: flex; flex-direction: column; gap: 10px; }
.note { padding: 12px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); }
.note.rework { border-left: 4px solid var(--bad); }
.note.approval { border-left: 4px solid var(--ok); }
.note .meta { font-size: .8rem; color: var(--muted); margin-bottom: 4px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.note .body { white-space: pre-wrap; word-break: break-word; }

.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; }
.gallery figure { margin: 0; position: relative; border-radius: 10px; overflow: hidden; background: var(--surface-2); aspect-ratio: 1; cursor: zoom-in; }
.gallery img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gallery figcaption { position: absolute; left: 0; right: 0; bottom: 0; padding: 4px 6px; font-size: .7rem; color: #fff; background: linear-gradient(transparent, rgba(0, 0, 0, .75)); }

.issue { padding: 12px; border-radius: 10px; border: 1px solid var(--border); border-left: 5px solid var(--warn); background: var(--surface); }
.issue.critical { border-left-color: var(--bad); }
.issue.info { border-left-color: var(--info); }
.issue.resolved { opacity: .65; border-left-color: var(--ok); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: var(--surface-2); white-space: nowrap; cursor: default; }
th.sort { cursor: pointer; user-select: none; }
tbody tr.link { cursor: pointer; }
tbody tr.link:hover { background: var(--surface-2); }
td .progress { min-width: 90px; }

/* ---------- admin ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.kpi { font: inherit; color: var(--text); text-align: left; cursor: pointer; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.kpi:hover { border-color: var(--muted); }
.kpi.sel { outline: 3px solid var(--accent); outline-offset: -1px; }
.kpi .n { font-size: 1.9rem; font-weight: 800; line-height: 1.1; }
.kpi .l { font-size: .8rem; color: var(--muted); font-weight: 600; }
.kpi.bad .n { color: var(--bad); }
.kpi.warn .n { color: var(--warn); }
.kpi.ok .n { color: var(--ok); }
.admin-grid { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 16px; margin-top: 16px; }
@media (max-width: 1000px) { .admin-grid { grid-template-columns: minmax(0, 1fr); } }
.attn { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-bottom: 1px solid var(--border); cursor: pointer; }
.attn:last-child { border-bottom: 0; }
.attn:hover { background: var(--surface-2); }
.load-row { display: grid; grid-template-columns: 150px 1fr 90px; gap: 10px; align-items: center; padding: 8px 0; }
.load-bar { display: flex; height: 18px; border-radius: 6px; overflow: hidden; background: var(--border); }
.load-bar div { height: 100%; }
.subnav { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }

.route-edit { display: flex; flex-direction: column; gap: 8px; }
.route-row { display: grid; grid-template-columns: 34px 1.2fr 90px 1fr 1.2fr auto; gap: 8px; align-items: center; padding: 8px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); }
.route-row.off { opacity: .5; }
@media (max-width: 760px) { .route-row { grid-template-columns: 34px 1fr auto; } .route-row .wide { grid-column: 2 / -1; } }

/* ---------- board ---------- */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(240px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 12px; align-items: start; }
.col { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px; display: flex; flex-direction: column; gap: 8px; min-height: 200px; }
.col h3 { display: flex; align-items: center; gap: 8px; padding: 4px 4px 8px; border-bottom: 3px solid var(--dept); }
.mini { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 10px; display: flex; flex-direction: column; gap: 6px; cursor: pointer; text-decoration: none; }

/* ---------- login ---------- */
.login { max-width: 900px; margin: 6vh auto 0; text-align: center; }
.login h1 { font-size: 2rem; margin-bottom: 6px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-top: 24px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 10px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 8px; box-shadow: var(--shadow); font: inherit; color: var(--text); }
.avatar { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 1.2rem; color: #fff; background: var(--c, #64748b); }
.pinpad { display: grid; grid-template-columns: repeat(3, 80px); gap: 12px; justify-content: center; margin: 20px 0; }
.pinpad button { height: 70px; border-radius: 16px; border: 1px solid var(--border); background: var(--surface); font-size: 1.6rem; font-weight: 700; cursor: pointer; color: var(--text); }
.pinpad button:active { background: var(--border); }
.pin-dots { display: flex; gap: 14px; justify-content: center; margin-top: 16px; min-height: 20px; }
.pin-dots span { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--muted); }
.pin-dots span.on { background: var(--text); border-color: var(--text); }

/* ---------- overlays ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, .55); z-index: 50; display: flex; align-items: flex-start; justify-content: center; padding: 6vh 12px; overflow-y: auto; }
.modal { background: var(--surface); border-radius: 16px; width: 100%; max-width: 560px; padding: 20px; box-shadow: 0 20px 60px rgba(0, 0, 0, .3); display: flex; flex-direction: column; gap: 14px; }
.modal.wide { max-width: 900px; }
.modal .foot { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.lightbox { position: fixed; inset: 0; z-index: 60; background: rgba(0, 0, 0, .92); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 16px; color: #fff; gap: 10px; }
.lightbox img { max-width: 100%; max-height: 80vh; object-fit: contain; border-radius: 6px; }

#drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(420px, 100vw); background: var(--surface); z-index: 40; box-shadow: -10px 0 30px rgba(0, 0, 0, .2); display: flex; flex-direction: column; padding-top: env(safe-area-inset-top); }
#drawer .head { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--border); }
#drawer .list { overflow-y: auto; flex: 1; }
.notif { display: block; padding: 12px 16px; border-bottom: 1px solid var(--border); text-decoration: none; cursor: pointer; }
.notif.unread { background: var(--info-bg); }
.notif .when { font-size: .75rem; color: var(--muted); }

#toast { position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 20px); transform: translateX(-50%); background: #0f172a; color: #fff; padding: 12px 18px; border-radius: 12px; z-index: 70; box-shadow: var(--shadow); max-width: 90vw; font-weight: 600; }
#toast.err { background: #b91c1c; }

/* ---------- traveler (print) ---------- */
.traveler { background: #fff; color: #000; max-width: 800px; margin: 0 auto; padding: 24px; border: 1px solid #ccc; }
.traveler table td, .traveler table th { border: 1px solid #999; color: #000; background: #fff; }
.traveler .qr svg { width: 130px; height: 130px; }
.tv-page + .tv-page { margin-top: 20px; }
.traveler table { width: 100%; border-collapse: collapse; margin-top: 12px; }
.traveler th, .traveler td { padding: 5px 7px; text-align: left; vertical-align: top; font-size: .9rem; }
.tv-specs th { width: 110px; background: #f3f3f3 !important; font-weight: 700; }
.tv-table .tv-dept td { background: #e9e9e9 !important; font-size: .95rem; }
.tv-table .tv-box { width: 26px; text-align: center; font-size: 1.1rem; }
.tv-table .tv-sign { width: 150px; }
.tv-table .tv-done td { color: #666 !important; }
.tv-table .tv-done td:nth-child(2) { text-decoration: line-through; }
.tv-table .tv-check td { font-style: italic; }
.tv-note { font-size: .8rem; font-weight: 400; margin-top: 2px; white-space: pre-wrap; }
.tv-finished { margin-top: 10px; font-size: .85rem; }
.tv-foot { margin-top: 10px; font-size: .75rem; color: #555; }
@media print {
  #topbar, #stale, .no-print { display: none !important; }
  body { background: #fff; }
  main { padding: 0; }
  .traveler { border: 0; max-width: none; padding: 0; }
  .tv-page { break-after: page; page-break-after: always; }
  .tv-page:last-child { break-after: auto; page-break-after: auto; }
  .tv-table tr { break-inside: avoid; }
}

@media (max-width: 640px) {
  .phead { grid-template-columns: 1fr; }
  .big-pct { text-align: left; }
  .brand span:last-child { display: none; }
  .load-row { grid-template-columns: 100px 1fr 70px; }
}

/* ---------- schedule (gantt) ---------- */
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--surface); }
.seg button { border: 0; background: transparent; padding: 8px 12px; min-height: 38px; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; }
.seg button.active { background: var(--primary); color: var(--primary-ink); }
.delays { margin-bottom: 14px; border-left: 5px solid var(--warn); }
.delays .attn { cursor: default; padding-left: 0; padding-right: 0; }
.undo-bar { margin: 10px 0; border-left: 5px solid var(--accent, #8322D5); align-items: center; }
.gantt { overflow: hidden; --label: 220px; }
.g-scroll { overflow: auto; max-height: calc(100vh - 260px); -webkit-overflow-scrolling: touch; }
.g-inner { position: relative; }
.g-head { display: flex; position: sticky; top: 0; z-index: 4; background: var(--surface-2); border-bottom: 1px solid var(--border); }
.g-label { width: var(--label); flex: none; position: sticky; left: 0; z-index: 3; background: var(--surface); padding: 8px 10px; border-right: 1px solid var(--border); font-size: .9rem; overflow: hidden; }
.g-label a { text-decoration: none; }
.g-head .g-label { background: var(--surface-2); z-index: 5; }
.g-days { display: flex; }
.g-day { flex: none; font-size: .7rem; color: var(--muted); text-align: center; padding: 4px 0; border-left: 1px solid var(--border); position: relative; height: 40px; display: flex; flex-direction: column; justify-content: flex-end; }
.g-day b { position: absolute; top: 3px; left: 3px; font-size: .7rem; color: var(--text); white-space: nowrap; }
.g-day.off { background: rgba(127, 127, 127, .08); }
.g-day.today { color: var(--accent); font-weight: 800; }
.g-rows { position: relative; }
.g-bg { position: absolute; top: 0; bottom: 0; right: 0; pointer-events: none; z-index: 0; }
.g-off { position: absolute; top: 0; bottom: 0; background: rgba(127, 127, 127, .07); }
.g-timeoff { position: absolute; top: 0; bottom: 0; background: repeating-linear-gradient(135deg, rgba(245, 158, 11, .16) 0 6px, transparent 6px 12px); font-size: .8rem; padding: 2px; overflow: hidden; pointer-events: auto; }
.g-today { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--accent); opacity: .7; }
.g-row { display: flex; border-bottom: 1px solid var(--border); position: relative; }
.g-row.drop { background: var(--info-bg); }
.g-track { position: relative; flex: 1; z-index: 1; }
.g-bar { position: absolute; height: 28px; border-radius: 7px; background: var(--c, #64748b); color: #fff; font-size: .78rem; font-weight: 700; display: flex; align-items: center; overflow: hidden; white-space: nowrap; box-shadow: 0 1px 2px rgba(0,0,0,.15); touch-action: none; user-select: none; -webkit-user-select: none; cursor: pointer; }
.g-bar .g-text { padding: 0 8px; overflow: hidden; text-overflow: ellipsis; text-shadow: 0 1px 1px rgba(0,0,0,.35); }
.g-bar.editable { cursor: grab; }
.g-bar.forecast { background: repeating-linear-gradient(135deg, var(--c) 0 8px, color-mix(in srgb, var(--c) 70%, #fff) 8px 16px); opacity: .85; outline: 2px dashed color-mix(in srgb, var(--c) 60%, #000); outline-offset: -2px; }
.g-bar.done { opacity: .4; }
.g-bar.delayed { box-shadow: 0 0 0 2px var(--warn); }
.g-bar.conflict { box-shadow: 0 0 0 2px var(--bad); }
.g-bar.dragging { opacity: .85; z-index: 10; cursor: grabbing; box-shadow: 0 6px 16px rgba(0,0,0,.3); }
.g-handle { position: absolute; right: 0; top: 0; bottom: 0; width: 14px; cursor: ew-resize; background: linear-gradient(90deg, transparent, rgba(255,255,255,.45)); }
.g-due { position: absolute; top: 0; bottom: 0; width: 3px; background: var(--bad); z-index: 2; }
.g-load { position: absolute; bottom: 0; height: 5px; background: var(--ok); opacity: .55; }
.g-load.full { background: var(--warn); opacity: .8; }
.g-load.over { background: var(--bad); opacity: .9; height: 7px; }
.g-key { display: inline-block; width: 22px; height: 10px; border-radius: 3px; vertical-align: middle; margin-right: 4px; background: #64748b; }
.g-key.forecast { background: repeating-linear-gradient(135deg, #64748b 0 4px, #a3b0c2 4px 8px); }
.g-key.done { opacity: .4; }
.g-key.due { width: 3px; background: var(--bad); }
.g-key.full { background: var(--warn); }
.g-key.over { background: var(--bad); }
.g-key.late { background: none; box-shadow: inset 0 0 0 2px var(--warn); }
.g-key.clash { background: none; box-shadow: inset 0 0 0 2px var(--bad); }
@media (max-width: 640px) { .gantt { --label: 140px; } }

/* ---------- props & tasks ---------- */
.task-banner { text-decoration: none; margin-top: 12px; padding: 12px 16px; border-left: 5px solid var(--hold); }
table.props td { vertical-align: top; }
table.props th { white-space: nowrap; }
table.props tr.grp td { background: var(--surface-2); font-weight: 800; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
table.props td.num, .num { text-align: right; white-space: nowrap; }
.item-cell { min-width: 160px; }
.linkish { background: none; border: 0; padding: 0; font: inherit; font-weight: 700; color: var(--text); cursor: pointer; text-align: left; }
.chip-task { display: inline-flex; align-items: center; gap: 6px; margin: 2px; padding: 5px 9px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); font: inherit; font-size: .78rem; font-weight: 700; cursor: pointer; color: var(--text); min-height: 32px; }
.chip-task { flex-direction: column; align-items: flex-start; gap: 1px; text-align: left; }
.chip-task b { font-weight: 700; }
.chip-task small { font-weight: 500; font-size: .7rem; opacity: .8; }
.chip-task .chip-n { font-style: normal; font-size: .68rem; padding: 0 5px; border-radius: 999px; background: var(--border); margin-left: 2px; }
.chip-task.in_progress { background: var(--warn-bg); border-color: transparent; color: var(--warn); }
.chip-task.review { background: var(--hold-bg); border-color: var(--hold); color: var(--hold); }
.chip-task.done { background: var(--ok-bg); border-color: transparent; color: var(--ok); }
.chip-task.done b::before { content: "✓ "; }
.task-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--border); cursor: pointer; flex-wrap: wrap; }
.task-row:last-child { border-bottom: 0; }
.task-row:hover { background: var(--surface-2); }
.review-list { max-height: 50vh; overflow: auto; display: flex; flex-direction: column; }
.review-row { padding: 8px 4px; border-bottom: 1px solid var(--border); align-items: flex-start; }
.similar { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.sim { border: 1px solid var(--border); border-radius: 10px; padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.sim-photos { display: flex; gap: 4px; }
.sim-photos img { width: 100%; height: 80px; object-fit: cover; border-radius: 6px; flex: 1; min-width: 0; }
.shared-tag { position: absolute; top: 6px; left: 6px; z-index: 1; background: rgba(0,0,0,.65); color: #fff; font-size: .7rem; font-weight: 700; padding: 2px 6px; border-radius: 6px; }
.tpl-row { display: grid; grid-template-columns: 1fr 1.5fr 90px auto; gap: 6px; }
.rep-person { padding: 10px 14px; border-top: 1px solid var(--border); }
.rep-person h3 { font-size: .95rem; }
.rep-day { margin: 8px 0 0 10px; }
.rep-table { margin-top: 4px; table-layout: fixed; }
.rep-table td { padding: 6px 8px; font-size: .9rem; }
.rep-table tr { cursor: pointer; }
.rep-table tr:hover { background: var(--surface-2); }
.quick-log { display: flex; gap: 4px; }
.quick-log input { width: 64px; min-height: 34px; padding: 4px 6px; }
input[type=range] { padding: 0; min-height: 30px; accent-color: var(--accent); }

/* ---------- client page ---------- */
.client-head { background: #111; color: #fff; padding: calc(env(safe-area-inset-top) + 14px) 16px 14px; font-weight: 800; font-size: 1.1rem; }
.client-head .wrap-c, .client-wrap { max-width: 900px; margin: 0 auto; }
.client-wrap { display: flex; flex-direction: column; gap: 16px; }
.client-hero h1 { font-size: 1.8rem; margin: 6px 0 10px; }
.client-pct { margin-bottom: 8px; color: var(--muted); font-weight: 600; }
.client-pct span { font-size: 2.4rem; font-weight: 800; color: var(--text); }
.client-steps { display: flex; flex-direction: column; margin-top: 10px; }
.cstep { display: flex; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border); }
.cstep:last-child { border-bottom: 0; }
.cstep .dot { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; border: 3px solid var(--border); font-weight: 800; flex: none; }
.cstep.done .dot { background: var(--ok); border-color: var(--ok); color: #fff; }
.cstep.now .dot { border-color: var(--accent); color: var(--accent); }
.client-gallery { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); margin-top: 10px; }
.progress.sm { height: 6px; margin-top: 6px; }
.cdot-key { margin: 4px 0 10px; display: flex; flex-wrap: wrap; gap: 4px 6px; align-items: center; }
.cdot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--border); background: transparent; flex: none; }
.cdot.done { background: var(--ok); border-color: var(--ok); }
.cdot.now { background: var(--accent); border-color: var(--accent); }
.cdots { display: inline-flex; gap: 5px; flex-wrap: wrap; justify-content: flex-end; }
.cgroup { border-top: 1px solid var(--border); }
.cgroup > summary { display: flex; gap: 12px; align-items: center; padding: 12px 0; cursor: pointer; list-style: none; }
.cgroup > summary::-webkit-details-marker { display: none; }
.cgroup > summary::before { content: '▸'; color: var(--muted); transition: transform .15s; }
.cgroup[open] > summary::before { transform: rotate(90deg); }
.cgroup-bar { width: 120px; flex: none; }
.cgroup-body { padding: 0 0 12px 22px; }
.cpiece { display: flex; gap: 12px; align-items: center; padding: 7px 0; border-bottom: 1px dashed var(--border); }
.cpiece:last-of-type { border-bottom: 0; }
.client-thumbs { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
@media (max-width: 560px) { .cgroup-bar { width: 70px; } }

/* ---------- prop specs ---------- */
fieldset.specs { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; margin: 0; display: flex; flex-direction: column; gap: 12px; }
fieldset.specs legend { font-weight: 800; padding: 0 6px; }
.dims { display: flex; gap: 6px; align-items: center; }
.dims input { min-width: 0; flex: 1; }
.dims select { width: auto; flex: none; }
.color-row { display: grid; grid-template-columns: 44px 1.4fr 1fr auto; gap: 6px; align-items: center; }
.color-row input[type=color] { width: 44px; height: 44px; padding: 2px; }
.color-row input[type=color][data-unset] { opacity: .35; }
.spec-box { border: 1px solid var(--border); border-left: 5px solid var(--accent); border-radius: 10px; padding: 10px 12px; background: var(--surface-2); display: flex; flex-direction: column; gap: 10px; }
.spec-grid { display: grid; grid-template-columns: 90px 1fr; gap: 6px 12px; font-size: .92rem; }
.spec-grid .k { font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; font-weight: 800; color: var(--muted); padding-top: 3px; }
.color-chip { display: inline-flex; align-items: center; gap: 6px; margin: 0 10px 4px 0; }
.color-chip i, .dot-swatch { display: inline-block; width: 16px; height: 16px; border-radius: 4px; border: 1px solid rgba(0,0,0,.2); vertical-align: middle; }
.dot-swatch { width: 10px; height: 10px; border-radius: 50%; margin-right: 2px; }
.ref-strip { display: flex; gap: 8px; flex-wrap: wrap; }
.ref-strip img { width: 110px; height: 82px; object-fit: cover; border-radius: 8px; cursor: zoom-in; border: 1px solid var(--border); }
.ref-thumb { position: relative; }
.ref-thumb button { position: absolute; top: 4px; right: 4px; min-height: 26px; padding: 2px 7px; }
.who-select { min-height: 36px; padding: 4px 8px; }
@media (max-width: 640px) { .color-row { grid-template-columns: 44px 1fr auto; } .color-row [data-c=area] { grid-column: 2 / 3; } }

/* ---------- production steps ---------- */
.steps { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 4px 16px; }
.step-row { display: flex; align-items: center; gap: 8px; padding: 4px 0; }
.step-row .check { flex: 1; min-width: 0; }
.step-row [data-hours] { width: 74px; min-height: 38px; padding: 6px 8px; }
.step-row [data-name] { min-width: 0; }
.step-row select[data-dept] { width: auto; max-width: 140px; min-height: 38px; padding: 6px; }
fieldset.specs legend .check { font-weight: 800; }

/* ---------- capacity ---------- */
.cap-wrap { max-height: calc(100vh - 240px); }
table.cap { border-collapse: separate; border-spacing: 0; }
table.cap th, table.cap td { border-bottom: 1px solid var(--border); }
.cap-name { position: sticky; left: 0; background: var(--surface); z-index: 2; min-width: 170px; }
table.cap thead th { position: sticky; top: 0; z-index: 3; }
table.cap thead .cap-name { z-index: 4; background: var(--surface-2); }
.cap-day { text-align: center; font-size: .72rem; min-width: 46px; padding: 6px 4px; text-transform: none; letter-spacing: 0; }
.cap-day strong { font-size: .95rem; color: var(--text); }
.cap-cell { text-align: center; font-weight: 800; font-size: .9rem; padding: 10px 4px; border-left: 1px solid var(--border); }
.cap-cell[data-cell] { cursor: pointer; }
.cap-cell.ok { background: var(--ok-bg); color: var(--ok); }
.cap-cell.full { background: var(--warn-bg); color: var(--warn); }
.cap-cell.over { background: var(--bad-bg); color: var(--bad); }
.cap-cell.unassigned { background: var(--surface-2); color: var(--muted); }

/* ---------- hover cards ---------- */
#hovertip { position: fixed; z-index: 80; max-width: 340px; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; box-shadow: 0 12px 32px rgba(15, 23, 42, .22); font-size: .85rem; pointer-events: none; display: flex; flex-direction: column; gap: 4px; }
#hovertip .tip-head { display: flex; align-items: center; gap: 6px; }
#hovertip .tip-title { font-weight: 800; font-size: .95rem; }
#hovertip .tip-row { display: grid; grid-template-columns: 82px 1fr; gap: 8px; }
#hovertip .tip-row > span { color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; font-weight: 800; padding-top: 2px; }
#hovertip .tip-warn { color: var(--warn); font-weight: 700; }
#hovertip .tip-foot { color: var(--muted); font-size: .75rem; border-top: 1px solid var(--border); padding-top: 6px; margin-top: 2px; }

/* ---------- costs ---------- */
.ok-text { color: var(--ok); }
.warn-text { color: var(--warn); }
.bad-text { color: var(--bad); }
table.cashflow tr.lowest td { background: var(--bad-bg); }
table.cashflow tr.past td { opacity: .6; }
.cash-bar { display: flex; flex-wrap: wrap; gap: 10px 12px; align-items: flex-end; padding: 0 14px 12px; }
.cash-bar .field { width: auto; margin: 0; }
.cash-bar input { width: 160px; }
.cash-bar .grow { flex: 1 1 260px; }
.rates { display: flex; flex-direction: column; gap: 6px; }
.rate-row { display: grid; grid-template-columns: 1fr 90px 100px auto; gap: 8px; align-items: center; }
.rate-row input { min-height: 38px; padding: 6px 8px; text-align: right; }
@media (max-width: 480px) { .rate-row { grid-template-columns: minmax(0, 1fr) 80px 90px; } .rate-row .check { grid-column: 1 / -1; } }
.cost-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.cost-grid > div { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 10px; display: flex; flex-direction: column; }
.cost-grid span { font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; font-weight: 800; color: var(--muted); }
.cost-grid strong { font-size: 1.2rem; }
.cost-grid em { font-style: normal; font-size: .78rem; color: var(--muted); }
.fin-table td { padding: 4px; }
.fin-table input { min-height: 38px; padding: 6px 8px; }
.tgroups { overflow: hidden; }
.tgroup + .tgroup { border-top: 1px solid var(--border); }
.tgroup > summary { display: flex; align-items: center; gap: 8px; padding: 10px 14px; cursor: pointer; list-style: none; }
.tgroup > summary::-webkit-details-marker { display: none; }
.tgroup > summary::before { content: '▸'; color: var(--muted); transition: transform .15s; }
.tgroup[open] > summary::before { transform: rotate(90deg); }
.tgroup > div .task-row { padding-left: 34px; }
.oneoff-text { color: #8322d5; font-weight: 600; }
@media (prefers-color-scheme: dark) { .oneoff-text { color: #c084fc; } }
.oneoff-card { border-left: 5px solid #8322d5; }
.proj-gantt { --label: 150px; border-top: 1px solid var(--border); }
/* Scrolls both ways inside the card, dates pinned at the top and prop names on the left; drag the bottom
   corner to make it taller. Smaller text and bars to fit more. */
.proj-gantt .g-scroll { max-height: 70vh; min-height: 160px; overflow: auto; resize: vertical; }
.proj-gantt.tall .g-scroll { max-height: none; height: auto !important; }
.proj-gantt .g-bar { height: 19px; font-size: .68rem; border-radius: 5px; touch-action: pan-x pan-y; }
.proj-gantt .g-bar .g-text { padding: 0 5px; }
.proj-gantt .g-label { font-size: .72rem; padding: 4px 8px; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; }
.proj-gantt .g-day { font-size: .68rem; }
.prop-list { width: 100%; table-layout: fixed; }
.prop-list th, .prop-list td { vertical-align: top; overflow-wrap: anywhere; }
.prop-list td { padding-top: 8px; padding-bottom: 8px; }
.prop-list .spec-lines div { margin-bottom: 2px; }
.prop-list .pl-dept { display: flex; align-items: center; gap: 5px; margin: 4px 0 3px; font-size: .72rem; }
.prop-list .pl-dept:first-child { margin-top: 0; }
.prop-list .chip-task { display: flex; width: 100%; justify-content: space-between; margin: 0 0 4px; min-height: 26px; padding: 3px 7px; font-size: .74rem; }
.prop-list .chip-task span { white-space: nowrap; }
.prop-list .badge { margin: 0 2px 3px 0; white-space: normal; }
.prop-list .ref-mini { display: flex; gap: 4px; flex-wrap: wrap; }
.prop-list .ref-mini img, .prop-list .ref-mini .pdf-tile { width: 64px; height: 64px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); cursor: zoom-in; background: var(--surface-2); }
.pdf-tile { display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; width: 90px; height: 90px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2); text-decoration: none; color: var(--text); font-size: 1.6rem; overflow: hidden; }
.pdf-tile span { font-size: .62rem; font-weight: 700; max-width: 100%; padding: 0 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prop-list .ref-mini .pdf-tile { font-size: 1.3rem; cursor: pointer; }
.prop-list tfoot td { font-weight: 700; background: var(--surface-2); border-top: 2px solid var(--border); }
/* Narrow screens (iPad portrait, phones): each prop becomes a card instead of a wide row. */
@media (max-width: 900px) {
  .prop-list colgroup, .prop-list thead { display: none; }
  .prop-list, .prop-list tbody, .prop-list tfoot, .prop-list tr, .prop-list td { display: block; width: 100%; }
  .prop-list tr { border-bottom: 1px solid var(--border); padding: 6px 12px; }
  .prop-list td { border: 0; padding: 4px 0; }
  .prop-list td:first-child { display: none; }
  .prop-list td.num { text-align: left; }
}
@media print { .prop-list .chip-task span { display: inline; } }
.tstep .progress { width: 80%; height: 5px; }
/* ---------- order list ---------- */
.order-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.order-grid .grow2 { grid-column: span 2; }
@media (max-width: 560px) { .order-grid .grow2 { grid-column: auto; } }
table.orders td { vertical-align: top; }
table.orders td.pick { width: 34px; }
table.orders td.pick input { width: 22px; height: 22px; }
table.orders .actions-cell { text-align: right; }
table.orders tr.muted-row td { opacity: .6; }
/* availability check on the task form */
.avail { border-radius: 10px; padding: 10px 12px; font-size: .88rem; line-height: 1.45; border: 1px solid var(--border); }
.avail.ok { background: var(--ok-bg); border-color: transparent; }
.avail.warn { background: var(--warn-bg); border-color: transparent; }
.avail.info { background: var(--surface-2); }
.avail-list .row { padding: 4px 0; border-bottom: 1px dashed var(--border); }
.avail-list .row:last-child { border-bottom: 0; }
.stage-work { margin-bottom: 14px; }
.stage-work .task-row.stage-task { width: 100%; border: 0; background: transparent; font: inherit; color: inherit; text-align: left; cursor: pointer; }
.stage-work details summary { cursor: pointer; margin: 4px 0; }
/* progress photos on a prop */
.pp-strip { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.pp-thumb { margin: 0; width: 120px; }
.pp-thumb img { width: 120px; height: 90px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); cursor: zoom-in; display: block; }
.pp-thumb figcaption { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; margin-top: 4px; }
.pp-thumb .shared-tag { position: static; }
.cpiece-photo { flex: none; }
.cpiece-photo figure { margin: 0; }
.cpiece-photo img { width: 44px; height: 44px; object-fit: cover; border-radius: 6px; cursor: zoom-in; display: block; }
.cpiece-photo figcaption { display: none; }
.grp-name { font-weight: 800; text-transform: inherit; letter-spacing: inherit; color: inherit; }
.wi-options { display: flex; flex-direction: column; gap: 8px; }
.wi-option { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; display: flex; flex-direction: column; gap: 4px; }
.wi-option.ok { border-color: var(--ok); background: var(--ok-bg); }
.pw-row { display: flex; gap: 6px; align-items: center; } .pw-row input { flex: 1; font-size: 1.15rem; }
/* timesheets */
.ts-period { flex-wrap: wrap; align-items: center; }
.ts-table { width: 100%; }
.ts-table td { vertical-align: top; padding: 8px 14px; border-top: 1px solid var(--border); }
.ts-day { width: 150px; }
.ts-total { width: 80px; }
.ts-entry { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-bottom: 6px; }
.ts-entry input[name=hours] { width: 80px; }
.ts-entry select { width: auto; max-width: 220px; }
.ts-entry input[name=note] { flex: 1 1 140px; min-width: 120px; }
.ts-add input, .ts-add select { opacity: .85; }
tr.ts-today td { background: var(--info-bg); }
tr.ts-future td { opacity: .55; }
.ts-team th.ts-today, .ts-team td.ts-today { background: var(--info-bg); }
.ts-team td, .ts-team th { padding-left: 6px; padding-right: 6px; }
/* the timer banner, at the very top of every screen, above the menu */
#top-stack { position: sticky; top: 0; z-index: 20; }
#top-stack #topbar { position: static; }
#timer-bar:not([hidden]) + #topbar { padding-top: 8px; }
#timer-bar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; padding: calc(env(safe-area-inset-top) + 10px) 16px 10px; background: #1e40af; color: #fff; font-size: 1.05rem; line-height: 1.35; }
#timer-bar a { color: #fff; font-weight: 800; text-decoration: underline; text-underline-offset: 3px; }
#timer-bar .tb-line { display: block; }
#timer-bar .tb-proj { opacity: .9; font-size: .95rem; }
#timer-bar .tb-note { display: block; font-size: .88rem; opacity: .92; margin-top: 2px; }
#timer-bar .tb-time { font-size: 1.7rem; font-variant-numeric: tabular-nums; letter-spacing: .02em; margin-right: 6px; }
#timer-bar .tb-tag { display: inline-block; font-size: .72rem; font-weight: 800; letter-spacing: .08em; padding: 2px 8px; border-radius: 999px; background: #fff; color: #15803d; vertical-align: middle; margin-right: 6px; }
#timer-bar .tb-accrued { font-weight: 800; }
#timer-bar .tb-dot { width: 14px; height: 14px; border-radius: 50%; background: #fff; animation: tbpulse 1s infinite; flex: none; }
#timer-bar.running { background: #15803d; box-shadow: 0 2px 10px rgba(21, 128, 61, .45); }
#timer-bar.running.stale { background: #7f1d1d; }
#timer-bar.paused { background: #b45309; }
#timer-bar.next { background: #1e40af; }
#timer-bar.clock { background: #0f766e; font-size: .95rem; }
#timer-bar.lunch { background: #7c3aed; }
#timer-bar.warn { background: #b45309; }
#timer-bar.bad { background: #7f1d1d; }
#timer-bar .btn { background: #fff; color: #111; border-color: transparent; font-weight: 800; }
#timer-bar .btn.ok { background: #16a34a; color: #fff; }
#timer-bar.running .btn.ok { background: #fff; color: #15803d; box-shadow: inset 0 0 0 2px #fff, 0 0 0 2px rgba(255,255,255,.5); }
@keyframes tbpulse { 50% { opacity: .25; } }
@media print { #timer-bar { display: none !important; } }
@media (max-width: 700px) {
  #timer-bar .tb-time { font-size: 1.35rem; } #timer-bar { font-size: .95rem; gap: 6px 8px; padding-bottom: 8px; }
  /* phones: keep the banner short; the note and clock buttons live on the time clock */
  #timer-bar .tb-note, #timer-bar .tb-clockbtn, #timer-bar .tb-clock, #timer-bar .tb-proj, #timer-bar .tb-tag { display: none; }
  #timer-bar .tb-line { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: calc(100vw - 32px); }
  #timer-bar .btn { padding: 6px 10px; }
}
#timer-bar.info { background: #1e40af; }
#timer-bar .tb-clock { margin-left: 10px; font-weight: 600; }
#timer-bar .tb-x { background: transparent; color: #fff; }
.cap-cell.cap-off { background: var(--surface-2); color: var(--muted); }

/* timer: time left against the estimate */
.tb-est { display: inline-flex; align-items: center; gap: 6px; margin-left: 6px; padding: 1px 8px; border-radius: 999px; background: rgba(255,255,255,.18); font-weight: 700; font-size: .82rem; white-space: nowrap; }
.tb-est.near { background: #f59e0b; color: #1f1300; }
.tb-est.over { background: #fff; color: #b91c1c; }
.tb-meter { width: 46px; height: 6px; border-radius: 3px; background: rgba(255,255,255,.35); overflow: hidden; display: inline-block; }
.tb-meter span { display: block; height: 100%; background: currentColor; }

/* task popup: time entries */
.task-logs summary { cursor: pointer; padding: 6px 0; }
table.tight { width: 100%; border-collapse: collapse; font-size: .86rem; }
table.tight td { padding: 4px 6px; border-top: 1px solid var(--border); }
table.tight td.num { text-align: right; font-weight: 700; white-space: nowrap; }

/* My Tasks: time accrued on the task being timed */
.mt-accrued { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 10px; padding: 12px 14px; border-radius: 10px; background: #fef2f2; border: 2px solid #dc2626; color: #7f1d1d; }
.mt-accrued.paused { background: #fffbeb; border-color: #d97706; color: #78350f; }
.mt-accrued .big { font-size: 1.35rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.task-row .accrued-live { color: #dc2626; font-weight: 800; }

/* project schedule: smaller, draggable; capacity grid with this job's share */
.proj-gantt .g-bar { font-size: .64rem; }
.proj-gantt .g-bar.editable { cursor: grab; }
.proj-gantt .g-label .dept-dot { width: 8px; height: 8px; }
table.proj-cap td.cap-cell { font-size: .78rem; white-space: nowrap; }
/* main schedule: smaller text in the Departments and People views */
.gantt.compact .g-label { font-size: .8rem; }
.gantt.compact .g-label .small { font-size: .7rem; }
.gantt.compact .g-bar { font-size: .7rem; }

table.punches td { padding: 6px 8px; font-size: .95rem; }
.ts-punches { font-size: .8rem; color: var(--muted); width: 100%; }

/* timesheet: paid clock time, then the task time inside it */
.ts-paid-label { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-bottom: 2px; }
.ts-breakdown { margin-top: 6px; font-size: .85rem; }
.ts-breakdown summary { cursor: pointer; }
.ts-breakdown .dept-dot { width: 8px; height: 8px; }

.pick-list { max-height: 60vh; overflow: auto; }
.pick-list .task-row { cursor: pointer; }

.tip-tasks { margin-top: 6px; border-top: 1px solid var(--border); padding-top: 6px; font-size: .8rem; line-height: 1.45; }
.tip-sub { font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }

/* "How to fix" recommendations for a late project */
.fix-rec { display: flex; gap: 12px; align-items: center; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; }
.fix-rec.ok { border-color: color-mix(in srgb, var(--ok) 55%, var(--border)); background: color-mix(in srgb, var(--ok) 6%, transparent); }
.fix-icon { font-size: 1.3rem; width: 28px; text-align: center; flex: none; }
.btn.fix-btn { padding: 1px 7px; font-size: .72rem; min-height: 0; margin-top: 3px; }
.danger-text { color: var(--bad) !important; }

.badge.wait { background: #fff7ed; color: #9a3412; border: 1px solid #fdba74; }
.wait-box [hidden] { display: none !important; }

/* projects list */
.late-line { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; font-size: .9rem; padding: 6px 10px; border-radius: 8px; }
.late-line.bad { background: color-mix(in srgb, var(--bad) 10%, transparent); color: var(--bad); }
.late-line.warn { background: color-mix(in srgb, var(--warn) 12%, transparent); color: #92400e; }
.late-line .fix-btn { margin-top: 0; }
.chip-att { display: inline-block; font-size: .74rem; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text); white-space: nowrap; }
.chip-att.bad { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, var(--border)); }
.chip-filter { border: 1px solid var(--border); background: var(--surface); border-radius: 999px; padding: 6px 12px; font-weight: 600; font-size: .85rem; cursor: pointer; color: var(--text); }
.chip-filter.active { background: #1e293b; color: #fff; border-color: #1e293b; }
.chip-filter .n { opacity: .65; font-weight: 700; margin-left: 2px; }
.plist-table tr[data-href] { cursor: pointer; }
.plist-table td { vertical-align: top; }

#toast .toast-undo { margin-left: 10px; background: #fff; color: #0f172a; border: 0; }

/* cash flow chart: money in / money out bars, net line (one $ scale) */
.cash-chart { position: relative; padding: 4px 14px 10px; --cc-in: #2a78d6; --cc-out: #eb6834; --cc-net: #1baf7a; }
.cash-chart svg { width: 100%; height: 280px; display: block; }
.cc-legend { display: flex; gap: 16px; font-size: .8rem; color: var(--muted); padding: 6px 0; }
.cash-chart .sw { display: inline-block; width: 12px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.sw.in { background: var(--cc-in); } .sw.out { background: var(--cc-out); } .sw.net { background: var(--cc-net); height: 3px; vertical-align: 3px; }
.cc-in { fill: var(--cc-in); } .cc-out { fill: var(--cc-out); }
.cc-net { fill: none; stroke: var(--cc-net); stroke-width: 2; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.cc-dot { fill: var(--cc-net); stroke: var(--surface); stroke-width: 2; vector-effect: non-scaling-stroke; }
.cc-grid { stroke: var(--border); stroke-width: 1; vector-effect: non-scaling-stroke; }
.cc-grid.zero { stroke: var(--muted); }
.cc-axis { font-size: 11px; fill: var(--muted); }
.cc-hit { fill: transparent; cursor: default; }
.cc-hit.on { fill: rgba(127, 127, 127, .08); }
.cc-tip { position: absolute; top: 34px; width: 180px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); padding: 8px 10px; font-size: .8rem; pointer-events: none; z-index: 5; }
.cc-tip div { display: flex; align-items: center; gap: 4px; } .cc-tip b { margin-left: auto; }
@media print { .cc-tip { display: none; } }

.budget-table { width: 100%; max-width: 640px; margin-top: 10px; }
.budget-table input.num { text-align: right; }
.budget-table .bg-sum td { border-top: 2px solid var(--border); font-size: 1rem; padding-top: 8px; }

/* The cash flow fits the page: tighter cells, headings and breakdown labels wrap; on phones each period is a card. */
table.cashflow { font-size: .86rem; }
table.cashflow th { white-space: normal; padding: 8px 6px; vertical-align: bottom; }
table.cashflow td { padding: 8px 6px; vertical-align: top; }
table.cashflow td.num { white-space: normal; }
.cashflow .fixed-line { display: flex; justify-content: space-between; gap: 6px; text-align: left; }
.cashflow .fixed-line > span:first-child { min-width: 0; overflow-wrap: anywhere; }
.cashflow .fixed-line > span:last-child { white-space: nowrap; }
@media (max-width: 760px) {
  table.cashflow thead { display: none; }
  table.cashflow, table.cashflow tbody, table.cashflow tr, table.cashflow td { display: block; width: 100%; }
  table.cashflow tr { border-bottom: 2px solid var(--border); padding: 6px 0; }
  table.cashflow td { border: 0; padding: 3px 12px; text-align: right; }
  table.cashflow td:first-child { text-align: left; font-weight: 800; font-size: 1rem; }
  table.cashflow td[data-label]:not(:first-child)::before { content: attr(data-label); float: left; color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; padding-top: 2px; }
  table.cashflow td .fixed-line { clear: both; }
}

.cashflow td.hover-detail { cursor: pointer; }
.cashflow td.hover-detail:hover { background: var(--surface-2); }
.cell-tip { position: fixed; z-index: 70; min-width: 200px; max-width: min(320px, 92vw); background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 8px 24px rgba(15, 23, 42, .18); padding: 8px 10px; font-size: .82rem; pointer-events: none; }
.cell-tip strong { display: block; margin-bottom: 4px; }
.cell-tip div { display: flex; justify-content: space-between; gap: 12px; padding: 1px 0; }
.cell-tip b { white-space: nowrap; }
.cell-tip .sub { padding-left: 12px; color: var(--muted); }
.cell-tip .gap { height: 6px; }
@media print { .cell-tip { display: none; } }

/* Cash flow What if… */
.wi-grid { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 800px) { .wi-grid { grid-template-columns: minmax(0, 1fr); } }
.wi-row { display: flex; align-items: flex-start; gap: 8px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px; line-height: 2; cursor: pointer; }
.wi-row .grow { min-width: 0; }
.wi-row select { max-width: 100%; }
.wi-row.on { border-color: var(--primary); background: var(--surface-2); }
.wi-row > input[type=checkbox] { margin-top: 10px; width: 18px; height: 18px; flex: none; }
.wi-row select, .wi-row input:not([type=checkbox]) { min-height: 32px; padding: 4px 6px; }
.wi-icon { font-size: 1.1rem; }
.wi-ask { display: flex; flex-direction: column; gap: 6px; padding: 10px 12px; border: 1px dashed var(--border); border-radius: 10px; background: var(--surface-2); }
.wi-ask textarea { resize: vertical; }
.wi-line { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin: 4px 0; }
#wi-out { position: sticky; top: 0; background: var(--surface); }
.wi-answer { margin-top: 6px; padding: 10px 12px; border-radius: 10px; background: var(--surface); border: 1px solid var(--border); font-size: .92rem; }
.wi-answer p { margin: 0 0 8px; } .wi-answer p:last-child { margin-bottom: 0; } .wi-answer ul { margin: 0 0 8px; padding-left: 20px; }

/* Projects: where the props are (cards) and the department grid (list) */
.pf-bar { display: flex; gap: 2px; height: 10px; border-radius: 5px; overflow: hidden; background: var(--surface-2); margin: 6px 0 4px; }
.pf-seg { background: var(--c); min-width: 3px; }
.pf-seg.done, .pf-done-dot { background: #475569; }
.pf-seg.wait { opacity: .35; }
.pf-line { line-height: 1.6; }
table.pgrid th.pg-head { white-space: normal; font-size: .7rem; min-width: 64px; max-width: 96px; text-align: center; }
table.pgrid td.pg-cell { text-align: center; background: color-mix(in srgb, var(--c) var(--a), transparent); border-left: 2px solid var(--surface); min-width: 56px; }
table.pgrid td.pg-cell .small { color: var(--text); opacity: .8; }

/* Staff invite code */
.invite-code { font-family: ui-monospace, Menlo, monospace; font-size: 2rem; font-weight: 800; letter-spacing: .18em; text-align: center; padding: 12px; border: 2px dashed var(--border); border-radius: 12px; background: var(--surface-2); }

/* Cash flow: Available now (opening balance + received - posted) and ☑ posted lines */
.avail-now { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; margin: 10px 0; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface-2); }
.avail-num { display: flex; flex-direction: column; min-width: 150px; }
.avail-num span { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; }
.avail-num strong { font-size: 1.6rem; }
.to-post { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 4px; }
.cashflow label.fixed-line { cursor: pointer; }
.cashflow .fixed-line input[type=checkbox] { width: 14px; height: 14px; vertical-align: -2px; margin: 0 2px 0 0; }
.cashflow .fixed-line.posted { opacity: 1; color: var(--ok); }
.cashflow .avail-inline { margin-top: 4px; padding: 2px 6px; border-radius: 6px; background: var(--surface-2); white-space: nowrap; }

.cashflow .bal-sum { margin-top: 4px; padding-top: 4px; border-top: 1px dashed var(--border); }
.cashflow .bal-line { display: flex; justify-content: space-between; gap: 8px; white-space: nowrap; }

/* Cash flow table on wider screens: smaller text so the item lines fit their columns. */
@media (min-width: 761px) {
  table.cashflow { font-size: .78rem; line-height: 1.3; }
  table.cashflow th { font-size: .68rem; padding: 6px 5px; }
  table.cashflow td { padding: 6px 5px; }
  .cashflow .small, .cashflow .fixed-line { font-size: .7rem; }
  .cashflow .fixed-line { gap: 4px; margin-top: 1px; }
  .cashflow .fixed-line input[type=checkbox] { width: 12px; height: 12px; }
  .cashflow .avail-inline { padding: 1px 5px; }
  /* One line per item: long names end in … (hover shows the whole line). */
  .cashflow .fixed-line > span:first-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  /* Fixed column widths so the table always fits the page (no sideways scrolling). */
  table.cashflow { table-layout: fixed; width: 100%; }
  table.cashflow td { overflow: hidden; }
  table.cashflow th:nth-child(1) { width: 6%; }
  table.cashflow th:nth-child(2) { width: 9%; }
  table.cashflow th:nth-child(3) { width: 13%; }
  table.cashflow th:nth-child(4) { width: 11%; }
  table.cashflow th:nth-child(5) { width: 4%; }
  table.cashflow th:nth-child(6) { width: 14.5%; }
  table.cashflow th:nth-child(7) { width: 16.5%; }
  table.cashflow th:nth-child(8) { width: 11%; }
  table.cashflow th:nth-child(9) { width: 15%; }
  table.cashflow td .nowrap { white-space: normal; }
  .cashflow .bal-line { white-space: normal; }
  .cashflow .bal-line > span:first-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
  table.cashflow .avail-inline { white-space: normal; }
}

/* Received / bought state in a project's costs window: the whole pill is the tick box. */
.state-toggle { display: inline-flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 10px; border: 1.5px solid var(--border); background: var(--surface-2); cursor: pointer; min-width: 150px; line-height: 1.15; }
.state-toggle input[type=checkbox] { width: 20px; height: 20px; margin: 0; flex: none; cursor: pointer; accent-color: var(--ok); }
.state-toggle span { display: flex; flex-direction: column; }
.state-toggle strong { font-size: .9rem; }
.state-toggle small { font-size: .74rem; color: var(--muted); }
.state-toggle.on { background: var(--ok-bg, #dcfce7); border-color: var(--ok, #16a34a); }
.state-toggle.on strong { color: var(--ok, #16a34a); }
.state-toggle.bad { background: var(--bad-bg); border-color: var(--bad, #dc2626); }
.state-toggle.bad strong { color: var(--bad, #dc2626); }
.state-toggle.warn strong { color: var(--warn, #b45309); }
.state-toggle:hover { filter: brightness(.97); }

/* Payments and materials in a project's costs window: fit the window without scrolling sideways. */
.cost-rows { width: 100%; }
.cost-rows th { padding: 6px 4px; }
.cost-rows td { padding: 3px; }
.cost-rows input { width: 100%; min-width: 0; padding: 6px; }
.cost-rows input[type=date] { min-width: 118px; font-size: .85rem; }
.cost-rows td:first-child input { min-width: 90px; }
.cost-rows .state-toggle { min-width: 0; padding: 4px 8px; gap: 6px; }
.cost-rows .state-toggle strong { font-size: .82rem; white-space: nowrap; }
.cost-rows .state-toggle small { font-size: .7rem; }
.cost-rows .btn.sm { padding: 4px 8px; }
@media (max-width: 900px) {
  .cost-rows thead { display: none; }
  .cost-rows, .cost-rows tbody { display: block; }
  .cost-rows tr { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; padding: 8px 0; border-bottom: 1px solid var(--border); align-items: end; }
  .cost-rows td { display: block; padding: 0; border: 0; }
  .cost-rows td[data-label]:not([data-label=""])::before { content: attr(data-label); display: block; font-size: .7rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 2px; }
  .cost-rows input[type=date] { min-width: 0; }
  .cost-rows td:empty { display: none; }
}

.cashflow .bal-total { margin-top: 2px; padding-top: 2px; border-top: 1px solid var(--border); font-weight: 700; color: var(--text); }
.cashflow .bal-cleared { margin-top: 3px; padding: 1px 4px; border-radius: 4px; background: var(--ok-bg); color: var(--ok); font-weight: 600; }
.cashflow .fixed-group { display: flex; justify-content: space-between; gap: 6px; white-space: nowrap; text-align: left; margin-top: 5px; padding-bottom: 1px; border-bottom: 1px solid var(--border); font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.cashflow .fixed-group.oneoff-text { color: #8322d5; }
@media (prefers-color-scheme: dark) { .cashflow .fixed-group.oneoff-text { color: #c084fc; } }
.cashflow .bal-cleared-sum { margin-top: 6px; padding-top: 4px; border-top: 1px dashed var(--ok); }
.link-btn { background: none; border: 0; padding: 4px 0; color: var(--accent, #2563eb); text-decoration: underline; cursor: pointer; font: inherit; align-self: flex-start; }
.link-btn.small { font-size: .85rem; }

/* Picked items from a standard list (e.g. a prop's materials). */
.cat-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.cat-chips .chips { display: contents; }
.cat-chips .chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 4px 3px 10px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); font-size: .88rem; }
.cat-chips .chip.off-list { border-style: dashed; color: var(--muted); }
.cat-chips .chip button { background: none; border: 0; cursor: pointer; color: var(--muted); padding: 0 4px; font-size: .8rem; }
.cat-chips select { width: auto; min-width: 140px; }

/* Schedule → Today: what's due on one day. */
.day-list { list-style: none; margin: 0 0 14px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.day-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; }
.day-item[data-task] { cursor: pointer; }
.day-item[data-task]:hover { border-color: var(--accent); }
.day-item .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.day-item .grow { flex: 1; min-width: 0; }

/* Task window: what to do, when, and the prop's steps. */
.task-about { display: flex; flex-direction: column; gap: 8px; padding: 12px 14px; border-radius: 10px; background: var(--surface-2); border-left: 4px solid var(--accent); }
.task-about .k { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: 2px; }
.task-about .ta-text { white-space: normal; line-height: 1.4; }
.task-about .ta-text + .ta-text { margin-top: 6px; padding-top: 6px; border-top: 1px dashed var(--border); }
.ta-chain { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin-top: 4px; }
.ta-step { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); font-size: .78rem; }
.ta-step i { width: 7px; height: 7px; border-radius: 50%; }
.ta-step.done { color: var(--ok); }
.ta-step.me { border-color: var(--accent); font-weight: 700; box-shadow: 0 0 0 1px var(--accent); }

/* Props & tasks → Detailed: one card per prop, its tasks listed in order. */
.pd-list { padding: 0 14px 14px; display: flex; flex-direction: column; gap: 10px; }
.pd-group { margin: 8px 0 0; font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.pd-card { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--surface); }
.pd-head { padding: 10px 12px; background: var(--surface-2); align-items: flex-start; }
.pd-tasks { width: 100%; border-collapse: collapse; }
.pd-tasks th { font-size: .7rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); text-align: left; padding: 6px 12px; border-bottom: 1px solid var(--border); }
.pd-tasks td { padding: 8px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.pd-tasks tr:last-child td { border-bottom: 0; }
.pd-row { cursor: pointer; }
.pd-row:hover td { background: var(--surface-2); }
.pd-row.done td { color: var(--muted); }
.prop-list .chip-task { flex-direction: row; align-items: center; }
.chip-task > span { background: var(--border); border-radius: 999px; padding: 0 5px; font-size: .68rem; }

/* Assign tasks: the tasks that will be given out, by prop. */
.assign-list { max-height: 320px; overflow-y: auto; border: 1px solid var(--border); border-radius: 10px; padding: 4px 10px 8px; }
.assign-list .al-prop { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 8px 0 2px; }
.assign-list .al-row { display: flex; align-items: center; gap: 10px; padding: 5px 0; border-bottom: 1px solid var(--border); cursor: pointer; }
.assign-list .al-row:last-child { border-bottom: 0; }
.pd-what { color: var(--muted); max-width: 46ch; white-space: pre-line; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin-top: 2px; }

.chip-task.sent-back { border-color: var(--bad); }

/* Mid-size screens (iPad landscape, small laptops): the top menu wraps instead of hiding links off the edge. */
@media (min-width: 761px) and (max-width: 1280px) {
  #nav { flex-wrap: wrap; overflow: visible; row-gap: 2px; }
  #nav a { padding: 7px 9px; font-size: .9rem; }
  #topbar { gap: 10px; }
}
/* Small laptops / iPad landscape: logo only and tighter links, so the whole menu fits on one line. */
@media (min-width: 761px) and (max-width: 1150px) {
  #shop-name { display: none; }
  #nav { gap: 2px; }
  #nav a { padding: 7px 7px; font-size: .86rem; }
}
/* Costs → Projects table: fits at 1024 wide (the client column goes first). */
table.cost-projects { font-size: .86rem; }
table.cost-projects th, table.cost-projects td { padding: 8px 6px; }
@media (max-width: 1200px) { table.cost-projects th:nth-child(2), table.cost-projects td:nth-child(2) { display: none; } }

/* Dashboard projects table at 1024 wide: drop Priority and Est. finish, and let "Who needs to act" wrap. */
table.dash-projects td:last-child { min-width: 160px; white-space: normal; }
@media (max-width: 1200px) {
  table.dash-projects th:nth-child(2), table.dash-projects td:nth-child(2),
  table.dash-projects th:nth-child(6), table.dash-projects td:nth-child(6) { display: none; }
  table.dash-projects th, table.dash-projects td { padding-left: 6px; padding-right: 6px; }
}
/* Orders at 1024 wide: "Added by" (col 8) goes; the order log keeps it. */
@media (max-width: 1200px) {
  table.orders th:nth-child(8), table.orders td:nth-child(8) { display: none; }
  table.orders th, table.orders td { padding-left: 6px; padding-right: 6px; }
}
/* A colour with no swatch picked yet: the picker looks empty, not grey. */
.color-row input[type=color][data-unset] { opacity: .3; }
/* Timesheet on a phone: date and total on one line, the day's entries full width beneath. */
@media (max-width: 600px) {
  .ts-table tr { display: grid; grid-template-columns: 1fr auto; border-top: 1px solid var(--border); }
  .ts-table td { border-top: 0; padding: 6px 12px; }
  .ts-table .ts-day { width: auto; grid-column: 1; grid-row: 1; }
  .ts-table .ts-total { width: auto; grid-column: 2; grid-row: 1; }
  .ts-table td:nth-child(2) { grid-column: 1 / -1; grid-row: 2; }
  .ts-table td:nth-child(2):empty { display: none; }
}
/* Costs page tiles: hover or tap for the breakdown behind each figure. */
.kb-tile { display: flex; flex-direction: column; justify-content: flex-start; }
.kb-tile .kb-i { color: var(--muted); font-size: .85em; }
.kb { display: flex; flex-direction: column; gap: 3px; min-width: 240px; }
.kb-head { font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; font-weight: 800; color: var(--muted); margin-top: 6px; }
.kb-line { display: flex; justify-content: space-between; gap: 14px; }
.kb-line strong { white-space: nowrap; font-variant-numeric: tabular-nums; }
.kb-line.kb-total { border-top: 1px solid var(--border); padding-top: 4px; margin-top: 2px; }
.kb-note { font-size: .8rem; color: var(--muted); margin-top: 4px; }
.kb-note.warn-text { color: var(--warn); }
.kb-more { font-size: .75rem; color: var(--muted); }
.modal .kb-line[data-kb-proj] { cursor: pointer; padding: 6px 4px; border-radius: 6px; }
.modal .kb-line[data-kb-proj]:hover { background: var(--surface-2); }
.modal .kb { font-size: .95rem; }
/* A job's cost and payment boxes open their breakdown (hover or tap). */
.cost-grid .jb { cursor: pointer; }
.cost-grid .jb:hover { border-color: var(--accent, #6366f1); }
.cost-grid .jb > span::after { content: ' ⓘ'; color: var(--muted); }
.kb-job { font-weight: 800; margin-top: 6px; }
.modal .kb-job { cursor: pointer; }
.kb-line.kb-sub > span { padding-left: 12px; }
/* One-off charges already in the bank balance, folded away under the current ones. */
.oo-past { border-top: 1px solid var(--border); }
.oo-past > summary { cursor: pointer; padding: 10px 14px; }
.oo-past .fin-table input, .oo-past .fin-table select { opacity: .85; }
.cc-axis.cc-weekend { opacity: .55; }
.set-bal { margin-top: 8px; }
/* Cash flow by day: the last 7 days before the balance date, greyed out and read-only. */
table.cashflow tr.cf-history td { opacity: .5; background: var(--surface-2); color: var(--muted); }
table.cashflow tr.cf-history-head td { font-size: .7rem; text-transform: uppercase; letter-spacing: .05em; font-weight: 800; color: var(--muted); background: var(--surface-2); padding: 6px 8px; }
/* Cleared the bank: the tick, then the date it cleared. */
.clr-cell { display: inline-flex; align-items: center; gap: 6px; }
.clr-cell .clr-date { width: auto; padding: 4px 6px; font-size: .85rem; }
.cost-kind { min-width: 110px; }
/* A job's costs window: each materials & outside costs line on two rows, each box labelled, so nothing is squeezed
   or scrolls sideways: type, what, est. cost, due / actual cost, bought, status, cleared, buttons. */
@media (min-width: 761px) {
  .modal.wide:has(#mat-rows) { max-width: min(1100px, 96vw); }
  table.cost-rows:has(#mat-rows) thead { display: none; }
  table.cost-rows:has(#mat-rows), #mat-rows { display: block; }
  #mat-rows tr { display: grid; grid-template-columns: 150px minmax(0, 1fr) 140px 175px auto; gap: 8px 10px; padding: 10px 0; border-bottom: 1px solid var(--border); align-items: end; }
  #mat-rows td { display: block; padding: 0; border: 0; min-width: 0; }
  #mat-rows td[data-label]:not([data-label=""])::before { content: attr(data-label); display: block; font-size: .7rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 2px; }
  #mat-rows td:nth-child(-n+4) { grid-row: 1; }
  #mat-rows td:nth-child(n+5):nth-child(-n+8) { grid-row: 2; }
  #mat-rows td:nth-child(9) { grid-column: 5; grid-row: 1 / 3; align-self: center; white-space: nowrap; }
  #mat-rows .state-toggle { width: 100%; }
  #mat-rows .cost-kind, #mat-rows .mat-what select, #mat-rows .mat-what input { width: 100%; min-width: 0; }
  #mat-rows td:empty { display: none; }
}
}
/* Monthly costs marked N/A for a month: greyed out, amount struck through. */
.na-btn { font-size: .7rem; margin-left: 4px; opacity: .7; }
.na-line { color: var(--muted); opacity: .75; }
.spread-months { margin-top: 4px; width: auto; }
.step-over td { background: var(--bad-bg); }
