/* Tide Care Office */
.layout { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.side { background: #0b1f3a; color: #c9d6ea; padding: 18px 14px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.side .brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 12px; color: #fff; font-weight: 700; font-size: 15px; }
.side .brand img { height: 26px; filter: brightness(0) invert(1); }
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side .grp { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: #7d90ad; padding: 14px 10px 6px; }
.side a.nav { display: flex; align-items: center; gap: 10px; min-height: 38px; padding: 8px 10px; border-radius: 8px; color: #d8e2f1; font-weight: 550; text-decoration: none; }
.side a.nav .lbl { flex: 1; min-width: 0; }
.side a.nav .ico { color: #8ea3c2; }
.side a.nav:hover { background: rgba(255, 255, 255, .06); }
.side a.nav:hover .ico { color: #d8e2f1; }
.side a.nav.on { background: #1666fe; color: #fff; }
.side a.nav.on .ico { color: #fff; }
.side a.nav:focus-visible, .side button:focus-visible, .appbar a:focus-visible, .appbar button:focus-visible { outline: 2px solid #8fb3ff; outline-offset: 2px; }
.side a.nav .count { background: #f04438; color: #fff; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 99px; }
.ico { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.vh { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
/* Drawer-only parts: hidden while the sidebar is showing */
.appbar, .nav-scrim, .side-close, .side-user { display: none; }
.side .promo { margin-top: auto; background: rgba(255, 255, 255, .06); border-radius: 12px; padding: 12px; font-size: 12px; display: grid; gap: 6px; }
.side .promo b { color: #fff; font-size: 13px; }
.side .promo a { color: #8fb3ff; font-weight: 600; }
.main { min-width: 0; display: flex; flex-direction: column; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px 28px 6px; }
.top .who { display: flex; align-items: center; gap: 10px; }
.top .who .meta { line-height: 1.2; }
.top .who .meta b { display: block; }
.top .who .meta span { font-size: 12px; color: var(--muted); }
.top .who-link { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; border-radius: var(--r); padding: 2px 4px; }
.top .who-link:hover { background: var(--bg); }
.signin-page { max-width: 560px; margin: 56px auto; padding: 0 20px; }
.page { padding: 10px 28px 48px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; align-content: start; } /* content never widens the page */
.card:has(> table.t) { overflow-x: auto; } /* a table too wide for its card scrolls inside the card */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-head p { color: var(--muted); margin-top: 2px; }
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.kpi { padding: 14px 16px; display: grid; gap: 2px; }
.kpi .lbl { font-size: 12px; font-weight: 600; color: var(--muted); }
.kpi .val { font-size: 26px; font-weight: 750; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.kpi .sub { font-size: 12px; color: var(--muted); }
.cols { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 18px; align-items: start; }
.rail { display: grid; gap: 18px; }
.tabsbar { display: flex; gap: 4px; }
.tabsbar button, .tabsbar a { border: 0; background: transparent; padding: 6px 12px; border-radius: 8px; font-weight: 600; color: var(--muted); cursor: pointer; text-decoration: none; }
.tabsbar .on { background: var(--blue-50); color: var(--blue); }
.cand { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line-2); }
.cand:last-child { border-bottom: 0; }
.cand .info { flex: 1; min-width: 0; }
.cand .info b { display: block; }
.cand .info span { font-size: 12px; color: var(--muted); }
.score { font-weight: 750; color: var(--blue); font-variant-numeric: tabular-nums; }
.alert { display: grid; gap: 2px; padding: 10px 0; border-bottom: 1px solid var(--line-2); text-decoration: none; color: inherit; }
.alert:last-child { border-bottom: 0; }
.alert b { font-size: 13px; }
.alert span { font-size: 12px; color: var(--muted); }
.alert:hover { text-decoration: none; }
.alert:hover b { color: var(--blue); }

/* Schedule grid */
.sched { overflow-x: auto; }
.sched table { border-collapse: separate; border-spacing: 0; width: 100%; min-width: 1050px; table-layout: fixed; }
.sched th { font-size: 12px; font-weight: 600; color: var(--muted); padding: 10px 8px; text-align: left; border-bottom: 1px solid var(--line); background: #fafbfc; position: sticky; top: 0; }
.sched th.today { color: var(--blue); }
.sched td { border-bottom: 1px solid var(--line-2); border-right: 1px solid var(--line-2); vertical-align: top; padding: 5px; height: 64px; }
.sched td.cg { width: 170px; padding: 8px 10px; border-right: 1px solid var(--line); background: #fff; }
.sched td.cg b { display: block; font-size: 13px; }
.sched td.cg span { font-size: 12px; color: var(--muted); }
.sched td.cg span.ot { color: var(--warn); font-weight: 600; }
.sched td.drop { background: var(--blue-50); outline: 2px dashed var(--blue); outline-offset: -3px; }
.sched td.todaycol { background: #fbfcff; }
.sched tr.openrow td { background: #fffaf3; }
.chip { display: block; border-radius: 7px; padding: 4px 7px; margin-bottom: 4px; font-size: 12px; line-height: 1.3; cursor: grab; border-left: 3px solid var(--blue); background: var(--blue-50); color: var(--ink); }
.chip b { font-weight: 650; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip span { color: var(--ink-2); }
.chip.tone-ok { background: var(--ok-bg); border-color: var(--ok); }
.chip.tone-warn { background: var(--warn-bg); border-color: #f79009; }
.chip.tone-bad { background: var(--bad-bg); border-color: var(--bad); }
.chip.tone-muted { background: #f3f5f8; border-color: #b4bfcf; }
.chip.tone-info { background: var(--blue-50); border-color: var(--blue); }
.chip.dragging { opacity: .4; }

.section-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.events td, .events th { padding: 7px 8px; font-size: 13px; }
.ok-mark { color: var(--ok); font-weight: 700; }
.bad-mark { color: var(--bad); font-weight: 700; }
.exc { border: 1px solid var(--line); border-radius: 10px; padding: 12px; display: grid; gap: 8px; }
.exc.open { border-color: #fbc98e; background: #fffaf3; }
tr.dim td { color: var(--muted); }
.pill-list { display: flex; flex-wrap: wrap; gap: 6px; }
.json { font-family: ui-monospace, Menlo, monospace; font-size: 11px; color: var(--ink-2); white-space: pre-wrap; word-break: break-all; }
pre.json { max-height: 320px; overflow: auto; background: var(--muted-bg); padding: 10px; border-radius: var(--r-sm); margin-top: 6px; }
/* Claim checks: blockers and warnings listed under a claim. */
.issues { margin: 4px 0 0; padding-left: 16px; font-size: 12px; line-height: 1.4; }
.issues.tone-bad, .issues.tone-warn { background: none; }
.issues.tone-bad li { color: var(--bad); }
.issues.tone-warn li { color: var(--warn); }
.issues a { font-weight: 600; }

/* Today's visit board. It keeps the side cards beside it only when it still has room for every column. */
.tscroll { overflow-x: auto; }
.vboard .nw { white-space: nowrap; } /* a time range wraps only after the dash */
@media (max-width: 1439px) {
  .cols { grid-template-columns: minmax(0, 1fr); }
  .rail { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); align-items: start; }
}
@media (max-width: 1180px) { .kpis { grid-template-columns: repeat(2, 1fr); } }

/* Phones: each visit becomes a card instead of a squeezed table row */
@media (max-width: 720px) {
  .card-head, .page-head .row { flex-wrap: wrap; }
  .tabsbar { overflow-x: auto; max-width: 100%; }
  .vboard thead { display: none; }
  .vboard, .vboard tbody { display: block; }
  .vboard tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "client evv" "time time" "cg cg" "svc svc" "next next"; gap: 3px 12px; padding: 12px 16px; border-bottom: 1px solid var(--line-2); }
  .vboard tr:last-child { border-bottom: 0; }
  .vboard tr.click:hover { background: #f8faff; }
  .vboard td { display: block; padding: 0; border: 0; }
  .vboard br { display: none; }
  .vboard .c-client { grid-area: client; }
  .vboard .c-client small::before, .vboard .c-svc small::before { content: " · "; }
  .vboard .c-evv { grid-area: evv; }
  .vboard .c-time { grid-area: time; }
  .vboard .c-time small::after { content: " · "; }
  .vboard .c-cg { grid-area: cg; }
  .vboard .c-cg::before { content: "Caregiver: "; color: var(--muted); }
  .vboard .c-svc { grid-area: svc; color: var(--ink-2); }
  .vboard .c-next { grid-area: next; margin-top: 6px; }
  .vboard .c-next:empty { display: none; }
}

/* Tablets and phones: the sidebar becomes a menu drawer opened from the top bar */
@media (max-width: 1023px) {
  .layout { display: block; }
  .appbar { display: flex; align-items: center; gap: 4px; position: sticky; top: 0; z-index: 40; height: 56px; padding: 0 10px 0 6px; background: #0b1f3a; color: #fff; box-shadow: 0 1px 0 rgba(255, 255, 255, .06); }
  .appbar-menu { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; border: 0; border-radius: 10px; background: transparent; color: #fff; cursor: pointer; }
  .appbar-menu .ico { width: 22px; height: 22px; }
  .appbar-menu:hover { background: rgba(255, 255, 255, .08); }
  .appbar-menu .dot { position: absolute; top: 9px; right: 8px; width: 9px; height: 9px; border-radius: 50%; background: #f04438; box-shadow: 0 0 0 2px #0b1f3a; }
  .appbar-brand { display: flex; align-items: center; gap: 8px; margin-right: auto; padding: 6px; border-radius: 8px; color: #fff; font-weight: 700; font-size: 15px; text-decoration: none; }
  .appbar-brand:hover { text-decoration: none; }
  .appbar-brand img { height: 22px; filter: brightness(0) invert(1); }
  .appbar-me { display: inline-flex; padding: 5px; border-radius: 50%; }
  .appbar-me .av { width: 32px; height: 32px; font-size: 12px; }

  .nav-scrim { display: block; position: fixed; inset: 0; z-index: 55; background: rgba(11, 31, 58, .5); opacity: 0; pointer-events: none; transition: opacity .2s ease; }
  .layout.nav-open .nav-scrim { opacity: 1; pointer-events: auto; }
  .side { position: fixed; top: 0; bottom: 0; left: 0; z-index: 60; width: min(304px, 86vw); height: 100%; padding-top: 12px; overscroll-behavior: contain; box-shadow: var(--shadow-lg);
    transform: translateX(-100%); visibility: hidden; transition: transform .22s ease, visibility 0s linear .22s; }
  .layout.nav-open .side { transform: none; visibility: visible; transition: transform .22s ease; }
  .side .brand { padding-right: 0; }
  .side .brand span { flex: 1; }
  .side-close { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border: 0; border-radius: 10px; background: transparent; color: #c9d6ea; cursor: pointer; }
  .side-close:hover { background: rgba(255, 255, 255, .08); color: #fff; }
  .side a.nav { min-height: 44px; }
  .side .promo { display: none; }
  .side-user { display: grid; gap: 10px; margin-top: auto; padding: 14px 6px 6px; border-top: 1px solid rgba(255, 255, 255, .1); }
  .side-me { display: flex; align-items: center; gap: 10px; padding: 6px 4px; border-radius: 8px; color: #fff; text-decoration: none; }
  .side-me:hover { background: rgba(255, 255, 255, .06); text-decoration: none; }
  .side-me b { display: block; }
  .side-me small { color: #9fb1cc; }
  .side-user .btn { justify-self: stretch; }

  .top { padding: 14px 16px 2px; }
  .top .who { display: none; }
  .page { padding: 10px 16px 40px; }
}
/* Small phones: side-by-side form fields and label/value lists stack */
@media (max-width: 600px) {
  .grid2, .grid3 { grid-template-columns: minmax(0, 1fr); }
  .kv { grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); }
  .kv dd { overflow-wrap: anywhere; }
  .card-head { flex-wrap: wrap; }
}
html.nav-lock, html.nav-lock body { overflow: hidden; }
@media (prefers-reduced-motion: reduce) { .side, .nav-scrim { transition: none !important; } }

@media print {
  body * { visibility: hidden; }
  .print-area, .print-area * { visibility: visible; }
  .print-area { position: absolute; left: 0; top: 0; width: 100%; padding: 24px; }
  .no-print { display: none !important; }
}

/* v0.2: inbox, messages, visit documentation, care plan editor */
.ibox { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; display: grid; gap: 6px; background: #fff; }
.ibox.high { border-color: #f4c7c3; box-shadow: inset 3px 0 0 var(--bad); }
.ibox .detail { font-size: 13px; color: var(--ink-2); }
.ibox form { margin-top: 4px; }
.task-grid { display: grid; gap: 6px; }
.tline { display: grid; grid-template-columns: 92px 1fr; gap: 10px; align-items: start; font-size: 13px; }
.tline .badge { justify-self: start; }
.sigcard { display: grid; gap: 4px; justify-items: start; }
.sig-svg { background: #fbfcfe; border: 1px solid var(--line); border-radius: 10px; padding: 4px 8px; max-width: 100%; }
.plan-row { display: grid; grid-template-columns: 1fr auto auto; gap: 10px; align-items: center; }
.plan-row .check input { margin-top: 0; }
.chat { display: grid; grid-template-columns: 300px 1fr; min-height: 560px; overflow: hidden; }
.chat .threads { border-right: 1px solid var(--line); overflow-y: auto; max-height: 70vh; }
.chat .threads .grp { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); padding: 12px 14px 4px; }
.thr { display: flex; gap: 10px; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--line-2); color: inherit; text-decoration: none; }
.thr:hover { background: #f8faff; text-decoration: none; }
.thr.on { background: var(--blue-50); }
.thr .what { flex: 1; min-width: 0; display: grid; }
.thr .what small { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thr .count { background: var(--blue); color: #fff; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 99px; }
.av.bc { background: #fff4e5; }
.conv { display: grid; grid-template-rows: auto 1fr auto; min-height: 0; max-height: 70vh; }
.conv > .empty { grid-row: 1 / -1; align-self: center; }
.conv-head { padding: 12px 16px; border-bottom: 1px solid var(--line); display: flex; gap: 10px; align-items: baseline; }
.msgs { overflow-y: auto; padding: 14px 16px; display: grid; gap: 8px; align-content: start; background: #fafbfd; }
.bubble { max-width: 70%; background: #fff; border: 1px solid var(--line); border-radius: 14px 14px 14px 4px; padding: 8px 12px; font-size: 14px; overflow-wrap: anywhere; }
.bubble > div { white-space: pre-wrap; }
.bubble.mine { justify-self: end; background: var(--blue-50); border-color: var(--blue-100); border-radius: 14px 14px 4px 14px; }
.bubble .who { display: block; font-weight: 700; font-size: 11px; color: var(--muted); }
.bubble .meta { display: block; font-size: 11px; color: var(--muted); margin-top: 2px; }
.composer { display: grid; grid-template-columns: 1fr auto; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--line); align-items: end; }
.composer textarea { min-height: 44px; resize: vertical; }
@media (max-width: 900px) { .chat { grid-template-columns: 1fr; } .chat .threads { max-height: 220px; border-right: 0; border-bottom: 1px solid var(--line); } }

/* ---------- Owner dashboard & reports (REP-01/02/03) */
.dash-top { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; align-items: stretch; }
.hero .card-body { display: grid; gap: 8px; align-content: start; height: 100%; }
.hero .lbl { font-size: 13px; font-weight: 650; color: #666666; }
.hero-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.hero .big { font-size: 56px; line-height: 1; font-weight: 750; letter-spacing: -0.03em; color: #191919; font-variant-numeric: proportional-nums; }
.hero .sub { color: #191919; }
.hero .def { color: #666666; line-height: 1.5; }
.hero .btn { justify-self: start; }
.dash-charts { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; }
.chart-box { width: 100%; min-height: 220px; }
.chart-svg { display: block; outline: none; }
.chart-svg:focus-visible { outline: 2px solid var(--blue); outline-offset: 4px; border-radius: 4px; }
.chart-card .table-view { display: none; max-height: 320px; overflow: auto; }
.chart-card.show-table .table-view { display: block; }
.chart-card.show-table .chart-view { display: none; }
.hbars { display: grid; gap: 10px; }
.hbar { display: grid; grid-template-columns: minmax(110px, 34%) 1fr auto; align-items: center; gap: 12px; padding: 2px 4px; border-radius: 6px; outline: none; }
.hbar:hover, .hbar:focus-visible { background: #f4f6f9; }
.hbar:focus-visible { box-shadow: 0 0 0 2px var(--blue); }
.hbar .lbl { font-size: 13px; color: #191919; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar .track { display: flex; height: 16px; align-items: stretch; }
.hbar .track i { display: block; height: 16px; margin-right: 2px; min-width: 2px; }
.hbar .track i:last-child { margin-right: 0; border-radius: 0 4px 4px 0; }
.hbar .val { font-size: 13px; color: #191919; font-variant-numeric: tabular-nums; text-align: right; min-width: 56px; }
.legend { display: flex; gap: 16px; margin-bottom: 10px; font-size: 13px; color: #191919; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.ctip { position: fixed; z-index: 1000; display: none; pointer-events: none; background: #fff; border: 1px solid #e3e8ef; border-radius: 8px; box-shadow: var(--shadow-lg); padding: 8px 10px; font-size: 12px; color: #191919; min-width: 150px; max-width: 280px; }
.ctip b { display: block; margin-bottom: 4px; font-size: 12px; }
.ctip div { display: flex; align-items: center; gap: 6px; padding: 1px 0; }
.ctip div i { width: 8px; height: 8px; border-radius: 2px; flex: none; }
.ctip div span { flex: 1; color: #666666; }
.ctip div em { font-style: normal; font-variant-numeric: tabular-nums; font-weight: 600; }
.rlist { display: grid; }
.rrow { display: grid; gap: 2px; padding: 12px 18px; border-bottom: 1px solid var(--line-2); color: inherit; text-decoration: none; }
.rrow:last-child { border-bottom: 0; }
.rrow:hover { background: #fafbfc; text-decoration: none; }
.rrow b { color: var(--blue); }
.rrow small { line-height: 1.45; }
.def-card { line-height: 1.55; }
@media (max-width: 1180px) { .dash-top, .dash-charts { grid-template-columns: 1fr; } }

/* ---------- Auto-fill (SCH-07) */
.af-list { display: grid; border: 1px solid var(--line); border-radius: var(--r-sm); }
.af-row { display: grid; grid-template-columns: auto minmax(160px, 1fr) minmax(0, 1.6fr) auto; align-items: center; gap: 14px; padding: 10px 12px; border-bottom: 1px solid var(--line-2); cursor: pointer; }
.af-row:last-child { border-bottom: 0; }
.af-row input { width: 16px; height: 16px; accent-color: var(--blue); }
.af-row.off { cursor: default; grid-template-columns: auto minmax(160px, 1fr) minmax(0, 1.6fr) auto; }
.af-visit, .af-cg > div { display: grid; gap: 1px; min-width: 0; }
.af-visit span, .af-cg span:not(.av) { font-size: 12px; color: var(--muted); }
.af-cg { display: flex; align-items: center; gap: 10px; min-width: 0; }
.af-cg .af-note { color: var(--warn) !important; }
.af-why { font-size: 13px; color: var(--ink-2); }
.sched .openrow .cg .btn { display: flex; width: fit-content; margin-top: 2px; padding-left: 0; }

/* ---------- Address lookup (DAT-02) */
.geo { gap: 8px; }
.geo-row { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; }
.geo-zip { width: 140px; }
.geo-status { font-size: 13px; color: var(--muted); padding-bottom: 10px; }
.geo-status.ok { color: var(--ok); font-weight: 500; }
.geo-list { display: grid; border: 1px solid var(--line); border-radius: var(--r-sm); overflow: hidden; }
.geo-list[hidden], .geo [data-geo-manual][hidden] { display: none; }
.geo-opt { display: grid; gap: 2px; text-align: left; padding: 9px 12px; border: 0; border-bottom: 1px solid var(--line-2); background: #fff; cursor: pointer; font: inherit; color: inherit; }
.geo-opt:last-child { border-bottom: 0; }
.geo-opt:hover { background: #fafbfc; }
.geo-opt.on { background: var(--blue-50); box-shadow: inset 3px 0 0 var(--blue); }
.geo-opt small { color: var(--muted); }
