/* =============================================================================
   Agendia — Design system (Admin / Superadmin)
   ============================================================================= */
:root {
    --bg: #f1f5f9;
    --bg-elevated: #ffffff;
    --text: #0f172a;
    --text-secondary: #475569;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --border-light: #f1f5f9;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-soft: rgba(37, 99, 235, 0.08);
    --sidebar-bg: #111827;
    --sidebar-border: rgba(255, 255, 255, 0.06);
    --sidebar-text: #9ca3af;
    --sidebar-hover: rgba(255, 255, 255, 0.05);
    --sidebar-active-bg: rgba(37, 99, 235, 0.15);
    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
    --shadow: 0 4px 6px -1px rgba(15, 23, 42, 0.07), 0 2px 4px -2px rgba(15, 23, 42, 0.05);
    --shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.08);
    --transition: 0.2s ease;
    --content-max: 1280px;
    --sidebar-width: 260px;
    --topbar-height: 64px;
    --font: 'Inter', system-ui, -apple-system, sans-serif;
}

[data-theme="dark"] {
    --bg: #0b1120;
    --bg-elevated: #111827;
    --text: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    --border: #1e293b;
    --border-light: #0f172a;
    --sidebar-bg: #030712;
}

*, *::before, *::after { box-sizing: border-box; }

html {
    -webkit-text-size-adjust: 100%;
    -webkit-font-smoothing: antialiased;
}

body {
    margin: 0;
    font-family: var(--font);
    font-size: 0.9375rem;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
}

a { color: var(--primary); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--primary-hover); }

/* ─── Auth ─── */
.layout-auth {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem max(1.5rem, env(safe-area-inset-right)) max(1.5rem, env(safe-area-inset-bottom)) max(1.5rem, env(safe-area-inset-left));
    background: linear-gradient(145deg, #0f172a 0%, #1e3a8a 50%, #2563eb 100%);
}
.auth-card {
    background: var(--bg-elevated);
    padding: 2.5rem;
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
}
.auth-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.375rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 0.25rem;
}
.auth-brand-mark {
    width: 40px;
    height: 40px;
    background: var(--primary);
    color: #fff;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}
.auth-card h1 { font-size: 1.125rem; font-weight: 600; color: var(--text-secondary); margin: 0 0 1.75rem; }

/* ─── Admin shell ─── */
.layout-admin { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 200;
    border-right: 1px solid var(--sidebar-border);
    transition: transform var(--transition);
}

.sidebar-brand {
    height: var(--topbar-height);
    padding: 0 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-bottom: 1px solid var(--sidebar-border);
    flex-shrink: 0;
}
.brand-logo {
    width: 38px;
    height: 38px;
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: #fff;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.1rem;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
}
.brand-name { color: #fff; font-weight: 600; font-size: 1.125rem; letter-spacing: -0.02em; }

.sidebar-nav {
    flex: 1;
    padding: 1rem 0.75rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.7rem 1rem;
    color: var(--sidebar-text);
    text-decoration: none;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 500;
    transition: all var(--transition);
}
.sidebar-link:hover {
    background: var(--sidebar-hover);
    color: #fff;
    text-decoration: none;
}
.sidebar-link.active {
    background: var(--sidebar-active-bg);
    color: #fff;
    box-shadow: inset 3px 0 0 var(--primary);
}
.sidebar-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.85;
    flex-shrink: 0;
}
.sidebar-icon svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.sidebar-footer {
    padding: 1rem 0.75rem;
    border-top: 1px solid var(--sidebar-border);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.sidebar-footer .sidebar-link { flex: 1; }
.sidebar-toggle {
    display: none;
    position: fixed;
    top: max(0.75rem, env(safe-area-inset-top));
    left: max(0.75rem, env(safe-area-inset-left));
    z-index: 201;
    background: var(--sidebar-bg);
    color: #fff;
    border: 1px solid var(--sidebar-border);
    width: 44px;
    height: 44px;
    padding: 0;
    border-radius: var(--radius-sm);
    cursor: pointer;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    box-shadow: var(--shadow);
}

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 199;
    background: rgba(15, 23, 42, 0.45);
    opacity: 0;
    transition: opacity 0.2s ease;
}
.sidebar-backdrop.visible {
    display: block;
    opacity: 1;
}

body.sidebar-open { overflow: hidden; }

.admin-main {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-width: 0;
}

.admin-topbar {
    height: var(--topbar-height);
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border);
    padding: 0 1.75rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: var(--shadow-sm);
}
.topbar-business {
    margin: 0;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.topbar-actions { display: flex; gap: 0.625rem; align-items: center; flex-wrap: wrap; }

.admin-content {
    padding: 1.75rem;
    flex: 1;
    max-width: calc(var(--content-max) + 3.5rem);
    width: 100%;
    margin: 0 auto;
}

/* ─── Page header ─── */
.page-header {
    margin-bottom: 1.75rem;
}
.page-header-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    flex-wrap: wrap;
}
.page-title {
    margin: 0;
    font-size: 1.625rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    color: var(--text);
    line-height: 1.25;
}
.page-desc {
    margin: 0.375rem 0 0;
    font-size: 0.9375rem;
    color: var(--text-muted);
    max-width: 540px;
}

/* ─── Layout grids ─── */
.page-grid {
    display: grid;
    grid-template-columns: minmax(300px, 380px) 1fr;
    gap: 1.5rem;
    align-items: start;
}
.page-grid-wide { grid-template-columns: 1fr; max-width: 900px; }
.page-grid-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 960px) {
    .page-grid, .page-grid-2 { grid-template-columns: 1fr; }
}

.panel {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}
.panel-sticky { position: sticky; top: calc(var(--topbar-height) + 1.5rem); }
.panel-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-light);
    background: linear-gradient(to bottom, var(--bg-elevated), var(--bg));
}
.panel-header h2, .panel-header h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
}
.panel-header p {
    margin: 0.25rem 0 0;
    font-size: 0.8125rem;
    color: var(--text-muted);
}
.panel-body { padding: 1.5rem; }

/* ─── Forms ─── */
.form { display: flex; flex-direction: column; gap: 0; }
.form-section {
    margin-bottom: 2rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid var(--border-light);
}
.form-section:last-child { margin-bottom: 0; padding-bottom: 0; border-bottom: none; }
.form-section-title {
    margin: 0 0 1.25rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
}
.form-group { margin-bottom: 1.125rem; }
.form-group:last-child { margin-bottom: 0; }
.form-label {
    display: block;
    margin-bottom: 0.375rem;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-secondary);
}
.form-control,
.form select,
.form textarea,
.form input[type="text"],
.form input[type="email"],
.form input[type="tel"],
.form input[type="number"],
.form input[type="date"],
.form input[type="time"],
.form input[type="datetime-local"],
.form input[type="password"] {
    display: block;
    width: 100%;
    min-height: 42px;
    padding: 0.625rem 0.875rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-family: inherit;
    background: var(--bg-elevated);
    color: var(--text);
    transition: border-color var(--transition), box-shadow var(--transition);
}
.form textarea { min-height: 100px; resize: vertical; line-height: 1.5; }
.form select[multiple] { min-height: 120px; padding: 0.5rem; }
.form-control:focus,
.form input:focus,
.form select:focus,
.form textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
}
.form-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}
.form-row-3 { grid-template-columns: repeat(3, 1fr); }
.form-span-2 { grid-column: span 2; }
@media (max-width: 640px) {
    .form-row, .form-row-3 { grid-template-columns: 1fr; }
    .form-span-2 { grid-column: span 1; }
}

.color-picker {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.color-picker input[type="color"] {
    width: 48px;
    height: 48px;
    padding: 3px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    background: var(--bg-elevated);
    flex-shrink: 0;
}
.color-picker input[type="color"]::-webkit-color-swatch-wrapper { padding: 2px; }
.color-picker input[type="color"]::-webkit-color-swatch { border-radius: 4px; border: none; }
.color-picker-hint { font-size: 0.8125rem; color: var(--text-muted); }

.form-check {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.75rem 1rem;
    background: var(--bg);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    margin-bottom: 0.625rem;
    cursor: pointer;
    transition: background var(--transition);
}
.form-check:hover { background: var(--primary-soft); }
.form-check input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
    cursor: pointer;
    flex-shrink: 0;
}
.form-check-label { font-size: 0.875rem; font-weight: 500; color: var(--text); cursor: pointer; }
.form-checks { display: flex; flex-direction: column; gap: 0; margin-top: 0.5rem; }
.form-hint { font-size: 0.8125rem; color: var(--text-muted); margin: 0 0 0.5rem; }

.form-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.5rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border-light);
}
.form-actions-flush { border-top: none; padding-top: 0; margin-top: 1rem; }

.hint-box {
    margin-top: 1.5rem;
    padding: 1rem 1.25rem;
    background: var(--primary-soft);
    border: 1px solid rgba(37, 99, 235, 0.15);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    color: var(--text-secondary);
}
.hint-box strong { color: var(--text); }

/* ─── Buttons ─── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    min-height: 40px;
    padding: 0.5rem 1.125rem;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 600;
    font-family: inherit;
    border: none;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    white-space: nowrap;
}
.btn-primary {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 1px 2px rgba(37, 99, 235, 0.2);
}
.btn-primary:hover {
    background: var(--primary-hover);
    color: #fff;
    text-decoration: none;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
    transform: translateY(-1px);
}
.btn-outline {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    color: var(--text-secondary);
}
.btn-outline:hover {
    background: var(--bg);
    border-color: var(--text-muted);
    color: var(--text);
    text-decoration: none;
}
.btn-danger { background: #ef4444; color: #fff; }
.btn-danger:hover { background: #dc2626; color: #fff; }
.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    min-height: 36px;
    padding: 0.375rem 0.625rem;
}
.btn-ghost:hover { background: #fef2f2; color: #ef4444; }
.btn-sm { min-height: 34px; padding: 0.375rem 0.875rem; font-size: 0.8125rem; }
.btn-lg { min-height: 48px; padding: 0.75rem 1.5rem; font-size: 1rem; }
.btn-block { width: 100%; }
.btn-icon {
    background: rgba(255,255,255,0.06);
    border: 1px solid var(--sidebar-border);
    border-radius: var(--radius-sm);
    color: var(--sidebar-text);
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1rem;
    transition: all var(--transition);
    flex-shrink: 0;
}
.btn-icon:hover { background: rgba(255,255,255,0.1); color: #fff; }

/* ─── Alerts ─── */
.alert {
    padding: 0.875rem 1.125rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1.25rem;
    font-size: 0.875rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.alert-success { background: #ecfdf5; color: #047857; border: 1px solid #a7f3d0; }
.alert-error { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }

/* ─── Tables & lists ─── */
.table-wrap {
    overflow-x: auto;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    background: var(--bg-elevated);
    box-shadow: var(--shadow-sm);
}
.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}
.table th {
    padding: 0.875rem 1.25rem;
    text-align: left;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.table td {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-light);
    vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: rgba(37, 99, 235, 0.02); }
.table-actions { display: flex; gap: 0.375rem; align-items: center; white-space: nowrap; }
.table-compact td, .table-compact th { padding: 0.75rem 1rem; }

.resource-dot {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    vertical-align: middle;
    margin-right: 0.5rem;
    border: 2px solid rgba(255,255,255,0.8);
    box-shadow: 0 0 0 1px var(--border);
}

.data-list { display: flex; flex-direction: column; gap: 0.75rem; }
.data-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
    transition: box-shadow var(--transition);
}
.data-card:hover { box-shadow: var(--shadow); }
.data-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}
.data-card-title { font-weight: 600; font-size: 0.9375rem; margin: 0; }

.empty-state {
    text-align: center;
    padding: 3rem 2rem;
    color: var(--text-muted);
}
.empty-state-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 1rem;
    background: var(--bg);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}
.empty-state h3 { margin: 0 0 0.5rem; color: var(--text-secondary); font-size: 1rem; }
.empty-state p { margin: 0; font-size: 0.875rem; }

/* ─── Badges & stats ─── */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.625rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: capitalize;
}
.badge-activo, .badge-confirmada, .badge-completada { background: #dcfce7; color: #15803d; }
.badge-prueba, .badge-pendiente { background: #fef9c3; color: #a16207; }
.badge-suspendido, .badge-cancelada { background: #fee2e2; color: #b91c1c; }
.badge-no_show { background: #f3e8ff; color: #7e22ce; }

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.stat-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.375rem 1.5rem;
    box-shadow: var(--shadow-sm);
}
.stat-card.accent { border-color: rgba(37, 99, 235, 0.3); }
.stat-card.highlight {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    color: #fff;
    border: none;
}
.stat-value { display: block; font-size: 1.875rem; font-weight: 700; letter-spacing: -0.03em; line-height: 1.1; }
.stat-label { font-size: 0.8125rem; color: var(--text-muted); margin-top: 0.375rem; font-weight: 500; }
.stat-card.highlight .stat-label { color: rgba(255,255,255,0.75); }

.rank-list { list-style: none; padding: 0; margin: 0; }
.rank-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border-light);
    font-size: 0.875rem;
}
.rank-list li:last-child { border-bottom: none; }

.filter-bar {
    display: flex;
    gap: 1rem;
    align-items: flex-end;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    padding: 1.25rem;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

/* ─── Calendar ─── */
.calendar-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
    padding: 1rem 1.25rem;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}
.calendar-nav { display: flex; align-items: center; gap: 0.75rem; }
.calendar-title { font-weight: 600; font-size: 1.0625rem; min-width: 160px; text-align: center; }
.calendar-views {
    display: flex;
    gap: 0.25rem;
    background: var(--bg);
    padding: 0.25rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-light);
}
.calendar-views .btn-sm { border-radius: 6px; }
.calendar-views .btn-primary { box-shadow: var(--shadow-sm); }

.calendar-list { display: flex; flex-direction: column; gap: 0.625rem; }
.cita-card {
    display: grid;
    grid-template-columns: 110px 1fr auto;
    gap: 1.25rem;
    align-items: center;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-left: 4px solid var(--primary);
    border-radius: var(--radius);
    padding: 1.125rem 1.25rem;
    transition: all var(--transition);
    animation: fadeIn 0.35s ease;
}
.cita-card:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.cita-card.estado-cancelada { border-left-color: #ef4444; }
.cita-card.estado-completada { border-left-color: #22c55e; }
.cita-card.estado-pendiente { border-left-color: #eab308; }
.cita-card.estado-noshow { border-left-color: #a855f7; }
.cita-time { font-size: 0.8125rem; color: var(--text-muted); line-height: 1.4; }
.cita-time strong { display: block; color: var(--text); font-size: 0.9375rem; margin-bottom: 0.125rem; }
.cita-body h3 { margin: 0 0 0.25rem; font-size: 0.9375rem; font-weight: 600; }
.cita-body p { margin: 0; font-size: 0.8125rem; color: var(--text-muted); }

.month-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px;
    background: var(--border);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}
.month-header {
    background: var(--bg);
    padding: 0.625rem;
    text-align: center;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
}
.month-cell {
    background: var(--bg-elevated);
    min-height: 100px;
    padding: 0.5rem;
    font-size: 0.75rem;
}
.month-cell.today { background: var(--primary-soft); }
.month-cell.empty { background: var(--bg); }
.month-day { font-weight: 600; display: block; margin-bottom: 0.375rem; font-size: 0.8125rem; }
.month-event {
    display: block;
    padding: 0.2rem 0.4rem;
    margin-bottom: 2px;
    border-radius: 4px;
    background: var(--primary-soft);
    color: var(--primary);
    font-size: 0.6875rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-decoration: none;
    font-weight: 500;
}
.month-event:hover { background: rgba(37, 99, 235, 0.15); text-decoration: none; }
.month-event.estado-pending { background: #fef9c3; color: #a16207; }
.month-event.estado-confirmed { background: var(--primary-soft); color: var(--primary); }
.month-event.estado-completed { background: #dcfce7; color: #15803d; }
.month-event.estado-cancelled { background: #fee2e2; color: #b91c1c; }
.month-event.estado-noshow { background: #f3e8ff; color: #7e22ce; }
.month-event-meta { display: block; font-size: 0.625rem; opacity: 0.85; margin-top: 1px; }
.month-empty { display: block; color: var(--text-muted); font-size: 0.75rem; margin-top: 0.5rem; }
.month-cell-expanded { min-height: 320px; }
.month-grid-day { grid-template-columns: 1fr; }
.month-grid-day .month-cell-expanded { min-height: 420px; }

.calendar-month {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.legend {
    display: flex;
    gap: 1.25rem;
    flex-wrap: wrap;
    margin-top: 1.5rem;
    font-size: 0.8125rem;
    color: var(--text-muted);
}
.dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 0.375rem;
}
.dot.confirmed { background: var(--primary); }
.dot.pending { background: #eab308; }
.dot.completed { background: #22c55e; }
.dot.cancelled { background: #ef4444; }
.dot.noshow { background: #a855f7; }

/* ─── Superadmin ─── */
.layout-superadmin .sidebar-brand .badge-sa {
    font-size: 0.625rem;
    background: rgba(37, 99, 235, 0.3);
    color: #93c5fd;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    margin-left: auto;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ─── Public hero ─── */
.layout-public { min-height: 100vh; }
.hero {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(145deg, #0f172a 0%, #1e3a8a 45%, #2563eb 100%);
    color: #fff;
    text-align: center;
    padding: 2rem;
}
.hero-inner { max-width: 640px; }
.hero-brand { font-size: 2.25rem; font-weight: 800; margin-bottom: 1rem; letter-spacing: -0.03em; }
.hero h1 { font-size: clamp(1.75rem, 4vw, 2.75rem); margin: 0 0 1rem; font-weight: 700; letter-spacing: -0.02em; }
.hero p { font-size: 1.125rem; opacity: 0.88; margin-bottom: 2rem; line-height: 1.6; }
.hero-actions { display: flex; gap: 1rem; justify-content: center; flex-wrap: wrap; }
.hero .btn-outline { border-color: rgba(255,255,255,0.35); color: #fff; background: rgba(255,255,255,0.05); }
.hero .btn-outline:hover { background: rgba(255,255,255,0.12); border-color: rgba(255,255,255,0.5); }

/* ─── Inline edit row (tables) ─── */
.inline-edit-row td { padding: 0.75rem 1rem; }
.inline-edit-row .form-control,
.inline-edit-row select {
    min-height: 36px;
    padding: 0.375rem 0.625rem;
    font-size: 0.8125rem;
}
.inline-edit-row input[type="color"] {
    width: 36px;
    height: 36px;
    padding: 2px;
    border-radius: 6px;
    border: 1px solid var(--border);
    cursor: pointer;
    vertical-align: middle;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: none; }
}

/* ─── Mobile & touch ─── */
@media (max-width: 960px) {
    .panel-sticky { position: static; top: auto; }
}

@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); width: min(280px, 88vw); }
    .sidebar.open { transform: translateX(0); }
    .sidebar-toggle { display: flex; }

    .admin-main { margin-left: 0; }
    .admin-content {
        padding: 1rem max(1rem, env(safe-area-inset-right)) max(1.5rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
    }

    .layout-superadmin .admin-topbar {
        padding: 0.75rem 1rem 0.75rem 3.75rem;
        min-height: var(--topbar-height);
    }
    .layout-superadmin .admin-topbar h1 {
        font-size: 1.125rem;
    }

    .admin-topbar {
        flex-direction: column;
        align-items: stretch;
        height: auto;
        min-height: var(--topbar-height);
        padding: 0.75rem 1rem 0.75rem 3.75rem;
        gap: 0.625rem;
    }
    .topbar-actions { width: 100%; }
    .topbar-actions .btn { flex: 1; min-height: 44px; }

    .page-header { margin-bottom: 1.25rem; }
    .page-header-row {
        flex-direction: column;
        align-items: stretch;
    }
    .page-header-row .btn { width: 100%; min-height: 44px; }
    .page-title { font-size: 1.375rem; }
    .page-desc { font-size: 0.875rem; }

    .panel-body { padding: 1.125rem; }
    .panel-header { padding: 1rem 1.125rem; }

    .form-control,
    .form select,
    .form textarea,
    .form input[type="text"],
    .form input[type="email"],
    .form input[type="tel"],
    .form input[type="number"],
    .form input[type="date"],
    .form input[type="time"],
    .form input[type="datetime-local"],
    .form input[type="password"] {
        font-size: 16px;
        min-height: 44px;
    }

    .btn { min-height: 44px; }
    .btn-sm { min-height: 40px; padding: 0.5rem 0.75rem; }

    .calendar-toolbar {
        flex-direction: column;
        align-items: stretch;
        padding: 0.875rem 1rem;
    }
    .calendar-nav {
        justify-content: center;
        flex-wrap: wrap;
    }
    .calendar-title {
        min-width: 0;
        flex: 1;
        font-size: 0.9375rem;
    }
    .calendar-views {
        justify-content: center;
        width: 100%;
    }
    .calendar-views .btn-sm { flex: 1; min-height: 40px; }

    .month-grid { min-width: 560px; }
    .month-header { padding: 0.5rem 0.25rem; font-size: 0.625rem; }
    .month-cell { min-height: 64px; padding: 0.375rem; }
    .month-cell-expanded { min-height: 200px; }
    .month-grid-day .month-cell-expanded { min-height: 280px; }
    .month-event { font-size: 0.625rem; padding: 0.15rem 0.3rem; }

    .cita-card {
        grid-template-columns: 1fr;
        gap: 0.625rem;
        padding: 1rem;
    }
    .cita-actions { justify-self: start; }
    .cita-actions .btn { width: 100%; min-height: 44px; }

    .data-card { padding: 1rem; }
    .data-card .form-actions { flex-direction: column; }
    .data-card .form-actions .btn { width: 100%; }

    .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 0.75rem; }
    .stat-card { padding: 1rem; }
    .stat-value { font-size: 1.5rem; }

    .filter-bar { flex-direction: column; align-items: stretch; }
    .filter-bar .form-group { width: 100%; margin: 0; }
    .filter-bar .btn { width: 100%; }

    .form-actions { flex-direction: column; align-items: stretch; }
    .form-actions .btn { width: 100%; }

    .legend {
        gap: 0.75rem;
        font-size: 0.75rem;
    }

    .auth-card { padding: 1.75rem 1.25rem; }

    .hero { padding: 2rem 1.25rem; }
    .hero-actions { flex-direction: column; }
    .hero-actions .btn { width: 100%; min-height: 48px; }

    .table-actions { flex-wrap: wrap; }
    .table-actions .btn { min-height: 40px; }

    .rank-list li {
        flex-wrap: wrap;
        gap: 0.375rem 0.75rem;
    }
    .rank-list li span { min-width: 0; word-break: break-word; }

    .inline-edit-row .form-row { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .topbar-actions { flex-direction: column; }
    .topbar-actions .btn-outline { display: inline-flex; }
    .calendar-nav .btn-ghost { display: none; }
    .page-title { font-size: 1.25rem; }
    .table { font-size: 0.8125rem; }
    .table th, .table td { padding: 0.625rem 0.75rem; }
}

@media (hover: none) {
    .btn-primary:hover,
    .cita-card:hover,
    .data-card:hover { transform: none; }
}
