/* ==========================================================================
   Interfaz administrativa — estilos base
   Los colores de marca (--brand, --brand-sidebar) se sobrescriben por negocio
   desde /theme.css. No hay identidad de marca fija en este archivo.
   ========================================================================== */

@font-face {
    font-family: "InterVariable";
    font-style: normal;
    font-display: swap;
    font-weight: 100 900;
    src: url("../vendor/inter/inter-latin-wght-normal.woff2") format("woff2-variations");
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
    font-family: "InterVariable";
    font-style: normal;
    font-display: swap;
    font-weight: 100 900;
    src: url("../vendor/inter/inter-latin-ext-wght-normal.woff2") format("woff2-variations");
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
    --brand: #7C5CE0;
    --brand-rgb: 124, 92, 224;
    --brand-contrast: #FFFFFF;
    --brand-hover: #6A4BD0;
    --brand-soft: #F1EDFD;
    --brand-sidebar: #1E1B3A;
    --brand-sidebar-2: #2A2550;

    --app-bg: #F6F5FB;
    --surface: #FFFFFF;
    --border: #ECEAF3;
    --border-strong: #DEDBEA;
    --text: #1F1D2B;
    --text-muted: #6E6B80;
    --text-soft: #9A97AA;

    --ok: #1F9D63;      --ok-soft: #E5F6EE;
    --warn: #B7791F;    --warn-soft: #FFF4DE;
    --danger: #D14343;  --danger-soft: #FDECEC;
    --info: #2F6FD6;    --info-soft: #E7F0FD;
    --pending: #6B6880; --pending-soft: #F0EFF5;

    --radius: 14px;
    --radius-sm: 10px;
    --shadow: 0 1px 2px rgba(30, 27, 58, .04), 0 4px 16px rgba(30, 27, 58, .05);
    --sidebar-w: 248px;
    --footer-h: 34px;

    --bs-body-font-family: "InterVariable", "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    --bs-body-color: var(--text);
    --bs-body-bg: var(--app-bg);
    --bs-border-color: var(--border);
    --bs-primary: var(--brand);
    --bs-primary-rgb: var(--brand-rgb);
    --bs-link-color: var(--brand);
    --bs-link-color-rgb: var(--brand-rgb);
    --bs-link-hover-color: var(--brand-hover);
    --bs-border-radius: var(--radius-sm);
    --bs-focus-ring-color: rgba(var(--brand-rgb), .25);
}

html, body { min-height: 100%; }
body {
    font-family: var(--bs-body-font-family);
    font-size: .9rem;
    background: var(--app-bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
}
a { text-decoration: none; }
.text-muted, .text-secondary { color: var(--text-muted) !important; }
.small-label { font-size: .75rem; color: var(--text-muted); font-weight: 500; }
.fw-semibold { font-weight: 600 !important; }
.tabular { font-variant-numeric: tabular-nums; }

/* ---------- Skip link (accesibilidad) ---------- */
.skip-link {
    position: absolute; left: -999px; top: 8px; z-index: 2000;
    background: var(--surface); padding: .5rem 1rem; border-radius: 8px; box-shadow: var(--shadow);
}
.skip-link:focus { left: 8px; }

/* ---------- Estructura ---------- */
.app-shell { display: flex; min-height: 100vh; }
.app-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.app-content { padding: 24px 28px 40px; flex: 1; }

/* ---------- Pie de página global (fijo; el contenido reserva su alto) ---------- */
.app-main { padding-bottom: calc(var(--footer-h) + env(safe-area-inset-bottom, 0px)); }
.app-footer {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 900;
    height: calc(var(--footer-h) + env(safe-area-inset-bottom, 0px));
    padding: 0 16px env(safe-area-inset-bottom, 0px);
    display: flex; align-items: center; justify-content: center; gap: .3em;
    background: var(--surface); border-top: 1px solid var(--border);
    color: var(--text-muted); font-size: .72rem; letter-spacing: .02em; white-space: nowrap;
}
.app-footer-brand { font-weight: 600; color: var(--text); }
@media (min-width: 992px) {
    /* Junto al menú lateral fijo: solo ocupa la columna de contenido. */
    .app-shell ~ .app-footer { left: var(--sidebar-w); }
}

/* ---------- Sidebar ---------- */
.sidebar {
    width: var(--sidebar-w);
    background: linear-gradient(180deg, var(--brand-sidebar) 0%, var(--brand-sidebar-2) 100%);
    color: #E7E5F3;
    display: flex; flex-direction: column;
}
@media (min-width: 992px) {
    .sidebar {
        position: sticky; top: 0; height: 100vh; flex: 0 0 var(--sidebar-w);
        border-radius: 0 0 0 0;
    }
    .sidebar .offcanvas-body { display: flex; flex-direction: column; height: 100%; overflow-y: auto; padding: 0; }
}
.sidebar.offcanvas-lg { --bs-offcanvas-width: 272px; --bs-offcanvas-bg: var(--brand-sidebar); }
.sidebar .offcanvas-header { color: #fff; }
.sidebar-brand { display: flex; align-items: center; gap: 12px; padding: 22px 22px 18px; color: #fff; }
.sidebar-brand:hover { color: #fff; }
.brand-mark {
    width: 40px; height: 40px; border-radius: 12px; flex: 0 0 40px;
    display: grid; place-items: center; font-weight: 700; font-size: .95rem;
    background: rgba(255, 255, 255, .12); color: #fff; letter-spacing: .02em;
}
.brand-logo { max-width: 44px; max-height: 44px; border-radius: 10px; background: #fff; object-fit: contain; padding: 3px; }
/* Logotipo horizontal: placa blanca a lo ancho; conserva la proporción, sin recortes. */
.sidebar-brand.is-wordmark { flex-direction: column; align-items: stretch; gap: 6px; padding: 18px 16px 14px; }
.brand-plate { display: flex; align-items: center; justify-content: center; background: #fff; border-radius: 12px; padding: 8px 10px; }
.brand-wordmark { display: block; width: auto; height: auto; max-width: 100%; max-height: 72px; object-fit: contain; }
/* Logotipo oficial (icono cuadrado con transparencia): centrado sobre el nombre, sin deformarlo. */
.sidebar-brand.is-app-icon { flex-direction: column; align-items: center; gap: 8px; padding: 20px 18px 16px; text-align: center; }
@media (max-width: 991.98px) { .sidebar-brand.is-app-icon { padding-top: 0; } }
.brand-icon { display: block; width: 88px; height: 88px; object-fit: contain; flex: 0 0 auto; }
.sidebar-brand.is-app-icon .brand-name { font-size: .92rem; line-height: 1.25; }
.brand-name { font-weight: 650; font-size: 1.05rem; line-height: 1.15; color: #fff; word-break: break-word; }
.brand-tagline { font-size: .72rem; color: rgba(255, 255, 255, .62); line-height: 1.2; margin-top: 2px; }

.sidebar-nav { list-style: none; margin: 6px 0 0; padding: 0 14px; display: flex; flex-direction: column; gap: 3px; }
.sidebar-nav .nav-section { font-size: .66rem; text-transform: uppercase; letter-spacing: .08em; color: rgba(255, 255, 255, .42); padding: 14px 12px 4px; }
.sidebar-link {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 14px; border-radius: 10px;
    color: rgba(255, 255, 255, .82); font-weight: 500; font-size: .92rem;
    transition: background-color .15s ease, color .15s ease;
}
.sidebar-link i { font-size: 1.1rem; width: 20px; text-align: center; opacity: .9; }
.sidebar-link:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.sidebar-link.active {
    background: var(--brand); color: var(--brand-contrast);
    box-shadow: 0 6px 16px rgba(var(--brand-rgb), .35);
}
.sidebar-link:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.sidebar-user {
    margin-top: auto; padding: 16px 20px; display: flex; align-items: center; gap: 12px;
    border-top: 1px solid rgba(255, 255, 255, .08);
}
.sidebar-user .avatar { background: rgba(255, 255, 255, .14); color: #fff; }
.sidebar-user .u-name { color: #fff; font-weight: 600; font-size: .86rem; line-height: 1.2; }
.sidebar-user .u-role { color: rgba(255, 255, 255, .6); font-size: .74rem; }

/* ---------- Topbar ---------- */
.topbar {
    display: flex; align-items: center; gap: 14px;
    padding: 14px 28px; background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 1020;
}
.topbar-search { flex: 1 1 auto; max-width: 420px; position: relative; }
.topbar-search i { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--text-soft); }
.topbar-search input {
    padding-left: 38px; background: #F6F5FA; border: 1px solid transparent; border-radius: 10px; height: 40px;
}
.topbar-search input:focus { background: #fff; border-color: rgba(var(--brand-rgb), .4); }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.icon-btn {
    width: 40px; height: 40px; border-radius: 10px; display: inline-grid; place-items: center;
    border: 0; background: transparent; color: var(--text-muted); position: relative; font-size: 1.15rem;
}
.icon-btn:hover { background: #F3F2F8; color: var(--text); }
.icon-btn .dot {
    position: absolute; top: 6px; right: 6px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px;
    background: var(--danger); color: #fff; font-size: .62rem; font-weight: 700; display: grid; place-items: center;
}
.status-pill {
    display: flex; align-items: center; gap: 10px; padding: 6px 12px; border-radius: 12px;
    background: #F8F7FC; border: 1px solid var(--border); line-height: 1.2;
}
.status-pill .dot-state { width: 9px; height: 9px; border-radius: 50%; background: var(--warn); flex: 0 0 9px; }
.status-pill .t1 { font-weight: 600; font-size: .8rem; }
.status-pill .t2 { font-size: .72rem; color: var(--text-muted); }

/* ---------- Avatares ---------- */
.avatar {
    width: 38px; height: 38px; border-radius: 50%; display: inline-grid; place-items: center;
    background: var(--brand-soft); color: var(--brand); font-weight: 650; font-size: .82rem; flex: 0 0 auto;
}
.avatar-lg { width: 64px; height: 64px; font-size: 1.25rem; }

/* ---------- Encabezado de página ---------- */
.page-header { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 14px; margin-bottom: 22px; }
.page-title { font-size: 1.65rem; font-weight: 700; margin: 0; letter-spacing: -.01em; }
.page-subtitle { color: var(--text-muted); margin: 4px 0 0; font-size: .95rem; }
.breadcrumb { font-size: .8rem; margin-bottom: 4px; }

/* ---------- Tarjetas ---------- */
.card, .panel {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.panel-header {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    padding: 16px 18px 10px;
}
.panel-title { font-size: .95rem; font-weight: 650; margin: 0; display: flex; align-items: center; gap: 9px; }
.panel-title i { color: var(--brand); font-size: 1.05rem; }
.panel-link { font-size: .78rem; font-weight: 600; }
.panel-body { padding: 6px 18px 16px; }
.panel-footer { padding: 12px 18px; border-top: 1px solid var(--border); }

/* KPI */
.kpi-card { padding: 20px; display: flex; gap: 16px; align-items: flex-start; height: 100%; }
.kpi-icon {
    width: 48px; height: 48px; border-radius: 12px; display: grid; place-items: center; font-size: 1.35rem; flex: 0 0 48px;
}
.kpi-green { background: var(--ok-soft); color: var(--ok); }
.kpi-purple { background: var(--brand-soft); color: var(--brand); }
.kpi-red { background: var(--danger-soft); color: var(--danger); }
.kpi-yellow { background: var(--warn-soft); color: #C98A12; }
.kpi-blue { background: var(--info-soft); color: var(--info); }
.kpi-label { color: var(--text-muted); font-size: .85rem; font-weight: 500; }
.kpi-value { font-size: 1.45rem; font-weight: 700; letter-spacing: -.01em; margin: 2px 0; white-space: nowrap; }
.kpi-delta { font-size: .8rem; font-weight: 600; }
.kpi-delta.up { color: var(--ok); }
.kpi-delta.down { color: var(--danger); }
.kpi-delta .muted { color: var(--text-soft); font-weight: 500; }
@media (max-width: 1399.98px) { .kpi-value { font-size: 1.25rem; } }

/* Listas de paneles */
.list-rows { list-style: none; margin: 0; padding: 0; }
.list-rows li { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--border); }
.list-rows li:last-child { border-bottom: 0; }
.list-rows .primary { font-weight: 600; font-size: .87rem; line-height: 1.25; }
.list-rows .secondary { color: var(--text-muted); font-size: .78rem; }
.rank {
    width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; flex: 0 0 28px;
    background: var(--brand-soft); color: var(--brand); font-weight: 700; font-size: .78rem;
}
.time-col { width: 72px; flex: 0 0 72px; color: var(--text-muted); font-size: .8rem; font-weight: 500; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 9px; }
.status-dot.info { background: var(--info); }
.status-dot.success { background: var(--ok); }
.status-dot.warning { background: #E3A008; }
.status-dot.danger { background: var(--danger); }
.status-dot.primary { background: var(--brand); }
.status-dot.secondary, .status-dot.pending { background: var(--text-soft); }

/* Badges suaves */
.badge-soft {
    display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 6px;
    font-size: .72rem; font-weight: 600; white-space: nowrap; line-height: 1.4;
}
.badge-soft-success { background: var(--ok-soft); color: var(--ok); }
.badge-soft-warning { background: var(--warn-soft); color: var(--warn); }
.badge-soft-danger { background: var(--danger-soft); color: var(--danger); }
.badge-soft-info { background: var(--info-soft); color: var(--info); }
.badge-soft-primary { background: var(--brand-soft); color: var(--brand); }
.badge-soft-pending, .badge-soft-secondary { background: var(--pending-soft); color: var(--pending); }

/* ---------- Botones ---------- */
.btn { font-weight: 600; border-radius: 10px; font-size: .87rem; padding: .5rem 1rem; }
.btn-sm { font-size: .78rem; padding: .3rem .7rem; border-radius: 8px; }
.btn-primary {
    --bs-btn-bg: var(--brand); --bs-btn-border-color: var(--brand); --bs-btn-color: var(--brand-contrast);
    --bs-btn-hover-bg: var(--brand-hover); --bs-btn-hover-border-color: var(--brand-hover); --bs-btn-hover-color: var(--brand-contrast);
    --bs-btn-active-bg: var(--brand-hover); --bs-btn-active-border-color: var(--brand-hover); --bs-btn-active-color: var(--brand-contrast);
    --bs-btn-disabled-bg: var(--brand); --bs-btn-disabled-border-color: var(--brand); --bs-btn-disabled-color: var(--brand-contrast);
}
.btn-outline-primary {
    --bs-btn-color: var(--brand); --bs-btn-border-color: rgba(var(--brand-rgb), .45);
    --bs-btn-hover-bg: var(--brand-soft); --bs-btn-hover-color: var(--brand); --bs-btn-hover-border-color: var(--brand);
    --bs-btn-active-bg: var(--brand-soft); --bs-btn-active-color: var(--brand); --bs-btn-active-border-color: var(--brand);
}
.btn-success {
    --bs-btn-bg: #1FA971; --bs-btn-border-color: #1FA971; --bs-btn-hover-bg: #178F5F; --bs-btn-hover-border-color: #178F5F;
}
.btn-light { --bs-btn-bg: #F3F2F8; --bs-btn-border-color: #F3F2F8; --bs-btn-hover-bg: #E9E7F2; --bs-btn-hover-border-color: #E9E7F2; }
.btn-icon { width: 34px; height: 34px; padding: 0; display: inline-grid; place-items: center; }
.btn .spinner-border { width: 1rem; height: 1rem; border-width: .15em; }

/* ---------- Formularios ---------- */
.form-label { font-weight: 600; font-size: .82rem; margin-bottom: .35rem; }
.form-control, .form-select { border-radius: 10px; border-color: var(--border-strong); font-size: .88rem; padding: .5rem .8rem; }
.form-control:focus, .form-select:focus { border-color: rgba(var(--brand-rgb), .6); box-shadow: 0 0 0 .2rem rgba(var(--brand-rgb), .15); }
.form-check-input:checked { background-color: var(--brand); border-color: var(--brand); }
.form-text { font-size: .76rem; color: var(--text-muted); }
.required::after { content: " *"; color: var(--danger); }
.form-section { padding: 20px; }
.form-section + .form-section { border-top: 1px solid var(--border); }
.form-section-title { font-size: .95rem; font-weight: 650; margin-bottom: 14px; }
.form-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; padding: 16px 20px; border-top: 1px solid var(--border); }

/* Segmentados (Día/Semana/Mes, Servicios/Productos) */
.segmented { display: inline-flex; background: #F3F2F8; border-radius: 10px; padding: 3px; gap: 2px; }
.segmented a, .segmented button {
    border: 0; background: transparent; padding: 6px 14px; border-radius: 8px; font-size: .8rem; font-weight: 600; color: var(--text-muted);
}
.segmented .active { background: var(--surface); color: var(--brand); box-shadow: 0 1px 3px rgba(0, 0, 0, .08); }

/* Pestañas */
.tabs-app { border-bottom: 1px solid var(--border); gap: 4px; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: thin; }
.tabs-app .nav-link {
    border: 0; border-bottom: 2px solid transparent; color: var(--text-muted); font-weight: 600; font-size: .85rem;
    padding: 10px 14px; border-radius: 0; white-space: nowrap;
}
.tabs-app .nav-link.active { color: var(--brand); border-bottom-color: var(--brand); background: transparent; }

/* ---------- Tablas ---------- */
.table-app { margin: 0; font-size: .85rem; --bs-table-bg: transparent; }
.table-app thead th {
    background: #F8F7FC; color: var(--text-muted); font-weight: 600; font-size: .76rem; text-transform: none;
    border-bottom: 1px solid var(--border); padding: 11px 14px; white-space: nowrap;
}
.table-app td { padding: 12px 14px; border-color: var(--border); vertical-align: middle; }
.table-app tbody tr:hover { background: #FBFAFE; }
.table-app .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table-wrap { overflow-x: auto; border-radius: var(--radius); }
.cell-title { font-weight: 600; }
.cell-sub { color: var(--text-muted); font-size: .76rem; }
.row-link { color: inherit; }
.row-link:hover { color: var(--brand); }

/* En móvil, las tablas marcadas se muestran como tarjetas apiladas */
@media (max-width: 767.98px) {
    .table-stack thead { display: none; }
    .table-stack, .table-stack tbody, .table-stack tr, .table-stack td { display: block; width: 100%; }
    .table-stack tr { border-bottom: 1px solid var(--border); padding: 8px 0; }
    .table-stack td { border: 0; padding: 4px 16px; display: flex; justify-content: space-between; gap: 12px; text-align: right; }
    .table-stack td::before { content: attr(data-label); color: var(--text-muted); font-weight: 600; font-size: .76rem; text-align: left; }
    .table-stack td.num { text-align: right; }
    .table-stack td[data-label=""]::before { content: none; }
}

/* Filtros */
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.filters .form-control, .filters .form-select { min-width: 140px; }
.filters .grow { flex: 1 1 220px; }

/* Paginación */
.pagination { --bs-pagination-active-bg: var(--brand); --bs-pagination-active-border-color: var(--brand); --bs-pagination-color: var(--text); --bs-pagination-border-radius: 8px; margin: 0; }
.pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 18px; border-top: 1px solid var(--border); font-size: .8rem; color: var(--text-muted); }

/* ---------- Estados (vacío, error, sin permisos) ---------- */
.empty-state { text-align: center; padding: 40px 20px; color: var(--text-muted); }
.empty-state i { font-size: 2.2rem; color: var(--text-soft); display: block; margin-bottom: 8px; }
.empty-state .title { font-weight: 650; color: var(--text); margin-bottom: 4px; }
.alert { border-radius: 12px; border: 0; font-size: .87rem; display: flex; gap: 10px; align-items: flex-start; }
.alert i { font-size: 1.1rem; line-height: 1.2; }
.alert-success { background: var(--ok-soft); color: #166B44; }
.alert-danger { background: var(--danger-soft); color: #9B2C2C; }
.alert-warning { background: var(--warn-soft); color: #8A5A10; }
.alert-info { background: var(--info-soft); color: #1F4E99; }
.notice-fiscal { background: #FFF8E8; border: 1px dashed #E8C778; color: #7A5A12; border-radius: 12px; padding: 10px 14px; font-size: .8rem; }

/* ---------- Agenda ---------- */
.agenda-toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.agenda-nav { display: flex; align-items: center; gap: 6px; }
.agenda-day { position: relative; display: grid; grid-template-columns: 64px 1fr; }
.agenda-hours { position: relative; }
.agenda-hour { height: 64px; font-size: .72rem; color: var(--text-soft); text-align: right; padding-right: 10px; transform: translateY(-7px); }
.agenda-grid { position: relative; border-left: 1px solid var(--border); }
.agenda-line { height: 64px; border-top: 1px solid var(--border); }
.agenda-line.half { border-top-style: dashed; }
.appt-block {
    position: absolute; left: 8px; right: 8px; border-radius: 8px; padding: 6px 10px; overflow: hidden;
    font-size: .76rem; line-height: 1.25; border-left: 4px solid; color: var(--text); min-height: 24px;
}
.appt-block:hover { filter: brightness(.97); color: var(--text); }
.appt-block .t { font-weight: 650; }
.appt-block .s { color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.appt-scheduled { background: #E8F1FD; border-color: #5B9BEA; }
.appt-confirmed { background: #E5F6EE; border-color: #3DB37E; }
.appt-completed { background: #F1EDFD; border-color: #9F86EA; }
.appt-cancelled { background: #FDECEC; border-color: #E07A7A; text-decoration: line-through; opacity: .75; }
.appt-no_show { background: #FFF4DE; border-color: #E8B14A; }
.now-line { position: absolute; left: 0; right: 0; height: 2px; background: var(--danger); z-index: 3; }
.now-line::before { content: ""; position: absolute; left: -5px; top: -4px; width: 10px; height: 10px; border-radius: 50%; background: var(--danger); }

.week-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.week-col { border-left: 1px solid var(--border); min-height: 260px; padding: 8px; }
.week-col:first-child { border-left: 0; }
.week-col .day-head { font-size: .74rem; font-weight: 650; color: var(--text-muted); margin-bottom: 8px; }
.week-col.today .day-head { color: var(--brand); }
.week-item { display: block; border-radius: 8px; padding: 6px 8px; margin-bottom: 6px; font-size: .74rem; border-left: 3px solid; color: var(--text); }
@media (max-width: 991.98px) {
    .week-grid { grid-template-columns: 1fr; }
    .week-col { border-left: 0; border-top: 1px solid var(--border); min-height: 0; }
}

.month-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.month-grid .dow { font-size: .72rem; font-weight: 650; color: var(--text-muted); padding: 8px; text-align: center; border-bottom: 1px solid var(--border); }
.month-cell { min-height: 96px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); padding: 6px; font-size: .74rem; }
.month-cell:nth-child(7n) { border-right: 0; }
.month-cell .num { font-weight: 650; color: var(--text-muted); }
.month-cell.other { background: #FBFBFD; }
.month-cell.other .num { color: var(--text-soft); }
.month-cell.today .num { color: var(--brand-contrast); background: var(--brand); border-radius: 50%; width: 22px; height: 22px; display: inline-grid; place-items: center; }
.month-cell .chip { display: block; margin-top: 3px; padding: 2px 6px; border-radius: 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text); }
@media (max-width: 767.98px) {
    .month-cell { min-height: 58px; padding: 4px; }
    .month-cell .chip { display: none; }
    .month-cell .count { display: inline-block !important; }
}

/* ---------- Venta (punto de venta) ---------- */
.pos-lines td { vertical-align: middle; }
.pos-lines .qty-input { width: 76px; }
.pos-lines .disc-input { width: 110px; }
.totals { font-size: .9rem; }
.totals .row-t { display: flex; justify-content: space-between; padding: 4px 0; }
.totals .grand { font-size: 1.15rem; font-weight: 700; border-top: 1px solid var(--border); margin-top: 6px; padding-top: 10px; }
.catalog-list { max-height: 340px; overflow-y: auto; }
.catalog-item {
    width: 100%; display: flex; justify-content: space-between; align-items: center; gap: 10px; text-align: left;
    border: 1px solid var(--border); background: var(--surface); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px;
}
.catalog-item:hover { border-color: rgba(var(--brand-rgb), .5); background: var(--brand-soft); }
.lookup { position: relative; }
.lookup-results {
    position: absolute; z-index: 30; top: 100%; left: 0; right: 0; background: var(--surface);
    border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); max-height: 280px; overflow-y: auto; margin-top: 4px;
}
.lookup-results button { display: block; width: 100%; text-align: left; border: 0; background: transparent; padding: 9px 12px; }
.lookup-results button:hover, .lookup-results button:focus { background: var(--brand-soft); }
.selected-customer { display: flex; align-items: center; gap: 12px; border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; }

/* ---------- Gráficos ligeros (SVG) ---------- */
.chart-bars { width: 100%; height: 220px; }
.chart-bars .bar { fill: var(--brand); }
.chart-bars .bar.alt { fill: #3DB37E; }
.chart-bars .bar.neg { fill: #E07A7A; }
.chart-bars text { font-size: 10px; fill: var(--text-soft); font-family: inherit; }
.chart-bars .grid { stroke: var(--border); stroke-width: 1; }
.hbar { height: 8px; border-radius: 4px; background: #F0EFF5; overflow: hidden; }
.hbar > span { display: block; height: 100%; background: var(--brand); border-radius: 4px; width: 0; }
.legend-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; margin-right: 6px; }

/* ---------- Ficha de cliente ---------- */
.profile-head { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.profile-meta { color: var(--text-muted); font-size: .84rem; display: flex; flex-direction: column; gap: 3px; }
.note-item { border-left: 3px solid var(--brand); background: #FBFAFE; padding: 10px 12px; border-radius: 0 10px 10px 0; margin-bottom: 10px; white-space: pre-wrap; }

/* ---------- Login ---------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px calc(24px + var(--footer-h)); background: radial-gradient(1200px 600px at 10% -10%, rgba(var(--brand-rgb), .12), transparent), var(--app-bg); }
.auth-card { width: 100%; max-width: 410px; padding: 32px; }
.auth-logo { display: block; width: auto; height: auto; max-width: 240px; max-height: 110px; margin: 0 auto 18px; object-fit: contain; }
/* «multiply»: el fondo casi blanco del archivo del logotipo se funde con el fondo blanco en lugar de verse como un recuadro. */
.auth-logo, .brand-plate .brand-wordmark, .topbar-brand img { mix-blend-mode: multiply; }
.auth-brand-name { text-align: center; font-weight: 700; font-size: 1.1rem; margin-bottom: 16px; }
.auth-icon { display: block; width: 176px; height: 176px; max-width: 60%; object-fit: contain; margin: -8px auto 6px; }
.has-app-icon .auth-brand-name { font-size: 1rem; color: var(--text-muted); font-weight: 600; margin-bottom: 18px; }
.has-app-icon .auth-mark { display: none; }
.has-app-icon > h1, .has-app-icon > h1 + p { text-align: center; }
@media (max-width: 575.98px) { .auth-icon { width: 148px; height: 148px; } .auth-card { padding: 24px 20px; } }
.topbar-brand { display: inline-flex; align-items: center; flex: 0 0 auto; }
.topbar-brand img { display: block; width: auto; height: 34px; max-width: 110px; object-fit: contain; }
@media (max-width: 575.98px) { .topbar-brand img { height: 28px; max-width: 70px; } }
/* Logotipo oficial en el encabezado móvil: cuadrado, sin fusión de color (tiene transparencia propia). */
.topbar-brand.is-app-icon img { width: 40px; height: 40px; max-width: none; object-fit: contain; mix-blend-mode: normal; }
.auth-mark { width: 52px; height: 52px; border-radius: 14px; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; font-size: 1.5rem; margin-bottom: 14px; }

/* ---------- Utilidades ---------- */
.gap-row { row-gap: 20px; }
.min-w-0 { min-width: 0; }
.text-truncate-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.dl-grid { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; font-size: .86rem; }
.dl-grid dt { color: var(--text-muted); font-weight: 500; }
.dl-grid dd { margin: 0; }
.logo-preview { max-width: 100%; width: auto; height: auto; max-height: 100px; object-fit: contain; border: 1px solid var(--border); border-radius: 10px; padding: 8px; background: #fff; }
.logo-preview-gray { filter: grayscale(1) contrast(1.25); }
.color-swatch { width: 44px; height: 38px; padding: 3px; }
[hidden] { display: none !important; }

/* ---------- Responsive ---------- */
@media (max-width: 991.98px) {
    .app-content { padding: 18px 16px 32px; }
    .topbar { padding: 10px 16px; }
    .status-pill .t2 { display: none; }
}
@media (max-width: 575.98px) {
    .page-title { font-size: 1.35rem; }
    .status-pill { display: none !important; }
    .topbar-search { max-width: none; }
    .kpi-card { padding: 16px; }
    .form-actions .btn { flex: 1 1 auto; }
}

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

/* La interfaz administrativa nunca se imprime: solo las plantillas de recibo. */
@media print {
    .sidebar, .topbar, .app-footer, .no-print { display: none !important; }
    .app-main { padding-bottom: 0; }
    .app-content { padding: 0; }
}
.notif-menu { width: 320px; max-width: calc(100vw - 32px); }
.notif-menu a.notif-item { display: flex; gap: 10px; padding: 10px 14px; color: var(--text); border-bottom: 1px solid var(--border); }
.notif-menu a.notif-item:hover { background: var(--brand-soft); }
.totals-box { max-width: 380px; }
.donut-bg { stroke: #F0EFF5; }
.donut-a { stroke: var(--brand); }
.donut-b { stroke: #EC6FB4; }
.donut-a-bg { background: var(--brand); }
.donut-b-bg { background: #EC6FB4; }

/* ---- Ajustes tras la revisión visual ---- */
.card.kpi-card { flex-direction: row; }
.panel-link { white-space: nowrap; }
.sidebar-brand { padding: 18px 20px 14px; }
.sidebar-link { padding: 8px 14px; }
.sidebar-nav { gap: 2px; }
.sidebar-nav .nav-section { padding: 10px 12px 2px; }
.sidebar-user { padding: 12px 20px; }
.legend-dot.appt-scheduled { background: #5B9BEA; }
.legend-dot.appt-confirmed { background: #3DB37E; }
.legend-dot.appt-completed { background: #9F86EA; }
.legend-dot.appt-no_show { background: #E8B14A; }
.legend-dot.appt-cancelled { background: #E07A7A; text-decoration: none; opacity: 1; }
.appt-block { padding: 4px 10px; }

/* ---- Cobro en efectivo: devolución al cliente (cash-tender.js) ---- */
.cash-tender { margin-top: 1rem; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 14px; background: var(--surface); }
.cash-tender[hidden] { display: none; }
.ct-quick { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.ct-quick .btn { min-width: 54px; }
.ct-rows { font-size: .95rem; }
.ct-row { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; }
.ct-row span:last-child { font-weight: 600; }
.ct-result { margin-top: 10px; padding: 14px 16px; border-radius: var(--radius-sm); display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 2px 12px; background: var(--pending-soft); color: var(--text); }
.ct-label { font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; white-space: nowrap; }
/* Si no cabe junto a la etiqueta (columna estrecha), el importe baja a su propia línea. */
.ct-value { font-size: 2rem; font-weight: 800; line-height: 1.1; margin-left: auto; text-align: right; white-space: nowrap; }
.ct-hint { flex-basis: 100%; font-size: .85rem; color: var(--text-muted); }
.ct-result[data-state="ok"] { background: var(--ok-soft); color: var(--ok); }
.ct-result[data-state="short"], .ct-result[data-state="error"] { background: var(--danger-soft); color: var(--danger); }
.ct-result[data-state="ok"] .ct-hint, .ct-result[data-state="short"] .ct-hint, .ct-result[data-state="error"] .ct-hint { color: inherit; }
@media (max-width: 575.98px) { .ct-value { font-size: 1.6rem; } }

/* ---- Nueva venta: tres pasos en una pantalla (pos.js) ---- */
.pos-header { margin-bottom: 14px; }
.pos-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; align-items: start; }
.pos-main { display: grid; gap: 16px; min-width: 0; }
.pos-step { padding: 18px; }
.pos-step-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.step-num { width: 30px; height: 30px; flex: 0 0 auto; border-radius: 50%; display: grid; place-items: center; background: var(--brand); color: var(--brand-contrast); font-weight: 700; font-size: .95rem; }
.pos-step-title { margin: 0; font-size: 1.1rem; font-weight: 650; }
.pos-label { font-weight: 600; font-size: .9rem; margin-bottom: 8px; }
.pos-search { position: relative; }
.pos-search > i { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--text-soft); pointer-events: none; }
.pos-search .form-control { padding-left: 42px; }
.pos-customer-hint { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-top: 10px; }
.pos .selected-customer { padding: 12px 14px; border-color: rgba(var(--brand-rgb), .35); background: var(--brand-soft); }
.pos-newcust { margin-top: 12px; border: 1px dashed rgba(var(--brand-rgb), .45); border-radius: var(--radius-sm); padding: 14px; }
.pos-newcust-title { font-weight: 650; margin-bottom: 8px; }

.pos-catalog-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.pos-tabs button { padding: 9px 16px; }
.pos-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 10px; padding: 2px; }
.pos-grid-empty { grid-column: 1 / -1; color: var(--text-muted); padding: 16px 4px; }
.pos-tile {
    position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; min-height: 118px; text-align: left;
    border: 1px solid var(--border-strong); border-radius: 12px; background: var(--surface); padding: 12px 12px 10px; color: var(--text);
    transition: border-color .15s ease, background-color .15s ease, transform .1s ease;
}
.pos-tile:hover { border-color: rgba(var(--brand-rgb), .6); background: var(--brand-soft); }
.pos-tile:active { transform: scale(.98); }
.pos-tile:focus-visible { outline: 3px solid rgba(var(--brand-rgb), .35); outline-offset: 1px; }
.pos-tile.in-cart { border-color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); }
.pt-kind { color: var(--brand); font-size: 1.05rem; line-height: 1; margin-bottom: 4px; }
.pt-name { font-weight: 600; font-size: .92rem; line-height: 1.25; overflow-wrap: anywhere; padding-right: 34px; }
.pt-meta, .pt-stock { font-size: .76rem; color: var(--text-muted); }
.pt-stock.is-out { color: var(--danger); }
.pt-price { margin-top: auto; padding-top: 6px; font-weight: 700; font-size: .98rem; }
.pt-badge { position: absolute; top: 8px; right: 8px; background: var(--brand); color: var(--brand-contrast); border-radius: 999px; padding: 1px 9px; font-size: .78rem; font-weight: 700; }

.pos-summary { padding: 18px; }
.pos-cart { display: grid; gap: 8px; }
.pos-cart-empty { color: var(--text-muted); font-size: .9rem; text-align: center; padding: 18px 8px; border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); }
.pos-cart-empty i { display: block; font-size: 1.5rem; margin-bottom: 4px; color: var(--text-soft); }
.cart-line {
    display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "info rm" "qty total" "disc disc";
    gap: 6px 10px; align-items: center; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px;
}
.cl-info { grid-area: info; min-width: 0; }
.cl-name { font-weight: 600; font-size: .92rem; overflow-wrap: anywhere; }
.cl-meta { font-size: .78rem; color: var(--text-muted); }
.cl-warn { font-size: .78rem; color: var(--danger); }
.cl-remove { grid-area: rm; align-self: start; }
.cl-qty { grid-area: qty; display: inline-flex; align-items: center; gap: 4px; }
.cl-step { width: 40px; height: 40px; padding: 0; font-size: 1.2rem; font-weight: 600; line-height: 1; }
.cl-qty-input { width: 60px; height: 40px; text-align: center; padding: 4px; -moz-appearance: textfield; appearance: textfield; }
.cl-qty-input::-webkit-outer-spin-button, .cl-qty-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.cl-total { grid-area: total; text-align: right; font-weight: 700; }
.cl-disc { grid-area: disc; display: flex; align-items: center; gap: 8px; font-size: .82rem; color: var(--text-muted); margin: 0; }
.cl-disc-input { max-width: 130px; }
.cl-disc-link { grid-area: disc; justify-self: start; padding: 0; font-size: .82rem; }

.pos-totals { margin: 14px 0 4px; padding-top: 10px; border-top: 1px solid var(--border); }
.pos-totals .grand { font-size: 1.45rem; }
.pos-pay { border-top: 1px solid var(--border); padding-top: 14px; margin-top: 10px; }
.pay-methods { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.pay-method, .pay-mode {
    display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; margin: 0; padding: 8px 10px; cursor: pointer;
    border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); font-weight: 600; font-size: .92rem; text-align: center;
}
.pay-method i { font-size: 1.15rem; color: var(--text-muted); }
.pay-method:hover, .pay-mode:hover { border-color: rgba(var(--brand-rgb), .6); }
.btn-check:checked + .pay-method, .btn-check:checked + .pay-mode { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); }
.btn-check:checked + .pay-method i { color: var(--brand); }
.btn-check:focus-visible + .pay-method, .btn-check:focus-visible + .pay-mode { outline: 3px solid rgba(var(--brand-rgb), .35); outline-offset: 1px; }
.pay-modes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.pos .cash-tender { margin-top: 12px; }
.pos-note { margin-top: 14px; }
.pos-note summary { cursor: pointer; font-size: .9rem; font-weight: 600; }
.pos-finish {
    display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; margin-top: 16px;
    padding: 15px 18px; font-size: 1.12rem; font-weight: 750; letter-spacing: .04em; text-transform: uppercase; border-radius: 12px;
}
.pos-finish-total { letter-spacing: 0; }
.pos-mobilebar { display: none; }

@media (min-width: 992px) {
    .pos-layout { grid-template-columns: minmax(0, 1fr) 400px; }
    .pos-side { position: sticky; top: 84px; }
    .pos-summary { max-height: calc(100vh - 84px - var(--footer-h) - 12px); overflow-y: auto; }
}
@media (min-width: 1400px) { .pos-layout { grid-template-columns: minmax(0, 1fr) 440px; } }
@media (max-width: 991.98px) {
    .pos { padding-bottom: 72px; }
    .pos-mobilebar {
        display: flex; align-items: center; justify-content: space-between; gap: 12px;
        position: fixed; left: 0; right: 0; bottom: calc(var(--footer-h) + env(safe-area-inset-bottom, 0px)); z-index: 1025;
        padding: 10px 16px; background: var(--surface); border-top: 1px solid var(--border); box-shadow: 0 -4px 16px rgba(30, 27, 58, .08);
    }
    .pos-mobilebar strong { font-size: 1.2rem; }
}
@media (max-width: 575.98px) {
    .pos-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .pos-tabs { width: 100%; }
    .pos-tabs button { flex: 1 1 0; }
}

/* ---- Venta registrada (confirmación) ---- */
.sale-done { max-width: 600px; margin: 8px auto 0; }
.done-card { padding: 32px 28px; text-align: center; }
.done-icon { width: 68px; height: 68px; margin: 0 auto 12px; border-radius: 50%; display: grid; place-items: center; background: var(--ok-soft); color: var(--ok); font-size: 2.2rem; }
.done-title { font-size: 1.5rem; font-weight: 700; margin: 0; }
.done-number { color: var(--text-muted); margin: 4px 0 20px; font-size: 1.05rem; }
.done-number strong { color: var(--text); }
.done-facts { margin: 0 0 24px; text-align: left; border-top: 1px solid var(--border); }
.done-facts > div { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 11px 2px; border-bottom: 1px solid var(--border); }
.done-facts dt { font-weight: 500; color: var(--text-muted); }
.done-facts dd { margin: 0; font-weight: 600; text-align: right; overflow-wrap: anywhere; }
.done-total { font-size: 1.4rem; font-weight: 750 !important; }
.done-change dd { color: var(--ok); font-size: 1.15rem; }
.done-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; }
.done-actions .btn { padding-top: 14px; padding-bottom: 14px; font-weight: 650; }
.done-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 20px; margin-top: 18px; font-size: .9rem; }

/* ---- Nueva operación (operations.js) ---- */
.op-cta { font-weight: 750; letter-spacing: .03em; padding: 12px 22px; border-radius: 12px; }
.dash-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.op-actions-compact .op-action { min-height: 110px; padding: 14px; }
.op-actions-compact .op-action i { font-size: 1.8rem; }
.op-wrap { max-width: 880px; display: grid; gap: 16px; }
.op-card { padding: 20px; }
.op-card-title { display: flex; align-items: center; gap: 10px; font-size: 1.1rem; font-weight: 650; margin: 0 0 14px; }
.op-steps { display: flex; gap: 8px; list-style: none; padding: 0; margin: 0 0 16px; max-width: 880px; }
.op-steps li { flex: 1 1 0; display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: var(--radius-sm); background: var(--surface); border: 1px solid var(--border); color: var(--text-muted); font-weight: 600; }
.op-steps li > span { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--border); color: var(--text-muted); font-size: .9rem; flex: 0 0 auto; }
.op-steps .is-current { border-color: var(--brand); color: var(--text); }
.op-steps .is-current > span { background: var(--brand); color: var(--brand-contrast); }
.op-steps .is-done > span { background: var(--ok); color: #fff; }
.op-results { display: grid; gap: 8px; }
.op-result { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); color: var(--text); text-decoration: none; min-height: 60px; }
.op-result:hover, .op-result:focus-visible { border-color: var(--brand); background: var(--brand-soft); color: var(--text); }
.op-dupes { border: 1px solid var(--warn); background: var(--warn-soft); }
.op-patient { display: flex; flex-direction: row; align-items: center; gap: 14px; }
.op-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.op-action { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; min-height: 150px; padding: 18px; text-align: center;
    background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius); color: var(--text); text-decoration: none; box-shadow: var(--shadow); transition: border-color .15s ease, transform .1s ease; }
.op-action:hover, .op-action:focus-visible { border-color: var(--brand); color: var(--text); }
.op-action:active { transform: scale(.98); }
.op-action i { font-size: 2.2rem; color: var(--brand); }
.op-action-title { font-size: 1.15rem; font-weight: 700; }
.op-action-hint { font-size: .85rem; color: var(--text-muted); }
.op-services { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; }
.op-service { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); cursor: pointer; margin: 0; min-height: 64px; }
.btn-check:checked + .op-service { border-color: var(--brand); background: var(--brand-soft); box-shadow: inset 0 0 0 1px var(--brand); }
.btn-check:focus-visible + .op-service, .btn-check:focus-visible + .op-slot { outline: 3px solid rgba(var(--brand-rgb), .35); outline-offset: 1px; }
.op-slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; }
.op-slots.is-invalid { outline: 2px solid var(--danger); outline-offset: 4px; border-radius: 6px; }
.op-slot { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 48px; margin: 0; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); font-weight: 650; cursor: pointer; background: var(--surface); }
.op-slot small { font-weight: 500; font-size: .7rem; color: var(--warn); }
.op-slot.is-busy { background: #FBFAF6; }
.btn-check:checked + .op-slot { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); }
.btn-check:disabled + .op-slot { opacity: .45; cursor: not-allowed; text-decoration: line-through; }
.op-day-list { margin: 0; padding-left: 18px; }
.op-sources { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 575.98px) {
    .op-steps li { padding: 8px 10px; font-size: .85rem; }
    .op-sources { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .op-actions { grid-template-columns: 1fr 1fr; }
    .op-action { min-height: 120px; }
}

/* ---- Recetario médico (medical.js) ---- */
.med-form { max-width: 980px; display: grid; gap: 16px; }
.med-facts { display: flex; flex-wrap: wrap; gap: 4px 20px; margin: 6px 0; font-size: .88rem; }
.med-facts div { display: flex; gap: 6px; }
.med-facts dt { color: var(--text-muted); font-weight: 500; }
.med-facts dd { margin: 0; }
.med-rx { font-family: Georgia, serif; font-size: 1.4rem; color: var(--brand); }
.med-items { display: grid; gap: 10px; }
.med-item { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px 12px; margin: 0; }
.med-item-head { float: none; width: 100%; display: flex; justify-content: space-between; align-items: center; font-size: .9rem; font-weight: 650; margin-bottom: 6px; }
.med-studies { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.med-section { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; margin: 0; }
.med-section legend { float: none; width: auto; font-size: .92rem; font-weight: 700; color: var(--brand); margin-bottom: 6px; padding: 0; }
.med-check { display: flex; align-items: flex-start; gap: 8px; padding: 4px 0; font-size: .9rem; cursor: pointer; }
.med-check .form-check-input { margin-top: .15rem; flex: 0 0 auto; }
.med-group { padding-left: 4px; margin-top: 4px; }
.med-group .med-check { padding-left: 14px; }
.med-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; }
.med-list { padding-left: 20px; }
.med-list li { margin-bottom: 8px; }
.pre-wrap { white-space: pre-wrap; }

/* ==========================================================================
   Experiencia móvil (iPhone primero, compatible con Android)
   ========================================================================== */
:root { --bottomnav-h: 0px; }

/* ---- Compartir documento (share.js) ---- */
.btn-wa { background: #128C4A; border-color: #128C4A; color: #fff; }
.btn-wa:hover, .btn-wa:focus-visible { background: #0E733C; border-color: #0E733C; color: #fff; }
.btn-wa:active, .btn-wa.is-busy { background: #0B5E31 !important; border-color: #0B5E31 !important; color: #fff !important; }
.text-wa { color: #128C4A; }
.share-block { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; }
.done-card .share-block { flex-direction: column; align-items: stretch; margin-bottom: 12px; }
.done-card .share-block .btn { padding-top: 14px; padding-bottom: 14px; font-weight: 650; }
.share-dl { font-weight: 600; font-size: .9rem; }
.done-card .share-dl { align-self: center; }
.share-status { flex-basis: 100%; }
.share-steps { padding-left: 1.3rem; margin: 0 0 12px; display: grid; gap: 16px; }
.share-steps li::marker { font-weight: 700; }
.btn-icon-touch { width: 44px; height: 44px; padding: 0; display: inline-grid; place-items: center; font-size: 1.2rem; border-radius: 12px; }
.td-actions { width: 1%; white-space: nowrap; text-align: right; }

/* ---- Agenda: lista del día con acciones rápidas ---- */
.appt-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.form-select { padding-right: 2.25rem; }
.appt-card { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 14px; padding: 14px; border: 1px solid var(--border-strong); border-left: 4px solid var(--brand); border-radius: var(--radius-sm); background: var(--surface); }
.appt-card.appt-confirmed { border-left-color: var(--info); }
.appt-card.appt-completed { border-left-color: var(--ok); }
.appt-card.appt-cancelled, .appt-card.appt-no_show { border-left-color: var(--text-soft); opacity: .85; }
.appt-time { font-weight: 750; font-size: 1rem; line-height: 1.2; white-space: nowrap; min-width: 72px; }
.appt-time small { display: block; font-weight: 500; font-size: .75rem; color: var(--text-muted); }
.appt-who { font-weight: 650; font-size: 1rem; color: var(--text); }
.appt-meta { color: var(--text-muted); font-size: .85rem; overflow-wrap: anywhere; }
.appt-actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.appt-actions form { margin: 0; }
.appt-actions .btn { min-height: 44px; display: inline-flex; align-items: center; }
.day-chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 6px; margin: 0 -2px 8px; scrollbar-width: thin; -webkit-overflow-scrolling: touch; }
.day-chip { flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; justify-content: center; min-width: 64px; min-height: 56px; padding: 6px 10px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); font-weight: 650; line-height: 1.15; cursor: pointer; }
.day-chip small { font-weight: 500; font-size: .72rem; color: var(--text-muted); text-transform: capitalize; }
.day-chip.is-active { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); }

/* ---- Barra de navegación inferior (teléfonos y tabletas) ---- */
.bottom-nav { display: none; }
@media (max-width: 991.98px) {
    :root { --bottomnav-h: 62px; }
    .bottom-nav {
        display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr);
        position: fixed; left: 0; right: 0; bottom: 0; z-index: 1030;
        height: calc(var(--bottomnav-h) + env(safe-area-inset-bottom, 0px));
        padding: 0 max(4px, env(safe-area-inset-right, 0px)) env(safe-area-inset-bottom, 0px) max(4px, env(safe-area-inset-left, 0px));
        background: rgba(255, 255, 255, .97); border-top: 1px solid var(--border-strong);
        box-shadow: 0 -4px 18px rgba(30, 27, 58, .07);
    }
    .bottom-nav a, .bottom-nav button {
        display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
        min-width: 0; border: 0; background: transparent; padding: 6px 2px; color: var(--text-muted);
        font-size: .7rem; font-weight: 600; line-height: 1.1; text-align: center; -webkit-tap-highlight-color: transparent;
    }
    .bottom-nav i { font-size: 1.3rem; line-height: 1; }
    .bottom-nav span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
    .bottom-nav .is-active { color: var(--brand); }
    .bottom-nav .bn-main { color: var(--text); }
    .bottom-nav .bn-plus { width: 40px; height: 30px; border-radius: 12px; display: grid; place-items: center; background: var(--brand); color: var(--brand-contrast); }
    .bottom-nav .bn-plus i { font-size: 1.2rem; }
    /* «Más» abre el menú completo: el botón de menú del encabezado sobraría. */
    .has-bottom-nav .topbar .topbar-menu { display: none; }

    /* El pie «Powered by» deja de ser fijo: queda al final de la página, encima de la barra inferior. */
    .has-bottom-nav .app-main { padding-bottom: 0; }
    .has-bottom-nav .app-footer { position: static; height: auto; padding: 10px 16px; white-space: normal; flex-wrap: wrap; }
    body.has-bottom-nav { padding-bottom: calc(var(--bottomnav-h) + env(safe-area-inset-bottom, 0px)); }
    .has-bottom-nav .pos-mobilebar { bottom: calc(var(--bottomnav-h) + env(safe-area-inset-bottom, 0px)); }
}

/* ---- Teléfonos: tamaños cómodos para el dedo, sin zoom automático de Safari ---- */
@media (max-width: 991.98px) {
    /* iOS amplía la página al escribir si el texto de un campo mide menos de 16 px. */
    .form-control, .form-select, .form-control-sm, .form-select-sm, .form-control-lg, .form-select-lg,
    input[type="text"], input[type="search"], input[type="tel"], input[type="email"], input[type="number"],
    input[type="date"], input[type="time"], input[type="password"], textarea, select { font-size: 16px; }
    .form-control, .form-select { min-height: 44px; }
    .form-control-sm, .form-select-sm { min-height: 40px; }
    .btn { min-height: 44px; }
    .btn-sm { min-height: 40px; }
    .btn.btn-icon { min-width: 44px; display: inline-grid; place-items: center; }
    .form-check-input { width: 1.25em; height: 1.25em; }
    .icon-btn { width: 44px; height: 44px; }
    .topbar {
        padding-top: calc(8px + env(safe-area-inset-top, 0px)); padding-bottom: 8px;
        padding-left: max(12px, env(safe-area-inset-left, 0px)); padding-right: max(12px, env(safe-area-inset-right, 0px));
        gap: 8px;
    }
    .app-content { padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
    .sidebar.offcanvas-lg { padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); }
    .sidebar-link { min-height: 46px; }
    .modal-dialog-scrollable .modal-content { max-height: calc(100dvh - 2rem); }
    .modal-fullscreen-sm-down .modal-content { padding-bottom: env(safe-area-inset-bottom, 0px); }
}
@media (max-width: 575.98px) {
    .page-header { margin-bottom: 16px; }
    .page-header > div:last-child:not(:first-child) { width: 100%; }
    .page-header > .btn { flex: 1 1 100%; justify-content: center; }
    .page-header > .d-flex { width: 100%; }
    .page-header > .d-flex > .btn, .page-header > .d-flex > .btn-group { flex: 1 1 100%; }
    .filters > div { flex: 1 1 100%; }
    .filters .form-control, .filters .form-select { min-width: 0; width: 100%; }
    .op-card { padding: 16px; }
    .op-services { grid-template-columns: 1fr; gap: 6px; }
    .op-service { min-height: 0; padding: 10px 12px; }
    .dash-actions > .btn, .dash-actions > a { flex: 1 1 100%; justify-content: center; }
    /* Agenda: navegación del día en una fila; filtros y vista debajo, a todo el ancho. */
    .agenda-toolbar { flex-direction: column; align-items: stretch; gap: 10px; }
    .agenda-toolbar > div, .agenda-toolbar form, .agenda-toolbar .segmented { width: 100%; }
    .agenda-toolbar form > select, .agenda-toolbar form > input { flex: 1 1 auto; }
    .agenda-toolbar .segmented a { flex: 1 1 0; text-align: center; }
    .agenda-nav h2 { font-size: .95rem; }
    /* Totales de listados: más compactos para llegar antes a la lista. */
    .kpi-mini.card { padding: 10px 14px !important; }
    .kpi-mini .fs-5 { font-size: 1.05rem !important; }
    .filters { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
    .filters > div { min-width: 0; }
    .filters > div.grow, .filters > div:has(select), .filters > div:last-child { grid-column: 1 / -1; }
    .filters > div:last-child .btn { width: 100%; }
    .op-slots { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .share-bar .share-block { flex-direction: column; align-items: stretch; }
    .share-bar .share-dl { align-self: center; }
    .share-bar .btn { padding-top: 12px; padding-bottom: 12px; }
    .done-card { padding: 24px 16px; }
    .done-actions { grid-template-columns: 1fr; }
}
