:root {
    --primary: #002e6b;
    --hover: #1d63b8;
    --accent: #22c3ff;
    --bg-light: #f0f2f5;
    --panel-bg: #ffffff;
    --text: #1a2530;
    --text-muted: #5c6b7a;
    --line: #e2e8f0;
    --shadow: 0 4px 24px rgba(0, 46, 107, 0.08);
    --radius: 12px;
    --sidebar-w: 268px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    margin: 0;
    font-family: "Inter", system-ui, -apple-system, Segoe UI, sans-serif;
    color: var(--text);
    background: var(--bg-light);
    font-size: 15px;
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
}

/* ---------- Auth ---------- */
.auth-body {
    min-height: 100vh;
    margin: 0;
    position: relative;
    overflow-x: hidden;
}

.auth-bg {
    position: fixed;
    inset: 0;
    z-index: 0;
    background: linear-gradient(145deg, #001a3d 0%, #002e6b 45%, #0a4a8f 100%);
}

.auth-bg-video,
.auth-bg-image {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.auth-bg-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(0, 20, 50, 0.55) 0%, rgba(0, 46, 107, 0.72) 100%);
    z-index: 1;
}

.auth-shell {
    position: relative;
    z-index: 2;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem 2.5rem;
    gap: 1.25rem;
}

.auth-card {
    width: min(100%, 420px);
    background: #fff;
    border-radius: var(--radius);
    padding: 1.5rem 1.6rem 1.6rem;
    border: 1px solid rgba(255, 255, 255, 0.35);
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.28);
}

.auth-card--glass {
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.auth-login-logo {
    text-align: center;
    margin: 0 0 0.35rem;
}
.auth-login-logo img {
    max-width: min(100%, 260px);
    height: auto;
    display: block;
    margin: 0 auto;
    object-fit: contain;
}

.auth-madeby {
    text-align: center;
}
.auth-madeby img {
    max-width: 180px;
    height: auto;
    opacity: 0.92;
    filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.2));
}

.auth-brand { margin: 0 0 0.75rem; text-align: center; }
.auth-brand img { max-width: min(100%, 260px); height: auto; display: block; margin: 0 auto; object-fit: contain; }
.auth-tagline { margin: 0 0 1.1rem; color: var(--text-muted); font-size: 0.9rem; text-align: center; }
.auth-card h1 { margin: 0 0 .5rem; color: var(--primary); font-size: 1.35rem; font-weight: 700; }
.auth-card p { margin: 0 0 1rem; color: var(--text-muted); font-size: .9rem; }
.auth-card label { display: block; margin: .6rem 0 .3rem; font-weight: 600; font-size: .85rem; }
.auth-card input {
    width: 100%;
    border: 1px solid #cad5df;
    border-radius: 10px;
    padding: .7rem .85rem;
    outline: none;
    transition: border-color .2s, box-shadow .2s;
}
.auth-card input:focus {
    border-color: var(--hover);
    box-shadow: 0 0 0 3px rgba(34, 195, 255, 0.18);
}

.btn-primary {
    width: 100%;
    margin-top: 1rem;
    border: 0;
    border-radius: 10px;
    padding: .78rem;
    color: #fff;
    background: linear-gradient(180deg, #003d8a 0%, var(--primary) 100%);
    cursor: pointer;
    font-weight: 600;
    font-family: inherit;
    transition: transform .15s, box-shadow .2s;
}
.btn-primary:hover { box-shadow: 0 6px 20px rgba(0, 46, 107, 0.25); transform: translateY(-1px); }

.link-muted { display: inline-block; margin-top: 1rem; color: var(--primary); text-decoration: none; font-weight: 500; font-size: .9rem; }

.auth-form-pro .auth-field-label {
    margin-top: 0.85rem;
}

.auth-form-pro .auth-field-label:first-of-type {
    margin-top: 0.15rem;
}

.auth-terms {
    display: flex;
    align-items: flex-start;
    gap: 0.55rem;
    margin-top: 1rem;
    font-size: 0.82rem;
    line-height: 1.45;
    color: var(--text-muted);
    font-weight: 500;
    cursor: pointer;
}

.auth-terms input[type="checkbox"] {
    width: auto;
    margin-top: 0.2rem;
    flex-shrink: 0;
    accent-color: var(--primary);
}

.auth-terms a {
    color: var(--primary);
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.auth-forgot-link {
    display: block;
    text-align: center;
    margin-top: 0.75rem;
}

.auth-version {
    margin: 1.15rem 0 0;
    text-align: center;
    font-size: 0.75rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted);
    font-weight: 600;
}

.auth-card--glass.auth-card--pro {
    width: min(100%, 440px);
    padding: 1.75rem 1.85rem 1.5rem;
    border-radius: 16px;
    box-shadow: 0 28px 70px rgba(0, 15, 40, 0.32), 0 0 0 1px rgba(255, 255, 255, 0.2);
}

.flash {
    border-radius: 10px;
    padding: .65rem .9rem;
    margin: .75rem 0;
    font-size: .88rem;
}
.flash.error { background: #fff0f0; color: #9b2c2c; border: 1px solid #f5c2c2; }
.flash.success { background: #ecfdf3; color: #166534; border: 1px solid #bbf7d0; }

/* ---------- Layout ---------- */
.layout { min-height: 100vh; display: flex; }

.sidebar {
    width: var(--sidebar-w);
    min-height: 100vh;
    background: linear-gradient(180deg, #002e6b 0%, #001f4a 100%);
    color: #e8f8ff;
    position: fixed;
    left: 0;
    top: 0;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 1rem 0.75rem 1rem;
    box-shadow: 4px 0 32px rgba(0, 0, 0, 0.12);
    z-index: 100;
}

.sidebar-inner { flex: 1; display: flex; flex-direction: column; min-height: 0; }

/* Logo: imagen ocupa todo el ancho del sidebar, sin texto al lado */
.brand-full {
    display: block;
    padding: 0.35rem 0.5rem 1.25rem;
    margin: 0 0 0.25rem;
    margin-bottom: 0.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    text-decoration: none;
    transition: opacity .2s;
}
.brand-full:hover { opacity: 0.92; }
.brand-full img {
    display: block;
    width: 100%;
    height: auto;
    max-height: 64px;
    object-fit: contain;
    object-position: left center;
}

.menu {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 0 1px 1rem;
}

.menu-link {
    color: rgba(255, 255, 255, 0.88);
    text-decoration: none;
    padding: 0.65rem 0.9rem;
    border-radius: 10px;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 500;
    font-size: 0.9rem;
    position: relative;
    overflow: hidden;
    transition: background .22s ease, color .2s, transform .18s ease;
}

.menu-link::before {
    content: "";
    position: absolute;
    left: 0;
    top: 8px;
    bottom: 8px;
    width: 3px;
    border-radius: 0 4px 4px 0;
    background: var(--accent);
    opacity: 0;
    transform: scaleY(0.6);
    transition: opacity .2s, transform .22s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.menu-link .nav-ico {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
    opacity: 0.92;
}

.menu-link:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    transform: translateX(2px);
}

.menu-link.active {
    background: rgba(255, 255, 255, 0.16);
    color: #fff;
    font-weight: 600;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
    transform: translateX(0);
}

.menu-link.active::before {
    opacity: 1;
    transform: scaleY(1);
}

.menu-label { flex: 1; }

.logout {
    color: rgba(255, 255, 255, 0.85);
    text-decoration: none;
    margin: 0.5rem 0.4rem 0;
    padding: 0.6rem 0.75rem;
    font-size: 0.88rem;
    border-radius: 8px;
    transition: background .2s;
}
.logout:hover { background: rgba(255, 255, 255, 0.1); color: #fff; }

.main {
    margin-left: var(--sidebar-w);
    width: calc(100% - var(--sidebar-w));
    padding: 0 1.25rem 2rem;
    min-height: 100vh;
}

.topbar {
    min-height: 58px;
    background: #fff;
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.65rem 0.25rem;
    position: sticky;
    top: 0;
    z-index: 10;
    margin: 0 -0.25rem;
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.04);
}

.topbar--full {
    margin-left: -1.25rem;
    margin-right: -1.25rem;
    padding-left: 1.25rem;
    padding-right: 1.25rem;
    width: calc(100% + 2.5rem);
    max-width: none;
    box-sizing: border-box;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    min-width: 0;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-shrink: 0;
}

.topbar-title {
    color: var(--primary);
    font-weight: 700;
    font-size: 1.05rem;
    letter-spacing: -0.02em;
    min-width: 0;
}

.topbar-user {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.1rem;
}
.topbar-user-name { font-size: 0.88rem; font-weight: 600; color: var(--text); }
.topbar-user-role { font-size: 0.75rem; color: var(--text-muted); text-transform: lowercase; }

.topbar-icon-btn {
    position: relative;
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border: none;
    border-radius: 10px;
    background: var(--bg-light);
    color: var(--primary);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.topbar-icon-btn:hover { background: #e8eef5; }

.topbar-bell { display: grid; place-items: center; line-height: 0; }

.topbar-notif-dot {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #e11d48;
    border: 2px solid #fff;
}

.topbar-notif-wrap {
    position: relative;
}

.topbar-notif-panel {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    width: min(360px, calc(100vw - 2rem));
    max-height: min(70vh, 420px);
    overflow: auto;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: 0 16px 40px rgba(15, 23, 42, 0.12);
    z-index: 50;
}

.topbar-notif-head {
    padding: 0.65rem 0.85rem;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    background: #fff;
}

.topbar-notif-list {
    padding: 0.35rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.topbar-notif-item {
    padding: 0.55rem 0.65rem;
    border-radius: 8px;
    background: #f8fafc;
    font-size: 0.82rem;
    line-height: 1.4;
}
.topbar-notif-item strong {
    display: block;
    color: var(--text);
    font-weight: 600;
    margin-bottom: 0.15rem;
}
.topbar-notif-item span {
    color: var(--text-muted);
    font-size: 0.78rem;
}
.topbar-notif-item time {
    display: block;
    margin-top: 0.35rem;
    font-size: 0.68rem;
    color: #94a3b8;
}

.topbar-user-wrap {
    position: relative;
}

.topbar-user-trigger {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    max-width: min(220px, 42vw);
    padding: 0.35rem 0.5rem 0.35rem 0.65rem;
    border: 1px solid transparent;
    border-radius: 10px;
    background: transparent;
    cursor: pointer;
    font: inherit;
    text-align: left;
    transition: background 0.15s, border-color 0.15s;
}
.topbar-user-trigger:hover {
    background: var(--bg-light);
    border-color: var(--line);
}

.topbar-user-trigger-text {
    display: flex;
    flex-direction: column;
    gap: 0.05rem;
    min-width: 0;
}

.topbar-user-trigger .topbar-user-name {
    font-size: 0.86rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topbar-user-trigger .topbar-user-role {
    font-size: 0.72rem;
    text-transform: none;
}

.topbar-chevron {
    color: var(--text-muted);
    font-size: 0.65rem;
    flex-shrink: 0;
}

.topbar-user-menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 220px;
    padding: 0.35rem;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: 0 16px 40px rgba(15, 23, 42, 0.12);
    z-index: 50;
}

.topbar-menu-item {
    display: block;
    padding: 0.55rem 0.75rem;
    border-radius: 8px;
    color: var(--text);
    text-decoration: none;
    font-size: 0.88rem;
    transition: background 0.12s;
}
.topbar-menu-item:hover {
    background: var(--bg-light);
}

.topbar-menu-item--accent {
    color: var(--accent, #0d6efd);
    font-weight: 600;
}

.topbar-menu-item--danger {
    color: #b91c1c;
    font-weight: 600;
}

.topbar-menu-divider {
    height: 1px;
    margin: 0.35rem 0.25rem;
    background: var(--line);
}

.menu-toggle {
    display: none;
    border: 0;
    background: var(--bg-light);
    font-size: 1.25rem;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    cursor: pointer;
    color: var(--primary);
}

/* ---------- Toolbar & buttons ---------- */
.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
    margin-top: 1rem;
    margin-bottom: 0.5rem;
}

.toolbar-search {
    display: flex;
    flex: 1;
    min-width: 200px;
    gap: 0.5rem;
    align-items: stretch;
}

.toolbar-search input[type="search"],
.toolbar-search input[type="text"] {
    flex: 1;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 0.55rem 0.85rem;
    font: inherit;
    background: #fff;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    transition: border-color .2s, box-shadow .2s;
}
.toolbar-search input:focus {
    outline: none;
    border-color: var(--hover);
    box-shadow: 0 0 0 3px rgba(34, 195, 255, 0.15);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.55rem 1rem;
    border-radius: 10px;
    font-family: inherit;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
    text-decoration: none;
    transition: transform .15s, box-shadow .2s, background .2s, border-color .2s;
    white-space: nowrap;
}

.btn-primary {
    background: linear-gradient(180deg, #003d8a 0%, var(--primary) 100%);
    color: #fff;
    border-color: rgba(0, 0, 0, 0.06);
    box-shadow: 0 2px 8px rgba(0, 46, 107, 0.2);
}
.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(0, 46, 107, 0.28);
}

.btn-secondary {
    background: #fff;
    color: var(--primary);
    border-color: #c5d4e3;
}
.btn-secondary:hover {
    border-color: var(--hover);
    background: #f8fbff;
}

.btn-ghost {
    background: transparent;
    color: var(--primary);
    border-color: transparent;
    text-decoration: underline;
    text-underline-offset: 3px;
    box-shadow: none;
}
.btn-ghost:hover { color: var(--hover); }

.btn-danger {
    background: #fef2f2;
    color: #b91c1c;
    border-color: #fecaca;
}
.btn-danger:hover { background: #fee2e2; border-color: #f87171; color: #991b1b; }

.btn-sm { padding: 0.4rem 0.75rem; font-size: 0.82rem; border-radius: 8px; }

.btn-icon {
    width: 34px;
    height: 34px;
    padding: 0;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: #fff;
    cursor: pointer;
    color: var(--text-muted);
    transition: border-color .2s, color .2s;
}
.btn-icon:hover { border-color: var(--accent); color: var(--primary); }

.inline-form { display: inline; margin: 0; padding: 0; }

/* ---------- Panels ---------- */
.panel-elevated {
    background: var(--panel-bg);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 1rem 1.1rem;
    box-shadow: var(--shadow);
}

.panel-grid.panel-elevated { margin-top: 0.85rem; }

.panel-grid.panel-elevated:first-of-type { margin-top: 1rem; }

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.panel-title {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    color: #1e3a5f;
    letter-spacing: -0.02em;
}

.panel-meta { font-size: 0.8rem; color: var(--text-muted); }

.panel-tools { display: flex; gap: 0.45rem; align-items: center; flex-wrap: wrap; }

/* KPI */
.kpi-row {
    margin-top: 1rem;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.85rem;
}

.kpi {
    border-radius: var(--radius);
    border: 1px solid transparent;
    padding: 0.95rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.85rem;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
}

.kpi-ico {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    flex-shrink: 0;
}
.kpi-ico svg { width: 22px; height: 22px; color: inherit; }

.kpi-label { font-size: 0.78rem; color: rgba(255, 255, 255, 0.88); font-weight: 500; text-transform: uppercase; letter-spacing: 0.04em; }
.kpi-value { font-size: 1.55rem; font-weight: 800; color: #fff; margin-top: 0.1rem; letter-spacing: -0.03em; }

.kpi-blue { background: linear-gradient(180deg, #1a6fff 0%, #0d6efd 100%); }
.kpi-blue .kpi-ico { background: rgba(255, 255, 255, 0.22); color: #fff; }
.kpi-slate { background: linear-gradient(180deg, #5a6268 0%, #495057 100%); }
.kpi-slate .kpi-ico { background: rgba(255, 255, 255, 0.18); color: #fff; }
.kpi-cyan { background: linear-gradient(180deg, #1fb8d4 0%, #17a2b8 100%); }
.kpi-cyan .kpi-ico { background: rgba(255, 255, 255, 0.2); color: #fff; }
.kpi-gray { background: linear-gradient(180deg, #7a8288 0%, #6c757d 100%); }
.kpi-gray .kpi-ico { background: rgba(255, 255, 255, 0.2); color: #fff; }

.grid-2 {
    margin-top: 1rem;
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1rem;
}

.grid-2-tall { align-items: stretch; }

.chart-box {
    width: 100%;
    min-height: 180px;
    padding: 0.25rem 0;
}

.chart-box--tall {
    min-height: 260px;
    height: 280px;
}

canvas { max-width: 100%; display: block; }
#chartPatientsLine,
#chartAppointmentsBars {
    width: 100%;
    height: 260px;
}

.dash-stat-cards {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.dash-stat-card {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 1rem 1.1rem;
    box-shadow: 0 2px 12px rgba(0, 46, 107, 0.06);
}

.dash-stat-card-head {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.dash-stat-card-value {
    font-size: 1.65rem;
    font-weight: 800;
    color: var(--primary);
    margin: 0.35rem 0 0;
    line-height: 1.15;
}

.dash-stat-card-foot {
    margin: 0.5rem 0 0;
    font-size: 0.78rem;
    color: var(--text-muted);
    line-height: 1.35;
}

.dash-trend {
    font-weight: 700;
}

.dash-trend--up { color: #16a34a; }
.dash-trend--down { color: #dc2626; }

.dash-chartjs-row {
    grid-template-columns: 1fr 1fr;
}

.dash-analytics {
    margin-top: 1rem;
}

.dash-analytics-head {
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
}

.dash-period-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-left: auto;
}

.dash-period-tab {
    border: 1px solid var(--line);
    background: #f8fafc;
    color: var(--text-muted);
    font: inherit;
    font-size: 0.8rem;
    font-weight: 600;
    padding: 0.4rem 0.75rem;
    border-radius: 8px;
    cursor: pointer;
}

.dash-period-tab:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.dash-period-tab.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.dash-analytics-body {
    display: grid;
    grid-template-columns: minmax(0, 1.6fr) minmax(200px, 0.9fr);
    gap: 1.25rem;
    margin-top: 0.75rem;
    align-items: start;
}

.dash-analytics-chart-wrap {
    min-height: 300px;
    height: 320px;
    position: relative;
}

#chartTrendBars {
    width: 100%;
    height: 300px;
}

.dash-ranking-title {
    margin: 0 0 0.65rem;
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--text);
}

.dash-ranking-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.dash-ranking-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.82rem;
    padding: 0.35rem 0;
    border-bottom: 1px solid var(--line);
}

.dash-ranking-item:last-child { border-bottom: 0; }

.dash-rank-badge {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: #e8ecf1;
    color: #64748b;
    font-weight: 800;
    font-size: 0.72rem;
    display: grid;
    place-items: center;
    flex-shrink: 0;
}

.dash-rank-badge--top {
    background: var(--primary);
    color: #fff;
}

.dash-rank-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 600;
}

.dash-rank-count {
    font-weight: 800;
    color: var(--primary);
    font-variant-numeric: tabular-nums;
}

.dash-ranking-empty {
    color: var(--text-muted);
    font-size: 0.85rem;
    padding: 0.25rem 0;
}

@media (max-width: 1100px) {
    .dash-stat-cards { grid-template-columns: repeat(2, 1fr); }
    .dash-chartjs-row { grid-template-columns: 1fr; }
    .dash-analytics-body { grid-template-columns: 1fr; }
}

/* Team & map widgets */
.widget-team .team-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.team-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--line);
}
.team-item:last-child { border-bottom: 0; }

.team-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--primary));
    color: #fff;
    font-weight: 700;
    font-size: 0.75rem;
    display: grid;
    place-items: center;
    flex-shrink: 0;
}

.team-meta { display: flex; flex-direction: column; gap: 0.15rem; min-width: 0; }
.team-name { font-weight: 600; font-size: 0.9rem; color: var(--text); }
.team-sub { font-size: 0.78rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.team-empty { color: var(--text-muted); font-size: 0.9rem; padding: 0.5rem 0; }

.map-card { padding: 0.25rem 0; }
.map-visual { border-radius: 10px; overflow: hidden; margin-bottom: 0.75rem; }
.map-svg { width: 100%; height: auto; display: block; }
.map-stats {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}
.map-stat {
    flex: 1;
    min-width: 72px;
    background: #f8fafc;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 0.55rem 0.65rem;
    text-align: center;
}
.map-stat-label { display: block; font-size: 0.72rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.map-stat strong { font-size: 1.15rem; color: var(--primary); }
.map-foot { margin: 0.65rem 0 0; font-size: 0.78rem; color: var(--text-muted); }

/* Forms */
.form-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.75rem;
    margin-top: 0.5rem;
}

.form-grid.compact { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.field-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.field input,
.field select,
.field textarea {
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 0.55rem 0.75rem;
    font: inherit;
    background: #fff;
    transition: border-color .2s, box-shadow .2s;
}
.field input:focus,
.field select:focus,
.field textarea:focus {
    outline: none;
    border-color: var(--hover);
    box-shadow: 0 0 0 3px rgba(34, 195, 255, 0.12);
}

.field-span-2 { grid-column: span 2; }

.form-actions {
    grid-column: 1 / -1;
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    align-items: center;
    margin-top: 0.5rem;
}

/* Tables */
.table-wrap { overflow: auto; border-radius: 10px; border: 1px solid var(--line); }

.table-pro {
    width: 100%;
    border-collapse: collapse;
    min-width: 640px;
}

.table-pro thead th {
    background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
    color: #475569;
    text-align: left;
    padding: 0.75rem 0.8rem;
    font-weight: 700;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid var(--line);
}

.table-pro tbody td {
    padding: 0.7rem 0.8rem;
    border-bottom: 1px solid #eef2f6;
    font-size: 0.9rem;
}

.table-pro tbody tr:nth-child(even) { background: #fafbfd; }
.table-pro tbody tr:hover { background: #f0f7ff; }

.table-empty {
    text-align: center;
    color: var(--text-muted);
    padding: 2rem 1rem !important;
}

.th-actions { text-align: right; }
.actions-inline { display: flex; align-items: center; justify-content: flex-end; gap: 0.45rem; flex-wrap: wrap; }

.badge {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    background: #e8f4fc;
    color: var(--primary);
}

.badge-warn {
    background: #fef3c7;
    color: #92400e;
}

.inv-row-low {
    background: #fffbeb;
}

/* Notifications */
.notifications-preview {
    margin-top: 1rem;
    padding: 1rem 1.1rem;
}

.notif-section-title {
    margin: 0 0 0.75rem;
    font-size: 0.95rem;
    font-weight: 700;
    color: #334a5f;
}

.notif-list { display: grid; gap: 0.55rem; }

.notif {
    border-left: 4px solid var(--accent);
    background: #f8fbfe;
    padding: 0.6rem 0.75rem;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.notif strong { color: #1f4b66; display: block; font-size: 0.88rem; }
.notif span { font-size: 0.82rem; color: var(--text-muted); }

/* ---------- Pacientes: toolbar, filtros, formulario colapsado ---------- */
.patients-toolbar-panel { margin-top: 1rem; }

.toolbar-rows {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.toolbar-row--actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.toolbar-row--import {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: flex-end;
    padding-top: 0.5rem;
    border-top: 1px solid var(--line);
}

.inline-import {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.45rem;
}

.import-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.patients-filters { margin-top: 0.75rem; }

.filters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 0.75rem;
    margin-top: 0.35rem;
}

.filters-grid .field.field-check {
    display: flex;
    align-items: center;
    min-height: 2.5rem;
}

.patients-list-panel { margin-top: 0.75rem; }

.patient-form-panel.is-collapsed {
    display: none !important;
}

.th-check,
.td-check {
    width: 40px;
    text-align: center;
}

.btn-check-label {
    cursor: pointer;
    gap: 0.35rem;
    margin: 0;
    font-weight: 600;
}

.chk-in-btn {
    margin: 0;
    accent-color: var(--primary);
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    border: 0 !important;
}

/* Legacy */
.panel-grid:not(.panel-elevated) {
    margin-top: 0.9rem;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 0.9rem;
}

.btn-min {
    border: 1px solid #c8d4de;
    background: #fff;
    border-radius: 8px;
    padding: 0.4rem 0.8rem;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.85rem;
}

.btn-min:hover { border-color: var(--hover); color: var(--primary); }
.btn-min.danger:hover { border-color: #ff9a9a; color: #a34141; }

@media (max-width: 1080px) {
    .kpi-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid-2 { grid-template-columns: 1fr; }
}

@media (max-width: 850px) {
    .menu-toggle { display: inline-flex; align-items: center; justify-content: center; }
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    }
    .sidebar.show { transform: translateX(0); }
    .main { margin-left: 0; width: 100%; }
}

@media (max-width: 560px) {
    .kpi-row { grid-template-columns: 1fr; }
    .topbar-title { font-size: 0.95rem; }
    .form-grid,
    .form-grid.compact { grid-template-columns: 1fr; }
    .field-span-2 { grid-column: span 1; }
}
