/* CBRO Clinical Dashboard */

:root {
    /* Color tokens — 5 grays only */
    --ink:       #1a1a1a;
    --ink-2:     #555;
    --ink-3:     #888;
    --border:    #ddd;
    --bg:        #f5f5f5;

    --surface:   #ffffff;
    --sidebar:   #0f1729;
    --sidebar-2: #151e35;
    --border-lt: #eee;

    --brand:     #0f1729;
    --accent:    #0d9488;
    --accent-dk: #0f766e;
    --accent-lt: #f0fdfa;

    --success:   #059669;
    --success-bg:#e6f5ec;
    --success-bd:#a7f3d0;

    --warning:   #d97706;
    --warning-bg: transparent;
    --warning-bd:#d97706;

    --danger:    #dc2626;
    --danger-bg: transparent;
    --danger-bd: #dc2626;

    --purple:    #7c3aed;
    --purple-bg: #f5f3ff;
    --purple-bd: #ddd6fe;

    /* Radii — strict scale */
    --radius:    6px;
    --radius-sm: 4px;
    --radius-lg: 6px;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0,0,0,.04);
    --shadow:    0 1px 3px rgba(0,0,0,.05);

    /* Timing */
    --ease:      .15s ease;

    /* Letter-spacing — single token for caps */
    --ls-caps:   0.06em;
}


/* RESET & BASE */

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--ink);
    margin: 0;
    font-size: 13px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.mono { font-family: 'JetBrains Mono', monospace; }
.display-font { font-family: 'Fraunces', serif; font-optical-sizing: auto; }


/* SCROLLBAR */

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--ink-3); }


/* FOCUS */

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.login-field:focus-visible, .pront-input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.btn:focus-visible, .sidebar-link:focus-visible, .cal-nav-btn:focus-visible, .cal-day:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }


/* LOGIN */

#tela-login {
    position: fixed; inset: 0;
    background: radial-gradient(ellipse at 30% 20%, #1a2540 0%, #0f1729 55%, #080e1c 100%);
    display: flex; justify-content: center; align-items: center;
    z-index: 99999; padding: 20px;
}

.login-card {
    background: #151e35;
    border-radius: var(--radius);
    box-shadow: 0 20px 40px -12px rgba(0,0,0,.45);
    padding: 40px 36px;
    width: 100%; max-width: 380px;
    position: relative; overflow: hidden;
    border: 1px solid rgba(255,255,255,.05);
    animation: loginFadeIn 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}
.login-card::before {
    content: ''; position: absolute; top: -60px; right: -60px;
    width: 140px; height: 140px; border-radius: 50%;
    border: 1px solid var(--accent); opacity: .08;
}
.login-card::after {
    content: ''; position: absolute; top: -30px; right: -30px;
    width: 90px; height: 90px; border-radius: 50%;
    border: 1px solid var(--accent); opacity: .12;
}

.login-eyebrow {
    font-size: 10px; font-weight: 700; letter-spacing: var(--ls-caps);
    color: var(--accent); text-transform: uppercase; margin-bottom: 8px;
}
.login-title {
    font-family: "Fraunces", serif; font-size: 28px; font-weight: 700;
    color: #ffffff; margin-bottom: 4px; letter-spacing: -.02em;
}
.login-sub { font-size: 12px; color: var(--ink-3); margin-bottom: 28px; }
.login-error { color: #fca5a5; font-size: 12px; font-weight: 600; margin-bottom: 10px; display: none; }

.login-field {
    width: 100%; padding: 10px 12px;
    border: 1px solid #1e2a45; border-radius: var(--radius-sm);
    font-size: 13px; outline: none;
    transition: border-color var(--ease);
    margin-bottom: 12px; font-family: "Inter", sans-serif;
    background: #0c1220; color: #e8eaf0;
}
.login-field::placeholder { color: #4a5568; }
.login-field:focus { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(13,148,136,.12); }

.login-btn {
    width: 100%; padding: 11px;
    background: var(--accent); color: white; border: none;
    border-radius: var(--radius-sm);
    font-size: 12px; font-weight: 700; cursor: pointer;
    transition: background var(--ease);
    letter-spacing: var(--ls-caps); text-transform: uppercase;
}
.login-btn:hover { background: var(--accent-dk); }

.login-card img { }


/* LAYOUT SHELL */

#app-principal { display: none; animation: fadeIn 0.4s ease-out; }


/* SIDEBAR */

#sidebar {
    background: var(--sidebar);
    width: 210px;
    min-height: 100vh;
    position: fixed; top: 0; left: 0; bottom: 0;
    display: flex; flex-direction: column;
    z-index: 50;
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.sidebar-logo {
    padding: 14px 14px 12px;
    border-bottom: 1px solid rgba(255,255,255,.06);
}
.sidebar-logo-badge { display: inline-flex; align-items: center; gap: 9px; }
.logo-eye {
    width: 32px; height: 32px; border-radius: 50%;
    background: transparent; display: flex;
    align-items: center; justify-content: center; flex-shrink: 0;
}
.logo-text-main {
    font-family: 'Fraunces', serif; font-size: 14px; font-weight: 700;
    color: white; letter-spacing: .01em;
}
.logo-text-sub {
    font-size: 9px; color: var(--ink-2);
    letter-spacing: var(--ls-caps); text-transform: uppercase;
}

.sidebar-actions { display: flex; gap: 4px; margin-top: 10px; }
.sidebar-action-btn {
    flex: 1; padding: 5px 0; font-size: 10px; font-weight: 600;
    border: 1px solid rgba(255,255,255,.07); border-radius: var(--radius-sm);
    background: rgba(255,255,255,.03); color: var(--ink-3);
    cursor: pointer; transition: all var(--ease); text-align: center;
}
.sidebar-action-btn:hover { background: rgba(255,255,255,.07); color: white; }
.sidebar-action-btn.danger:hover { background: rgba(239,68,68,.12); color: #fca5a5; border-color: rgba(239,68,68,.25); }

.sidebar-section-label {
    padding: 14px 14px 5px; font-size: 9px; font-weight: 700;
    letter-spacing: var(--ls-caps); text-transform: uppercase; color: var(--ink-2);
}
.sidebar-section-separator { height: 1px; background: rgba(255,255,255,.04); margin: 4px 10px; }

.sidebar-link {
    display: flex; align-items: center; gap: 8px;
    padding: 7px 12px; margin: 1px 6px;
    border-radius: var(--radius-sm);
    font-size: 12px; font-weight: 500; color: var(--ink-3);
    text-decoration: none; cursor: pointer;
    transition: all 0.2s ease;
    border-left: 2px solid transparent;
}
.sidebar-link:hover { background: rgba(255,255,255,.04); color: #e2e8f0; padding-left: 14px; }
.sidebar-link.active {
    background: rgba(13,148,136,.08);
    color: #5eead4;
    border-left-color: var(--accent);
}
.sidebar-link .icon { width: 15px; height: 15px; opacity: .5; flex-shrink: 0; }
.sidebar-link.active .icon { opacity: 1; }
.sidebar-link.highlight {
    color: var(--accent); border-left-color: rgba(13,148,136,.3);
    background: rgba(13,148,136,.05); margin-top: 4px;
}
.sidebar-link.highlight:hover { background: rgba(13,148,136,.1); color: #5eead4; }
.sidebar-badge-count {
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--accent); color: white;
    font-size: 9px; font-weight: 700;
    border-radius: 999px; padding: 0 6px; min-width: 16px; margin-left: auto;
}

.sidebar-spacer { flex: 1; }

.sidebar-footer { padding: 10px 14px; border-top: 1px solid rgba(255,255,255,.06); }
.sidebar-status { display: flex; align-items: center; gap: 6px; font-size: 10px; color: var(--ink-2); }
.status-dot {
    display: inline-block; width: 6px; height: 6px; border-radius: 50%;
    background: #4ade80; box-shadow: 0 0 0 2px rgba(74,222,128,.2);
    animation: pulse-green 2.5s infinite;
}
@keyframes pulse-green {
    0%,100% { box-shadow: 0 0 0 2px rgba(74,222,128,.2); }
    50% { box-shadow: 0 0 0 4px rgba(74,222,128,.06); }
}


/* MAIN CONTENT AREA */

#main-content {
    margin-left: 210px;
    min-height: 100vh;
    display: flex; flex-direction: column;
    transition: margin-left .2s;
    background: var(--bg);
}

.page-header {
    background: var(--surface);
    padding: 10px 20px;
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
    gap: 8px; flex-wrap: wrap;
    position: sticky; top: 0; z-index: 20;
}
.page-title {
    font-size: 18px; font-weight: 700;
    color: var(--ink); letter-spacing: -.01em;
}
.page-actions { display: flex; gap: 5px; align-items: center; flex-wrap: wrap; }


/* MOBILE TOPBAR */

.topbar-mobile {
    display: none; background: var(--sidebar); color: white;
    padding: 10px 12px; align-items: center; justify-content: space-between;
    position: sticky; top: 0; z-index: 30;
}
.hamburger { background: none; border: none; cursor: pointer; padding: 4px; }


/* OVERLAY */

#overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(15,23,41,.4); z-index: 40;
    backdrop-filter: blur(2px);
    animation: overlayFadeIn 0.25s ease-out;
}


/* BUTTONS */

.btn {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 5px 11px; height: 28px;
    border-radius: var(--radius-sm);
    font-size: 12px; font-weight: 600;
    cursor: pointer; transition: all var(--ease);
    border: 1px solid transparent;
    white-space: nowrap; text-decoration: none;
    font-family: 'Inter', sans-serif;
}
.btn-primary { background: var(--brand); color: white; }
.btn-primary:hover { background: #1e293b; transform: translateY(-1px); box-shadow: 0 2px 6px rgba(0,0,0,.1); }
.btn-success { background: var(--accent); color: white; }
.btn-success:hover { background: var(--accent-dk); }
.btn-ghost { background: var(--surface); color: var(--ink-2); border-color: var(--border); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent-dk); background: var(--accent-lt); }
.btn-danger-ghost { color: var(--danger); border-color: var(--border); background: var(--surface); }
.btn-danger-ghost:hover { background: #fef2f2; border-color: var(--danger); }
.btn-sm { padding: 3px 9px; font-size: 11px; height: 24px; }
.btn-xs { padding: 2px 7px; font-size: 10px; height: 22px; }


/* CARDS */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden; width: 100%;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.card:hover { border-color: var(--ink-3); box-shadow: 0 2px 8px rgba(0,0,0,.04); }
.card-header {
    padding: 8px 14px;
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
    background: transparent; flex-wrap: wrap; gap: 4px;
    min-height: 36px;
}
.card-label {
    font-size: 11px; font-weight: 500;
    letter-spacing: var(--ls-caps); text-transform: uppercase;
    color: var(--ink-2);
}
.card-body { padding: 0; }


/* CALENDAR */

.cal-nav { display: flex; align-items: center; gap: 2px; }
.cal-nav-btn {
    width: 24px; height: 24px;
    border-radius: var(--radius-sm);
    background: var(--surface); border: 1px solid var(--border);
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    color: var(--ink-3); font-size: 13px;
    transition: all var(--ease);
}
.cal-nav-btn:hover { background: var(--bg); border-color: var(--ink-3); color: var(--ink-2); }

.cal-month-label {
    font-size: 12px; font-weight: 600;
    color: var(--ink);
    min-width: 90px; text-align: center;
}

.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; }
.cal-weekday {
    text-align: center; font-size: 9px; font-weight: 700;
    color: var(--ink-3); letter-spacing: var(--ls-caps);
    text-transform: uppercase; padding: 3px 0 5px;
}

.cal-day {
    aspect-ratio: 1;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    border-radius: 50%; cursor: pointer;
    font-size: 11px; font-weight: 500; color: var(--ink-2);
    position: relative; padding: 1px;
    transition: all var(--ease);
}
.cal-day:hover { background: var(--bg); color: var(--ink); }
.cal-day.today {
    background: var(--accent);
    color: white; font-weight: 700;
}
.cal-day.selected {
    background: var(--brand); color: white !important; font-weight: 700;
}
.cal-day[title] { cursor: pointer; }

.has-dot {
    width: 3px; height: 3px; border-radius: 50%;
    background: var(--accent); position: absolute; bottom: 2px;
}
.cal-day.selected .has-dot { background: white !important; }
.cal-day.today .has-dot { background: white !important; }


/* STAT / RESUMO */

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    display: flex; justify-content: space-between; align-items: center;
    transition: all 0.2s ease;
}
.stat-card:hover { background: var(--bg); border-color: var(--ink-3); }
.stat-label {
    font-size: 10px; font-weight: 500;
    letter-spacing: var(--ls-caps); text-transform: uppercase;
    color: var(--ink-2);
}
.stat-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 20px; font-weight: 700;
}


/* RECEPTION GRID LAYOUT */

.grid-recepcao { display: flex; flex-direction: column; gap: 12px; }
.grid-recepcao-col-1 { display: flex; flex-direction: column; gap: 8px; width: 100%; }
.grid-recepcao-col-2 { width: 100%; }

@media (min-width: 1024px) {
    .grid-recepcao { flex-direction: row; align-items: flex-start; }
    .grid-recepcao-col-1 { width: 260px; flex-shrink: 0; }
    .grid-recepcao-col-2 { flex: 1; min-width: 0; }
}

.grid-recepcao-panels { display: flex; gap: 12px; margin-top: 8px; }
.panel-agendados, .panel-fila { flex: 1; min-width: 0; }
.panel-title-bar { display: flex; align-items: center; gap: 6px; }

.badge-fila-count {
    font-size: 10px; font-weight: 700;
    background: var(--accent); color: white;
    border-radius: 999px; padding: 0 7px; min-width: 18px;
    text-align: center; line-height: 18px;
}
.badge-fila-count-purple {
    font-size: 10px; font-weight: 700;
    background: var(--purple); color: white;
    border-radius: 999px; padding: 0 7px; min-width: 18px;
    text-align: center; line-height: 18px;
}


/* PATIENT ROWS */

.patient-row {
    display: flex; align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 0 14px;
    height: 48px;
    border-bottom: 1px solid var(--border-lt);
    transition: background 0.15s ease;
}
.patient-row:hover { background: var(--bg); }
.patient-row:last-child { border-bottom: none; }

.patient-row-left {
    display: flex; gap: 8px; flex: 1; min-width: 0; align-items: center;
    overflow: hidden;
}
.patient-row-right {
    display: flex; align-items: center; gap: 5px; flex-shrink: 0;
}

.patient-code {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px; color: var(--ink-3); font-weight: 500;
    flex-shrink: 0;
}
.patient-name {
    font-size: 13px; font-weight: 700;
    color: var(--ink);
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.patient-name-link {
    cursor: pointer; text-decoration: none;
    transition: color var(--ease);
}
.patient-name-link:hover { color: var(--accent); }

.patient-meta {
    font-size: 11px; color: var(--ink-3);
    white-space: nowrap;
    overflow: hidden; text-overflow: ellipsis;
}
.patient-convenio { font-weight: 600; color: var(--ink-2); }

.patient-billing {
    font-size: 9px; font-weight: 600;
    color: var(--success); background: var(--success-bg);
    border: 1px solid var(--success-bd);
    border-radius: 3px; padding: 1px 7px;
    display: inline-block; white-space: nowrap;
}
.patient-docs { display: flex; gap: 3px; flex-wrap: wrap; }
.doc-link {
    font-size: 9px; font-weight: 600;
    color: white; background: var(--ink-3);
    border-radius: 3px; padding: 1px 6px;
    text-decoration: none; transition: background var(--ease);
}
.doc-link:hover { background: var(--ink-2); }

/* Keep alternating rows transparent to not fight with hover */
#listaAgendadosContainer .patient-row:nth-child(even),
#listaAgendadosContainer .patient-row:nth-child(odd),
#listaFilaAtendimentoContainer .fila-row:nth-child(even),
#listaFilaAtendimentoContainer .fila-row:nth-child(odd) { background: transparent; }


/* BADGES */

.badge {
    display: inline-flex; align-items: center; gap: 3px;
    font-size: 10px; font-weight: 600;
    letter-spacing: var(--ls-caps); text-transform: uppercase;
    padding: 1px 7px; border-radius: 3px;
    white-space: nowrap; line-height: 1.5;
}
.badge-pending {
    background: transparent; color: #b45309;
    border: none; border-left: 2px solid #d97706;
    border-radius: 0; padding-left: 6px;
}
.badge-confirmed {
    background: var(--success-bg); color: #065f46; border: 1px solid var(--success-bd);
}
.badge-cancelled {
    background: transparent; color: var(--danger); border: none;
}
.badge-arrived {
    background: var(--purple-bg); color: var(--purple); border: 1px solid var(--purple-bd);
}


/* CHECK-IN BUTTON */

.btn-checkin {
    background: var(--purple); color: white;
    border: 1px solid var(--purple); border-radius: var(--radius-sm);
    transition: all var(--ease);
    font-size: 10px; font-weight: 600; padding: 2px 9px;
    height: 22px; cursor: pointer;
    font-family: 'Inter', sans-serif;
}
.btn-checkin:hover { background: #6d28d9; }


/* ACTION BUTTONS */

.btn-delete-row {
    flex-shrink: 0;
    width: 24px; height: 24px;
    border-radius: var(--radius-sm);
    background: transparent; border: 1px solid var(--border);
    color: var(--ink-3); font-size: 10px; font-weight: 700;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    transition: all var(--ease);
}
.btn-delete-row:hover { background: #fef2f2; border-color: var(--danger); color: var(--danger); }

.btn-arrow-right {
    flex-shrink: 0;
    width: 24px; height: 24px; border-radius: 50%;
    background: var(--accent); border: none; color: white;
    font-size: 12px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all var(--ease);
}
.btn-arrow-right:hover { background: var(--accent-dk); }

.btn-arrow-left {
    flex-shrink: 0;
    width: 24px; height: 24px; border-radius: 50%;
    background: var(--ink-3); border: none; color: white;
    font-size: 12px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all var(--ease);
}
.btn-arrow-left:hover { background: var(--ink-2); }


/* DROPDOWN MENUS */

.dropdown-wrap { position: relative; flex-shrink: 0; }

.btn-dots {
    width: 24px; height: 24px;
    border-radius: var(--radius-sm);
    background: transparent; border: 1px solid var(--border);
    color: var(--ink-3); font-size: 13px; font-weight: 700;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    line-height: 1; transition: all var(--ease);
}
.btn-dots:hover { background: var(--bg); border-color: var(--ink-3); }

.dropdown-menu {
    display: none; position: fixed;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: 0 4px 12px rgba(0,0,0,.08);
    min-width: 170px; z-index: 9999; overflow: hidden; padding: 3px;
}
.dropdown-menu.open { display: block; animation: dropdownIn 0.18s cubic-bezier(0.16, 1, 0.3, 1); }

.menu-item {
    padding: 6px 10px; font-size: 12px; font-weight: 500;
    color: var(--ink-2); border-radius: var(--radius-sm);
    cursor: pointer; white-space: nowrap;
    transition: all var(--ease);
}
.menu-item:hover { background: var(--bg); color: var(--ink); }
.menu-item-danger { color: var(--danger); }
.menu-item-danger:hover { background: #fef2f2; color: var(--danger); }


/* FILA (Queue) ROWS */

.fila-row {
    display: flex; align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 0 14px;
    height: 48px;
    border-bottom: 1px solid var(--border-lt);
    transition: background 0.15s ease;
}
.fila-row:hover { background: var(--bg); }
.fila-row:last-child { border-bottom: none; }

.fila-row-left {
    display: flex; gap: 8px; flex: 1; min-width: 0; align-items: center;
    overflow: hidden;
}
.fila-row-right {
    display: flex; align-items: center; gap: 5px; flex-shrink: 0;
}

.tempo-espera {
    font-size: 10px; font-weight: 600;
    background: var(--purple-bg); color: var(--purple);
    border-radius: 3px; padding: 1px 7px;
    white-space: nowrap;
}


/* NOTIFY BAR */

.notify-bar {
    padding: 6px 12px;
    background: var(--accent-lt);
    border: 1px solid #99f6e4;
    border-radius: var(--radius);
    display: flex; align-items: center;
    justify-content: space-between;
    gap: 8px; flex-wrap: wrap;
}
.notify-bar-text {
    font-size: 12px; color: var(--accent-dk); font-weight: 500;
    display: flex; align-items: center; gap: 5px;
}


/* CONVENIO ITEMS */

.conv-item {
    display: flex; justify-content: space-between; align-items: center;
    padding: 6px 14px;
    border-bottom: 1px solid var(--border-lt);
    font-size: 12px; color: var(--ink-2);
    transition: background 0.15s ease;
}
.conv-item:last-child { border-bottom: none; }
.conv-item:hover { background: var(--bg); }
.conv-count {
    font-size: 10px; font-weight: 700;
    background: var(--bg); color: var(--ink-2);
    border-radius: 3px; padding: 1px 8px;
    min-width: 22px; text-align: center;
}


/* DATA TABLES */

.table-wrapper { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }

.data-table { width: 100%; border-collapse: collapse; min-width: 700px; }
.data-table th {
    padding: 7px 14px;
    background: var(--bg);
    text-align: left; font-size: 10px; font-weight: 700;
    letter-spacing: var(--ls-caps); text-transform: uppercase;
    color: var(--ink-2);
    border-bottom: 1px solid var(--border);
}
.data-table td {
    padding: 8px 14px; font-size: 12px;
    border-bottom: 1px solid var(--border-lt);
    color: var(--ink-2);
    transition: background 0.15s ease;
}
.data-table tr:hover td { background: var(--bg); }
.data-table tr:last-child td { border-bottom: none; }


/* EMPTY STATE */

.empty-state {
    padding: 28px 20px; text-align: center;
    color: var(--ink-3); font-size: 12px; font-weight: 500;
    border: 1px dashed var(--border);
    border-radius: var(--radius); margin: 10px;
}


/* DASHBOARD */

.grid-dashboard { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.dashboard-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); overflow: hidden;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.dashboard-card:hover { border-color: var(--ink-3); box-shadow: 0 2px 8px rgba(0,0,0,.04); }
.dashboard-card .card-header {
    padding: 8px 14px; border-bottom: 1px solid var(--border);
    background: transparent;
}
.dashboard-card .card-body { padding: 14px; }
.dashboard-card canvas { width: 100% !important; max-height: 220px; }

.dashboard-stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.dashboard-stat {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-sm); padding: 12px; text-align: center;
    transition: all 0.2s ease;
}
.dashboard-stat:hover { background: var(--bg); border-color: var(--ink-3); }
.dashboard-stat-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 22px; font-weight: 700; margin-bottom: 3px;
}
.dashboard-stat-label {
    font-size: 9px; font-weight: 500;
    letter-spacing: var(--ls-caps); text-transform: uppercase;
    color: var(--ink-3);
}


/* TOAST NOTIFICATIONS */

#toast-container {
    position: fixed; top: 12px; right: 12px; z-index: 99998;
    display: flex; flex-direction: column; gap: 6px; pointer-events: none;
}
.toast {
    pointer-events: auto; display: flex; align-items: center; gap: 8px;
    padding: 8px 14px; border-radius: var(--radius);
    font-size: 12px; font-weight: 600; color: white;
    box-shadow: 0 4px 12px rgba(0,0,0,.12);
    animation: toast-in .35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    max-width: 320px;
}
.toast-success { background: #065f46; border-left: 3px solid #34d399; }
.toast-error   { background: #991b1b; border-left: 3px solid #f87171; }
.toast-warning { background: #78350f; border-left: 3px solid #fbbf24; }
.toast-info    { background: #1e3a5f; border-left: 3px solid #60a5fa; }
.toast.removing { animation: toast-out .25s ease-in forwards; }

@keyframes toast-in  {
    from { opacity: 0; transform: translateX(80px) scale(0.95); }
    to   { opacity: 1; transform: translateX(0) scale(1); }
}
@keyframes toast-out {
    from { opacity: 1; transform: translateX(0) scale(1); }
    to   { opacity: 0; transform: translateX(80px) scale(0.95); }
}


/* ERROR BANNER */

#error-banner {
    display: none; position: fixed; top: 0; left: 0; right: 0;
    z-index: 99997;
    background: #fffbeb; border-bottom: 2px solid var(--warning);
    padding: 8px 16px; text-align: center;
    font-size: 12px; font-weight: 600; color: #92400e;
}
#error-banner.active { display: block; }


/* WHATSAPP STATUS INDICATOR */

.whatsapp-status-dot {
    display: inline-block; width: 6px; height: 6px;
    border-radius: 50%; margin-right: 3px;
}
.whatsapp-status-dot.connected {
    background: #4ade80; box-shadow: 0 0 0 2px rgba(74,222,128,.2);
}
.whatsapp-status-dot.disconnected {
    background: #f87171; box-shadow: 0 0 0 2px rgba(248,113,113,.2);
    animation: pulse-red 2s infinite;
}
@keyframes pulse-red {
    0%,100% { box-shadow: 0 0 0 2px rgba(248,113,113,.2); }
    50% { box-shadow: 0 0 0 4px rgba(248,113,113,.06); }
}


/* LAST UPDATED TIMESTAMP */

.last-updated-ts {
    font-size: 9px; color: var(--ink-3); font-weight: 500;
    display: inline-block; margin-left: 6px;
}


/* LOADING SKELETON */

.skeleton-row {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 14px; border-bottom: 1px solid var(--border-lt);
}
.skeleton-block {
    background: linear-gradient(90deg, var(--bg) 25%, var(--border) 50%, var(--bg) 75%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s infinite;
    border-radius: var(--radius-sm);
}
@keyframes skeleton-shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}


/* PRONTUARIO (Medical Record) OVERLAY */

#overlay-prontuario {
    display: none; position: fixed; inset: 0;
    z-index: 10000; background: #0f1729;
    font-family: 'Inter', sans-serif;
    color: #e8eaf0; flex-direction: column;
}
#overlay-prontuario * { box-sizing: border-box; }

.pront-topbar {
    display: flex; align-items: center; gap: 12px;
    padding: 6px 16px;
    background: #151e35;
    border-bottom: 1px solid #1e2a45;
    flex-wrap: wrap; min-height: 44px;
}
.pront-topbar-info {
    display: flex; align-items: center; gap: 14px;
    flex: 1; min-width: 0; flex-wrap: wrap;
}
.pront-topbar-info .pront-info-item { display: flex; flex-direction: column; gap: 1px; }
.pront-topbar-info .pront-info-label {
    font-size: 9px; font-weight: 700;
    letter-spacing: var(--ls-caps); text-transform: uppercase;
    color: var(--ink-2);
}
.pront-topbar-info .pront-info-value {
    font-size: 12px; font-weight: 700;
    color: #e8eaf0; white-space: nowrap;
}

.pront-topbar-actions { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }

.pront-btn {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 5px 11px; border-radius: var(--radius-sm);
    font-size: 11px; font-weight: 700;
    cursor: pointer; border: 1px solid transparent;
    transition: all var(--ease); white-space: nowrap;
    font-family: 'Inter', sans-serif;
}
.pront-btn-teal { background: var(--accent); color: white; border-color: var(--accent); }
.pront-btn-teal:hover { background: var(--accent-dk); }
.pront-btn-ghost { background: transparent; color: var(--ink-3); border-color: #1e2a45; }
.pront-btn-ghost:hover { border-color: var(--accent); color: var(--accent); }
.pront-btn-danger { background: transparent; color: #f87171; border-color: #f87171; }
.pront-btn-danger:hover { background: #ef4444; color: white; }
.pront-btn-primary { background: var(--accent); color: white; border-color: var(--accent); }
.pront-btn-primary:hover { background: var(--accent-dk); }

.pront-dropdown { position: relative; display: inline-block; }
.pront-dropdown-content {
    display: none; position: absolute; right: 0; top: 100%;
    margin-top: 3px; background: #151e35;
    border: 1px solid #1e2a45; border-radius: var(--radius);
    box-shadow: 0 6px 20px rgba(0,0,0,.35);
    min-width: 170px; z-index: 10001;
    overflow: hidden; padding: 3px;
}
.pront-dropdown-content.open { display: block; }
.pront-dropdown-item {
    padding: 7px 10px; font-size: 11px; font-weight: 600;
    color: var(--ink-3); cursor: pointer;
    white-space: nowrap; border-radius: var(--radius-sm);
    transition: all var(--ease);
}
.pront-dropdown-item:hover { background: #1e2a45; color: var(--accent); }

.pront-body { display: flex; flex: 1; min-height: 0; overflow: hidden; }

.pront-sidebar {
    width: 170px; flex-shrink: 0;
    background: #151e35; border-right: 1px solid #1e2a45;
    overflow-y: auto; display: flex; flex-direction: column;
}
.pront-sidebar-label {
    padding: 10px 12px 4px; font-size: 9px; font-weight: 700;
    letter-spacing: var(--ls-caps); text-transform: uppercase; color: var(--ink-2);
}
.pront-tab-btn {
    display: block; width: 100%; text-align: left;
    padding: 8px 12px; font-size: 12px; font-weight: 500;
    color: var(--ink-3); cursor: pointer;
    border: none; background: none;
    border-left: 2px solid transparent;
    transition: all .12s; font-family: 'Inter', sans-serif;
}
.pront-tab-btn:hover { background: rgba(255,255,255,.03); color: white; }
.pront-tab-btn.active {
    background: rgba(13,148,136,.08);
    color: var(--accent); font-weight: 700;
    border-left-color: var(--accent);
}

.pront-main {
    flex: 1; overflow-y: auto;
    padding: 18px 22px; display: flex;
    flex-direction: column; gap: 0;
}
.pront-main::-webkit-scrollbar { width: 5px; }
.pront-main::-webkit-scrollbar-thumb { background: #1e2a45; border-radius: 99px; }

.pront-section-title {
    font-size: 10px; font-weight: 700;
    letter-spacing: var(--ls-caps); text-transform: uppercase;
    color: var(--accent); margin-bottom: 10px;
    padding-bottom: 7px; border-bottom: 1px solid #1e2a45;
}
.pront-field-label {
    font-size: 9px; font-weight: 700;
    letter-spacing: var(--ls-caps); text-transform: uppercase;
    color: var(--ink-3); margin-bottom: 3px; display: block;
}
.pront-field-group { margin-bottom: 10px; }
.pront-input {
    width: 100%; padding: 6px 9px;
    background: #0c1220; border: 1px solid #1e2a45;
    border-radius: var(--radius-sm);
    color: #e8eaf0; font-size: 12px;
    font-family: 'Inter', sans-serif;
    outline: none; transition: border-color var(--ease);
}
.pront-input:focus { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(13,148,136,.1); }
.pront-input::placeholder { color: #4a5568; }
textarea.pront-input { resize: vertical; min-height: 44px; }

.pront-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.pront-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.pront-grid-4 { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; gap: 8px; }
.pront-grid-7 { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }

.pront-eye-box {
    background: #151e35; border: 1px solid #1e2a45;
    border-radius: var(--radius); padding: 10px;
    margin-bottom: 8px;
}
.pront-eye-title {
    font-size: 9px; font-weight: 700;
    color: var(--accent); text-transform: uppercase;
    letter-spacing: var(--ls-caps); margin-bottom: 8px;
}

.pront-tab-content { display: none; }
.pront-tab-content.active { display: block; }

.pront-proxima-consulta { display: flex; align-items: center; gap: 6px; }
.pront-proxima-consulta label {
    font-size: 9px; font-weight: 700;
    color: var(--ink-3); text-transform: uppercase;
    letter-spacing: var(--ls-caps); white-space: nowrap;
}
.pront-proxima-consulta input {
    width: 110px; padding: 4px 8px;
    background: #0c1220; border: 1px solid #1e2a45;
    border-radius: var(--radius-sm);
    color: #e8eaf0; font-size: 11px;
    font-family: 'Inter', sans-serif;
    outline: none; transition: border-color var(--ease);
}
.pront-proxima-consulta input:focus { border-color: var(--accent); }
.pront-autosave-indicator { font-size: 9px; color: var(--ink-2); font-weight: 600; padding: 0 6px; }


/* SWEETALERT2 z-index override */

.swal2-container { z-index: 20000 !important; }


/* RESPONSIVE */

@media (max-width: 1023px) {
    #sidebar { transform: translateX(-100%); }
    #sidebar.open { transform: translateX(0); }
    #main-content { margin-left: 0; }
    .topbar-mobile { display: flex; }
    .page-header { top: 48px; }
}

@media (max-width: 899px) {
    .grid-recepcao-panels { flex-direction: column; }
}

@media (max-width: 768px) {
    .grid-dashboard { grid-template-columns: 1fr; }
    .dashboard-stats-grid { grid-template-columns: 1fr 1fr; }

    .pront-sidebar {
        width: 100%; flex-shrink: unset;
        border-right: none; border-bottom: 1px solid #1e2a45;
        overflow-x: auto; overflow-y: hidden;
        flex-direction: row; max-height: 40px;
    }
    .pront-sidebar-label { display: none; }
    .pront-tab-btn {
        white-space: nowrap; padding: 9px 11px;
        border-left: none; border-bottom: 2px solid transparent;
        font-size: 11px;
    }
    .pront-tab-btn.active { border-left-color: transparent; border-bottom-color: var(--accent); }
    .pront-body { flex-direction: column; }
    .pront-main { padding: 12px; }
    .pront-grid-2, .pront-grid-3, .pront-grid-4, .pront-grid-7 { grid-template-columns: 1fr; }
    .pront-topbar { padding: 5px 10px; }
    .pront-topbar-info { gap: 8px; }
}

@media (max-width: 480px) {
    .page-header { padding: 8px 12px; }
    .page-title { font-size: 15px; }
    .btn { padding: 4px 9px; font-size: 11px; height: 26px; }
    .patient-row, .fila-row { padding: 0 10px; height: 44px; }
    .card-header { padding: 7px 10px; }
    .dashboard-stats-grid { grid-template-columns: 1fr; }
}


/* ANIMATIONS */

/* Page load fade-in */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Sidebar slide-in on mobile */
@keyframes sidebarSlideIn {
    from { transform: translateX(-100%); opacity: 0.5; }
    to   { transform: translateX(0);     opacity: 1; }
}
@media (max-width: 1023px) {
    #sidebar.open {
        animation: sidebarSlideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    }
}

/* Login entrance */
@keyframes loginFadeIn {
    from { opacity: 0; transform: translateY(16px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* Overlay fade */
@keyframes overlayFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* Dropdown entrance */
@keyframes dropdownIn {
    from { opacity: 0; transform: translateY(-4px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0)    scale(1); }
}

/* Prontuario overlay entrance */
@keyframes prontSlideUp {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
}
#overlay-prontuario[style*="flex"] {
    animation: prontSlideUp 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Notify bar entrance */
@keyframes notifySlideDown {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}
.notify-bar {
    animation: notifySlideDown 0.3s ease-out;
}

/* Button active press */
.btn:active,
.btn-checkin:active,
.login-btn:active,
.pront-btn:active {
    transform: scale(0.97);
}

/* Skeleton shimmer */
@keyframes shimmer {
    0%   { background-position: -200px 0; }
    100% { background-position: 200px 0; }
}
.skeleton-shimmer {
    background: linear-gradient(90deg,
        var(--bg) 25%,
        var(--border) 50%,
        var(--bg) 75%);
    background-size: 400px 100%;
    animation: shimmer 1.4s ease-in-out infinite;
}


/* ACCESSIBILITY — Reduced Motion */

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }

    .login-card { animation: none; }
    .login-card img { animation: none; }
    .status-dot { animation: none; }
    .whatsapp-status-dot.disconnected { animation: none; }
    .skeleton-block { animation: none; }
    .toast { animation: none; }
    .toast.removing { animation: none; }
}
