﻿/* ════════════════════════════════════════════════════════════════
   MeuPosOp — Professional Design System
   ════════════════════════════════════════════════════════════════ */

/* ── Reset & Variables ───────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    /* Brand */
    --primary: #1D6B56;
    --primary-dark: #123F33;
    --primary-light: #214F42;
    --primary-50: #16362D;

    /* Surfaces */
    --bg: #071511;
    --surface: #0E221C;
    --surface-hover: #163129;

    /* Sidebar */
    --sidebar-bg: #081510;
    --sidebar-hover: #143128;
    --sidebar-active: #1D6B56;
    --sidebar-text: #A7C6BA;
    --sidebar-text-active: #FFFFFF;
    --sidebar-w: clamp(220px, 20vw, 280px);

    /* Text */
    --text: #E6F2EC;
    --text-secondary: #B8CEC4;
    --text-muted: #7D9A8F;

    /* Borders */
    --border: #214137;
    --border-strong: #346354;

    /* Status */
    --danger: #D16363;
    --danger-light: #341A1A;
    --danger-text: #F5C5C5;
    --warning: #C8922B;
    --warning-light: #31240E;
    --warning-text: #F4D796;
    --success: #2FA883;
    --success-light: #132C24;
    --success-text: #B9EBD8;
    --info: #42A58D;
    --info-light: #12332C;
    --info-text: #C1EDE2;

    /* WhatsApp */
    --wpp-bg: #0B1E18;
    --wpp-bg-pattern: url("data:image/svg+xml,%3Csvg width='200' height='200' xmlns='http://www.w3.org/2000/svg'%3E%3Cdefs%3E%3Cpattern id='p' width='40' height='40' patternUnits='userSpaceOnUse'%3E%3Ccircle cx='20' cy='20' r='1' fill='%231d473c' opacity='.45'/%3E%3C/pattern%3E%3C/defs%3E%3Crect width='200' height='200' fill='url(%23p)'/%3E%3C/svg%3E");
    --wpp-header: #0F5E4C;
    --wpp-header-light: #15765F;
    --wpp-outgoing: #1A4E3D;
    --wpp-incoming: #132A23;
    --wpp-input-bg: #10251F;

    /* Layout */
    --radius: 10px;
    --radius-lg: 14px;
    --radius-sm: 6px;
    --shadow-sm: 0 1px 2px rgba(8, 32, 24, .07);
    --shadow: 0 2px 8px rgba(8, 32, 24, .08);
    --shadow-md: 0 10px 24px rgba(8, 32, 24, .10);
    --shadow-lg: 0 20px 40px rgba(8, 32, 24, .12);
    --shadow-xl: 0 30px 60px rgba(8, 32, 24, .16);
    --transition: 150ms cubic-bezier(.4,0,.2,1);

    /* Typography */
    --font-size-xs: clamp(.82rem, .78rem + .12vw, .92rem);
    --font-size-sm: clamp(.92rem, .88rem + .18vw, 1rem);
    --font-size-body: clamp(1rem, .97rem + .22vw, 1.08rem);
    --font-size-lg: clamp(1.1rem, 1.02rem + .45vw, 1.3rem);
    --font-size-xl: clamp(1.45rem, 1.2rem + .95vw, 1.95rem);
    --font-size-2xl: clamp(1.9rem, 1.45rem + 1.6vw, 2.6rem);

    /* Spacing */
    --page-pad-y: clamp(1.25rem, 1rem + 1vw, 2rem);
    --page-pad-x: clamp(1rem, .8rem + 1.4vw, 2.5rem);
}

html {
    color-scheme: dark;
    font-size: clamp(15px, 14px + .25vw, 18px);
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background:
        radial-gradient(circle at top left, rgba(41, 140, 111, .18), transparent 26%),
        radial-gradient(circle at bottom right, rgba(10, 33, 26, .55), transparent 30%),
        linear-gradient(180deg, #081611 0%, var(--bg) 100%);
    color: var(--text);
    display: flex;
    min-height: 100vh;
    font-size: var(--font-size-body);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

button, input, select, textarea {
    font: inherit;
}

img, svg {
    max-width: 100%;
}

/* ── Sidebar ─────────────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-w);
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
    overflow-y: auto;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: .85rem;
    padding: 1.5rem 1.25rem 1.25rem;
    border-bottom: 1px solid rgba(255,255,255,.08);
}

.brand-icon {
    width: 42px; height: 42px;
    background: var(--primary);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    flex-shrink: 0;
}

.brand-text { display: flex; flex-direction: column; }
.brand-name {
    font-size: 1.35rem;
    font-weight: 800;
    color: #fff;
    letter-spacing: -.02em;
}
.brand-accent { color: #7FD4B2; }
.brand-sub { font-size: var(--font-size-xs); color: #93B8AA; margin-top: 1px; }

.sidebar-nav { padding: .75rem 0; flex: 1; }
.nav-item {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .7rem 1.25rem;
    margin: 2px .75rem;
    color: var(--sidebar-text);
    text-decoration: none;
    font-weight: 500;
    font-size: var(--font-size-sm);
    border-radius: var(--radius-sm);
    transition: all var(--transition);
}
.nav-item svg { flex-shrink: 0; opacity: .7; transition: opacity var(--transition); }
.nav-item:hover { background: var(--sidebar-hover); color: #F5FBF8; }
.nav-item:hover svg { opacity: 1; }
.nav-item.active {
    background: var(--sidebar-active);
    color: var(--sidebar-text-active);
    font-weight: 600;
}
.nav-item.active svg { opacity: 1; }
.nav-divider {
    height: 1px;
    background: rgba(255,255,255,.06);
    margin: .75rem 1.25rem;
}

.sidebar-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid rgba(255,255,255,.06);
}
.sidebar-footer-status {
    display: flex;
    align-items: center;
    gap: .5rem;
    font-size: var(--font-size-xs);
    color: var(--sidebar-text);
}
.status-dot {
    width: 8px; height: 8px;
    background: var(--success);
    border-radius: 50%;
    animation: pulse-dot 2s infinite;
}
@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: .4; }
}

/* ── Main Content ────────────────────────────────────────────── */
.main-content {
    margin-left: var(--sidebar-w);
    flex: 1;
    padding: var(--page-pad-y) var(--page-pad-x);
    min-height: 100vh;
    overflow-x: auto;
    animation: fadeIn .25s ease;
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ── Page Header ─────────────────────────────────────────────── */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: .85rem;
    margin-bottom: 1.75rem;
}
.page-header h2 {
    font-size: var(--font-size-xl);
    font-weight: 700;
    letter-spacing: -.02em;
    color: var(--text);
}

/* ── Cards ────────────────────────────────────────────────────── */
.card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    padding: 1.5rem;
    margin-bottom: 1.25rem;
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition);
    backdrop-filter: blur(10px);
}
.card:hover { box-shadow: var(--shadow); }
.card h3 { font-size: var(--font-size-lg); font-weight: 700; letter-spacing: -.01em; }

.card-header-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
    gap: 1rem;
}

/* ── Stats Grid ──────────────────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr));
    gap: 1rem;
    margin-bottom: 1.75rem;
}
.stat-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
    transition: all var(--transition);
    position: relative;
    overflow: hidden;
}
.stat-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: var(--primary);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-card .stat-value {
    font-size: var(--font-size-2xl);
    font-weight: 800;
    color: var(--primary);
    letter-spacing: -.03em;
    line-height: 1;
}
.stat-card .stat-label {
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
    font-weight: 500;
    margin-top: .4rem;
}
.stat-danger::before { background: var(--danger); }
.stat-danger .stat-value { color: var(--danger); }
.stat-warning::before { background: var(--warning); }
.stat-warning .stat-value { color: var(--warning); }
.stat-success::before { background: var(--success); }
.stat-success .stat-value { color: var(--success); }
.stat-default::before { background: var(--primary); }

/* ── Tables ──────────────────────────────────────────────────── */
.table-shell {
    width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
}

table {
    width: 100%;
    min-width: 720px;
    border-collapse: collapse;
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
th, td {
    text-align: left;
    padding: .85rem 1rem;
    border-bottom: 1px solid var(--border);
}
th {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: var(--font-size-xs);
    text-transform: uppercase;
    letter-spacing: .06em;
    background: color-mix(in srgb, var(--surface) 82%, #000 18%);
    position: sticky;
    top: 0;
}
tbody tr { transition: background var(--transition); }
tbody tr.clickable-row { cursor: pointer; }
tbody tr.clickable-row:hover { background: var(--primary-50) !important; }
tbody tr:last-child td { border-bottom: none; }
td { font-size: var(--font-size-sm); }

.row-danger { background: var(--danger-light) !important; }
.row-warning { background: var(--warning-light) !important; }
.clickable-row { cursor: pointer; }

/* ── Badges ──────────────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    padding: .2rem .65rem;
    border-radius: 999px;
    font-size: var(--font-size-xs);
    font-weight: 600;
    letter-spacing: .01em;
    white-space: nowrap;
}
.badge-success { background: var(--success-light); color: var(--success-text); }
.badge-warning { background: var(--warning-light); color: var(--warning-text); }
.badge-danger  { background: var(--danger-light);  color: var(--danger-text); }
.badge-info    { background: var(--info-light);     color: var(--info-text); }
.badge-muted   { background: #132720; color: var(--text-muted); }

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .45rem;
    padding: .55rem 1.15rem;
    border-radius: var(--radius-sm);
    border: none;
    font-weight: 600;
    font-size: var(--font-size-sm);
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
    font-family: inherit;
}
.btn:active { transform: scale(.97); }
.btn-primary {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 8px 18px rgba(20, 76, 61, .35);
}
.btn-primary:hover { background: var(--primary-dark); box-shadow: 0 12px 22px rgba(20, 76, 61, .42); }
.btn-secondary {
    background: var(--surface);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--surface-hover); border-color: var(--border-strong); }
.btn-danger {
    background: var(--danger);
    color: #fff;
    box-shadow: 0 1px 2px rgba(239,68,68,.3);
}
.btn-danger:hover { background: #DC2626; }
.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    padding: .4rem .6rem;
}
.btn-ghost:hover { background: var(--surface-hover); }
.btn-sm { padding: .4rem .85rem; font-size: var(--font-size-xs); }
.btn-xs { padding: .25rem .5rem; font-size: var(--font-size-xs); min-width: auto; border-radius: 4px; }
.btn-icon {
    width: 32px; height: 32px;
    padding: 0;
    border-radius: var(--radius-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.btn-icon.btn-sm { width: 28px; height: 28px; }

/* ── Forms ────────────────────────────────────────────────────── */
.form-group { margin-bottom: 1.15rem; }
.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: .4rem;
    font-size: .82rem;
    color: var(--text-secondary);
}
.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: .6rem .85rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: .9rem;
    font-family: inherit;
    color: var(--text);
    background: var(--surface);
    transition: all var(--transition);
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(47, 168, 131, .18);
}
.form-group input::placeholder,
.form-group textarea::placeholder { color: var(--text-muted); }
.form-group .form-hint {
    font-size: .75rem;
    color: var(--text-muted);
    margin-top: .3rem;
}

/* ── Modal ────────────────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(3, 10, 8, .72);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn .15s ease;
}
.modal {
    background: var(--surface);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 540px;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: var(--shadow-xl);
    animation: modalSlideIn .2s ease;
}
@keyframes modalSlideIn { from { opacity: 0; transform: translateY(-8px) scale(.98); } to { opacity: 1; transform: none; } }
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.15rem 1.5rem;
    border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 1.05rem; font-weight: 700; }
.modal-close {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    padding: 4px;
    transition: all var(--transition);
    display: flex;
}
.modal-close:hover { background: var(--surface-hover); color: var(--text); }
.modal-body { padding: 1.5rem; }

/* ── Toasts ──────────────────────────────────────────────────── */
.toast-container {
    position: fixed;
    top: 1.25rem;
    right: 1.25rem;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: .5rem;
    pointer-events: none;
}
.toast {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .75rem 1.15rem;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    border-left: 4px solid var(--primary);
    font-size: .85rem;
    font-weight: 500;
    pointer-events: auto;
    animation: toastIn .3s ease, toastOut .3s ease 2.7s forwards;
    min-width: 260px;
    max-width: 400px;
}
.toast-success { border-left-color: var(--success); }
.toast-error   { border-left-color: var(--danger); }
.toast-warning { border-left-color: var(--warning); }
@keyframes toastIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateX(20px); } }

/* ── Reports / Patient List + Detail ─────────────────────────── */
.simulator-layout {
    display: grid;
    grid-template-columns: 180px minmax(0, 1fr);
    gap: 0;
    height: min(85vh, calc(100vh - 5rem));
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-md);
    min-height: 0;
}

.sim-patient-list {
    border-right: 1px solid var(--border);
    overflow-y: auto;
    background: var(--surface);
    min-height: 0;
}
.sim-patient-list-header {
    padding: .75rem 1rem;
    background: var(--wpp-header);
    color: #fff;
    font-weight: 600;
    font-size: var(--font-size-xs);
    display: flex;
    align-items: center;
    gap: .5rem;
    position: sticky;
    top: 0;
    z-index: 1;
}
.sim-patient-item {
    padding: .55rem .85rem;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: all var(--transition);
}
.sim-patient-item:hover { background: var(--surface-hover); }
.sim-patient-item.active {
    background: var(--primary-50);
    border-left: 3px solid var(--primary);
}
.sim-patient-name { font-weight: 600; font-size: var(--font-size-xs); line-height: 1.3; }
.sim-patient-phone { font-size: .78rem; color: var(--text-muted); margin-top: 1px; }
.sim-patient-status { font-size: var(--font-size-xs); margin-top: 4px; }
.sim-patient-meta {
    display: none;
}
.sim-patient-meta-label {
    font-size: .78rem;
    color: var(--text-secondary);
    line-height: 1.3;
}
.sim-patient-badges {
    display: flex;
    gap: .25rem;
    flex-wrap: wrap;
    margin-top: .35rem;
}
.sim-patient-badges .badge {
    font-size: .7rem;
    padding: .15rem .45rem;
}

.sim-empty {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 1rem;
    text-align: center;
    padding: 2rem;
}
.sim-report-panel {
    background: linear-gradient(180deg, var(--surface) 0%, var(--bg) 100%);
    background: var(--surface);
    overflow-y: auto;
    min-height: 0;
    padding: 1.1rem;
}
.sim-detail-panel {
    background: linear-gradient(180deg, var(--surface) 0%, var(--bg) 100%);
    overflow-y: auto;
    min-height: 0;
    padding: 1.25rem 1.5rem;
}
.sim-report-empty {
    min-height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    text-align: center;
    font-size: var(--font-size-sm);
}
.sim-report-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: .75rem;
    margin-bottom: 1rem;
}
.sim-report-header h3 {
    font-size: var(--font-size-lg);
    font-weight: 700;
}
.sim-report-badges {
    display: flex;
    gap: .35rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}
.sim-report-section {
    padding: .9rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: color-mix(in srgb, var(--surface) 82%, #000 18%);
    margin-bottom: .8rem;
}
.sim-report-section strong {
    display: block;
    font-size: var(--font-size-xs);
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--text-secondary);
    margin-bottom: .35rem;
}
.sim-report-section p {
    font-size: var(--font-size-sm);
    margin-bottom: .75rem;
}
.sim-report-section p:last-child { margin-bottom: 0; }
.sim-report-list,
.sim-score-breakdown {
    display: flex;
    flex-direction: column;
    gap: .6rem;
}
.sim-report-item,
.sim-score-row {
    padding: .7rem .75rem;
    border-radius: var(--radius-sm);
    background: var(--surface);
    border: 1px solid var(--border);
}
.sim-score-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: .75rem;
}
.sim-score-copy { min-width: 0; }
.sim-report-question {
    font-size: var(--font-size-sm);
    font-weight: 700;
    color: var(--text);
    margin-bottom: .2rem;
}
.sim-report-answer {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    line-height: 1.4;
}

.sim-chat-area {
    display: flex;
    flex-direction: column;
    background: var(--wpp-bg);
    background-image: var(--wpp-bg-pattern);
    min-height: 0;
}
.sim-chat-header {
    padding: .85rem 1.15rem;
    background: var(--wpp-header);
    color: #fff;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: .85rem;
    font-size: .9rem;
}
.sim-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--wpp-header-light);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .85rem;
    color: #fff;
    flex-shrink: 0;
}
.sim-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: .4rem;
}
.sim-msg {
    max-width: 65%;
    padding: .55rem .85rem;
    border-radius: var(--radius);
    font-size: .88rem;
    line-height: 1.45;
    position: relative;
    word-wrap: break-word;
}
.sim-msg-bot {
    align-self: flex-start;
    background: var(--wpp-incoming);
    border-top-left-radius: 2px;
    box-shadow: 0 1px 1px rgba(0, 0, 0, .06);
    color: var(--text);
}
.sim-msg-patient {
    align-self: flex-end;
    background: var(--wpp-outgoing);
    border-top-right-radius: 2px;
    box-shadow: 0 1px 1px rgba(0, 0, 0, .06);
    color: #EAF7F1;
}
.sim-msg-time {
    font-size: .62rem;
    color: var(--text-muted);
    text-align: right;
    margin-top: .2rem;
}
.sim-msg-system {
    align-self: center;
    background: rgba(225, 218, 210, .85);
    font-size: .78rem;
    color: var(--text-secondary);
    padding: .3rem .85rem;
    border-radius: 999px;
    box-shadow: 0 1px 1px rgba(0, 0, 0, .04);
}
.sim-choices {
    display: flex;
    flex-wrap: wrap;
    gap: .35rem;
    margin-top: .5rem;
}
.sim-choice-btn {
    padding: .35rem .85rem;
    border: 1.5px solid var(--wpp-header);
    border-radius: 999px;
    background: #10251F;
    color: var(--wpp-header);
    font-size: .8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    font-family: inherit;
}
.sim-choice-btn:hover {
    background: var(--wpp-header);
    color: #fff;
}
.sim-input-area {
    display: flex;
    gap: .5rem;
    padding: .65rem 1rem;
    background: var(--wpp-input-bg);
    border-top: 1px solid rgba(0, 0, 0, .06);
}
.sim-input-area input {
    flex: 1;
    padding: .6rem 1.1rem;
    border: none;
    border-radius: 999px;
    font-size: .88rem;
    font-family: inherit;
    background: #0D1E19;
    color: var(--text);
    box-shadow: var(--shadow-sm);
}
.sim-input-area input:focus {
    outline: none;
    box-shadow: var(--shadow);
}
.sim-send-btn {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: none;
    background: var(--wpp-header);
    color: #fff;
    font-size: 1.1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    flex-shrink: 0;
}
.sim-send-btn:hover {
    background: var(--wpp-header-light);
    transform: scale(1.05);
}

/* ── Protocol Flow (legacy) ───────────────────────────────────── */
.protocol-flow {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: 1.25rem;
    gap: 0;
}
.flow-card {
    width: 100%;
    max-width: 520px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    overflow: hidden;
    transition: all var(--transition);
    box-shadow: var(--shadow-sm);
}
.flow-card:hover { box-shadow: var(--shadow); border-color: var(--border-strong); }
.flow-card-initial { border-color: var(--primary); border-width: 2px; }
.flow-card-initial::before {
    content: '';
    position: absolute; top: 0; left: 0; right: 0;
    height: 3px; background: var(--primary);
}
.flow-card-header {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .6rem .9rem;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    font-size: .8rem;
}
.flow-seq-number {
    font-weight: 700;
    color: var(--primary);
    font-size: .82rem;
}
.flow-card-actions {
    margin-left: auto;
    display: flex;
    gap: .2rem;
    align-items: center;
}
.flow-card-body {
    padding: .85rem 1rem;
    font-size: .9rem;
    line-height: 1.45;
}
.flow-card-choices {
    display: flex;
    flex-wrap: wrap;
    gap: .3rem;
    padding: 0 1rem .65rem;
}
.flow-choice {
    display: inline-block;
    padding: .18rem .55rem;
    border-radius: 999px;
    border: 1px solid var(--primary);
    color: var(--primary);
    font-size: .72rem;
    font-weight: 600;
}
.flow-card-footer {
    padding: .5rem 1rem;
    background: var(--bg);
    border-top: 1px solid var(--border);
    font-size: .78rem;
}
.flow-arrow {
    color: var(--text-muted);
    font-weight: 500;
}
.flow-branch {
    display: flex;
    flex-wrap: wrap;
    gap: .4rem;
    align-items: center;
}
.flow-branch-label {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: .75rem;
}
.flow-branch-item {
    display: inline-flex;
    align-items: center;
    padding: .15rem .5rem;
    border-radius: 4px;
    background: var(--info-light);
    color: var(--info-text);
    font-size: .72rem;
    font-weight: 600;
}
.flow-connector {
    color: var(--border-strong);
    font-size: 1.1rem;
    padding: .1rem 0;
    text-align: center;
}

/* ── Horizontal Protocol Tree ────────────────────────────────── */
.tree-container {
    margin-top: 1rem;
    overflow-x: auto;
    overflow-y: visible;
    padding-bottom: 1rem;
    -webkit-overflow-scrolling: touch;
}
.tree-area {
    position: relative;
    display: inline-flex;
    flex-direction: column;
    gap: 1.5rem;
    min-width: 100%;
    padding: 1rem .5rem;
}
.tree-svg {
    position: absolute;
    top: 0; left: 0;
    pointer-events: none;
    z-index: 0;
}
.tree-line {
    fill: none;
    stroke: var(--border-strong);
    stroke-width: 2;
    stroke-dasharray: none;
}
.tree-node {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 1.25rem;
    position: relative;
    z-index: 1;
}
.tree-card {
    min-width: 160px;
    width: clamp(160px, 16vw, 220px);
    max-width: 220px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    transition: all var(--transition);
    flex-shrink: 0;
    overflow: hidden;
}
.tree-card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--border-strong);
}
.tree-card-root {
    border-color: var(--primary);
    border-width: 2px;
    box-shadow: var(--shadow);
}
.tree-card-ref {
    min-width: auto;
    max-width: none;
    padding: .4rem .7rem;
    background: var(--primary-light);
    border-color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
}
.tree-ref-badge {
    font-weight: 700;
    font-size: .78rem;
    color: var(--primary-dark);
}
.tree-card-head {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: .3rem;
    padding: .35rem .55rem;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    font-size: .72rem;
}
.tree-seq {
    font-weight: 800;
    color: var(--primary);
    font-size: .8rem;
}
.tree-card-actions {
    margin-left: auto;
    display: flex;
    flex-wrap: wrap;
    gap: .15rem;
    align-items: center;
}
.tree-card-text {
    padding: .45rem .55rem;
    font-size: .8rem;
    line-height: 1.4;
    color: var(--text);
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
}
.tree-card-chips {
    display: flex;
    flex-wrap: wrap;
    gap: .2rem;
    padding: 0 .55rem .35rem;
}
.tree-children {
    display: flex;
    flex-direction: column;
    gap: .75rem;
    justify-content: center;
}
.tree-branch {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: .75rem;
    min-width: 0;
}
.tree-branch-label {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: .3rem;
    min-width: 60px;
    padding-top: .55rem;
    flex-shrink: 0;
}
.tree-branch-tag {
    display: inline-block;
    padding: .15rem .5rem;
    border-radius: 4px;
    background: var(--info-light);
    color: var(--info-text);
    font-size: .7rem;
    font-weight: 700;
    text-transform: capitalize;
}
.tree-branch-tag-empty {
    background: var(--surface-hover);
    color: var(--text-muted);
    border: 1px dashed var(--border-strong);
}
.tree-branch-tag-next {
    background: var(--success-light);
    color: var(--success-text);
}
.tree-detach-btn {
    font-size: .75rem;
    padding: 0 .3rem;
    color: var(--danger) !important;
    opacity: 0;
    transition: opacity var(--transition);
}
.tree-branch:hover .tree-detach-btn {
    opacity: 1;
}
.tree-add-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px dashed var(--primary);
    background: var(--primary-50);
    color: var(--primary);
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    flex-shrink: 0;
    margin-top: .3rem;
}
.tree-add-btn:hover {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
    box-shadow: var(--shadow);
}

/* Orphan zone */
.tree-orphan-zone {
    margin-top: 1.5rem;
    padding: 1rem;
    background: var(--warning-light);
    border: 1px dashed var(--warning);
    border-radius: var(--radius);
}
.tree-orphan-title {
    font-weight: 700;
    font-size: .85rem;
    color: var(--warning-text);
    margin-bottom: .75rem;
}
.tree-orphan-zone .tree-node {
    margin-bottom: .5rem;
}

/* Attach picker modal */
.attach-list {
    display: flex;
    flex-direction: column;
    gap: .35rem;
    max-height: 300px;
    overflow-y: auto;
    margin-top: .75rem;
}
.attach-item {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .55rem .75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
    font-size: .85rem;
}
.attach-item:hover {
    background: var(--primary-light);
    border-color: var(--primary);
}

/* ── Protocol Info ───────────────────────────────────────────── */
.protocol-info {
    display: flex;
    gap: .65rem;
    align-items: center;
    margin-bottom: .85rem;
}

/* ── Protocol Editor Simplified ─────────────────────────────── */
.protocol-card-shell {
    overflow-x: auto;
    overflow-y: visible;
}
.protocol-shell-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1rem;
}
.protocol-shell-copy {
    min-width: 0;
}
.protocol-meta-row {
    display: flex;
    flex-wrap: wrap;
    gap: .45rem;
    margin-top: .7rem;
}
.protocol-empty-board {
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius);
    background: linear-gradient(180deg, var(--surface) 0%, color-mix(in srgb, var(--bg) 76%, #000 24%) 100%);
    padding: 2rem 1.5rem;
    text-align: center;
}
.protocol-empty-icon {
    width: 54px;
    height: 54px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: .85rem;
    background: var(--primary-50);
    color: var(--primary);
    font-size: 1.4rem;
    font-weight: 700;
}
.tree-container-simple {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: linear-gradient(180deg, var(--surface) 0%, color-mix(in srgb, var(--bg) 76%, #000 24%) 100%);
    padding: 1rem;
}
.tree-area-simple {
    min-width: max-content;
    padding: .75rem;
    gap: 1.25rem;
}
.tree-line-soft {
    stroke: color-mix(in srgb, var(--primary) 18%, var(--border-strong));
    stroke-width: 2;
}
.tree-card-mid {
    border-left: 4px solid var(--info);
}
.tree-card-end {
    border-left: 4px solid var(--danger);
}
.tree-card-root {
    border-left: 4px solid var(--success);
}
.tree-card-actions-soft {
    opacity: 0;
    transition: opacity var(--transition);
}
.tree-card:hover .tree-card-actions-soft {
    opacity: 1;
}
.tree-card-text-editable {
    cursor: text;
    min-height: 36px;
}
.tree-card-text-editable:hover {
    background: color-mix(in srgb, var(--primary-50) 45%, transparent);
}
.tree-score-hint {
    padding: 0 .75rem .4rem;
    font-size: .74rem;
    color: var(--info-text);
    font-weight: 600;
}
.tree-card-chips-simple {
    border-top: 1px solid var(--border);
    padding-top: .55rem;
}
.tree-children-simple {
    gap: .6rem;
}
.tree-branch-simple {
    align-items: flex-start;
}
.tree-branch-label-wide {
    min-width: 88px;
}
.tree-branch-actions {
    display: flex;
    gap: .4rem;
    align-items: center;
    padding-top: .2rem;
}
.tree-composer-box {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) 130px minmax(160px, 220px) auto auto;
    gap: .45rem;
    align-items: center;
    padding: .65rem;
    border: 1px solid var(--border);
    background: var(--surface);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm);
}
.tree-inline-input,
.tree-composer-select {
    width: 100%;
    min-width: 0;
    padding: .55rem .7rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font-size: .84rem;
    font-family: inherit;
}
.tree-inline-input:focus,
.tree-composer-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,.10);
}
.protocol-status-bar {
    display: flex;
    flex-wrap: wrap;
    gap: .85rem;
    align-items: center;
    padding-top: .95rem;
    margin-top: .95rem;
    border-top: 1px solid var(--border);
    font-size: .8rem;
    color: var(--text-secondary);
}
.protocol-status-ok {
    color: var(--success-text);
    font-weight: 700;
}
.protocol-status-warning {
    color: var(--warning-text);
    font-weight: 700;
}
.score-grid {
    display: grid;
    gap: .45rem;
    margin-top: .55rem;
}
.score-row {
    display: grid;
    grid-template-columns: minmax(120px, 1fr) 90px;
    gap: .65rem;
    align-items: center;
    padding: .45rem .6rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg);
}
.score-label {
    color: var(--text-secondary);
    font-size: .82rem;
    font-weight: 600;
}
.score-input {
    width: 100%;
    padding: .45rem .55rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font-family: inherit;
}
.sim-header-meta {
    display: flex;
    gap: .4rem;
    flex-wrap: wrap;
    margin-top: .35rem;
}
.template-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: .75rem;
}
.template-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    padding: 1rem;
    text-align: left;
    cursor: pointer;
    transition: all var(--transition);
    font-family: inherit;
}
.template-card:hover {
    border-color: var(--primary);
    background: var(--primary-50);
    box-shadow: var(--shadow);
}
.template-card strong {
    display: block;
    font-size: var(--font-size-body);
    margin-bottom: .35rem;
    color: var(--text);
}
.template-card span {
    display: block;
    font-size: var(--font-size-sm);
    line-height: 1.45;
    color: var(--text-secondary);
}
.template-card small {
    display: inline-block;
    margin-top: .65rem;
    color: var(--primary-dark);
    font-weight: 700;
}

/* ── Branching Form Rows ─────────────────────────────────────── */
.branching-row {
    display: flex;
    align-items: center;
    gap: .5rem;
    margin-bottom: .35rem;
    padding: .4rem .6rem;
    background: var(--bg);
    border-radius: var(--radius-sm);
    font-size: var(--font-size-sm);
}
.branching-option {
    font-weight: 600;
    min-width: 80px;
    color: var(--text-secondary);
}
.branching-target select,
.branching-row select {
    padding: .3rem .5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: var(--font-size-xs);
    background: var(--surface);
    font-family: inherit;
}

/* ── Link Rows (modal) ───────────────────────────────────────── */
.link-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: .7rem 0;
    border-bottom: 1px solid var(--border);
    font-size: var(--font-size-sm);
}
.link-row:last-child { border-bottom: none; }

/* ── Chips ────────────────────────────────────────────────────── */
.chip-list { display: flex; flex-wrap: wrap; gap: .3rem; }
.chip {
    display: inline-block;
    padding: .15rem .55rem;
    border-radius: 999px;
    background: var(--primary-light);
    color: var(--primary-dark);
    font-size: var(--font-size-xs);
    font-weight: 600;
}

/* ── Action Buttons ──────────────────────────────────────────── */
.action-buttons {
    display: flex;
    gap: .35rem;
    flex-wrap: wrap;
    align-items: center;
    min-width: 0;
}

/* ── Empty States ────────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 3.5rem 2rem;
    color: var(--text-muted);
}
.empty-state .empty-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: .5;
}
.empty-state p { font-size: .95rem; }

/* ── Utilities ───────────────────────────────────────────────── */
.text-muted { color: var(--text-muted); }
.text-center { text-align: center; }
.mt-half { margin-top: .25rem; }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: .5rem; }

.spinner {
    display: inline-block;
    width: 22px; height: 22px;
    border: 2.5px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Scrollbar ───────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border-radius: 999px;
}
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 1200px) {
    .simulator-layout { grid-template-columns: 180px minmax(0, 1fr); }
    table { min-width: 640px; }
}

@media (max-width: 900px) {
    body {
        flex-direction: column;
    }
    .sidebar {
        width: 100%;
        position: sticky;
        top: 0;
        left: auto;
        bottom: auto;
        height: auto;
        max-height: none;
        overflow: visible;
        border-bottom: 1px solid var(--border);
        box-shadow: 0 12px 24px rgba(0, 0, 0, .22);
    }
    .sidebar-brand {
        justify-content: flex-start;
        padding: .95rem 1rem .75rem;
    }
    .sidebar .brand-text,
    .sidebar .nav-item span,
    .sidebar .sidebar-footer span,
    .sidebar .nav-divider {
        display: initial;
    }
    .sidebar-nav {
        display: flex;
        flex-wrap: wrap;
        gap: .45rem;
        padding: .75rem 1rem 1rem;
    }
    .nav-item {
        justify-content: flex-start;
        margin: 0;
        padding: .75rem .95rem;
        flex: 1 1 170px;
        min-height: 44px;
    }
    .sidebar-footer {
        display: none;
    }
    .main-content {
        margin-left: 0;
        padding: 1.1rem;
    }
    .simulator-layout { grid-template-columns: 1fr; height: auto; }
    .sim-patient-list { max-height: 180px; }
    .sim-detail-panel { border-top: 1px solid var(--border); padding: 1rem; }
    .auth-shell { grid-template-columns: 1fr; max-width: 560px; }
    .auth-hero { min-height: auto; }
    .protocol-shell-header { flex-direction: column; }
    .tree-node { flex-direction: column; gap: 1rem; }
    .tree-branch { flex-direction: column; gap: .45rem; }
    .tree-branch-label-wide { min-width: 0; padding-top: 0; }
    .tree-composer-box { grid-template-columns: 1fr; }
    .tree-area-simple { min-width: 100%; }
    .card-header-row,
    .protocol-shell-header,
    .page-header,
    .link-row {
        flex-direction: column;
        align-items: stretch;
    }
    .action-buttons {
        width: 100%;
    }
    .action-buttons .btn,
    .page-header > .btn,
    .page-header .btn {
        flex: 1 1 180px;
        min-width: 0;
    }
    .modal {
        width: min(94vw, 640px);
    }
}

@media (max-width: 640px) {
    html { font-size: 16px; }
    .main-content { padding: 1rem .85rem 1.25rem; }
    .card { padding: 1rem; }
    .stats-grid { grid-template-columns: 1fr; }
    .page-header h2 { width: 100%; }
    .sidebar-brand {
        padding-inline: .85rem;
    }
    .sidebar-nav {
        padding-inline: .85rem;
    }
    .nav-item {
        flex: 1 1 100%;
    }
    .sim-patient-item,
    .sim-patient-list-header,
    .sim-detail-panel,
    .sim-report-panel { padding-left: .9rem; padding-right: .9rem; }
    .sim-msg { max-width: 82%; }
    .sim-input-area {
        flex-wrap: wrap;
    }
    .sim-input-area input,
    .sim-send-btn {
        width: 100%;
    }
    .sim-send-btn {
        border-radius: 14px;
        height: 44px;
    }
    .modal-header,
    .modal-body {
        padding-inline: 1rem;
    }
    .action-buttons .btn,
    .btn-block,
    .link-row .btn {
        width: 100%;
    }
    table {
        min-width: 560px;
    }
    .table-shell {
        margin-inline: -.1rem;
    }
    .auth-shell { padding: .5rem; }
    .auth-wrapper { padding: 0; }
    .auth-card { padding: 1.5rem 1.1rem 1.2rem; }
    .auth-hero { padding: 1.15rem; border-radius: 22px; }
    .auth-hero-title { max-width: none; }
}

@media (max-width: 480px) {
    .main-content {
        padding: .85rem .7rem 1rem;
    }
    .card,
    .sim-detail-panel,
    .sim-report-panel,
    .modal {
        border-radius: 12px;
    }
    .stats-grid {
        gap: .75rem;
    }
    .stat-card,
    .sim-report-section,
    .sim-report-item,
    .sim-score-row {
        padding: .8rem;
    }
    .sim-chat-header {
        padding: .75rem .85rem;
    }
    .sim-messages {
        padding: .85rem;
    }
    .toast-container {
        left: .75rem;
        right: .75rem;
        top: .75rem;
    }
    .toast {
        min-width: 0;
        max-width: none;
        width: 100%;
    }
}

/* ── Auth Pages ──────────────────────────────────────────────── */
.main-content-full {
    flex: 1;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(circle at top left, rgba(40, 114, 91, .18), transparent 30%),
        radial-gradient(circle at bottom right, rgba(12, 33, 27, .22), transparent 32%),
        linear-gradient(135deg, #0B1E18 0%, #123328 52%, #194739 100%);
}
.auth-shell {
    width: min(1120px, 100%);
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(360px, 460px);
    gap: clamp(1.25rem, 2vw, 2.4rem);
    align-items: stretch;
    padding: clamp(1rem, 1vw, 1.5rem);
}
.auth-hero {
    position: relative;
    padding: clamp(1.4rem, 2vw, 2.4rem);
    border-radius: 28px;
    color: #F2FAF6;
    background:
        linear-gradient(160deg, rgba(255,255,255,.06), transparent 46%),
        linear-gradient(135deg, rgba(26, 88, 69, .95) 0%, rgba(15, 47, 38, .98) 100%);
    border: 1px solid rgba(255,255,255,.08);
    box-shadow: 0 30px 60px rgba(2, 12, 9, .35);
    overflow: hidden;
}
.auth-hero::after {
    content: '';
    position: absolute;
    inset: auto -10% -25% auto;
    width: 260px;
    height: 260px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(126, 205, 174, .22), transparent 70%);
}
.auth-hero-badge {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    padding: .4rem .75rem;
    border-radius: 999px;
    background: rgba(255,255,255,.09);
    border: 1px solid rgba(255,255,255,.08);
    font-size: var(--font-size-xs);
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
}
.auth-hero-title {
    font-size: clamp(2rem, 1.6rem + 1.2vw, 3rem);
    line-height: 1.05;
    letter-spacing: -.04em;
    margin-top: 1.1rem;
    max-width: 12ch;
}
.auth-hero-subtitle {
    margin-top: 1rem;
    max-width: 58ch;
    color: rgba(242, 250, 246, .82);
    font-size: var(--font-size-body);
}
.auth-hero-points {
    display: grid;
    gap: .75rem;
    margin-top: 1.5rem;
}
.auth-hero-point {
    display: flex;
    gap: .7rem;
    align-items: flex-start;
    padding: .85rem 1rem;
    border-radius: 18px;
    background: rgba(255,255,255,.06);
    border: 1px solid rgba(255,255,255,.08);
}
.auth-hero-dot {
    width: 10px;
    height: 10px;
    margin-top: .38rem;
    border-radius: 50%;
    background: #8DE0BE;
    box-shadow: 0 0 0 6px rgba(141, 224, 190, .12);
    flex-shrink: 0;
}
.auth-wrapper {
    width: 100%;
    max-width: 480px;
    padding: clamp(1rem, .8rem + 1vw, 1.5rem);
    display: flex;
    align-items: center;
}
.auth-card {
    background: var(--surface);
    border-radius: 26px;
    border: 1px solid rgba(255,255,255,.22);
    padding: 2rem 2rem 1.5rem;
    box-shadow: 0 28px 60px rgba(3, 16, 12, .22);
    backdrop-filter: blur(10px);
    width: 100%;
}
.auth-brand {
    text-align: center;
    margin-bottom: 1.5rem;
}
.auth-title-sm {
    font-size: clamp(1.45rem, 1.2rem + .5vw, 1.8rem);
}
.auth-title {
    font-size: var(--font-size-xl);
    font-weight: 800;
    letter-spacing: -.03em;
    margin-top: .75rem;
}
.auth-subtitle {
    color: var(--text-muted);
    font-size: var(--font-size-sm);
    margin-top: .35rem;
    line-height: 1.5;
}
.auth-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 1.25rem;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid var(--border);
    background: #F5FAF7;
}
.auth-tab {
    flex: 1;
    padding: .8rem;
    border: none;
    background: var(--bg);
    font-weight: 600;
    font-size: var(--font-size-sm);
    cursor: pointer;
    color: var(--text-secondary);
    transition: all var(--transition);
    font-family: inherit;
}
.auth-tab.active {
    background: var(--primary);
    color: #fff;
    box-shadow: inset 0 -2px 0 rgba(255,255,255,.14);
}
.auth-tab:not(.active):hover {
    background: #EAF4F0;
}
.btn-block {
    width: 100%;
    margin-top: .9rem;
    min-height: 46px;
}
.auth-form-note {
    margin-top: .8rem;
    color: var(--text-muted);
    font-size: var(--font-size-xs);
    text-align: center;
}
.auth-error {
    background: var(--danger-light);
    color: var(--danger-text);
    padding: .55rem .85rem;
    border-radius: var(--radius-sm);
    font-size: var(--font-size-sm);
    font-weight: 500;
    margin-bottom: .5rem;
}
.auth-link-text {
    text-align: center;
    font-size: var(--font-size-sm);
    color: var(--text-muted);
    margin-top: 1rem;
}
.auth-link {
    color: var(--primary);
    font-weight: 600;
    text-decoration: none;
}
.auth-link:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

/* ── Form Validation States ──────────────────────────────────── */
.form-group input.input-error,
.form-group select.input-error,
.form-group textarea.input-error {
    border-color: var(--danger);
}
.form-group input.input-error:focus,
.form-group select.input-error:focus,
.form-group textarea.input-error:focus {
    box-shadow: 0 0 0 3px rgba(239,68,68,.15);
}
.field-error {
    font-size: .74rem;
    color: var(--danger);
    margin-top: .3rem;
    display: flex;
    align-items: center;
    gap: .25rem;
}
.field-error::before {
    content: '⚠';
    font-size: .72rem;
}
.form-group input.input-valid,
.form-group select.input-valid {
    border-color: var(--success);
}

/* ── Button Loading State ────────────────────────────────────── */
.btn-loading {
    position: relative;
    pointer-events: none;
    opacity: .75;
    cursor: not-allowed;
}
.btn-loading .btn-inner-text { visibility: hidden; }
.btn-loading::after {
    content: '';
    position: absolute;
    width: 14px; height: 14px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin .65s linear infinite;
}

/* ── Skeleton Loader ─────────────────────────────────────────── */
.skeleton {
    background: linear-gradient(90deg, var(--surface-hover) 25%, var(--border) 50%, var(--surface-hover) 75%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.4s infinite;
    border-radius: var(--radius-sm);
}
@keyframes skeleton-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}
.skeleton-row {
    height: 48px;
    margin-bottom: 1px;
}
.skeleton-card {
    height: 80px;
    border-radius: var(--radius-lg);
    margin-bottom: 1rem;
}
