:root {
  --bg: #f7f4ee;
  --card: #ffffff;
  --ink: #1d1d1f;
  --muted: #5a5a5a;
  --line: #ddd6c9;
  --line-soft: #ece6db;
  --brand: #1f5f8b;
  --brand-dark: #154766;
  --chip: #eaf1f7;
  --row-hover: #f3f7fa;
  --ok-bg: #e5f4e8;
  --ok-ink: #1d5e2b;
  --warn-bg: #fdecea;
  --warn-ink: #9b1c1c;
  --focus: #f2a900;
  --wrap: 1200px;
  font-size: 20px;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: -apple-system, "Helvetica Neue", Arial, sans-serif; line-height: 1.5; }
a { color: var(--brand); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
/* Keep jump targets (like #results) from hiding under the sticky top bar. */
[id] { scroll-margin-top: 10rem; }

/* Top bar and tabs: same width as the page so everything lines up. */
.top { background: var(--brand); color: #fff; position: sticky; top: 0; z-index: 10; }
.top-inner { max-width: var(--wrap); margin: 0 auto; padding: .75rem 2rem 0; }
.top-row { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: .5rem; }
.agency { font-weight: 700; font-size: 1.15rem; }
.top-date { font-size: .95rem; opacity: .9; }
.tabs { display: flex; gap: .35rem; }
.tab { color: #fff; text-decoration: none; padding: .55rem 1.3rem; border-radius: 10px 10px 0 0; font-weight: 600; font-size: 1.05rem; }
.tab:hover { background: var(--brand-dark); }
.tab.active { background: var(--bg); color: var(--brand-dark); }

/* Page */
main { max-width: var(--wrap); margin: 0 auto; padding: 1.75rem 2rem 4rem; }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1.25rem; }
h1 { font-size: 1.8rem; margin: 0; }
h2 { font-size: 1.3rem; margin: 0 0 .6rem; }
h3 { font-size: 1.1rem; margin: 1.25rem 0 .5rem; }
section { margin-bottom: 2.25rem; }
.lead { font-size: 1.15rem; margin: -.5rem 0 1.5rem; }
.muted { color: var(--muted); }
.count { display: inline-block; min-width: 1.6em; padding: 0 .45em; border-radius: 999px; background: var(--chip); color: var(--brand-dark); font-size: .85rem; text-align: center; vertical-align: middle; }
.section-note { margin: -.4rem 0 .6rem; }
.empty { color: var(--muted); font-style: italic; margin: .25rem 0; }
.flash { background: var(--ok-bg); color: var(--ok-ink); border: 2px solid var(--ok-ink); padding: .6rem 1rem; border-radius: 10px; font-weight: 600; margin-bottom: 1.25rem; display: flex; align-items: center; justify-content: space-between; gap: 1rem; position: sticky; top: 6.4rem; z-index: 5; box-shadow: 0 4px 12px rgba(0,0,0,.08); }
.back-link { display: inline-block; margin-bottom: .5rem; font-weight: 600; padding: .3rem 0; }
.result-count { display: flex; align-items: center; gap: 1rem; min-height: 44px; }
.notice { background: var(--warn-bg); color: var(--warn-ink); border: 2px solid var(--warn-ink); padding: .7rem 1rem; border-radius: 10px; font-weight: 600; margin-bottom: 1.25rem; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 1.1rem 1.3rem; margin-bottom: .75rem; }
.row { display: flex; align-items: center; gap: 1rem; justify-content: space-between; }
.name { font-weight: 700; }
.overdue { color: var(--warn-ink); font-weight: 700; }
.nowrap { white-space: nowrap; }
.chip { display: inline-block; background: var(--chip); border-radius: 999px; padding: .05rem .7rem; margin: 0 .3rem .3rem 0; font-size: .9rem; text-transform: capitalize; }
.pre { white-space: pre-line; }
code { overflow-wrap: anywhere; }

/* Buttons */
.btn, button { display: inline-block; font: inherit; font-weight: 600; padding: .5rem 1.15rem; border-radius: 10px; border: 2px solid var(--brand); background: var(--brand); color: #fff; text-decoration: none; cursor: pointer; min-height: 48px; line-height: 1.6; white-space: nowrap; }
.btn:hover, button:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn.secondary, button.secondary { background: #fff; color: var(--brand); }
.btn.secondary:hover, button.secondary:hover { background: var(--chip); }
.btn.small, button.small { font-size: .95rem; padding: .3rem .9rem; min-height: 44px; }
.btn.big, button.big { font-size: 1.15rem; padding: .65rem 1.6rem; }
button.link-danger { background: none; border: 0; color: var(--warn-ink); text-decoration: underline; padding: .5rem 0; min-height: 44px; font-weight: 600; }
button.link-danger:hover { background: none; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.inline-form { display: inline-flex; gap: .4rem; align-items: center; margin: 0; }

/* Tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; background: var(--card); }
table.list { width: 100%; border-collapse: collapse; }
table.list th, table.list td { text-align: left; padding: .65rem 1rem; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
table.list tbody tr:last-child td { border-bottom: 0; }
table.list th { background: #faf8f4; color: var(--muted); font-size: .9rem; font-weight: 600; border-bottom: 1px solid var(--line); }
table.list td.row-actions { text-align: right; white-space: nowrap; width: 1%; }
table.list td.row-actions > * + * { margin-left: .4rem; }
table.trip-list { table-layout: fixed; }
tr[data-href] { cursor: pointer; }
tr[data-href]:hover td { background: var(--row-hover); }

/* Today: fixed columns so every section lines up. */
table.today-list { table-layout: fixed; }
table.today-list td.who { width: 20%; }
table.today-list td.when { width: 24%; white-space: nowrap; }
table.today-list td.phone { width: 14%; white-space: nowrap; font-weight: 600; }
table.today-list td.row-actions { width: 250px; }

/* Forms */
.form-col { max-width: 780px; }
form.stack label { display: block; font-weight: 600; margin: 1rem 0 .3rem; }
input[type=text], input[type=email], input[type=tel], input[type=date], input[type=number], input[type=search], select, textarea {
  font: inherit; width: 100%; padding: .5rem .75rem; border: 2px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); min-height: 48px;
}
textarea { min-height: 6rem; }
input:focus, select:focus, textarea:focus, .btn:focus-visible, button:focus-visible, .tab:focus-visible, summary:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.hint { color: var(--muted); font-size: .9rem; margin: -.2rem 0 .3rem; }
.error { color: var(--warn-ink); font-weight: 600; margin: .25rem 0 0; }
.has-error input, .has-error select, .has-error textarea { border-color: var(--warn-ink); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
.grid3 { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 0 1rem; }
.checks { display: flex; flex-wrap: wrap; gap: .5rem 1.5rem; }
form.stack .checks label { font-weight: 400; display: flex; align-items: center; gap: .4rem; margin: 0; text-transform: capitalize; }
.checks input { width: 1.3rem; height: 1.3rem; }
.form-actions { margin-top: 1.5rem; }
fieldset.plain { border: 0; padding: 0; margin: 1rem 0 0; }
fieldset.plain legend { font-weight: 600; padding: 0; margin-bottom: .4rem; }
.search { font-size: 1.2rem; padding: .7rem 1rem; margin-bottom: .75rem; max-width: 640px; }

/* Customer page: details on the left, activity on the right. */
.profile { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 2rem; align-items: start; }
.profile-main table.list th, .profile-main table.list td { padding: .6rem .8rem; }
.profile-side .card { margin-bottom: 1rem; }
.profile-side .phone-number { font-size: 1.6rem; font-weight: 700; margin-bottom: .75rem; }
.side-actions { display: grid; gap: .5rem; margin-bottom: .5rem; }
.side-actions .btn { text-align: center; }
dl.facts { margin: 0; }
dl.facts dt { font-size: .85rem; font-weight: 600; color: var(--muted); margin-top: .6rem; }
dl.facts dd { margin: 0; font-size: .95rem; overflow-wrap: anywhere; }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: .6rem; }
.section-head h2 { margin: 0; }
details.add-panel { margin-top: .6rem; }
details.add-panel > summary { list-style: none; display: inline-block; }
details.add-panel > summary::-webkit-details-marker { display: none; }
details.add-panel[open] > summary { display: none; }
details.add-panel .card { margin-top: .25rem; }

/* Settings templates */
details.template > summary { cursor: pointer; font-weight: 700; font-size: 1.05rem; padding: .5rem 0; }
details.template textarea { min-height: 11rem; }
details.template > summary .muted { font-weight: 400; }
details.template[open] > summary { margin-bottom: .25rem; }

/* Reach Out picker */
.pickers { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; margin-bottom: 2rem; max-width: 900px; }
.pickers select, .pickers input { max-width: 320px; }
.pickers .card { margin: 0; display: flex; flex-direction: column; }
.pickers h3 { margin-top: 0; }
.pickers .card p:last-child { margin: auto 0 0; padding-top: .75rem; }

.phone-list td { height: 2.4em; }

@media print {
  .top, .no-print { display: none !important; }
  body { background: #fff; }
}
form.stack h2 { margin-top: 2.25rem; }
form.stack h2:first-child { margin-top: 0; }

/* Desktop workspace: quiet Mac-like chrome with generous, readable controls. */
:root { --bg:#f5f5f7; --line:#d5d5da; --line-soft:#e8e8ed; --brand:#2464aa; --brand-dark:#174a81; --chip:#eaf0f8; --focus:#2464aa; --sidebar:230px; }
[hidden] { display:none !important; }
.top { position:fixed; inset:0 auto 0 0; width:var(--sidebar); background:#ececf0; color:var(--ink); border-right:1px solid var(--line); }
.top-inner { height:100%; padding:1.6rem .65rem .9rem; display:flex; flex-direction:column; }
.top-row { display:block; padding:0 .65rem; margin-bottom:1.6rem; }
.agency { font-size:1.05rem; line-height:1.35; overflow-wrap:break-word; }
.sidebar-caption { font-size:.75rem; color:var(--muted); margin:.45rem 0 0; }
.tabs { flex:1; flex-direction:column; gap:.35rem; }
.tab { color:var(--ink); font-size:1rem; border-radius:8px; padding:.6rem .8rem; font-weight:500; }
.tab:hover { background:#e0e0e6; }
.tab.active { color:var(--brand-dark); background:#dbe7f6; font-weight:650; }
.settings-tab { margin-top:auto; }
.sidebar-footer { color:var(--muted); font-size:.75rem; padding:1rem .7rem 0; }
main { max-width:none; margin:0 0 0 var(--sidebar); padding:1.3rem 1.6rem 3rem; }
main > * { max-width:1300px; margin-left:auto; margin-right:auto; }
main > .form-col { margin-left:0; }
.page-date { color:var(--muted); font-size:.85rem; margin-top:0; margin-bottom:.65rem; }
h1 { font-size:1.7rem; letter-spacing:-.025em; }
h2 { font-size:1.2rem; }
.lead { font-size:1rem; color:var(--muted); }
.btn,button { border-width:1px; border-radius:8px; line-height:1.4; padding:.5rem .9rem; }
.btn.secondary,button.secondary { border-color:#c2c5cd; color:var(--brand-dark); }
.card,.table-wrap { border-radius:10px; box-shadow:0 1px 2px rgba(0,0,0,.025); }
table.list th { background:#f9f9fb; }
table.list th,table.list td { padding:.65rem .75rem; overflow-wrap:anywhere; }
table.trip-list { table-layout:auto; }
table.trip-list th:nth-last-child(2) { width:24%; }
.trip-dates { min-width:150px; max-width:220px; white-space:normal; }
.cell-note { display:block; color:var(--muted); font-size:.85rem; margin-top:.15rem; }
table.today-list { table-layout:auto; }
table.today-list td.who { width:18%; }
table.today-list td.what { width:28%; }
table.today-list td.when { width:16%; white-space:normal; }
table.today-list td.phone { width:15%; white-space:normal; font-size:.85rem; }
table.today-list td.row-actions { width:auto; white-space:normal; min-width:190px; }
.row-actions .inline-form { margin-top:.25rem; }
.nowrap { white-space:normal; }
.profile { grid-template-columns:minmax(290px,340px) minmax(0,1fr); gap:1.25rem; }
.profile-side .card { padding:1rem; }
.profile-side .phone-number { font-size:1.25rem; }
dl.facts dd { overflow-wrap:break-word; }
.facts-grid { display:grid; grid-template-columns:minmax(130px,1fr) 1.5fr; gap:.6rem 1rem; }
.facts-grid dt { margin:0; font-size:.9rem; }
.facts-grid dd { font-size:1rem; min-width:0; }
.workspace-grid { display:grid; grid-template-columns:1fr 1fr; gap:1rem; }
.workspace-grid section { margin-bottom:1.5rem; }
.workspace-grid h2 { margin-bottom:1rem; }
.form-col { max-width:850px; }
form.stack { scroll-margin-top:1rem; }
form.stack h2 { padding-bottom:.4rem; border-bottom:1px solid var(--line); }
.form-actions { position:sticky; bottom:0; background:var(--bg); padding:.7rem 0; z-index:2; }
.card .form-actions { background:#fff; }
input[type=text],input[type=email],input[type=tel],input[type=date],input[type=number],input[type=search],select,textarea { border-width:1px; border-color:#b5b7c1; }
input[type=checkbox] { width:22px; height:22px; accent-color:var(--brand); }
.filter-bar { display:flex; flex-wrap:wrap; align-items:end; gap:.6rem; margin-bottom:1rem; }
.filter-bar label { display:block; color:var(--muted); font-size:.85rem; margin-bottom:.25rem; }
.filter-search { flex:1; min-width:220px; }
.filter-bar select { min-width:155px; }
.list-tools { margin-bottom:1.5rem; font-size:.9rem; gap:1rem; }
.outreach-picker { max-width:900px; }
.outreach-picker label:first-child { margin-top:0; }
.today-section h3 { font-size:.9rem; color:var(--muted); margin-top:1rem; }
.today-section .table-wrap { margin-bottom:.8rem; }
.flash { position:static; border-width:1px; font-size:.95rem; box-shadow:none; }
.skip-link { position:absolute; top:-100px; left:250px; z-index:100; background:#fff; padding:.5rem; }
.skip-link:focus { top:10px; }
a:focus-visible { outline:3px solid var(--focus); outline-offset:3px; border-radius:2px; }
[id] { scroll-margin-top:1rem; }
@media(max-width:1200px) {
 :root { --sidebar:200px; }
 main { padding:1.1rem; }
 .workspace-grid { grid-template-columns:1fr; }
 .profile { grid-template-columns:300px minmax(0,1fr); }
 .profile-main table.list th,.profile-main table.list td { padding:.5rem; }
 .profile-main .row-actions { white-space:normal; }
}
@media print {
 .top,.skip-link,.page-date,.form-actions,.list-tools,.filter-bar { display:none !important; }
 main { margin:0; padding:0; }
 .table-wrap { overflow:visible; }
 .workspace-grid,.profile { display:block; }
 section { break-inside:avoid; }
}
.print-page main { margin:0 auto; max-width:1200px; }
.print-page main > * { max-width:none; }
@media print { .print-page main { max-width:none; margin:0; } }
.flash { position:sticky; top:.5rem; z-index:5; box-shadow:0 2px 8px rgba(0,0,0,.05); }
.workspace-grid .hint { margin-top:.9rem; margin-bottom:0; }
button:disabled { opacity:.65; cursor:wait; }
@media print { thead { display:table-header-group; } tr { break-inside:avoid; } .flash { display:none !important; } }
