:root {
  --bg: #f4f6f8; --surface: #ffffff; --surface-2: #f8fafb; --border: #dfe4ea; --border-strong: #c5cdd6;
  --text: #17212b; --text-2: #4b5a6a; --text-3: #7a8896;
  --nav: #0d2b45; --nav-text: #c9d6e2; --nav-active: #ffffff;
  --accent: #0b6e83; --accent-hover: #095a6b; --accent-soft: #e0f0f4; --accent-text: #ffffff;
  --red: #c0392b; --red-soft: #fbe7e4; --amber: #b7791f; --amber-soft: #fcf1d9;
  --green: #1f7a4d; --green-soft: #def3e8; --blue: #2563eb; --blue-soft: #e3ecfd;
  --shadow: 0 1px 2px rgba(16, 32, 48, .06), 0 2px 8px rgba(16, 32, 48, .05);
  --shadow-lg: 0 12px 40px rgba(16, 32, 48, .22);
  --radius: 8px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1720; --surface: #17212c; --surface-2: #1c2834; --border: #2a3846; --border-strong: #3a4b5c;
    --text: #e6edf3; --text-2: #aab8c5; --text-3: #7d8d9c;
    --nav: #0a1a2a; --nav-text: #9fb2c4;
    --accent: #3aa7bd; --accent-hover: #52b8cc; --accent-soft: #14343c; --accent-text: #06222a;
    --red: #ef6f60; --red-soft: #3a1c19; --amber: #e2a94a; --amber-soft: #3a2d12;
    --green: #4cc38a; --green-soft: #12301f; --blue: #6c9bff; --blue-soft: #1a2a4a;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3); --shadow-lg: 0 12px 40px rgba(0, 0, 0, .6);
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 var(--font); -webkit-font-smoothing: antialiased; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 22px; font-weight: 650; letter-spacing: -.01em; }
h2 { font-size: 16px; font-weight: 650; }
h3 { font-size: 13px; font-weight: 650; text-transform: uppercase; letter-spacing: .04em; color: var(--text-2); }
a { color: var(--accent); text-decoration: none; } a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
[hidden] { display: none !important; }
.muted { color: var(--text-3); } .small { font-size: 12px; } .right { text-align: right; } .nowrap { white-space: nowrap; }
.grow { flex: 1; min-width: 0; } .row { display: flex; align-items: center; gap: 8px; } .row-wrap { flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 12px; }

/* ------------------------------------------------------------ shell */
.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.nav { background: var(--nav); color: var(--nav-text); padding: 16px 10px; display: flex; flex-direction: column; gap: 2px; position: sticky; top: 0; height: 100vh; overflow-y: auto; scrollbar-width: thin; }
.brand { color: #fff; font-weight: 700; font-size: 16px; padding: 4px 10px 16px; letter-spacing: .01em; }
.brand small { display: block; font-weight: 500; font-size: 11px; color: var(--nav-text); letter-spacing: .06em; text-transform: uppercase; margin-top: 2px; }
.nav a { color: var(--nav-text); padding: 6px 10px; border-radius: 6px; display: flex; align-items: center; gap: 10px; font-weight: 500; }
.nav a:hover { background: rgba(255, 255, 255, .07); text-decoration: none; }
.nav a.active { background: rgba(255, 255, 255, .13); color: var(--nav-active); }
.nav .count { margin-left: auto; background: var(--red); color: #fff; border-radius: 999px; font-size: 11px; padding: 0 7px; font-weight: 650; }
.nav > * { flex-shrink: 0; }
.nav .spacer { flex: 1; }
.nav .me { padding: 10px; border-top: 1px solid rgba(255, 255, 255, .12); margin-top: 8px; font-size: 13px; }
.nav .me b { color: #fff; display: block; font-weight: 600; }
.nav .me button { background: none; border: 0; color: var(--nav-text); padding: 0; cursor: pointer; font-size: 12px; margin-right: 12px; }
.nav .me button:hover { color: #fff; text-decoration: underline; }
.main { padding: 24px 28px 60px; min-width: 0; max-width: 1500px; }
.beta-banner { background: var(--amber-soft); color: var(--amber); border: 1px solid var(--amber); border-radius: 6px; padding: 6px 12px; margin-bottom: 16px; font-size: 13px; font-weight: 550; }
.beta-tag { display: inline-block; background: var(--amber-soft); color: var(--amber); border-radius: 4px; padding: 0 7px; font-size: 11px; font-weight: 700; letter-spacing: .06em; vertical-align: middle; margin-left: 6px; }
.page-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head .sub { color: var(--text-2); margin-top: 3px; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
@media (max-width: 860px) {
  .list-row { flex-wrap: wrap; row-gap: 6px; } .list-row .grow { flex-basis: 100%; }
  .shell { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }          /* the bar is as tall as its contents, whatever the page height */
  .main { padding: 16px 14px 50px; }
}

/* ------------------------------------------------------------ controls */
.btn { border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); border-radius: 6px; padding: 7px 13px; cursor: pointer; font-weight: 550; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.btn:hover { background: var(--surface-2); } .btn:disabled { opacity: .55; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); } .btn-primary:hover { background: var(--accent-hover); }
.btn-success { background: var(--green); border-color: var(--green); color: #fff; } .btn-success:hover { filter: brightness(1.1); }
.btn-danger { background: var(--red); border-color: var(--red); color: #fff; } .btn-danger:hover { filter: brightness(1.08); }
.btn-ghost { background: transparent; } .btn-sm { padding: 3px 9px; font-size: 12px; }
.icon-btn { background: none; border: 0; cursor: pointer; color: var(--text-2); font-size: 20px; line-height: 1; padding: 2px 8px; border-radius: 4px; } .icon-btn:hover { background: var(--surface-2); color: var(--text); }
input, select, textarea { background: var(--surface); border: 1px solid var(--border-strong); border-radius: 6px; padding: 6px 9px; width: 100%; }
textarea { resize: vertical; min-height: 64px; }
input[type=checkbox], input[type=radio] { width: auto; }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.field-label { font-size: 12px; font-weight: 600; color: var(--text-2); } .field-hint { font-size: 12px; color: var(--text-3); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; } .grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 14px; }
.check { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.search { max-width: 260px; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.tabs button { background: none; border: 0; padding: 8px 14px; cursor: pointer; color: var(--text-2); font-weight: 550; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ------------------------------------------------------------ cards, chips */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.card-head .count-badge { background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 0 8px; font-size: 12px; color: var(--text-2); }
.card-body { padding: 14px 16px; }
.empty { padding: 22px 16px; color: var(--text-3); text-align: center; }
.chip { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2); white-space: nowrap; }
.chip-red { background: var(--red-soft); color: var(--red); border-color: transparent; } .chip-amber { background: var(--amber-soft); color: var(--amber); border-color: transparent; }
.chip-green { background: var(--green-soft); color: var(--green); border-color: transparent; } .chip-blue { background: var(--blue-soft); color: var(--blue); border-color: transparent; }
.avatar { display: inline-flex; width: 24px; height: 24px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); align-items: center; justify-content: center; font-size: 10.5px; font-weight: 700; flex: none; }
.due { font-size: 12px; font-weight: 600; white-space: nowrap; }
.due-over { color: var(--red); } .due-today { color: var(--amber); } .due-soon { color: var(--blue); } .due-later { color: var(--text-3); font-weight: 500; }
.bar { display: inline-block; width: 90px; height: 7px; border-radius: 999px; background: var(--border); overflow: hidden; vertical-align: middle; }
.bar > span { display: block; height: 100%; background: var(--green); border-radius: 999px; }
.bar.warn > span { background: var(--amber); } .bar.bad > span { background: var(--red); } .bar.wide { width: 100%; height: 9px; }
.dot { display: inline-block; width: 11px; height: 11px; border-radius: 50%; background: var(--border-strong); }
.dot-green { background: #2fb36d; } .dot-yellow { background: #e9b429; } .dot-red { background: #d9483b; } .dot-na { background: var(--border-strong); }
button.dot { border: 0; padding: 0; cursor: pointer; }
.form-error { background: var(--red-soft); color: var(--red); border-radius: 6px; padding: 8px 12px; margin-top: 8px; font-weight: 550; }
.notice { background: var(--amber-soft); color: var(--amber); border-radius: 6px; padding: 8px 12px; font-weight: 550; margin-bottom: 12px; }
.notice.info { background: var(--accent-soft); color: var(--accent); }

/* ------------------------------------------------------------ lists / tables */
.list-row { display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--border); cursor: pointer; }
.list-row:last-child { border-bottom: 0; } .list-row:hover { background: var(--surface-2); }
.list-row .title { font-weight: 600; } .list-row .meta { color: var(--text-2); font-size: 13px; }
table.t { width: 100%; border-collapse: collapse; }
table.t th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-2); padding: 8px 12px; border-bottom: 1px solid var(--border); background: var(--surface-2); font-weight: 650; white-space: nowrap; }
table.t td { padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.t tr:last-child td { border-bottom: 0; }
table.t tbody tr.click { cursor: pointer; } table.t tbody tr.click:hover { background: var(--surface-2); }
.scroll-x { overflow-x: auto; }
.two-col { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 18px; align-items: start; }
@media (max-width: 1100px) { .two-col { grid-template-columns: 1fr; } }

/* ------------------------------------------------------------ kanban */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(250px, 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); min-height: 140px; display: flex; flex-direction: column; }
.col.drop { outline: 2px dashed var(--accent); outline-offset: -2px; background: var(--accent-soft); }
.col-head { padding: 10px 12px 8px; display: flex; align-items: baseline; gap: 8px; }
.col-head b { font-size: 13px; } .col-head .sum { margin-left: auto; font-size: 12px; color: var(--text-2); }
.col-body { padding: 0 8px 8px; display: flex; flex-direction: column; gap: 8px; }
.deal { background: var(--surface); border: 1px solid var(--border); border-radius: 7px; padding: 10px 11px; cursor: pointer; box-shadow: var(--shadow); }
.deal:hover { border-color: var(--accent); } .deal.dragging { opacity: .45; }
.deal .co { font-weight: 650; } .deal .svc { color: var(--text-2); font-size: 13px; margin: 1px 0 6px; }
.deal .next { display: flex; gap: 8px; align-items: baseline; justify-content: space-between; font-size: 12.5px; border-top: 1px solid var(--border); margin-top: 8px; padding-top: 7px; }
.deal .next span:first-child { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.deal .foot { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.deal.alert { border-left: 3px solid var(--red); }

/* ------------------------------------------------------------ drawer */
.drawer-wrap { position: fixed; inset: 0; background: rgba(8, 20, 32, .45); z-index: 40; display: flex; justify-content: flex-end; }
.drawer { width: min(640px, 100%); background: var(--bg); height: 100%; overflow-y: auto; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; }
.drawer-head { background: var(--surface); border-bottom: 1px solid var(--border); padding: 16px 20px; position: sticky; top: 0; z-index: 2; display: flex; gap: 12px; align-items: flex-start; }
.drawer-body { padding: 18px 20px 40px; display: flex; flex-direction: column; gap: 16px; }
.nextbox { border: 1px solid var(--border-strong); border-left: 4px solid var(--accent); background: var(--surface); border-radius: var(--radius); padding: 12px 14px; }
.nextbox.over { border-left-color: var(--red); background: var(--red-soft); }
.nextbox .lbl { font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; font-weight: 700; color: var(--text-2); }
.nextbox .what { font-size: 15px; font-weight: 600; margin: 3px 0 6px; }
.timeline { display: flex; flex-direction: column; }
.tl-item { display: grid; grid-template-columns: 90px 1fr; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.tl-item:last-child { border: 0; } .tl-date { color: var(--text-3); font-size: 12px; } .tl-sum { font-weight: 550; } .tl-next { color: var(--text-2); font-size: 12.5px; margin-top: 2px; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 6px 14px; }
.kv dt { color: var(--text-2); font-size: 12.5px; } .kv dd { margin: 0; }

/* ------------------------------------------------------------ the work tree */
.tree { width: 100%; }
.tree-head, .tree-row { display: grid; grid-template-columns: minmax(240px, 1fr) 176px 118px 130px 116px 116px 108px 80px 34px; gap: 8px; align-items: center; padding: 0 12px; }
.tree-head { font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-2); font-weight: 650; background: var(--surface-2); border-bottom: 1px solid var(--border); height: 36px; position: sticky; top: 0; z-index: 1; }
.tree-row { min-height: 42px; border-bottom: 1px solid var(--border); }
.tree-row:hover { background: var(--surface-2); }
.tree-row.t-bucket, .tree-row.t-location, .tree-row.t-track { background: var(--surface-2); font-weight: 600; }
.tree-row.t-track { border-left: 4px solid #0f766e; } .tree-row.t-location { border-left: 4px solid #2563eb; } .tree-row.t-bucket { border-left: 4px solid #7c3aed; }
.tree-row.focus { animation: flash 2.4s ease-out; }
@keyframes flash { 0%, 40% { background: var(--accent-soft); } 100% { background: transparent; } }
.tree-title { display: flex; align-items: center; gap: 6px; min-width: 0; }
.tree-title .name { overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; cursor: pointer; padding: 4px 0; } .tree-title .name:hover { text-decoration: underline; }
.caret { width: 20px; height: 20px; border: 0; background: none; cursor: pointer; color: var(--text-2); border-radius: 4px; flex: none; padding: 0; font-size: 11px; } .caret:hover { background: var(--border); }
.caret.leaf { visibility: hidden; }
.type { font-size: 10px; text-transform: uppercase; letter-spacing: .05em; font-weight: 700; padding: 1px 6px; border-radius: 4px; color: #fff; flex: none; }
.tree-row select, .tree-row input { padding: 3px 6px; font-size: 12.5px; }
.status-sel { border-radius: 999px; font-weight: 600; border-color: transparent; padding-left: 9px; cursor: pointer; }
.st-planned { background: #e6eaee; color: #46525e; } .st-scheduled { background: #dbe8fb; color: #1f4fae; } .st-on_site { background: #ebe0fb; color: #6a2fb5; }
.st-started { background: #fdebc6; color: #8a5a00; } .st-documenting { background: #dfe3fa; color: #2e3d9e; } .st-review_1 { background: #d3f0f7; color: #0b6e83; }
.st-review_2 { background: #ccf1ec; color: #0b7a6c; } .st-follow_up { background: #fde0cf; color: #a4480f; } .st-tr_complete, .st-done { background: #d5f1e1; color: #166b41; }
.st-stuck { background: #fbd9d4; color: #a52a1d; } .st-on_hold { background: #f6dce8; color: #94295f; } .st-cancelled { background: #ececec; color: #888; text-decoration: line-through; }
@media (prefers-color-scheme: dark) {
  .st-planned { background: #2a3642; color: #b5c1cc; } .st-scheduled { background: #1c2f52; color: #9cbcff; } .st-on_site { background: #35224f; color: #cdaaff; }
  .st-started { background: #473510; color: #f1c66b; } .st-documenting { background: #232b57; color: #a9b6ff; } .st-review_1 { background: #12353f; color: #6fd0e6; }
  .st-review_2 { background: #103a34; color: #6fd9c9; } .st-follow_up { background: #4b2a14; color: #ffb388; } .st-tr_complete, .st-done { background: #12331f; color: #62d392; }
  .st-stuck { background: #471d19; color: #ff9d90; } .st-on_hold { background: #43203a; color: #f5a6cf; } .st-cancelled { background: #26292d; color: #7b8590; }
}
.hrs { font-size: 12.5px; color: var(--text-2); white-space: nowrap; } .hrs.over { color: var(--red); font-weight: 650; }
.prog { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-2); } .prog .bar { width: 60px; }
.ovr { color: var(--red); font-weight: 650; font-size: 12px; }
.contract-card { padding: 12px 14px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.contract-card + .contract-card { margin-top: 10px; }
.big { font-size: 26px; font-weight: 700; letter-spacing: -.02em; line-height: 1; }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; margin-bottom: 18px; }
.kpi { padding: 14px 16px; } .kpi .lbl { color: var(--text-2); font-size: 12.5px; margin-top: 6px; } .kpi .note { color: var(--text-3); font-size: 12px; margin-top: 2px; }
.kpi.bad .big { color: var(--red); } .kpi.good .big { color: var(--green); }
.hbar { display: grid; grid-template-columns: 140px 1fr 90px; gap: 10px; align-items: center; padding: 5px 0; }
.hbar .track { height: 18px; background: var(--surface-2); border-radius: 4px; overflow: hidden; } .hbar .track > div { height: 100%; background: var(--accent); border-radius: 4px; min-width: 2px; }

/* ------------------------------------------------------------ overlays */
.overlay { position: fixed; inset: 0; background: rgba(8, 20, 32, .5); z-index: 60; display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px; overflow-y: auto; }
.modal { background: var(--surface); border-radius: 10px; width: min(520px, 100%); box-shadow: var(--shadow-lg); }
.modal-wide { width: min(720px, 100%); }
.modal-head { display: flex; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--border); } .modal-head h2 { flex: 1; }
.modal-body { padding: 16px 18px 6px; } .modal-foot { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }
.menu { position: fixed; z-index: 80; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 8px; box-shadow: var(--shadow-lg); padding: 4px; min-width: 190px; max-height: 70vh; overflow-y: auto; }
.menu-item { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 7px 10px; border-radius: 5px; cursor: pointer; } .menu-item:hover, .menu-item:focus { background: var(--accent-soft); outline: 0; } .menu-item.danger { color: var(--red); }
.menu-sep { height: 1px; background: var(--border); margin: 4px 0; } .menu-head { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); padding: 6px 10px 2px; font-weight: 700; }
.toasts { position: fixed; bottom: 18px; right: 18px; z-index: 100; display: flex; flex-direction: column; gap: 8px; max-width: 420px; }
.toast { background: var(--nav); color: #fff; padding: 10px 14px; border-radius: 8px; box-shadow: var(--shadow-lg); font-weight: 550; } .toast-err { background: var(--red); }
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login .card { width: min(380px, 100%); padding: 28px; } .login h1 { margin-bottom: 4px; } .login p { color: var(--text-2); margin: 0 0 20px; }

/* ------------------------------------------------------------ contacts, sites, proposals */
.search-wrap { position: relative; margin-bottom: 12px; }
.search-results { position: absolute; left: 0; right: 0; top: 100%; z-index: 5; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 8px; box-shadow: var(--shadow-lg); max-height: 260px; overflow-y: auto; margin-top: 2px; }
.search-hit { display: block; width: 100%; text-align: left; background: none; border: 0; border-bottom: 1px solid var(--border); padding: 8px 12px; cursor: pointer; }
.search-hit:last-child { border-bottom: 0; } .search-hit:hover, .search-hit:focus, .search-hit.active { background: var(--accent-soft); outline: 0; }
.warn-text { color: var(--warn, #b45309); }
.bench { font-size: 13px; color: var(--text-2); border-left: 3px solid var(--accent); background: var(--accent-soft); border-radius: 0 6px 6px 0; padding: 6px 10px; margin: -2px 0 12px; }
.bench[hidden] { display: none; }
.contact-lines { display: flex; flex-direction: column; gap: 3px; }
.site-row { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--border); border-radius: 8px; padding: 9px 12px; cursor: pointer; }
.site-row:hover { background: var(--surface-2); } .site-row.on { border-color: var(--accent); background: var(--accent-soft); }
.site-row input[type=radio] { margin-top: 4px; }
.two-up { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
@media (max-width: 1000px) { .two-up { grid-template-columns: 1fr; } }
.pline-n { width: 24px; height: 24px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 12px; flex: none; }
.pline-body { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(280px, 1fr); gap: 0; }
@media (max-width: 1100px) { .pline-body { grid-template-columns: 1fr; } }
.pline-inputs { padding: 14px 16px; } .pline-inputs h3 { margin: 12px 0 8px; } .pline-inputs h3:first-of-type { margin-top: 0; }
.pline .card-head input { font-weight: 650; font-size: 15px; }
.results { background: var(--surface-2); border-left: 1px solid var(--border); padding: 14px 16px; border-radius: 0 0 var(--radius) 0; }
@media (max-width: 1100px) { .results { border-left: 0; border-top: 1px solid var(--border); } }
.rrow { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; font-variant-numeric: tabular-nums; }
.rrow.strong { font-weight: 650; border-top: 1px solid var(--border); margin-top: 3px; padding-top: 6px; }
.rrow.muted { color: var(--text-3); font-size: 13px; }
.actual { margin-top: 12px; padding-top: 10px; border-top: 2px solid var(--border-strong); }
input.missing { border-color: var(--red); background: var(--red-soft); }
input.missing::placeholder { color: var(--red); font-weight: 600; }
.totalbar { position: sticky; bottom: 0; z-index: 4; background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 12px 16px; }
.totalbar-main { display: flex; align-items: center; gap: 28px; flex-wrap: wrap; }
.totalbar .big { font-size: 22px; }
.blockers { margin: 10px 0 0; padding-left: 20px; color: var(--amber); font-weight: 550; }

details.discarded { border-top: 1px solid var(--border); padding: 0 16px; } details.discarded summary { cursor: pointer; color: var(--text-2); padding: 10px 0; font-size: 13px; }
details.discarded .list-row { padding-left: 0; padding-right: 0; }

.site-chip { display: inline-flex; align-items: center; gap: 4px; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 999px; padding: 2px 10px; font-size: 13px; font-weight: 600; }
.where .regime { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ---- pipeline panel on a deal ---- */
.flow-body { display: flex; flex-direction: column; gap: 12px; }
.steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; }
.step { display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; font-size: 11.5px; color: var(--text-3); position: relative; }
.step .num { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; background: var(--surface-2); border: 2px solid var(--border-strong); color: var(--text-3); z-index: 1; }
.step::before { content: ''; position: absolute; top: 12px; left: -50%; width: 100%; height: 2px; background: var(--border-strong); }
.step:first-child::before { display: none; }
.step.done .num { background: var(--green); border-color: var(--green); color: #fff; }
.step.done::before, .step.current::before { background: var(--green); }
.step.done { color: var(--text-2); }
.step.current .num { background: var(--accent); border-color: var(--accent); color: var(--accent-text); box-shadow: 0 0 0 4px var(--accent-soft); }
.step.current { color: var(--text); font-weight: 650; }
.step.closed .num { background: var(--red); border-color: var(--red); color: #fff; }
.where { font-size: 15px; }
.gate { border-radius: 6px; padding: 10px 14px; }
.gate.blocked { background: var(--amber-soft); border-left: 4px solid var(--amber); }
.gate.ready { background: var(--green-soft); color: var(--green); border-left: 4px solid var(--green); font-weight: 600; }
.gate-title { font-weight: 650; margin-bottom: 4px; }
.gate ul { margin: 0; padding-left: 18px; }
.ready-tick { align-items: flex-start; margin: 0; font-weight: 550; }
.track { border: 1px solid var(--border); border-radius: 6px; padding: 10px 14px; display: flex; flex-direction: column; gap: 8px; }
.track-head { display: flex; align-items: center; gap: 10px; justify-content: space-between; }
.checklist .lbl { font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; font-weight: 700; color: var(--text-2); margin-bottom: 6px; }
.checklist .check { margin-bottom: 6px; }
.mailpv { border: 1px solid var(--border); border-radius: 6px; padding: 10px 14px; margin-bottom: 12px; background: var(--surface-2); }
.mailpv .k { display: inline-block; width: 72px; color: var(--text-3); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.mailbody { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); white-space: pre-wrap; }
a.btn.disabled { opacity: .5; pointer-events: none; }
@media (max-width: 640px) { .steps { grid-template-columns: repeat(3, 1fr); row-gap: 10px; } .step:nth-child(4)::before { display: none; } }

/* ---- notification bell ---- */
.nav .navbtn { color: var(--nav-text); background: none; border: 0; padding: 6px 10px; border-radius: 6px; display: flex; align-items: center; gap: 10px; font: inherit; font-weight: 500; cursor: pointer; text-align: left; width: 100%; }
.nav .navbtn:hover { background: rgba(255, 255, 255, .07); }
.notif-list { display: flex; flex-direction: column; gap: 6px; max-height: 60vh; overflow: auto; }
.notif { display: flex; gap: 10px; align-items: flex-start; text-align: left; width: 100%; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; cursor: pointer; font: inherit; color: var(--text); }
.notif:hover { background: var(--surface-2); }
.notif.unread { border-left: 4px solid var(--accent); background: var(--accent-soft); }
.notif .ni { font-size: 16px; line-height: 1.3; }
.notif .nt { flex: 1; }
.notif .dot-unread { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); margin-top: 6px; flex: none; }

/* ---- client services ---- */
.tree-title .add-btn { width: 20px; height: 20px; line-height: 18px; font-size: 14px; border: 1px solid var(--border); border-radius: 50%; color: var(--accent); opacity: .55; }
.tree-row:hover .add-btn { opacity: 1; }
.plan-prompt { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.sched-preview table { width: 100%; }

.sticky-alerts { position: sticky; top: 0; z-index: 20; display: flex; flex-direction: column; gap: 6px; margin: 0 0 12px; padding: 6px 0; background: var(--bg, #f4f6f8); }
.sticky-alerts .notice { margin: 0; box-shadow: 0 2px 8px rgba(0,0,0,.12); display: flex; align-items: center; gap: 14px; padding: 6px 12px; font-size: 13px; }
.sticky-alerts .notice .btn { flex: none; white-space: nowrap; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0 14px; }
@media (max-width: 720px) { .grid4 { grid-template-columns: 1fr 1fr; } }

/* inputs every proposal needs, outlined heavier than the rest */
input.key-input { border: 2px solid var(--accent); border-radius: 6px; background: var(--accent-soft); }
input.key-input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.key-legend { font-size: 12px; color: var(--accent); font-weight: 600; margin: 0 0 6px; }
/* a reminder that floats above the page until it is dealt with */
.float-banner { position: fixed; bottom: 150px; right: 28px; z-index: 60; width: min(430px, calc(100vw - 32px));
  display: flex; align-items: flex-start; gap: 10px; background: var(--amber-soft); color: var(--amber); border: 2px solid var(--amber);
  border-radius: 10px; padding: 10px 14px; box-shadow: var(--shadow-lg); font-weight: 550; }
.float-banner[hidden] { display: none; }
.float-banner-body { flex: 1; }

/* To-Do page */
.todo-list { display: flex; flex-direction: column; gap: 8px; }
.todo { display: flex; gap: 12px; align-items: flex-start; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 10px 14px; }
.todo.unread { border-left: 4px solid var(--accent); }
.todo .todo-check { width: 20px; height: 20px; margin-top: 2px; flex: none; accent-color: var(--accent); cursor: pointer; }
.todo .ni { font-size: 16px; line-height: 1.3; flex: none; }
.todo .nt { flex: 1; min-width: 0; }
.todo.done .nt b { text-decoration: line-through; color: var(--text-3); }
.todo.done { background: var(--surface-2); }

/* a client's projects, as cards */
.proj-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 12px; }
.proj .co { font-size: 15px; }
.proj.proj-done { opacity: .75; background: var(--surface-2); }
.proj .prog { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-2); }

/* sidebar groups */
.nav .nav-box { background: rgba(255, 255, 255, .06); border: 1px solid rgba(255, 255, 255, .14); border-radius: 9px; padding: 4px; display: flex; flex-direction: column; gap: 1px; margin: 0 0 8px; }
.nav .nav-group { display: flex; flex-direction: column; gap: 1px; margin: 0 0 8px; padding-top: 8px; border-top: 1px solid rgba(255, 255, 255, .10); }
.nav .nav-box + .nav-group, .nav .nav-group.first { padding-top: 0; border-top: 0; }

/* an administrator viewing the app as someone else (QC) */
.viewing-as { position: sticky; top: 0; z-index: 90; background: #5b21b6; color: #fff; border-radius: 6px; padding: 8px 14px; margin-bottom: 12px; font-size: 13.5px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; box-shadow: var(--shadow-lg); }
.viewing-as .btn { background: #fff; color: #5b21b6; border-color: #fff; }

/* a box a file can be dropped on (Deliverables) */
.drop-over { outline: 2px dashed var(--accent); outline-offset: -2px; background: color-mix(in srgb, var(--accent) 8%, transparent); }
.drop-zone { border: 1px dashed var(--line, #c9ced6); border-radius: 8px; padding: 12px 14px; }
.drop-zone.drop-over { border-style: solid; }
.drop-hint { font-size: 12px; color: var(--muted, #6b7280); padding: 0 16px 10px; }

/* the 20/20: rated cells */
.r-good { background: color-mix(in srgb, #16a34a 16%, transparent); }
.r-warn { background: color-mix(in srgb, #d97706 20%, transparent); }
.r-bad { background: color-mix(in srgb, #dc2626 20%, transparent); }
table.twenty td { border-bottom: 1px solid var(--line, #e5e7eb); vertical-align: top; }

/* People cards (Admin > People) */
.pcards { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 14px; align-items: start; }
.person.inactive { opacity: .7; }
.person .card-head .avatar { flex: none; }
.pgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; }
.ppay { margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--border); }
@media (max-width: 480px) { .pgrid { grid-template-columns: 1fr; } .pcards { grid-template-columns: 1fr; } }
.person-head { cursor: pointer; }
.person-head:hover { background: var(--surface-2); }
.person-head:focus-visible { outline: 2px solid var(--accent, #2b6cb0); outline-offset: -2px; }
.person-head .caret-ind { font-size: 11px; }
.person.open { grid-column: 1 / -1; }

/* Time Off page */
.tocards { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 14px; align-items: start; }
.tobig { font-size: 30px; font-weight: 700; line-height: 1.1; margin-bottom: 6px; }
.tobig.ovr { color: var(--red); }
.tograph { margin: 4px 0 12px; }
.togrid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
.tofact .tovalue { font-weight: 600; }
@media (max-width: 480px) { .togrid { grid-template-columns: 1fr; } }


/* ------------------------------------------------------------ phones, tablets and laptops */
html { -webkit-text-size-adjust: 100%; }
.nav-body { display: contents; }                              /* on a wide screen the menu is simply the sidebar */
.nav-toggle { display: none; } .navbar .count { display: none; }
.tabs { overflow-x: auto; flex-wrap: nowrap; scrollbar-width: none; -webkit-overflow-scrolling: touch; } .tabs::-webkit-scrollbar { display: none; } .tabs button { white-space: nowrap; flex: none; }
.board, .scroll-x { -webkit-overflow-scrolling: touch; }
img, video, canvas, svg { max-width: 100%; }
.stack, .stack > *, .card, .main > * { min-width: 0; }           /* a wide table inside a card scrolls inside the card; it never widens the page */

@media (max-width: 860px) {
  /* the sidebar becomes a bar across the top with a Menu button; the menu opens below it and scrolls if it is long */
  .nav { position: sticky; top: 0; z-index: 50; height: auto; overflow: visible; padding: 0; flex-direction: column; gap: 0; }
  .navbar { display: flex; align-items: center; gap: 10px; padding: 8px max(12px, env(safe-area-inset-right)) 8px max(12px, env(safe-area-inset-left)); }
  .navbar .brand { padding: 0; flex: 1; font-size: 15px; } .navbar .brand small { display: inline; margin: 0 0 0 8px; }
  .navbar .count { display: inline-block; margin: 0; }
  .nav-toggle { display: inline-flex; align-items: center; gap: 6px; background: rgba(255, 255, 255, .12); color: #fff; border: 0; border-radius: 8px; padding: 9px 14px; font-weight: 600; cursor: pointer; min-height: 40px; }
  .nav-body { display: none; flex-direction: column; gap: 2px; padding: 4px 10px 16px; max-height: calc(100vh - 58px); max-height: calc(100dvh - 58px); overflow-y: auto; border-top: 1px solid rgba(255, 255, 255, .12); }
  .nav.open .nav-body { display: flex; }
  .nav .spacer { display: none; } .nav .me { margin-top: 8px; }
  .nav a { padding: 11px 12px; }
  .main { padding-left: max(14px, env(safe-area-inset-left)); padding-right: max(14px, env(safe-area-inset-right)); padding-bottom: max(50px, env(safe-area-inset-bottom)); }
  .sticky-alerts { top: 56px; }                           /* sits just under the bar */
  .page-head .actions { margin-left: 0; width: 100%; }
  .page-head .actions .search, .page-head .actions input[type=search] { flex: 1 1 100%; width: 100%; }
  .toasts { left: 12px; right: 12px; bottom: max(12px, env(safe-area-inset-bottom)); max-width: none; }
  .kv { grid-template-columns: 1fr; gap: 2px; } .kv dd { margin-bottom: 8px; }
  .hbar { grid-template-columns: 90px 1fr 70px; }
  .tl-item { grid-template-columns: 70px 1fr; }
  input, select, textarea { font-size: 16px; }              /* anything smaller makes a phone zoom in on the field */
  .tree-row select, .tree-row input { font-size: 16px; }
}
@media (max-width: 640px) {
  .grid2, .grid3, .grid4 { grid-template-columns: 1fr; }
  .overlay { padding: 0; align-items: stretch; }
  .modal, .modal-wide { width: 100%; min-height: 100%; border-radius: 0; display: flex; flex-direction: column; }
  .modal-body { flex: 1; }
  .modal-foot { position: sticky; bottom: 0; background: var(--surface); padding-bottom: max(12px, env(safe-area-inset-bottom)); flex-wrap: wrap; }
  .modal-foot .btn { flex: 1 1 auto; justify-content: center; }
  .page-head h1 { font-size: 22px; }
  .card-head { flex-wrap: wrap; }
  .kpis { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
}
@media (pointer: coarse) {                                   /* a finger, not a mouse: bigger things to hit */
  .btn { min-height: 40px; } .btn-sm { min-height: 36px; padding: 6px 12px; font-size: 13px; }
  .icon-btn { min-width: 40px; min-height: 40px; }
  input:not([type=checkbox]):not([type=radio]), select { min-height: 40px; }
  input[type=checkbox], input[type=radio] { width: 20px; height: 20px; }
  .menu-item { padding: 12px 12px; }
  .tabs button { padding: 12px 14px; }
  .caret { width: 32px; height: 32px; } .tree-title .add-btn { width: 30px; height: 30px; line-height: 28px; }
  .tree-row { min-height: 52px; }
}
@media (hover: none) { .tree-title .add-btn { opacity: 1; } }       /* nothing to hover over on a touch screen: show the little + always */
@media (max-width: 860px) and (orientation: landscape) { .nav-body { max-height: calc(100vh - 52px); max-height: calc(100dvh - 52px); } }

/* the work tree has nine columns: where the page is narrower than that (a phone, a tablet, a small laptop) each item becomes a small card - its name across the top, its status, owner, date and so on wrapping underneath */
@media (max-width: 1260px) {
  .tree-head { display: none; }
  .tree-row { display: flex; flex-wrap: wrap; gap: 6px 8px; padding: 10px 12px; align-items: center; }
  .tree-row > .tree-title { flex: 1 1 100%; }
  .tree-row > select, .tree-row > input, .tree-row > .status-sel { flex: 1 1 140px; width: auto; min-width: 120px; }
  .tree-row > span { flex: 0 1 auto; }
  .tree-row > .icon-btn { margin-left: auto; }
}
@media (max-width: 640px) { .board { grid-auto-columns: minmax(270px, 86%); scroll-snap-type: x proximity; } .board > .col { scroll-snap-align: start; } }

/* drag and drop uploads */
.dropzone { border: 1.5px dashed var(--border-strong); border-radius: 8px; padding: 10px 12px; margin: 6px 0; transition: border-color .12s, background .12s; }
.dropzone-over { border-color: var(--accent); border-style: solid; background: var(--accent-soft); }
.dropzone .row { margin-left: 0; }

/* the two Actions cards on a client */
.action-tiles { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.action-tile { display: inline-flex; align-items: center; gap: 10px; padding: 8px 14px; cursor: pointer; font: inherit; color: var(--text); text-align: left; }
.action-tile:hover { background: var(--surface-2); border-color: var(--border-strong); }
