:root {
    /* Default theme: Azul oscuro */
    --bg: #0A1019;
    --bg-grad: radial-gradient(1200px 600px at 100% -10%, rgba(245, 158, 11, 0.06), transparent 60%);
    --surface: #111A26;
    --surface-2: #162130;
    --surface-3: #1B2838;
    --surface-hover: #172334;
    --border: #223042;
    --border-strong: #2E3F54;
    --ink: #E8EDF3;
    --ink-soft: #9AA9BA;
    --ink-faint: #627387;
    --accent: #F59E0B;
    --accent-hover: #FBBF24;
    --accent-ink: #1A1206;
    --accent-tint: rgba(245, 158, 11, 0.13);
    --accent-glow: rgba(245, 158, 11, 0.35);
    --ok: #34D399;
    --ok-tint: rgba(52, 211, 153, 0.13);
    --warn: #FB923C;
    --warn-tint: rgba(251, 146, 60, 0.14);
    --info: #94A3B8;
    --info-tint: rgba(148, 163, 184, 0.14);
    --danger: #F87171;
    --danger-solid: #DC2626;
    --danger-tint: rgba(248, 113, 113, 0.13);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
    --shadow-lg: 0 24px 64px rgba(0, 0, 0, 0.55);
    --overlay: rgba(3, 6, 10, 0.62);
    --radius: 12px;
    --mono: 'IBM Plex Mono', ui-monospace, Menlo, monospace;
}

:root[data-theme="light"] {
    --bg: #F4F6FA;
    --bg-grad: radial-gradient(1200px 600px at 100% -10%, rgba(217, 119, 6, 0.06), transparent 60%);
    --surface: #FFFFFF;
    --surface-2: #F6F8FB;
    --surface-3: #EEF2F7;
    --surface-hover: #F8FAFC;
    --border: #E3E8EF;
    --border-strong: #CDD5E0;
    --ink: #111C2D;
    --ink-soft: #55657A;
    --ink-faint: #8593A6;
    --accent: #D97706;
    --accent-hover: #B45309;
    --accent-ink: #FFFFFF;
    --accent-tint: rgba(217, 119, 6, 0.10);
    --accent-glow: rgba(217, 119, 6, 0.30);
    --ok: #059669;
    --ok-tint: rgba(5, 150, 105, 0.10);
    --warn: #EA580C;
    --warn-tint: rgba(234, 88, 12, 0.10);
    --info: #64748B;
    --info-tint: rgba(100, 116, 139, 0.12);
    --danger: #DC2626;
    --danger-solid: #DC2626;
    --danger-tint: rgba(220, 38, 38, 0.08);
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
    --shadow: 0 10px 30px rgba(15, 23, 42, 0.10);
    --shadow-lg: 0 24px 64px rgba(15, 23, 42, 0.18);
    --overlay: rgba(15, 23, 42, 0.38);
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
    margin: 0;
    background: var(--bg-grad), var(--bg);
    background-attachment: fixed;
    color: var(--ink);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 14px;
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-weight: 700; letter-spacing: -0.015em; margin: 0; }
svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.hidden { display: none !important; }
.mono { font-family: var(--mono) !important; }
.muted { color: var(--ink-faint); }

/* ============================================================
   LOGIN
   ============================================================ */
.login-screen { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login-panel {
    position: relative;
    overflow: hidden;
    padding: 48px 56px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 22px;
    background:
        radial-gradient(600px 400px at 20% 10%, rgba(245, 158, 11, 0.20), transparent 60%),
        radial-gradient(500px 500px at 90% 100%, rgba(245, 158, 11, 0.10), transparent 60%),
        linear-gradient(160deg, #0E1724, #070C14);
    color: #E8EDF3;
    border-right: 1px solid rgba(255, 255, 255, 0.06);
}
.login-panel::after {
    content: '';
    position: absolute;
    inset: 0;
    background-image: linear-gradient(rgba(255,255,255,.035) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.035) 1px, transparent 1px);
    background-size: 36px 36px;
    mask-image: radial-gradient(ellipse at 30% 30%, #000 20%, transparent 70%);
    pointer-events: none;
}
.login-brand { display: flex; align-items: center; gap: 12px; font-weight: 800; font-size: 18px; letter-spacing: -.01em; position: absolute; top: 40px; left: 56px; }
.login-hero { font-size: 34px; line-height: 1.15; max-width: 460px; letter-spacing: -0.03em; font-weight: 800; }
.login-points { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 12px; color: #B4C0CE; font-size: 14px; }
.login-points li { display: flex; align-items: center; gap: 10px; }
.login-points svg { color: #F59E0B; background: rgba(245, 158, 11, .14); border-radius: 50%; padding: 3px; width: 20px; height: 20px; }
.login-foot { position: absolute; bottom: 32px; left: 56px; margin: 0; font-size: 12px; color: #627387; }

.login-side { display: flex; align-items: center; justify-content: center; padding: 32px; }
.login-card { width: 100%; max-width: 360px; }
.login-card h1 { font-size: 24px; }
.login-sub { color: var(--ink-soft); font-size: 13.5px; margin: 6px 0 28px; }
.login-card .field { margin-bottom: 16px; }

.login-error {
    margin: 14px 0 0;
    font-size: 12.5px;
    color: var(--danger);
    background: var(--danger-tint);
    border-radius: 8px;
    padding: 9px 11px;
}

/* ============================================================
   LOGO / BRAND
   ============================================================ */
.logo-mark {
    width: 34px; height: 34px;
    border-radius: 10px;
    background: linear-gradient(145deg, #FBBF24, #D97706);
    color: #1A1206;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 4px 14px var(--accent-glow), inset 0 1px 0 rgba(255,255,255,.35);
}
.logo-mark svg { width: 20px; height: 20px; stroke-width: 2.1; }

/* ============================================================
   FIELDS / INPUTS
   ============================================================ */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field label { font-size: 12px; font-weight: 600; color: var(--ink-soft); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.optional { font-weight: 400; color: var(--ink-faint); }
.hint { font-size: 12px; color: var(--ink-faint); }

input, select {
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--ink);
    border-radius: 8px;
    padding: 9px 11px;
    font-size: 13.5px;
    font-family: inherit;
    transition: border-color .15s, box-shadow .15s, background .15s;
    width: 100%;
}
input::placeholder { color: var(--ink-faint); }
input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-tint); }
select { cursor: pointer; }

.input-action { display: flex; gap: 8px; }
.input-suffix { position: relative; width: 130px; flex-shrink: 0; }
.input-suffix input { padding-right: 56px; }
.input-suffix span { position: absolute; right: 11px; top: 50%; transform: translateY(-50%); font-size: 12px; color: var(--ink-faint); pointer-events: none; }

.choice-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.choice { position: relative; cursor: pointer; }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice-body {
    display: flex; flex-direction: column; gap: 2px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    border-radius: 10px;
    padding: 11px 13px;
    transition: border-color .15s, background .15s, box-shadow .15s;
}
.choice-body strong { font-size: 13.5px; }
.choice-body small { font-size: 12px; color: var(--ink-faint); }
.choice:hover .choice-body { border-color: var(--border-strong); }
.choice input:checked + .choice-body { border-color: var(--accent); background: var(--accent-tint); box-shadow: 0 0 0 3px var(--accent-tint); }

.duration-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.presets { display: flex; gap: 6px; flex-wrap: wrap; flex: 1; }
.presets button {
    background: var(--surface-2); border: 1px solid var(--border); color: var(--ink-soft);
    border-radius: 999px; padding: 6px 12px; font-size: 12px; font-weight: 600; font-family: inherit; cursor: pointer;
}
.presets button:hover { border-color: var(--border-strong); color: var(--ink); }
.presets button.active { border-color: var(--accent); color: var(--accent); background: var(--accent-tint); }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 8px 15px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    border: 1px solid transparent;
    transition: background-color .15s, border-color .15s, color .15s, opacity .15s, box-shadow .15s;
    white-space: nowrap;
}
.btn-primary { background: var(--accent); color: var(--accent-ink); box-shadow: 0 1px 0 rgba(255,255,255,.2) inset, 0 4px 12px -4px var(--accent-glow); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--surface-2); color: var(--ink); border-color: var(--border); }
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }
.btn-ghost { background: transparent; color: var(--ink-soft); border-color: var(--border); }
.btn-ghost:hover { color: var(--ink); border-color: var(--border-strong); background: var(--surface-2); }
.btn-danger { background: var(--danger-solid); color: #fff; }
.btn-danger:hover { filter: brightness(1.08); }
.btn-sm { padding: 6px 11px; font-size: 12px; }
.btn-lg { padding: 11px 16px; font-size: 14px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.icon-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 34px; height: 34px;
    border-radius: 8px;
    background: transparent;
    border: 1px solid transparent;
    color: var(--ink-soft);
    cursor: pointer;
    transition: background .15s, color .15s, border-color .15s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); border-color: var(--border); }
.icon-btn.sm { width: 28px; height: 28px; }
.icon-btn.sm svg { width: 14px; height: 14px; }
.link-btn { background: none; border: none; color: var(--accent); font-weight: 600; font-size: 12.5px; cursor: pointer; padding: 0; font-family: inherit; }
.link-btn:hover { text-decoration: underline; }

/* ============================================================
   APP SHELL
   ============================================================ */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    width: 244px;
    flex-shrink: 0;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 18px 12px;
    position: sticky;
    top: 0;
    height: 100vh;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 4px 8px 22px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text strong { font-size: 15px; letter-spacing: -.01em; }
.brand-text span { font-size: 11.5px; color: var(--ink-faint); }

.nav-label { font-size: 10.5px; font-weight: 700; color: var(--ink-faint); text-transform: uppercase; letter-spacing: .08em; padding: 0 12px 8px; }
.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-item {
    position: relative;
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 9px 12px;
    border-radius: 8px;
    background: none;
    border: none;
    color: var(--ink-soft);
    font-size: 13.5px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    text-align: left;
    transition: background .15s, color .15s;
}
.nav-item svg { width: 17px; height: 17px; }
.nav-item:hover { background: var(--surface-2); color: var(--ink); }
.nav-item.active { background: var(--accent-tint); color: var(--accent); font-weight: 600; }
.nav-item.active::before { content: ''; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }
.nav-count { margin-left: auto; font-size: 11px; font-weight: 600; color: var(--ink-faint); background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 0 7px; min-width: 22px; text-align: center; }
.nav-count:empty { display: none; }
.nav-item.active .nav-count { color: var(--accent); border-color: transparent; background: var(--accent-tint); }

.sidebar-footer { border-top: 1px solid var(--border); padding-top: 12px; }
.session-user { display: flex; align-items: center; gap: 10px; padding: 4px 4px 4px 8px; }
.session-avatar {
    width: 32px; height: 32px; border-radius: 50%;
    background: linear-gradient(145deg, var(--accent-tint), var(--surface-3));
    border: 1px solid var(--border);
    color: var(--accent);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 12.5px; flex-shrink: 0;
}
.session-meta { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.25; }
.session-name { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.session-role { font-size: 11.5px; color: var(--ink-faint); }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.topbar {
    position: sticky; top: 0; z-index: 10;
    display: flex; align-items: center; justify-content: space-between; gap: 16px;
    padding: 18px 36px;
    background: color-mix(in srgb, var(--bg) 82%, transparent);
    backdrop-filter: blur(10px) saturate(160%);
    border-bottom: 1px solid var(--border);
}
.crumbs { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--ink-faint); margin-bottom: 2px; }
.crumbs svg { width: 12px; height: 12px; }
.crumbs span { color: var(--ink-soft); }
.topbar h1 { font-size: 21px; }
.topbar-actions { display: flex; align-items: center; gap: 6px; }
.topbar-actions .btn { margin-left: 8px; }
#refresh-btn.spinning svg { animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.content {
    padding: 24px 36px 56px;
    max-width: 1440px;
    width: 100%;
    margin: 0 auto;
}
.tab-content { animation: fadein .2s ease-out; }
@keyframes fadein { from { opacity: 0; transform: translateY(4px); } }

/* ============================================================
   DASHBOARD
   ============================================================ */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 16px; }
.kpi {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 18px;
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
}
.kpi-top { display: flex; align-items: center; justify-content: space-between; }
.kpi-label { font-size: 12.5px; font-weight: 600; color: var(--ink-soft); }
.kpi-icon { width: 32px; height: 32px; border-radius: 9px; display: flex; align-items: center; justify-content: center; background: var(--surface-2); color: var(--ink-soft); }
.kpi-icon.accent { background: var(--accent-tint); color: var(--accent); }
.kpi-icon.ok { background: var(--ok-tint); color: var(--ok); }
.kpi-icon.warn { background: var(--warn-tint); color: var(--warn); }
.kpi-value { font-size: 30px; font-weight: 800; letter-spacing: -.03em; margin-top: 8px; font-variant-numeric: tabular-nums; }
.kpi-value small { font-size: 14px; color: var(--ink-faint); font-weight: 600; letter-spacing: 0; margin-left: 4px; }
.kpi-foot { font-size: 12px; color: var(--ink-faint); margin-top: 2px; }

.dash-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.panel { padding: 18px 20px; }
.panel-wide { grid-column: 1 / -1; }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.panel-head h3 { font-size: 14.5px; }
.panel-sub { font-size: 12px; color: var(--ink-faint); }

.status-bar { display: flex; height: 12px; border-radius: 999px; overflow: hidden; background: var(--surface-3); gap: 2px; }
.status-bar span { display: block; height: 100%; transition: flex-grow .4s; }
.status-legend { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 18px; margin-top: 18px; }
.legend-item { display: flex; align-items: center; gap: 9px; font-size: 13px; color: var(--ink-soft); }
.legend-item b { margin-left: auto; color: var(--ink); font-variant-numeric: tabular-nums; }
.legend-dot { width: 9px; height: 9px; border-radius: 3px; }

.list { display: flex; flex-direction: column; }
.list-item {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 6px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    border-radius: 6px;
}
.list-item:last-child { border-bottom: none; }
.list-item:hover { background: var(--surface-hover); }
.list-main { min-width: 0; flex: 1; display: flex; flex-direction: column; }
.list-main strong { font-size: 13.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-main span { font-size: 12px; color: var(--ink-faint); }
.list-side { text-align: right; font-size: 12.5px; color: var(--ink-soft); white-space: nowrap; }
.list-empty { padding: 22px 6px; text-align: center; color: var(--ink-faint); font-size: 13px; }
.checkin-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 0 24px; }

/* ============================================================
   TABLE CARD
   ============================================================ */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}
.card-toolbar { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.spacer { flex: 1; }
.search { position: relative; width: 300px; max-width: 100%; }
.search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--ink-faint); width: 15px; height: 15px; }
.search input { padding: 8px 12px 8px 34px; font-size: 13px; }
.filter-select { width: auto; max-width: 300px; padding: 8px 11px; font-size: 13px; }
.result-count { font-size: 12px; color: var(--ink-faint); font-variant-numeric: tabular-nums; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
    display: inline-flex; align-items: center; gap: 6px;
    background: transparent; border: 1px solid var(--border);
    color: var(--ink-soft);
    border-radius: 999px; padding: 5px 11px;
    font-size: 12px; font-weight: 600; font-family: inherit; cursor: pointer;
}
.chip:hover { border-color: var(--border-strong); color: var(--ink); }
.chip.active { background: var(--accent-tint); border-color: transparent; color: var(--accent); }
.chip-count { font-size: 11px; opacity: .75; font-variant-numeric: tabular-nums; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
    text-align: left;
    padding: 10px 18px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--ink-faint);
    font-weight: 700;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
tbody td { padding: 12px 18px; border-bottom: 1px solid var(--border); color: var(--ink); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background .1s; }
tbody tr:hover { background: var(--surface-hover); }
tbody tr.clickable { cursor: pointer; }
.col-act { width: 56px; }
.col-chev { width: 40px; }
td.chev { color: var(--ink-faint); }
tr:hover td.chev { color: var(--accent); }

.entity { display: flex; align-items: center; gap: 11px; min-width: 0; }
.entity-avatar {
    width: 34px; height: 34px; border-radius: 9px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 13px; color: #fff;
    text-transform: uppercase;
}
.entity-avatar.round { border-radius: 50%; width: 30px; height: 30px; font-size: 12px; }
.entity-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.entity-text strong { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.entity-text span { font-size: 12px; color: var(--ink-faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.contact { display: flex; flex-direction: column; gap: 2px; font-size: 12.5px; color: var(--ink-soft); }
.contact span { display: inline-flex; align-items: center; gap: 6px; }
.contact svg { width: 13px; height: 13px; color: var(--ink-faint); }

.token-cell { display: inline-flex; align-items: center; gap: 4px; }
.token { font-family: var(--mono); font-size: 12px; color: var(--ink-soft); letter-spacing: .02em; }
.copy-btn { opacity: 0; transition: opacity .15s; }
tr:hover .copy-btn, .copy-btn:focus-visible, .drawer .copy-btn { opacity: 1; }
.copy-btn.copied { color: var(--ok); }

.type-tag { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--ink-soft); }
.type-tag svg { width: 14px; height: 14px; color: var(--ink-faint); }

.expiry { display: flex; flex-direction: column; gap: 5px; min-width: 130px; }
.expiry-top { display: flex; justify-content: space-between; gap: 8px; font-size: 12.5px; }
.expiry-top .rel { color: var(--ink-faint); font-size: 11.5px; }
.expiry-top .rel.soon { color: var(--warn); font-weight: 600; }
.expiry-top .rel.past { color: var(--danger); font-weight: 600; }
.progress { height: 4px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.progress span { display: block; height: 100%; border-radius: 999px; background: var(--ok); }
.progress span.soon { background: var(--warn); }
.progress span.past { background: var(--danger); }

.badge {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 3px 10px 3px 8px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 600;
    white-space: nowrap;
}
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.ACTIVE, .badge.on { background: var(--ok-tint); color: var(--ok); }
.badge.EXPIRED { background: var(--warn-tint); color: var(--warn); }
.badge.SUSPENDED, .badge.off { background: var(--info-tint); color: var(--info); }
.badge.REVOKED { background: var(--danger-tint); color: var(--danger); }
.role-tag { font-size: 12px; font-weight: 600; color: var(--ink-soft); background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; padding: 2px 8px; }
.role-tag.configurador { color: var(--accent); border-color: transparent; background: var(--accent-tint); }

.health { display: inline-flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--ink-soft); white-space: nowrap; }
.health-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-faint); position: relative; flex-shrink: 0; }
.health-dot.ok { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-tint); }
.health-dot.warn { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-tint); }
.health-dot.bad { background: var(--danger); box-shadow: 0 0 0 3px var(--danger-tint); }

.empty-row td { padding: 0; }
.empty-state { padding: 52px 20px; text-align: center; color: var(--ink-faint); }
.empty-state .empty-icon { width: 46px; height: 46px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); display: inline-flex; align-items: center; justify-content: center; margin-bottom: 12px; color: var(--ink-soft); }
.empty-state .empty-icon svg { width: 22px; height: 22px; }
.empty-state strong { display: block; color: var(--ink); font-size: 14px; margin-bottom: 4px; }
.empty-state p { margin: 0 0 14px; font-size: 13px; }

.skeleton { height: 12px; border-radius: 6px; background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ============================================================
   ACTION MENU
   ============================================================ */
.action-menu {
    position: fixed; z-index: 70;
    min-width: 200px;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: 10px;
    box-shadow: var(--shadow-lg);
    padding: 5px;
    animation: pop .12s ease-out;
}
.action-menu button {
    display: flex; align-items: center; gap: 10px; width: 100%;
    background: none; border: none; color: var(--ink);
    padding: 8px 10px; border-radius: 6px;
    font-size: 13px; font-family: inherit; cursor: pointer; text-align: left;
}
.action-menu button svg { width: 15px; height: 15px; color: var(--ink-faint); }
.action-menu button:hover { background: var(--surface-2); }
.action-menu button.danger { color: var(--danger); }
.action-menu button.danger svg { color: var(--danger); }
.action-menu button.danger:hover { background: var(--danger-tint); }
.action-menu hr { border: none; border-top: 1px solid var(--border); margin: 5px 2px; }

/* ============================================================
   DRAWER
   ============================================================ */
.drawer-overlay { position: fixed; inset: 0; background: var(--overlay); z-index: 40; animation: fade .15s ease-out; }
.drawer {
    position: fixed; top: 0; right: 0; bottom: 0; z-index: 45;
    width: 460px; max-width: 100%;
    background: var(--surface);
    border-left: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    display: flex; flex-direction: column;
    transform: translateX(100%);
    transition: transform .22s cubic-bezier(.2,.8,.2,1);
}
.drawer.open { transform: none; }
.drawer-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 22px 24px 18px; border-bottom: 1px solid var(--border); }
.drawer-kicker { font-size: 11.5px; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: .08em; margin-bottom: 4px; }
.drawer-head h2 { font-size: 19px; }
.drawer-body { flex: 1; overflow-y: auto; padding: 20px 24px 28px; display: flex; flex-direction: column; gap: 22px; }
.drawer-section h4 { margin: 0 0 10px; font-size: 11.5px; font-weight: 700; color: var(--ink-faint); text-transform: uppercase; letter-spacing: .07em; display: flex; justify-content: space-between; align-items: center; }
.drawer-section h4 .link-btn { text-transform: none; letter-spacing: 0; }
.props { display: grid; grid-template-columns: 130px 1fr; gap: 10px 14px; font-size: 13px; }
.props dt { color: var(--ink-faint); }
.props dd { margin: 0; color: var(--ink); min-width: 0; overflow-wrap: anywhere; }
.drawer-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.token-box { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: var(--surface-2); border: 1px dashed var(--border-strong); border-radius: 10px; padding: 12px 14px; }
.token-box .token { font-size: 14px; color: var(--ink); }
.mini-list { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.mini-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 13px; }
.mini-row:last-child { border-bottom: none; }
.mini-row.clickable { cursor: pointer; }
.mini-row.clickable:hover { background: var(--surface-hover); }
.mini-row .grow { flex: 1; min-width: 0; }
.mini-empty { padding: 16px; text-align: center; font-size: 13px; color: var(--ink-faint); }

/* ============================================================
   MODALS
   ============================================================ */
.modal-overlay {
    position: fixed; inset: 0;
    background: var(--overlay);
    backdrop-filter: blur(3px);
    display: flex; align-items: center; justify-content: center;
    z-index: 50;
    padding: 20px;
    animation: fade .15s ease-out;
}
.modal-card {
    width: 100%;
    max-width: 380px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 22px;
    box-shadow: var(--shadow-lg);
    animation: pop .18s ease-out;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
}
.modal-card h3 { font-size: 16px; margin-bottom: 14px; }
.modal-card-lg { max-width: 500px; }
.modal-card-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 18px; gap: 12px; }
.modal-card-header h3 { margin-bottom: 2px; }
.modal-sub { margin: 0; font-size: 12.5px; color: var(--ink-faint); }
.modal-form { display: flex; flex-direction: column; gap: 15px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.form-message { margin: 0; font-size: 12.5px; }
.form-message:empty { display: none; }
.form-message.error { color: var(--danger); background: var(--danger-tint); padding: 9px 11px; border-radius: 8px; }
.form-message.success { color: var(--ok); }
.confirm-icon { width: 42px; height: 42px; border-radius: 12px; background: var(--danger-tint); color: var(--danger); display: flex; align-items: center; justify-content: center; margin-bottom: 14px; }
.confirm-icon svg { width: 21px; height: 21px; }
.confirm-icon.neutral { background: var(--accent-tint); color: var(--accent); }
.confirm-text { margin: -6px 0 16px; color: var(--ink-soft); font-size: 13.5px; }
#prompt-modal .field { margin-bottom: 8px; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(.98); } }

/* ============================================================
   TOASTS
   ============================================================ */
.toasts { position: fixed; right: 22px; bottom: 22px; z-index: 80; display: flex; flex-direction: column; gap: 8px; }
.toast {
    display: flex; align-items: center; gap: 10px;
    background: var(--surface);
    color: var(--ink);
    border: 1px solid var(--border-strong);
    padding: 11px 14px;
    border-radius: 10px;
    font-size: 13px;
    box-shadow: var(--shadow-lg);
    animation: pop .18s ease-out;
    max-width: 380px;
}
.toast svg { width: 16px; height: 16px; color: var(--ok); }
.toast.error svg { color: var(--danger); }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1100px) {
    .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 900px) {
    .login-screen { grid-template-columns: 1fr; }
    .login-panel { display: none; }
    .dash-grid { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
    .app-shell { flex-direction: column; }
    .sidebar { width: 100%; height: auto; position: static; flex-direction: row; align-items: center; padding: 10px 16px; gap: 12px; overflow-x: auto; }
    .brand { padding: 0; }
    .brand-text, .nav-label, .nav-count { display: none; }
    .nav { flex-direction: row; }
    .nav-item.active::before { display: none; }
    .sidebar-footer { border: none; padding: 0; }
    .session-meta, .session-avatar { display: none; }
    .topbar, .content { padding-left: 16px; padding-right: 16px; }
    .field-row, .choice-grid { grid-template-columns: 1fr; }
    .search { width: 100%; }
}
.btn.danger-text { color: var(--danger); }
.btn.danger-text:hover { background: var(--danger-tint); border-color: transparent; color: var(--danger); }
.checkin-grid .list-item { border-bottom: none; }
