/* ==========================================================================
   Kavod Homecare — admin portal
   Loaded after style.css (shares its tokens, buttons and form fields).
   ========================================================================== */

:root {
    --sidebar-w: 256px;
    --topbar-h: 68px;
    --admin-bg: #F3F7F7;

    --danger: #C2410C;
    --danger-strong: #B42318;
    --danger-tint: #FEECE8;
    --warning: #92400E;
    --warning-tint: #FEF3C7;
    --info: #1D4ED8;
    --info-tint: #E0E9FF;
    --neutral-tint: #EEF1F4;

    /* Chart palette (validated: CVD-safe, ≥3:1 on white) */
    --chart-1: #0B8AA0; /* validated with dataviz validate_palette.js against --chart-2 (CVD ΔE 14.4) */
    --chart-2: #D9503F;
    --chart-grid: #E6EAED;
}

/* ---------- Small utilities ---------- */
[hidden] { display: none !important; }
.icon { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-sm { width: 16px; height: 16px; }
.muted { color: var(--muted); }
.mono { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }
.nowrap { white-space: nowrap; }
.center { text-align: center !important; }
.num { text-align: right !important; font-variant-numeric: tabular-nums; white-space: nowrap; }
code { font-size: .9em; background: var(--neutral-tint); padding: 1px 6px; border-radius: 4px; }

.btn .icon { margin: 0 -2px; }
.btn-sm { padding: .45em .9em; font-size: .85rem; }
.btn[disabled] { opacity: .45; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-danger { background: var(--danger-strong); color: #fff; }
.btn-danger:hover { background: #912018; }
.btn-danger-soft { background: var(--danger-tint); color: var(--danger-strong); }
.btn-danger-soft:hover { background: #FBD5CD; }
.btn-success-soft { background: var(--success-tint); color: var(--success); }
.btn-success-soft:hover { background: #BBF7D0; }

/* ---------- Badges ---------- */
.badge { white-space: nowrap; line-height: 1.6; }
.badge-success { background: var(--success-tint); color: var(--success); }
.badge-warning { background: var(--warning-tint); color: var(--warning); }
.badge-danger  { background: var(--danger-tint); color: var(--danger-strong); }
.badge-info    { background: var(--info-tint); color: var(--info); }
.badge-neutral { background: var(--neutral-tint); color: var(--muted); }

.yes, .no { display: inline-flex; align-items: center; gap: 4px; font-weight: 600; font-size: .9rem; }
.yes { color: var(--success); }
.no { color: var(--danger-strong); }
.rating { color: #B45309; font-weight: 600; }

/* ---------- Alerts & notices ---------- */
.alert { padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 20px; font-size: .95rem; border: 1px solid transparent; }
.alert p { margin: 0; }
.alert p + p { margin-top: 4px; }
.alert-success { background: var(--success-tint); color: #14532D; border-color: #BBF7D0; }
.alert-error   { background: var(--danger-tint); color: #7A271A; border-color: #FBD5CD; }
.alert-warning { background: var(--warning-tint); color: #78350F; border-color: #FDE68A; }
.alert-invite  { background: var(--info-tint); color: #1E3A8A; border-color: #C7D7FE; }

.invite-link { display: flex; gap: 8px; margin-top: 10px; }
.invite-link input { flex: 1; min-width: 0; padding: 8px 10px; border: 1px solid #C7D7FE; border-radius: 6px; font: .85rem/1.3 ui-monospace, Consolas, monospace; background: #fff; color: var(--ink); }

.demo-notice {
    display: flex; gap: 10px; align-items: flex-start;
    padding: 10px 14px; margin-bottom: 20px;
    border: 1px dashed #F3B4AA; border-radius: var(--radius-sm);
    background: #FFF8F6; color: #7A271A; font-size: .88rem;
}
.demo-notice p { margin: 0; }
.demo-notice .icon { margin-top: 2px; color: var(--coral-dark); }

/* ==========================================================================
   Auth pages (login, setup, signup)
   ========================================================================== */
.auth-body { background: var(--bg-soft); }
.auth-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(360px, 5fr) 7fr; }

.auth-brand {
    position: relative; overflow: hidden;
    display: flex; flex-direction: column; justify-content: space-between; gap: 40px;
    padding: 48px;
    background: var(--teal-deep); color: #fff;
}
.auth-brand::before, .auth-brand::after {
    content: ""; position: absolute; border-radius: 50%;
    border: 56px solid rgba(255, 255, 255, .05);
}
.auth-brand::before { width: 520px; height: 520px; right: -260px; top: -140px; }
.auth-brand::after { width: 300px; height: 300px; left: -150px; bottom: -110px; border-color: rgba(201, 79, 47, .12); }
.auth-logo .logo { height: 44px; width: auto; position: relative; }
.auth-brand-copy { position: relative; max-width: 26em; }
.auth-brand-tag { display: inline-block; font-size: .78rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: #F4A28C; margin-bottom: 12px; }
.auth-brand h2 { font-size: clamp(1.5rem, 2.4vw, 2.1rem); line-height: 1.2; }
.auth-brand-points { position: relative; list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; color: rgba(255, 255, 255, .8); font-size: .95rem; }
.auth-brand-points li { display: flex; gap: 10px; align-items: center; }
.auth-brand-points li::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #F4A28C; flex: none; }

.auth-main { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 48px 24px; }
.auth-card { width: 100%; max-width: 440px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 40px; box-shadow: var(--shadow); }
.auth-card h1 { font-size: 1.9rem; margin-bottom: .25em; }
.auth-intro { color: var(--muted); margin-bottom: 24px; }
.auth-logo-mobile { display: none; }
.auth-form { margin-top: 8px; }
.auth-row { display: flex; justify-content: space-between; align-items: center; margin: -4px 0 22px; }
.auth-help { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line); font-size: .88rem; color: var(--muted); }
.auth-help p { margin: 0 0 8px; }
.auth-help strong { color: var(--ink); }
.auth-footer { margin-top: 20px; font-size: .9rem; }
.auth-footer a { color: var(--muted); text-decoration: none; }
.auth-footer a:hover { color: var(--teal); }

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field-hint { font-size: .82rem; color: var(--muted); margin: 6px 0 0; }
.field input[readonly] { background: var(--bg-soft); color: var(--muted); }

.password-wrap { position: relative; }
.password-wrap input { padding-right: 70px; }
.password-toggle {
    position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
    border: 0; background: transparent; color: var(--teal); font: 600 .82rem var(--font-main);
    padding: 6px 10px; border-radius: 6px; cursor: pointer;
}
.password-toggle:hover { background: var(--teal-tint); }

.strength { display: flex; align-items: center; gap: 10px; margin-top: 8px; font-size: .8rem; color: var(--muted); }
.strength-bar { flex: 0 0 90px; height: 6px; border-radius: 99px; background: var(--neutral-tint); overflow: hidden; }
.strength-bar span { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--danger-strong); transition: width .2s, background-color .2s; }
.strength[data-level="2"] .strength-bar span { width: 50%; background: #D97706; }
.strength[data-level="3"] .strength-bar span { width: 75%; background: var(--teal); }
.strength[data-level="4"] .strength-bar span { width: 100%; background: var(--success); }
.strength[data-level="1"] .strength-bar span { width: 25%; }

.checkbox { display: inline-flex; gap: 10px; align-items: flex-start; font-size: .92rem; cursor: pointer; }
.checkbox input { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--teal); flex: none; }
.checkbox-block { display: flex; margin: 4px 0 22px; color: var(--muted); }

/* ==========================================================================
   Portal shell
   ========================================================================== */
.admin-body { background: var(--admin-bg); }
.admin-shell { display: flex; min-height: 100vh; }

.sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: 40;
    width: var(--sidebar-w);
    display: flex; flex-direction: column;
    background: var(--teal-deep); color: rgba(255, 255, 255, .78);
}
.sidebar-logo { display: block; padding: 20px 22px 14px; }
.sidebar-logo .logo { height: 36px; width: auto; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 4px 12px 16px; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.2) transparent; }
.sidebar-nav ul { list-style: none; margin: 0; padding: 0; }
.sidebar-section { margin: 18px 12px 6px; font-size: .7rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: rgba(255, 255, 255, .45); }
.sidebar-link {
    display: flex; align-items: center; gap: 12px;
    padding: 9px 12px; margin: 1px 0;
    border-radius: 10px; color: inherit; text-decoration: none; font-weight: 500; font-size: .95rem;
    transition: background-color .15s, color .15s;
}
.sidebar-link:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.sidebar-link.is-active { background: rgba(255, 255, 255, .12); color: #fff; box-shadow: inset 3px 0 0 var(--coral); }
.sidebar-link .icon { opacity: .9; }
.sidebar-link > span:first-of-type { flex: 1; }
.nav-count {
    min-width: 22px; padding: 0 7px; border-radius: 99px;
    background: var(--coral); color: var(--on-coral);
    font-size: .72rem; font-weight: 700; line-height: 1.75; text-align: center;
    box-shadow: 0 0 0 2px var(--teal-deep);
}

.sidebar-user { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-top: 1px solid rgba(255, 255, 255, .1); }
.sidebar-user-text { flex: 1; min-width: 0; line-height: 1.3; }
.sidebar-user-text strong { display: block; color: #fff; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-text span { font-size: .78rem; }
.sidebar-user form { margin: 0; }

.avatar {
    display: inline-grid; place-items: center; flex: none;
    width: 36px; height: 36px; border-radius: 50%;
    background: var(--teal-tint); color: var(--teal-dark);
    font: 700 .8rem var(--font-main); letter-spacing: .02em;
}
.sidebar .avatar { background: var(--coral); color: var(--on-coral); }
.avatar-sm { width: 32px; height: 32px; font-size: .75rem; }
.avatar-lg { width: 56px; height: 56px; font-size: 1.05rem; }
.avatar-lg .icon { width: 26px; height: 26px; }
.avatar-coral { background: var(--coral-tint); color: var(--coral-dark); }
.avatar-ghost { background: var(--neutral-tint); color: var(--muted); }

.icon-btn {
    display: inline-grid; place-items: center;
    width: 40px; height: 40px; border-radius: 10px; border: 0;
    background: transparent; color: var(--ink); cursor: pointer;
}
.icon-btn:hover { background: var(--neutral-tint); }
.icon-btn-dark { color: rgba(255, 255, 255, .75); width: 36px; height: 36px; }
.icon-btn-dark:hover { background: rgba(255, 255, 255, .1); color: #fff; }

.admin-main { flex: 1; min-width: 0; margin-left: var(--sidebar-w); display: flex; flex-direction: column; }

.topbar {
    position: sticky; top: 0; z-index: 30;
    display: flex; align-items: center; gap: 16px;
    min-height: var(--topbar-h); padding: 10px 32px;
    background: rgba(243, 247, 247, .9);
    backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--line);
}
.topbar-title { flex: 1; min-width: 0; }
.topbar h1 { font-size: 1.45rem; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.breadcrumb { display: inline-flex; align-items: center; gap: 2px; font-size: .82rem; color: var(--muted); text-decoration: none; font-weight: 600; }
.breadcrumb:hover { color: var(--teal); }
.topbar-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.sidebar-toggle { display: none; }

.admin-content { padding: 28px 32px 56px; width: 100%; max-width: 1360px; }
.page-intro { color: var(--muted); margin: 0 0 20px; }

/* ---------- Panels ---------- */
.panel { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; margin-bottom: 20px; }
.panel-flush { padding: 0; overflow: hidden; }
.panel-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.panel-head-pad { padding: 18px 22px 0; }
.panel-head h2, .panel-title { font-size: 1.1rem; margin: 0; }
.panel-title { margin-bottom: 16px; }
.panel-head p { margin: 2px 0 0; font-size: .86rem; color: var(--muted); }
.panel-link { display: inline-flex; align-items: center; gap: 4px; margin-top: 14px; font-weight: 600; font-size: .9rem; text-decoration: none; }
.stack > .panel:last-child { margin-bottom: 0; }

.live-dot { display: inline-flex; align-items: center; gap: 6px; font-size: .78rem; font-weight: 700; color: var(--success); text-transform: uppercase; letter-spacing: .06em; }
.live-dot::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 0 rgba(21, 128, 61, .5); animation: pulse 2s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 8px rgba(21, 128, 61, 0); } 100% { box-shadow: 0 0 0 0 rgba(21, 128, 61, 0); } }

/* ---------- Stat tiles ---------- */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stats-grid-3 { grid-template-columns: repeat(3, 1fr); }
.stat {
    position: relative; display: flex; flex-direction: column; gap: 2px;
    padding: 16px 18px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
    color: var(--ink); text-decoration: none; transition: border-color .15s, box-shadow .15s, transform .15s;
}
a.stat:hover { border-color: transparent; box-shadow: var(--shadow); transform: translateY(-2px); }
.stat-icon { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; margin-bottom: 8px; background: var(--teal-tint); color: var(--teal); }
.stat-coral .stat-icon { background: var(--coral-tint); color: var(--coral-dark); }
.stat-label { font-size: .84rem; color: var(--muted); font-weight: 500; }
.stat-value { font-family: var(--font-heading); font-size: 1.65rem; font-weight: 700; line-height: 1.15; font-variant-numeric: tabular-nums; }
.stat-note { font-size: .78rem; color: var(--muted); }

/* ---------- Dashboard ---------- */
.dash-grid { display: grid; grid-template-columns: 3fr 2fr; gap: 20px; }
.dash-grid > .panel { margin-bottom: 20px; }
.chart-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }

.alert-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.alert-item {
    display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center;
    padding: 12px 14px; border-radius: 10px; background: var(--bg-soft); border-left: 3px solid var(--line);
}
.alert-item > .icon { align-self: start; margin-top: 2px; }
.alert-item strong { display: block; font-size: .93rem; }
.alert-item p { margin: 2px 0 0; font-size: .84rem; color: var(--muted); }
.alert-item-danger { border-left-color: var(--danger-strong); }
.alert-item-danger > .icon { color: var(--danger-strong); }
.alert-item-warning { border-left-color: #D97706; }
.alert-item-warning > .icon { color: #B45309; }

.people-list { list-style: none; margin: 0; padding: 0; }
.people-list li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.people-list li:last-child { border-bottom: 0; }
.people-main { flex: 1; min-width: 0; line-height: 1.35; }
.people-main strong { display: block; font-size: .93rem; }
.people-main span { font-size: .82rem; color: var(--muted); }

.quick-actions h2 { font-size: 1.1rem; margin-bottom: 14px; }
.quick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.quick-card {
    display: grid; grid-template-columns: auto 1fr; column-gap: 12px; align-items: center;
    padding: 14px 16px; border: 1px solid var(--line); border-radius: 12px; text-decoration: none; color: var(--ink);
    transition: border-color .15s, background-color .15s;
}
.quick-card:hover { border-color: var(--teal); background: var(--teal-tint); }
.quick-card .icon { grid-row: span 2; color: var(--teal); width: 24px; height: 24px; }
.quick-card span { font-size: .8rem; color: var(--muted); }

/* ---------- Charts ---------- */
.chart-panel { margin: 0 0 20px; display: flex; flex-direction: column; }
.chart-panel .panel-head { margin-bottom: 8px; }
.chart { position: relative; height: 220px; margin-top: 4px; }
.chart svg { width: 100%; height: 100%; overflow: visible; }
.chart .grid line { stroke: var(--chart-grid); stroke-width: 1; shape-rendering: crispEdges; }
.chart .axis text { fill: var(--muted); font: 500 11px var(--font-main); }
.chart .bar { transition: opacity .15s; }
.chart .series-0 { fill: var(--chart-1); }
.chart .series-1 { fill: var(--chart-2); }
.chart .value-label { fill: var(--ink); font: 600 11px var(--font-main); }
.chart .hit { fill: transparent; cursor: default; }
.chart .hit:hover + .hover-band, .chart .hover-band.is-on { opacity: 1; }
.chart .hover-band { fill: var(--teal-tint); opacity: 0; transition: opacity .1s; }
.chart.is-hovering .bar:not(.is-hot) { opacity: .45; }
.chart-tooltip {
    position: absolute; pointer-events: none; z-index: 5;
    background: var(--ink); color: #fff; border-radius: 8px; padding: 8px 10px;
    font-size: .8rem; line-height: 1.4; white-space: nowrap; box-shadow: var(--shadow);
    transform: translate(-50%, calc(-100% - 10px));
}
.chart-tooltip strong { display: block; font-size: .78rem; color: rgba(255,255,255,.7); font-weight: 600; }
.chart-tooltip .tt-row { display: flex; align-items: center; gap: 6px; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; list-style: none; margin: 0 0 6px; padding: 0; font-size: .82rem; color: var(--muted); }
.chart-legend li { display: inline-flex; align-items: center; gap: 6px; }
.chart-key { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.chart-key-0 { background: var(--chart-1); }
.chart-key-1 { background: var(--chart-2); }
.chart-table { margin-top: 10px; font-size: .84rem; }
.chart-table summary { cursor: pointer; color: var(--teal); font-weight: 600; width: max-content; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th, .table td { padding: 12px 16px; text-align: left; vertical-align: middle; border-bottom: 1px solid var(--line); }
.table thead th { font-size: .74rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); background: #FAFCFC; white-space: nowrap; }
.panel-flush .table th:first-child, .panel-flush .table td:first-child { padding-left: 22px; }
.panel-flush .table th:last-child, .panel-flush .table td:last-child { padding-right: 22px; }
.table tbody tr:last-child td, .table tbody tr:last-child th { border-bottom: 0; }
.table tbody tr:hover { background: #FAFCFC; }
.table-compact th, .table-compact td { padding: 7px 10px; }
.cell-person { display: flex; align-items: center; gap: 10px; }
.cell-link { font-weight: 600; color: var(--ink); text-decoration: none; }
.cell-link:hover { color: var(--teal); text-decoration: underline; }
.cell-actions { text-align: right; white-space: nowrap; }
.cell-actions form { display: inline; }
.cell-actions .btn + .btn, .cell-actions form + form { margin-left: 6px; }
.empty-row { text-align: center !important; color: var(--muted); padding: 32px !important; }
.row-muted td { background: #FCFCFD; }

/* ---------- Filters & tabs ---------- */
.filter-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 16px; }
.filter-bar > input, .filter-bar > select, .search-field input, .inline-select select {
    padding: 9px 12px; border: 1.5px solid var(--line); border-radius: var(--radius-sm); font: inherit; font-size: .92rem; background: #fff; color: var(--ink);
}
.filter-bar > input:focus, .filter-bar > select:focus, .search-field input:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px var(--teal-tint); }
.filter-bar-flat { margin: 0; align-items: flex-end; }
.filter-bar-flat .field { margin: 0; }
.search-field { position: relative; flex: 1 1 260px; max-width: 380px; }
.search-field .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search-field input { width: 100%; padding-left: 36px; }

.tab-list { display: flex; gap: 4px; overflow-x: auto; margin-bottom: 16px; border-bottom: 1px solid var(--line); scrollbar-width: none; }
.tab {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 10px 14px; margin-bottom: -1px; border: 0; border-bottom: 2px solid transparent;
    background: none; color: var(--muted); font: 600 .92rem var(--font-main); text-decoration: none; white-space: nowrap; cursor: pointer;
}
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"], .tab[aria-current="page"] { color: var(--teal-dark); border-bottom-color: var(--teal); }
.tab-count { min-width: 22px; padding: 0 7px; border-radius: 99px; background: var(--neutral-tint); font-size: .75rem; text-align: center; line-height: 1.7; }
.tab[aria-current="page"] .tab-count { background: var(--teal-tint); color: var(--teal-dark); }

/* ---------- Detail pages ---------- */
.detail-head { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; margin-bottom: 20px; }
.detail-head h2 { font-size: 1.4rem; margin: 0; }
.detail-head p { margin: 2px 0 0; color: var(--muted); font-size: .92rem; }
.detail-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-left: auto; }
.detail-grid { display: grid; grid-template-columns: 3fr 2fr; gap: 20px; align-items: start; }
.detail-grid > .panel { margin-bottom: 20px; }

.dl-grid { display: grid; grid-template-columns: minmax(130px, auto) 1fr; gap: 10px 20px; margin: 0; font-size: .93rem; }
.dl-grid dt { color: var(--muted); }
.dl-grid dd { margin: 0; font-weight: 500; }

.doc-list { list-style: none; margin: 0; padding: 0; }
.doc-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.doc-row:last-child { border-bottom: 0; }
.doc-icon { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; background: var(--neutral-tint); color: var(--muted); }
.doc-main { flex: 1; min-width: 180px; line-height: 1.35; }
.doc-main strong { display: block; font-size: .93rem; }
.doc-main span { font-size: .8rem; color: var(--muted); }
.doc-actions { display: flex; gap: 6px; width: 100%; padding-left: 50px; }

.decision-panel .btn-block { margin-bottom: 10px; }
.decision { margin-top: 4px; }
.decision summary { list-style: none; }
.decision summary::-webkit-details-marker { display: none; }
.decision[open] summary { margin-bottom: 12px; }
.decision .field { margin-bottom: 10px; }

.timeline, .history, .notes { list-style: none; margin: 0; padding: 0; }
.timeline li { display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.timeline li:last-child { border-bottom: 0; }
.timeline strong { display: block; font-size: .93rem; }
.timeline span { font-size: .82rem; color: var(--muted); }
.history li { position: relative; padding: 0 0 18px 22px; }
.history li::before { content: ""; position: absolute; left: 4px; top: 7px; width: 9px; height: 9px; border-radius: 50%; background: var(--line); border: 2px solid #fff; box-shadow: 0 0 0 1px var(--line); }
.history li:not(:last-child)::after { content: ""; position: absolute; left: 8px; top: 18px; bottom: 0; width: 1px; background: var(--line); }
.history li.history-key::before { background: var(--coral); box-shadow: 0 0 0 1px var(--coral); }
.history strong { display: block; font-size: .93rem; }
.history span { font-size: .84rem; color: var(--muted); }
.notes li { padding: 12px 14px; background: var(--warning-tint); border-radius: 10px; margin-bottom: 14px; }
.notes p { margin: 0 0 4px; }
.notes span { font-size: .8rem; color: var(--warning); }
.privacy-note { display: flex; align-items: center; gap: 8px; font-size: .84rem; color: var(--muted); }

/* ---------- Forms (admin) ---------- */
.form-layout { max-width: 880px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.form-grid-3 { grid-template-columns: repeat(3, 1fr); }
.form-grid-4 { grid-template-columns: repeat(4, 1fr); }
.field-span { grid-column: 1 / -1; }
.field-narrow { max-width: 320px; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; padding-top: 4px; }
.field select { appearance: none; background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235B6573' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") right 12px center / 16px no-repeat; padding-right: 36px; }

.input-affix { display: flex; align-items: stretch; border: 1.5px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; background: #fff; }
.input-affix:focus-within { border-color: var(--teal); box-shadow: 0 0 0 4px var(--teal-tint); }
.input-affix span { display: grid; place-items: center; padding: 0 12px; background: var(--bg-soft); color: var(--muted); font-weight: 600; }
.field .input-affix input { border: 0; box-shadow: none !important; border-radius: 0; }

.segmented { display: inline-flex; padding: 4px; margin-bottom: 18px; background: var(--neutral-tint); border-radius: 10px; }
.segmented label { position: relative; cursor: pointer; }
.segmented input { position: absolute; opacity: 0; }
.segmented span { display: block; padding: 7px 16px; border-radius: 7px; font-weight: 600; font-size: .9rem; color: var(--muted); }
.segmented input:checked + span { background: #fff; color: var(--ink); box-shadow: var(--shadow-sm); }
.segmented input:focus-visible + span { outline: 3px solid var(--coral-dark); }

.weekdays { display: flex; flex-wrap: wrap; gap: 6px; border: 0; padding: 0; margin: 0 0 18px; }
.weekdays legend { font-weight: 600; font-size: .9rem; margin-bottom: 8px; }
.weekdays label { cursor: pointer; }
.weekdays input { position: absolute; opacity: 0; }
.weekdays span { display: grid; place-items: center; width: 48px; height: 40px; border-radius: 10px; border: 1.5px solid var(--line); font-weight: 600; font-size: .88rem; color: var(--muted); }
.weekdays input:checked + span { background: var(--teal); border-color: var(--teal); color: #fff; }
.weekdays input:focus-visible + span { outline: 3px solid var(--coral-dark); }

.calc-box { display: flex; flex-direction: column; justify-content: center; padding: 12px 16px; margin-bottom: 18px; border-radius: var(--radius-sm); background: var(--teal-tint); }
.calc-box span { font-size: .8rem; color: var(--teal-dark); }
.calc-box strong { font-family: var(--font-heading); font-size: 1.4rem; color: var(--teal-dark); }

.choice-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 18px; }
.choice-card { position: relative; cursor: pointer; }
.choice-card input { position: absolute; top: 18px; left: 16px; accent-color: var(--teal); width: 18px; height: 18px; }
.choice-body { display: block; padding: 14px 16px 14px 44px; border: 1.5px solid var(--line); border-radius: 12px; height: 100%; }
.choice-body strong { display: block; }
.choice-body span { font-size: .86rem; color: var(--muted); }
.choice-card input:checked + .choice-body { border-color: var(--teal); background: var(--teal-tint); }

/* ---------- Timesheets ---------- */
.entry-list { display: grid; gap: 14px; margin-bottom: 24px; }
.entry { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; }
.entry-flagged { border-left: 4px solid #D97706; }
.entry-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 14px; }
.entry-head .cell-person > div { line-height: 1.35; }
.entry-head .cell-person strong { display: block; }
.entry-head .muted { font-size: .84rem; }
.entry-times { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; margin: 0 0 12px; padding: 12px 14px; background: var(--bg-soft); border-radius: 10px; }
.entry-times dt { font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; }
.entry-times dd { margin: 2px 0 0; font-variant-numeric: tabular-nums; }
.entry-note, .entry-comment { margin: 0 0 8px; font-size: .9rem; }
.entry-comment { padding: 8px 12px; border-radius: 8px; background: var(--info-tint); color: #1E3A8A; }
.flag-line { display: flex; align-items: center; gap: 6px; margin: 0 0 6px; color: #92400E; font-weight: 600; font-size: .88rem; }
.entry-actions { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 8px; padding-top: 12px; margin-top: 8px; border-top: 1px solid var(--line); }
.inline-form summary { list-style: none; }
.inline-form summary::-webkit-details-marker { display: none; }
.inline-form[open] { flex-basis: 100%; order: 5; }
.inline-form-body { margin-top: 10px; padding: 14px; border-radius: 10px; background: var(--bg-soft); }

/* ---------- Payroll ---------- */
.payroll-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 20px; }
.stepper { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; margin: 0; padding: 0; counter-reset: s; }
.stepper li { display: flex; align-items: center; gap: 8px; padding: 6px 12px 6px 6px; border-radius: 99px; background: var(--neutral-tint); font-size: .84rem; font-weight: 600; color: var(--muted); }
.stepper span { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: #fff; font-size: .78rem; }
.stepper .is-current { background: var(--teal); color: #fff; }
.stepper .is-current span { color: var(--teal); }
.payroll-person th, .payroll-person td { background: #FAFCFC; font-weight: 600; }
.payroll-person th .badge, .payroll-person th .muted { margin-left: 6px; font-weight: 500; font-size: .78rem; }
.payroll-line td { color: var(--muted); font-size: .88rem; padding-top: 8px !important; padding-bottom: 8px !important; }
.payroll-line td:first-child { padding-left: 40px !important; }
.payroll-table tfoot th, .payroll-table tfoot td { padding: 14px 16px; border-top: 2px solid var(--ink); font-size: 1rem; }
.payroll-table tfoot th { padding-left: 22px; text-align: left; }
.payroll-table tfoot td:last-child { padding-right: 22px; }
.chip-list { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; margin: 12px 0 0; padding: 0; }
.chip { padding: 5px 12px; border-radius: 99px; background: var(--warning-tint); color: var(--warning); font-size: .84rem; }
.action-panel { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 16px; }
.action-panel p { margin: 0; max-width: 34em; }
.action-buttons { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- Invoice ---------- */
.invoice-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 16px; }
.invoice-paper { max-width: 820px; background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 48px 56px; box-shadow: var(--shadow); }
.invoice-top { display: flex; justify-content: space-between; gap: 32px; margin-bottom: 36px; }
.invoice-top p, .invoice-to p { margin: 4px 0 0; color: var(--muted); font-size: .92rem; }
.invoice-label { font-size: .74rem !important; text-transform: uppercase; letter-spacing: .08em; font-weight: 700; color: var(--muted); margin: 0 0 6px !important; }
.invoice-meta { text-align: right; }
.invoice-meta h2 { font-size: 2rem; color: var(--teal); margin-bottom: 10px; }
.invoice-meta dl { display: grid; grid-template-columns: auto auto; gap: 4px 16px; margin: 0; font-size: .9rem; }
.invoice-meta dt { color: var(--muted); }
.invoice-meta dd { margin: 0; font-weight: 600; }
.invoice-to { margin-bottom: 28px; }
.invoice-lines { margin-bottom: 20px; }
.invoice-lines th:first-child, .invoice-lines td:first-child { padding-left: 0; }
.invoice-lines th:last-child, .invoice-lines td:last-child { padding-right: 0; }
.invoice-totals { display: grid; grid-template-columns: 1fr auto; gap: 8px 32px; max-width: 300px; margin: 0 0 24px auto; font-variant-numeric: tabular-nums; }
.invoice-totals dt { color: var(--muted); }
.invoice-totals dd { margin: 0; text-align: right; }
.invoice-grand { font-weight: 700; font-size: 1.15rem; color: var(--ink) !important; padding-top: 8px; border-top: 2px solid var(--ink); }
.invoice-note { font-size: .88rem; padding: 10px 14px; background: var(--bg-soft); border-radius: 8px; }
.invoice-foot { margin-top: 28px; padding-top: 18px; border-top: 1px solid var(--line); font-size: .86rem; color: var(--muted); }
.invoice-foot p { margin: 0 0 4px; }

/* ---------- Reports & settings ---------- */
.reports-layout, .settings-layout { display: grid; grid-template-columns: 220px 1fr; gap: 20px; align-items: start; }
.report-nav { position: sticky; top: calc(var(--topbar-h) + 20px); display: flex; flex-direction: column; gap: 2px; }
.report-nav a { padding: 9px 12px; border-radius: 8px; color: var(--muted); font-weight: 600; font-size: .92rem; text-decoration: none; }
.report-nav a:hover { background: #fff; color: var(--ink); }
.report-nav a[aria-current="page"] { background: #fff; color: var(--teal-dark); box-shadow: inset 3px 0 0 var(--teal); }
.settings-layout .panel { scroll-margin-top: calc(var(--topbar-h) + 20px); }
.invite-form { margin-top: 20px; padding: 18px; border-radius: 12px; background: var(--bg-soft); }
.invite-form h3 { font-size: 1rem; margin-bottom: 12px; }
.form-grid-invite { grid-template-columns: 2fr 1fr auto; align-items: end; }
.form-grid-invite .btn { margin-bottom: 18px; }
.inline-select { margin: 0; }
.inline-select select { padding: 6px 10px; font-size: .88rem; }
.role-matrix { margin-top: 16px; }
.role-matrix summary { cursor: pointer; font-weight: 600; color: var(--teal); margin-bottom: 10px; }
.toggle-list { list-style: none; margin: 0 0 16px; padding: 0; }
.toggle-list li { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.switch { position: relative; width: 42px; height: 24px; flex: none; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 99px; background: #CBD3DA; transition: background-color .15s; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: var(--shadow-sm); }
.switch input:checked + span { background: var(--teal); }
.switch input:checked + span::after { transform: translateX(18px); }
.switch input:focus-visible + span { outline: 3px solid var(--coral-dark); outline-offset: 2px; }

/* ---------- Map ---------- */
.map { height: 380px; border-radius: 10px; overflow: hidden; background: var(--bg-soft); z-index: 0; }
.map-key { width: 12px; height: 12px; border-radius: 50%; display: inline-block; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--line); }
.map-key-home { background: var(--teal-deep); border-radius: 3px; }
.map-key-ok { background: var(--chart-1); }
.map-key-bad { background: var(--chart-2); }

/* ---------- Offers & patients ---------- */
.geo-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 6px; }
.geo-row .field-hint { margin: 0; }
.detail-actions form { margin: 0; }
.tab-count-alert { background: var(--coral) !important; color: var(--on-coral) !important; }
.plain-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: .9rem; }
.history li span { display: block; }
.request-row { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.request-row:last-child { border-bottom: 0; }
.request-row p { margin: 2px 0 0; font-size: .88rem; }
.request-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0; }
.request-actions input { padding: 7px 10px; border: 1.5px solid var(--line); border-radius: var(--radius-sm); font: inherit; font-size: .85rem; min-width: 220px; }

.not-built { background: #fff; border: 1px dashed #C9D3D9; border-radius: var(--radius); margin-bottom: 20px; }
.not-built h2 { font-size: 1.25rem; }
.not-built p { max-width: 34em; margin: 0 auto 16px; }
.not-built-icon { display: inline-grid; place-items: center; width: 56px; height: 56px; margin-bottom: 12px; border-radius: 16px; background: var(--teal-tint); color: var(--teal); }
.not-built-icon .icon { width: 28px; height: 28px; }
.not-built-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }

/* ---------- Settings: email (SMTP) ---------- */
.mb-16 { margin-bottom: 16px; }
.mt-6 { margin-top: 6px; }
.small { font-size: .84rem; }
.form-grid-smtp { grid-template-columns: 2fr 1fr 1.6fr; }
.form-actions-left { justify-content: flex-start; flex-wrap: wrap; padding-top: 8px; }
.provider-presets { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 16px; }
.provider-presets .field-hint { margin: 0 4px 0 0; }
.chip-btn {
    padding: 5px 12px; border-radius: 99px; border: 1.5px solid var(--line); background: #fff;
    font: 600 .82rem var(--font-main); color: var(--ink); cursor: pointer; transition: border-color .15s, background-color .15s;
}
.chip-btn:hover { border-color: var(--teal); background: var(--teal-tint); }
[data-smtp-fields] { transition: opacity .2s; }
[data-smtp-fields].is-muted { opacity: .45; }
@media (max-width: 640px) { .form-grid-smtp { grid-template-columns: 1fr; } }

/* ---------- Patient CSV import ---------- */
.icon-flip { transform: rotate(180deg); }
.import-layout { display: grid; grid-template-columns: 1fr 1.3fr; gap: 20px; }
.import-layout .panel { margin-bottom: 20px; }
.csv-drop {
    position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px;
    padding: 24px 16px; margin-bottom: 8px; border: 2px dashed #C9D3D9; border-radius: 14px;
    background: var(--bg-soft); text-align: center; cursor: pointer; transition: border-color .15s, background-color .15s;
}
.csv-drop:hover, .csv-drop.is-over { border-color: var(--teal); background: var(--teal-tint); }
.csv-drop.has-file { border-style: solid; border-color: var(--teal); background: var(--teal-tint); }
.csv-drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.csv-drop-icon { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; background: #fff; color: var(--teal); margin-bottom: 6px; }
.csv-drop .muted { font-size: .82rem; }
.import-rules { margin-top: 14px; }
.import-rules li { line-height: 1.5; }
.import-preview { max-height: 520px; overflow: auto; }
.import-preview thead th { position: sticky; top: 0; z-index: 1; }
.row-bad td { background: #FFF6F4; }
.row-dup td { background: #FFFCF0; }
.row-errors { margin: 4px 0 0; padding-left: 16px; font-size: .78rem; color: var(--danger-strong); }
.import-confirm { display: block; }
@media (max-width: 900px) { .import-layout { grid-template-columns: 1fr; } }

/* ---------- Contact messages ---------- */
.message-list { list-style: none; margin: 0; padding: 0; }
.message-list a { display: flex; align-items: flex-start; gap: 12px; padding: 14px 22px; border-bottom: 1px solid var(--line); color: var(--ink); text-decoration: none; }
.message-list li:last-child a { border-bottom: 0; }
.message-list a:hover { background: #FAFCFC; }
.message-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.message-main strong { font-size: .93rem; }
.message-main strong .muted { font-weight: 400; }
.message-main > span { font-size: .88rem; color: var(--muted); }
.message-when { font-size: .78rem; color: var(--muted); white-space: nowrap; }
.message-body p { margin: 0; font-size: 1rem; line-height: 1.7; white-space: normal; }
.message-when { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.replied { display: inline-flex; align-items: center; gap: 4px; color: var(--teal); font-weight: 600; }

/* Conversation */
.thread { display: flex; flex-direction: column; gap: 14px; margin-bottom: 20px; max-width: 820px; }
.bubble { max-width: 88%; padding: 14px 18px; border-radius: 16px; border: 1px solid var(--line); background: #fff; }
.bubble header { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin-bottom: 6px; font-size: .84rem; }
.bubble header span { color: var(--muted); }
.bubble p { margin: 0; line-height: 1.65; overflow-wrap: anywhere; }
.bubble-in { align-self: flex-start; border-top-left-radius: 4px; }
.bubble-out { align-self: flex-end; border-top-right-radius: 4px; background: var(--teal-tint); border-color: #CDE7E5; }
.bubble-saved { background: #FFFBEB; border-color: #FDE68A; }
.bubble-failed { background: var(--danger-tint); border-color: #FBD5CD; }
.bubble .badge { color: inherit; }
.bubble-error { margin-top: 8px !important; font-size: .84rem; color: var(--danger-strong); }
.thread-note { margin: -8px 0 16px; }
.reply-box { max-width: 820px; }
.reply-meta { display: flex; flex-wrap: wrap; gap: 4px 20px; margin: 0 0 10px; font-size: .88rem; color: var(--muted); }
.reply-meta strong { color: var(--ink); }
.reply-box textarea { min-height: 180px; line-height: 1.6; }
.reply-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.message-list .empty-row { display: block; padding: 32px; text-align: center; color: var(--muted); }

/* ---------- Email outbox ---------- */
.inline-test { margin: 10px 0 0; }
.outbox { display: grid; grid-template-columns: 320px 1fr; gap: 20px; align-items: start; }
.outbox-list { list-style: none; margin: 0; padding: 6px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); max-height: 720px; overflow-y: auto; }
.outbox-list a { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border-radius: 10px; color: var(--ink); text-decoration: none; }
.outbox-list a:hover { background: var(--bg-soft); }
.outbox-list a.is-open { background: var(--teal-tint); }
.outbox-list strong { font-size: .9rem; }
.outbox-list span { font-size: .78rem; color: var(--muted); }
.outbox-preview { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.outbox-meta { margin: 0; padding: 12px 16px; border-bottom: 1px solid var(--line); font-size: .88rem; }
.outbox-preview iframe { display: block; width: 100%; height: 720px; border: 0; background: #EEF3F4; }
@media (max-width: 900px) { .outbox { grid-template-columns: 1fr; } .outbox-list { max-height: 260px; } }

/* ---------- Misc ---------- */
.empty-state { text-align: center; padding: 64px 20px; }
.empty-state p { color: var(--muted); }
.pagination { display: flex; align-items: center; justify-content: flex-end; gap: 8px; font-size: .88rem; color: var(--muted); }
.pagination span { margin-right: auto; }

.toast {
    position: fixed; left: 50%; bottom: 24px; z-index: 100; transform: translateX(-50%);
    max-width: calc(100% - 32px); padding: 12px 18px; border-radius: 10px;
    background: var(--ink); color: #fff; font-size: .9rem; box-shadow: var(--shadow-lg);
}

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 1200px) {
    .chart-grid { grid-template-columns: 1fr 1fr; }
    .entry-times { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 1024px) {
    .sidebar { transform: translateX(-100%); transition: transform .25s ease; box-shadow: var(--shadow-lg); }
    .sidebar.is-open { transform: none; }
    .sidebar-backdrop { position: fixed; inset: 0; z-index: 35; background: rgba(10, 47, 56, .4); opacity: 0; visibility: hidden; transition: opacity .2s, visibility .2s; }
    .sidebar.is-open + .sidebar-backdrop { opacity: 1; visibility: visible; }
    .admin-main { margin-left: 0; }
    .sidebar-toggle { display: inline-grid; margin-left: -8px; }
    .dash-grid, .detail-grid { grid-template-columns: 1fr; }
    .reports-layout, .settings-layout { grid-template-columns: 1fr; }
    .report-nav { position: static; flex-direction: row; overflow-x: auto; scrollbar-width: none; }
    .report-nav a { white-space: nowrap; }
}

@media (max-width: 860px) {
    .auth-shell { grid-template-columns: 1fr; }
    .auth-brand { display: none; }
    .auth-logo-mobile { display: block; margin-bottom: 24px; }
    .auth-logo-mobile .logo { height: 38px; width: auto; }
    .chart-grid { grid-template-columns: 1fr; }
    .stats-grid-3 { grid-template-columns: 1fr 1fr 1fr; }
}

@media (max-width: 640px) {
    .topbar { padding: 10px 16px; }
    .topbar h1 { font-size: 1.2rem; }
    .topbar-actions .btn { padding: .55em .8em; font-size: .85rem; }
    .admin-content { padding: 20px 16px 40px; }
    .auth-main { padding: 24px 16px; }
    .auth-card { padding: 28px 22px; }
    .field-row, .form-grid, .form-grid-3, .form-grid-4, .form-grid-invite, .choice-cards { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .stats-grid-3 { grid-template-columns: 1fr; }
    .stat-value { font-size: 1.35rem; }
    .entry-times { grid-template-columns: 1fr 1fr; }
    .detail-actions { margin-left: 0; width: 100%; }
    .doc-actions { padding-left: 0; }
    .invoice-paper { padding: 28px 20px; }
    .invoice-top { flex-direction: column; }
    .invoice-meta { text-align: left; }
    .alert-item { grid-template-columns: auto 1fr; }
    .alert-item > .btn { grid-column: 2; justify-self: start; }
    .filter-bar > * { flex: 1 1 140px; }
}

/* ---------- Print (invoices) ---------- */
@media print {
    .sidebar, .topbar, .demo-notice, .no-print, .toast, .skip-link { display: none !important; }
    .admin-main { margin: 0; }
    .admin-content { padding: 0; }
    .admin-body { background: #fff; }
    .invoice-paper { border: 0; box-shadow: none; padding: 0; max-width: none; }
}
.chart-grid-1 { grid-template-columns: 1fr; }
.audience { border: 0; padding: 0; margin: 0 0 18px; }
.audience .checkbox-block { margin: 4px 0 8px; color: var(--ink); }
.audience .checkbox-block span { color: var(--muted); }
.audience .checkbox-block strong { color: var(--ink); }
img.avatar { object-fit: cover; }
.payment-review { border-color: #FDE68A; box-shadow: 0 0 0 1px #FDE68A; }
.compare tr.is-changed td:last-child { background: #EFF6FF; font-weight: 600; }
.payment-review-actions { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 10px; margin-top: 14px; }
.payment-review-actions form { margin: 0; }

/* ---------- Timesheets, attendance, payroll, invoices (live) ---------- */
.field-inline { display: flex; align-items: center; gap: 6px; font-size: .86rem; color: var(--muted); }
.field-inline input { padding: 8px 10px; border: 1.5px solid var(--line); border-radius: var(--radius-sm); font: inherit; font-size: .9rem; background: #fff; color: var(--ink); }
.inline-paid { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0; }
.inline-paid input[type="date"] { padding: 8px 10px; border: 1.5px solid var(--line); border-radius: var(--radius-sm); font: inherit; font-size: .9rem; }
.invoice-actions form, .invoice-actions details { margin: 0; }
.invoice-paper.is-void { position: relative; }
.invoice-void { margin: -20px 0 24px; padding: 10px 14px; border-radius: 8px; background: #FEECE8; color: #B42318; font-size: .92rem; }
.invoice-correction td { background: #FFFBEB; color: #92400E; }
.row-muted td { color: var(--muted); }
.row-muted td a { color: var(--muted); }
.map-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin: 0; color: var(--muted); }
.map-pin-home { background: var(--teal-deep, #0A2F38); border: 2px solid #fff; border-radius: 3px; box-shadow: 0 0 0 1px rgba(0, 0, 0, .2); }
.payroll-head h2 { margin: 0; }
.payroll-head .cal-nav { display: flex; align-items: center; gap: 10px; margin: 4px 0 0; }
.entry-head > div:last-child { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.entry-head .badge .icon { width: 12px; height: 12px; vertical-align: -1px; }
.entry-head .badge { white-space: nowrap; display: inline-flex; align-items: center; gap: 4px; }
.add-hours { padding: 0; }
.add-hours > summary { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; padding: 16px 20px; cursor: pointer; list-style: none; }
.add-hours > summary::-webkit-details-marker { display: none; }
.add-hours > summary strong { display: inline-flex; align-items: center; gap: 6px; color: var(--teal-dark); }
.add-hours > summary .muted { font-size: .88rem; }
.add-hours-form { padding: 0 20px 20px; }
.alert-item .action-buttons { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---------- Approval: confirm each visit with the patient ---------- */
.approval-steps { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; list-style: none; margin: 0 0 20px; padding: 0; }
.approval-steps li { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); }
.approval-steps li > span { display: grid; place-items: center; flex: none; width: 28px; height: 28px; border-radius: 50%; background: var(--teal); color: #fff; font-weight: 700; font-size: .88rem; }
.approval-steps strong { display: block; font-size: .95rem; }
.approval-steps p { margin: 2px 0 0; font-size: .84rem; color: var(--muted); }
.confirm-box { margin: 12px 0 4px; padding: 14px 16px; border-radius: 12px; background: var(--teal-tint); border: 1px solid rgba(18, 78, 92, .2); }
.call-patient { margin-bottom: 10px; line-height: 1.6; }
.call-label { display: block; font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--teal-dark); }
.call-link { display: inline-flex; align-items: center; gap: 4px; font-weight: 700; }
.confirm-check { margin: 4px 0 10px; font-weight: 600; }
.confirm-note { margin-bottom: 12px; }
.confirm-note input { max-width: 520px; }
.inline-form-body .call-patient { margin-top: 6px; padding-top: 10px; border-top: 1px solid var(--line); }
.entry-confirmed { display: flex; align-items: center; gap: 6px; margin: 0 0 8px; color: var(--success); font-size: .9rem; font-weight: 600; }
@media (max-width: 860px) { .approval-steps { grid-template-columns: 1fr; } }
.clock-details { margin: 0 0 8px; font-size: .88rem; }
.clock-details summary { cursor: pointer; color: var(--teal-dark); font-weight: 600; }
.clock-details .plain-list { margin-top: 6px; }
.clock-details .flag-line { display: inline; }
td .flag-line { margin: 0 0 2px; font-size: .82rem; }
.schedule-summary { margin: 0; padding: 10px 14px; border-radius: var(--radius-sm); background: var(--teal-tint); color: var(--teal-dark); font-weight: 600; font-size: .92rem; }
.schedule-summary:empty { display: none; }
.schedule-summary.is-bad { background: #FEECE8; color: #B42318; }

/* ---------- Dashboard ---------- */
.dash-hero { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: stretch; gap: 20px; padding: 24px 26px; margin-bottom: 18px; border-radius: var(--radius-lg, 18px); background: linear-gradient(135deg, var(--teal-deep, #0A2F38) 0%, var(--teal, #124E5C) 100%); color: #fff; }
.dash-hero-text { flex: 1 1 340px; }
.dash-hero-date { margin: 0 0 4px; font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: #F4A28C; }
.dash-hero h2 { margin: 0 0 6px; font-size: 1.6rem; color: #fff; }
.dash-hero p { margin: 0; color: rgba(255, 255, 255, .85); }
.dash-hero-money { display: flex; flex-direction: column; justify-content: center; gap: 2px; min-width: 240px; padding: 14px 18px; border-radius: 14px; background: rgba(255, 255, 255, .1); }
.dash-hero-money span { font-size: .82rem; color: rgba(255, 255, 255, .8); }
.dash-hero-money strong { font-family: var(--font-heading); font-size: 2rem; line-height: 1.15; color: #fff; }

.pipeline { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 18px; counter-reset: step; }
.pipeline-step { position: relative; display: flex; flex-direction: column; gap: 2px; padding: 14px 16px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); color: var(--ink); text-decoration: none; transition: box-shadow .15s, transform .15s; }
.pipeline-step:hover { box-shadow: var(--shadow-sm); transform: translateY(-1px); }
.pipeline-step:not(:last-child)::after { content: ""; position: absolute; right: -8px; top: 50%; width: 10px; height: 10px; border-top: 2px solid var(--line); border-right: 2px solid var(--line); transform: translateY(-50%) rotate(45deg); background: var(--bg-soft); z-index: 1; }
.pipeline-step.is-hot { border-color: var(--coral); box-shadow: 0 0 0 1px var(--coral); }
.pipeline-label { display: flex; align-items: center; gap: 6px; font-size: .8rem; font-weight: 700; color: var(--muted); }
.pipeline-num { display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: var(--teal-tint); color: var(--teal-dark); font-size: .72rem; }
.pipeline-step.is-hot .pipeline-num { background: var(--coral); color: var(--on-coral); }
.pipeline-step strong { font-family: var(--font-heading); font-size: 1.8rem; line-height: 1.1; }
.pipeline-amount { font-weight: 700; color: var(--teal-dark); font-variant-numeric: tabular-nums; }
.pipeline-hint { font-size: .78rem; color: var(--muted); }

.job-rows { list-style: none; margin: 0; padding: 0; }
.job-rows li { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.job-rows li:last-child { border-bottom: 0; }
.job-rows .people-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.job-rows .people-main > span { font-size: .84rem; color: var(--muted); }
.job-rows-amount { font-variant-numeric: tabular-nums; white-space: nowrap; }
.job-rows-side { display: flex; flex-direction: column; align-items: flex-end; }
.visit-time { flex: none; width: 52px; padding: 6px 0; text-align: center; border-radius: 8px; background: var(--bg-soft); font-weight: 700; font-variant-numeric: tabular-nums; }
.progress { display: block; height: 6px; margin-top: 4px; border-radius: 99px; background: var(--neutral-tint, #EEF1F4); overflow: hidden; max-width: 260px; }
.progress span { display: block; height: 100%; border-radius: 99px; background: var(--teal); }

@media (max-width: 1100px) { .pipeline { grid-template-columns: repeat(3, minmax(0, 1fr)); } .pipeline-step::after { display: none; } }
@media (max-width: 640px) {
    .pipeline { grid-template-columns: 1fr 1fr; }
    .dash-hero { padding: 20px; }
    .dash-hero-money { min-width: 0; flex: 1 1 100%; }
    .job-rows li { flex-wrap: wrap; }
}
.dash-grid { margin-bottom: 20px; }
.chart-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 900px) { .chart-grid-2 { grid-template-columns: 1fr; } }
.audit-record { margin-top: 6px; font-size: .86rem; }
.audit-record summary { cursor: pointer; color: var(--teal-dark); font-weight: 600; }
.audit-record .dl-grid { margin-top: 8px; padding: 10px 12px; border-radius: 8px; background: var(--bg-soft); }
.danger-link { color: var(--danger-strong, #B42318) !important; }

/* ---------- Patient invoices ---------- */
.pi-patient-pick { max-width: 640px; }
.pi-patient-pick .field { margin: 0; }
.pi-input { width: 100%; padding: 8px 10px; border: 1.5px solid var(--line); border-radius: var(--radius-sm); font: inherit; font-size: .9rem; background: #fff; color: var(--ink); }
.pi-input:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px var(--teal-tint); }
.pi-money { max-width: 130px; text-align: right; font-variant-numeric: tabular-nums; }
.pi-qty { max-width: 80px; text-align: right; }
.pi-jobs td { vertical-align: middle; }
.pi-jobs td:first-child input { width: 18px; height: 18px; accent-color: var(--teal); }
.pi-items { display: grid; gap: 8px; }
.pi-item { display: grid; grid-template-columns: 1fr 80px 130px; gap: 8px; }
.pi-form .form-actions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.patient-invoice .pi-brand .logo { height: 34px; width: auto; margin-bottom: 6px; }
.invoice-draft { margin: -20px 0 24px; padding: 10px 14px; border-radius: 8px; background: var(--warning-tint); color: #78350F; font-size: .92rem; }
.pi-bottom { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 20px; margin-bottom: 20px; }
.pi-bottom .invoice-totals { margin: 0 0 0 auto; min-width: 260px; }
.pi-pay { display: flex; align-items: center; gap: 14px; max-width: 420px; }
.pi-pay img { flex: none; border: 1px solid var(--line); border-radius: 10px; padding: 6px; background: #fff; }
.pi-pay p { margin: 0; font-size: .86rem; color: var(--muted); }
.pi-pay .invoice-label { color: var(--teal-dark) !important; }
@media (max-width: 640px) { .pi-item { grid-template-columns: 1fr 70px 100px; } .pi-pay { flex-direction: column; align-items: flex-start; } }
.pi-jobs th:nth-child(3), .pi-jobs td:nth-child(3) { width: auto; }
.pi-jobs td:nth-child(2) { white-space: nowrap; }
.pi-jobs th:first-child, .pi-jobs td:first-child { width: 36px; }

/* ---------- Professional earnings ---------- */
.earnings-filter { margin-bottom: 10px; }
.date-field { display: inline-flex; align-items: center; gap: 8px; font-size: .88rem; font-weight: 600; color: var(--muted); }
.date-field input { padding: 8px 10px; border: 1.5px solid var(--line); border-radius: var(--radius-sm); font: inherit; font-weight: 400; font-size: .92rem; color: var(--ink); background: #fff; }
.date-field input:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px var(--teal-tint); }
.earnings-filter .checkbox { align-items: center; color: var(--muted); }
a.chip-btn { text-decoration: none; display: inline-block; }
.chip-btn.is-active { border-color: var(--teal); background: var(--teal); color: #fff; }
.earnings-person { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.earnings-person h2 { margin: 0 0 2px; font-size: 1.25rem; }
.earnings-person p { margin: 0; }
.table tfoot th, .table tfoot td { padding: 14px 16px; border-top: 2px solid var(--ink); font-size: .98rem; text-align: left; }
.table tfoot .num { text-align: right; }
@media (max-width: 640px) {
    .earnings-filter > .search-field, .earnings-filter > .date-field, .earnings-filter > .checkbox { flex: 1 1 100%; max-width: none; }
    .earnings-filter .date-field span { width: 40px; }
    .earnings-filter .date-field input { flex: 1; min-width: 0; }
}

/* ---------- Patient invoices (professional layout) ---------- */
.pi-paper { position: relative; padding: 0 0 36px; overflow: hidden; }
.pi-paper::before { content: ""; display: block; height: 6px; background: var(--teal); margin-bottom: 40px; }
.pi-paper > *:not(.pi-stamp) { margin-left: 52px; margin-right: 52px; }
.pi-paper .invoice-void, .pi-paper .invoice-draft { margin-top: -16px; }
.pi-head { display: flex; justify-content: space-between; gap: 32px; margin-bottom: 30px; }
.pi-from p { margin: 6px 0 0; color: var(--muted); font-size: .88rem; line-height: 1.5; }
.pi-from .logo { height: 36px; width: auto; margin-bottom: 8px; }
.pi-from-name { color: var(--ink) !important; font-weight: 700; font-size: .98rem !important; }
.pi-reg { font-size: .82rem !important; }
.pi-title { text-align: right; }
.pi-title h2 { margin: 0 0 12px; font-size: 2.1rem; letter-spacing: .06em; text-transform: uppercase; color: var(--teal); }
.pi-meta { display: grid; grid-template-columns: auto auto; gap: 5px 18px; margin: 0; font-size: .88rem; }
.pi-meta dt { color: var(--muted); text-align: left; }
.pi-meta dd { margin: 0; font-weight: 600; text-align: right; white-space: nowrap; }
.pi-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 26px; }
.pi-parties > div { padding: 14px 16px; background: var(--bg-soft); border-left: 3px solid var(--teal); border-radius: 0 8px 8px 0; }
.pi-parties p { margin: 0; font-size: .9rem; color: var(--muted); line-height: 1.5; }
.pi-bill-name { color: var(--ink) !important; font-weight: 700; font-size: 1rem !important; }
.pi-lines { margin-bottom: 22px; }
.pi-lines thead th { background: var(--teal-deep); color: #fff; font-size: .72rem; letter-spacing: .05em; vertical-align: bottom; }
.pi-lines thead th span { font-weight: 400; text-transform: none; letter-spacing: 0; color: #C6DCE1; }
.pi-lines tbody tr:nth-child(even) td { background: #FAFCFC; }
.pi-lines td { vertical-align: top; }
.pi-n { width: 32px; color: var(--muted); }
.pi-pay { align-items: flex-start; padding: 14px; border: 1px solid var(--line); border-radius: 10px; max-width: 470px; }
.pi-pay img { padding: 4px; }
.pi-scan { margin: 0 0 8px !important; }
.pi-bank { display: grid; grid-template-columns: auto 1fr; gap: 3px 14px; margin: 0; font-size: .86rem; }
.pi-bank dt { color: var(--muted); }
.pi-bank dd { margin: 0; font-weight: 600; color: var(--ink); }
.pi-bank dd.mono { white-space: nowrap; }
.pi-totals { min-width: 280px; column-gap: 0; }
.pi-totals dt { padding-right: 28px; }
.pi-totals .invoice-grand { border-top: 0; margin-top: 6px; padding: 10px 12px; background: var(--teal); color: #fff !important; }
.pi-totals dt.invoice-grand { border-radius: 6px 0 0 6px; }
.pi-totals dd.invoice-grand { border-radius: 0 6px 6px 0; }
.pi-paper .invoice-note { margin-top: 0; margin-bottom: 8px; }
.pi-thanks { margin-top: 18px; font-size: .86rem; color: var(--muted); }
.pi-stamp { position: absolute; top: 300px; right: 64px; margin: 0; padding: 6px 16px; border: 3px solid var(--success); border-radius: 8px; color: var(--success); font-weight: 800; font-size: 1.1rem; text-transform: uppercase; letter-spacing: .08em; transform: rotate(-8deg); opacity: .85; pointer-events: none; }
.pi-pad { padding: 20px 22px 4px; }
.pi-money-affix { display: inline-flex; max-width: 150px; margin-left: auto; }
.pi-money-affix input { width: 100%; min-width: 0; padding: 7px 10px; border: 0; font: inherit; text-align: right; font-variant-numeric: tabular-nums; }
.pi-money-affix input:focus { outline: none; }
.pi-money-affix span { padding: 0 9px; }
.pi-item-head { font-size: .78rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.pi-item-head span:not(:first-child) { text-align: right; }
.pi-item .pi-qty, .pi-item .pi-money { max-width: none; }
.pi-form-foot { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 18px; margin-top: 8px; }
.pi-live { margin: 0; min-width: 260px; column-gap: 0; }
.pi-live dt { padding-right: 28px; }
@media (max-width: 760px) {
    .pi-paper > *:not(.pi-stamp) { margin-left: 20px; margin-right: 20px; }
    .pi-head { flex-direction: column; }
    .pi-title { text-align: left; }
    .pi-parties { grid-template-columns: 1fr; }
    .pi-stamp { top: 24px; right: 16px; }
}
@media print {
    .pi-paper { padding-bottom: 0; }
    .pi-paper > *:not(.pi-stamp) { margin-left: 0; margin-right: 0; }
    .pi-paper::before, .pi-lines thead th, .pi-totals .invoice-grand, .pi-parties > div { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .page-loader { display: none !important; }
}

/* Patient invoices: VAT per line, QR preview */
.pi-item { grid-template-columns: 1fr 80px 130px 170px; }
.pi-item-head span:last-child { text-align: left; }
.pi-vat { min-width: 150px; padding-right: 6px; background: #fff; }
.pi-live dt.pi-live-rate, .pi-live dd.pi-live-rate { font-size: .84rem; }
.pi-live dt.pi-live-rate { padding-left: 10px; }
.pi-totals dt:not(.invoice-grand) { font-size: .9rem; }
.pi-qr { position: relative; margin: 0; flex: none; }
.pi-qr.is-preview img { opacity: .55; }
.pi-qr figcaption { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%) rotate(-12deg); padding: 3px 10px; border: 2px solid var(--danger-strong); border-radius: 6px; background: #fff; color: var(--danger-strong); font-weight: 800; font-size: .8rem; letter-spacing: .08em; text-transform: uppercase; }
.pi-qr-missing { display: flex; gap: 8px; align-items: flex-start; flex: none; width: 160px; padding: 12px; border: 1.5px dashed var(--line); border-radius: 10px; font-size: .8rem; color: var(--muted); }
@media (max-width: 640px) { .pi-item { grid-template-columns: 1fr 64px 96px; } .pi-item .pi-vat { grid-column: 1 / -1; } .pi-item-head span:last-child { display: none; } }

/* Patient invoices: new patient, deleted */
.pi-new-patient { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.pi-new-patient p { margin: 0; color: var(--muted); font-size: .9rem; }
.pi-deleted-link { display: inline-flex; align-items: center; gap: 6px; margin-left: auto; font-size: .88rem; font-weight: 600; color: var(--muted); text-decoration: none; }
.pi-deleted-link:hover { color: var(--danger-strong); }

/* ---------- Clock records: one visit in full (Job approval) ---------- */
.cr-intro { margin: 0 0 12px; font-size: .9rem; }
.cr-list { display: grid; gap: 14px; margin-bottom: 24px; }
.cr-list-nested { gap: 10px; margin: 12px 0 4px; }
.cr { padding: 16px 18px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
.cr-flagged { border-left: 4px solid #D97706; }
.cr-list-nested .cr { background: var(--bg-soft); }
.cr-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 10px; }
.cr-when { font-size: .92rem; }
.cr-when .muted { font-size: .86rem; }
.cr-badges { display: flex; flex-wrap: wrap; gap: 6px; }
.cr-badges .badge { display: inline-flex; align-items: center; gap: 4px; }
.cr-badges .badge .icon { width: 12px; height: 12px; }
.cr-person { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; font-size: .92rem; }

.cr-sides { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 10px; }
.cr-side { padding: 12px 14px; border-radius: 12px; background: var(--bg-soft); border: 1px solid var(--line); }
.cr-list-nested .cr-side { background: #fff; }
.cr-side.is-edited { border-color: #FBD38D; background: #FFFBEB; }
.cr-side-label { margin: 0; font-size: .7rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }
.cr-time { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 2px 0 4px; font-family: var(--font-heading); font-size: 1.6rem; font-weight: 700; line-height: 1.15; font-variant-numeric: tabular-nums; color: var(--ink); }
.cr-side-empty .cr-time { font-size: 1.05rem; font-family: var(--font-main); color: var(--muted); }
.cr-tag { padding: 2px 8px; border-radius: 99px; background: #FEF3C7; color: #92400E; font: 700 .7rem var(--font-main); letter-spacing: .02em; }
.cr-sub { margin: 0 0 8px; font-size: .82rem; color: var(--muted); }
.cr-sub strong { color: var(--ink); font-variant-numeric: tabular-nums; }
.cr-vs { font-weight: 700; }
.cr-vs.is-ok { color: var(--success); }
.cr-vs.is-warn { color: #B45309; }
.cr-vs.is-info { color: var(--teal); }
.cr-loc { display: flex; align-items: flex-start; gap: 6px; margin: 0; padding: 8px 10px; border-radius: 10px; font-size: .84rem; line-height: 1.45; background: #fff; }
.cr-loc .icon { flex: none; margin-top: 2px; }
.cr-loc.is-ok { background: var(--success-tint); color: #166534; }
.cr-loc.is-warn { background: var(--warning-tint); color: #92400E; }
.cr-loc.is-bad { background: var(--danger-tint); color: var(--danger-strong); }
.cr-loc a { color: inherit; font-weight: 600; }
.cr-loc .muted { color: inherit; opacity: .75; }

.cr-address { display: flex; align-items: flex-start; gap: 6px; margin: 0 0 10px; font-size: .86rem; color: var(--muted); }
.cr-address .icon { flex: none; margin-top: 2px; }
.cr-address strong { color: var(--ink); }
.cr-stats { display: flex; flex-wrap: wrap; gap: 6px 22px; margin: 0 0 10px; font-size: .88rem; }
.cr-stats div { display: flex; gap: 6px; }
.cr-stats dt { color: var(--muted); }
.cr-stats dd { margin: 0; font-weight: 600; }

.cr-review { margin: 0 0 10px; padding: 12px 14px; border-radius: 12px; background: #FFFBEB; border: 1px solid #FDE68A; }
.cr-review-title { display: flex; align-items: center; gap: 6px; margin: 0 0 6px; font-weight: 700; font-size: .86rem; color: #92400E; }
.cr-review ul { margin: 0; padding-left: 18px; font-size: .88rem; display: grid; gap: 4px; }
.cr-reasons-title { margin-top: 10px; color: var(--ink); }
.cr-reasons { list-style: none; padding-left: 0 !important; }
.cr-reasons li { padding: 6px 10px; border-left: 3px solid #D97706; background: #fff; border-radius: 0 8px 8px 0; font-style: italic; }
.cr-notes { font-size: .88rem; }
.cr-notes p { margin: 0 0 4px; }
.clock-details summary { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.clock-details summary .flag-line { margin: 0; }
@media (max-width: 640px) { .cr-sides { grid-template-columns: 1fr; } }
.clock-details summary .flag-line { display: inline-flex; white-space: nowrap; }

/* ---------- Live attendance: clock-in locations today ---------- */
.loc-summary { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin: 0 0 14px; font-size: .92rem; }
.loc-chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border-radius: 99px; font-weight: 600; font-size: .84rem; }
.loc-chip::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: currentColor; }
.loc-chip-ok { background: var(--success-tint); color: #166534; }
.loc-chip-far { background: #FFF1E6; color: #B4461F; }
.loc-chip-rough { background: var(--warning-tint); color: #92400E; }
.loc-chip-none { background: var(--neutral-tint); color: var(--muted); }

.loc-layout { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(300px, 1fr); gap: 16px; align-items: start; }
.loc-map-wrap { position: sticky; top: calc(var(--topbar-h) + 12px); }
.loc-map { height: 460px; border-radius: 14px; overflow: hidden; border: 1px solid var(--line); background: var(--bg-soft); }
.loc-map-error { padding: 20px; color: var(--muted); }
.loc-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 10px 0 0; font-size: .8rem; color: var(--muted); }
.loc-legend > span { display: inline-flex; align-items: center; gap: 6px; }

/* Map pins (also used in the list and the legend) */
.mk { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; border: 2.5px solid #fff; box-shadow: 0 2px 6px rgba(10, 47, 56, .35); color: #fff; font: 800 .8rem var(--font-main); line-height: 1; }
.mk-legend { width: 20px; height: 20px; font-size: .66rem; border-width: 2px; box-shadow: none; flex: none; }
.mk-legend .icon { width: 12px; height: 12px; }
.mk-home { width: 30px; height: 30px; border-radius: 9px; background: var(--teal); }
.mk-legend.mk-home { width: 20px; height: 20px; border-radius: 6px; }
.mk-in.mk-ok, .mk-in.mk-nohome { background: #15803D; }
.mk-in.mk-far { background: var(--coral); }
.mk-in.mk-rough { background: #D97706; }
.mk-in.mk-none { background: #8A94A0; }
.mk-out { width: 34px; height: 20px; border-radius: 6px; background: var(--teal-deep); font-size: .6rem; letter-spacing: .04em; }
.mk-legend.mk-out { width: 30px; height: 18px; font-size: .56rem; }
.loc-pop { font: .86rem/1.45 var(--font-main); color: var(--ink); min-width: 200px; }
.loc-pop p { margin: 6px 0 0; }
.loc-pop a { display: inline-block; margin-top: 6px; font-weight: 600; }

/* Visit list */
.loc-visits { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; max-height: 520px; overflow-y: auto; }
.loc-visit { display: flex; gap: 12px; align-items: flex-start; width: 100%; padding: 12px; border: 1.5px solid var(--line); border-radius: 14px; background: #fff; text-align: left; font: inherit; color: inherit; cursor: pointer; transition: border-color .15s, box-shadow .15s; }
.loc-visit:hover { border-color: var(--teal); }
.loc-visit.is-active { border-color: var(--teal); box-shadow: 0 0 0 3px var(--teal-tint); }
.loc-visit .mk { flex: none; box-shadow: none; border: 0; }
.loc-visit-body { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.loc-visit-who { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; font-weight: 700; }
.loc-visit-where { font-size: .82rem; color: var(--muted); }
.loc-visit-line { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 2px; font-size: .84rem; }
.loc-visit-label { min-width: 62px; font-weight: 600; font-variant-numeric: tabular-nums; }
.loc-pill { padding: 2px 9px; border-radius: 99px; font-size: .78rem; font-weight: 600; }
.loc-pill-ok, .loc-pill-nohome { background: var(--success-tint); color: #166534; }
.loc-pill-far { background: #FFF1E6; color: #B4461F; }
.loc-pill-rough { background: var(--warning-tint); color: #92400E; }
.loc-pill-none { background: var(--neutral-tint); color: var(--muted); }
.loc-working { display: inline-flex; align-items: center; gap: 4px; font-size: .74rem; font-weight: 600; color: var(--success); }
.loc-working .live-dot { font-size: 0; gap: 0; }
.loc-flag { display: inline-flex; align-items: center; gap: 3px; font-size: .74rem; font-weight: 700; color: #B45309; }
.loc-flag .icon { width: 12px; height: 12px; }
.loc-empty { display: flex; gap: 12px; align-items: flex-start; padding: 18px; border-radius: 14px; background: var(--bg-soft); color: var(--muted); }
.loc-empty p { margin: 0; }
@media (max-width: 900px) {
    .loc-layout { grid-template-columns: 1fr; }
    .loc-map-wrap { position: static; }
    .loc-map { height: 340px; }
    .loc-visits { max-height: none; }
}

/* ---------- Reports: the standard management report ---------- */
.rp-filter { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; margin-bottom: 16px; }
.rp-periods { margin: 0; flex-wrap: wrap; }
.rp-custom { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.rp { background: #fff; border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 28px 30px 10px; }
.rp-head { display: flex; flex-wrap: wrap; align-items: center; gap: 18px 28px; padding-bottom: 20px; margin-bottom: 8px; border-bottom: 3px solid var(--teal); }
.rp-head-brand .logo { height: 40px; width: auto; }
.rp-head-text { flex: 1; min-width: 240px; }
.rp-kicker { margin: 0; font-size: .74rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--coral-dark); }
.rp-head h2 { margin: 2px 0 4px; font-size: 1.6rem; }
.rp-head .muted { margin: 0; font-size: .86rem; }
.rp-section { padding: 22px 0 8px; border-bottom: 1px solid var(--line); }
.rp-section:last-child { border-bottom: 0; }
.rp-section h3 { display: flex; align-items: center; gap: 10px; margin: 0 0 14px; font-size: 1.2rem; }
.rp-section h3 > span { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; background: var(--teal); color: #fff; font-size: .85rem; }
.rp-section h4 { margin: 18px 0 8px; font-size: .95rem; }
.rp-section .chart-panel { margin: 18px 0 8px; border: 1px solid var(--line); box-shadow: none; }

.rp-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.rp-kpi { display: flex; flex-direction: column; gap: 2px; padding: 14px 16px; border-radius: 14px; background: var(--bg-soft); border: 1px solid var(--line); }
.rp-kpi-label { font-size: .76rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.rp-kpi-value { font-family: var(--font-heading); font-size: 1.55rem; font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; color: var(--ink); }
.rp-kpi-note { font-size: .8rem; color: var(--muted); }
.rp-chg { font-weight: 700; color: var(--muted); white-space: nowrap; }
.rp-chg.is-good { color: var(--success); }
.rp-chg.is-bad { color: var(--danger-strong); }

.rp-points { margin-top: 14px; padding: 14px 16px; border-radius: 14px; border: 1px solid var(--line); }
.rp-points-title { margin: 0 0 8px; font-weight: 700; }
.rp-points ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.rp-point { position: relative; padding-left: 20px; font-size: .92rem; }
.rp-point::before { content: ""; position: absolute; left: 2px; top: .45em; width: 9px; height: 9px; border-radius: 50%; background: var(--muted); }
.rp-point-good::before { background: var(--success); }
.rp-point-warn::before { background: #D97706; }
.rp-point-bad::before { background: var(--danger-strong); }
.rp-point-info::before { background: var(--teal); }

.rp-table th[scope="row"] { font-weight: 500; }
.rp-table td.num strong { font-variant-numeric: tabular-nums; }
.rp-note { margin: 10px 0 0; font-size: .88rem; color: var(--muted); }
.rp-two { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.rp-defs ul { margin: 0; padding-left: 18px; display: grid; gap: 6px; font-size: .86rem; color: var(--muted); }
.rp-defs strong { color: var(--ink); }
@media (max-width: 1000px) { .rp-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } .rp-two { grid-template-columns: 1fr; } }
@media (max-width: 640px) { .rp { padding: 18px 14px 6px; } .rp-kpi-value { font-size: 1.25rem; } }
@media print {
    @page { size: A4; margin: 14mm 12mm; }
    .rp { border: 0; padding: 0; border-radius: 0; }
    .rp-section { break-inside: auto; }
    .rp-kpis, .rp-points, .rp-table tr, .chart-panel { break-inside: avoid; }
    .rp-section h3 { break-after: avoid; }
    .rp .chart-table { display: none; }
    .rp-head, .rp-section h3 > span, .rp-kpi, .rp-chg, .rp-point::before, .chart rect, .chart-key { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .rp-kpis { grid-template-columns: repeat(4, 1fr); }
    .rp-two { grid-template-columns: 1fr 1fr; }
}

/* Dashboard: this month at a glance (links to the detail) */
.dash-glance .rp-kpis { margin-top: 4px; }
a.rp-kpi-link { text-decoration: none; color: inherit; transition: border-color .15s, box-shadow .15s; }
a.rp-kpi-link:hover { border-color: var(--teal); box-shadow: 0 0 0 3px var(--teal-tint); }

/* Reports: period buttons (links styled as a segmented control) */
.rp-periods { display: inline-flex; padding: 4px; background: var(--neutral-tint); border-radius: 10px; }
.rp-periods a { display: block; white-space: nowrap; padding: 7px 14px; border-radius: 7px; font-weight: 600; font-size: .88rem; color: var(--muted); text-decoration: none; }
.rp-periods a:hover { color: var(--ink); }
.rp-periods a.is-on { background: #fff; color: var(--ink); box-shadow: var(--shadow-sm); }
@media print {
    .rp .table-wrap { overflow: visible; }
    .rp-table { font-size: 9pt; }
    .rp-table th, .rp-table td { padding: 6px 8px; }
    .rp-table thead th { white-space: normal; }
}
