:root {
  /* 60-30-10: light neutral background and surfaces (60%), charcoal text and gray
     borders (30%), one blue accent for navigation, links, buttons and KPIs (10%).
     Green, amber and red are only for status, and always come with an icon or word.
     (--teal* names are kept so older rules still work; they now hold the blue accent.) */
  --paper: #F6F7F9;
  --surface: #FFFFFF;
  --ink: #1F2933;
  --ink-2: #4B5563;
  --ink-3: #6B7280;
  --line: #DDE2E8;
  --line-2: #EEF1F4;
  --teal: #2B5C8A;
  --teal-bg: #E7EEF6;
  --teal-ink: #1D4266;
  --green: #2E6B40;
  --green-bg: #E4F2E7;
  --amber: #A8660F;
  --amber-bg: #FCF1DC;
  --red: #A3382E;
  --red-bg: #F8E3DF;
  --navy: #2B5C8A;
  --focus: #2B5C8A;
  --radius-s: 4px;
  --radius-m: 8px;
  --font: "Public Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font: 400 14px/1.45 var(--font);
  font-variant-numeric: tabular-nums;
}
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ------------------------------------------------------------------ buttons */
.btn {
  font: 500 14px/1 var(--font);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  border-radius: var(--radius-s);
  padding: 8px 12px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex; align-items: center; gap: 6px;
}
.btn:hover { border-color: var(--ink-3); }
.btn.primary { background: var(--teal); border-color: var(--teal); color: #fff; }
.btn.primary:hover { background: var(--teal-ink); }
.btn.quiet { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn.quiet:hover { color: var(--ink); background: var(--line-2); }
.btn.ghost { border-color: transparent; background: transparent; font-size: 22px; padding: 4px 10px; color: var(--ink-2); }
.btn.ghost:hover { background: var(--line-2); color: var(--ink); }
.btn.danger { color: var(--red); border-color: var(--red-bg); background: var(--surface); }
.btn.danger:hover { background: var(--red-bg); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* ------------------------------------------------------------------- topbar */
.topbar {
  display: flex; align-items: center; gap: 24px;
  padding: 14px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.brand .loc { font-weight: 600; color: var(--ink-2); }
.weeknav { display: flex; align-items: center; gap: 4px; flex: 1; }
.weeknav h1 { font-size: 20px; font-weight: 700; margin: 0 6px; letter-spacing: -0.01em; min-width: 190px; text-align: center; }
.weeknav input[type=date] { margin-left: 8px; }
.actions { display: flex; gap: 6px; }

input, select, textarea {
  font: 400 14px/1.3 var(--font);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  padding: 7px 9px;
  background: var(--surface);
}
textarea { width: 100%; resize: vertical; }

/* ------------------------------------------------------------------ summary */
.summary {
  display: flex; gap: 28px; align-items: baseline;
  padding: 16px 24px 4px;
}
.summary .stat { margin: 0; color: var(--ink-2); }
.summary .stat strong { font-size: 22px; font-weight: 700; color: var(--ink); margin-right: 4px; letter-spacing: -0.01em; }
.summary .stat.open strong { color: var(--ink-3); }
.summary .stat.open.has strong { color: var(--amber); }
.summary .stat.open.has { color: var(--amber); }

/* ------------------------------------------------------------------ filters */
.filters {
  display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: end;
  padding: 12px 24px 14px;
}
.filters label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--ink-2); }
.filters label.check { flex-direction: row; align-items: center; gap: 6px; font-size: 13px; color: var(--ink); padding-bottom: 8px; }
.filters .search input { width: 260px; }

/* -------------------------------------------------------------------- board */
.board-wrap { padding: 0 24px 40px; overflow-x: auto; }
.board {
  width: 100%; min-width: 1100px;
  border-collapse: separate; border-spacing: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
}
.board thead th {
  position: sticky; top: 0; z-index: 2;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  text-align: left; font-weight: 600; font-size: 12px; color: var(--ink-2);
  padding: 10px 10px 8px;
  vertical-align: bottom;
}
.board thead th:first-child { border-top-left-radius: var(--radius-m); }
.board thead th:last-child { border-top-right-radius: var(--radius-m); }
.col-client { width: 200px; }
.col-cg { width: 190px; }
.col-hours { width: 64px; text-align: right !important; }

th.day { width: calc((100% - 454px) / 7); }
th.day .dname { display: block; color: var(--ink-2); }
th.day .dnum { display: block; font-size: 17px; font-weight: 700; color: var(--ink); }
th.day.today .dnum { color: var(--teal); }
/* Coverage bar: the one bold element. Teal = covered hours, amber = open hours. */
.cov { display: flex; height: 6px; margin-top: 7px; border-radius: 3px; overflow: hidden; background: var(--line-2); }
.cov i { display: block; height: 100%; }
.cov .a { background: var(--teal); }
.cov .o { background: var(--amber); }
.covtxt { display: block; margin-top: 4px; font-size: 11px; font-weight: 500; color: var(--ink-3); }
.covtxt b { color: var(--amber); font-weight: 600; }

.board tbody td {
  border-bottom: 1px solid var(--line-2);
  padding: 6px 8px;
  vertical-align: top;
}
.board tbody tr.first-of-client td { border-top: 1px solid var(--line); }
.board tbody tr:first-child td { border-top: 0; }
.board tbody tr:hover td { background: #F9FAFB; }
td.client a, td.cg a { color: var(--ink); font-weight: 600; text-decoration: none; }
td.client .sub, td.cg .sub { display: block; color: var(--ink-3); font-size: 12px; }
td.client .cont { color: var(--ink-3); font-size: 12px; }
td.cg.open-cg { color: var(--amber); font-weight: 600; }
.badge { display: inline-block; font-size: 11px; font-weight: 600; padding: 1px 6px; border-radius: 3px; margin-top: 3px; }
.badge.va { background: #E6ECF6; color: var(--navy); }
.badge.hold { background: var(--red-bg); color: var(--red); }
td.hours { text-align: right; font-weight: 600; }
td.daycell { position: relative; min-height: 40px; }

.chip {
  display: block; width: 100%;
  text-align: left;
  font: 500 12px/1.3 var(--font);
  border: 1px solid transparent;
  border-radius: var(--radius-s);
  padding: 4px 6px;
  margin-bottom: 4px;
  cursor: pointer;
  background: var(--teal-bg); color: var(--teal-ink);
}
.chip .t { display: block; font-weight: 600; }
.chip .h { color: inherit; opacity: .75; }
.chip .rep { float: right; opacity: .55; }
.chip:hover { border-color: var(--teal); }
.chip.open { background: var(--amber-bg); color: #7A4A08; border: 1px dashed var(--amber); }
.chip.missed { background: var(--red-bg); color: var(--red); text-decoration: line-through; }
.chip.done { background: var(--line-2); color: var(--ink-2); }
.add {
  display: block; width: 100%;
  border: 1px dashed transparent; border-radius: var(--radius-s);
  background: transparent; color: var(--ink-3);
  font: 500 16px/1 var(--font); padding: 3px 0; cursor: pointer;
  opacity: 0;
}
td.daycell:hover .add, .add:focus-visible { opacity: 1; border-color: var(--line); }
.empty { color: var(--ink-2); padding: 24px 0; }
.loading tbody { opacity: .45; transition: opacity .15s; }

/* ------------------------------------------------------------------- drawer */
.scrim { position: fixed; inset: 0; background: rgba(28, 41, 45, .28); z-index: 20; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 21;
  width: min(480px, 100vw);
  background: var(--surface);
  border-left: 1px solid var(--line);
  display: flex; flex-direction: column;
  animation: slidein .16s ease-out;
}
@keyframes slidein { from { transform: translateX(24px); opacity: .6; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .drawer { animation: none; } }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 20px; border-bottom: 1px solid var(--line); }
.drawer-head h2 { margin: 0; font-size: 18px; }
.drawer-body { flex: 1; overflow-y: auto; padding: 16px 20px; display: flex; flex-direction: column; gap: 14px; }
.drawer-foot { display: flex; gap: 8px; align-items: center; padding: 12px 20px; border-top: 1px solid var(--line); }
.drawer-foot .spacer { flex: 1; }
.field { display: flex; flex-direction: column; gap: 4px; position: relative; }
.field > label { font-size: 12px; font-weight: 600; color: var(--ink-2); }
.field.inline { flex-direction: row; align-items: center; gap: 8px; }
.row2, .row3 { display: grid; gap: 10px; }
.row2 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.row3 { grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr) minmax(0, 1fr); }
.field select, .field input { min-width: 0; max-width: 100%; text-overflow: ellipsis; }
.fixed { margin: 0; font-weight: 600; font-size: 15px; }
.payer-line { margin: -6px 0 0; color: var(--ink-2); font-size: 12px; }
.hint { color: var(--ink-3); font-size: 12px; }

.picklist, .suggest { list-style: none; margin: 0; padding: 0; }
.picklist { position: absolute; top: 58px; left: 0; right: 0; z-index: 3; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-s); max-height: 220px; overflow-y: auto; }
.picklist:empty { display: none; }
.picklist li, .suggest li { padding: 7px 10px; cursor: pointer; }
.picklist li:hover, .picklist li[aria-selected=true] { background: var(--line-2); }
.suggest { max-height: 240px; overflow-y: auto; border: 1px solid var(--line); border-radius: var(--radius-s); }
.suggest li { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; border-bottom: 1px solid var(--line-2); }
.suggest li:last-child { border-bottom: 0; }
.suggest li:hover, .suggest li:focus-visible { background: var(--teal-bg); outline: none; }
.suggest .nm { font-weight: 600; }
.suggest .meta { grid-column: 1 / -1; color: var(--ink-3); font-size: 12px; }
.suggest .tag { font-size: 11px; font-weight: 600; color: var(--teal); }
.suggest .tag.warn { color: var(--amber); }
.suggest li.none { color: var(--ink-3); cursor: default; display: block; }
.cg-current { display: flex; align-items: center; justify-content: space-between; padding: 8px 10px; border-radius: var(--radius-s); background: var(--teal-bg); color: var(--teal-ink); font-weight: 600; }
.cg-current.open { background: var(--amber-bg); color: #7A4A08; }
.cg-current button { font-size: 12px; padding: 4px 8px; }

.repeat { border: 1px solid var(--line); border-radius: var(--radius-s); padding: 8px 12px 12px; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.repeat legend { font-size: 12px; font-weight: 600; color: var(--ink-2); padding: 0 4px; }
.days { display: flex; gap: 4px; }
.days label { display: flex; align-items: center; justify-content: center; width: 38px; height: 32px; border: 1px solid var(--line); border-radius: var(--radius-s); cursor: pointer; font-size: 12px; font-weight: 600; }
.days input { position: absolute; opacity: 0; pointer-events: none; }
.days label:has(input:checked) { background: var(--teal); border-color: var(--teal); color: #fff; }
.days label:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 2px; }
label.check { display: flex; align-items: center; gap: 6px; font-size: 13px; }

.issues { display: flex; flex-direction: column; gap: 6px; }
.issue { padding: 8px 10px; border-radius: var(--radius-s); font-size: 13px; border-left: 3px solid; }
.issue.hard { background: var(--red-bg); border-color: var(--red); color: #6E2019; }
.issue.block { background: var(--amber-bg); border-color: var(--amber); color: #6A4007; }
.issue.warn { background: var(--line-2); border-color: var(--ink-3); color: var(--ink-2); }
.history ul { margin: 6px 0 0; padding-left: 18px; color: var(--ink-2); font-size: 12px; }

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: var(--radius-s);
  font-weight: 500; z-index: 30;
}
.toast.err { background: var(--red); }

@media (max-width: 900px) {
  .topbar { flex-wrap: wrap; gap: 10px; padding: 12px 16px; }
  .weeknav h1 { min-width: 0; font-size: 17px; }
  .summary, .filters, .board-wrap { padding-left: 16px; padding-right: 16px; }
  .summary { flex-wrap: wrap; gap: 14px; }
}

/* ------------------------------------------------ matching, couples, rates */
td.client .needs { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 4px; }
.need { font-size: 11px; font-weight: 600; padding: 1px 6px; border-radius: 3px; background: var(--line-2); color: var(--ink-2); }
.need.req { background: #EFE7F7; color: #5B3A86; }
td.client .name-btn, td.cg .name-btn { all: unset; cursor: pointer; font-weight: 600; color: var(--ink); }
td.client .name-btn:hover, td.cg .name-btn:hover { text-decoration: underline; }
td.client .name-btn:focus-visible, td.cg .name-btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.chip .couple { display: inline-block; font-size: 10px; font-weight: 700; letter-spacing: .02em; margin-left: 4px; padding: 0 4px; border-radius: 3px; background: rgba(46, 98, 102, .14); }
.chip.open .couple { background: rgba(176, 111, 20, .16); }
.needs-line { margin: 2px 0 0; font-size: 12px; color: #5B3A86; }
.needs-line:empty { display: none; }
.shared-line { margin: -4px 0 0; font-size: 13px; font-weight: 600; color: var(--teal-ink); }
.rate-line { margin: -6px 0 0; font-size: 12px; color: var(--ink); background: var(--line-2); padding: 6px 8px; border-radius: var(--radius-s); }
.rate-line b { font-weight: 600; }
.suggest .tag.region { color: var(--ink-2); }
.sub-h { margin: 4px 0 2px; font-size: 14px; }
.attr-grid { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 12px; align-items: center; margin-top: 6px; }
.attr-grid .lbl { font-size: 13px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius-s); overflow: hidden; }
.seg label { font-size: 12px; font-weight: 600; padding: 5px 9px; cursor: pointer; color: var(--ink-2); border-left: 1px solid var(--line); }
.seg label:first-child { border-left: 0; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label:has(input:checked) { background: var(--teal); color: #fff; }
.seg label:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: -2px; }

/* ---------------------------------------------------- items 5 and 8 additions */
.subnav { display: flex; gap: 2px; padding: 6px 20px; background: var(--surface); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.badge.over { background: var(--amber-bg); color: #6A4007; }
.confirm-line { font-size: 13px; padding: 8px 10px; border-radius: var(--radius-s); background: var(--line-2); color: var(--ink-2); }
.confirm-line.ok { background: var(--teal-bg); color: var(--teal-ink); }
.confirm-line.bad { background: var(--red-bg); color: #6E2019; }
.offer-box { border: 1px solid var(--line); border-radius: var(--radius-m); padding: 10px 12px; background: #F9FAFB; }
.offer-box .sub-h { margin-top: 0; }
.offer-list { list-style: none; margin: 6px 0 10px; padding: 0; max-height: 280px; overflow-y: auto; border: 1px solid var(--line-2); border-radius: var(--radius-s); background: var(--surface); }
.offer-list li { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 2px 8px; padding: 7px 9px; border-bottom: 1px solid var(--line-2); font-size: 13px; }
.offer-list li:last-child { border-bottom: 0; }
.offer-list .meta { grid-column: 2; color: var(--ink-3); font-size: 12px; }
.offer-list li.nope { opacity: .55; }
.offer-rec { display: flex; gap: 8px; align-items: center; justify-content: space-between; font-size: 13px; padding: 4px 0; border-bottom: 1px dashed var(--line-2); }
.offer-rec:last-child { border-bottom: 0; }

.alert-box { border-left: 3px solid var(--red); background: var(--red-bg); color: #6E2019; padding: 8px 10px; border-radius: var(--radius-s); margin: 0 0 10px; font-size: 13px; white-space: pre-line; max-height: 160px; overflow: auto; }
.alert-box div + div { margin-top: 4px; }
