/* Tabla de gastos delegados con scroll vertical y altura fija */
.gastos-scrollable-table {
    max-height: 16cm;
    height: 16cm;
    overflow-y: auto;
    overflow-x: auto;
    border-radius: 24px;
    background: transparent;
    box-shadow: none;
}
/* --- Gastos delegados tabla responsiva y glass --- */
.gastos-delegados-container {
    margin: 2.5rem auto 2rem auto;
    max-width: 1100px;
    padding: 2.2rem 1.2rem 2.2rem 1.2rem;
    border-radius: 32px;
    box-shadow: var(--shadow);
    background: var(--surface);
    backdrop-filter: blur(32px) saturate(1.2);
}

.responsive-table-wrap {
    width: 100%;
    overflow-x: auto;
    border-radius: 24px;
    background: transparent;
    box-shadow: none;
}

.glass-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: rgba(255,255,255,0.68);
    border-radius: 24px;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(10,132,255,0.08);
    backdrop-filter: blur(18px) saturate(1.2);
    font-size: 1.01rem;
}

.glass-table th, .glass-table td {
    padding: 0.85rem 0.7rem;
    border-bottom: 1px solid rgba(16,37,66,0.07);
    text-align: left;
    background: rgba(255,255,255,0.44);
    backdrop-filter: blur(8px);
}
.glass-table thead th {
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 0.82rem;
    color: var(--muted);
    background: rgba(247,249,252,0.92);
}
.glass-table tbody tr:hover td {
    background: #e8f5ee;
}
.glass-table td {
    min-width: 110px;
}

@media (max-width: 900px) {
    .gastos-delegados-container {
        padding: 1.1rem 0.2rem 1.1rem 0.2rem;
        border-radius: 18px;
    }
    .glass-table th, .glass-table td {
        padding: 0.55rem 0.3rem;
        font-size: 0.97rem;
    }
    .glass-table td {
        min-width: 90px;
    }
}

@media (max-width: 600px) {
    .gastos-delegados-container {
        padding: 0.5rem 0.1rem 0.5rem 0.1rem;
        border-radius: 12px;
    }
    .glass-table th, .glass-table td {
        padding: 0.38rem 0.18rem;
        font-size: 0.92rem;
    }
    .glass-table td {
        min-width: 80px;
    }
}
.mini-field input[type="month"] {
    width: 3.5cm !important;
    min-width: 3.5cm !important;
    max-width: 3.5cm !important;
    height: 1.1rem !important;
    padding: 0.01rem 0.1rem !important;
    font-size: 0.68rem !important;
    border-radius: 4px !important;
    box-sizing: border-box !important;
}
.mini-filter-card {
    padding: 0.4rem 0.6rem !important;
    margin-bottom: 0.5rem !important;
    border-radius: 16px !important;
    min-width: unset !important;
    max-width: 340px;
    width: 100%;
}
.mini-filter-form {
    gap: 0.3rem !important;
}
.mini-filter-grid {
    gap: 0.2rem !important;
}
.mini-field label {
    margin-bottom: 0.08rem !important;
    font-size: 0.78rem !important;
}
.mini-field input {
    padding: 0.28rem 0.4rem !important;
    font-size: 0.85rem !important;
    border-radius: 8px !important;
    min-width: 80px;
    max-width: 120px;
    width: 100%;
}
.mini-filter-actions {
    gap: 0.2rem !important;
}
.mini-btn {
    padding: 0.38rem 0.7rem !important;
    font-size: 0.92rem !important;
    border-radius: 8px !important;
    min-width: 60px;
}
:root {
    --bg: #eef3fb;
    --bg-soft: #f7f9fc;
    --surface: rgba(255, 255, 255, 0.72);
    --surface-strong: rgba(255, 255, 255, 0.92);
    --text: #102542;
    --muted: #5b6578;
    --line: rgba(16, 37, 66, 0.08);
    --blue: #0a84ff;
    --green: #30d158;
    --orange: #ff9f0a;
    --red: #ff453a;
    --violet: #5e5ce6;
    --shadow: 0 30px 60px rgba(15, 23, 42, 0.12);
    --sidebar-width: 220px;
}

/* ── MODO OSCURO — Navy Médico ─────────────────────────────── */
html.dark {
    --bg: #0a1628;
    --bg-soft: #0d1e3d;
    --surface: rgba(255, 255, 255, 0.07);
    --surface-strong: rgba(255, 255, 255, 0.11);
    --text: #e2ecff;
    --muted: #7a9cc0;
    --line: rgba(255, 255, 255, 0.08);
    --shadow: 0 30px 60px rgba(0, 0, 0, 0.4);
}

html.dark body {
    background:
        radial-gradient(circle at top left, rgba(10, 80, 180, 0.15), transparent 24%),
        radial-gradient(circle at 80% 20%, rgba(94, 92, 230, 0.12), transparent 26%),
        linear-gradient(180deg, #0a1628 0%, #0d1e3d 100%);
}

/* Tablas glass en dark — se elimina el efecto glass para un look oscuro limpio */
html.dark .glass-table {
    background: transparent;
    backdrop-filter: none;
    box-shadow: none;
}
html.dark .glass-table th,
html.dark .glass-table td {
    background: transparent;
    backdrop-filter: none;
    border-bottom-color: rgba(255, 255, 255, 0.07);
    color: var(--text);
}
html.dark .glass-table thead th {
    background: rgba(255, 255, 255, 0.05);
    color: var(--muted);
}
html.dark .glass-table tbody tr:hover { background: transparent !important; }
html.dark .glass-table tbody tr:hover td {
    background: rgba(255, 255, 255, 0.04) !important;
}
html.dark .fila-principal.abierta td {
    background: rgba(255, 255, 255, 0.04) !important;
}

/* Inputs, selects y textareas */
html.dark input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="button"]),
html.dark select,
html.dark textarea {
    background: rgba(255, 255, 255, 0.07) !important;
    border-color: rgba(255, 255, 255, 0.12) !important;
    color: var(--text) !important;
    color-scheme: dark;
}
html.dark input::placeholder,
html.dark textarea::placeholder {
    color: var(--muted);
    opacity: 1;
}

/* Glass cards */
html.dark .glass-card {
    border-color: rgba(255, 255, 255, 0.07);
}

/* Mensajes Django */
html.dark .message {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.1);
    color: var(--text);
}
html.dark .message-success { background: rgba(48, 209, 88, 0.12); border-color: rgba(48, 209, 88, 0.2); }
html.dark .message-error   { background: rgba(255, 69, 58, 0.12);  border-color: rgba(255, 69, 58, 0.2); }
html.dark .message-warning { background: rgba(255, 159, 10, 0.12); border-color: rgba(255, 159, 10, 0.2); }

/* Contenedor de gastos delegados */
html.dark .gastos-delegados-container {
    background: var(--surface);
}

/* Scrollbar en dark */
html.dark ::-webkit-scrollbar-track { background: #0d1e3d; }
html.dark ::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.15); border-radius: 4px; }
html.dark ::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.25); }

/* Dashboard — filtro de fecha */
html.dark .mini-filter-card {
    background: rgba(255, 255, 255, 0.07) !important;
    border-color: rgba(255, 255, 255, 0.1) !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3) !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
}
html.dark .mini-field {
    background: rgba(255, 255, 255, 0.06) !important;
    border-color: rgba(255, 255, 255, 0.08) !important;
}
html.dark .mini-field label { color: var(--muted) !important; }
html.dark .mini-filter-card select {
    background-color: rgba(255, 255, 255, 0.08) !important;
    border-color: rgba(255, 255, 255, 0.12) !important;
    color: var(--text) !important;
    color-scheme: dark !important;
}
html.dark select option {
    background-color: #1a2a4a;
    color: #e8edf5;
}
html.dark .mini-filter-card .secondary-button,
html.dark .mini-filter-card a.secondary-button {
    border-color: rgba(255, 255, 255, 0.15) !important;
    color: var(--muted) !important;
}

/* Dashboard — tarjetas positivas/negativas */
html.dark .stat-card.is-positive {
    background: rgba(48, 209, 88, 0.1) !important;
    border-color: rgba(48, 209, 88, 0.2) !important;
    box-shadow: 0 4px 20px rgba(48, 209, 88, 0.08) !important;
}
html.dark .stat-card.is-positive .stat-value { color: #4ade80 !important; }
html.dark .stat-card.is-negative {
    background: rgba(255, 69, 58, 0.1) !important;
    border-color: rgba(255, 69, 58, 0.2) !important;
    box-shadow: 0 4px 20px rgba(255, 69, 58, 0.08) !important;
}
html.dark .stat-card.is-negative .stat-value { color: #f87171 !important; }

/* Dashboard — tabla movimientos destacados (colores inline hardcoded) */
html.dark .chart-card td { color: var(--text) !important; }
html.dark .chart-card tr { border-top-color: rgba(255, 255, 255, 0.07) !important; }

/* Dashboard — botón inactivo tabs de movimientos */
html.dark #mov-tipo-tabs button[style*="#f5f7fb"] {
    background: rgba(255, 255, 255, 0.07) !important;
    color: var(--muted) !important;
    border-color: rgba(255, 255, 255, 0.1) !important;
}

/* Dashboard — tarjetas de delegados (background inline rgba(246,248,252)) */
html.dark [style*="rgba(246,248,252"] {
    background: rgba(255, 255, 255, 0.06) !important;
    border-color: rgba(255, 255, 255, 0.08) !important;
}
html.dark [style*="rgba(246,248,252"] span[style*="color:#5b6578"],
html.dark [style*="rgba(246,248,252"] span[style*="color:#2a3b5d"] {
    color: var(--text) !important;
}

/* Dashboard — tooltips */
html.dark .stat-card-tooltip {
    background: rgba(10, 22, 40, 0.96);
    border-color: rgba(255, 255, 255, 0.08);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    color: var(--text);
}
html.dark .stat-card-tooltip-detail { border-top-color: rgba(255, 255, 255, 0.08); color: var(--muted); }
html.dark .stat-card-tooltip-row-label,
html.dark .diff-tooltip-row-label { color: var(--muted); }
html.dark .diff-tooltip-divider { border-top-color: rgba(255, 255, 255, 0.08); }
html.dark .diff-tooltip-section-label { color: var(--text); }

/* ── MODO OSCURO — Componentes de templates (global) ──────── */

/* Filtros compartidos (gastos_delegados, facturas, gastos_mensuales, pedidos, articulos, franquiciados) */
html.dark .filtro-btn-trigger {
    background: rgba(255,255,255,0.07) !important;
    border-color: rgba(255,255,255,0.12) !important;
    color: var(--text) !important;
}
html.dark .filtro-btn-trigger:hover {
    background: rgba(95,109,250,0.12) !important;
    border-color: #5f6dfa !important;
}
html.dark .filtro-dropdown {
    background: #0d1e3d !important;
    border-color: rgba(255,255,255,0.12) !important;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4) !important;
}
html.dark .filtro-option { color: var(--text) !important; }
html.dark .filtro-option:hover { background: rgba(95,109,250,0.1) !important; }
html.dark .filtro-limpiar {
    background: rgba(255,255,255,0.06) !important;
    border-color: rgba(255,255,255,0.12) !important;
    color: var(--muted) !important;
}

/* Paneles de detalle expandibles en tablas */
html.dark .fila-detalle td { background: transparent !important; }
html.dark .detalle-panel {
    background: rgba(255,255,255,0.04) !important;
    border-left-color: rgba(95,109,250,0.35) !important;
}
html.dark .detalle-label { color: var(--muted) !important; }
html.dark .detalle-valor,
html.dark .detalle-item strong { color: var(--text) !important; }

/* Import — tarjetas laterales y zona de carga */
html.dark .hero-side {
    background: rgba(255,255,255,0.07) !important;
}
html.dark .dropzone {
    background: rgba(255,255,255,0.04) !important;
    border-color: rgba(95,109,250,0.4) !important;
}
html.dark .panel-label { color: var(--muted) !important; }
html.dark .panel-value { color: var(--text) !important; }
html.dark .panel-meta  { color: var(--muted) !important; }

/* Gastos delegados — resumen y buscador */
html.dark .resumen-item {
    background: rgba(255,255,255,0.07) !important;
    box-shadow: 0 1px 4px rgba(0,0,0,0.3) !important;
}
html.dark .resumen-item strong { color: var(--text) !important; }
html.dark .resumen-cat-del-card {
    background: rgba(255,255,255,0.07) !important;
    box-shadow: 0 1px 4px rgba(0,0,0,0.3) !important;
}
html.dark .search-bar {
    background: rgba(255,255,255,0.07) !important;
    border-color: rgba(255,255,255,0.12) !important;
}
html.dark .search-bar input[type="text"] { color: var(--text) !important; }

/* Franquiciados */
html.dark .franq-stat-card {
    background: rgba(255,255,255,0.07) !important;
    border-color: rgba(255,255,255,0.1) !important;
}
html.dark .tab-pill { background: rgba(255,255,255,0.06) !important; }
html.dark .tab-pill.active {
    background: rgba(255,255,255,0.13) !important;
    color: var(--text) !important;
}
html.dark .franq-table th {
    background: rgba(255,255,255,0.06) !important;
    color: var(--muted) !important;
}
html.dark .franq-table tr:hover td { background: rgba(255,255,255,0.04) !important; }

/* Pedidos — badges de estado */
html.dark .estado-si   { background: rgba(48,209,88,0.15)  !important; color: #4ade80 !important; }
html.dark .estado-no   { background: rgba(255,69,58,0.15)   !important; color: #f87171 !important; }
html.dark .estado-pdte { background: rgba(255,159,10,0.15)  !important; color: #fbbf24 !important; }

/* Texto inline oscuro — necesita ser legible en dark mode */
html.dark [style*="color:#2a3b5d"],
html.dark [style*="color: #2a3b5d"],
html.dark [style*="color:#102542"],
html.dark [style*="color: #102542"] { color: var(--text) !important; }

/* Superficies inline blancas (#fff, #ffffff, #fff8f0, etc.) */
html.dark [style*="background:#fff"],
html.dark [style*="background: #fff"] {
    background: rgba(255,255,255,0.10) !important;
}

/* Superficies inline gris claro (#f6f8fc, #f5f7fb) */
html.dark div[style*="background:#f6f8fc"],
html.dark div[style*="background: #f6f8fc"],
html.dark div[style*="background:#f5f7fb"],
html.dark div[style*="background: #f5f7fb"] {
    background: rgba(255,255,255,0.06) !important;
}

/* Zipper — preset tags, checkboxes, preview card */
html.dark .zipper-preset-btn span {
    background: rgba(255,255,255,0.07) !important;
    border-color: rgba(255,255,255,0.12) !important;
    color: var(--text) !important;
}
html.dark .zipper-check-item {
    background: rgba(255,255,255,0.07) !important;
    border-color: rgba(255,255,255,0.1) !important;
}
html.dark .zipper-preview-card {
    background: rgba(255,255,255,0.07) !important;
    border-color: rgba(124,58,237,0.3) !important;
}

/* Formularios — .form-input usado en admin_panel, facturas, mi_cuenta, etc. */
html.dark .form-input {
    background: rgba(255,255,255,0.07) !important;
    border-color: rgba(255,255,255,0.12) !important;
    color: var(--text) !important;
}

/* Gastos delegados — gráfica y botones de modo */
html.dark .month-switcher-button {
    background: rgba(255,255,255,0.07) !important;
    border-color: rgba(255,255,255,0.12) !important;
    color: var(--muted) !important;
}
html.dark .month-switcher-button:hover {
    background: rgba(95,109,250,0.12) !important;
    border-color: #5f6dfa !important;
    color: var(--text) !important;
}
html.dark .month-switcher-button.is-active {
    background: linear-gradient(135deg, #0a84ff 0%, #5e5ce6 100%) !important;
    color: #fff !important;
    border-color: transparent !important;
}
html.dark .grafica-facturas-card {
    background: rgba(255,255,255,0.07) !important;
    box-shadow: 0 1px 4px rgba(0,0,0,0.3) !important;
}
html.dark .grafica-gastos-card {
    background: rgba(255,255,255,0.07) !important;
    box-shadow: 0 1px 4px rgba(0,0,0,0.3) !important;
}
html.dark .grafica-toggle-btn {
    background: rgba(255,255,255,0.07) !important;
    border-color: rgba(255,255,255,0.12) !important;
    color: var(--muted) !important;
}
html.dark .grafica-toggle-btn:hover {
    border-color: #a855f7 !important;
    color: #c4b5fd !important;
}

/* Gastos delegados — botón adjuntos y modal */
html.dark .btn-adj {
    background: rgba(255,255,255,0.07) !important;
    border-color: rgba(255,255,255,0.1) !important;
}
html.dark .modal-adjuntos-card {
    background: #0d1e3d !important;
    box-shadow: 0 12px 40px rgba(0,0,0,0.5) !important;
}
html.dark .modal-adj-titulo { color: var(--text) !important; }
html.dark .modal-adj-item {
    background: rgba(255,255,255,0.07) !important;
}
html.dark .modal-adj-file-label {
    background: rgba(255,255,255,0.06) !important;
    border-color: rgba(255,255,255,0.15) !important;
}
html.dark .modal-adj-upload { border-top-color: rgba(255,255,255,0.08) !important; }

/* ─────────────────────────────────────────────────────────── */

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: "SF Pro Display", "Segoe UI Variable", "Segoe UI", sans-serif;
    color: var(--text);
    overflow-x: hidden;
    background:
        radial-gradient(circle at top left, rgba(10, 132, 255, 0.18), transparent 24%),
        radial-gradient(circle at 80% 20%, rgba(94, 92, 230, 0.16), transparent 26%),
        linear-gradient(180deg, #f6f9fe 0%, #edf2fb 100%);
    transition: background 0.3s, color 0.2s;
}

.app-shell {
    min-height: 100vh;
}


.app-content {
    margin-left: 0;
    min-height: 100vh;
    position: relative;
    z-index: 1;
}

.content-wrap {
    width: 100%;
    max-width: 1400px;
    margin: 0;
    padding: 1rem 1.4rem 3rem;
    position: relative;
    z-index: 1;
}

/* Contenedor centrado reutilizable para páginas con contenido acotado */
.page-wrap {
    max-width: 1180px;
    margin: 0 auto;
}


@media (max-width: 900px) {
    :root {
        --sidebar-width: 0;
    }

    .content-wrap {
        padding: 0.9rem 1rem 70px;
    }
}

.ambient {
    position: fixed;
    inset: auto;
    width: 32rem;
    height: 32rem;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.28;
    pointer-events: none;
    z-index: 0;
}

.ambient-one {
    top: -8rem;
    right: -8rem;
    background: rgba(10, 132, 255, 0.4);
}

.ambient-two {
    left: -10rem;
    bottom: -8rem;
    background: rgba(48, 209, 88, 0.24);
}

.wrap {
    width: min(1440px, calc(100% - 2rem));
    margin: 0 auto;
    position: relative;
    z-index: 1;
}

.site-header {
    padding: 2rem 0 1rem;
}

.site-header .wrap {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1.5rem;
}

.brand-link {
    display: inline-flex;
    align-items: center;
    gap: 1rem;
    text-decoration: none;
}

.brand-name {
    font-size: clamp(2.5rem, 5vw, 4.5rem);
    font-weight: 800;
    letter-spacing: 0.06em;
}

.brand-subname {
    font-size: clamp(1.1rem, 2vw, 1.8rem);
    font-weight: 700;
    letter-spacing: 0.42em;
    color: #2a4e86;
    padding-left: 0.3rem;
}


    .brand-symbol {
        width: 72px;
        height: 72px;
    }
.eyebrow {
    margin: 0 0 0.55rem;
    text-transform: uppercase;
    letter-spacing: 0.18em;
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--blue);
}

nav {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

nav a {
    color: var(--text);
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 600;
    padding: 0.75rem 1rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.5);
    backdrop-filter: blur(14px);
}

main {
    padding: 0;
}

.glass-card {
    background: var(--surface);
    border: 1px solid rgba(255, 255, 255, 0.6);
    border-radius: 28px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(28px);
}

.messages {
    display: grid;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.message {
    padding: 1rem 1.1rem;
    border-radius: 18px;
    font-weight: 600;
}

.message-success {
    color: #0f5132;
    background: rgba(48, 209, 88, 0.16);
    border: 1px solid rgba(48, 209, 88, 0.28);
}

.message-error {
    color: #842029;
    background: rgba(255, 69, 58, 0.14);
    border: 1px solid rgba(255, 69, 58, 0.24);
}

.hero-dashboard {
    display: grid;
    grid-template-columns: 1.5fr 0.55fr 0.95fr;
    gap: 1.25rem;
    margin-bottom: 1.25rem;
}

.hero-dashboard-dashboard-only {
    grid-template-columns: minmax(0, 1.55fr) minmax(320px, 0.95fr);
}

.hero-copy,
.hero-side,
.period-filter-card,
.stat-card,
.chart-card,
.table-shell,
.empty-state {
    padding: 1.5rem;
}

.hero-compact {
    padding: 1.15rem 1.2rem;
}

.hero-copy h2 {
    margin: 0 0 0.85rem;
    font-size: clamp(2.25rem, 4vw, 4rem);
    line-height: 0.98;
    letter-spacing: -0.04em;
}

.upload-form {
    margin-top: 0.7rem;
}

.form-grid {
    display: grid;
    grid-template-columns: 1.4fr 0.8fr;
    gap: 1rem;
    margin-bottom: 1rem;
}

.field-group label {
    display: block;
    margin-bottom: 0.45rem;
    font-weight: 700;
    color: var(--text);
}

.field-group input {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 0.95rem 1rem;
    background: rgba(255, 255, 255, 0.88);
    font: inherit;
    color: var(--text);
}

.field-group input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.dropzone {
    position: relative;
    display: grid;
    place-items: center;
    min-height: 148px;
    padding: 1rem;
    border: 1.5px dashed rgba(10, 132, 255, 0.26);
    border-radius: 24px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.84) 0%, rgba(239, 244, 252, 0.92) 100%);
    transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.dropzone:hover,
.dropzone.is-dragover {
    transform: translateY(-1px);
    border-color: rgba(10, 132, 255, 0.58);
    box-shadow: 0 16px 36px rgba(10, 132, 255, 0.12);
}

.dropzone-copy {
    text-align: center;
    pointer-events: none;
}

.dropzone-title,
.dropzone-subtitle,
.dropzone-meta {
    margin: 0;
}

.dropzone-title {
    font-size: 1rem;
    font-weight: 700;
}

.dropzone-subtitle {
    margin-top: 0.25rem;
    color: var(--muted);
    font-size: 0.92rem;
}

.dropzone-meta {
    margin-top: 0.55rem;
    font-size: 0.8rem;
    color: var(--blue);
}

.file-list {
    display: grid;
    gap: 0.45rem;
    margin: 0.65rem 0 0;
    padding-left: 1.1rem;
    color: var(--muted);
    font-size: 0.9rem;
}

.form-errors {
    margin-bottom: 1rem;
    padding: 0.9rem 1rem;
    border-radius: 18px;
    color: #842029;
    background: rgba(255, 69, 58, 0.14);
    border: 1px solid rgba(255, 69, 58, 0.24);
}

.form-errors p {
    margin: 0;
}

.form-errors p + p {
    margin-top: 0.35rem;
}

.field-help {
    margin: 0.5rem 0 0;
    color: var(--muted);
    font-size: 0.88rem;
}

.primary-button {
    appearance: none;
    border: 0;
    border-radius: 999px;
    background: linear-gradient(135deg, #0a84ff 0%, #5e5ce6 100%);
    color: #fff;
    font: inherit;
    font-weight: 700;
    padding: 0.95rem 1.4rem;
    cursor: pointer;
    box-shadow: 0 18px 32px rgba(10, 132, 255, 0.28);
}

.hero-side {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 100%;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.9) 0%, rgba(238, 243, 251, 0.88) 100%);
}

.period-filter-card h3 {
    margin: 0 0 0.8rem;
    font-size: 1.4rem;
}

.period-filter-form {
    display: grid;
    gap: 0.9rem;
}

.period-filter-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
}

.compact-field label {
    margin-bottom: 0.3rem;
    font-size: 0.88rem;
}

.compact-field input {
    padding: 0.78rem 0.9rem;
}

.period-filter-actions {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.small-button {
    padding: 0.78rem 1rem;
    box-shadow: none;
}

.secondary-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.78rem 1rem;
    border-radius: 999px;
    color: var(--text);
    text-decoration: none;
    font-weight: 700;
    background: rgba(247, 249, 252, 0.9);
    border: 1px solid rgba(16, 37, 66, 0.08);
}

.panel-label,
.panel-meta {
    margin: 0;
    color: var(--muted);
}

.panel-value {
    margin: 0.35rem 0;
    font-size: clamp(4rem, 7vw, 5.5rem);
    line-height: 0.9;
    letter-spacing: -0.05em;
}

.trend-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 2rem;
    padding: 0.3rem 0.7rem;
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 700;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.stat-label,
.stat-helper,
.table-caption {
    margin: 0;
    color: var(--muted);
    font-size: 0.92rem;
}

.stat-helper {
    font-weight: 400;
}

.stat-delta-row {
    display: flex;
    align-items: center;
    margin: 0 0 0.55rem;
    flex-wrap: wrap;
}

.stat-delta-trend {
    min-height: 2.1rem;
    padding: 0.42rem 0.82rem;
    font-size: 0.84rem;
    font-weight: 800;
    letter-spacing: -0.01em;
    border: 1px solid rgba(255, 255, 255, 0.64);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.76),
        0 10px 18px rgba(16, 37, 66, 0.05);
    backdrop-filter: blur(18px);
}

.stat-delta-trend.is-positive {
    color: #0c6b31 !important;
    background: linear-gradient(180deg, rgba(48, 209, 88, 0.34) 0%, rgba(222, 248, 229, 0.92) 100%) !important;
    border-color: rgba(48, 209, 88, 0.34) !important;
}

.stat-delta-trend.is-negative {
    color: #b42318 !important;
    background: linear-gradient(180deg, rgba(255, 69, 58, 0.34) 0%, rgba(254, 233, 231, 0.94) 100%) !important;
    border-color: rgba(255, 69, 58, 0.32) !important;
}

.stat-delta-trend.is-neutral {
    color: #667085 !important;
    background: linear-gradient(180deg, rgba(102, 112, 133, 0.18) 0%, rgba(244, 245, 247, 0.92) 100%) !important;
    border-color: rgba(102, 112, 133, 0.2) !important;
}

.stat-card.is-positive {
    border-color: rgba(48, 209, 88, 0.22);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.7),
        0 26px 44px rgba(48, 209, 88, 0.08);
}

.stat-card.is-negative {
    border-color: rgba(255, 69, 58, 0.22);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.7),
        0 26px 44px rgba(255, 69, 58, 0.08);
}

.stat-value {
    margin: 0.2rem 0;
    font-size: 1.15rem;
    letter-spacing: -0.01em;
}

.chart-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.chart-card {
    min-height: 360px;
}

.chart-card-wide {
    grid-column: 1 / -1;
    min-height: 420px;
}

/* Tarjeta que ocupa 2 de las 3 columnas del grid (el donut) */
.chart-card-two-thirds {
    grid-column: span 2;
    min-height: 420px;
}

/* Fila flex que envuelve el donut + movimientos y ocupa toda la fila del grid */
.chart-row-flex {
    grid-column: 1 / -1;
    display: flex;
    gap: 1rem;
    align-items: stretch;
}

.chart-card canvas {
    width: 100% !important;
    height: 280px !important;
}

/* Canvas del donut: más alto para que el círculo respire con la leyenda abajo */
.chart-donut-card canvas {
    height: 340px !important;
}

.chart-detail {
    margin-top: 0.85rem;
    padding: 0.8rem 0.95rem;
    border-radius: 14px;
    background: rgba(10, 132, 255, 0.08);
    color: #0a4f94;
    font-weight: 700;
}

.chart-card-wide canvas {
    height: 340px !important;
}

.section-heading {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: flex-start;
    margin-bottom: 1rem;
}

.section-heading h3,
.empty-state h3 {
    margin: 0;
    font-size: 1.5rem;
}

.table-shell {
    overflow: hidden;
}

.detail-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: end;
    gap: 1rem;
    margin-bottom: 1rem;
}

.month-switcher {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.month-switcher-button {
    appearance: none;
    border: 1px solid rgba(16, 37, 66, 0.08);
    background: rgba(247, 249, 252, 0.9);
    color: var(--muted);
    border-radius: 999px;
    padding: 0.72rem 1rem;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

.month-switcher-button.is-active {
    background: linear-gradient(135deg, #0a84ff 0%, #5e5ce6 100%);
    color: #fff;
    box-shadow: 0 12px 24px rgba(10, 132, 255, 0.24);
}

.detail-search {
    min-width: min(280px, 100%);
}

.detail-search-label,
.metric-label {
    display: block;
    margin-bottom: 0.35rem;
    color: var(--muted);
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.detail-search input {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 0.9rem 1rem;
    background: rgba(255, 255, 255, 0.88);
    font: inherit;
    color: var(--text);
}

.compact-table-wrap {
    overflow: auto;
}

.compact-analytics-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.92rem;
}

.compact-analytics-table th,
.compact-analytics-table td {
    padding: 0.95rem 0.8rem;
    border-bottom: 1px solid var(--line);
    text-align: right;
    background: rgba(255, 255, 255, 0.56);
}

.compact-analytics-table thead th {
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 0.72rem;
    color: var(--muted);
    background: rgba(247, 249, 252, 0.96);
}

.compact-analytics-table tbody th {
    text-align: left;
    min-width: 240px;
    font-size: 0.96rem;
}

.compact-analytics-table tbody tr:hover th,
.compact-analytics-table tbody tr:hover td {
    background: rgba(10, 132, 255, 0.04);
}

.cell-total {
    font-weight: 700;
    background: rgba(94, 92, 230, 0.05) !important;
}

.trend-chip.is-positive {
    color: #0f7b39;
    background: rgba(48, 209, 88, 0.14);
}

.trend-chip.is-negative {
    color: #b42318;
    background: rgba(255, 69, 58, 0.14);
}

.trend-chip.is-neutral {
    color: #667085;
    background: rgba(102, 112, 133, 0.12);
}

.empty-state {
    max-width: 760px;
}

code {
    font-family: "Cascadia Code", monospace;
    background: rgba(16, 37, 66, 0.06);
    padding: 0.15rem 0.35rem;
    border-radius: 6px;
}

@media (max-width: 1080px) {
    .hero-dashboard,
    .form-grid,
    .stats-grid,
    .chart-grid,
    .site-header .wrap,
    .period-filter-grid {
        grid-template-columns: 1fr;
        display: grid;
    }

    .site-header .wrap {
        align-items: flex-start;
    }

    .brand-symbol {
        width: 72px;
        height: 72px;
    }

    .brand-name {
        font-size: clamp(2rem, 9vw, 3.4rem);
    }

    .brand-subname {
        font-size: clamp(1rem, 4vw, 1.4rem);
        letter-spacing: 0.28em;
    }

    .chart-card-wide,
    .chart-card-two-thirds {
        grid-column: auto;
    }


    .detail-toolbar {
        align-items: stretch;
        flex-direction: column;
    }
}

@media (max-width: 600px) {
    /* Solo en móvil pequeño el donut y movimientos se apilan verticalmente */
    .chart-row-flex {
        flex-direction: column;
    }
}

@media (max-width: 700px) {
    .wrap {
        width: min(100%, calc(100% - 1rem));
    }

    .hero-copy,
    .hero-side,
    .period-filter-card,
    .stat-card,
    .chart-card,
    .table-shell,
    .empty-state {
        padding: 1.1rem;
        border-radius: 22px;
    }

    nav {
        width: 100%;
    }
}

/* ── Tab switcher (Recibidas/Emitidas, Por artículo/Por delegado, Ventas €/Unidades…) ── */
.tab-switcher {
    display: flex;
    gap: 0.4rem;
    background: #f0f4fb;
    border-radius: 12px;
    padding: 0.3rem;
}
.tab-pill {
    padding: 0.4rem 1rem;
    border-radius: 9px;
    border: none;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    background: transparent;
    color: #8fa1c7;
    text-decoration: none;
    transition: all 0.15s;
    display: inline-flex;
    align-items: center;
    white-space: nowrap;
}
.tab-pill.tab-pill-active {
    background: linear-gradient(90deg, #5f6dfa, #8f3fff);
    color: #fff;
    box-shadow: 0 1px 4px rgba(16,37,66,0.12);
}
html.dark .tab-switcher { background: rgba(255,255,255,0.07); }
html.dark .tab-pill { color: #5a7a96; }
html.dark .tab-pill.tab-pill-active {
    background: linear-gradient(90deg, #5f6dfa, #8f3fff);
    color: #fff;
    box-shadow: none;
}

/* Anti-FOUC: fade-in del contenido en cada navegación entre páginas */
@keyframes contentFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}
.content-wrap {
    animation: contentFadeIn 0.2s ease-out both;
}
