/* ─────────────────────────────────────────────────────────────────────────
   CareScheduler360 — Global stylesheet
   Design tokens taken from Figma "IDEAL CARE — ADMIN UI"
   ─────────────────────────────────────────────────────────────────────── */
:root {
    --c-primary:        #16A34A;
    --c-primary-dark:   #15803D;
    --c-primary-light:  #DCFCE7;
    --c-primary-border: #BBF7D0;
    --c-primary-text:   #166534;

    --c-brand-blue:     #1E40AF;
    --c-brand-blue-dk:  #1E3A8A;

    --c-text:           #111827;
    --c-text-soft:      #374151;
    --c-muted:          #6B7280;
    --c-muted-light:    #9CA3AF;
    --c-border:         #E5E7EB;
    --c-border-soft:    #F3F4F6;
    --c-bg:             #F9FAFB;
    --c-card:           #FFFFFF;

    --c-danger:         #DC2626;
    --c-danger-bg:      #FEE2E2;
    --c-warning:        #F59E0B;
    --c-warning-bg:     #FEF3C7;
    --c-info:           #3B82F6;
    --c-info-bg:        #DBEAFE;

    --radius-sm: 6px;
    --radius:    8px;
    --radius-lg: 12px;
    --radius-xl: 16px;

    --shadow-sm: 0 1px 2px rgba(0,0,0,.04);
    --shadow:    0 4px 12px rgba(15,23,42,.06);
    --shadow-lg: 0 12px 28px rgba(15,23,42,.10);

    --sidebar-w:   240px;
    --topbar-h:    64px;
    --container:   1440px;

    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

/* Form controls do not inherit the page font — browsers give them their own
   UI font. It shows up worst on input[type="date"], which Chrome renders in a
   near-monospace face, so a date field looks nothing like the Inter text
   beside it. Most components already opt in with `font-family: inherit`
   one by one; making it the default means a new control cannot forget.
   Kept at the lowest possible specificity so anything deliberately different
   (e.g. the monospace hex field in .color-input) still wins, and `button` is
   left out because .btn already sets `font: inherit`. */
input, select, textarea, optgroup { font-family: inherit; }

html, body {
    margin: 0;
    padding: 0;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.5;
    color: var(--c-text);
    background: var(--c-bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6 {
    margin: 0;
    font-weight: 700;
    color: var(--c-text);
    line-height: 1.25;
}

a { color: var(--c-primary); text-decoration: none; }
a:hover { color: var(--c-primary-dark); }

/* ──────────────────────────────────────────────────────────────────
   LOGIN PAGE (Figma node 5:62)
   ────────────────────────────────────────────────────────────────── */
.auth-page {
    min-height: 100vh;
    width: 100%;
    background:
        linear-gradient(135deg, rgba(30,58,138,.78) 0%, rgba(30,64,175,.72) 100%),
        url('../images/auth/login-bg.png') center / cover no-repeat;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    overflow: hidden;
}

/* Decorative icons over background (matching Figma) */
.auth-page::before,
.auth-page::after {
    content: '';
    position: absolute;
    top: 0; right: 0;
    width: 50%; height: 100%;
    pointer-events: none;
    background-repeat: no-repeat;
    opacity: .12;
}
.auth-page::before {
    background-image:
        /* dots pattern top right */
        radial-gradient(circle at 10px 10px, #ffffff 1.5px, transparent 1.6px);
    background-size: 20px 20px;
    background-position: 90% 6%;
    background-repeat: repeat;
    width: 220px; height: 140px;
    top: 50px; right: 80px;
}
.auth-deco {
    position: absolute;
    pointer-events: none;
    color: rgba(255,255,255,.18);
}
.auth-deco-calendar { top: 80px;  right: 290px; }
.auth-deco-clock    { top: 200px; right: 130px; }
.auth-deco-clip     { top: 310px; right: 240px; }
.auth-deco-people   { top: 430px; right: 110px; }
.auth-deco-wave     { position: absolute; left: 0; bottom: 0; width: 100%; }

.auth-card {
    position: relative;
    z-index: 2;
    width: 100%;
    max-width: 384px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 20px 50px rgba(0,0,0,.25);
    padding: 33px;
}

.auth-logo {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    margin-bottom: 26px;
}
.auth-logo .logo-circle {
    width: 64px; height: 64px;
    border-radius: 50%;
    background: #DBEAFE;
    display: flex; align-items: center; justify-content: center;
    color: var(--c-brand-blue);
}
.auth-logo h1 {
    font-size: 20px;
    font-weight: 700;
    color: var(--c-text);
}
.auth-subtitle {
    font-size: 14px;
    color: var(--c-muted);
    text-align: center;
    margin: 0;
}

.auth-form .form-group { margin-bottom: 16px; }
.auth-form label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--c-text);
    margin-bottom: 6px;
}

.input-wrap { position: relative; }
.form-control {
    width: 100%;
    height: 42px;
    padding: 0 13px;
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    font: inherit;
    font-size: 14px;
    color: var(--c-text);
    background: #fff;
    transition: border-color .15s, box-shadow .15s;
    outline: none;
}
.form-control::placeholder { color: var(--c-muted-light); }
.form-control:focus {
    border-color: var(--c-primary);
    box-shadow: 0 0 0 3px rgba(var(--c-primary-rgb), .12);
}
.form-control.has-trailing { padding-right: 38px; }

.toggle-pwd {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: 0;
    color: var(--c-muted);
    cursor: pointer;
    padding: 2px;
    display: flex;
    align-items: center;
}
.toggle-pwd:hover { color: var(--c-text); }

.form-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 4px 0 20px;
    font-size: 14px;
}
.form-row .remember {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--c-text-soft);
    cursor: pointer;
}
.form-row .remember input {
    width: 16px; height: 16px;
    accent-color: var(--c-primary);
    margin: 0;
}
.form-row .link {
    color: var(--c-primary);
    font-weight: 500;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 0;
    border-radius: var(--radius);
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    padding: 0 18px;
    height: 40px;
    cursor: pointer;
    transition: background .15s, transform .05s;
    text-decoration: none;
    white-space: nowrap;
}
.btn-primary {
    background: var(--c-primary);
    color: #fff;
    width: 100%;
    transition: background .2s ease;
}
.btn-primary:hover  {
    background: var(--c-hover);
    color: var(--c-hover-text);
}
.btn-primary:active {
    background: var(--c-selected);
    color: var(--c-selected-text);
    transform: translateY(1px);
}
.btn-secondary {
    background: #fff;
    color: var(--c-text);
    border: 1px solid var(--c-border);
}
.btn-secondary:hover { background: var(--c-border-soft); }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; }

.alert {
    padding: 10px 14px;
    border-radius: var(--radius);
    font-size: 13px;
    margin-bottom: 14px;
}
.alert-danger { background: var(--c-danger-bg); color: var(--c-danger); }
.alert-success { background: var(--c-primary-light); color: var(--c-primary-text); }
.alert-info { background: var(--c-info-bg); color: var(--c-info); }

/* ──────────────────────────────────────────────────────────────────
   APP SHELL — Sidebar + Topbar (Figma node 6:114)
   ────────────────────────────────────────────────────────────────── */
.app {
    min-height: 100vh;
    display: flex;
    background: var(--c-bg);
}

.sidebar {
    width: var(--sidebar-w);
    background: #fff;
    border-right: 1px solid var(--c-border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 30;
    transition: transform .2s;
}
.sidebar-brand {
    height: var(--topbar-h);
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 20px;
    border-bottom: 1px solid var(--c-border);
}
.sidebar-brand .brand-mark {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: #DBEAFE;
    display: flex; align-items: center; justify-content: center;
    color: var(--c-brand-blue);
    flex-shrink: 0;
}
.sidebar-brand .brand-text {
    font-size: 15px;
    font-weight: 700;
    color: var(--c-brand-blue);
    line-height: 1.2;
}
.sidebar-brand .sidebar-logo {
    max-width: 150px;
    max-height: 44px;
    width: auto;
    height: auto;
    object-fit: contain;
    object-position: left center;
}
.sidebar-brand .sidebar-logo-text {
    font-size: 14px;
    font-weight: 700;
    color: var(--c-brand-blue);
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    word-break: break-word;
}

@media (max-width: 768px) {
    .sidebar-brand .sidebar-logo {
        max-width: 120px;
        max-height: 40px;
    }
    .sidebar-brand .sidebar-logo-text {
        font-size: 13px;
    }
}

@media (max-width: 480px) {
    .sidebar-brand .sidebar-logo {
        max-width: 100px;
        max-height: 36px;
    }
    .sidebar-brand .sidebar-logo-text {
        font-size: 12px;
    }
}

.sidebar-nav {
    padding: 18px 12px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow-y: auto;
    flex: 1;
}
.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius);
    color: var(--c-text-soft);
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    transition: background .12s, color .12s;
}
.nav-item:hover {
    background: #f3f4f6;
    color: var(--c-text);
}
.nav-item:hover svg { color: var(--c-text); }
.nav-item.active {
    background: rgba(var(--c-primary-rgb), .12);
    color: var(--c-primary);
    font-weight: 600;
}
.nav-item.active svg { color: var(--c-primary); }
.nav-item svg {
    width: 18px; height: 18px;
    color: var(--c-muted);
    flex-shrink: 0;
}

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

.topbar {
    height: var(--topbar-h);
    background: #fff;
    border-bottom: 1px solid var(--c-border);
    padding: 0 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 20;
}
.topbar h1 {
    font-size: 18px;
    font-weight: 700;
    color: var(--c-text);
}
.topbar-actions {
    display: flex;
    align-items: center;
    gap: 18px;
}
.icon-btn {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: transparent;
    border: 0;
    color: var(--c-muted);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    position: relative;
    transition: background .12s;
}
.icon-btn:hover { background: var(--c-border-soft); color: var(--c-text); }
.icon-btn .dot {
    position: absolute;
    top: 8px; right: 8px;
    width: 8px; height: 8px;
    background: var(--c-danger);
    border: 2px solid #fff;
    border-radius: 50%;
}

.user-menu {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 12px 4px 4px;
    border-radius: 50px;
    cursor: pointer;
    background: transparent;
    border: 0;
    color: var(--c-text);
    font: inherit;
}
.user-menu:hover { background: var(--c-border-soft); }
.user-menu .avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: rgba(var(--c-primary-rgb), 0.12);
    color: var(--c-primary);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700;
    font-size: 13px;
    overflow: hidden;
    flex-shrink: 0;
}
.user-menu .avatar img { width: 100%; height: 100%; object-fit: cover; }
.user-menu .user-meta { display: flex; flex-direction: column; line-height: 1.2; text-align: left; }
.user-menu .user-name { font-size: 14px; font-weight: 600; }
.user-menu .user-franchise { font-size: 11px; font-weight: 500; color: var(--c-muted); }
.user-menu .caret { color: var(--c-muted); }

.dropdown-location {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 6px 12px 8px;
    font-size: 12px;
    font-weight: 600;
    color: var(--c-muted);
    text-transform: uppercase;
    letter-spacing: .3px;
}
.dropdown-location svg { flex-shrink: 0; color: var(--c-primary); }

.dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 8px;
    background: #fff;
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    min-width: 180px;
    padding: 6px;
    display: none;
    z-index: 100;
}
.dropdown.open { display: block; }
.dropdown a, .dropdown button {
    display: block;
    width: 100%;
    text-align: left;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    color: var(--c-text);
    font-size: 14px;
    text-decoration: none;
    background: none;
    border: 0;
    cursor: pointer;
    font: inherit;
}
.dropdown a:hover, .dropdown button:hover { background: var(--c-border-soft); }
.dropdown hr { border: 0; border-top: 1px solid var(--c-border); margin: 4px 0; }

.content {
    padding: 28px 32px 40px;
    max-width: 100%;
}

.page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}
.page-head h2 {
    font-size: 22px;
    font-weight: 700;
}

/* ──────────────────────────────────────────────────────────────────
   DASHBOARD CARDS  (KPI / panels)
   ────────────────────────────────────────────────────────────────── */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 18px;
    margin-bottom: 24px;
}

/* Chart.js needs a constrained, position:relative parent — without a
   fixed height the canvas + parent feed each other and grow forever. */
.chart-box {
    position: relative;
    width: 100%;
    height: 220px;
}
.chart-box > canvas { max-width: 100%; }
.kpi-card {
    display: block;
    background: #fff;
    border: 1px solid var(--c-border);
    border-radius: var(--radius-lg);
    padding: 20px 22px;
    text-decoration: none;
    color: inherit;
    transition: transform .15s, box-shadow .15s;
}
/* Only cards that link somewhere show the hover affordance — a static card
   (Hours Today) hovering like a button would be misleading. */
a.kpi-card:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}
.kpi-label {
    font-size: 13px;
    color: var(--c-muted);
    margin-bottom: 10px;
    font-weight: 500;
}
.kpi-value-row {
    display: flex;
    align-items: baseline;
    gap: 10px;
}
.kpi-value {
    font-size: 30px;
    font-weight: 800;
    color: var(--c-text);
    letter-spacing: -.5px;
    line-height: 1;
}
.kpi-delta {
    font-size: 13px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 2px;
}
.kpi-delta.up   { color: var(--c-primary); }
.kpi-delta.down { color: var(--c-danger); }

/* ──────────────────────────────────────────────────────────────────
   COUNTER TILES  ("Timesheets style", used app-wide)
   Icon badge on the right, colored per status (not grey), label above
   value on the left. Every page supplies its own accent/icon colors via
   the --ctr-accent / --ctr-icon-bg / --ctr-icon-fg custom properties
   (inline style="--ctr-accent:#16A34A;..."), since the palette differs
   per tile/status — this block is layout only. Column count is a
   modifier class (not inline grid-template-columns) so the responsive
   breakpoints below can actually override it.
   ────────────────────────────────────────────────────────────────── */
.ctr-tiles {
    display: grid;
    gap: 16px;
    margin-bottom: 22px;
}
.ctr-tiles-3 { grid-template-columns: repeat(3, 1fr); }
.ctr-tiles-4 { grid-template-columns: repeat(4, 1fr); }
.ctr-tiles-5 { grid-template-columns: repeat(5, 1fr); }
.ctr-tiles-6 { grid-template-columns: repeat(6, 1fr); }
.ctr-tile {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: #fff;
    border: 1px solid var(--c-border);
    border-left-width: 4px;
    border-left-color: var(--ctr-accent, var(--c-border));
    border-radius: 12px;
    padding: 16px 18px;
    text-decoration: none;
    color: inherit;
    transition: box-shadow .12s, transform .12s;
}
a.ctr-tile { cursor: pointer; }
a.ctr-tile:hover { box-shadow: 0 4px 12px rgba(0,0,0,.06); transform: translateY(-1px); }
a.ctr-tile.active, a.ctr-tile.is-active { box-shadow: 0 0 0 2px var(--c-primary); }
.ctr-tile-label {
    font-size: 13px;
    color: var(--c-muted);
    margin-bottom: 6px;
}
.ctr-tile-value {
    font-size: 26px;
    font-weight: 700;
    line-height: 1;
    color: var(--c-text);
}
.ctr-tile-delta { font-size: 12px; font-weight: 600; margin-left: 6px; }
.ctr-tile-delta.up   { color: var(--c-primary); }
.ctr-tile-delta.down { color: var(--c-danger); }
.ctr-tile-icon {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: var(--ctr-icon-bg, #F3F4F6);
    color: var(--ctr-icon-fg, #6B7280);
}
.ctr-tile-icon svg { width: 21px; height: 21px; }
@media (max-width: 900px) {
    .ctr-tiles-3, .ctr-tiles-4, .ctr-tiles-5, .ctr-tiles-6 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 560px) {
    .ctr-tiles-3, .ctr-tiles-4, .ctr-tiles-5, .ctr-tiles-6 { grid-template-columns: 1fr; }
}

.grid-2-1 {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 18px;
    margin-bottom: 24px;
}

.card {
    background: #fff;
    border: 1px solid var(--c-border);
    border-radius: var(--radius-lg);
    padding: 22px;
}
.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}
.card-head h3 {
    font-size: 15px;
    font-weight: 700;
}
.card-head .link {
    font-size: 13px;
    font-weight: 600;
}

/* Standalone text link — used in dashboard and other tenant pages */
.link {
    color: var(--c-primary);
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    transition: opacity .12s;
}
.link:hover { opacity: .75; }

/* Tenant tile (Who's Working / Recent Tenants etc.) */
.tile-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: 24px;
}
.tile {
    background: #fff;
    border: 1px solid var(--c-border);
    border-radius: var(--radius-lg);
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: box-shadow .15s, transform .15s;
}
.tile:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.tile-head { display: flex; align-items: center; gap: 10px; }
.tile-head .avatar {
    width: 38px; height: 38px;
    border-radius: 50%;
    background: rgba(var(--c-primary-rgb), 0.12);
    color: var(--c-primary);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700;
    font-size: 13px;
    flex-shrink: 0;
}
.tile-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--c-text);
    line-height: 1.25;
}
.tile-sub {
    font-size: 12px;
    color: var(--c-muted);
}
.tile-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 12px;
    color: var(--c-muted);
}

/* Tables */
.table-wrap { overflow-x: auto; }
table.data {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
table.data th {
    text-align: left;
    padding: 12px 14px;
    color: var(--c-muted);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .03em;
    border-bottom: 1px solid var(--c-border);
    background: #fff;
}
table.data td {
    padding: 14px;
    border-bottom: 1px solid var(--c-border-soft);
    color: var(--c-text);
    vertical-align: middle;
}
table.data tr:last-child td { border-bottom: 0; }
table.data tr:hover td { background: var(--c-border-soft); }

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 50px;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.4;
}
.badge-success { background: rgba(var(--c-primary-rgb), 0.1); color: var(--c-primary); }
.badge-warning { background: var(--c-warning-bg);    color: #92400E; }
.badge-danger  { background: var(--c-danger-bg);     color: #991B1B; }
.badge-info    { background: var(--c-info-bg);       color: #1E40AF; }
.badge-muted   { background: var(--c-border-soft);   color: var(--c-muted); }

.badge.plan-trial      { background: var(--c-info-bg);       color: #1E40AF; }
.badge.plan-basic      { background: rgba(var(--c-primary-rgb), 0.1); color: var(--c-primary); }
.badge.plan-pro        { background: #FCE7F3;                color: #9D174D; }
.badge.plan-enterprise { background: var(--c-warning-bg);    color: #92400E; }

/* Status dot */
.dot-status {
    width: 8px; height: 8px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 6px;
    vertical-align: middle;
}
.dot-status.green  { background: var(--c-primary); }
.dot-status.amber  { background: var(--c-warning); }
.dot-status.red    { background: var(--c-danger); }
.dot-status.blue   { background: var(--c-info); }

/* Activity / alert items */
.activity { display: flex; flex-direction: column; gap: 14px; }
.activity-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}
.activity-item .pill {
    width: 28px; height: 28px;
    border-radius: 50%;
    background: rgba(var(--c-primary-rgb), 0.1);
    color: var(--c-primary);
    display: flex; align-items: center; justify-content: center;
    font-size: 12px;
    flex-shrink: 0;
}
.activity-item .body { font-size: 13px; color: var(--c-text); line-height: 1.4; }
.activity-item .body strong { font-weight: 600; }
.activity-item .body small { display: block; color: var(--c-muted); margin-top: 2px; font-size: 11px; }

.alerts { display: flex; flex-direction: column; gap: 10px; }
.alert-tile {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    border-radius: var(--radius);
    font-size: 13px;
}
.alert-tile.danger  { background: var(--c-danger-bg);  color: #991B1B; }
.alert-tile.warning { background: var(--c-warning-bg); color: #92400E; }
.alert-tile.info    { background: var(--c-info-bg);    color: #1E40AF; }
.alert-tile .meta {
    margin-top: 2px;
    font-size: 11px;
    opacity: .75;
}

/* Mobile hamburger */
.menu-btn {
    display: none;
    background: transparent;
    border: 0;
    cursor: pointer;
    color: var(--c-text);
    margin-right: 12px;
}

/* ──────────────────────────────────────────────────────────────────
   THEME-AWARE INTERACTIVE STATES
   ────────────────────────────────────────────────────────────────── */
/* Table rows and interactive containers use theme colors */
table tbody tr {
    transition: background .2s ease;
}
table tbody tr:hover {
    background: rgba(var(--c-primary), .05);
}

/* Form controls use theme colors */
input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
textarea:focus,
select:focus {
    border-color: var(--c-primary);
    box-shadow: 0 0 0 3px rgba(var(--c-primary), .1);
}

/* Toggle switches (checkboxes/radio) */
input[type="checkbox"]:checked,
input[type="radio"]:checked {
    background: var(--c-primary);
    border-color: var(--c-primary);
}

/* Filter tab active state */
.filter-tabs a.active,
.filter-tabs button.active {
    color: var(--c-primary);
    border-bottom-color: var(--c-primary);
}

/* Modal and dialog elements */
.modal-overlay {
    background: rgba(0, 0, 0, .35);
}

/* Rate pin hover states (already theme-aware) */
.rate-pin:hover .rate-pin-dot {
    box-shadow: 0 0 0 4px rgba(var(--c-primary), .15);
}

.rate-pin.is-on .rate-pin-dot {
    background: var(--c-primary);
}

/* ──────────────────────────────────────────────────────────────────
   RESPONSIVE
   ────────────────────────────────────────────────────────────────── */
@media (max-width: 1100px) {
    .kpi-grid { grid-template-columns: repeat(2, 1fr); }
    .grid-2-1 { grid-template-columns: 1fr; }
}
@media (max-width: 800px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
    .main { margin-left: 0; }
    .menu-btn { display: inline-flex; }
    .content { padding: 18px; }
    .topbar { padding: 0 18px; }
    .user-menu .user-meta { display: none; }
}
@media (max-width: 480px) {
    .kpi-grid { grid-template-columns: 1fr; }
    .auth-card { padding: 24px; }
}

.sidebar-backdrop {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 25;
}
.sidebar-backdrop.open { display: block; }

/* ──────────────────────────────────────────────────────────────────
   FORMS  (create/edit pages)
   ────────────────────────────────────────────────────────────────── */
.form-section {
    background: #fff;
    border: 1px solid var(--c-border);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 18px;
}
.form-section h3 {
    font-size: 15px;
    font-weight: 700;
    margin-bottom: 4px;
}
.form-section .section-desc {
    font-size: 13px;
    color: var(--c-muted);
    margin-bottom: 18px;
}
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}
.form-grid .full { grid-column: 1 / -1; }
.req { color: var(--c-danger); margin-left: 2px; }
.form-help {
    margin-top: 4px;
    font-size: 12px;
    color: var(--c-muted);
}
.invalid-feedback {
    color: var(--c-danger);
    font-size: 12px;
    margin-top: 4px;
}
.form-control.is-invalid {
    border-color: var(--c-danger);
    background: #FEF2F2;
}

.form-control[type="select"],
select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none' stroke='%236B7280' stroke-width='2' stroke-linecap='round'><polyline points='2,2 6,6 10,2'/></svg>");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 36px;
}
textarea.form-control {
    height: auto;
    min-height: 80px;
    padding: 10px 13px;
    resize: vertical;
}

.form-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    padding-top: 8px;
}
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn-danger {
    background: var(--c-danger);
    color: #fff;
    border: 0;
}
.btn-danger:hover { background: #B91C1C; color: #fff; }
.btn-ghost-danger {
    background: transparent;
    color: var(--c-danger);
    border: 1px solid #FECACA;
}
.btn-ghost-danger:hover { background: var(--c-danger-bg); }

/* Radio-style segmented control for "access mode" */
.segmented {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}
.segmented label {
    display: block;
    cursor: pointer;
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    padding: 12px 14px;
    transition: all .15s;
    background: #fff;
}
.segmented label:hover { border-color: var(--c-primary); }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label:has(input:checked) {
    border-color: var(--c-primary);
    background: var(--c-primary-light);
    box-shadow: 0 0 0 3px rgba(22,163,74,.10);
}
.segmented .seg-label { font-weight: 600; font-size: 13px; color: var(--c-text); display: block; }
.segmented .seg-desc  { font-size: 12px; color: var(--c-muted); display: block; margin-top: 2px; }

/* ──────────────────────────────────────────────────────────────────
   FILTER TABS  (Tenants index header)
   ────────────────────────────────────────────────────────────────── */
.filter-tabs {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--c-border);
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.filter-tab {
    padding: 10px 16px;
    border: 0;
    background: none;
    color: var(--c-muted);
    font: inherit;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.filter-tab:hover { color: var(--c-text); }
.filter-tab.active {
    color: var(--c-primary);
    border-bottom-color: var(--c-primary);
    font-weight: 600;
}
.filter-tab .count {
    background: var(--c-border-soft);
    color: var(--c-muted);
    border-radius: 50px;
    padding: 1px 8px;
    font-size: 11px;
    font-weight: 600;
}
.filter-tab.active .count {
    background: var(--c-primary-light);
    color: var(--c-primary-text);
}

.toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 18px;
    flex-wrap: wrap;
}
.toolbar .search {
    flex: 1;
    min-width: 220px;
    position: relative;
}
.toolbar .search input {
    width: 100%;
    height: 38px;
    padding: 0 14px 0 38px;
    border: 1px solid var(--c-border);
    border-radius: 50px;
    background: #fff;
    font: inherit;
    font-size: 14px;
    outline: none;
}
.toolbar .search input:focus {
    border-color: var(--c-primary);
    box-shadow: 0 0 0 3px rgba(22,163,74,.12);
}
.toolbar .search svg {
    position: absolute;
    left: 12px; top: 50%;
    transform: translateY(-50%);
    color: var(--c-muted);
}
.toolbar select {
    height: 38px;
    padding: 0 32px 0 14px;
    border: 1px solid var(--c-border);
    border-radius: 50px;
    background-color: #fff;
    font: inherit;
    font-size: 14px;
}

/* Pagination */
.pagination {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    list-style: none;
    justify-content: flex-end;
    margin: 0;
}
.pagination li span,
.pagination li a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    padding: 0 10px;
    border-radius: 6px;
    border: 1px solid var(--c-border);
    color: var(--c-text);
    font-size: 13px;
    text-decoration: none;
    background: #fff;
}
.pagination li.active span,
.pagination li a:hover {
    background: var(--c-primary);
    color: #fff;
    border-color: var(--c-primary);
}
.pagination li.disabled span {
    color: var(--c-muted-light);
    background: var(--c-border-soft);
}

/* List footer: results summary + "Show items" per-page selector + page links */
.list-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    padding: 12px 16px;
    border-top: 1px solid var(--c-border);
}
.list-controls .list-summary {
    margin: 0;
    font-size: 13px;
    color: var(--c-muted);
}
.list-controls .list-summary strong {
    color: var(--c-text);
    font-weight: 600;
}
.list-controls-right {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}
.per-page-form {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 0;
}
.per-page-form label {
    font-size: 13px;
    color: var(--c-muted);
    margin: 0;
}
.per-page-select {
    height: 32px;
    padding: 0 28px 0 10px;
    border: 1px solid var(--c-border);
    border-radius: 6px;
    background: #fff;
    color: var(--c-text);
    font-size: 13px;
    cursor: pointer;
}
.list-controls-right .pagination {
    padding: 0;
}


/* Stat row inside tenant show page */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
    margin-bottom: 22px;
}
.stat-tile {
    background: #fff;
    border: 1px solid var(--c-border);
    border-radius: var(--radius-lg);
    padding: 16px 18px;
}
.stat-tile .label { font-size: 12px; color: var(--c-muted); font-weight: 500; margin-bottom: 6px; }
.stat-tile .value { font-size: 22px; font-weight: 800; color: var(--c-text); letter-spacing: -.4px; }

/* Reveal box for new password */
.reveal-box {
    background: #FFFBEB;
    border: 1px solid #FCD34D;
    border-radius: var(--radius);
    padding: 14px 16px;
    margin-bottom: 18px;
}
.reveal-box h4 { font-size: 14px; margin-bottom: 8px; }
.reveal-box code {
    display: inline-block;
    padding: 6px 12px;
    background: #fff;
    border: 1px dashed #FCD34D;
    border-radius: 6px;
    font-family: 'SFMono-Regular', Menlo, monospace;
    font-size: 13px;
    color: #92400E;
    user-select: all;
}

/* ──────────────────────────────────────────────────────────────────
   PLAN CARDS  (Plans & Billing index)
   ────────────────────────────────────────────────────────────────── */
.plan-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 18px;
    margin-top: 4px;
}
.plan-card {
    background: #fff;
    border: 1px solid var(--c-border);
    border-radius: var(--radius-lg);
    padding: 22px 22px 18px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    transition: transform .15s, box-shadow .15s, border-color .15s;
}
.plan-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(0,0,0,.06);
    border-color: #C7D2FE;
}
.plan-card.plan-inactive { opacity: .65; }
.plan-card .plan-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
}
.plan-card .plan-name {
    font-size: 18px;
    font-weight: 700;
    color: var(--c-text);
}
.plan-card .plan-tagline {
    font-size: 12.5px;
    color: var(--c-muted);
    margin-top: 2px;
}
.plan-card .plan-price {
    display: flex;
    align-items: baseline;
    gap: 4px;
    margin-top: 4px;
}
.plan-card .plan-price .amt {
    font-size: 28px;
    font-weight: 800;
    color: var(--c-text);
    line-height: 1;
}
.plan-card .plan-price .per {
    font-size: 13px;
    color: var(--c-muted);
}
.plan-card .plan-price-yearly {
    font-size: 12.5px;
    color: var(--c-muted);
}
.plan-card .plan-price-yearly .save-tag {
    display: inline-block;
    margin-left: 6px;
    background: var(--c-primary-light);
    color: var(--c-primary-text);
    border-radius: 999px;
    padding: 1px 8px;
    font-size: 11px;
    font-weight: 600;
}
.plan-card .plan-features {
    list-style: none;
    padding: 0;
    margin: 6px 0 4px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
}
.plan-card .plan-features li {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 13px;
    color: var(--c-text);
    line-height: 1.4;
}
.plan-card .plan-features li svg {
    color: var(--c-primary);
    flex: none;
    margin-top: 3px;
}
.plan-card .plan-usage {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding-top: 4px;
    border-top: 1px solid var(--c-border-soft);
}
.plan-card .usage-pill {
    background: var(--c-primary-light);
    color: var(--c-primary-text);
    font-size: 12px;
    padding: 3px 10px;
    border-radius: 999px;
}
.plan-card .usage-pill.muted { background: var(--c-border-soft); color: var(--c-muted); }
.plan-card .usage-pill.warn  { background: var(--c-warning-bg);  color: #92400E; }
.plan-card .plan-actions {
    display: flex;
    gap: 6px;
    justify-content: flex-end;
}

/* Inline checkbox label inside form rows */
.check-line {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--c-text);
    cursor: pointer;
}
.check-line input { margin: 0; }

@media (max-width: 800px) {
    .form-grid { grid-template-columns: 1fr; }
    .segmented { grid-template-columns: 1fr; }
    .stat-grid { grid-template-columns: 1fr 1fr; }
}

/* ──────────────────────────────────────────────────────────────────
   SETTINGS  (tabbed layout)
   ────────────────────────────────────────────────────────────────── */
.settings-shell {
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: 18px;
    align-items: start;
}
.settings-tabs {
    background: #fff;
    border: 1px solid var(--c-border);
    border-radius: var(--radius-lg);
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    position: sticky;
    top: 80px;
}
.settings-tab {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius);
    font-size: 13.5px;
    font-weight: 500;
    color: var(--c-text-soft);
    cursor: pointer;
    transition: background .15s, color .15s;
}
.settings-tab:hover { background: var(--c-border-soft); color: var(--c-text); }
.settings-tab.active {
    background: var(--c-primary-light);
    color: var(--c-primary-text);
    font-weight: 600;
}
.settings-tab svg { flex-shrink: 0; }

.settings-panel { min-width: 0; }

/* Hex color picker pair */
.color-input {
    display: flex;
    gap: 8px;
    align-items: center;
}
.color-input input[type="color"] {
    width: 44px;
    height: 40px;
    padding: 2px;
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    cursor: pointer;
    background: #fff;
    flex-shrink: 0;
}
.color-input input[type="text"] {
    flex: 1;
    font-family: 'SF Mono', Menlo, monospace;
    text-transform: uppercase;
}

/* Asset upload preview */
.asset-preview {
    background: var(--c-border-soft);
    border: 1px dashed var(--c-border);
    border-radius: var(--radius);
    padding: 16px;
    height: 96px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 8px;
}
.asset-preview img { max-width: 100%; max-height: 64px; object-fit: contain; }
.asset-preview .favicon-img { max-width: 48px; max-height: 48px; }
.asset-empty {
    color: var(--c-muted);
    font-size: 12px;
    font-style: italic;
}

@media (max-width: 900px) {
    .settings-shell { grid-template-columns: 1fr; }
    .settings-tabs {
        flex-direction: row;
        overflow-x: auto;
        position: static;
    }
    .settings-tab { white-space: nowrap; }
}

/* ──────────────────────────────────────────────────────────────────
   TOGGLE SWITCH + PREFERENCE ROWS  (Settings — Figma 37:44683)
   ────────────────────────────────────────────────────────────────── */
.pref-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
    padding: 18px 0;
    border-bottom: 1px solid var(--c-border-soft);
}
.pref-row:first-of-type { padding-top: 4px; }
.pref-row:last-of-type  { border-bottom: 0; padding-bottom: 4px; }
.pref-text { min-width: 0; }
.pref-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--c-text);
}
.pref-desc {
    font-size: 13px;
    color: var(--c-muted);
    margin-top: 2px;
    line-height: 1.45;
}

.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
    cursor: pointer;
}
.switch input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}
.switch .switch-track {
    position: absolute;
    inset: 0;
    background: var(--c-border);
    border-radius: 999px;
    transition: background .18s;
}
.switch .switch-track::before {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background: #fff;
    border-radius: 50%;
    box-shadow: var(--shadow-sm);
    transition: transform .18s;
}
.switch input:checked + .switch-track {
    background: var(--c-primary);
}
.switch input:checked + .switch-track::before {
    transform: translateX(20px);
}
.switch input:focus-visible + .switch-track {
    box-shadow: 0 0 0 3px rgba(22,163,74,.20);
}

/* Upcoming (not-yet-built) sidebar nav items */
.nav-item.is-upcoming {
    opacity: .55;
    cursor: default;
}
.nav-item.is-upcoming:hover {
    background: transparent;
    color: var(--c-text-soft);
}

/* ───────────────────────── Settings: shared building blocks ───────────────────────── */
.section-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-top: 20px;
}
.section-count {
    color: var(--c-muted);
    font-weight: 500;
    font-size: 13px;
}
.field-hint {
    margin: 6px 0 0;
    font-size: 12px;
    color: var(--c-muted);
}
.check-inline {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
    font-size: 13px;
    color: var(--c-text-soft);
    cursor: pointer;
}
.inline-form { display: inline; }
.table-empty {
    text-align: center;
    color: var(--c-muted);
    padding: 28px !important;
}
.kpi-grid-3 { grid-template-columns: repeat(3, 1fr); }

/* Ghost button */
.btn-ghost {
    background: #fff;
    border: 1px solid var(--c-border);
    color: var(--c-text);
}
.btn-ghost:hover { background: var(--c-border-soft); }

/* Leading cell (icon + title + subtitle) */
.cell-lead { display: flex; align-items: center; gap: 12px; }
.cell-icon {
    width: 34px; height: 34px;
    flex-shrink: 0;
    border-radius: 9px;
    background: rgba(var(--c-primary-rgb), 0.1);
    color: var(--c-primary);
    display: flex; align-items: center; justify-content: center;
}
.cell-title { font-weight: 600; color: var(--c-text); }
.cell-sub { font-size: 12px; color: var(--c-muted); margin-top: 2px; }

/* Status pill (active / inactive) — theme-aware */
.status-pill {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 4px 11px;
    border-radius: 999px;
    font-size: 12px; font-weight: 600;
}
.status-pill .dot { width: 6px; height: 6px; border-radius: 50%; }
.status-pill.is-on  { background: rgba(var(--c-primary-rgb), 0.08); color: var(--c-primary); }
.status-pill.is-on .dot  { background: var(--c-primary); }
.status-pill.is-off { background: var(--c-border-soft); color: var(--c-muted); }
.status-pill.is-off .dot { background: var(--c-muted); }

/* Row action icon buttons */
.row-actions { display: flex; align-items: center; gap: 6px; justify-content: flex-end; }
.icon-action {
    width: 32px; height: 32px;
    display: inline-flex; align-items: center; justify-content: center;
    border: 1px solid var(--c-border);
    background: #fff;
    border-radius: 8px;
    color: var(--c-text-soft);
    cursor: pointer;
    transition: all .15s;
}
.icon-action:hover { background: var(--c-border-soft); color: var(--c-text); }
.icon-action-danger:hover { background: #fef3f2; color: #d92d20; border-color: #fecdca; }

/* ───────────────────────── Modal ───────────────────────── */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(16, 24, 40, .55);
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding: 7vh 16px 16px;
    z-index: 100;
}
.modal-overlay.open { display: flex; }
.modal {
    background: #fff;
    border-radius: 14px;
    width: 100%;
    max-width: 520px;
    max-height: 86vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 20px 48px rgba(16, 24, 40, .28);
    animation: modal-in .16s ease-out;
}
.modal > form {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
}
@keyframes modal-in {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}
.modal-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 18px 22px;
    border-bottom: 1px solid var(--c-border);
    flex-shrink: 0;
}
.modal-head h3 { margin: 0; font-size: 17px; }
.modal-close {
    background: none; border: none;
    font-size: 24px; line-height: 1;
    color: var(--c-muted); cursor: pointer;
}
.modal-close:hover { color: var(--c-text); }
.modal-body {
    padding: 20px 22px;
    overflow-y: auto;
    flex: 1 1 auto;
    min-height: 0;
}
.modal-body .form-group { margin-bottom: 14px; }
.modal-foot {
    display: flex; justify-content: flex-end; gap: 10px;
    padding: 16px 22px;
    border-top: 1px solid var(--c-border);
    flex-shrink: 0;
}
.modal-foot .btn {
    width: auto !important;
}

/* ───────────────────────── Branding preview ───────────────────────── */
.brand-preview {
    border: 1px solid var(--c-border);
    border-radius: 12px;
    overflow: hidden;
    max-width: 460px;
}
.brand-preview-bar {
    display: flex; align-items: center; gap: 10px;
    padding: 14px 18px;
    color: #fff; font-weight: 700;
}
.brand-preview-dot { width: 18px; height: 18px; border-radius: 6px; background: #fff; }
.brand-preview-body { padding: 18px; display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.brand-preview-body p { width: 100%; margin: 0 0 4px; font-size: 14px; }
.brand-preview-btn {
    border: none; color: #fff;
    padding: 9px 16px; border-radius: 8px;
    font-weight: 600; font-size: 13px; cursor: pointer;
}
.brand-preview-badge {
    color: #fff; padding: 5px 12px;
    border-radius: 999px; font-size: 12px; font-weight: 600;
}

@media (max-width: 720px) {
    .kpi-grid-3 { grid-template-columns: 1fr; }
    .section-head { flex-direction: column; }
}

/* ───────────────────────── Dark action button ───────────────────────── */
.btn-dark {
    background: #111827;
    color: #fff;
}
.btn-dark:hover { background: #1f2937; color: #fff; }
.btn-dark:active { transform: translateY(1px); }

/* KPI-with-corner-icon tiles now use the shared .ctr-tile component. */

/* ───────────────────────── Rate distribution map ───────────────────────── */
.rate-map {
    position: relative;
    margin-top: 16px;
    height: 300px;
    border: 1px solid var(--c-border);
    border-radius: 12px;
    background-color: #fbfdfc;
    background-image:
        linear-gradient(to right, #e5e7eb 1px, transparent 1px),
        linear-gradient(to bottom, #e5e7eb 1px, transparent 1px);
    background-size: 16.666% 25%;
    overflow: hidden;
}
.rate-map-blob {
    position: absolute;
    background: rgba(148,163,184,.16);
    border-radius: 999px;
    filter: blur(2px);
    transform: translate(-50%, -50%);
}
.rate-pin {
    position: absolute;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    z-index: 2;
}
.rate-pin-dot {
    width: 30px; height: 30px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 0 0 4px rgba(var(--c-primary-rgb), .15);
    transition: transform .12s, box-shadow .12s;
}
.rate-pin.is-on  .rate-pin-dot { background: var(--c-primary); color: #fff; box-shadow: 0 0 0 4px rgba(var(--c-primary-rgb), .15); }
.rate-pin.is-off .rate-pin-dot { background: var(--c-border); color: #fff; box-shadow: 0 0 0 4px rgba(var(--c-border-rgb, 203, 213, 225), .18); }
.rate-pin:hover .rate-pin-dot { transform: scale(1.12); }
.rate-pin-label {
    font-size: 10px;
    font-weight: 600;
    color: var(--c-text);
    background: rgba(255,255,255,.92);
    padding: 2px 8px;
    border-radius: 4px;
    white-space: nowrap;
    box-shadow: 0 1px 2px rgba(0,0,0,.1);
}
/* Tooltip on hover */
.rate-pin::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: -36px;
    left: 50%;
    transform: translateX(-50%);
    background: #111827;
    color: #fff;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity .15s;
    z-index: 10;
}
.rate-pin:hover::after {
    opacity: 1;
}
.rate-map-hint {
    text-align: center;
    margin: 12px 0 0;
    font-size: 12px;
    color: var(--c-muted);
}

/* ───────────────────────── Table toolbar (search + filter + add) ───────────────────────── */
.table-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.toolbar-search {
    position: relative;
    min-width: 200px;
}
.toolbar-search input {
    width: 100%;
    height: 36px;
    padding: 0 12px 0 34px;
    border: 1px solid var(--c-border);
    border-radius: 8px;
    background: #fff;
    font: inherit;
    font-size: 13px;
    outline: none;
}
.toolbar-search input:focus {
    border-color: var(--c-primary);
    box-shadow: 0 0 0 3px rgba(22,163,74,.12);
}
.toolbar-search svg {
    position: absolute;
    left: 11px; top: 50%;
    transform: translateY(-50%);
    color: var(--c-muted);
}
.toolbar-select {
    height: 36px;
    padding: 0 30px 0 12px;
    border: 1px solid var(--c-border);
    border-radius: 8px;
    background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23667085' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E") no-repeat right 10px center;
    font: inherit;
    font-size: 13px;
    color: var(--c-text);
    cursor: pointer;
    outline: none;
    appearance: none;
    -webkit-appearance: none;
}
.toolbar-select:focus { border-color: var(--c-primary); }

/* ───────────────────────── Status text (dot + label, no pill bg) ───────────────────────── */
.status-text {
    display: inline-flex; align-items: center; gap: 7px;
    font-size: 13px; font-weight: 600;
}
.status-text .dot { width: 7px; height: 7px; border-radius: 50%; }
.status-text.is-on  { color: var(--c-primary); }
.status-text.is-on .dot  { background: var(--c-primary); }
.status-text.is-off { color: var(--c-muted); }
.status-text.is-off .dot { background: var(--c-border); }

/* ───────────────────────── Plain-text row action link ───────────────────────── */
.link-action {
    background: none;
    border: none;
    padding: 0;
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    color: var(--c-primary);
    cursor: pointer;
    transition: color .2s ease;
}
.link-action:hover {
    color: var(--c-hover);
    text-decoration: underline;
}
.link-action:active {
    color: var(--c-selected);
}
.link-action-danger { color: #98a2b3; }
.link-action-danger:hover { color: #d92d20; }

/* ──────────────────────────────────────────────────────────────────
   WHO'S WORKING SECTION  (Dashboard — Figma 6:200–6:340)
   Horizontal caregiver cards: avatar + name/client, time + Active,
   location row. Matches the Figma layout exactly.
   ────────────────────────────────────────────────────────────────── */

/* Responsive row of equal-width cards (6 across on wide screens). */
.who-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

/* Individual caregiver card */
.who-card {
    background: #fff;
    border: 1px solid #E5E7EB;
    border-radius: 12px;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    transition: box-shadow .15s, border-color .15s;
}
.who-card:hover {
    border-color: #BBF7D0;
    box-shadow: 0 2px 8px rgba(22, 163, 74, .10);
}

/* Top row: avatar + name/client */
.who-top {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Avatar circle — 38px */
.who-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgba(var(--c-primary-rgb), 0.12);
    color: var(--c-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 13px;
    flex-shrink: 0;
    overflow: hidden;
}
.who-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.who-id {
    min-width: 0;
    flex: 1;
}

/* Caregiver name */
.who-name {
    font-size: 14px;
    font-weight: 600;
    color: #111827;
    line-height: 1.25;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Client name */
.who-client {
    font-size: 12px;
    color: #6B7280;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Middle row: time (left) + Active status (right) */
.who-mid {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
.who-time {
    font-size: 12px;
    color: #6B7280;
}
.who-status {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    font-weight: 500;
    color: var(--c-primary);
    white-space: nowrap;
}
.who-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--c-primary);
    flex-shrink: 0;
}

/* Location row */
.who-loc {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    color: #9CA3AF;
    min-width: 0;
}
.who-loc svg {
    width: 13px;
    height: 13px;
    flex-shrink: 0;
}
.who-loc span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

@media (max-width: 1024px) {
    .who-grid {
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
        gap: 14px;
    }
}
@media (max-width: 640px) {
    .who-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 12px;
    }
}

/* ──────────────────────────────────────────────────────────────────
   CURRENTLY WORKING SECTION  (Schedule — collapsible with live map)
   ────────────────────────────────────────────────────────────────── */

/* Container */
.cw-section {
    background: #F0FDF4;
    border: 1px solid #BBF7D0;
    border-radius: var(--radius-xl);
    padding: 20px 22px;
    margin-bottom: 24px;
}

/* Header row */
.cw-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}
.cw-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 15px;
    font-weight: 700;
    color: #166534;
}
/* Pulsing green live-dot */
.cw-live-dot {
    width: 10px; height: 10px;
    border-radius: 50%;
    background: #16A34A;
    flex-shrink: 0;
    position: relative;
}
.cw-live-dot::after {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    background: rgba(22,163,74,.25);
    animation: cwPulse 1.8s ease-in-out infinite;
}
@keyframes cwPulse {
    0%, 100% { transform: scale(1); opacity: .8; }
    50%       { transform: scale(1.55); opacity: 0; }
}

/* Collapse toggle button */
.cw-toggle {
    background: none;
    border: 0;
    cursor: pointer;
    color: #6B7280;
    padding: 4px;
    border-radius: var(--radius-sm);
    display: flex; align-items: center;
    transition: color .15s, background .15s;
    line-height: 1;
}
.cw-toggle:hover { color: #166534; background: rgba(22,163,74,.08); }
.cw-toggle svg { transition: transform .25s ease; }
.cw-toggle.is-collapsed svg { transform: rotate(180deg); }

/* Collapsible body */
.cw-body {
    display: flex;
    gap: 16px;
    align-items: stretch;
    flex-wrap: nowrap;
}
.cw-body.is-hidden { display: none; }

/* Left: 2-column cards grid.
   align-content:start keeps the rows at their natural height — without it the
   grid stretches its rows to fill the map's height and the cards balloon into
   tall empty boxes, which is the main way this drifted from the design. */
.cw-cards {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-auto-rows: min-content;
    align-content: start;
    gap: 10px;
    min-width: 0;
}

/* Individual caregiver card */
.cw-card {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #fff;
    border: 1px solid #E5E7EB;
    border-radius: 12px;
    padding: 13px 14px;
    text-decoration: none;
    color: inherit;
    transition: box-shadow .15s, border-color .15s, transform .12s;
    cursor: pointer;
    min-width: 0;
}
.cw-card:hover {
    border-color: #BBF7D0;
    box-shadow: 0 2px 10px rgba(22,163,74,.10);
    transform: translateY(-1px);
    color: inherit;
}

/* Avatar with green status dot */
.cw-avatar-wrap {
    position: relative;
    flex-shrink: 0;
    width: 48px; height: 48px;
}
.cw-avatar {
    width: 48px; height: 48px;
    border-radius: 50%;
    background: rgba(var(--c-primary-rgb), 0.12);
    color: var(--c-primary);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700;
    font-size: 15px;
    overflow: hidden;
    object-fit: cover;
}
.cw-avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.cw-online-dot {
    position: absolute;
    bottom: 1px; right: 1px;
    width: 13px; height: 13px;
    background: #22C55E;
    border: 2.5px solid #fff;
    border-radius: 50%;
}

/* Card info (name + time·client) */
.cw-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.cw-name {
    font-size: 14px;
    font-weight: 600;
    color: #111827;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}
.cw-sub {
    font-size: 12px;
    color: #6B7280;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

/* Right chevron */
.cw-arrow {
    flex-shrink: 0;
    color: #9CA3AF;
    transition: color .15s, transform .15s;
}
.cw-card:hover .cw-arrow {
    color: #16A34A;
    transform: translateX(2px);
}

/* Right: Map panel.
   `isolation: isolate` is load-bearing, not decoration. Leaflet stacks its own
   panes and controls at z-index 400–1000; `position: relative` alone does NOT
   open a stacking context, so those numbers used to compete at the root level
   and beat every modal on the page (.modal-overlay is 100). The map then
   painted over open dialogs and stayed clickable through the backdrop.
   Isolating collapses the whole map into a single z-index:auto box in the root
   stack, so ordinary modals sit above it again. */
.cw-map-wrap {
    position: relative;
    isolation: isolate;
    width: 380px;
    flex-shrink: 0;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid #BBF7D0;
    min-height: 240px;
    align-self: stretch;
}
.cw-map {
    width: 100%;
    height: 100%;
    min-height: 240px;
}

/* Expand-to-full-view control, floated over the inline map.
   Leaflet's own panes and controls run up to z-index 1000, so this has to sit
   above that band or the map paints straight over it. */
.cw-map-expand {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 1001;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    border: 1px solid var(--c-border);
    border-radius: 8px;
    color: #374151;
    cursor: pointer;
    box-shadow: 0 1px 4px rgba(0,0,0,.18);
    transition: background .12s, color .12s;
}
.cw-map-expand:hover { background: #F0FDF4; color: #16A34A; }
.cw-map-expand svg { width: 15px; height: 15px; }

/* Full-view map modal */
.cw-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, .55);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    z-index: 1000;
}
.cw-modal-backdrop[hidden] { display: none; }
.cw-modal {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 1100px;
    height: min(80vh, 760px);
    background: #fff;
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 20px 50px rgba(0,0,0,.28);
}
.cw-modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--c-border);
    background: #F0FDF4;
}
.cw-modal-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 15px;
    font-weight: 700;
    color: #166534;
}
.cw-modal-close {
    background: none;
    border: 0;
    font-size: 24px;
    line-height: 1;
    color: #6B7280;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 6px;
}
.cw-modal-close:hover { color: #111827; background: rgba(0,0,0,.05); }
/* The map fills the rest of the dialog — it needs a real height, not auto. */
.cw-modal-map { flex: 1; min-height: 0; }

/* Leaflet caregiver pin */
/* Map pin — a circular caregiver avatar ringed in green, as in the design.
   Falls back to initials on the brand colour when the caregiver has no photo. */
.cw-pin {
    width: 44px; height: 44px;
    border-radius: 50%;
    border: 3px solid #16A34A;
    box-shadow: 0 2px 8px rgba(0,0,0,.22);
    display: flex; align-items: center; justify-content: center;
    color: #fff;
    font-weight: 700;
    font-size: 13px;
    font-family: 'Inter', -apple-system, sans-serif;
    background: var(--cw-pin-bg, #16A34A);
    cursor: pointer;
    overflow: hidden;
    transition: box-shadow .15s, transform .12s;
}
.cw-pin img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    display: block;
}
/* Leaflet's divIcon carries a white box + border by default, which would
   frame the round pin in a square. */
.cw-pin-wrap { background: transparent; border: 0; }
.cw-pin:hover {
    box-shadow: 0 4px 14px rgba(0,0,0,.28);
}

/* Empty state */
.cw-empty {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 28px 0;
    color: #6B7280;
    font-size: 13px;
    gap: 8px;
}

@media (max-width: 900px) {
    .cw-body { flex-direction: column; }
    .cw-map-wrap { width: 100%; height: 240px; align-self: auto; }
    .cw-map { height: 240px; min-height: 240px; }
}
@media (max-width: 640px) {
    .cw-cards { grid-template-columns: 1fr; }
}


/* ── Live-sync toast ──────────────────────────────────────────────────────
   Shown when another admin, or a caregiver on the mobile app, changed
   something this page is displaying. See public/js/sync.js.

   Bottom-left on purpose: the confirm dialog owns the centre, and the
   right-hand side is where sidebars and detail panes open. This corner is the
   one place a notice can sit without covering something the admin is using.
   ──────────────────────────────────────────────────────────────────────── */
.sync-toast {
    position: fixed;
    left: 20px;
    bottom: 20px;
    z-index: 1400;               /* under the confirm modal, over page chrome */
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px 10px 14px;
    border-radius: 10px;
    background: #111827;
    color: #f9fafb;
    font-size: 13px;
    font-weight: 500;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .22);
    /* Animated in by a class the script adds on the next frame, so the
       transition actually runs instead of being skipped on insert. */
    opacity: 0;
    transform: translateY(8px);
    transition: opacity .18s ease, transform .18s ease;
    pointer-events: none;
}

.sync-toast.open {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.sync-toast-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--c-primary, #16A34A);
    flex: none;
}

.sync-toast-btn {
    border: 0;
    background: rgba(255, 255, 255, .14);
    color: inherit;
    font: inherit;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 6px;
    cursor: pointer;
}

.sync-toast-btn:hover { background: rgba(255, 255, 255, .24); }

.sync-toast-close {
    border: 0;
    background: none;
    color: inherit;
    font-size: 18px;
    line-height: 1;
    padding: 0 2px;
    cursor: pointer;
    opacity: .6;
}

.sync-toast-close:hover { opacity: 1; }

@media (max-width: 640px) {
    .sync-toast { left: 12px; right: 12px; bottom: 12px; }
}

@media (prefers-reduced-motion: reduce) {
    .sync-toast { transition: none; }
}
