/* ============================================================
   Agenda · Sistema de gestión de citas
   Hoja de estilos principal (sin dependencias externas)
   ============================================================ */

:root {
    --bg: #f5f7fb;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --surface-3: #f1f5f9;
    --border: #e5e9f2;
    --border-strong: #d6dded;
    --text: #0f172a;
    --text-2: #334155;
    --muted: #64748b;
    --muted-2: #94a3b8;

    --primary: #4f46e5;
    --primary-500: #5b53ea;
    --primary-600: #4338ca;
    --primary-700: #3730a3;
    --primary-300: #a5b4fc;
    --primary-200: #c7d2fe;
    --primary-100: #e0e7ff;
    --primary-soft: #eef2ff;
    --primary-ring: rgba(79, 70, 229, 0.16);
    --primary-contrast: #ffffff;
    --primary-a06: rgba(79, 70, 229, 0.06);
    --primary-a10: rgba(79, 70, 229, 0.1);
    --primary-a12: rgba(79, 70, 229, 0.12);
    --primary-a18: rgba(79, 70, 229, 0.18);
    --primary-a25: rgba(79, 70, 229, 0.25);
    --primary-a28: rgba(79, 70, 229, 0.28);
    --primary-a35: rgba(79, 70, 229, 0.35);
    --primary-shadow: rgba(79, 70, 229, 0.55);

    --success: #059669;
    --success-soft: #ecfdf5;
    --warning: #b45309;
    --warning-soft: #fffbeb;
    --danger: #dc2626;
    --danger-soft: #fef2f2;
    --info: #0369a1;
    --info-soft: #f0f9ff;

    --radius: 16px;
    --radius-sm: 12px;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04), 0 6px 18px -12px rgba(15, 23, 42, 0.12);
    --shadow-md: 0 18px 40px -24px rgba(15, 23, 42, 0.28);

    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, "Helvetica Neue", Arial, sans-serif;
    --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

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

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.55;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

::selection {
    background: var(--primary-200);
    color: #1e1b4b;
}

a {
    color: var(--primary);
}

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

[hidden] {
    display: none !important;
}

h1,
h2,
h3,
p {
    overflow-wrap: break-word;
}

.icon {
    width: 19px;
    height: 19px;
    flex: 0 0 auto;
    display: inline-block;
    vertical-align: middle;
}

.muted {
    color: var(--muted);
}

.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;
}

/* ------------------------------------------------------------
   Estructura general
   ------------------------------------------------------------ */

.layout {
    display: grid;
    grid-template-columns: 268px minmax(0, 1fr);
    min-height: 100vh;
}

.main {
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 100vh;
}

.content {
    width: 100%;
    max-width: 1240px;
    margin: 0 auto;
    padding: 30px 32px 56px;
    display: flex;
    flex-direction: column;
    gap: 22px;
}

.stack {
    display: flex;
    flex-direction: column;
    gap: 20px;
    min-width: 0;
}

/* ------------------------------------------------------------
   Barra lateral
   ------------------------------------------------------------ */

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    gap: 26px;
    padding: 24px 16px;
    background:
        radial-gradient(520px 280px at 0% 0%, var(--primary-a28), transparent 65%),
        linear-gradient(180deg, #0b1220 0%, #0e1729 100%);
    color: #cbd5e1;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(148, 163, 184, 0.35) transparent;
    z-index: 50;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 2px 6px;
    text-decoration: none;
    color: #fff;
}

.brand-mark {
    width: 42px;
    height: 42px;
    border-radius: 13px;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, var(--primary-500), var(--primary-600));
    color: var(--primary-contrast);
    box-shadow: 0 10px 22px -10px var(--primary-shadow);
    flex: 0 0 auto;
}

.brand-mark .icon {
    width: 22px;
    height: 22px;
}

.brand-mark--lg {
    width: 48px;
    height: 48px;
    border-radius: 14px;
}

.brand-mark--image {
    padding: 4px;
    background: #ffffff;
    box-shadow: 0 8px 18px -12px rgba(15, 23, 42, 0.6);
}

.brand-mark--image img {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: 9px;
    object-fit: contain;
}

.brand-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
    line-height: 1.2;
}

.brand-text strong {
    font-size: 17px;
    letter-spacing: -0.01em;
    overflow-wrap: anywhere;
}

.brand-text small {
    margin-top: 3px;
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: #94a3b8;
    overflow-wrap: anywhere;
}

.auth-form .btn-block {
    height: auto;
    min-height: 46px;
    padding: 10px 18px;
    white-space: normal;
    line-height: 1.35;
}

.nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-label {
    padding: 0 12px;
    margin: 4px 0 6px;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: #64748b;
}

.nav-label--spaced {
    margin-top: 20px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 10px 12px;
    border-radius: 10px;
    color: #cbd5e1;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: background 0.16s ease, color 0.16s ease;
}

.nav-link .icon {
    width: 19px;
    height: 19px;
    color: #94a3b8;
    transition: color 0.16s ease;
}

.nav-link:hover {
    background: rgba(148, 163, 184, 0.1);
    color: #fff;
}

.nav-link:hover .icon {
    color: #e2e8f0;
}

.nav-link.is-active {
    background: linear-gradient(90deg, var(--primary-a25), var(--primary-a10));
    color: #fff;
    box-shadow: inset 0 0 0 1px var(--primary-a25);
}

.nav-link.is-active .icon {
    color: var(--primary-300);
}

.sidebar-foot {
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.sidebar-tip {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 12px;
    border-radius: 12px;
    background: var(--primary-a10);
    border: 1px solid var(--primary-a18);
}

.sidebar-tip__icon {
    color: var(--primary-300);
}

.sidebar-tip .icon {
    width: 17px;
    height: 17px;
}

.sidebar-tip p {
    margin: 0;
    font-size: 12px;
    line-height: 1.45;
    color: var(--primary-200);
}

.user-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-radius: 12px;
    background: rgba(148, 163, 184, 0.08);
    border: 1px solid rgba(148, 163, 184, 0.12);
}

.user-card__link {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
    margin: -2px;
    padding: 2px;
    border-radius: 9px;
    color: inherit;
    text-decoration: none;
    transition: background 0.15s ease;
}

.user-card__link:hover {
    background: rgba(148, 163, 184, 0.1);
}

.user-meta {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
}

.user-meta strong {
    font-size: 13px;
    color: #f1f5f9;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-meta small {
    font-size: 11px;
    color: #94a3b8;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-card form {
    display: flex;
}

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, var(--primary-500), var(--primary-600));
    color: var(--primary-contrast);
    font-size: 12.5px;
    font-weight: 700;
    letter-spacing: 0.02em;
    flex: 0 0 auto;
}

.avatar--lg {
    width: 46px;
    height: 46px;
    font-size: 15px;
}

.sidebar-scrim {
    display: none;
}

/* ------------------------------------------------------------
   Barra superior
   ------------------------------------------------------------ */

.topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    height: 70px;
    padding: 0 32px;
    background: var(--bg);
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
}

.topbar-left,
.topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.topbar-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.today-chip {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 7px 12px;
    border-radius: 999px;
    background: #fff;
    border: 1px solid var(--border);
    color: var(--muted);
    font-size: 12.5px;
    font-weight: 500;
    white-space: nowrap;
}

.today-chip .icon {
    width: 15px;
    height: 15px;
    color: var(--primary);
}

.icon-btn.menu-btn {
    display: none;
}

/* ------------------------------------------------------------
   Cabeceras de página
   ------------------------------------------------------------ */

.page-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px;
    flex-wrap: wrap;
}

.page-head h1 {
    margin: 2px 0 0;
    font-size: clamp(24px, 2.4vw, 30px);
    line-height: 1.15;
    letter-spacing: -0.028em;
}

.eyebrow {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--primary);
}

.page-sub {
    margin: 6px 0 0;
    font-size: 14px;
    color: var(--muted);
}

.page-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.page-meta {
    display: flex;
    align-items: center;
    gap: 8px 16px;
    margin-top: 12px;
    flex-wrap: wrap;
}

.meta-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--muted);
}

.meta-item .icon {
    width: 15px;
    height: 15px;
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
    text-decoration: none;
}

.back-link .icon {
    width: 15px;
    height: 15px;
}

.back-link:hover {
    color: var(--primary);
}

/* ------------------------------------------------------------
   Botones
   ------------------------------------------------------------ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 42px;
    padding: 0 18px;
    border: 1px solid transparent;
    border-radius: 11px;
    background: transparent;
    color: var(--text);
    font-size: 14px;
    font-weight: 600;
    line-height: 1;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease,
        transform 0.16s ease, box-shadow 0.16s ease;
}

.btn .icon {
    width: 17px;
    height: 17px;
}

.btn:focus-visible,
.icon-btn:focus-visible,
.page-link:focus-visible,
.nav-link:focus-visible,
.status-option:focus-visible,
.cal-daynum:focus-visible,
a:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.btn-primary {
    background: linear-gradient(180deg, var(--primary-500), var(--primary));
    color: var(--primary-contrast);
    box-shadow: 0 8px 16px -10px var(--primary-shadow), inset 0 1px 0 rgba(255, 255, 255, 0.16);
}

.btn-primary:hover {
    background: linear-gradient(180deg, var(--primary), var(--primary-600));
    transform: translateY(-1px);
}

.btn-secondary {
    background: #fff;
    border-color: var(--border-strong);
    color: var(--text-2);
    box-shadow: var(--shadow-sm);
}

.btn-secondary:hover {
    background: #fbfcff;
    border-color: #c3cbe0;
}

.btn-ghost {
    color: var(--muted);
}

.btn-ghost:hover {
    background: rgba(15, 23, 42, 0.05);
    color: var(--text);
}

.btn-danger {
    background: var(--danger-soft);
    border-color: #fecaca;
    color: #b91c1c;
}

.btn-danger:hover {
    background: #fee2e2;
}

.btn-sm {
    height: 36px;
    padding: 0 13px;
    border-radius: 9px;
    font-size: 13px;
}

.btn-block {
    width: 100%;
    height: 46px;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.icon-btn {
    display: inline-grid;
    place-items: center;
    width: 38px;
    height: 38px;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 10px;
    background: transparent;
    color: var(--muted);
    text-decoration: none;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.icon-btn:hover {
    background: var(--surface-3);
    color: var(--text);
}

.icon-btn--danger:hover {
    background: var(--danger-soft);
    color: #b91c1c;
}

.icon-btn--ghost {
    color: #94a3b8;
}

.icon-btn--ghost:hover {
    background: rgba(148, 163, 184, 0.16);
    color: #fff;
}

/* ------------------------------------------------------------
   Tarjetas
   ------------------------------------------------------------ */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 19px 24px;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}

.card-title {
    margin: 0;
    font-size: 15.5px;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.card-hint {
    display: inline-block;
    font-size: 12.5px;
    color: var(--muted);
}

.card-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    font-weight: 600;
    color: var(--primary);
    text-decoration: none;
}

.card-link .icon {
    width: 15px;
    height: 15px;
}

.card-link:hover {
    color: var(--primary-600);
    text-decoration: underline;
}

.card-body {
    padding: 22px 24px;
}

.card-body--flush {
    padding: 0;
}

/* ------------------------------------------------------------
   Métricas del panel
   ------------------------------------------------------------ */

.stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
}

.stat {
    position: relative;
    display: flex;
    gap: 14px;
    padding: 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.stat::after {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 3px;
    background: var(--primary);
    opacity: 0.9;
}

.stat--info::after {
    background: var(--info);
}

.stat--warning::after {
    background: #f59e0b;
}

.stat--success::after {
    background: var(--success);
}

.stat__icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    background: var(--primary-soft);
    color: var(--primary);
}

.stat__icon .icon {
    width: 21px;
    height: 21px;
}

.stat--info .stat__icon {
    background: var(--info-soft);
    color: var(--info);
}

.stat--warning .stat__icon {
    background: var(--warning-soft);
    color: var(--warning);
}

.stat--success .stat__icon {
    background: var(--success-soft);
    color: var(--success);
}

.stat__body {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
}

.stat__label {
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
}

.stat__value {
    font-size: 30px;
    font-weight: 700;
    line-height: 1.15;
    letter-spacing: -0.03em;
    font-variant-numeric: tabular-nums;
}

.stat__hint {
    font-size: 12px;
    color: var(--muted-2);
}

/* ------------------------------------------------------------
   Panel: agenda de hoy y próximas citas
   ------------------------------------------------------------ */

.dash-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr);
    gap: 20px;
    align-items: start;
}

.agenda-list {
    display: flex;
    flex-direction: column;
}

.agenda-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px 24px;
    border-bottom: 1px solid var(--border);
    color: inherit;
    text-decoration: none;
    transition: background 0.15s ease;
}

.agenda-item:last-child {
    border-bottom: none;
}

.agenda-item:hover {
    background: var(--surface-2);
}

.agenda-item.is-past {
    opacity: 0.72;
}

.agenda-time {
    min-width: 58px;
    padding: 5px 8px;
    border-radius: 9px;
    background: var(--primary-soft);
    color: var(--primary);
    font-size: 13.5px;
    font-weight: 700;
    text-align: center;
    font-variant-numeric: tabular-nums;
    flex: 0 0 auto;
}

.agenda-body {
    display: flex;
    flex-direction: column;
    gap: 3px;
    flex: 1;
    min-width: 0;
}

.agenda-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.agenda-meta {
    display: flex;
    align-items: center;
    gap: 5px;
    flex-wrap: wrap;
    font-size: 12px;
    color: var(--muted);
}

.agenda-meta .icon {
    width: 13px;
    height: 13px;
}

.sep {
    margin: 0 2px;
    color: var(--muted-2);
}

.upcoming-list {
    display: flex;
    flex-direction: column;
}

.upcoming-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 24px;
    border-bottom: 1px solid var(--border);
    color: inherit;
    text-decoration: none;
    transition: background 0.15s ease;
}

.upcoming-item:last-child {
    border-bottom: none;
}

.upcoming-item:hover {
    background: var(--surface-2);
}

.upcoming-date {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 44px;
    border-radius: 10px;
    background: var(--surface-3);
    flex: 0 0 auto;
}

.upcoming-date strong {
    font-size: 16px;
    line-height: 1;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.upcoming-date small {
    margin-top: 3px;
    font-size: 9.5px;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: var(--muted);
}

.upcoming-body {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
}

.upcoming-time {
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--primary);
}

.upcoming-title {
    font-size: 13.5px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.upcoming-contact {
    font-size: 12px;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.empty-note {
    margin: 0;
    padding: 22px 24px;
    font-size: 13.5px;
    color: var(--muted);
}

.status-bars {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.status-bar__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 6px;
    font-size: 13px;
}

.status-bar__label {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-2);
    font-weight: 500;
}

.status-bar__count {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.bar {
    height: 7px;
    border-radius: 999px;
    background: var(--surface-3);
    overflow: hidden;
}

.bar__fill {
    display: block;
    height: 100%;
    width: var(--value, 0%);
    border-radius: inherit;
    transition: width 0.5s ease;
}

.bar__fill--pending {
    background: #f59e0b;
}

.bar__fill--confirmed {
    background: #10b981;
}

.bar__fill--done {
    background: #64748b;
}

.bar__fill--cancelled {
    background: #ef4444;
}

/* ------------------------------------------------------------
   Insignias y puntos de estado
   ------------------------------------------------------------ */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 999px;
    border: 1px solid transparent;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.3;
    white-space: nowrap;
}

.badge--pending {
    background: var(--warning-soft);
    border-color: #fde68a;
    color: #b45309;
}

.badge--confirmed {
    background: var(--success-soft);
    border-color: #a7f3d0;
    color: #047857;
}

.badge--done {
    background: var(--surface-3);
    border-color: #e2e8f0;
    color: #475569;
}

.badge--cancelled {
    background: var(--danger-soft);
    border-color: #fecaca;
    color: #b91c1c;
}

.badge--admin {
    background: var(--primary-soft);
    border-color: var(--primary-200);
    color: var(--primary-600);
}

.badge--user {
    background: var(--surface-3);
    border-color: #e2e8f0;
    color: #475569;
}

.badge .icon {
    width: 12px;
    height: 12px;
}

.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex: 0 0 auto;
}

.status-dot--pending {
    background: #f59e0b;
}

.status-dot--confirmed {
    background: #10b981;
}

.status-dot--done {
    background: #64748b;
}

.status-dot--cancelled {
    background: #ef4444;
}

/* ------------------------------------------------------------
   Formularios
   ------------------------------------------------------------ */

.field {
    display: flex;
    flex-direction: column;
    gap: 7px;
    min-width: 0;
    margin: 0;
}

.field label {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-2);
}

.field input,
.field select,
.field textarea {
    width: 100%;
    height: 44px;
    padding: 0 13px;
    border: 1px solid var(--border-strong);
    border-radius: 10px;
    background: #fff;
    color: var(--text);
    font-size: 14px;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.field textarea {
    height: auto;
    min-height: 112px;
    padding: 11px 13px;
    line-height: 1.55;
    resize: vertical;
}

.field select {
    appearance: none;
    -webkit-appearance: none;
    padding-right: 38px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
    cursor: pointer;
}

.field input::placeholder,
.field textarea::placeholder {
    color: var(--muted-2);
}

.field input:hover,
.field select:hover,
.field textarea:hover {
    border-color: #c3cbe0;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-ring);
}

.field.has-error input,
.field.has-error select,
.field.has-error textarea {
    border-color: #fca5a5;
    background: #fffafa;
}

.field.has-error input:focus,
.field.has-error select:focus,
.field.has-error textarea:focus {
    box-shadow: 0 0 0 4px rgba(220, 38, 38, 0.12);
}

.field-error {
    margin: 0;
    font-size: 12.5px;
    font-weight: 500;
    color: #b91c1c;
}

.req {
    color: #dc2626;
}

.input-icon {
    position: relative;
    display: flex;
    align-items: center;
}

.input-icon .icon {
    position: absolute;
    left: 13px;
    width: 17px;
    height: 17px;
    color: var(--muted-2);
    pointer-events: none;
}

.input-icon input {
    padding-left: 40px;
}

.field--full {
    grid-column: 1 / -1;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}

.form-section {
    padding: 24px;
}

.form-section + .form-section {
    border-top: 1px solid var(--border);
}

.form-section__head {
    margin-bottom: 18px;
}

.form-section__head h2 {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.form-section__head p {
    margin: 4px 0 0;
    font-size: 12.5px;
    color: var(--muted);
}

.form-alert {
    padding: 20px 24px 0;
}

.form-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    padding: 18px 24px;
    background: var(--surface-2);
    border-top: 1px solid var(--border);
}

.form-actions__meta {
    font-size: 12px;
    color: var(--muted);
}

.form-actions__buttons {
    display: flex;
    align-items: center;
    gap: 10px;
}

.form-note {
    margin: 12px 0 0;
    font-size: 12px;
    color: var(--muted-2);
}

/* ------------------------------------------------------------
   Filtros
   ------------------------------------------------------------ */

.filters-card {
    padding: 18px 20px;
}

.filters {
    display: flex;
    align-items: flex-end;
    gap: 14px;
    flex-wrap: wrap;
}

.filters .field {
    min-width: 138px;
}

.field--search {
    flex: 1 1 260px;
    min-width: 220px;
}

.filters__actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

/* ------------------------------------------------------------
   Tabla de citas
   ------------------------------------------------------------ */

.table-wrap {
    overflow-x: auto;
    contain: paint;
}

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

.table th {
    padding: 12px 20px;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--muted);
    text-align: left;
    white-space: nowrap;
}

.table td {
    padding: 13px 20px;
    border-bottom: 1px solid var(--border);
    font-size: 13.5px;
    vertical-align: middle;
}

.table tbody tr:last-child td {
    border-bottom: none;
}

.table tbody tr:hover {
    background: #fafbff;
}

.table th:last-child,
.table td:last-child {
    text-align: right;
}

.cell-date {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.cell-date__main {
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
}

.tag {
    padding: 2px 7px;
    border-radius: 6px;
    background: var(--surface-3);
    color: var(--muted);
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.tag--today {
    background: var(--primary-soft);
    color: var(--primary);
}

.cell-time {
    display: flex;
    flex-direction: column;
    line-height: 1.25;
    white-space: nowrap;
}

.cell-time strong {
    font-size: 14px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.cell-time small {
    font-size: 11.5px;
    color: var(--muted-2);
}

.cell-title {
    display: block;
    max-width: 300px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    color: var(--text);
    font-weight: 600;
    text-decoration: none;
}

.cell-title:hover {
    color: var(--primary);
}

.cell-sub {
    display: flex;
    align-items: center;
    gap: 4px;
    max-width: 280px;
    margin-top: 2px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    font-size: 12px;
    color: var(--muted);
}

.cell-sub .icon {
    width: 12px;
    height: 12px;
    flex: 0 0 auto;
}

.cell-contact {
    display: block;
    max-width: 220px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    color: var(--text-2);
    font-weight: 500;
}

.row-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 2px;
}

.row-actions form {
    display: flex;
}

.user-cell {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.user-cell > div {
    display: flex;
    align-items: center;
    gap: 7px;
    min-width: 0;
}

.user-cell strong {
    font-size: 13.5px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.count-pill {
    display: inline-flex;
    align-items: baseline;
    gap: 4px;
    font-size: 12.5px;
    color: var(--muted);
    white-space: nowrap;
}

.count-pill strong {
    font-size: 13.5px;
    color: var(--text);
    font-variant-numeric: tabular-nums;
}

.icon-btn--muted {
    color: var(--muted-2);
    cursor: default;
}

.icon-btn--muted:hover {
    background: transparent;
    color: var(--muted-2);
}

.page-note {
    margin: 0;
    padding: 0 2px;
    font-size: 12.5px;
    line-height: 1.6;
    color: var(--muted);
}

.table-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    padding: 14px 20px;
    border-top: 1px solid var(--border);
}

.table-foot__info {
    font-size: 12.5px;
    color: var(--muted);
}

.pagination {
    display: flex;
    align-items: center;
    gap: 4px;
}

.page-link {
    display: inline-grid;
    place-items: center;
    min-width: 34px;
    height: 34px;
    padding: 0 8px;
    border: 1px solid transparent;
    border-radius: 9px;
    color: var(--text-2);
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    transition: background 0.15s ease, color 0.15s ease;
}

.page-link .icon {
    width: 15px;
    height: 15px;
}

.page-link:hover {
    background: var(--surface-3);
    color: var(--text);
}

.page-link.is-active {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--primary-contrast);
    box-shadow: 0 4px 10px -6px var(--primary-shadow);
}

.page-link.is-disabled {
    opacity: 0.35;
    pointer-events: none;
}

.page-ellipsis {
    padding: 0 2px;
    color: var(--muted-2);
}

/* ------------------------------------------------------------
   Alertas
   ------------------------------------------------------------ */

.alert {
    display: flex;
    align-items: flex-start;
    gap: 11px;
    padding: 13px 16px;
    border: 1px solid transparent;
    border-radius: 12px;
    font-size: 13.5px;
    line-height: 1.5;
    transition: opacity 0.35s ease, transform 0.35s ease;
}

.alert .icon {
    width: 18px;
    height: 18px;
    margin-top: 1px;
    flex: 0 0 auto;
}

.alert--success {
    background: var(--success-soft);
    border-color: #a7f3d0;
    color: #065f46;
}

.alert--error {
    background: var(--danger-soft);
    border-color: #fecaca;
    color: #991b1b;
}

.alert--warning {
    background: var(--warning-soft);
    border-color: #fde68a;
    color: #92400e;
}

.alert--info {
    background: var(--info-soft);
    border-color: #bae6fd;
    color: #075985;
}

.alert.is-leaving {
    opacity: 0;
    transform: translateY(-4px);
}

/* ------------------------------------------------------------
   Estados vacíos
   ------------------------------------------------------------ */

.empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 54px 24px;
    text-align: center;
}

.empty__icon {
    display: grid;
    place-items: center;
    width: 58px;
    height: 58px;
    margin-bottom: 10px;
    border-radius: 18px;
    background: var(--primary-soft);
    color: var(--primary);
}

.empty__icon .icon {
    width: 26px;
    height: 26px;
}

.empty h3 {
    margin: 0;
    font-size: 16px;
    letter-spacing: -0.01em;
}

.empty p {
    max-width: 400px;
    margin: 0 0 14px;
    font-size: 13.5px;
    color: var(--muted);
}

.empty--sm {
    padding: 34px 24px;
}

.empty--sm .empty__icon {
    width: 48px;
    height: 48px;
    border-radius: 14px;
}

.empty--sm .empty__icon .icon {
    width: 22px;
    height: 22px;
}

/* ------------------------------------------------------------
   Detalle de cita
   ------------------------------------------------------------ */

.detail-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr);
    gap: 20px;
    align-items: start;
}

/* ------------------------------------------------------------
   Mi cuenta
   ------------------------------------------------------------ */

.settings-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr);
    gap: 20px;
    align-items: start;
}

.account-head {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 18px;
}

.account-head strong {
    display: block;
    font-size: 15px;
    letter-spacing: -0.01em;
}

.account-head small {
    display: block;
    font-size: 12.5px;
    color: var(--muted);
}

.password-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.password-hints {
    padding: 13px 15px;
    border: 1px dashed var(--border-strong);
    border-radius: 12px;
    background: var(--surface-2);
}

.password-hints__title {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0 0 6px;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
}

.password-hints__title .icon {
    width: 14px;
    height: 14px;
}

.password-hints ul {
    display: flex;
    flex-direction: column;
    gap: 3px;
    margin: 0;
    padding-left: 18px;
    font-size: 12.5px;
    color: var(--muted);
}

.role-static {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    min-height: 44px;
}

.role-static .form-note {
    margin: 0;
}

/* ------------------------------------------------------------
   Apariencia
   ------------------------------------------------------------ */

.appearance-preview {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    flex-wrap: wrap;
    padding: 18px 22px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.appearance-preview__brand {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.appearance-preview__brand strong {
    display: block;
    font-size: 15.5px;
    letter-spacing: -0.01em;
}

.appearance-preview__brand small {
    display: block;
    font-size: 12px;
    color: var(--muted);
}

.appearance-preview__colors {
    display: flex;
    align-items: center;
    gap: 8px;
}

.preview-swatch {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    background: var(--swatch, var(--primary));
    border: 1px solid rgba(15, 23, 42, 0.14);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

.appearance-preview__login {
    display: flex;
    align-items: center;
    gap: 14px;
}

.appearance-preview__login small {
    display: block;
    font-size: 9.5px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted-2);
}

.appearance-preview__login strong {
    display: block;
    font-size: 12.5px;
    font-weight: 600;
}

.color-input {
    display: flex;
    align-items: center;
    gap: 10px;
}

.field input.color-picker {
    width: 48px;
    height: 44px;
    flex: 0 0 48px;
    padding: 4px;
    border: 1px solid var(--border-strong);
    border-radius: 10px;
    background: #fff;
    cursor: pointer;
}

.color-picker::-webkit-color-swatch-wrapper {
    padding: 0;
}

.color-picker::-webkit-color-swatch {
    border: none;
    border-radius: 6px;
}

.color-picker::-moz-color-swatch {
    border: none;
    border-radius: 6px;
}

.color-text {
    flex: 1;
    font-family: var(--mono);
    letter-spacing: 0.02em;
    text-transform: lowercase;
}

.color-presets {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 2px;
}

.color-preset {
    width: 26px;
    height: 26px;
    padding: 0;
    border: 2px solid #fff;
    border-radius: 50%;
    background: var(--swatch, var(--primary));
    box-shadow: 0 0 0 1px var(--border-strong);
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.color-preset:hover {
    transform: scale(1.12);
    box-shadow: 0 0 0 2px var(--primary-a35);
}

.color-preset:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.upload-row {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    padding: 16px;
    border: 1px dashed var(--border-strong);
    border-radius: 12px;
    background: var(--surface-2);
}

.upload-row--spaced {
    margin-top: 16px;
}

.upload-preview {
    display: grid;
    place-items: center;
    width: 74px;
    height: 74px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: #fff;
    color: var(--muted-2);
    overflow: hidden;
    flex: 0 0 auto;
}

.upload-preview .icon {
    width: 26px;
    height: 26px;
}

.upload-preview img {
    display: block;
    width: 100%;
    height: 100%;
    padding: 6px;
    object-fit: contain;
}

.upload-preview--wide {
    width: 148px;
    height: 88px;
    border-radius: 12px;
}

.upload-preview--wide img {
    padding: 0;
    object-fit: cover;
}

.upload-body {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
    min-width: 0;
}

.upload-body > label {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-2);
}

.upload-body input[type="file"] {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--border-strong);
    border-radius: 10px;
    background: #fff;
    color: var(--muted);
    font-size: 12.5px;
    cursor: pointer;
}

.upload-body input[type="file"]::file-selector-button {
    margin-right: 10px;
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: var(--surface-3);
    color: var(--text-2);
    font: inherit;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}

.radio-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.radio-card {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 13px 14px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #fff;
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.radio-card:hover {
    border-color: var(--border-strong);
    background: var(--surface-2);
}

.radio-card:has(input:checked) {
    border-color: var(--primary);
    background: var(--primary-soft);
    box-shadow: 0 0 0 1px var(--primary-a25);
}

.radio-card input {
    width: 16px;
    height: 16px;
    margin: 2px 0 0;
    accent-color: var(--primary);
    flex: 0 0 auto;
}

.radio-card__body {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}

.radio-card__body strong {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
}

.radio-card__body strong .icon {
    width: 15px;
    height: 15px;
    color: var(--primary);
}

.radio-card__body small {
    font-size: 12px;
    line-height: 1.45;
    color: var(--muted);
}

.check-field {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 13px 14px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface-2);
    cursor: pointer;
}

.check-field input {
    width: 16px;
    height: 16px;
    margin: 2px 0 0;
    accent-color: var(--primary);
    flex: 0 0 auto;
}

.check-field strong {
    display: block;
    font-size: 13px;
}

.check-field small {
    display: block;
    margin-top: 2px;
    font-size: 12px;
    line-height: 1.45;
    color: var(--muted);
}

.check-inline {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    margin-top: 2px;
    font-size: 12.5px;
    color: var(--muted);
    cursor: pointer;
}

.check-inline input {
    width: 15px;
    height: 15px;
    accent-color: var(--primary);
}

.reset-card {
    border-color: #fecaca;
}

.reset-card__body {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    padding: 20px 24px;
}

.reset-card__body h2 {
    margin: 0;
    font-size: 15px;
    letter-spacing: -0.01em;
}

.reset-card__body p {
    margin: 4px 0 0;
    max-width: 560px;
    font-size: 12.5px;
    color: var(--muted);
}

.reset-card__body form {
    display: flex;
}


.detail-hero {
    display: flex;
    gap: 24px;
    padding: 24px;
}

.date-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 106px;
    min-height: 118px;
    border-radius: 16px;
    background: linear-gradient(160deg, var(--primary-500), var(--primary-600));
    color: var(--primary-contrast);
    flex: 0 0 auto;
    box-shadow: 0 16px 28px -20px var(--primary-shadow);
}

.date-tile__weekday {
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    opacity: 0.85;
}

.date-tile__day {
    margin: 2px 0;
    font-size: 40px;
    font-weight: 700;
    line-height: 1.05;
    letter-spacing: -0.03em;
    font-variant-numeric: tabular-nums;
}

.date-tile__month {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.1em;
    opacity: 0.9;
}

.detail-hero__body {
    flex: 1;
    min-width: 0;
}

.detail-hero__body h2 {
    margin: 0;
    font-size: 21px;
    letter-spacing: -0.02em;
}

.detail-location {
    display: flex;
    align-items: center;
    gap: 7px;
    margin: 7px 0 20px;
    font-size: 13.5px;
    color: var(--muted);
}

.detail-location .icon {
    width: 16px;
    height: 16px;
}

.meta-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px 24px;
    margin: 0;
    padding-top: 18px;
    border-top: 1px dashed var(--border);
}

.meta-grid dt {
    margin-bottom: 3px;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: var(--muted-2);
}

.meta-grid dd {
    margin: 0;
    font-size: 13.5px;
    font-weight: 500;
}

.notes {
    font-size: 14px;
    line-height: 1.65;
    color: var(--text-2);
}

.contact-head {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 18px;
}

.contact-head strong {
    display: block;
    font-size: 14.5px;
}

.contact-head small {
    font-size: 12px;
    color: var(--muted);
}

.contact-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.contact-list li {
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: 13.5px;
    color: var(--text-2);
}

.contact-list .icon {
    color: var(--muted-2);
}

.contact-list a {
    color: var(--text-2);
    text-decoration: none;
}

.contact-list a:hover {
    color: var(--primary);
    text-decoration: underline;
}

.status-form {
    margin: 0;
}

.status-options {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.status-option {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    height: 38px;
    padding: 0 11px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #fff;
    color: var(--text-2);
    font-size: 12.5px;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.status-option .icon {
    width: 14px;
    height: 14px;
    margin-left: auto;
    color: var(--success);
}

.status-option:hover:not(:disabled) {
    background: var(--surface-2);
    border-color: var(--border-strong);
}

.status-option.is-active {
    border-color: var(--primary);
    background: var(--primary-soft);
    color: var(--primary);
    cursor: default;
}

.status-option:disabled {
    opacity: 1;
    -webkit-text-fill-color: currentColor;
}

.info-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 0;
}

.info-list > div {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    padding-bottom: 9px;
    border-bottom: 1px dashed var(--border);
    font-size: 13px;
}

.info-list > div:last-child {
    padding-bottom: 0;
    border-bottom: none;
}

.info-list dt {
    color: var(--muted);
}

.info-list dd {
    margin: 0;
    font-weight: 600;
    text-align: right;
}

/* ------------------------------------------------------------
   Calendario
   ------------------------------------------------------------ */

.cal-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}

.cal-title {
    margin: 0;
    font-size: 18px;
    letter-spacing: -0.02em;
}

.cal-nav {
    display: flex;
    align-items: center;
    gap: 6px;
}

.cal-scroll {
    overflow-x: auto;
    contain: paint;
}

.cal-hint {
    display: none;
    align-items: center;
    gap: 6px;
    margin: 0;
    padding: 9px 18px;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
    font-size: 11.5px;
    color: var(--muted);
}

.cal-hint .icon {
    width: 14px;
    height: 14px;
}

.cal-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    min-width: 780px;
}

.cal-dow {
    padding: 10px 12px;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--muted);
}

.cal-cell {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-height: 118px;
    padding: 8px;
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    background: #fff;
    transition: background 0.15s ease;
}

.cal-cell:nth-child(7n) {
    border-right: none;
}

.cal-cell.is-outside {
    background: #fafbfd;
}

.cal-cell.is-outside .cal-daynum {
    color: var(--muted-2);
}

.cal-cell.is-today {
    background: var(--primary-a06);
}

.cal-cell:hover {
    background: #f8faff;
}

.cal-cell__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
}

.cal-daynum {
    display: inline-grid;
    place-items: center;
    width: 26px;
    height: 26px;
    border-radius: 8px;
    color: var(--text-2);
    font-size: 12.5px;
    font-weight: 600;
    text-decoration: none;
    font-variant-numeric: tabular-nums;
}

.cal-daynum:hover {
    background: var(--primary-soft);
    color: var(--primary);
}

.cal-cell.is-today .cal-daynum {
    background: var(--primary);
    color: var(--primary-contrast);
}

.cal-count {
    padding: 1px 6px;
    border-radius: 999px;
    background: var(--surface-3);
    color: var(--muted);
    font-size: 10.5px;
    font-weight: 700;
}

.cal-cell.is-today .cal-count {
    background: var(--primary-100);
    color: var(--primary);
}

.cal-events {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}

.cal-event {
    display: flex;
    flex-direction: column;
    padding: 4px 6px;
    border-left: 2px solid transparent;
    border-radius: 6px;
    font-size: 10.5px;
    line-height: 1.3;
    text-decoration: none;
    overflow: hidden;
}

.cal-event__time {
    font-size: 9.5px;
    font-weight: 700;
    opacity: 0.8;
}

.cal-event__title {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cal-event--pending {
    background: var(--warning-soft);
    border-color: #f59e0b;
    color: #92400e;
}

.cal-event--confirmed {
    background: var(--success-soft);
    border-color: #10b981;
    color: #065f46;
}

.cal-event--done {
    background: var(--surface-3);
    border-color: #94a3b8;
    color: #475569;
}

.cal-event--cancelled {
    background: var(--danger-soft);
    border-color: #ef4444;
    color: #991b1b;
    opacity: 0.8;
}

.cal-more {
    padding-left: 4px;
    color: var(--primary);
    font-size: 10px;
    font-weight: 700;
    text-decoration: none;
}

.cal-legend {
    display: flex;
    align-items: center;
    gap: 18px;
    flex-wrap: wrap;
    padding: 14px 24px;
    border-top: 1px solid var(--border);
    background: var(--surface-2);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 12px;
    font-weight: 500;
    color: var(--muted);
}

/* ------------------------------------------------------------
   Login y páginas de error
   ------------------------------------------------------------ */

.auth {
    display: grid;
    place-items: center;
    min-height: 100vh;
    padding: 32px 20px;
    background:
        radial-gradient(900px 480px at 8% -10%, var(--primary-a18) 0%, transparent 60%),
        radial-gradient(800px 480px at 105% 0%, var(--primary-a12) 0%, transparent 55%),
        var(--bg);
}

.auth-card {
    width: 100%;
    max-width: 442px;
    padding: 36px 34px 28px;
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid #eef2f7;
    border-radius: 22px;
    box-shadow: 0 30px 80px -40px rgba(15, 23, 42, 0.45), 0 2px 8px rgba(15, 23, 42, 0.04);
}

.auth-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 28px;
}

.auth-brand strong {
    display: block;
    font-size: 18px;
    letter-spacing: -0.01em;
}

.auth-brand small {
    display: block;
    margin-top: 2px;
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--muted);
}

.auth-head h1 {
    margin: 0;
    font-size: 24px;
    letter-spacing: -0.025em;
}

.auth-head p {
    margin: 6px 0 0;
    font-size: 13.5px;
    color: var(--muted);
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-top: 22px;
}

.auth-form .field input {
    height: 46px;
}

.auth-form .alert {
    margin-top: 14px;
}

.auth-foot {
    margin: 22px 0 0;
    text-align: center;
    font-size: 11.5px;
    color: var(--muted-2);
}

.demo-box {
    margin-top: 24px;
    padding: 12px 14px;
    border: 1px dashed var(--border-strong);
    border-radius: 12px;
    background: var(--surface-2);
}

.demo-box__title {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
}

.demo-box__title .icon {
    width: 13px;
    height: 13px;
}

.demo-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    padding: 3px 0;
    font-size: 12px;
}

.demo-label {
    width: 92px;
    font-weight: 500;
    color: var(--muted);
}

.demo-row code {
    padding: 2px 6px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fff;
    font-family: var(--mono);
    font-size: 11.5px;
    color: var(--text-2);
}

.error-card {
    width: 100%;
    max-width: 470px;
    padding: 44px 36px;
    border: 1px solid var(--border);
    border-radius: 22px;
    background: #fff;
    box-shadow: 0 30px 80px -46px rgba(15, 23, 42, 0.4);
    text-align: center;
}

.error-code {
    display: inline-block;
    padding: 5px 12px;
    border-radius: 999px;
    background: var(--primary-soft);
    color: var(--primary);
    font-size: 11.5px;
    font-weight: 800;
    letter-spacing: 0.2em;
}

.error-card h1 {
    margin: 14px 0 8px;
    font-size: 24px;
    letter-spacing: -0.02em;
}

.error-card p {
    margin: 0;
    font-size: 14px;
    color: var(--muted);
}

.error-actions {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 24px;
}

.error-detail {
    margin-top: 18px;
    padding: 14px;
    border-radius: 10px;
    background: #0f172a;
    color: #e2e8f0;
    font-family: var(--mono);
    font-size: 12px;
    text-align: left;
    overflow: auto;
    white-space: pre-wrap;
}

/* ------------------------------------------------------------
   Responsive
   ------------------------------------------------------------ */

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

    .dash-grid,
    .detail-grid,
    .settings-grid {
        grid-template-columns: minmax(0, 1fr);
    }
}

@media (max-width: 980px) {
    .layout {
        grid-template-columns: minmax(0, 1fr);
    }

    .sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        width: min(288px, 86vw);
        height: 100dvh;
        overflow-y: auto;
        transform: translateX(-100%);
        transition: transform 0.24s ease;
        box-shadow: 24px 0 60px -30px rgba(15, 23, 42, 0.7);
    }

    .sidebar.is-open {
        transform: translateX(0);
    }

    .sidebar-scrim {
        position: fixed;
        inset: 0;
        z-index: 45;
        display: block;
        background: rgba(15, 23, 42, 0.45);
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.24s ease;
    }

    .sidebar-scrim.is-visible {
        opacity: 1;
        pointer-events: auto;
    }

    .icon-btn.menu-btn {
        display: inline-grid;
    }

    .topbar {
        height: 64px;
        padding: 0 20px;
    }

    .content {
        padding: 24px 20px 48px;
    }

    body.no-scroll {
        overflow: hidden;
    }
}

@media (max-width: 720px) {
    .topbar-title {
        display: none;
    }

    .page-head {
        align-items: flex-start;
    }

    .page-actions {
        width: 100%;
    }

    .content {
        padding: 20px 16px 44px;
        gap: 18px;
    }

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

    .form-section {
        padding: 20px 18px;
    }

    .card-head {
        padding: 16px 18px;
    }

    .card-body {
        padding: 18px;
    }

    .form-actions {
        padding: 16px 18px;
    }

    .form-actions__buttons {
        width: 100%;
        justify-content: flex-end;
    }

    .appearance-preview {
        padding: 16px;
        gap: 14px;
    }

    .appearance-preview__brand {
        flex: 1 1 100%;
    }

    .appearance-preview__login {
        order: 2;
        flex: 1 1 100%;
        justify-content: space-between;
    }

    .appearance-preview__colors {
        order: 3;
    }

    .upload-row {
        flex-direction: column;
    }

    .upload-preview {
        width: 64px;
        height: 64px;
    }

    .upload-preview--wide {
        width: 100%;
        height: 150px;
    }

    .radio-row {
        grid-template-columns: minmax(0, 1fr);
    }

    .reset-card__body {
        align-items: flex-start;
        padding: 18px;
    }

    .filters-card {
        padding: 16px;
    }

    .filters .field {
        flex: 1 1 100%;
        min-width: 0;
    }

    .filters__actions {
        width: 100%;
        margin-left: 0;
    }

    .filters__actions .btn {
        flex: 1;
    }

    .agenda-item {
        display: grid;
        grid-template-columns: 58px minmax(0, 1fr);
        align-items: start;
        gap: 3px 14px;
        padding: 14px 18px;
    }

    .agenda-time {
        grid-row: 1 / span 2;
        align-self: start;
    }

    .agenda-body {
        grid-column: 2;
    }

    .agenda-item .badge {
        grid-column: 2;
        justify-self: start;
        margin: 3px 0 0;
    }

    .upcoming-item {
        padding: 12px 18px;
    }

    /* La tabla se convierte en una lista de tarjetas en móvil */
    .table-wrap {
        overflow-x: visible;
        contain: none;
    }

    .table {
        display: block;
        min-width: 0;
    }

    .table thead {
        display: none;
    }

    .table tbody {
        display: block;
    }

    .table tbody tr {
        display: grid;
        grid-template-columns: auto minmax(0, 1fr) auto;
        grid-template-areas:
            "date time status"
            "title title title"
            "contact contact actions";
        align-items: center;
        gap: 4px 10px;
        padding: 14px 16px;
        border-bottom: 1px solid var(--border);
    }

    .table tbody tr:last-child {
        border-bottom: none;
    }

    .table tbody tr:hover {
        background: transparent;
    }

    .table td {
        display: block;
        padding: 0;
        border: none;
        text-align: left;
    }

    .table th:last-child,
    .table td:last-child {
        text-align: left;
    }

    .table td:nth-child(1) {
        grid-area: date;
    }

    .table td:nth-child(2) {
        grid-area: time;
        justify-self: start;
    }

    .table td:nth-child(3) {
        grid-area: title;
    }

    .table td:nth-child(4) {
        grid-area: contact;
    }

    .table td:nth-child(5) {
        grid-area: status;
        justify-self: end;
    }

    .table td:nth-child(6) {
        grid-area: actions;
        justify-self: end;
    }

    .cell-time {
        flex-direction: column;
        gap: 0;
    }

    .cell-time small {
        font-size: 11px;
    }

    .cell-date {
        flex-direction: column;
        align-items: flex-start;
        gap: 2px;
    }

    .cell-title {
        max-width: 100%;
        white-space: normal;
        font-size: 14px;
    }

    .cell-sub {
        max-width: 100%;
    }

    .cell-contact {
        max-width: 100%;
    }

    .cell-date__main {
        font-size: 12.5px;
    }

    .tag {
        font-size: 9.5px;
    }

    .row-actions .icon-btn {
        width: 36px;
        height: 36px;
    }

    .table-foot {
        padding: 12px 16px;
    }

    /* Listado de usuarios en móvil */
    .table--users tbody tr {
        grid-template-columns: minmax(0, 1fr) auto;
        grid-template-areas:
            "user role"
            "email email"
            "appointments actions";
        gap: 6px 10px;
    }

    .table--users td:nth-child(1) {
        grid-area: user;
        justify-self: start;
    }

    .table--users td:nth-child(2) {
        grid-area: email;
    }

    .table--users td:nth-child(3) {
        grid-area: role;
        justify-self: end;
    }

    .table--users td:nth-child(4) {
        grid-area: appointments;
        justify-self: start;
    }

    .table--users td:nth-child(5) {
        display: none;
    }

    .table--users td:nth-child(6) {
        grid-area: actions;
        justify-self: end;
    }

    .table--users .user-cell strong {
        font-size: 14px;
    }

    .detail-hero {
        flex-direction: column;
        padding: 20px 18px;
    }

    .detail-hero__body h2 {
        font-size: 19px;
    }

    .meta-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .date-tile {
        flex-direction: row;
        justify-content: flex-start;
        gap: 10px;
        width: 100%;
        min-height: 0;
        padding: 12px 16px;
    }

    .date-tile__day {
        order: -1;
        margin: 0;
        font-size: 30px;
    }

    .date-tile__weekday {
        order: -2;
    }

    .date-tile__month {
        margin-left: auto;
    }

    .cal-toolbar {
        padding: 16px 18px;
    }

    .cal-hint {
        display: flex;
    }

    .cal-legend {
        padding: 12px 18px;
        gap: 12px;
    }

    .auth-card {
        padding: 28px 22px 22px;
    }

    .error-card {
        padding: 34px 22px;
    }
}

@media (max-width: 560px) {
    .stats {
        grid-template-columns: minmax(0, 1fr);
    }

    .status-options {
        grid-template-columns: minmax(0, 1fr);
    }

    .page-actions .btn {
        flex: 1;
    }

    .demo-label {
        width: 100%;
    }
}

@media (max-height: 780px) and (min-width: 981px) {
    .sidebar-tip {
        display: none;
    }
}

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