/* =========================================================================
   Estilos base de la plataforma. Mobile-first: los estilos por defecto son
   para móvil y se amplían con media queries para tablet (≥768px) y
   escritorio (≥1024px).
   ========================================================================= */

:root {
    --color-primary: #2563eb;
    --color-primary-dark: #1d4ed8;
    --color-text: #1f2937;
    --color-muted: #6b7280;
    --color-bg: #f9fafb;
    --color-surface: #ffffff;
    --color-border: #e5e7eb;
    --color-success-bg: #ecfdf5;
    --color-success: #047857;
    --color-error-bg: #fef2f2;
    --color-error: #b91c1c;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0, 0, 0, .08), 0 1px 2px rgba(0, 0, 0, .04);
    --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

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

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

body {
    margin: 0;
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.5;
    color: var(--color-text);
    background: var(--color-bg);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

img {
    max-width: 100%;
    height: auto;
}

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

.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 16px;
}

/* --- Botones --------------------------------------------------------------- */
.btn {
    display: inline-block;
    padding: 10px 18px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    font: inherit;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: background-color .15s ease;
}

.btn-primary {
    background: var(--color-primary);
    color: #fff;
}

.btn-primary:hover,
.btn-primary:focus-visible {
    background: var(--color-primary-dark);
}

.btn:focus-visible {
    outline: 3px solid rgba(37, 99, 235, .4);
    outline-offset: 2px;
}

/* --- Alertas --------------------------------------------------------------- */
.alert {
    margin: 16px 0;
    padding: 12px 16px;
    border-radius: var(--radius);
    border: 1px solid transparent;
}

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

.alert-error {
    background: var(--color-error-bg);
    color: var(--color-error);
    border-color: #fecaca;
}

/* --- Cabecera y pie --------------------------------------------------------- */
.site-header {
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
}

.site-header__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 60px;
}

.brand {
    font-weight: 700;
    font-size: 1.15rem;
    color: var(--color-text);
    text-decoration: none;
}

.site-footer {
    margin-top: auto;
    padding: 24px 0;
    color: var(--color-muted);
    font-size: .9rem;
    border-top: 1px solid var(--color-border);
    background: var(--color-surface);
}

/* --- Portada ---------------------------------------------------------------- */
.hero {
    padding: 48px 0;
}

.hero__title {
    margin: 0 0 16px;
    font-size: 1.75rem;
    line-height: 1.2;
}

.hero__lead {
    margin: 0;
    max-width: 640px;
    font-size: 1.05rem;
    color: var(--color-muted);
}

/* --- Página de error ------------------------------------------------------ */
.page-error {
    align-items: center;
    justify-content: center;
}

.error-box {
    text-align: center;
    padding: 32px 16px;
    max-width: 480px;
}

.error-code {
    margin: 0;
    font-size: 3.5rem;
    font-weight: 800;
    color: var(--color-primary);
}

.error-message {
    margin: 8px 0 24px;
    font-size: 1.2rem;
    font-weight: 500;
}

.site-header__nav {
    display: flex;
    align-items: center;
    gap: 16px;
}

.hero__actions {
    margin-top: 24px;
}

/* --- Utilidades --------------------------------------------------------------- */
.muted {
    color: var(--color-muted);
}

.visually-hidden {
    position: absolute !important;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

code {
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
    font-size: .9em;
    background: #f3f4f6;
    padding: 2px 6px;
    border-radius: 4px;
}

.btn-block {
    display: block;
    width: 100%;
    text-align: center;
}

.btn-link {
    background: none;
    border: 0;
    padding: 0;
    color: var(--color-primary);
    font-weight: 500;
}

.alert-info {
    background: #eff6ff;
    color: #1e40af;
    border-color: #bfdbfe;
}

/* --- Formularios -------------------------------------------------------------- */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    font-size: .95rem;
}

.form input[type="text"],
.form input[type="email"],
.form input[type="password"],
.form input[type="tel"],
.form select,
.form textarea {
    display: block;
    width: 100%;
    padding: 10px 12px;
    font: inherit;
    font-size: 16px; /* evita zoom automático en iOS */
    color: var(--color-text);
    background: #fff;
    border: 1px solid #d1d5db;
    border-radius: var(--radius);
}

.form input:focus,
.form select:focus,
.form textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .2);
}

.form [aria-invalid="true"] {
    border-color: var(--color-error);
}

.field-error {
    margin: 6px 0 0;
    color: var(--color-error);
    font-size: .875rem;
}

.field-hint {
    margin: 6px 0 0;
    color: var(--color-muted);
    font-size: .85rem;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0 16px;
}

.form-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 20px;
    font-size: .95rem;
}

.checkbox {
    display: flex !important;
    align-items: flex-start;
    gap: 8px;
    font-weight: 400 !important;
    cursor: pointer;
}

.checkbox input {
    margin-top: 4px;
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.password-field {
    position: relative;
}

.password-field input {
    padding-right: 84px !important;
}

.password-toggle {
    position: absolute;
    top: 50%;
    right: 6px;
    transform: translateY(-50%);
    padding: 6px 10px;
    font: inherit;
    font-size: .85rem;
    color: var(--color-primary);
    background: none;
    border: 0;
    cursor: pointer;
}

/* --- Autenticación ------------------------------------------------------------ */
.page-auth {
    background: linear-gradient(180deg, #eff6ff 0%, var(--color-bg) 320px);
}

.auth-wrap {
    width: 100%;
    max-width: 480px;
    margin: 0 auto;
    padding: 32px 16px 48px;
}

.auth-brand {
    display: block;
    margin-bottom: 20px;
    text-align: center;
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--color-text);
    text-decoration: none;
}

.auth-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    box-shadow: var(--shadow);
    padding: 24px 20px;
}

.auth-title {
    margin: 0 0 6px;
    font-size: 1.5rem;
}

.auth-subtitle {
    margin: 0 0 20px;
    color: var(--color-muted);
}

.auth-footer {
    margin: 20px 0 0;
    text-align: center;
    font-size: .95rem;
}

/* --- Paneles -------------------------------------------------------------------- */
.topbar {
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    position: sticky;
    top: 0;
    z-index: 10;
}

.topbar__inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    min-height: 60px;
}

.topbar__toggle {
    padding: 8px 12px;
    font: inherit;
    background: none;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    cursor: pointer;
}

.topbar__nav {
    display: none;
    flex-basis: 100%;
    flex-direction: column;
    gap: 4px;
    padding: 8px 0 16px;
}

.topbar__nav.is-open {
    display: flex;
}

.topbar__nav a {
    padding: 8px 0;
    color: var(--color-text);
    text-decoration: none;
}

.topbar__nav a.is-active {
    color: var(--color-primary);
    font-weight: 600;
}

.topbar__user {
    padding: 8px 0;
    color: var(--color-muted);
    font-size: .9rem;
}

.topbar__logout {
    margin: 0;
}

.panel-main {
    padding-top: 24px;
    padding-bottom: 48px;
}

.page-title {
    margin: 0 0 16px;
    font-size: 1.5rem;
}

.page-subtitle {
    margin: -8px 0 20px;
    color: var(--color-muted);
}

.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    box-shadow: var(--shadow);
    padding: 20px;
    margin-bottom: 20px;
}

.card--narrow {
    max-width: 720px;
}

.card__title {
    margin: 0 0 16px;
    font-size: 1.2rem;
}

.card__subtitle {
    margin: 24px 0 12px;
    font-size: 1rem;
}

.details {
    display: grid;
    grid-template-columns: 1fr;
    gap: 4px 16px;
    margin: 0;
}

.details dt {
    color: var(--color-muted);
    font-size: .9rem;
}

.details dd {
    margin: 0 0 12px;
}

.stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

.stat {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    padding: 16px;
    display: flex;
    flex-direction: column;
}

.stat__value {
    font-size: 1.6rem;
    font-weight: 700;
}

.stat__label {
    color: var(--color-muted);
    font-size: .9rem;
}

.badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: .8rem;
    font-weight: 600;
    background: #f3f4f6;
    color: var(--color-text);
}

.badge--trial { background: #eff6ff; color: #1d4ed8; }
.badge--active { background: var(--color-success-bg); color: var(--color-success); }
.badge--suspended,
.badge--cancelled { background: var(--color-error-bg); color: var(--color-error); }

.tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 0;
    margin: 0;
    list-style: none;
}

/* Tablas: en móvil cada fila se muestra como tarjeta */
.table-wrap {
    width: 100%;
}

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

.table thead {
    display: none;
}

.table tr {
    display: block;
    padding: 12px 0;
    border-bottom: 1px solid var(--color-border);
}

.table td {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 4px 0;
}

.table td[data-label]::before {
    content: attr(data-label);
    color: var(--color-muted);
    font-size: .85rem;
    flex-shrink: 0;
}

/* En móvil la tabla ocupa exactamente el ancho disponible y los textos largos
   (correos, códigos) se parten en vez de desbordar la página */
.table,
.table tbody {
    display: block;
    width: 100%;
}

.table td {
    min-width: 0;
    overflow-wrap: anywhere;
    text-align: right;
}

.table td:not([data-label]) {
    justify-content: flex-start;
}

/* --- Fase 3: configuración del negocio ---------------------------------------- */
.btn-secondary {
    background: #fff;
    color: var(--color-text);
    border-color: #d1d5db;
}

.btn-secondary:hover {
    background: #f3f4f6;
}

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

.btn-danger:hover {
    background: var(--color-error-bg);
}

.btn-small {
    padding: 6px 10px;
    font-size: .85rem;
}

.btn[disabled] {
    opacity: .5;
    cursor: not-allowed;
}

.small {
    font-size: .85rem;
}

.alert-warning {
    background: #fffbeb;
    color: #92400e;
    border-color: #fde68a;
}

.page-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}

.form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 20px;
}

.form--boxed {
    padding: 16px;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    margin-bottom: 20px;
}

.form--inline {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 12px;
}

.form--inline .form-group {
    flex: 1 1 260px;
    margin-bottom: 0;
}

.form-group--inline select {
    max-width: 220px;
}

.form input[type="number"],
.form input[type="time"],
.form input[type="date"],
.form input[type="url"],
.form input[type="file"] {
    display: block;
    width: 100%;
    padding: 10px 12px;
    font: inherit;
    font-size: 16px;
    border: 1px solid #d1d5db;
    border-radius: var(--radius);
    background: #fff;
}

.form input[type="color"] {
    width: 64px;
    height: 42px;
    padding: 2px;
    border: 1px solid #d1d5db;
    border-radius: var(--radius);
    background: #fff;
}

.fieldset {
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 12px 16px;
    margin: 0 0 16px;
}

.fieldset legend {
    padding: 0 6px;
    font-weight: 600;
}

.check-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 6px;
}

.logo-preview {
    display: block;
    max-width: 160px;
    max-height: 80px;
    margin-bottom: 8px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: #fff;
    padding: 4px;
}

.logo-preview--small {
    max-height: 48px;
    margin: 0;
}

.color-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 6px;
    vertical-align: middle;
}

.is-inactive td {
    opacity: .6;
}

.row-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.row-actions form {
    margin: 0;
}

.filter-tabs {
    display: flex;
    gap: 4px;
    margin: 0 0 12px;
    border-bottom: 1px solid var(--color-border);
}

.filter-tabs a {
    padding: 8px 12px;
    color: var(--color-muted);
    text-decoration: none;
    border-bottom: 2px solid transparent;
}

.filter-tabs a.is-active {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
    font-weight: 600;
}

.limit-usage {
    margin: 0 0 12px;
    font-size: .9rem;
}

.item-list {
    margin: 0 0 16px;
    padding-left: 20px;
}

.item-list li {
    margin-bottom: 4px;
}

/* Asistente */
.wizard-steps {
    margin-bottom: 16px;
}

.wizard-steps__count {
    margin: 0 0 8px;
    color: var(--color-muted);
    font-size: .9rem;
}

.wizard-steps ol {
    display: flex;
    gap: 6px;
    padding: 0;
    margin: 0;
    list-style: none;
}

.wizard-steps li {
    flex: 1;
    padding: 8px 4px;
    text-align: center;
    border-bottom: 3px solid var(--color-border);
    color: var(--color-muted);
    font-size: .85rem;
}

.wizard-steps li a {
    color: inherit;
    text-decoration: none;
}

.wizard-steps li.is-done {
    border-color: #93c5fd;
    color: var(--color-text);
}

.wizard-steps li.is-current {
    border-color: var(--color-primary);
    color: var(--color-primary);
    font-weight: 700;
}

.wizard-steps__label {
    display: none;
}

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

.choice-card {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 14px;
    border: 2px solid var(--color-border);
    border-radius: 12px;
    cursor: pointer;
    background: #fff;
}

.choice-card input {
    margin-top: 4px;
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.choice-card:has(input:checked) {
    border-color: var(--color-primary);
    background: #eff6ff;
}

.choice-card__body {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.form-group--full {
    grid-column: 1 / -1;
}

/* Horario semanal */
.week {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
}

.week-day {
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 10px 12px;
    margin: 0;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 16px;
}

.week-day__toggle {
    min-width: 120px;
    font-weight: 600 !important;
}

.week-day__closed {
    display: none;
}

.week-day.is-closed .week-day__hours {
    display: none;
}

.week-day.is-closed .week-day__closed {
    display: inline;
}

.week-day__hours {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 12px;
    flex: 1;
}

.week-day__hours > label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: .9rem;
    margin: 0;
}

.week-day__hours input[type="time"] {
    width: auto;
    display: inline-block;
    padding: 6px 8px;
}

.week-day__breaks {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex-basis: 100%;
}

.break-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    font-size: .9rem;
}

.week-day__error {
    flex-basis: 100%;
}

/* Plan */
.usage__row {
    margin-bottom: 14px;
}

.usage__label {
    display: flex;
    justify-content: space-between;
    margin-bottom: 4px;
}

.usage__bar {
    height: 8px;
    background: #e5e7eb;
    border-radius: 999px;
    overflow: hidden;
}

.usage__bar span {
    display: block;
    height: 100%;
    background: var(--color-primary);
}

.usage__bar.is-full span {
    background: var(--color-error);
}

.plan-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    margin-bottom: 16px;
}

.plan-card {
    border: 1px solid var(--color-border);
    border-radius: 12px;
    padding: 16px;
}

.plan-card.is-current {
    border: 2px solid var(--color-primary);
}

.plan-card h3 {
    margin: 0 0 6px;
}

.plan-card__price {
    font-size: 1.4rem;
    font-weight: 700;
    margin: 0 0 8px;
}

.plan-card ul {
    padding-left: 18px;
    margin: 8px 0 0;
}

/* --- Fase 5: panel con barra lateral ---------------------------------------------- */
.shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 264px;
    max-width: 85vw;
    background: #111827;
    color: #e5e7eb;
    display: flex;
    flex-direction: column;
    transform: translateX(-100%);
    transition: transform .2s ease;
    z-index: 30;
    overflow-y: auto;
}

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

.sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(17, 24, 39, .45);
    z-index: 25;
}

.sidebar__brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 18px 20px;
    font-weight: 700;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
}

.sidebar__brand a {
    color: #fff;
    text-decoration: none;
}

.sidebar__logo {
    width: 32px;
    height: 32px;
    object-fit: contain;
    border-radius: 6px;
    background: #fff;
}

.sidebar__nav {
    flex: 1;
    padding: 10px 0;
}

.sidebar__nav ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.sidebar__nav a {
    display: block;
    padding: 9px 20px;
    color: #d1d5db;
    text-decoration: none;
    border-left: 3px solid transparent;
    font-size: .95rem;
}

.sidebar__nav a:hover,
.sidebar__nav a:focus-visible {
    background: rgba(255, 255, 255, .06);
    color: #fff;
}

.sidebar__nav a.is-active {
    background: rgba(255, 255, 255, .1);
    color: #fff;
    border-left-color: var(--color-primary);
    font-weight: 600;
}

.sidebar__group {
    margin: 16px 20px 6px;
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: #9ca3af;
}

.sidebar__user {
    padding: 14px 20px;
    border-top: 1px solid rgba(255, 255, 255, .08);
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sidebar__user .btn-link {
    color: #93c5fd;
    text-align: left;
}

.shell__main {
    flex: 1;
    min-width: 0;
}

.mobilebar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
}

.mobilebar__toggle {
    padding: 8px 12px;
    font: inherit;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: #fff;
    cursor: pointer;
}

.mobilebar__brand {
    font-weight: 700;
}

.page-panel .panel-main {
    padding: 20px 16px 48px;
    max-width: 1280px;
}

.section-title {
    font-size: 1rem;
    margin: 8px 0 10px;
    color: var(--color-muted);
}

.grid-2 {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0 20px;
}

.hero-number {
    font-size: 2.2rem;
    font-weight: 800;
    margin: 0 0 4px;
}

.stat--link {
    color: inherit;
    text-decoration: none;
}

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

.details--compact dd {
    margin-bottom: 6px;
}

.alert-info a,
.alert-warning a,
.alert-error a {
    font-weight: 600;
    margin-left: 6px;
}

/* Insignias de estado de reserva y de pago (siempre con texto, nunca solo color) */
.badge--bk-draft { background: #f3f4f6; color: #374151; }
.badge--bk-pending_payment { background: #fffbeb; color: #92400e; }
.badge--bk-confirmed { background: var(--color-success-bg); color: var(--color-success); }
.badge--bk-completed { background: #eef2ff; color: #3730a3; }
.badge--bk-cancelled,
.badge--bk-refunded,
.badge--bk-no_show { background: var(--color-error-bg); color: var(--color-error); }
.badge--pay-pendiente_pago { background: #fffbeb; color: #92400e; }
.badge--pay-pagado { background: var(--color-success-bg); color: var(--color-success); }
.badge--pay-anticipo_pagado { background: #ecfeff; color: #155e75; }
.badge--pay-cancelado,
.badge--pay-reembolsado { background: #f3f4f6; color: #4b5563; }
.badge--sub-trial { background: #eff6ff; color: #1d4ed8; }
.badge--sub-active { background: var(--color-success-bg); color: var(--color-success); }
.badge--sub-past_due,
.badge--sub-cancelled,
.badge--sub-expired { background: var(--color-error-bg); color: var(--color-error); }

/* Listas de reservas compactas */
.booking-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.booking-list a {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--color-border);
    color: inherit;
    text-decoration: none;
}

.booking-list a:hover .booking-list__main strong {
    color: var(--color-primary);
}

.booking-list__time {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    min-width: 88px;
}

.booking-list__main {
    flex: 1;
    min-width: 160px;
}

/* Filtros */
.filters {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0 12px;
    align-items: end;
}

.filters .form-group {
    margin-bottom: 12px;
}

.filters input,
.filters select {
    width: 100%;
    padding: 9px 10px;
    font: inherit;
    border: 1px solid #d1d5db;
    border-radius: var(--radius);
    background: #fff;
}

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

.filter-tabs--inline {
    border-bottom: 0;
    margin: 0;
    flex-wrap: wrap;
}

.pagination {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    margin: 12px 0;
}

.pagination a,
.pagination span {
    padding: 6px 10px;
    border-radius: var(--radius);
}

.pagination a {
    border: 1px solid var(--color-border);
    background: #fff;
    text-decoration: none;
}

.pagination .is-current {
    background: var(--color-primary);
    color: #fff;
}

.action-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.action-row form,
.inline-form {
    margin: 0;
    display: inline-flex;
    gap: 6px;
    align-items: center;
}

.inline-form input {
    padding: 6px 8px;
    font: inherit;
    font-size: .85rem;
    border: 1px solid #d1d5db;
    border-radius: var(--radius);
    max-width: 180px;
}

.timeline {
    list-style: none;
    margin: 0;
    padding: 0 0 0 14px;
    border-left: 2px solid var(--color-border);
}

.timeline li {
    position: relative;
    padding: 6px 0 6px 10px;
}

.timeline li::before {
    content: "";
    position: absolute;
    left: -20px;
    top: 13px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--color-primary);
    border: 2px solid #fff;
}

/* Selector de horarios */
.slot-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
    gap: 8px;
    margin: 8px 0 16px;
}

.slot {
    position: relative;
    cursor: pointer;
}

.slot input {
    position: absolute;
    opacity: 0;
    inset: 0;
}

.slot span {
    display: block;
    padding: 10px 6px;
    text-align: center;
    border: 1px solid #d1d5db;
    border-radius: var(--radius);
    background: #fff;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.slot input:checked + span {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: #fff;
}

.slot input:focus-visible + span {
    outline: 3px solid rgba(37, 99, 235, .4);
    outline-offset: 2px;
}

.slot.is-disabled {
    cursor: not-allowed;
}

.slot.is-disabled span {
    background: #f3f4f6;
    color: #9ca3af;
    text-decoration: line-through;
    font-weight: 400;
}

.client-picker {
    position: relative;
}

.client-results {
    list-style: none;
    margin: 4px 0 0;
    padding: 4px 0;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: #fff;
    box-shadow: var(--shadow);
    max-height: 240px;
    overflow-y: auto;
}

.client-results button {
    display: block;
    width: 100%;
    padding: 8px 12px;
    text-align: left;
    font: inherit;
    background: none;
    border: 0;
    cursor: pointer;
}

.client-results button:hover,
.client-results button:focus-visible {
    background: #eff6ff;
}

/* Calendario */
.cal-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

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

.cal-toolbar__title {
    margin-left: 8px;
}

.cal-toolbar__filters {
    display: flex;
    gap: 8px;
}

.cal-toolbar__filters select {
    padding: 7px 8px;
    font: inherit;
    border: 1px solid #d1d5db;
    border-radius: var(--radius);
}

.cal-grid-wrap,
.cal-month-wrap {
    overflow-x: auto;
    padding: 12px;
}

.cal-grid {
    display: grid;
    grid-template-columns: 52px repeat(var(--cal-cols), minmax(120px, 1fr));
    min-width: calc(52px + var(--cal-cols) * 120px);
}

.cal-grid__corner,
.cal-grid__head {
    position: sticky;
    top: 0;
    background: var(--color-surface);
    z-index: 2;
    padding: 6px 4px;
    font-weight: 600;
    font-size: .85rem;
    text-align: center;
    border-bottom: 1px solid var(--color-border);
}

.cal-grid__head.is-today {
    color: var(--color-primary);
}

.cal-grid__times {
    position: relative;
}

.cal-grid__times span {
    position: absolute;
    right: 6px;
    transform: translateY(-50%);
    font-size: .75rem;
    color: var(--color-muted);
    font-variant-numeric: tabular-nums;
}

.cal-grid__times span:first-child {
    transform: none; /* la primera hora no se corta contra el encabezado */
}

.cal-grid__col {
    position: relative;
    border-left: 1px solid var(--color-border);
}

.cal-slot {
    position: absolute;
    left: 0;
    right: 0;
    border-top: 1px dashed #eef0f3;
}

a.cal-slot:hover,
a.cal-slot:focus-visible {
    background: #eff6ff;
}

.cal-event {
    position: absolute;
    left: 3px;
    right: 3px;
    padding: 2px 6px;
    overflow: hidden;
    font-size: .78rem;
    line-height: 1.25;
    color: var(--color-text);
    text-decoration: none;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-left-width: 4px;
    border-radius: 6px;
    z-index: 1;
}

.cal-event:hover,
.cal-event:focus-visible {
    z-index: 3;
    box-shadow: var(--shadow);
}

.cal-event__sub {
    display: block;
    color: var(--color-muted);
}

.cal-event--pending_payment { background: #fffbeb; border-color: #fde68a; }
.cal-event--draft { background: #f9fafb; border-style: dashed; }
.cal-event--completed { background: #eef2ff; border-color: #c7d2fe; }
.cal-event--no_show { background: var(--color-error-bg); border-color: #fecaca; }

.cal-month {
    display: grid;
    grid-template-columns: repeat(7, minmax(110px, 1fr));
    min-width: 770px;
    border-top: 1px solid var(--color-border);
    border-left: 1px solid var(--color-border);
}

.cal-month__head {
    padding: 6px;
    font-size: .8rem;
    font-weight: 600;
    text-align: center;
    border-right: 1px solid var(--color-border);
    border-bottom: 1px solid var(--color-border);
    background: var(--color-bg);
}

.cal-month__cell {
    position: relative;
    min-height: 104px;
    padding: 4px;
    border-right: 1px solid var(--color-border);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.cal-month__cell.is-outside {
    background: #fafafa;
    color: var(--color-muted);
}

.cal-month__cell.is-today .cal-month__day {
    background: var(--color-primary);
    color: #fff;
}

.cal-month__day {
    align-self: flex-start;
    padding: 0 6px;
    border-radius: 999px;
    font-size: .85rem;
    font-weight: 600;
    color: inherit;
    text-decoration: none;
}

.cal-chip {
    display: block;
    padding: 1px 4px;
    font-size: .72rem;
    border-radius: 4px;
    background: #eff6ff;
    color: var(--color-text);
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cal-month__add {
    position: absolute;
    right: 4px;
    top: 2px;
    padding: 0 6px;
    text-decoration: none;
    font-weight: 700;
    color: var(--color-muted);
}

.cal-month__add:hover {
    color: var(--color-primary);
}

/* Gráficos */
.chart {
    position: relative;
    margin: 0;
}

.chart__svg {
    width: 100%;
    height: auto;
    display: block;
}

.chart__grid {
    stroke: #eef0f3;
    stroke-width: 1;
}

.chart__baseline {
    stroke: #d1d5db;
}

.chart__axis {
    font-size: 11px;
    fill: var(--color-muted);
    font-family: var(--font);
}

.chart__bar {
    fill: var(--color-primary);
}

.chart__hit {
    fill: transparent;
}

.chart__item:hover .chart__bar,
.chart__item:focus .chart__bar {
    fill: var(--color-primary-dark);
}

.chart__item:focus {
    outline: none;
}

.chart__item:focus .chart__hit {
    fill: rgba(37, 99, 235, .06);
}

.chart__tooltip {
    position: absolute;
    pointer-events: none;
    padding: 6px 10px;
    font-size: .8rem;
    background: #111827;
    color: #fff;
    border-radius: 6px;
    white-space: nowrap;
    transform: translate(-50%, -110%);
}

.chart__table {
    margin-top: 8px;
    font-size: .9rem;
}

.table--plain thead {
    display: table-header-group;
}

.table--plain tr {
    display: table-row;
    padding: 0;
}

.table--plain td,
.table--plain th {
    display: table-cell;
    padding: 4px 8px;
    border-bottom: 1px solid var(--color-border);
}

.table--plain td::before {
    content: none !important;
}

.rank {
    list-style: none;
    margin: 0;
    padding: 0;
}

.rank li {
    display: grid;
    grid-template-columns: 1fr;
    gap: 4px;
    padding: 8px 0;
    border-bottom: 1px solid var(--color-border);
}

.rank__bar {
    height: 8px;
    background: #eef0f3;
    border-radius: 999px;
    overflow: hidden;
}

.rank__bar span {
    display: block;
    height: 100%;
    background: var(--color-primary);
    border-radius: 0 4px 4px 0;
}

.rank__value {
    color: var(--color-muted);
    font-size: .9rem;
    font-variant-numeric: tabular-nums;
}

/* Integración */
.copy-field {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin-bottom: 12px;
}

.copy-field input,
.copy-field textarea {
    flex: 1 1 280px;
    padding: 9px 10px;
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
    font-size: .85rem;
    border: 1px solid #d1d5db;
    border-radius: var(--radius);
    background: var(--color-bg);
}

.share {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.share .btn {
    color: #fff;
}

.share--whatsapp { background: #128c4b; }
.share--facebook { background: #1b4fb3; }
.share--x { background: #111827; }
.share--telegram { background: #1c7bb5; }

.widget-preview {
    width: 100%;
    min-height: 560px;
    border: 1px solid var(--color-border);
    border-radius: 12px;
    background: #fff;
}

.item-list--actions li {
    display: flex;
    align-items: center;
    gap: 12px;
}

.choice-grid--3 {
    margin-bottom: 16px;
}

.table--matrix td:not(:first-child) {
    text-align: center;
}

.message-preview {
    padding: 12px 14px;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    white-space: normal;
    word-wrap: break-word;
}

/* Página pública y widget */
.page-public,
.page-embed {
    background: var(--color-bg);
}

.catalog {
    width: 100%;
    max-width: 760px;
    margin: 0 auto;
    padding: 24px 16px 40px;
}

.catalog--embed {
    padding-top: 16px;
}

.catalog__header {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 12px;
}

.catalog__logo {
    width: 64px;
    height: 64px;
    object-fit: contain;
    border-radius: 12px;
    background: #fff;
    border: 1px solid var(--color-border);
}

.catalog__name {
    margin: 0;
    font-size: 1.6rem;
}

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

.catalog__section {
    margin-top: 24px;
}

.catalog__section h2 {
    font-size: 1.1rem;
    border-bottom: 2px solid var(--color-primary);
    padding-bottom: 6px;
}

.catalog__list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.catalog__item {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--color-border);
}

.catalog__item p {
    margin: 4px 0 0;
}

.catalog__meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    white-space: nowrap;
}

.catalog__chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    list-style: none;
    padding: 0;
}

.catalog__chips li {
    padding: 4px 12px;
    border-radius: 999px;
    background: #fff;
    border: 1px solid var(--color-border);
}

.catalog__hours {
    display: grid;
    grid-template-columns: 120px 1fr;
    gap: 4px 12px;
    margin: 0;
}

.catalog__hours dd {
    margin: 0;
    font-variant-numeric: tabular-nums;
}

.catalog__contact {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.catalog__open {
    margin-top: 24px;
    text-align: center;
}

.theme-dark {
    --color-bg: #0f172a;
    --color-surface: #111827;
    --color-text: #e5e7eb;
    --color-muted: #9ca3af;
    --color-border: #1f2937;
    color: var(--color-text);
}

@media (prefers-color-scheme: dark) {
    .theme-auto {
        --color-bg: #0f172a;
        --color-surface: #111827;
        --color-text: #e5e7eb;
        --color-muted: #9ca3af;
        --color-border: #1f2937;
        color: var(--color-text);
    }
}

/* --- Tablet ----------------------------------------------------------------- */
@media (min-width: 768px) {
    .container {
        padding: 0 24px;
    }

    .form-grid {
        grid-template-columns: 1fr 1fr;
    }

    .auth-card {
        padding: 32px;
    }

    .stats {
        grid-template-columns: repeat(4, 1fr);
    }

    .details {
        grid-template-columns: 200px 1fr;
    }

    .details dd {
        margin-bottom: 8px;
    }

    .table {
        display: table;
    }

    .table tbody {
        display: table-row-group;
    }

    .table td {
        text-align: left;
    }

    .table thead {
        display: table-header-group;
    }

    .table tr {
        display: table-row;
        padding: 0;
    }

    .table th,
    .table td {
        display: table-cell;
        padding: 10px 12px;
        text-align: left;
        border-bottom: 1px solid var(--color-border);
        vertical-align: top;
    }

    .table th {
        font-size: .85rem;
        color: var(--color-muted);
        font-weight: 600;
    }

    .table td[data-label]::before {
        content: none;
    }

    .wizard-steps__label {
        display: inline;
    }

    .choice-grid,
    .check-grid,
    .plan-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .filters {
        grid-template-columns: repeat(3, 1fr);
    }

    .rank li {
        grid-template-columns: minmax(140px, 1fr) 2fr auto;
        align-items: center;
        gap: 12px;
    }

    .page-panel .panel-main {
        padding: 24px 24px 48px;
    }

    .hero {
        padding: 80px 0;
    }

    .hero__title {
        font-size: 2.4rem;
    }
}

/* --- Escritorio ------------------------------------------------------------- */
@media (min-width: 1024px) {
    .sidebar {
        position: sticky;
        top: 0;
        height: 100vh;
        transform: none;
        flex-shrink: 0;
    }

    .sidebar-backdrop,
    .mobilebar {
        display: none !important;
    }

    .grid-2 {
        grid-template-columns: 1fr 1fr;
    }

    .filters {
        grid-template-columns: repeat(4, 1fr);
    }

    .choice-grid--3 {
        grid-template-columns: repeat(3, 1fr);
    }

    .page-panel .panel-main {
        padding: 28px 32px 56px;
    }

    .topbar__toggle {
        display: none;
    }

    .topbar__nav,
    .topbar__nav.is-open {
        display: flex;
        flex-basis: auto;
        flex-direction: row;
        align-items: center;
        gap: 20px;
        padding: 0;
    }

    .hero {
        padding: 112px 0;
    }

    .hero__title {
        font-size: 3rem;
        max-width: 820px;
    }
}

@media (prefers-reduced-motion: reduce) {
    * {
        transition: none !important;
    }
}

/* Botones secundarios legibles en el widget con tema oscuro */
.theme-dark .btn-secondary {
    background: #1f2937;
    color: #e5e7eb;
    border-color: #374151;
}

@media (prefers-color-scheme: dark) {
    .theme-auto .btn-secondary {
        background: #1f2937;
        color: #e5e7eb;
        border-color: #374151;
    }
}
