/* ===================================================
   TITAN Cafeteria DTE
   Estética inspirada en Apple: capas iOS/macOS,
   mucho aire, acento azul y sombras suaves.
   =================================================== */
:root {
    --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-spring: cubic-bezier(0.34, 1.3, 0.64, 1);
    /* Capas tipo “dark mode” Apple (aprox. HIG) */
    --bg: #000000;
    --shell: #1c1c1e;
    --shell-hover: #2c2c2e;
    --surface: #1c1c1e;
    --surface-hover: #2c2c2e;
    --surface-active: #3a3a3c;
    --elevated: #2c2c2e;
    --border: rgba(84, 84, 88, 0.48);
    --border-strong: rgba(84, 84, 88, 0.65);
    /* Azul sistema (modo oscuro) */
    --brand: #0a84ff;
    --brand-hover: #409cff;
    --brand-light: rgba(10, 132, 255, 0.22);
    --accent-ink: #64d2ff;
    --accent-ink-bg: rgba(100, 210, 255, 0.12);
    --positive: #30d158;
    --positive-bg: rgba(48, 209, 88, 0.18);
    --critical: #ff9f0a;
    --critical-bg: rgba(255, 159, 10, 0.18);
    --negative: #ff453a;
    --negative-bg: rgba(255, 69, 58, 0.18);
    --info: #0a84ff;
    --info-bg: rgba(10, 132, 255, 0.18);
    --neutral: rgba(235, 235, 245, 0.5);
    --neutral-bg: rgba(235, 235, 245, 0.08);
    --text: rgba(255, 255, 255, 0.92);
    --text-secondary: rgba(235, 235, 245, 0.55);
    --text-placeholder: rgba(235, 235, 245, 0.35);
    --radius: 14px;
    --radius-sm: 10px;
    --radius-xs: 6px;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.45);
    --transition: 0.2s cubic-bezier(0.25, 0.1, 0.25, 1);
    /* Campos, overlays y toasts (oscuro) */
    --field-bg: rgba(14, 10, 10, 0.72);
    --toast-bg: rgba(43, 27, 24, 0.97);
    --toast-shadow: 0 12px 40px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.05) inset;
    --modal-scrim: rgba(20, 12, 11, 0.76);
    --modal-dialog-shadow:
        0 0 0 1px rgba(255, 255, 255, 0.04) inset,
        0 24px 48px rgba(0, 0, 0, 0.45),
        0 12px 24px rgba(0, 0, 0, 0.3);
}

/* Modo claro (iOS/macOS HIG aprox.) */
[data-theme="light"] {
    --bg: #f2f2f7;
    --shell: #ffffff;
    --shell-hover: #e5e5ea;
    --surface: #ffffff;
    --surface-hover: #e5e5ea;
    --surface-active: #d1d1d6;
    --elevated: #ffffff;
    --border: rgba(60, 60, 67, 0.18);
    --border-strong: rgba(60, 60, 67, 0.29);
    --brand: #007aff;
    --brand-hover: #0062d9;
    --brand-light: rgba(0, 122, 255, 0.14);
    --accent-ink: #5ac8fa;
    --accent-ink-bg: rgba(90, 200, 250, 0.14);
    --positive: #34c759;
    --positive-bg: rgba(52, 199, 89, 0.16);
    --critical: #ff9500;
    --critical-bg: rgba(255, 149, 0, 0.16);
    --negative: #ff3b30;
    --negative-bg: rgba(255, 59, 48, 0.14);
    --info: #007aff;
    --info-bg: rgba(0, 122, 255, 0.14);
    --neutral: rgba(60, 60, 67, 0.55);
    --neutral-bg: rgba(60, 60, 67, 0.08);
    --text: rgba(0, 0, 0, 0.88);
    --text-secondary: rgba(60, 60, 67, 0.62);
    --text-placeholder: rgba(60, 60, 67, 0.35);
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 24px 64px rgba(0, 0, 0, 0.12);
    --field-bg: #f2f2f7;
    --toast-bg: rgba(255, 255, 255, 0.98);
    --toast-shadow: 0 8px 32px rgba(0, 0, 0, 0.12), 0 0 0 0.5px rgba(0, 0, 0, 0.06) inset;
    --modal-scrim: rgba(0, 0, 0, 0.38);
    --modal-dialog-shadow: 0 0 0 0.5px rgba(0, 0, 0, 0.06) inset, 0 24px 48px rgba(0, 0, 0, 0.12);
}

[data-theme="light"] .login-card {
    background: rgba(255, 255, 255, 0.92);
    box-shadow: var(--shadow-lg), 0 0 0 0.5px rgba(0, 0, 0, 0.06) inset;
}

[data-theme="light"] .login-shell::before {
    background:
        radial-gradient(ellipse 120% 80% at 50% -20%, rgba(0, 122, 255, 0.1), transparent 55%),
        radial-gradient(ellipse 90% 60% at 100% 100%, rgba(90, 200, 250, 0.06), transparent 50%);
}

[data-theme="light"] .pin-key {
    background: #ffffff;
    border-color: var(--border-strong);
}

[data-theme="light"] .shell-bar {
    background: rgba(255, 255, 255, 0.82);
    border-bottom-color: var(--border);
}

[data-theme="light"] .sim-banner {
    background: rgba(255, 149, 0, 0.12);
    border-bottom-color: rgba(255, 149, 0, 0.35);
    color: rgba(120, 60, 0, 0.92);
}

[data-theme="light"] .tile:hover {
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .kpi-card:hover {
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .nav-overlay {
    background: rgba(0, 0, 0, 0.35);
}

[data-theme="light"] .modal-dialog {
    background: var(--surface);
    box-shadow: var(--modal-dialog-shadow);
}
[data-theme="light"] .modal-head {
    background: transparent;
}
[data-theme="light"] .receipt-banner {
    background: linear-gradient(90deg, rgba(157, 31, 36, 0.08), rgba(208, 173, 114, 0.05));
}
[data-theme="light"] .tab-btn:hover {
    background: rgba(0, 0, 0, 0.05);
}
[data-theme="light"] .f-btn-ghost:hover {
    background: rgba(0, 0, 0, 0.05);
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { height: 100%; }
body {
    font-family:
        -apple-system,
        BlinkMacSystemFont,
        "SF Pro Text",
        "SF Pro Display",
        "Segoe UI",
        "Inter",
        system-ui,
        sans-serif;
    background: var(--bg);
    color: var(--text);
    height: 100%;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-feature-settings: "kern" 1, "liga" 1;
    overflow: hidden;
}

.screen { display: none; height: 100%; }
.screen.active { display: flex; flex-direction: column; }

/* ===========================
   LOGIN
   =========================== */
.login-shell {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    padding: 28px 20px;
    position: relative;
    overflow: hidden;
}
/* Brillo cinematográfico muy suave (espacio / premium) */
.login-shell::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse 120% 80% at 50% -20%, rgba(10, 132, 255, 0.14), transparent 55%),
        radial-gradient(ellipse 90% 60% at 100% 100%, rgba(100, 210, 255, 0.06), transparent 50%);
    pointer-events: none;
}
.login-shell::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.03), transparent 35%);
    pointer-events: none;
}
.login-shell > * { position: relative; z-index: 2; }
.login-card {
    position: relative;
    background: rgba(28, 28, 30, 0.82);
    border: 1px solid var(--border);
    border-radius: calc(var(--radius) + 2px);
    padding: 40px 36px 32px;
    width: 100%;
    max-width: 360px;
    box-shadow: var(--shadow-lg), 0 0 0 0.5px rgba(255, 255, 255, 0.06) inset;
    backdrop-filter: saturate(180%) blur(24px);
    -webkit-backdrop-filter: saturate(180%) blur(24px);
}

.login-theme-wrap {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 4;
}

.theme-toggle {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: var(--radius-xs);
    background: rgba(235, 235, 245, 0.08);
    color: var(--brand);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    -webkit-tap-highlight-color: transparent;
}

.theme-toggle:hover {
    background: rgba(10, 132, 255, 0.15);
}

[data-theme="light"] .theme-toggle:hover {
    background: rgba(0, 122, 255, 0.12);
}

.theme-toggle .icon-sun {
    display: block;
}

.theme-toggle .icon-moon {
    display: none;
}

[data-theme="light"] .theme-toggle .icon-sun {
    display: none;
}

[data-theme="light"] .theme-toggle .icon-moon {
    display: block;
}

.theme-toggle:focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: 2px;
}

.shell-theme-toggle {
    background: transparent;
}

.shell-theme-toggle:hover {
    background: rgba(10, 132, 255, 0.12);
}

[data-theme="light"] .shell-theme-toggle:hover {
    background: rgba(0, 122, 255, 0.1);
}
.login-logo {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 20px;
}
.logo-icon {
    width: 48px; height: 48px;
    background: linear-gradient(180deg, #3a3a3c 0%, #2c2c2e 100%);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow:
        0 4px 16px rgba(0, 0, 0, 0.35),
        inset 0 1px 0 rgba(255, 255, 255, 0.12);
}
.logo-icon--brand {
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 1px;
    padding: 0 2px;
}
.logo-glyph {
    flex-shrink: 0;
    opacity: .98;
    filter: drop-shadow(0 1px 1px rgba(0,0,0,.25));
}
.login-logo h1 {
    font-size: 1.28rem;
    font-weight: 600;
    letter-spacing: -0.03em;
    text-transform: none;
    line-height: 1.2;
    color: var(--text);
}
.login-sub {
    font-size: 0.75rem;
    color: var(--text-secondary);
    letter-spacing: 0;
    font-weight: 400;
    text-transform: none;
}
.login-address {
    font-size: .68rem;
    color: var(--text-placeholder);
    line-height: 1.45;
    margin-top: 6px;
    max-width: 16rem;
}
.login-divider { height: 1px; background: var(--border); margin-bottom: 24px; }

.login-label {
    text-align: center;
    font-size: .78rem;
    color: var(--text-secondary);
    margin-bottom: 18px;
}

.pin-display {
    display: flex;
    justify-content: center;
    gap: 14px;
    margin-bottom: 6px;
}
.pin-dot {
    width: 13px; height: 13px;
    border-radius: 50%;
    border: 2px solid var(--text-placeholder);
    transition: var(--transition);
}
.pin-dot.filled { background: var(--brand); border-color: var(--brand); }
.pin-dot.error { border-color: var(--negative); background: var(--negative); animation: shake .35s ease; }

@keyframes shake {
    0%,100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

.pin-error {
    text-align: center;
    font-size: .72rem;
    color: var(--negative);
    height: 18px;
    line-height: 18px;
    margin-bottom: 6px;
}

.pin-pad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    max-width: 252px;
    margin: 0 auto;
}
.pin-key {
    height: 54px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: rgba(44, 44, 46, 0.85);
    color: var(--text);
    font-size: 1.25rem;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}
.pin-key:active { background: var(--surface-active); transform: scale(0.97); }
.pin-key:focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: 2px;
}
.pin-key-empty { background: transparent; border-color: transparent; pointer-events: none; }
.pin-key-fn { color: var(--text-secondary); font-size: .9rem; }

.login-env { text-align: center; margin-top: 20px; }
.env-tag {
    display: inline-block;
    font-size: .58rem;
    font-weight: 700;
    padding: 2px 10px;
    border-radius: 20px;
    background: var(--critical-bg);
    color: var(--critical);
    letter-spacing: 1.2px;
}

/* ===========================
   SHELL BAR
   =========================== */
.shell-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 52px;
    padding: 0 18px;
    background: rgba(28, 28, 30, 0.92);
    flex-shrink: 0;
    z-index: 100;
    border-bottom: 0.5px solid var(--border);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.25);
}
.shell-start, .shell-end { display: flex; align-items: center; gap: 10px; }
.shell-menu-btn {
    display: none;
    width: 36px; height: 36px;
    border: none; border-radius: var(--radius-xs);
    background: transparent;
    color: var(--brand);
    cursor: pointer;
    align-items: center; justify-content: center;
}
.shell-brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.shell-brand-text { display: flex; flex-direction: column; min-width: 0; }
.shell-logo {
    width: 32px; height: 32px;
    background: linear-gradient(180deg, #48484a 0%, #3a3a3c 100%);
    border-radius: var(--radius-xs);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1);
}
.shell-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
    letter-spacing: -0.025em;
    text-transform: none;
    line-height: 1.15;
}
.shell-tagline {
    font-size: 0.62rem;
    color: var(--text-secondary);
    font-weight: 400;
    letter-spacing: 0.01em;
    margin-top: 2px;
    max-width: 13rem;
    line-height: 1.3;
    white-space: normal;
    text-transform: none;
}
.shell-date { font-size: 0.72rem; color: var(--text-placeholder); }

.shell-icon-btn {
    width: 36px; height: 36px;
    border: none; border-radius: var(--radius-xs);
    background: transparent;
    color: var(--brand);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}
.shell-icon-btn:hover { background: rgba(10, 132, 255, 0.12); color: var(--brand-hover); }
.shell-icon-btn.syncing svg { animation: spin .7s linear infinite; }
.shell-icon-btn.sync-error { color: var(--danger, #ff453a); }
.shell-icon-btn.sync-error::after {
    content: ""; position: absolute; top: 6px; right: 6px;
    width: 6px; height: 6px; border-radius: 50%;
    background: var(--danger, #ff453a); box-shadow: 0 0 0 2px var(--surface-card, #1c1c1e);
}
.shell-icon-btn { position: relative; }
@keyframes spin { to { transform: rotate(360deg); } }

.shell-avatar {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: rgba(235, 235, 245, 0.12);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
}
.shell-avatar:hover { background: rgba(235, 235, 245, 0.2); }

.shell-menu-btn:focus-visible,
.shell-icon-btn:focus-visible,
.shell-avatar:focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: 2px;
}

/* Modo simulación — aviso bajo la barra */
.sim-banner {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 18px;
    background: rgba(255, 159, 10, 0.1);
    border-bottom: 0.5px solid rgba(255, 159, 10, 0.35);
    font-size: 0.75rem;
    color: rgba(255, 214, 170, 0.95);
    flex-shrink: 0;
    z-index: 99;
}
.sim-banner[hidden] { display: none !important; }
.sim-banner-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--critical);
    box-shadow: 0 0 0 3px rgba(255, 159, 10, 0.22);
    flex-shrink: 0;
    animation: simPulse 2s ease-in-out infinite;
}
@keyframes simPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: .45; }
}
.sim-banner-text { line-height: 1.35; }

@media (prefers-reduced-motion: reduce) {
    .sim-banner-dot { animation: none; }
}

/* ===========================
   LAYOUT
   =========================== */
.app-body {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Side Nav */
.side-nav {
    width: 228px;
    background: var(--surface);
    border-right: 0.5px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 14px 10px;
    overflow-y: auto;
    flex-shrink: 0;
}
.nav-section-label {
    font-size: 0.62rem;
    font-weight: 600;
    color: var(--text-placeholder);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    padding: 14px 14px 8px;
}
.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.84rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
    -webkit-tap-highlight-color: transparent;
    text-align: left;
    width: 100%;
    position: relative;
}
.nav-item:hover { background: rgba(235, 235, 245, 0.06); color: var(--text); }
.nav-item.active {
    background: rgba(10, 132, 255, 0.14);
    color: var(--text);
    box-shadow: inset 3px 0 0 var(--brand);
}
.nav-item.active svg { stroke: var(--brand); }
.nav-item:focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: 1px;
}
.nav-disabled {
    opacity: .4;
    cursor: default;
    pointer-events: none;
}
.nav-badge {
    margin-left: auto;
    font-size: .55rem;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 10px;
    background: var(--neutral-bg);
    color: var(--neutral);
    letter-spacing: .5px;
}

.nav-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 149;
}

/* Content */
.content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 28px 24px 32px;
    scroll-behavior: smooth;
    background: var(--bg);
}

@media (prefers-reduced-motion: reduce) {
    .content { scroll-behavior: auto; }
}

.module { display: none; }
.module.active {
    display: block;
    animation: moduleEnter .28s var(--ease-out-expo) forwards;
}
@keyframes moduleEnter {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
    .module.active { animation: none; opacity: 1; transform: none; }
}

/* Page Header (Fiori object page style) */
.page-header {
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}
.page-header--compact {
    margin-top: 8px;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: none;
}
.page-header h2 {
    font-size: 1.45rem;
    font-weight: 600;
    letter-spacing: -0.03em;
    line-height: 1.18;
    text-transform: none;
    color: var(--text);
}
.page-header h3 {
    font-size: 1.05rem;
    font-weight: 500;
    color: var(--text-secondary);
    letter-spacing: 0;
    text-transform: none;
}
.page-sub { font-size: 0.86rem; color: var(--text-secondary); margin-top: 8px; max-width: 42rem; line-height: 1.5; }
.page-header::after {
    content: '';
    display: block;
    width: 48px;
    height: 3px;
    margin-top: 16px;
    border-radius: 999px;
    background: var(--brand);
    opacity: 0.9;
}

.page-breadcrumb {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: .75rem;
    color: var(--text-placeholder);
    margin-bottom: 8px;
}
.breadcrumb-link {
    background: none; border: none;
    color: var(--brand); font-size: .75rem; font-family: inherit;
    cursor: pointer;
    padding: 0;
}
.breadcrumb-link:hover { text-decoration: underline; }
.breadcrumb-link:focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: 2px;
    border-radius: 2px;
}

/* ===========================
   KPI CARDS
   =========================== */
.kpi-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: 24px;
}
.kpi-card {
    background:
        linear-gradient(180deg, rgba(255,255,255,.025), rgba(255,255,255,0) 24%),
        linear-gradient(180deg, rgba(10, 132, 255, 0.05), rgba(10, 132, 255, 0) 42%),
        var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 18px;
    box-shadow: 0 1px 2px rgba(0,0,0,.12);
    transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition);
    position: relative;
    overflow: hidden;
}
.kpi-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--border-strong);
    opacity: .6;
}
.kpi-row .kpi-card:nth-child(1)::before { background: linear-gradient(90deg, var(--positive), #7fd47f); }
.kpi-row .kpi-card:nth-child(2)::before { background: linear-gradient(90deg, var(--info), #9ed6ff); }
.kpi-row .kpi-card:nth-child(3)::before { background: linear-gradient(90deg, var(--critical), #f2c48d); }
.kpi-row .kpi-card:nth-child(4)::before { background: linear-gradient(90deg, var(--brand), var(--accent-ink)); }
.kpi-card:hover {
    border-color: var(--border-strong);
    box-shadow: 0 10px 28px rgba(0,0,0,.28);
    transform: translateY(-1px);
}
@media (prefers-reduced-motion: reduce) {
    .kpi-card { transition: none; }
    .kpi-card:hover { transform: none; }
}
.kpi-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}
.kpi-title { font-size: .72rem; color: var(--text-secondary); font-weight: 500; }
.kpi-icon {
    width: 28px; height: 28px;
    border-radius: var(--radius-xs);
    display: flex;
    align-items: center;
    justify-content: center;
}
.kpi-positive { background: var(--positive-bg); color: var(--positive); }
.kpi-info { background: var(--info-bg); color: var(--info); }
.kpi-warning { background: var(--critical-bg); color: var(--critical); }
.kpi-neutral { background: var(--neutral-bg); color: var(--neutral); }
.kpi-value {
    font-size: 1.6rem;
    font-weight: 700;
    line-height: 1.1;
}
.kpi-footer { font-size: .65rem; color: var(--text-placeholder); margin-top: 6px; }
.kpi-card-matrix {
    grid-column: span 2;
}
.sales-matrix {
    display: grid;
    grid-template-columns: minmax(120px, 1.1fr) repeat(2, minmax(0, 1fr));
    gap: 8px;
}
.sales-matrix__cell {
    min-height: 72px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    background: rgba(255,255,255,.02);
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
}
.sales-matrix__cell strong {
    font-size: 1.05rem;
    line-height: 1.15;
}
.sales-matrix__cell span {
    font-size: .68rem;
    color: var(--text-placeholder);
}
.sales-matrix__cell--header,
.sales-matrix__cell--label {
    min-height: 0;
    background: var(--elevated);
    font-size: .72rem;
    font-weight: 700;
    color: var(--text-secondary);
}
.sales-matrix__cell--header {
    align-items: center;
    text-transform: uppercase;
    letter-spacing: .4px;
}
.sales-matrix__cell--label {
    justify-content: center;
}
.sales-matrix__cell--muted {
    background: transparent;
    border-style: dashed;
}

/* ===========================
   TILES
   =========================== */
.tile-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
}
.tile {
    background:
        linear-gradient(180deg, rgba(255,255,255,.025), rgba(255,255,255,0) 26%),
        var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 20px 44px 20px 20px;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    box-shadow: 0 1px 2px rgba(0,0,0,.1);
}
.tile::after {
    content: '';
    position: absolute;
    right: 16px;
    top: 50%;
    margin-top: -5px;
    width: 8px;
    height: 8px;
    border-right: 2px solid var(--text-placeholder);
    border-bottom: 2px solid var(--text-placeholder);
    transform: rotate(-45deg);
    opacity: .35;
    transition: opacity var(--transition), transform var(--transition);
}
.tile:hover::after { opacity: .85; transform: rotate(-45deg) translateX(2px); }
.tile:hover {
    border-color: rgba(10, 132, 255, 0.35);
    background: var(--surface-hover);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
}
.tile:active { transform: scale(.98); }
.tile:focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: 2px;
}
.tile-locked { cursor: default; padding-right: 20px; }
.tile-locked::after { display: none; }
.tile-locked:hover { border-color: var(--border); background: var(--surface); box-shadow: 0 1px 2px rgba(0,0,0,.1); }
.tile-icon {
    width: 52px; height: 52px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 14px;
}
.tile-icon-blue { background: var(--brand-light); color: var(--brand); }
.tile-icon-teal { background: var(--accent-ink-bg); color: var(--accent-ink); }
.tile-icon-orange { background: var(--critical-bg); color: var(--critical); }
.tile-icon-purple { background: rgba(132,118,222,.14); color: #b8afff; }
.tile-label { font-size: .88rem; font-weight: 600; margin-bottom: 4px; }
.tile-label {
    font-size: 1.05rem;
    letter-spacing: .03em;
    text-transform: uppercase;
}
.tile-desc { font-size: .72rem; color: var(--text-secondary); margin-bottom: 10px; }
.tile-status {
    font-size: .58rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 10px;
    letter-spacing: .3px;
}
.tile-active { background: var(--positive-bg); color: var(--positive); }
.tile-pending { background: var(--neutral-bg); color: var(--neutral); }

/* ===========================
   TAB BAR
   =========================== */
.tab-bar {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 5px;
    margin-bottom: 20px;
    background: var(--elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: inset 0 1px 0 rgba(255,255,255,.04);
}
.tab-btn {
    padding: 9px 18px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: .8rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    border-radius: var(--radius-xs);
    transition: background var(--transition), color var(--transition), box-shadow var(--transition);
    -webkit-tap-highlight-color: transparent;
}
.tab-btn:hover { color: var(--text); background: rgba(255,255,255,.04); }
.tab-btn.active {
    color: var(--brand);
    background: var(--surface-active);
    box-shadow: 0 1px 3px rgba(0,0,0,.2), inset 0 1px 0 rgba(255,255,255,.06);
}
.tab-btn:focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: 2px;
}

.ftab-panel { display: none; }
.ftab-panel.active { display: block; }

/* Toolbar */
.toolbar {
    display: flex;
    gap: 8px;
    margin-bottom: 14px;
    flex-wrap: wrap;
    align-items: center;
}
.toolbar-spacer { flex: 1 1 24px; }
.toolbar-actions {
    justify-content: flex-end;
}
.toolbar-actions .selection-chip {
    margin-left: auto;
}
.toolbar input[type="date"],
.toolbar input[type="time"] {
    padding: 8px 12px;
    background: var(--field-bg);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-xs);
    color: var(--text);
    font-size: .78rem;
    font-family: inherit;
    transition: var(--transition);
}
.toolbar input[type="date"]:focus,
.toolbar input[type="time"]:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 2px var(--brand-light);
}
.toolbar select {
    min-width: 168px;
}
.selection-chip {
    display: inline-flex;
    align-items: center;
    min-height: 36px;
    padding: 0 12px;
    border-radius: 999px;
    background: rgba(10, 132, 255, 0.1);
    color: var(--brand);
    border: 1px solid var(--border);
    font-size: .78rem;
    white-space: nowrap;
}

/* ===========================
   BUTTONS
   =========================== */
.f-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: 1px solid transparent;
    border-radius: var(--radius-xs);
    font-size: .8rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
    -webkit-tap-highlight-color: transparent;
    white-space: nowrap;
}
.f-btn-primary {
    background: var(--brand);
    color: #0a1830;
    border-color: rgba(10,24,48,.08);
    font-weight: 700;
}
.f-btn-primary:hover {
    background: var(--brand-hover);
    box-shadow: 0 6px 20px rgba(10, 132, 255, 0.22);
    color: #09162b;
}
.f-btn-primary:active { transform: scale(.98); }
.f-btn:focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: 2px;
}
.f-btn-primary:disabled { opacity: .35; cursor: not-allowed; }
.f-btn-ghost { background: transparent; color: var(--text-secondary); }
.f-btn-ghost:hover { background: rgba(255,255,255,.04); color: var(--text); }
.f-btn-sm { padding: 6px 12px; font-size: .72rem; }
.f-btn-outline { background: transparent; color: var(--text-secondary); border-color: var(--border-strong); }
.f-btn-outline:hover { background: var(--surface-hover); border-color: rgba(10, 132, 255, 0.35); color: var(--text); }
.f-btn-positive { background: var(--positive); color: #fff; border-color: var(--positive); }
.f-btn-secondary {
    background: rgba(10, 132, 255, 0.12);
    color: var(--brand);
    border-color: rgba(10, 132, 255, 0.28);
    font-weight: 600;
}
.f-btn-secondary:hover { background: rgba(10, 132, 255, 0.2); }
.f-btn-secondary:disabled { opacity: .35; cursor: not-allowed; }

/* ===========================
   PREVIEW DTE (Apple-style)
   =========================== */
.modal-xxl { max-width: 980px; }
.modal-dialog.modal-xl { max-width: 920px; }
.preview-head-text h3 { margin: 0; }
.modal-subtitle { margin: 4px 0 0; font-size: 0.78rem; color: var(--text-placeholder); }
.pv-head {
    display: flex; justify-content: space-between; gap: 16px;
    padding: 14px 16px; margin-bottom: 14px;
    background: var(--surface-elevated, rgba(255,255,255,.04));
    border: 1px solid var(--border, rgba(255,255,255,.08));
    border-radius: 12px;
    flex-wrap: wrap;
}
.pv-head-left { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.pv-tipo { font-size: 0.95rem; font-weight: 700; color: var(--text); }
.pv-control { font-size: 0.74rem; color: var(--text-secondary); }
.pv-control code { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 0.72rem; }
.pv-head-right { display: flex; gap: 6px; align-items: flex-start; flex-wrap: wrap; }
.pv-chip {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 4px 10px; border-radius: 999px;
    font-size: 0.66rem; font-weight: 700; letter-spacing: 0.4px;
    border: 1px solid transparent;
}
.pv-chip-test { background: rgba(255, 159, 10, 0.16); color: #ff9f0a; border-color: rgba(255, 159, 10, 0.35); }
.pv-chip-prod { background: rgba(48, 209, 88, 0.18); color: #30d158; border-color: rgba(48, 209, 88, 0.4); }
.pv-chip-info { background: rgba(10, 132, 255, 0.16); color: var(--brand); border-color: rgba(10, 132, 255, 0.4); }
.pv-chip-warn { background: rgba(255, 69, 58, 0.16); color: #ff453a; border-color: rgba(255, 69, 58, 0.4); }
.pv-section { margin: 0 0 14px; }
.pv-section-title {
    font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.6px;
    color: var(--text-placeholder); margin: 0 0 8px;
    display: flex; align-items: center; gap: 8px;
}
.pv-pill {
    background: rgba(10, 132, 255, 0.12); color: var(--brand);
    padding: 2px 8px; border-radius: 999px; font-size: 0.62rem;
    text-transform: none; letter-spacing: 0; font-weight: 600;
}
.pv-grid { display: grid; gap: 10px 16px; }
.pv-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 640px) { .pv-grid-2 { grid-template-columns: 1fr; } }
.pv-grid > div {
    display: flex; flex-direction: column; gap: 2px;
    padding: 10px 12px;
    background: var(--surface-card, rgba(255,255,255,.03));
    border: 1px solid var(--border, rgba(255,255,255,.06));
    border-radius: 10px;
    min-width: 0;
}
.pv-k { font-size: 0.66rem; color: var(--text-placeholder); text-transform: uppercase; letter-spacing: 0.5px; }
.pv-v { font-size: 0.86rem; color: var(--text); font-weight: 500; word-break: break-word; }
.pv-empty {
    padding: 14px; border-radius: 10px;
    background: var(--surface-card, rgba(255,255,255,.03));
    border: 1px dashed var(--border, rgba(255,255,255,.1));
    color: var(--text-secondary); font-size: 0.82rem;
}
.pv-table-wrap {
    border: 1px solid var(--border, rgba(255,255,255,.08));
    border-radius: 12px; overflow: hidden;
}
.pv-table {
    width: 100%; border-collapse: collapse; font-size: 0.78rem;
    background: var(--surface-card, rgba(255,255,255,.02));
}
.pv-table th {
    text-align: left; padding: 10px 12px;
    background: rgba(255,255,255,0.04); color: var(--text-placeholder);
    font-weight: 600; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.4px;
    border-bottom: 1px solid var(--border, rgba(255,255,255,.08));
}
.pv-table td { padding: 10px 12px; border-bottom: 1px solid var(--border, rgba(255,255,255,.05)); color: var(--text); }
.pv-table tbody tr:last-child td { border-bottom: none; }
.pv-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.pv-totales-grid {
    display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}
@media (max-width: 720px) { .pv-totales-grid { grid-template-columns: repeat(2, 1fr); } }
.pv-tot {
    display: flex; flex-direction: column; gap: 2px;
    padding: 12px 14px;
    background: var(--surface-card, rgba(255,255,255,.03));
    border: 1px solid var(--border, rgba(255,255,255,.06));
    border-radius: 10px;
}
.pv-tot span { font-size: 0.66rem; color: var(--text-placeholder); text-transform: uppercase; letter-spacing: 0.4px; }
.pv-tot strong { font-size: 0.95rem; color: var(--text); font-variant-numeric: tabular-nums; }
.pv-tot-final {
    background: linear-gradient(135deg, rgba(10,132,255,0.18), rgba(10,132,255,0.06));
    border-color: rgba(10, 132, 255, 0.45);
}
.pv-tot-final strong { font-size: 1.18rem; color: var(--brand); }
.pv-letras {
    margin: 10px 0 0; padding: 10px 14px; border-radius: 10px;
    background: rgba(10, 132, 255, 0.06);
    color: var(--text-secondary); font-style: italic; font-size: 0.78rem;
    text-align: center;
}
.pv-details summary {
    cursor: pointer; padding: 10px 14px; border-radius: 10px;
    background: var(--surface-card, rgba(255,255,255,.03));
    border: 1px solid var(--border, rgba(255,255,255,.08));
    color: var(--text-secondary); font-size: 0.8rem;
    display: flex; align-items: center; gap: 8px;
}
.pv-details summary::-webkit-details-marker { display: none; }
.pv-details[open] summary { border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.pv-json {
    margin: 0; padding: 14px;
    background: rgba(0,0,0,.35); color: #b6e3ff;
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
    font-size: 0.72rem; line-height: 1.45;
    border: 1px solid var(--border, rgba(255,255,255,.08));
    border-top: none;
    border-bottom-left-radius: 10px; border-bottom-right-radius: 10px;
    max-height: 320px; overflow: auto; white-space: pre-wrap; word-break: break-word;
}
[data-theme="light"] .pv-json { background: #1c1c1e; color: #d6f1ff; }

/* ===========================
   LIST ITEMS / TABLE ROWS
   =========================== */
.list-container { display: flex; flex-direction: column; gap: 8px; }

.list-row {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px 14px 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
    margin-bottom: 0;
    box-shadow: 0 6px 16px rgba(0,0,0,.12);
    border-left: 3px solid transparent;
}
.list-row--interactive:hover {
    background: var(--surface-hover);
    border-color: var(--border-strong);
    border-left-color: var(--brand);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.32);
}
.list-row:active { background: var(--surface-active); }

.list-row-glyph {
    width: 42px;
    height: 42px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: var(--text-secondary);
    background: var(--elevated);
    border: 1px solid var(--border);
}
.list-row-glyph--receipt { color: var(--info); background: var(--info-bg); border-color: rgba(103,182,255,.24); }
.list-row-glyph--dte { color: var(--positive); background: var(--positive-bg); border-color: rgba(102,194,133,.22); }

.list-row--clickable { cursor: pointer; }
.list-row:not(.list-row--clickable) { cursor: default; }
.list-row--clickable:focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: 2px;
}
.row-hint {
    font-size: 0.75rem;
    color: var(--text-placeholder);
    font-weight: 400;
}
.receipt-detail-summary {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 12px 20px;
    padding: 16px 18px;
    border-radius: var(--radius-sm);
    background: var(--elevated);
    border: 1px solid var(--border);
}
.receipt-detail-total {
    font-size: 1.75rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--positive);
}
.row-check {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.row-check input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}
.row-check span {
    width: 18px;
    height: 18px;
    border-radius: 5px;
    border: 1px solid var(--border-strong);
    background: var(--bg);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.row-check input:checked + span {
    background: var(--brand);
    border-color: var(--brand);
}
.row-check input:checked + span::after {
    content: '';
    width: 9px;
    height: 5px;
    border-left: 2px solid #fff;
    border-bottom: 2px solid #fff;
    transform: rotate(-45deg) translateY(-1px);
}

.row-main { flex: 1; min-width: 0; }
.row-title { font-size: .82rem; font-weight: 600; margin-bottom: 2px; }
.row-meta { font-size: .7rem; color: var(--text-secondary); display: flex; gap: 10px; flex-wrap: wrap; }
.row-amount { font-size: 1rem; font-weight: 700; color: var(--positive); white-space: nowrap; }
.row-actions { display: flex; gap: 6px; flex-shrink: 0; }
.row-actions .f-btn {
    white-space: nowrap;
}

/* Status tags */
.status-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: .6rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 10px;
    letter-spacing: .3px;
    text-transform: uppercase;
}
.st-positive { background: var(--positive-bg); color: var(--positive); }
.st-info { background: var(--info-bg); color: var(--info); }
.st-critical { background: var(--critical-bg); color: var(--critical); }
.st-negative { background: var(--negative-bg); color: var(--negative); }
.st-neutral { background: var(--neutral-bg); color: var(--neutral); }
.st-dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; }

/* ===========================
   MODAL
   =========================== */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: var(--modal-scrim);
    z-index: 200;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 20px;
    animation: overlayFade .2s var(--ease-out-expo);
}
@keyframes overlayFade { from { opacity: 0; } to { opacity: 1; } }
.modal-overlay.open { display: flex; }

.modal-dialog {
    background:
        linear-gradient(180deg, rgba(255,255,255,.03), rgba(255,255,255,0) 18%),
        linear-gradient(180deg, rgba(157,31,36,.06), rgba(157,31,36,0) 24%),
        var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    width: 100%;
    max-width: 440px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--modal-dialog-shadow);
    animation: modalIn .32s var(--ease-out-expo);
}
.modal-lg { max-width: 520px; }
.modal-xl { max-width: 760px; }

@keyframes modalIn {
    from { opacity: 0; transform: translateY(16px) scale(.96); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}
@media (prefers-reduced-motion: reduce) {
    .modal-overlay { animation: none; }
    .modal-dialog { animation: none; }
}

.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(180deg, rgba(255,255,255,.02), rgba(255,255,255,0));
}
.modal-head h3 { font-size: .92rem; font-weight: 700; }
.modal-close {
    width: 32px; height: 32px;
    border: none; border-radius: var(--radius-xs);
    background: rgba(255,255,255,.035);
    color: var(--text-secondary);
    font-size: 1.1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    transition: background var(--transition), color var(--transition);
}
.modal-close:hover { background: var(--surface-hover); color: var(--text); }
.modal-close:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
    -webkit-overflow-scrolling: touch;
}
.modal-foot {
    display: flex;
    gap: 8px;
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    justify-content: flex-end;
    flex-wrap: wrap;
}
.modal-foot .f-btn {
    min-width: 120px;
    justify-content: center;
}

/* Receipt banner in modal */
.receipt-banner {
    background: linear-gradient(90deg, rgba(157,31,36,.11), rgba(208,173,114,.06));
    border-radius: var(--radius-xs);
    padding: 14px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}
.rb-left { font-size: .82rem; color: var(--text-secondary); }
.rb-right { font-size: 1.2rem; font-weight: 700; color: var(--positive); }

/* Form */
.form-section-title {
    font-size: .72rem;
    font-weight: 700;
    color: var(--text-placeholder);
    text-transform: uppercase;
    letter-spacing: .8px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 8px;
}
.form-hint { font-size: .68rem; color: var(--text-placeholder); margin-bottom: 14px; }
.form-field > .form-hint { margin-top: 6px; margin-bottom: 0; }

/* Insumo: combobox con sugerencias (typeahead) */
.ing-combo { position: relative; width: 100%; }
.ing-combo-input { width: 100%; min-width: 0; }
.combo-cell { min-width: 220px; max-width: 420px; vertical-align: top; }
.ing-combo-list {
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% + 5px);
    margin: 0;
    padding: 6px 0;
    list-style: none;
    z-index: 220;
    max-height: min(280px, 46vh);
    overflow-y: auto;
    overflow-x: hidden;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-strong);
    background: var(--surface);
    box-shadow: var(--shadow-lg);
    -webkit-overflow-scrolling: touch;
}
.ing-combo-opt {
    padding: 10px 14px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 3px;
    transition: background var(--transition);
}
.ing-combo-opt.is-active,
.ing-combo-opt:hover { background: var(--surface-hover); }
.ing-combo-name {
    font-size: .82rem;
    font-weight: 600;
    color: var(--text);
    letter-spacing: -0.02em;
    line-height: 1.25;
}
.ing-combo-meta {
    font-size: .68rem;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
    line-height: 1.3;
}

.form-field { margin-bottom: 14px; }
.form-field label {
    display: block;
    font-size: .7rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 5px;
}
.form-field input,
.form-field select {
    width: 100%;
    padding: 9px 12px;
    background: var(--field-bg);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-xs);
    color: var(--text);
    font-size: .82rem;
    font-family: inherit;
    transition: var(--transition);
    -webkit-appearance: none;
}
.form-field input:focus,
.form-field select:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 2px var(--brand-light);
}
.form-field input::placeholder { color: var(--text-placeholder); }
.checkbox-row {
    display: flex !important;
    align-items: center;
    gap: 10px;
    font-size: .78rem;
    margin-bottom: 0 !important;
}
.checkbox-row input[type="checkbox"] {
    width: 16px;
    height: 16px;
    margin: 0;
    padding: 0;
    accent-color: var(--brand);
    -webkit-appearance: checkbox;
}
.form-row { display: flex; gap: 10px; }
.form-row .form-field { flex: 1; }

/* ===========================
   DTE DETAIL
   =========================== */
.dte-qr-block {
    text-align: center;
    padding: 20px;
    background: linear-gradient(180deg, rgba(255,255,255,.025), rgba(255,255,255,0)), var(--elevated);
    border-radius: var(--radius-sm);
    margin-bottom: 18px;
}
.dte-qr-block img {
    width: 150px; height: 150px;
    border-radius: var(--radius-xs);
    background: #fff;
    padding: 8px;
}
.dte-qr-text { font-size: .65rem; color: var(--text-placeholder); margin-top: 8px; }
.detail-subsection {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}
.detail-subsection h4 {
    font-size: .84rem;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.detail-grid { display: flex; flex-direction: column; }
.detail-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    gap: 10px;
}
.detail-row:last-child { border-bottom: none; }
.dk { font-size: .75rem; color: var(--text-secondary); flex-shrink: 0; }
.dv { font-size: .8rem; font-weight: 500; text-align: right; word-break: break-all; max-width: 60%; }
.dv-lg { font-size: 1.1rem; font-weight: 700; color: var(--positive); }
.dv-mono { font-size: .65rem; color: var(--text-secondary); font-family: 'SF Mono', 'Cascadia Code', monospace; }

/* ===========================
   EMPTY STATE
   =========================== */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 44px 24px;
    text-align: center;
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-sm);
    background: linear-gradient(180deg, rgba(255,255,255,.02), transparent 40%);
    margin-top: 4px;
}
.empty-state[hidden] { display: none !important; }
.compact-empty { padding: 20px 12px; }
.empty-state svg { opacity: .35; }
.empty-state p { font-size: .88rem; color: var(--text); font-weight: 600; letter-spacing: -0.02em; }
.empty-state span { font-size: .74rem; color: var(--text-secondary); max-width: 260px; line-height: 1.45; }

/* ===========================
   TOAST
   =========================== */
#toastContainer {
    position: fixed;
    top: 56px;
    right: 20px;
    z-index: 999;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
    width: 320px;
}
.toast-item {
    background: var(--toast-bg);
    color: var(--text);
    border: 1px solid var(--border-strong);
    border-left: 4px solid var(--info);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    font-size: .8rem;
    font-weight: 500;
    line-height: 1.35;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    box-shadow: var(--toast-shadow);
    animation: toastIn .35s var(--ease-out-expo);
    pointer-events: auto;
}
.toast-item span:last-child { flex: 1; min-width: 0; }
.toast-item.out { animation: toastOut .25s ease forwards; }
.toast-success { border-left-color: var(--positive); }
.toast-error { border-left-color: var(--negative); }
.toast-info { border-left-color: var(--info); }
.t-icon { flex-shrink: 0; width: 18px; height: 18px; }
.toast-success .t-icon { color: var(--positive); }
.toast-error .t-icon { color: var(--negative); }
.toast-info .t-icon { color: var(--info); }

@keyframes toastIn {
    from { opacity: 0; transform: translateX(24px) scale(.96); }
    to { opacity: 1; transform: translateX(0) scale(1); }
}
@keyframes toastOut { to { opacity: 0; transform: translateX(16px); filter: blur(2px); } }
@media (prefers-reduced-motion: reduce) {
    .toast-item { animation: none; }
    .toast-item.out { animation: none; filter: none; }
}

.spinner {
    display: inline-block;
    width: 14px; height: 14px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin .6s linear infinite;
}

/* ===========================
   INVENTORY TABS
   =========================== */
.itab-panel { display: none; }
.itab-panel.active { display: block; }
.ptab-panel { display: none; }
.ptab-panel.active { display: block; }

/* Toolbar */
.toolbar-search { flex: 1; max-width: 320px; }
.toolbar-search input {
    width: 100%;
    padding: 8px 12px;
    background: var(--field-bg);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-xs);
    color: var(--text);
    font-size: .8rem;
    font-family: inherit;
    transition: var(--transition);
}
.toolbar-search input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand-light); }
.toolbar-search input::placeholder { color: var(--text-placeholder); }

.toolbar select {
    padding: 8px 12px;
    background: var(--field-bg);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-xs);
    color: var(--text);
    font-size: .78rem;
    font-family: inherit;
    -webkit-appearance: none;
    transition: var(--transition);
}
.toolbar select:focus { outline: none; border-color: var(--brand); }

/* ===========================
   DATA TABLE
   =========================== */
.inv-table-wrap { overflow-x: auto; margin-bottom: 8px; }
.inv-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: .78rem;
}
.inv-table thead th {
    padding: 10px 12px;
    text-align: left;
    font-weight: 600;
    font-size: .68rem;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-strong);
    white-space: nowrap;
    position: sticky;
    top: 0;
    background: var(--elevated);
    z-index: 2;
}
.inv-table tbody tr {
    transition: var(--transition);
}
.inv-table tbody tr:hover { background: var(--surface-hover); }
.inv-table tbody td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.inv-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.inv-table input,
.inv-table select {
    width: 100%;
    padding: 7px 9px;
    background: var(--field-bg);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-xs);
    color: var(--text);
    font-size: .75rem;
    font-family: inherit;
}
.inv-table input:focus,
.inv-table select:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 2px var(--brand-light);
}
.td-name { font-weight: 600; color: var(--text); }
.td-link { cursor: pointer; color: var(--brand); }
.td-link:hover { text-decoration: underline; }
.td-secondary { color: var(--text-secondary); font-size: .72rem; }
.td-empty { text-align: center; padding: 32px 12px !important; color: var(--text-placeholder); }
.td-danger { color: var(--negative); font-weight: 700; }

.row-low td { background: rgba(157,31,36,.08); }
.row-total td { border-top: 2px solid var(--border-strong); background: var(--surface); }

.cat-tag {
    display: inline-block;
    font-size: .62rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
    background: var(--neutral-bg);
    color: var(--neutral);
    letter-spacing: .2px;
    white-space: nowrap;
}

.inv-table-compact { font-size: .75rem; }
.inv-table-compact td { padding: 7px 10px; }

.table-footer {
    font-size: .7rem;
    color: var(--text-placeholder);
    padding: 8px 4px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
}
.table-pagination {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.table-pagination-status {
    font-size: .68rem;
    color: var(--text-secondary);
}
.table-pagination button[disabled] {
    opacity: .45;
    cursor: not-allowed;
}

.margin-badge {
    display: inline-block;
    font-size: .72rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 10px;
    background: var(--neutral-bg);
    color: var(--neutral);
}
.margin-badge.positive { background: var(--positive-bg); color: var(--positive); }
.margin-badge.critical { background: var(--critical-bg); color: var(--critical); }

/* ===========================
   ALERTS
   =========================== */
.alert-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    background: var(--critical-bg);
    border: 1px solid rgba(231,101,0,.2);
    border-radius: var(--radius-sm);
    margin-bottom: 14px;
    font-size: .82rem;
    font-weight: 500;
    color: var(--critical);
}
.row-alert { border-left: 3px solid var(--critical); }

/* ===========================
   DASHBOARD CARDS
   =========================== */
.dash-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}
.dash-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 18px;
}
.dash-card-wide { grid-column: span 2; }
.dash-card-title {
    font-size: .78rem;
    font-weight: 700;
    color: var(--text-secondary);
    margin-bottom: 14px;
    text-transform: uppercase;
    letter-spacing: .5px;
}
.dash-list { display: flex; flex-direction: column; gap: 10px; }
.accounting-kpi-row {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin-bottom: 12px;
}
.accounting-kpi-row .kpi-card {
    padding: 14px;
}
.dash-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}
.dash-row-main { flex: 1; min-width: 0; }
.dash-row-name { font-size: .8rem; font-weight: 600; display: block; }
.dash-row-cat { font-size: .65rem; color: var(--text-placeholder); }
.dash-row-val {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    min-width: 130px;
}
.margin-bar {
    display: block;
    height: 6px;
    border-radius: 3px;
    background: var(--positive);
    min-width: 4px;
    transition: width .3s ease;
}
.margin-bar-low { background: var(--critical); }
.margin-pct {
    font-size: .72rem;
    font-weight: 700;
    color: var(--text-secondary);
    min-width: 42px;
    text-align: right;
}
.margin-pct.positive { color: var(--positive); }
.margin-pct.critical { color: var(--critical); }

/* ===========================
   RECIPE DETAIL
   =========================== */
.recipe-summary { display: flex; flex-direction: column; }
.recipe-sum-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    gap: 10px;
}
.recipe-sum-row:last-child { border-bottom: none; }
.recipe-notes {
    margin-top: 14px;
    padding: 12px;
    background: var(--elevated);
    border-radius: var(--radius-xs);
    font-size: .78rem;
    color: var(--text-secondary);
}

.positive { color: var(--positive); }
.critical { color: var(--critical); }

/* ===========================
   RECIPE EDITOR
   =========================== */
.recipe-calc-bar {
    display: flex;
    gap: 12px;
    margin-top: 14px;
    padding: 14px 16px;
    background: var(--elevated);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}
.calc-item { flex: 1; text-align: center; }
.calc-label { display: block; font-size: .62rem; font-weight: 600; color: var(--text-placeholder); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 4px; }
.calc-value { font-size: 1rem; font-weight: 700; }

.rec-ing-input {
    width: 100%;
    padding: 6px 8px;
    background: var(--field-bg);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-xs);
    color: var(--text);
    font-size: .76rem;
    font-family: inherit;
    transition: var(--transition);
}
.rec-ing-input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand-light); }
.rec-ing-input::placeholder { color: var(--text-placeholder); }
.rec-ing-input.num { text-align: right; }
.rec-ing-del {
    width: 26px; height: 26px;
    border: none; border-radius: var(--radius-xs);
    background: var(--negative-bg);
    color: var(--negative);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .9rem;
    line-height: 1;
    transition: var(--transition);
}
.rec-ing-del:hover { background: var(--negative); color: #fff; }

/* ===========================
   RESPONSIVE
   =========================== */
@media (max-width: 768px) {
    .shell-menu-btn { display: flex; }
    .shell-date { display: none; }

    .side-nav {
        position: fixed;
        left: -260px;
        top: 48px;
        bottom: 0;
        width: 250px;
        z-index: 150;
        transition: left .25s ease;
        box-shadow: var(--shadow-lg);
    }
    .side-nav.open { left: 0; }
    .nav-overlay.open { display: block; }

    .content { padding: 16px; }

    .kpi-row { grid-template-columns: repeat(2, 1fr); }
    .tile-grid { grid-template-columns: repeat(2, 1fr); }

    #toastContainer { right: 10px; left: 10px; width: auto; }

    .modal-overlay { padding: 10px; align-items: flex-end; }
    .modal-dialog { border-radius: var(--radius) var(--radius) 0 0; max-height: 90vh; }
}

@media (max-width: 420px) {
    .kpi-row { grid-template-columns: 1fr 1fr; gap: 8px; }
    .tile-grid { grid-template-columns: 1fr; }
    .kpi-value { font-size: 1.3rem; }
    .kpi-card-matrix { grid-column: span 2; }
    .sales-matrix {
        grid-template-columns: minmax(96px, 1fr) repeat(2, minmax(0, 1fr));
        gap: 6px;
    }
    .sales-matrix__cell {
        padding: 8px 10px;
        min-height: 64px;
    }
    .sales-matrix__cell strong {
        font-size: .92rem;
    }
    .dash-grid { grid-template-columns: 1fr; }
    .dash-card-wide { grid-column: span 1; }
    .toolbar-search { max-width: 100%; }
    .inv-table { font-size: .7rem; }
    .toolbar-actions {
        justify-content: stretch;
    }
    .toolbar-actions .selection-chip {
        margin-left: 0;
        width: 100%;
        justify-content: center;
    }
    .inv-table thead th, .inv-table tbody td { padding: 8px 6px; }
    .modal-foot {
        justify-content: stretch;
    }
    .modal-foot .f-btn {
        flex: 1 1 100%;
        width: 100%;
    }
    .row-actions {
        margin-left: auto;
    }
}

/* ============================================================
   Inventario 2.0 — Salud, bloqueados, producción, mermas
   ============================================================ */

.tab-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    margin-left: 6px;
    border-radius: 9px;
    background: var(--critical, #ff3b30);
    color: #fff;
    font-size: 0.68rem;
    font-weight: 700;
    line-height: 1;
}

.health-grid { display: flex; flex-direction: column; gap: 16px; }
.health-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 12px;
}
.health-card {
    background: var(--surface, #fff);
    border: 1px solid var(--border, #e5e5ea);
    border-radius: 14px;
    padding: 14px 16px;
}
.health-title { font-size: 0.78rem; color: var(--text-secondary); margin-bottom: 4px; }
.health-value { font-size: 1.6rem; font-weight: 700; color: var(--text-primary); }
.health-footer { font-size: 0.72rem; color: var(--text-placeholder); margin-top: 4px; }
.health-success .health-value { color: var(--success, #34c759); }
.health-warning .health-value { color: var(--warning, #ff9500); }
.health-critical .health-value { color: var(--critical, #ff3b30); }
.health-info .health-value { color: var(--accent, #007aff); }

.health-sections {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 14px;
}
.health-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-faint, #f0f0f3);
}
.health-row:last-child { border-bottom: none; }
.health-row-title { font-weight: 600; color: var(--text-primary); font-size: 0.86rem; }
.health-row-sub { font-size: 0.74rem; color: var(--text-secondary); margin-top: 2px; }
.health-row-actions { display: flex; gap: 6px; }
.dash-card-footer { padding-top: 12px; margin-top: 8px; border-top: 1px solid var(--border-light); display: flex; justify-content: flex-end; }

/* Bloqueados */
.blocked-card {
    background: var(--surface, #fff);
    border: 1px solid var(--border, #e5e5ea);
    border-left: 4px solid var(--critical, #ff3b30);
    border-radius: 12px;
    padding: 14px 16px;
    margin-bottom: 10px;
}
.blocked-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 10px;
}
.blocked-title { font-weight: 700; color: var(--text-primary); }
.blocked-sub { font-size: 0.76rem; color: var(--text-secondary); margin-top: 2px; }
.blocked-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.blocked-reason {
    font-size: 0.82rem;
    color: var(--critical, #ff3b30);
    margin-bottom: 10px;
    padding: 8px 10px;
    background: rgba(255, 59, 48, 0.08);
    border-radius: 8px;
}
.blocked-grid { display: flex; flex-direction: column; gap: 6px; }
.blocked-row {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 12px;
    font-size: 0.8rem;
    padding: 6px 0;
    border-top: 1px solid var(--border-faint, #f0f0f3);
}
.blocked-ing { font-weight: 600; color: var(--text-primary); }
.blocked-need { color: var(--text-secondary); }
.blocked-have { color: var(--critical, #ff3b30); font-weight: 600; }

/* Producción */
.prod-card {
    background: var(--surface, #fff);
    border: 1px solid var(--border, #e5e5ea);
    border-radius: 12px;
    padding: 14px 16px;
    margin-bottom: 10px;
}
.prod-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 12px;
}
.prod-code { font-weight: 700; color: var(--text-primary); }
.prod-sub { font-size: 0.76rem; color: var(--text-secondary); margin-top: 2px; }
.prod-body {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 12px;
    margin-bottom: 12px;
}
.prod-body > div { display: flex; flex-direction: column; gap: 2px; }
.prod-k { font-size: 0.7rem; color: var(--text-placeholder); text-transform: uppercase; letter-spacing: 0.04em; }
.prod-v { font-size: 0.92rem; font-weight: 600; color: var(--text-primary); }
.prod-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

/* Popup de bloqueo */
.inv-block-card {
    background: var(--surface, #fff);
    border: 1px solid var(--border, #e5e5ea);
    border-radius: 10px;
    padding: 12px 14px;
    margin-bottom: 10px;
}
.inv-block-head { font-weight: 700; color: var(--text-primary); margin-bottom: 4px; }
.inv-block-reason { font-size: 0.78rem; color: var(--text-secondary); margin-bottom: 8px; }
.muted { color: var(--text-placeholder); font-weight: 400; }

/* Login usuario / contraseña */
.login-form-fields {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 0.35rem;
    max-width: 280px;
    margin-left: auto;
    margin-right: auto;
}
.login-field {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    text-align: left;
}
.login-field-label {
    font-size: 0.72rem;
    color: var(--text-secondary, rgba(255, 255, 255, 0.65));
    letter-spacing: 0.02em;
}
.login-input {
    width: 100%;
    box-sizing: border-box;
    padding: 0.65rem 0.75rem;
    border-radius: 10px;
    border: 1px solid var(--border, rgba(255, 255, 255, 0.14));
    background: var(--surface-elevated, rgba(0, 0, 0, 0.22));
    color: var(--text-primary, #fff);
    font-size: 0.95rem;
}
html[data-theme="light"] .login-input {
    background: rgba(255, 255, 255, 0.92);
    color: #111;
    border-color: rgba(0, 0, 0, 0.12);
}
.login-submit-btn {
    margin-top: 0.35rem;
    padding: 0.72rem 1rem;
    border-radius: 10px;
    border: none;
    font-weight: 600;
    cursor: pointer;
    background: var(--accent, #0a84ff);
    color: #fff;
}
.login-submit-btn:hover {
    filter: brightness(1.06);
}
