:root {
    --ink: #171717;
    --ink-2: #242424;
    --paper: #ffffff;
    --canvas: #f3f3f1;
    --muted: #777974;
    --line: #e6e6e1;
    --accent: #ef4b32;
    --accent-soft: #fff0ed;
    --success: #18a463;
    --danger: #d84736;
    --shadow: 0 20px 60px rgba(18, 18, 16, .09);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body, button, input, select { font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
body { color: var(--ink); background: var(--canvas); }
a { color: inherit; text-decoration: none; }
button { border: 0; cursor: pointer; }

.section-kicker { color: var(--accent); font-size: .76rem; font-weight: 900; letter-spacing: .13em; }
.brand-mark { width: 72px; height: 72px; display: grid; place-items: center; border-radius: 23px; color: var(--paper); background: var(--accent); box-shadow: 0 20px 45px rgba(239, 75, 50, .28); font-size: 2rem; font-weight: 950; }
.brand-mark.small { width: 42px; height: 42px; border-radius: 14px; font-size: 1.2rem; box-shadow: none; }

/* Acceso */
.login-page { min-height: 100dvh; display: grid; place-items: center; padding: 28px; background: radial-gradient(circle at 12% 16%, rgba(239,75,50,.18), transparent 28%), linear-gradient(135deg, #eeeeeb, #fafaf8); }
.login-shell { width: min(1100px, 100%); min-height: 680px; display: grid; grid-template-columns: 1.05fr .95fr; overflow: hidden; border: 1px solid rgba(255,255,255,.85); border-radius: 38px; background: rgba(255,255,255,.92); box-shadow: 0 34px 100px rgba(0,0,0,.14); }
.login-brand { position: relative; display: flex; flex-direction: column; justify-content: center; padding: 72px; overflow: hidden; color: white; background: linear-gradient(145deg, #121212, #2b2927); }
.login-brand::before { content: ""; position: absolute; width: 380px; height: 380px; top: -210px; right: -150px; border-radius: 50%; border: 65px solid rgba(255,255,255,.05); }
.login-brand::after { content: ""; position: absolute; width: 270px; height: 270px; left: -130px; bottom: -130px; border-radius: 50%; background: rgba(239,75,50,.18); }
.login-brand > * { position: relative; z-index: 1; }
.login-brand .brand-kicker { display: block; margin-top: 34px; color: rgba(255,255,255,.55); font-size: .78rem; font-weight: 900; letter-spacing: .18em; }
.login-brand h1 { max-width: 430px; margin: 15px 0 18px; font-size: clamp(3rem, 5vw, 4.7rem); line-height: .94; letter-spacing: -.065em; }
.login-brand p { max-width: 440px; margin: 0; color: rgba(255,255,255,.66); font-size: 1.08rem; line-height: 1.55; }
.brand-note { position: absolute; left: 72px; bottom: 48px; display: flex; align-items: center; gap: 10px; color: rgba(255,255,255,.72); font-size: .9rem; font-weight: 700; }
.live-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 5px rgba(24,164,99,.14); }
.login-panel { display: grid; place-items: center; padding: 55px; }
.login-panel-inner { width: min(390px, 100%); }
.login-panel h2 { margin: 10px 0 8px; font-size: 2.4rem; letter-spacing: -.05em; }
.login-help { margin: 0 0 32px; color: var(--muted); line-height: 1.5; }
.login-panel label { display: block; margin: 20px 0 8px; font-size: .88rem; font-weight: 850; }
.login-panel input { width: 100%; min-height: 54px; padding: 0 16px; border: 1px solid var(--line); border-radius: 15px; outline: 0; background: #fafaf9; color: var(--ink); font-size: 1rem; transition: .2s; }
.login-panel input:focus { border-color: var(--ink); background: white; box-shadow: 0 0 0 4px rgba(23,23,23,.07); }
.password-field { position: relative; }
.password-field input { padding-right: 66px; }
.password-toggle { position: absolute; top: 8px; right: 8px; height: 38px; padding: 0 13px; border-radius: 10px; background: #ececea; color: #555; font-size: .8rem; font-weight: 850; }
.field-error { display: block; min-height: 17px; margin-top: 5px; color: var(--danger); font-size: .78rem; }
.login-error { margin-bottom: 18px; padding: 13px 15px; border: 1px solid #f0c4bd; border-radius: 13px; background: #fff2f0; color: #a62f20; font-size: .9rem; font-weight: 750; }
.login-submit { width: 100%; min-height: 56px; margin-top: 22px; padding: 0 18px; display: flex; align-items: center; justify-content: space-between; border-radius: 16px; background: var(--accent); color: white; font-size: 1rem; font-weight: 900; box-shadow: 0 16px 34px rgba(239,75,50,.25); }
.login-submit:hover { background: #de3e28; transform: translateY(-1px); }
.security-copy { display: block; margin-top: 22px; color: #9a9a95; text-align: center; }

/* Panel */
.dashboard-page { min-height: 100dvh; display: grid; grid-template-columns: 248px minmax(0, 1fr); }
.dashboard-sidebar { position: sticky; top: 0; height: 100dvh; display: flex; flex-direction: column; padding: 28px 22px; color: white; background: var(--ink); }
.sidebar-brand { display: flex; align-items: center; gap: 13px; font-size: .9rem; letter-spacing: .08em; }
.sidebar-brand span:last-child { display: grid; }
.sidebar-brand strong { font-size: .66rem; color: rgba(255,255,255,.48); letter-spacing: .18em; }
.sidebar-nav { margin-top: 54px; }
.sidebar-nav a { display: flex; align-items: center; gap: 13px; padding: 14px; border-radius: 14px; color: rgba(255,255,255,.63); font-weight: 750; }
.sidebar-nav a.active { color: white; background: rgba(255,255,255,.10); }
.sidebar-nav a span { width: 24px; font-size: 1.25rem; }
.mobile-nav-toggle { display: none; }
.sidebar-bottom { margin-top: auto; }
.sidebar-user { display: flex; gap: 11px; align-items: center; padding: 14px 0; border-top: 1px solid rgba(255,255,255,.1); }
.sidebar-user > span { width: 38px; height: 38px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 12px; background: rgba(255,255,255,.11); font-weight: 900; }
.sidebar-user div { display: grid; min-width: 0; }
.sidebar-user strong { overflow: hidden; font-size: .86rem; text-overflow: ellipsis; }
.sidebar-user small { margin-top: 2px; color: rgba(255,255,255,.45); }
.logout-button { width: 100%; padding: 11px; border-radius: 11px; background: rgba(255,255,255,.07); color: rgba(255,255,255,.7); font-weight: 750; }
.dashboard-main { min-width: 0; padding: 40px clamp(24px, 4vw, 62px) 28px; }
.dashboard-header { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; }
.dashboard-header h1 { margin: 4px 0 3px; font-size: clamp(2.4rem, 4vw, 4rem); line-height: 1; letter-spacing: -.065em; }
.dashboard-header p { margin: 0; color: var(--muted); font-size: .92rem; }
.refresh-button { display: flex; align-items: center; gap: 8px; min-height: 43px; padding: 0 16px; border: 1px solid var(--line); border-radius: 13px; background: white; color: var(--ink); font-weight: 800; }
.refresh-button.loading span { animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.filter-panel { margin-top: 28px; display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 10px; border: 1px solid var(--line); border-radius: 18px; background: rgba(255,255,255,.75); }
.quick-filters { display: flex; flex-wrap: wrap; gap: 5px; }
.quick-filters a, .quick-filters button { min-height: 40px; display: grid; place-items: center; padding: 0 14px; border-radius: 11px; background: transparent; color: #62645f; font-size: .86rem; font-weight: 850; }
.quick-filters .active { background: var(--ink); color: white; }
.store-filter { margin-left: auto; display: flex; align-items: center; gap: 9px; }
.store-filter label { color: var(--muted); font-size: .78rem; font-weight: 850; }
.store-filter select { min-height: 40px; padding: 0 35px 0 12px; border: 1px solid var(--line); border-radius: 11px; background: white; color: var(--ink); font-weight: 750; }
.custom-filter { width: 100%; display: none; align-items: flex-end; gap: 10px; padding: 12px 4px 3px; border-top: 1px solid var(--line); }
.custom-filter.visible { display: flex; }
.custom-filter label { display: grid; gap: 6px; color: var(--muted); font-size: .76rem; font-weight: 800; }
.custom-filter input { min-height: 42px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px; background: white; }
.custom-filter button { min-height: 42px; padding: 0 17px; border-radius: 10px; background: var(--accent); color: white; font-weight: 850; }
.hero-metrics { margin-top: 22px; display: grid; grid-template-columns: 1.35fr 1fr 1fr; gap: 16px; }
.metric-card, .store-card, .panel { border: 1px solid var(--line); border-radius: 22px; background: white; box-shadow: 0 12px 34px rgba(20,20,18,.045); }
.metric-card { min-height: 180px; padding: 23px; display: flex; flex-direction: column; }
.total-card { color: white; border-color: var(--ink); background: linear-gradient(145deg, #171717, #2c2b29); box-shadow: var(--shadow); }
.metric-heading { display: flex; justify-content: space-between; align-items: center; color: #787a75; font-size: .84rem; font-weight: 800; }
.total-card .metric-heading { color: rgba(255,255,255,.58); }
.metric-icon { width: 35px; height: 35px; display: grid; place-items: center; border-radius: 11px; background: var(--accent); color: white; font-weight: 900; }
.metric-icon.dark { background: #f0f0ed; color: var(--ink); }
.metric-card > strong { margin-top: 19px; font-size: clamp(2rem, 3.2vw, 3.25rem); line-height: 1; letter-spacing: -.055em; white-space: nowrap; }
.metric-footer { min-height: 24px; margin-top: auto; display: flex; align-items: center; gap: 8px; color: #969792; }
.metric-footer small { font-size: .76rem; }
.trend { display: inline-flex; align-items: center; padding: 4px 8px; border-radius: 999px; font-size: .73rem; font-weight: 900; }
.trend.positive { color: #087947; background: #dff5e9; }
.trend.negative { color: #b63324; background: #fde8e4; }
.trend.neutral { color: #70716d; background: #eeeeeb; }
.store-grid { margin-top: 16px; display: grid; grid-template-columns: repeat(4, minmax(230px, 1fr)); gap: 16px; }
.store-card { padding: 20px; }
.store-card-header { display: flex; justify-content: space-between; gap: 10px; }
.store-card-header > div { display: flex; align-items: center; gap: 10px; min-width: 0; }
.store-number { width: 31px; height: 31px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 10px; color: var(--accent); background: var(--accent-soft); font-size: .75rem; font-weight: 950; }
.store-card h2 { margin: 0; overflow: hidden; font-size: .93rem; white-space: nowrap; text-overflow: ellipsis; }
.connection-state { display: flex; align-items: center; gap: 6px; color: #a26721; font-size: .65rem; font-weight: 850; white-space: nowrap; }
.connection-state i { width: 7px; height: 7px; border-radius: 50%; background: #e5a84e; }
.connection-state.online { color: #117849; }
.connection-state.online i { background: var(--success); }
.store-total { margin-top: 22px; display: flex; justify-content: space-between; align-items: flex-end; gap: 8px; }
.store-total > strong { font-size: 1.8rem; letter-spacing: -.045em; white-space: nowrap; }
.store-stats { margin-top: 18px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.store-stats span { padding: 10px; display: grid; gap: 3px; border-radius: 11px; background: #f7f7f5; }
.store-stats small { color: var(--muted); font-size: .66rem; }
.store-stats strong { font-size: .9rem; }
.payment-pills { margin-top: 11px; display: grid; gap: 5px; }
.payment-pills span { display: flex; justify-content: space-between; color: var(--muted); font-size: .72rem; }
.payment-pills strong { color: #42433f; }
.last-sale { margin-top: 15px; padding-top: 12px; border-top: 1px solid var(--line); color: #969792; font-size: .68rem; }
.last-sale strong { color: #61625e; }
.analytics-grid { margin-top: 16px; display: grid; grid-template-columns: 1.65fr .85fr; gap: 16px; }
.bottom-grid { margin-top: 16px; display: grid; grid-template-columns: .9fr 1.4fr; gap: 16px; }
.panel { min-width: 0; padding: 22px; }
.panel-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.panel-header h2 { margin: 4px 0 0; font-size: 1.25rem; letter-spacing: -.035em; }
.panel-header > span { color: var(--muted); font-size: .78rem; font-weight: 750; }
.bar-chart { height: 250px; margin-top: 24px; display: flex; align-items: stretch; gap: clamp(6px, 1vw, 14px); overflow-x: auto; }
.bar-column { min-width: 38px; flex: 1; display: grid; grid-template-rows: 22px 1fr 24px; text-align: center; }
.bar-column > span { color: #7c7d78; font-size: .62rem; font-weight: 800; opacity: 0; transition: .2s; }
.bar-column:hover > span { opacity: 1; }
.bar-column > div { min-height: 150px; display: flex; align-items: flex-end; justify-content: center; }
.bar-column i { width: min(30px, 72%); min-height: 4px; border-radius: 7px 7px 3px 3px; background: linear-gradient(180deg, var(--accent), #ff846e); transition: height .4s ease; }
.bar-column small { padding-top: 8px; color: #8d8e89; font-size: .65rem; white-space: nowrap; }
.payment-list, .product-list { margin-top: 22px; display: grid; gap: 19px; }
.payment-row > div:first-child, .product-data > div:first-child { display: flex; justify-content: space-between; gap: 10px; font-size: .82rem; }
.payment-row span, .product-data span { color: var(--muted); }
.progress { height: 7px; margin-top: 9px; overflow: hidden; border-radius: 999px; background: #eeeeeb; }
.progress i { display: block; height: 100%; border-radius: inherit; background: var(--accent); }
.payment-row small, .product-data small { display: block; margin-top: 5px; color: #9a9b96; font-size: .65rem; }
.product-row { display: flex; align-items: flex-start; gap: 11px; }
.rank { width: 28px; height: 28px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 9px; background: var(--ink); color: white; font-size: .7rem; font-weight: 900; }
.product-data { min-width: 0; flex: 1; }
.product-data strong { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.table-wrap { margin-top: 16px; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .77rem; }
th { padding: 9px 10px; color: #969792; text-align: left; font-size: .65rem; letter-spacing: .06em; text-transform: uppercase; }
td { padding: 11px 10px; border-top: 1px solid #eeeeeb; color: #5e5f5b; white-space: nowrap; }
td:last-child, th:last-child { text-align: right; }
td strong { color: var(--ink); }
.empty-state { min-height: 220px; display: grid; place-items: center; color: #969792; text-align: center; }
.empty-state.compact { min-height: 90px; }
.dashboard-footer { padding: 24px 0 4px; color: #999a95; font-size: .72rem; text-align: center; }
.status-page { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.status-card { width: min(520px, 100%); padding: 44px; border-radius: 26px; background: white; box-shadow: var(--shadow); text-align: center; }
.status-icon { width: 50px; height: 50px; margin: 0 auto 20px; display: grid; place-items: center; border-radius: 16px; background: var(--accent-soft); color: var(--accent); font-size: 1.4rem; font-weight: 950; }
.status-card h1 { margin: 8px 0 10px; font-size: 2rem; letter-spacing: -.05em; }
.status-card p { color: var(--muted); line-height: 1.55; }
.status-card a { display: inline-flex; margin-top: 12px; padding: 12px 17px; border-radius: 12px; background: var(--ink); color: white; font-weight: 850; }

/* Auditoría */
.audit-list { margin-top: 20px; display: grid; gap: 14px; }
.audit-card { padding: 21px 23px; border: 1px solid var(--line); border-radius: 21px; background: white; box-shadow: 0 12px 34px rgba(20,20,18,.045); }
.audit-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.audit-store { color: var(--accent); font-size: .72rem; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; }
.audit-card h2 { margin: 3px 0 5px; font-size: 1.22rem; letter-spacing: -.035em; }
.audit-card small { color: var(--muted); font-size: .76rem; }
.audit-revision { padding: 7px 10px; border-radius: 10px; background: #f2f2ef; color: #555650; font-size: .72rem; font-weight: 850; white-space: nowrap; }
.audit-summary { margin: 18px 0 11px; font-size: 1rem; font-weight: 850; }
.audit-tags { display: flex; flex-wrap: wrap; gap: 7px; }
.audit-tags span { padding: 6px 9px; border-radius: 999px; background: #f2f2ef; color: #555650; font-size: .73rem; font-weight: 800; }
.audit-tags span.added { color: #087947; background: #dff5e9; }
.audit-tags span.removed { color: #b63324; background: #fde8e4; }
.audit-total { margin-top: 15px; padding-top: 13px; border-top: 1px solid var(--line); color: var(--muted); font-size: .8rem; }
.audit-total strong { color: var(--ink); }
.audit-details { margin-top: 13px; color: #63645f; font-size: .8rem; }
.audit-details summary { cursor: pointer; color: var(--ink); font-weight: 850; }
.audit-details ul { margin: 10px 0 0; padding-left: 19px; display: grid; gap: 5px; }
.audit-details li strong { color: var(--accent); font-size: .7rem; }
.audit-empty { min-height: 330px; border: 1px solid var(--line); border-radius: 22px; background: white; }

@media (max-width: 1260px) {
    .store-grid { grid-template-columns: repeat(2, minmax(240px, 1fr)); }
}
@media (max-width: 980px) {
    .dashboard-page { grid-template-columns: 76px minmax(0, 1fr); }
    .dashboard-sidebar { padding: 22px 14px; align-items: center; }
    .sidebar-brand span:last-child, .sidebar-nav a:not(.active) { display: none; }
    .sidebar-nav a { justify-content: center; padding: 13px; }
    .sidebar-nav a.active { font-size: 0; }
    .sidebar-nav a.active span { font-size: 1.25rem; text-align: center; }
    .sidebar-user div, .logout-button { display: none; }
    .hero-metrics, .analytics-grid, .bottom-grid { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
    .login-page { padding: 0; }
    .login-shell { min-height: 100dvh; grid-template-columns: 1fr; border-radius: 0; }
    .login-brand { min-height: 300px; padding: 38px; }
    .login-brand h1 { font-size: 2.9rem; }
    .login-brand p { font-size: .96rem; }
    .brand-note { position: static; margin-top: 32px; }
    .login-panel { padding: 40px 28px; }
    .dashboard-page { display: block; }
    .dashboard-sidebar { position: static; width: 100%; height: 68px; flex-direction: row; justify-content: space-between; padding: 13px 18px; }
    .sidebar-brand span:last-child, .sidebar-user div, .logout-button { display: grid; }
    .mobile-nav-toggle { width: 39px; height: 39px; display: grid; place-items: center; margin-left: auto; margin-right: 9px; border-radius: 11px; background: rgba(255,255,255,.12); color: white; font-size: 1.2rem; }
    .sidebar-nav { position: absolute; z-index: 5; top: 60px; right: 16px; left: 16px; display: none; margin: 0; padding: 8px; border: 1px solid rgba(255,255,255,.12); border-radius: 15px; background: #252525; box-shadow: 0 18px 40px rgba(0,0,0,.25); }
    .sidebar-nav.open { display: grid; }
    .sidebar-nav a, .sidebar-nav a.active { justify-content: flex-start; padding: 12px; font-size: .88rem; }
    .sidebar-nav a:not(.active), .sidebar-nav a.active { display: flex; }
    .sidebar-nav a.active { font-size: .88rem; }
    .sidebar-nav a.active span { font-size: 1.25rem; text-align: left; }
    .sidebar-bottom { margin: 0; display: flex; align-items: center; gap: 8px; }
    .sidebar-user { padding: 0; border: 0; }
    .sidebar-user > span { display: none; }
    .logout-button { width: auto; padding: 10px; font-size: .7rem; }
    .dashboard-main { padding: 25px 16px; }
    .dashboard-header { align-items: center; }
    .dashboard-header h1 { font-size: 2.7rem; }
    .dashboard-header p { font-size: .75rem; }
    .refresh-button { width: 43px; padding: 0; justify-content: center; font-size: 0; }
    .refresh-button span { font-size: 1.2rem; }
    .filter-panel { align-items: stretch; }
    .quick-filters { width: 100%; display: grid; grid-template-columns: repeat(2, 1fr); }
    .store-filter { width: 100%; margin-left: 0; justify-content: space-between; }
    .store-filter select { flex: 1; }
    .custom-filter { flex-wrap: wrap; }
    .custom-filter label { flex: 1; }
    .custom-filter input { width: 100%; }
    .hero-metrics, .store-grid { grid-template-columns: 1fr; }
    .metric-card { min-height: 155px; }
    .store-card-header { flex-wrap: wrap; }
    .bar-chart { height: 230px; }
    .panel { padding: 18px; border-radius: 18px; }
    .audit-card { padding: 18px; border-radius: 18px; }
    .audit-card-head { flex-direction: column; gap: 8px; }
}

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

/* Desglose de cobros: no sustituye ni duplica el total del ticket. */
.payment-breakdown { display:block; margin-top:5px; font-size:11px; line-height:1.45; opacity:.75; white-space:nowrap; }
.audit-payment-detail { display:flex; flex-wrap:wrap; gap:8px 24px; margin:12px 0; font-size:13px; line-height:1.6; }
