:root {
    --bg-0: #0b1020;
    --bg-1: #0f172a;
    --bg-2: #1e293b;
    --bg-3: #28324a;
    --surface: rgba(255, 255, 255, 0.04);
    --surface-strong: rgba(255, 255, 255, 0.07);
    --border: rgba(255, 255, 255, 0.08);
    --border-strong: rgba(255, 255, 255, 0.14);
    --text: #e6edf7;
    --text-muted: #93a3bd;
    --primary: #ef4444;
    --primary-2: #f97373;
    --primary-glow: rgba(239, 68, 68, 0.35);
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;
    --radius: 16px;
    --radius-sm: 10px;
    --shadow-1: 0 6px 24px rgba(0, 0, 0, 0.25);
    --shadow-2: 0 16px 48px rgba(0, 0, 0, 0.35);
    --transition: all 180ms cubic-bezier(.4, 0, .2, 1);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    color: var(--text);
    background: radial-gradient(circle at 0% 0%, #1a2547 0%, transparent 45%),
                radial-gradient(circle at 100% 100%, #2a1430 0%, transparent 45%),
                linear-gradient(135deg, var(--bg-0), var(--bg-1));
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; }
code { font-family: 'JetBrains Mono', monospace; background: rgba(255,255,255,0.07); padding: 2px 6px; border-radius: 4px; }

.app {
    display: grid;
    grid-template-columns: 280px 1fr;
    min-height: 100vh;
}

/* ========== HAMBURGER + BACKDROP (mobile only) ========== */
.menu-toggle {
    display: none;
    align-items: center; justify-content: center;
    width: 42px; height: 42px;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    color: var(--text);
    cursor: pointer;
    flex-shrink: 0;
}
.menu-toggle:hover { background: var(--surface-strong); }
.sidebar-backdrop {
    display: none;
    position: fixed; inset: 0;
    background: rgba(5, 8, 18, 0.65);
    backdrop-filter: blur(4px);
    z-index: 90;
    opacity: 0;
    transition: opacity 220ms ease;
}
body.sidebar-open .sidebar-backdrop { display: block; opacity: 1; }
body.sidebar-open { overflow: hidden; }

/* ========== SIDEBAR ========== */
.sidebar {
    background: linear-gradient(180deg, rgba(15, 23, 42, 0.9), rgba(11, 16, 32, 0.95));
    backdrop-filter: blur(20px);
    border-right: 1px solid var(--border);
    padding: 1.5rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    position: sticky;
    top: 0;
    height: 100vh;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.brand-logo {
    width: 48px; height: 48px;
    background: linear-gradient(135deg, var(--primary), #c026d3);
    border-radius: 14px;
    display: grid; place-items: center;
    color: #fff;
    box-shadow: 0 8px 20px var(--primary-glow);
}
.icon { display: inline-block; vertical-align: -3px; flex-shrink: 0; }
.btn .icon, .menu-item .icon { vertical-align: middle; }
.card-header h2 .icon { vertical-align: -3px; margin-right: 0.4rem; opacity: 0.85; }
.menu-item { display: flex; align-items: center; gap: 0.7rem; }
.menu-item .icon { width: 18px; height: 18px; }
.menu-item.active .icon { color: var(--primary-2); }

.brand-title { font-weight: 800; font-size: 1.05rem; letter-spacing: -0.01em; }
.brand-sub { color: var(--text-muted); font-size: 0.78rem; }

.menu { display: flex; flex-direction: column; gap: 0.35rem; flex: 1; }
.menu-item {
    display: flex; align-items: center; gap: 0.85rem;
    padding: 0.75rem 0.95rem;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    transition: var(--transition);
    font-weight: 500;
    font-size: 0.95rem;
}
.menu-item:hover { background: var(--surface); color: var(--text); }
.menu-item.active {
    background: linear-gradient(135deg, rgba(239,68,68,0.18), rgba(192,38,211,0.12));
    color: #fff;
    box-shadow: inset 0 0 0 1px rgba(239,68,68,0.25);
}

.sidebar-footer {
    display: flex; align-items: center; gap: 0.6rem;
    color: var(--text-muted); font-size: 0.85rem;
    padding: 0.85rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
}
.status-dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--success);
    box-shadow: 0 0 0 4px rgba(16,185,129,0.18);
    animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.55; }
}

/* ========== MAIN ========== */
.main { padding: 0; }
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--border);
    background: rgba(11,16,32,0.55);
    backdrop-filter: blur(14px);
    position: sticky; top: 0; z-index: 5;
}
.page-title { margin: 0; font-size: clamp(1.15rem, 1rem + 1vw, 1.6rem); font-weight: 700; letter-spacing: -0.02em; }
.page-subtitle { margin: 0.15rem 0 0; color: var(--text-muted); font-size: clamp(0.82rem, 0.78rem + 0.2vw, 0.92rem); }
.topbar-actions { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.topbar-left { display: flex; align-items: center; gap: 0.85rem; min-width: 0; flex: 1; }
.topbar-left > div { min-width: 0; }
.topbar-left .page-title,
.topbar-left .page-subtitle { overflow-wrap: anywhere; }
.clock {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.95rem;
    color: var(--text-muted);
    padding: 0.5rem 0.9rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
}

.content { padding: 2rem; }

/* ========== BUTTONS ========== */
.btn {
    display: inline-flex; align-items: center; gap: 0.5rem;
    padding: 0.65rem 1.15rem;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    font-weight: 600;
    font-size: 0.92rem;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}
.btn-primary {
    background: linear-gradient(135deg, var(--primary), #f97373);
    color: #fff;
    box-shadow: 0 6px 20px var(--primary-glow);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 10px 28px var(--primary-glow); }
.btn-ghost {
    background: var(--surface);
    border-color: var(--border-strong);
    color: var(--text);
}
.btn-ghost:hover { background: var(--surface-strong); }
.btn-lg { padding: 0.9rem 1.5rem; font-size: 1rem; }
.btn-sm { padding: 0.4rem 0.75rem; font-size: 0.82rem; }

/* ========== STATS ========== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin-bottom: 1.75rem;
}
.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.4rem;
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(8px);
}
.stat-card::after {
    content: ''; position: absolute; inset: 0;
    background: linear-gradient(135deg, var(--accent, transparent), transparent 60%);
    opacity: 0.18;
    pointer-events: none;
}
.stat-primary  { --accent: #6366f1; }
.stat-success  { --accent: #10b981; }
.stat-warning  { --accent: #f59e0b; }
.stat-danger   { --accent: #ef4444; }

.stat-label { color: var(--text-muted); font-size: 0.85rem; font-weight: 500; }
.stat-value { font-size: 2.4rem; font-weight: 800; letter-spacing: -0.03em; margin: 0.25rem 0 0.4rem; }
.stat-hint { font-size: 0.82rem; color: var(--text-muted); }

/* ========== CARD ========== */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    backdrop-filter: blur(8px);
    box-shadow: var(--shadow-1);
    margin-bottom: 1.5rem;
}
.card-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.25rem;
}
.card-header h2 { margin: 0; font-size: 1.2rem; font-weight: 700; }
.card-header .muted { font-size: 0.85rem; }
.muted { color: var(--text-muted); }
.small { font-size: 0.8rem; }

.legend {
    display: flex; gap: 0.85rem; align-items: center;
    color: var(--text-muted); font-size: 0.83rem;
}
.legend-dot {
    width: 9px; height: 9px; border-radius: 50%;
    display: inline-block; margin-right: 4px;
}
.legend-green { background: var(--success); }
.legend-yellow { background: var(--warning); }
.legend-red { background: var(--danger); }

/* ========== HOSPITAL CARDS ========== */
.hospital-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}
.hospital-card {
    background: linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0.02));
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.15rem;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}
.hospital-card:hover {
    transform: translateY(-3px);
    border-color: var(--border-strong);
    box-shadow: var(--shadow-1);
}
.hospital-card::before {
    content: '';
    position: absolute; top: 0; left: 0; right: 0;
    height: 3px;
    background: var(--accent-color, var(--info));
}
.hospital-card.available { --accent-color: var(--success); }
.hospital-card.limited   { --accent-color: var(--warning); }
.hospital-card.full      { --accent-color: var(--danger); }

.hospital-head {
    display: flex; justify-content: space-between; align-items: flex-start;
    gap: 0.75rem;
    margin-bottom: 1rem;
}
.hospital-name { font-weight: 700; font-size: 1.02rem; line-height: 1.3; }
.hospital-bairro { color: var(--text-muted); font-size: 0.83rem; margin-top: 0.2rem; display: inline-flex; align-items: center; gap: 0.3rem; }
.hospital-bairro .icon { vertical-align: middle; }

.badge {
    padding: 0.3rem 0.65rem; border-radius: 999px;
    font-size: 0.72rem; font-weight: 600; letter-spacing: 0.02em;
    text-transform: uppercase;
    white-space: nowrap;
}
.badge-available { background: rgba(16,185,129,0.18); color: #6ee7b7; }
.badge-limited   { background: rgba(245,158,11,0.18); color: #fcd34d; }
.badge-full      { background: rgba(239,68,68,0.18); color: #fca5a5; }

.meter {
    height: 6px;
    background: rgba(255,255,255,0.07);
    border-radius: 999px;
    overflow: hidden;
    margin-bottom: 0.55rem;
}
.meter-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-color, var(--info)), var(--accent-color, var(--info)));
    transition: width 600ms ease;
}
.hospital-card.available .meter-fill { background: linear-gradient(90deg, #34d399, #10b981); }
.hospital-card.limited   .meter-fill { background: linear-gradient(90deg, #fbbf24, #f59e0b); }
.hospital-card.full      .meter-fill { background: linear-gradient(90deg, #fb7185, #ef4444); }

.hospital-numbers {
    display: flex; justify-content: space-between;
    font-size: 0.85rem;
    margin-bottom: 0.85rem;
}
.hospital-numbers strong { font-size: 1rem; }
.hospital-livres {
    display: flex; justify-content: space-between; align-items: baseline;
    padding-top: 0.75rem;
    border-top: 1px dashed var(--border);
}
.livres-label { color: var(--text-muted); font-size: 0.82rem; }
.livres-value { font-size: 1.4rem; font-weight: 800; color: var(--accent-color, var(--info)); }
.hospital-card.available .livres-value { color: #34d399; }
.hospital-card.limited   .livres-value { color: #fbbf24; }
.hospital-card.full      .livres-value { color: #fb7185; }

/* ========== FORMS ========== */
.grid-2 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
    gap: 1.5rem;
}
.form { display: flex; flex-direction: column; gap: 1.15rem; }
.field { display: flex; flex-direction: column; gap: 0.45rem; }
.field label { font-weight: 500; font-size: 0.92rem; color: var(--text); }
.field select, .field input, .field textarea {
    background: rgba(0,0,0,0.25);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    padding: 0.75rem 0.9rem;
    color: var(--text);
    font-size: 0.95rem;
    font-family: inherit;
    transition: var(--transition);
}
.field select:focus, .field input:focus, .field textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}
.field select option { background: var(--bg-2); }
.field textarea { resize: vertical; }

.form-actions { display: flex; justify-content: flex-end; }

.info-box {
    margin-top: 1.5rem;
    padding: 1rem 1.15rem;
    background: rgba(59,130,246,0.08);
    border-left: 3px solid var(--info);
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    color: var(--text-muted);
}
.info-box strong { color: var(--text); display: block; margin-bottom: 0.45rem; }
.info-box ol { margin: 0.4rem 0 0 1.1rem; padding: 0; line-height: 1.7; }
.info-box p { margin: 0.4rem 0 0; line-height: 1.6; }

/* ========== ALERTS ========== */
.alert {
    padding: 0.85rem 1.1rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
    font-size: 0.92rem;
}
.alert-success { background: rgba(16,185,129,0.12); border: 1px solid rgba(16,185,129,0.3); color: #6ee7b7; }
.alert-error   { background: rgba(239,68,68,0.12); border: 1px solid rgba(239,68,68,0.3); color: #fca5a5; }
.alert-warning { background: rgba(245,158,11,0.12); border: 1px solid rgba(245,158,11,0.3); color: #fcd34d; display: flex; align-items: center; gap: 0.5rem; }
.alert .icon { vertical-align: middle; }
.alert a { text-decoration: underline; }
.btn-success { background: linear-gradient(135deg, #10b981, #34d399); color: #fff; box-shadow: 0 4px 14px rgba(16,185,129,0.3); }
.btn-success:hover { transform: translateY(-1px); box-shadow: 0 8px 20px rgba(16,185,129,0.4); }
.btn-danger { background: rgba(239,68,68,0.18); color: #fca5a5; border-color: rgba(239,68,68,0.35); }
.btn-danger:hover { background: rgba(239,68,68,0.28); }

/* ========== TABS ========== */
.tabs {
    display: flex; gap: 0.25rem;
    margin-bottom: 1.25rem;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}
.tab {
    padding: 0.7rem 1.1rem;
    color: var(--text-muted);
    font-weight: 500;
    border-bottom: 2px solid transparent;
    transition: var(--transition);
    text-decoration: none;
}
.tab:hover { color: var(--text); }
.tab.active { color: #fff; border-bottom-color: var(--primary); }

/* ========== FORM INLINE ========== */
.form-inline {
    display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center;
}
.form-inline input,
.form-inline select {
    background: rgba(0,0,0,0.25);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    padding: 0.55rem 0.75rem;
    color: var(--text);
    font-size: 0.9rem;
    font-family: inherit;
    min-width: 140px;
}
.form-inline input:focus, .form-inline select:focus { outline: none; border-color: var(--primary); }
.data-table input, .data-table select {
    background: rgba(0,0,0,0.25);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.4rem 0.6rem;
    color: var(--text);
    font-size: 0.88rem;
    font-family: inherit;
    width: 100%;
}

/* ========== AUTO REFRESH ========== */
.auto-refresh-bar {
    display: flex; align-items: center; gap: 0.55rem;
    padding: 0.55rem 0.85rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
    font-size: 0.83rem;
    width: fit-content;
}
.status-dot-live {
    background: var(--success);
    box-shadow: 0 0 0 4px rgba(16,185,129,0.18);
    animation: pulse 1.5s ease-in-out infinite;
}
.stat-flash { animation: flash 0.7s ease; }
@keyframes flash {
    0% { color: var(--text); }
    50% { color: var(--primary-2); transform: scale(1.05); }
    100% { color: var(--text); }
}

/* ========== GRAPH (vis.js) ========== */
.graph-container {
    height: 600px;
    background: rgba(0,0,0,0.3);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-top: 1rem;
}
.graph-controls {
    display: flex; flex-wrap: wrap; gap: 0.85rem; align-items: end;
    padding: 0.85rem;
    background: rgba(0,0,0,0.2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
}
.graph-controls .field { margin-bottom: 0; }
.graph-buttons { display: flex; gap: 0.5rem; align-items: center; }
.graph-result {
    margin-top: 1rem;
    padding: 0.85rem 1rem;
    background: rgba(99,102,241,0.08);
    border-left: 3px solid #6366f1;
    border-radius: var(--radius-sm);
}
.graph-result-row {
    display: flex; gap: 0.6rem; padding: 0.25rem 0;
    font-size: 0.92rem; flex-wrap: wrap;
}

/* ========== STATS & CHARTS ========== */
.export-link {
    display: flex; align-items: center; justify-content: center;
    gap: 0.4rem;
    height: 100%;
    text-decoration: none;
    color: var(--success);
    font-weight: 600;
}
.export-link:hover { color: #6ee7b7; }
.algo-pill {
    display: inline-block;
    padding: 0.18rem 0.55rem;
    background: rgba(99,102,241,0.18);
    border: 1px solid rgba(99,102,241,0.3);
    color: #c7d2fe;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.04em;
}

/* ========== RESULT CARD ========== */
.result-card { display: flex; flex-direction: column; }
.result-banner {
    display: flex; align-items: center; gap: 0.85rem;
    padding: 1rem 1.15rem;
    background: rgba(16,185,129,0.1);
    border: 1px solid rgba(16,185,129,0.3);
    border-radius: var(--radius-sm);
    margin-bottom: 1.1rem;
}
.result-icon { display: inline-grid; place-items: center; color: var(--success); }
.result-banner strong { display: block; }
.result-banner .muted { font-size: 0.85rem; }

.result-detail {
    background: rgba(0,0,0,0.2);
    border-radius: var(--radius-sm);
    padding: 0.5rem 1rem;
    margin-bottom: 1.1rem;
}
.detail-row {
    display: flex; justify-content: space-between; align-items: center;
    padding: 0.6rem 0;
    border-bottom: 1px dashed var(--border);
    font-size: 0.92rem;
}
.detail-row:last-child { border-bottom: none; }
.detail-label { color: var(--text-muted); }
.detail-value { font-weight: 600; text-align: right; }
.detail-value.highlight { color: #f97373; font-size: 1rem; }

.path-box {
    padding: 1rem;
    background: rgba(99,102,241,0.08);
    border: 1px solid rgba(99,102,241,0.25);
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
}
.path-title { font-weight: 600; margin-bottom: 0.7rem; font-size: 0.92rem; }
.path-flow {
    display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem;
}
.path-node {
    padding: 0.4rem 0.75rem;
    background: rgba(255,255,255,0.06);
    border: 1px solid var(--border);
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 500;
}
.path-node.origin { background: rgba(239,68,68,0.18); border-color: rgba(239,68,68,0.4); color: #fca5a5; }
.path-node.destination { background: rgba(16,185,129,0.18); border-color: rgba(16,185,129,0.4); color: #6ee7b7; }
.path-arrow { color: var(--text-muted); display: inline-flex; align-items: center; }
.path-title { display: flex; align-items: center; gap: 0.45rem; }
.status-badge .icon { vertical-align: -2px; margin-right: 0.15rem; }
.btn .icon { vertical-align: middle; }
.mapa-bairro { display: flex; align-items: center; gap: 0.45rem; }

.empty-state {
    text-align: center; padding: 2.5rem 1rem;
    color: var(--text-muted);
}
.empty-icon { color: var(--text-muted); opacity: 0.55; margin-bottom: 0.75rem; }
.empty-state p { margin: 0 0 0.4rem; font-size: 1rem; color: var(--text); }
.empty-state .btn { margin-top: 0.75rem; }

/* ========== TABLES ========== */
.table-wrapper { overflow-x: auto; }
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}
.data-table th {
    text-align: left;
    padding: 0.85rem 0.9rem;
    background: rgba(0,0,0,0.25);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid var(--border);
}
.data-table td {
    padding: 0.85rem 0.9rem;
    border-bottom: 1px solid var(--border);
}
.data-table tbody tr { transition: var(--transition); }
.data-table tbody tr:hover { background: var(--surface-strong); }
.rota-cell { color: var(--text-muted); font-size: 0.85rem; }

.row-pass td { background: rgba(16,185,129,0.05); }
.row-fail td { background: rgba(239,68,68,0.05); }
.row-chosen { background: rgba(239,68,68,0.08); }

.status-badge {
    display: inline-block;
    padding: 0.25rem 0.65rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
}
.status-done { background: rgba(16,185,129,0.18); color: #6ee7b7; }
.status-active { background: rgba(245,158,11,0.18); color: #fcd34d; }
.status-fail { background: rgba(239,68,68,0.18); color: #fca5a5; }

.test-summary { display: flex; align-items: center; gap: 0.75rem; }
.test-counter {
    font-size: 1.6rem; font-weight: 800;
    padding: 0.4rem 1rem; border-radius: var(--radius-sm);
}
.test-counter.all-pass { background: rgba(16,185,129,0.15); color: #6ee7b7; }
.test-counter.has-fail { background: rgba(245,158,11,0.15); color: #fcd34d; }

.analyze-details {
    background: rgba(0,0,0,0.2);
    border-radius: var(--radius-sm);
    padding: 0.5rem 1rem;
}
.analyze-details summary {
    cursor: pointer; padding: 0.5rem 0; font-weight: 500;
    color: var(--text-muted);
}
.analyze-details summary:hover { color: var(--text); }
.analyze-table {
    width: 100%; border-collapse: collapse; margin-top: 0.5rem;
    font-size: 0.85rem;
}
.analyze-table th, .analyze-table td {
    padding: 0.4rem 0.5rem;
    border-bottom: 1px solid var(--border);
    text-align: left;
}

/* ========== MAPA ========== */
.mapa-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}
.mapa-card {
    background: rgba(0,0,0,0.2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.1rem;
}
.mapa-bairro {
    font-weight: 700; font-size: 1rem;
    margin-bottom: 0.85rem;
    padding-bottom: 0.6rem;
    border-bottom: 1px solid var(--border);
}
.mapa-section-title {
    color: var(--text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-top: 0.85rem;
    margin-bottom: 0.4rem;
}
.mapa-list { list-style: none; margin: 0; padding: 0; }
.mapa-list li {
    display: grid; grid-template-columns: 14px 1fr auto; gap: 0.5rem;
    align-items: center;
    padding: 0.35rem 0;
    font-size: 0.88rem;
}
.dot { width: 9px; height: 9px; border-radius: 50%; }
.dot-available { background: var(--success); }
.dot-limited { background: var(--warning); }
.dot-full { background: var(--danger); }

.mapa-vizinhos { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.vizinho-chip {
    padding: 0.25rem 0.6rem;
    background: rgba(99,102,241,0.12);
    border: 1px solid rgba(99,102,241,0.25);
    border-radius: 999px;
    font-size: 0.78rem;
    color: #c7d2fe;
}

/* ========== INSTALL ========== */
.install-body {
    display: grid;
    place-items: center;
    min-height: 100vh;
    padding: 2rem;
}
.install-card {
    width: 100%; max-width: 540px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2.5rem;
    box-shadow: var(--shadow-2);
    backdrop-filter: blur(20px);
}
.install-header { text-align: center; margin-bottom: 1.75rem; }
.install-icon {
    display: inline-grid; place-items: center;
    width: 72px; height: 72px;
    background: linear-gradient(135deg, var(--primary), #c026d3);
    border-radius: 22px;
    color: #fff;
    box-shadow: 0 12px 36px var(--primary-glow);
    margin-bottom: 0.85rem;
}
.install-header h1 { margin: 0; font-size: 1.6rem; }
.install-steps {
    list-style: none;
    margin: 0 0 1.5rem; padding: 0;
}
.install-steps li {
    padding: 0.7rem 1rem;
    background: rgba(0,0,0,0.2);
    border-left: 3px solid var(--success);
    border-radius: var(--radius-sm);
    margin-bottom: 0.5rem;
    font-size: 0.92rem;
}
.install-actions { display: flex; gap: 0.75rem; justify-content: center; }

/* ========== RESPONSIVE ========== */

/* Large desktop and below — slightly tighter paddings */
@media (max-width: 1280px) {
    .content { padding: 1.5rem; }
    .topbar { padding: 1.25rem 1.5rem; }
    .app { grid-template-columns: 250px 1fr; }
}

/* Tablet landscape and below — sidebar becomes off-canvas drawer */
@media (max-width: 1024px) {
    .app { grid-template-columns: 1fr; }
    .menu-toggle { display: inline-flex; }

    .sidebar {
        position: fixed;
        top: 0; left: 0;
        width: min(86vw, 320px);
        height: 100vh;
        z-index: 100;
        transform: translateX(-100%);
        transition: transform 260ms cubic-bezier(.4, 0, .2, 1);
        overflow-y: auto;
        flex-direction: column;
        gap: 1.5rem;
    }
    body.sidebar-open .sidebar { transform: translateX(0); }

    .topbar {
        padding: 1rem 1.25rem;
        gap: 0.75rem;
    }
    .content { padding: 1.25rem; }
    .stats-grid { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
    .hospital-grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
    .mapa-grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
    .graph-container { height: clamp(400px, 60vh, 560px); }
}

/* Tablet portrait and large phones */
@media (max-width: 768px) {
    .topbar { padding: 0.9rem 1rem; }
    .content { padding: 1rem; }
    .card { padding: 1.15rem; }
    .card-header { gap: 0.75rem; margin-bottom: 1rem; }
    .stats-grid { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0.75rem; margin-bottom: 1.25rem; }
    .stat-card { padding: 1.1rem; }
    .stat-value { font-size: 1.9rem; }
    .grid-2 { grid-template-columns: 1fr; gap: 1rem; }
    .hospital-grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 0.75rem; }
    .mapa-grid { grid-template-columns: 1fr; }
    .graph-container { height: clamp(360px, 55vh, 480px); }
    .form-inline { gap: 0.4rem; }
    .form-inline input, .form-inline select { min-width: 0; flex: 1 1 130px; font-size: 0.85rem; }
    .install-card { padding: 1.75rem; }
    .test-summary { width: 100%; justify-content: space-between; }
    .data-table { font-size: 0.84rem; }
    .data-table th, .data-table td { padding: 0.65rem 0.55rem; }
    .topbar-actions { width: 100%; justify-content: space-between; }
    .topbar-actions .btn span { display: none; }
    .topbar-actions .btn { padding: 0.6rem 0.8rem; }
    .topbar-actions .btn-lg { padding: 0.75rem 1rem; font-size: 0.9rem; }
}

/* Phones */
@media (max-width: 600px) {
    .topbar { flex-wrap: wrap; }
    .topbar-left { width: 100%; }
    .topbar-actions { width: 100%; gap: 0.5rem; }
    .clock { font-size: 0.78rem; padding: 0.4rem 0.7rem; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .hospital-grid { grid-template-columns: 1fr; }
    .stat-value { font-size: 1.65rem; }
    .stat-card { padding: 0.95rem; }
    .card { padding: 1rem; border-radius: 12px; }
    .content { padding: 0.85rem; }
    .install-card { padding: 1.25rem; border-radius: 14px; }
    .install-icon { width: 60px; height: 60px; }
    .install-header h1 { font-size: 1.3rem; }
    .install-actions { flex-direction: column; }
    .install-actions .btn { width: 100%; justify-content: center; }
    .btn { padding: 0.6rem 0.95rem; font-size: 0.88rem; }
    .btn-lg { padding: 0.8rem 1.2rem; font-size: 0.94rem; }
    .test-counter { font-size: 1.3rem; padding: 0.3rem 0.75rem; }
    .tabs { gap: 0.1rem; }
    .tab { padding: 0.55rem 0.75rem; font-size: 0.85rem; }
    .path-flow { gap: 0.35rem; }
    .path-node { padding: 0.3rem 0.6rem; font-size: 0.78rem; }
    .graph-container { height: clamp(320px, 50vh, 420px); }
    .graph-controls { padding: 0.7rem; gap: 0.5rem; }
    .graph-controls .field { width: 100%; }
    .graph-buttons { width: 100%; flex-wrap: wrap; }
    .graph-buttons .btn { flex: 1 1 auto; justify-content: center; }
    .form-actions { width: 100%; }
    .form-actions .btn { width: 100%; justify-content: center; }
    .info-box { padding: 0.85rem 0.95rem; font-size: 0.84rem; }
    .alert { font-size: 0.85rem; padding: 0.7rem 0.9rem; }
    .badge { padding: 0.25rem 0.55rem; font-size: 0.65rem; }
    .table-wrapper { margin: 0 -1rem; padding: 0 1rem; }
    .data-table { font-size: 0.78rem; }
    .data-table th, .data-table td { padding: 0.55rem 0.5rem; white-space: nowrap; }
    .rota-cell { white-space: normal; min-width: 200px; }
}

/* Small phones */
@media (max-width: 420px) {
    .stats-grid { grid-template-columns: 1fr; }
    .topbar-actions .clock { display: none; }
    .brand-title { font-size: 0.95rem; }
    .brand-sub { font-size: 0.72rem; }
    .menu-item { padding: 0.7rem 0.85rem; font-size: 0.9rem; }
    .card-header h2 { font-size: 1.05rem; }
    .stat-value { font-size: 1.5rem; }
    .install-card { padding: 1rem; }
}

/* Reduce motion preference */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}
