:root {
    --bg: #0c0f14;
    --bg2: #12161e;
    --bg3: #1a1f2b;
    --card: #161b26;
    --card-hover: #1c2233;
    --border: #252d3d;
    --border-light: #2e3850;
    --fg: #e8ecf4;
    --fg-muted: #8892a6;
    --fg-dim: #5a6478;
    --accent: #00d68f;
    --accent-dim: rgba(0, 214, 143, 0.12);
    --accent-glow: rgba(0, 214, 143, 0.25);
    --red: #ff4d6a;
    --red-dim: rgba(255, 77, 106, 0.12);
    --orange: #ffaa2c;
    --orange-dim: rgba(255, 170, 44, 0.12);
    --blue: #3d9eff;
    --blue-dim: rgba(61, 158, 255, 0.12);
    --purple: #a78bfa;
    --purple-dim: rgba(167, 139, 250, 0.12);
    --cyan: #22d3ee;
    --cyan-dim: rgba(34, 211, 238, 0.12);
    --radius: 10px;
    --radius-sm: 6px;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: "Space Grotesk", sans-serif;
    background: var(--bg);
    color: var(--fg);
    min-height: 100vh;
    overflow-x: hidden;
}

body::before {
    content: "";
    position: fixed;
    top: -30%;
    left: -10%;
    width: 60%;
    height: 60%;
    background: radial-gradient(
        ellipse,
        rgba(0, 214, 143, 0.04) 0%,
        transparent 70%
    );
    pointer-events: none;
    z-index: 0;
}

body::after {
    content: "";
    position: fixed;
    bottom: -20%;
    right: -10%;
    width: 50%;
    height: 50%;
    background: radial-gradient(
        ellipse,
        rgba(61, 158, 255, 0.03) 0%,
        transparent 70%
    );
    pointer-events: none;
    z-index: 0;
}

/* ── App ── */
.app {
    position: relative;
    z-index: 1;
    max-width: 1480px;
    margin: 0 auto;
    padding: 20px 24px 60px;
}

/* ── Header ── */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 0 28px;
    flex-wrap: wrap;
    gap: 16px;
    position: relative;
    z-index: 50;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 14px;
}

.logo-icon {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, var(--accent), #00b87a);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: #0c0f14;
    box-shadow: 0 0 20px var(--accent-glow);
}

.logo-icon-lg {
    width: 56px;
    height: 56px;
    font-size: 24px;
}

.header-title {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.header-sub {
    font-size: 12px;
    color: var(--fg-muted);
    margin-top: 1px;
}

.header-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--card);
    color: var(--fg);
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.btn:hover {
    background: var(--card-hover);
    border-color: var(--border-light);
    transform: translateY(-1px);
}

.btn:disabled {
    opacity: 0.5;
    pointer-events: none;
}

.btn-primary {
    background: var(--accent);
    color: #0c0f14;
    border-color: var(--accent);
    font-weight: 600;
}

.btn-primary:hover {
    background: #00e89c;
    border-color: #00e89c;
    box-shadow: 0 0 20px var(--accent-glow);
}

.btn-danger {
    color: var(--red);
    border-color: rgba(255, 77, 106, 0.25);
}

.btn-danger:hover {
    background: var(--red-dim);
    border-color: var(--red);
}

.btn-sm {
    padding: 9px 16px;
    font-size: 12px;
}

.btn .spinner {
    width: 14px;
    height: 14px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    display: none;
}

.btn.loading .spinner {
    display: inline-block;
}

.btn.loading .btn-text {
    opacity: 0;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ── Tabs ── */
.tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 20px;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 4px;
    width: fit-content;
}

.tab {
    padding: 9px 20px;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--fg-muted);
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.tab:hover {
    color: var(--fg);
    background: var(--bg3);
}

.tab.active {
    background: var(--accent);
    color: #0c0f14;
    font-weight: 600;
}

.tab .badge {
    font-size: 10px;
    padding: 1px 7px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.15);
    font-weight: 600;
}

.tab:not(.active) .badge {
    background: var(--bg3);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* ── KPI Cards ── */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(185px, 1fr));
    gap: 12px;
    margin-bottom: 22px;
}

.kpi-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 18px;
    position: relative;
    overflow: hidden;
    transition: all 0.25s;
}

.kpi-card:hover {
    border-color: var(--border-light);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.kpi-card::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
}

.kpi-card.green::before {
    background: var(--accent);
}
.kpi-card.blue::before {
    background: var(--blue);
}
.kpi-card.orange::before {
    background: var(--orange);
}
.kpi-card.red::before {
    background: var(--red);
}
.kpi-card.purple::before {
    background: var(--purple);
}
.kpi-card.cyan::before {
    background: var(--cyan);
}

.kpi-label {
    font-size: 10.5px;
    font-weight: 500;
    color: var(--fg-muted);
    text-transform: uppercase;
    letter-spacing: 0.7px;
    margin-bottom: 7px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.kpi-label i {
    font-size: 11px;
}

.kpi-card.green .kpi-label i {
    color: var(--accent);
}
.kpi-card.blue .kpi-label i {
    color: var(--blue);
}
.kpi-card.orange .kpi-label i {
    color: var(--orange);
}
.kpi-card.red .kpi-label i {
    color: var(--red);
}
.kpi-card.purple .kpi-label i {
    color: var(--purple);
}
.kpi-card.cyan .kpi-label i {
    color: var(--cyan);
}

.kpi-value {
    font-family: "JetBrains Mono", monospace;
    font-size: 22px;
    font-weight: 600;
    letter-spacing: -0.5px;
}

.kpi-card.green .kpi-value {
    color: var(--accent);
}
.kpi-card.blue .kpi-value {
    color: var(--blue);
}
.kpi-card.orange .kpi-value {
    color: var(--orange);
}
.kpi-card.red .kpi-value {
    color: var(--red);
}
.kpi-card.purple .kpi-value {
    color: var(--purple);
}
.kpi-card.cyan .kpi-value {
    color: var(--cyan);
}

.kpi-sub {
    font-size: 11px;
    color: var(--fg-dim);
    margin-top: 3px;
    font-family: "JetBrains Mono", monospace;
}

.kpi-skeleton {
    background: var(--bg3);
    border-radius: 4px;
    height: 22px;
    width: 80px;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%,
    100% {
        opacity: 0.4;
    }
    50% {
        opacity: 0.8;
    }
}

/* ── Charts ── */
.charts-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    margin-bottom: 22px;
}

.chart-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
}

.chart-title {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.chart-title i {
    color: var(--accent);
    font-size: 13px;
}

.chart-wrap {
    position: relative;
    height: 210px;
}

/* ── Toolbar ── */
.toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
    flex-wrap: wrap;
    padding: 16px;
}

.search-box {
    position: relative;
    flex: 1;
    min-width: 200px;
    max-width: 340px;
}

.search-box i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--fg-dim);
    font-size: 13px;
}

.search-box input {
    width: 100%;
    padding: 9px 12px 9px 36px;
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--fg);
    font-family: inherit;
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s;
}

.search-box input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
}

.search-box input::placeholder {
    color: var(--fg-dim);
}

.filter-select {
    padding: 9px 14px;
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--fg);
    font-family: inherit;
    font-size: 13px;
    outline: none;
    cursor: pointer;
}

.filter-select:focus {
    border-color: var(--accent);
}

.filter-select option {
    background: var(--bg2);
}

.toolbar-info {
    margin-left: auto;
    font-size: 12px;
    color: var(--fg-dim);
}

/* ── Table ── */
.table-container {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.table-scroll {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 1020px;
}

thead {
    background: var(--bg2);
    position: sticky;
    top: 0;
    z-index: 2;
}

thead th {
    padding: 11px 12px;
    text-align: left;
    font-size: 10.5px;
    font-weight: 600;
    color: var(--fg-muted);
    text-transform: uppercase;
    letter-spacing: 0.7px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
    transition: color 0.2s;
}

thead th:hover {
    color: var(--fg);
}

thead th .sort-icon {
    margin-left: 4px;
    font-size: 10px;
    opacity: 0.4;
}

thead th.sorted .sort-icon {
    opacity: 1;
    color: var(--accent);
}

tbody tr {
    border-bottom: 1px solid var(--border);
    transition: background 0.15s;
}

tbody tr:hover {
    background: var(--card-hover);
}

tbody tr:last-child {
    border-bottom: none;
}

tbody tr.low-stock {
    background: rgba(255, 77, 106, 0.04);
}

tbody tr.low-stock:hover {
    background: rgba(255, 77, 106, 0.08);
}

td {
    padding: 9px 12px;
    font-size: 13px;
    vertical-align: middle;
}

td.editable {
    cursor: text;
}

td.editable:hover {
    background: rgba(0, 214, 143, 0.04);
}

td.edit-cell {
    padding: 4px 6px;
}

td.edit-cell input {
    width: 100%;
    padding: 6px 8px;
    background: var(--bg);
    border: 1px solid var(--accent);
    border-radius: 4px;
    color: var(--fg);
    font-family: "JetBrains Mono", monospace;
    font-size: 13px;
    outline: none;
    box-shadow: 0 0 0 3px var(--accent-dim);
}

.product-name {
    font-weight: 600;
    color: var(--fg);
}

.product-sku {
    font-family: "JetBrains Mono", monospace;
    font-size: 11px;
    color: var(--fg-dim);
    margin-top: 2px;
}

.category-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 500;
    background: var(--blue-dim);
    color: var(--blue);
}

.money {
    font-family: "JetBrains Mono", monospace;
    font-weight: 500;
}

.money.positive {
    color: var(--accent);
}
.money.negative {
    color: var(--red);
}

.margin-bar {
    display: flex;
    align-items: center;
    gap: 8px;
}

.margin-track {
    width: 46px;
    height: 5px;
    background: var(--bg);
    border-radius: 10px;
    overflow: hidden;
}

.margin-fill {
    height: 100%;
    border-radius: 10px;
    transition: width 0.4s ease;
}

.margin-fill.high {
    background: var(--accent);
}
.margin-fill.mid {
    background: var(--orange);
}
.margin-fill.low {
    background: var(--red);
}

.margin-text {
    font-family: "JetBrains Mono", monospace;
    font-size: 11.5px;
    font-weight: 500;
    min-width: 38px;
}

.stock-num {
    font-family: "JetBrains Mono", monospace;
    font-weight: 600;
}

.stock-low {
    color: var(--red);
}
.stock-ok {
    color: var(--accent);
}
.stock-mid {
    color: var(--orange);
}

.actions-cell {
    display: flex;
    gap: 3px;
    justify-content: center;
}

.action-btn {
    width: 29px;
    height: 29px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--fg-dim);
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s;
}

.action-btn:hover {
    background: var(--bg3);
    color: var(--fg);
}

.action-btn:disabled {
    opacity: 0.2;
    pointer-events: none;
}

.action-btn.delete:hover {
    background: var(--red-dim);
    color: var(--red);
}

.action-btn.sell:hover {
    background: var(--blue-dim);
    color: var(--blue);
}

.empty-state {
    text-align: center;
    padding: 50px 20px;
}

.empty-icon {
    font-size: 44px;
    color: var(--fg-dim);
    margin-bottom: 14px;
    opacity: 0.4;
}

.empty-title {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 6px;
}

.empty-desc {
    font-size: 13px;
    color: var(--fg-muted);
    margin-bottom: 18px;
}

.table-loading {
    display: flex;
    justify-content: center;
    padding: 40px;
}

.spinner-lg {
    width: 28px;
    height: 28px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* ── Movements ── */
.mov-type {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
}

.mov-type.venta {
    background: var(--accent-dim);
    color: var(--accent);
}
.mov-type.entrada {
    background: var(--blue-dim);
    color: var(--blue);
}
.mov-type.merma {
    background: var(--red-dim);
    color: var(--red);
}
.mov-type.ajuste {
    background: var(--orange-dim);
    color: var(--orange);
}
.mov-type.devolucion {
    background: var(--purple-dim);
    color: var(--purple);
}

.mov-qty {
    font-family: "JetBrains Mono", monospace;
    font-weight: 600;
}

.mov-qty.out {
    color: var(--red);
}
.mov-qty.in {
    color: var(--accent);
}

.mov-type.traslado {
    background: var(--orange-dim);
    color: var(--orange);
}

.sales-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 10px;
    margin-bottom: 18px;
}

.sale-stat {
    background: var(--bg3);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
}

.sale-stat-label {
    font-size: 10px;
    color: var(--fg-dim);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    margin-bottom: 5px;
}

.sale-stat-value {
    font-family: "JetBrains Mono", monospace;
    font-size: 18px;
    font-weight: 600;
}

/* ── Admin ── */
.admin-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 10px;
    margin-bottom: 18px;
}

.admin-stat {
    background: var(--bg3);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
}

.admin-stat-label {
    font-size: 10px;
    color: var(--fg-dim);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    margin-bottom: 5px;
}

.admin-stat-value {
    font-family: "JetBrains Mono", monospace;
    font-size: 20px;
    font-weight: 600;
}

.admin-subnav {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 3px;
    width: fit-content;
}

.admin-subnav-btn {
    padding: 7px 18px;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: var(--fg-muted);
    font-family: inherit;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.admin-subnav-btn:hover {
    color: var(--fg);
}

.admin-subnav-btn.active {
    background: var(--accent);
    color: #0c0f14;
    font-weight: 600;
}

.admin-content {
    display: none;
}

.admin-content.active {
    display: block;
}

.role-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
}

.role-badge.admin {
    background: var(--red-dim);
    color: var(--red);
}
.role-badge.vendedor {
    background: var(--blue-dim);
    color: var(--blue);
}
.role-badge.default {
    background: var(--bg3);
    color: var(--fg-dim);
}

.perm-group {
    margin-bottom: 14px;
}

.perm-group-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--fg-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--border);
}

.perm-grid {
    display: grid;
    gap: 8px;
}

.perm-item {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 5px 0;
    cursor: pointer;
}

.perm-item input[type="checkbox"] {
    accent-color: var(--accent);
    width: 15px;
    height: 15px;
    cursor: pointer;
}

.perm-item label {
    font-size: 12px;
    color: var(--fg-muted);
    cursor: pointer;
    user-select: none;
}

.perm-count {
    font-family: "JetBrains Mono", monospace;
    font-size: 11px;
    color: var(--fg-dim);
}

/* ── Pagination ── */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
    padding: 16px;
    border-top: 1px solid var(--border);
}

.page-btn {
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--fg-muted);
    font-family: inherit;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.page-btn:hover {
    background: var(--bg3);
    color: var(--fg);
}

.page-btn.active {
    background: var(--accent);
    color: #0c0f14;
    border-color: var(--accent);
    font-weight: 600;
}

.page-btn:disabled {
    opacity: 0.3;
    pointer-events: none;
}

.page-info {
    font-size: 12px;
    color: var(--fg-dim);
    margin: 0 8px;
}

/* ── Modal ── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.modal {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 14px;
    width: 100%;
    max-width: 520px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    transform: translateY(20px) scale(0.97);
    transition: transform 0.25s;
}

.modal.modal-lg {
    max-width: 600px;
}

.modal-overlay.active .modal {
    transform: translateY(0) scale(1);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px 0;
}

.modal-title {
    font-size: 17px;
    font-weight: 700;
}

.modal-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--fg-muted);
    cursor: pointer;
    font-size: 16px;
    transition: all 0.2s;
}

.modal-close:hover {
    background: var(--bg3);
    color: var(--fg);
}

.modal-body {
    padding: 20px 24px;
}

.modal-footer {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    padding: 0 24px 20px;
}

/* ── Forms ── */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

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

.form-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--fg-muted);
}

.form-input {
    padding: 10px 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--fg);
    font-family: inherit;
    font-size: 13px;
    outline: none;
    transition: all 0.2s;
}

.form-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
}

.form-input::placeholder {
    color: var(--fg-dim);
}

.form-input.error {
    border-color: var(--red);
    box-shadow: 0 0 0 3px var(--red-dim);
}

.form-hint {
    font-size: 11px;
    color: var(--fg-dim);
    margin-top: 2px;
}

.form-error {
    font-size: 11px;
    color: var(--red);
    margin-top: 2px;
}

.mov-preview {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    margin-top: 6px;
}

.mov-preview-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0;
    font-size: 13px;
}

.mov-preview-row .label {
    color: var(--fg-muted);
}

.mov-preview-row .value {
    font-family: "JetBrains Mono", monospace;
    font-weight: 500;
}

/* ── Login ── */
.login-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 1;
}

.login-card {
    width: 100%;
    max-width: 400px;
    padding: 20px;
}

.login-error {
    display: none;
    font-size: 12px;
    color: var(--red);
    background: var(--red-dim);
    padding: 10px 12px;
    border-radius: var(--radius-sm);
}

/* ── Toast ── */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 12px 18px;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
    animation: toastIn 0.3s ease;
    min-width: 260px;
}

.toast.success {
    border-left: 3px solid var(--accent);
}

.toast.success i {
    color: var(--accent);
}

.toast.error {
    border-left: 3px solid var(--red);
}

.toast.error i {
    color: var(--red);
}

.toast.warning {
    border-left: 3px solid var(--orange);
}

.toast.warning i {
    color: var(--orange);
}

.toast-exit {
    animation: toastOut 0.3s ease forwards;
}

/* ── POS Layout ── */
/* ── POS LAYOUT DESKTOP (mejorado) ── */
.pos-container {
    display: grid;
    grid-template-columns: 1fr 360px;
    gap: 20px;
    align-items: start;
}

@media (max-width: 900px) {
    .pos-container {
        grid-template-columns: 1fr;
        gap: 0;
        align-items: normal;
    }
}

/* Catálogo - ocupa toda la altura disponible */
/* Catálogo - solo para desktop */
.pos-catalog {
    display: flex;
    flex-direction: column;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    min-height: 900px; /* Solo desktop */
}

/* En móvil, que sea auto */
@media (max-width: 900px) {
    .pos-catalog {
        min-height: auto;
        height: auto;
    }
}

/* Grid de productos - sin scroll interno, que crezca y muestre todo */
.pos-grid {
    flex: 1;
    overflow-y: auto; /* Scroll solo si hay muchos productos */
    padding: 16px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
    align-content: start;
}

/* Carrito - STICKY (siempre visible) */
/* ── POS CART - DESKTOP ── */
.pos-cart {
    position: sticky;
    top: 20px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    height: fit-content;
    max-height: calc(100vh - 40px);
}

/* ── MÓVIL ── */
@media (max-width: 900px) {
    .pos-cart {
        position: sticky;
        bottom: 0;
        top: auto; /* Anular el top de desktop */
        height: auto;
        max-height: 60px; /* Altura minimizada por defecto */
        min-height: auto; /* Anular min-height */
        border-radius: var(--radius) var(--radius) 0 0;
    }

    .pos-cart.expanded {
        max-height: 70vh;
    }

    .pos-cart .pos-cart-body {
        overflow-y: auto;
        max-height: calc(70vh - 60px);
        padding: 12px;
    }

    .pos-cart:not(.expanded) .pos-cart-body {
        display: none;
    }
}

/* Cuerpo del carrito - scrollable si hay muchos items */
.pos-cart-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.pos-cart-items {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

/* Footer del carrito siempre visible */
.pos-cart-footer {
    flex-shrink: 0;
    padding: 16px;
    border-top: 1px solid var(--border);
    background: var(--bg2);
}

/* Header del carrito siempre visible */
.pos-cart-header {
    flex-shrink: 0;
    padding: 16px;
    border-bottom: 1px solid var(--border);
    background: var(--bg2);
}

/* ── BARRA SUPERIOR DEL POS ── */
.pos-top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
    padding: 12px 16px;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    flex-wrap: wrap;
    flex-shrink: 0;
}

/* Contenedor principal del contenido */
#contentPos {
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* Ajuste global para que todo el contenido ocupe altura completa */
.app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    padding: 20px 24px 20px;
}

/* El contenido de la pestaña activa debe poder crecer */
.tab-content.active {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.pos-product-card {
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.pos-product-card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.pos-p-name {
    font-weight: 600;
    font-size: 13px;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.pos-p-stock {
    font-size: 11px;
    color: var(--fg-dim);
}

.pos-p-price {
    font-family: "JetBrains Mono", monospace;
    font-weight: 600;
    color: var(--accent);
    margin-top: auto;
}

/* ── HEADER MÓVIL ── */
.pos-cart-header-mobile {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    cursor: pointer;
    background: var(--bg2);
    border-bottom: 1px solid var(--border);
    user-select: none;
    flex-wrap: nowrap;
}

.pos-cart-header-mobile .pos-cart-header-left,
.pos-cart-header-mobile .pos-cart-header-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: nowrap;
}

.pos-cart-header-mobile .cart-item-count {
    background: var(--accent);
    color: #000;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 20px;
    margin-left: 6px;
    white-space: nowrap;
}

.pos-cart-header-mobile #cartTotalPreview {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 600;
    color: var(--accent);
    white-space: nowrap;
}

.pos-cart-header-mobile #cartToggleIcon {
    transition: transform 0.2s;
}

.pos-cart.expanded #cartToggleIcon {
    transform: rotate(180deg);
}

/* Carrito - Desktop (normal) */
.pos-cart {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    height: auto;
    max-height: none;
}
/* ── BOTÓN FLOTANTE DE ESCÁNER (solo móvil) ── */
.pos-scan-fab {
    display: none; /* Oculto por defecto en desktop */
}

.pos-scan-btn {
    display: flex;
    width: 44px;
    height: 44px;
    min-width: 44px;
    flex-shrink: 0;
    border-radius: var(--radius-sm);
    background: var(--bg3);
    border: 1px solid var(--border);
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--fg-muted);
    font-size: 18px;
    transition: all 0.2s;
}

.pos-scan-btn:hover {
    background: var(--card-hover);
    color: var(--accent);
    border-color: var(--accent);
}


.pos-cart-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.pos-cart-header {
    padding: 16px;
    border-bottom: 1px solid var(--border);
    background: var(--bg2);
}

.pos-cart-title {
    font-size: 16px;
    font-weight: 700;
}

.pos-cart-date {
    font-size: 11px;
    color: var(--fg-dim);
    margin-top: 2px;
}

.pos-cart-items {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

.pos-cart-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px;
    border-bottom: 1px solid var(--border-light);
    animation: fadeUp 0.2s ease;
}

.pos-cart-item:last-child {
    border-bottom: none;
}

.pos-item-info {
    flex: 1;
}

.pos-item-name {
    font-size: 13px;
    font-weight: 500;
}

.pos-item-meta {
    font-size: 11px;
    color: var(--fg-dim);
}

.pos-item-controls {
    display: flex;
    align-items: center;
    gap: 6px;
}

.pos-btn-qty {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--fg);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
}

.pos-btn-qty:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.pos-item-total {
    font-family: "JetBrains Mono", monospace;
    font-weight: 600;
    font-size: 13px;
    min-width: 60px;
    text-align: right;
}

.pos-cart-footer {
    padding: 16px;
    border-top: 1px solid var(--border);
    background: var(--bg2);
}

.pos-cart-total-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 6px;
    font-size: 13px;
    color: var(--fg-muted);
}

.pos-cart-total-row.main {
    font-size: 16px;
    font-weight: 700;
    color: var(--fg);
    margin-top: 10px;
    margin-bottom: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--border-light);
}

/* ── POS Categories Bar ── */
.pos-categories-wrapper {
    display: flex;
    flex-wrap: wrap; /* Permite que los chips bajen a la siguiente línea */
    gap: 8px;
    padding: 8px 16px 12px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--bg2);
}

.pos-categories-wrapper::-webkit-scrollbar {
    height: 4px;
}

.pos-categories-wrapper::-webkit-scrollbar-track {
    background: var(--bg3);
    border-radius: 4px;
}

.pos-categories-wrapper::-webkit-scrollbar-thumb {
    background: var(--accent);
    border-radius: 4px;
}

.pos-categories-wrapper::-webkit-scrollbar-thumb:hover {
    background: var(--accent);
    opacity: 0.8;
}

.pos-cat-chip {
    flex-shrink: 0; /* No se encogen, pero al haber wrap, no hacen scroll */
    padding: 6px 14px;
    border-radius: 20px;
    background: var(--bg3);
    border: 1px solid var(--border);
    color: var(--fg-muted);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
    user-select: none;
}

/* Efecto hover en desktop */
.pos-cat-chip:hover {
    background: var(--card-hover);
    color: var(--fg);
    border-color: var(--border-light);
}

.pos-cat-chip.active {
    background: var(--accent-dim);
    color: var(--accent);
    border-color: var(--accent);
    font-weight: 600;
}

/* Icono botón transparente */
.btn-icon {
    background: transparent;
    border: none;
    color: var(--fg-muted);
    cursor: pointer;
    padding: 8px;
    border-radius: 6px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}
.btn-icon:hover {
    background: var(--bg3);
    color: var(--fg);
}

/* Estilos KPIs del Modal Resumen */
.pos-summary-kpis {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

.pos-kpi-card {
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px;
    text-align: center;
}

.pos-kpi-label {
    font-size: 11px;
    color: var(--fg-dim);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.pos-kpi-value {
    font-family: "JetBrains Mono", monospace;
    font-size: 18px;
    font-weight: 600;
}

/* ── Tabla Compacta ── */
.compact-table {
    table-layout: auto;
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    min-width: 540px;
}

.compact-table th,
.compact-table td {
    padding: 4px 8px;
    white-space: nowrap;
    border-bottom: 1px solid var(--border-light);
}

.compact-table th:nth-child(1),
.compact-table th:nth-child(3),
.compact-table th:nth-child(4) {
    width: 1%;
    text-align: right;
}
.compact-table th:nth-child(1) {
    text-align: left;
}

.compact-table th:nth-child(2) {
    width: auto;
    text-align: left;
}

/* ── POS Discounts ── */
.pos-discount-actions {
    display: flex;
    gap: 6px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.pos-discount-btn {
    flex: 1;
    padding: 6px 4px;
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--fg-muted);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s;
}

.pos-discount-btn:hover {
    background: var(--card-hover);
    color: var(--fg);
}

.pos-discount-btn.active {
    background: var(--orange-dim);
    color: var(--orange);
    border-color: var(--orange);
}

.pos-discount-input {
    width: 100%;
    padding: 4px 8px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--fg);
    font-family: "JetBrains Mono", monospace;
    font-size: 12px;
    text-align: center;
    outline: none;
}

.pos-discount-input:focus {
    border-color: var(--orange);
}

/* ── User Pill (Header) ── */
.user-pill {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--fg);
    font-size: 12px;
    margin-right: auto;
    transition: all 0.2s;
    user-select: none;
}

.user-pill:hover {
    background: var(--card-hover);
    border-color: var(--border-light);
}

.user-pill i {
    font-size: 18px;
    color: var(--accent);
}

.user-info-text {
    display: flex;
    flex-direction: column;
    line-height: 1.3;
}

.up-name {
    font-weight: 600;
    color: var(--fg);
}

.up-biz {
    font-size: 10px;
    color: var(--fg-dim);
    max-width: 150px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── User Dropdown ── */
.user-dropdown {
    position: relative;
    margin-left: auto;
}

.user-pill {
    cursor: pointer;
    padding-right: 8px;
}

.dropdown-menu {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 200px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    z-index: 100;
    padding: 6px;
    animation: fadeIn 0.15s ease;
}

.dropdown-menu.show {
    display: block;
}

.dropdown-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    background: transparent;
    border: none;
    color: var(--fg);
    font-family: inherit;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
}

.dropdown-item:hover {
    background: var(--bg3);
    color: var(--accent);
}

.dropdown-item:active {
    transform: scale(0.98);
}

.dropdown-divider {
    height: 1px;
    background: var(--border);
    margin: 4px 0;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsive: En móviles ocultar nombre del negocio para ahorrar espacio */
@media (max-width: 600px) {
    .up-biz {
        display: none;
    }
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(40px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes toastOut {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(40px);
    }
}

/* ── Animations ── */
.fade-up {
    opacity: 0;
    transform: translateY(16px);
    animation: fadeUp 0.5s ease forwards;
}

@keyframes fadeUp {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.delay-1 {
    animation-delay: 0.05s;
}
.delay-2 {
    animation-delay: 0.1s;
}
.delay-3 {
    animation-delay: 0.15s;
}
.delay-4 {
    animation-delay: 0.2s;
}

/* ── Responsive ── */
@media (max-width: 768px) {
    .app {
        padding: 12px 14px 40px;
    }
    .header-title {
        font-size: 18px;
    }
    .charts-row {
        grid-template-columns: 1fr;
    }
    .kpi-grid {
        grid-template-columns: 1fr 1fr;
    }
    .form-grid {
        grid-template-columns: 1fr;
    }
    .tabs {
        width: 100%;
    }
    .tab {
        flex: 1;
        justify-content: center;
        padding: 9px 10px;
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    .kpi-grid {
        grid-template-columns: 1fr;
    }
    .perm-grid {
        grid-template-columns: 1fr 1fr;
    }
}

::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--border-light);
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

/* ── Impresión de Ticket ── */
@media print {
    @page {
        size: 80mm auto;
        margin: 0;
    }

    body {
        background: white;
        margin: 0;
    }

    #appContainer,
    #app,
    #loginScreen,
    #toastContainer,
    header,
    .header {
        display: none !important;
    }

    #printable-ticket {
        display: block !important;
        position: fixed;
        top: 0;
        left: 0;
        width: 80mm;
        background: white;
        color: black;
        padding: 3mm 5mm;
        margin: 0;
        z-index: 9999;
        box-shadow: none;
    }

    .ticket-line {
        border-bottom: 1px dashed #000 !important;
        margin: 5px 0;
    }
    .ticket-total {
        font-weight: bold !important;
        font-size: 14px !important;
    }
}

#printable-ticket {
    display: none;
    font-family: "Courier New", Courier, monospace;
    font-size: 12px;
    color: #000;
    background: #fff;
    padding: 10px;
}

/* Estilo específico para el modal de opciones (Sí/No) */
#confirmModal #confirmBtn {
    background: var(--accent);
    color: #0c0f14;
    border-color: var(--accent);
}

#confirmModal #confirmBtn:hover {
    background: #00e89c;
    box-shadow: 0 0 20px var(--accent-glow);
}

#confirmModal .modal-footer button:not(#confirmBtn) {
    background: transparent;
    color: var(--fg-muted);
    border-color: var(--border);
}
#confirmModal .modal-footer button:not(#confirmBtn):hover {
    background: var(--bg3);
    color: var(--fg);
    border-color: var(--border-light);
}

/* ── POS Client Input ── */
.pos-client-wrapper {
    position: relative;
    margin-bottom: 2px;
}

.pos-client-input {
    width: 100%;
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--border);
    color: var(--fg-muted);
    font-size: 11px;
    padding: 5px 10px;
    outline: none;
    transition: border-color 0.2s;
}

.pos-client-input:focus {
    border-bottom-color: var(--accent);
    color: var(--fg);
}

.pos-client-wrapper i {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--fg-dim);
    font-size: 10px;
}

#posClientDropdown {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    z-index: 200;
    box-shadow: var(--shadow);
    max-height: 200px;
    overflow-y: auto;
}

.pos-client-option {
    padding: 8px 12px;
    font-size: 12px;
    color: var(--fg);
    cursor: pointer;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    justify-content: space-between;
}

.pos-client-option:hover {
    background: var(--bg3);
}

.pos-client-option.create-new {
    color: var(--accent);
    font-weight: 600;
}

#posClientDropdown {
    width: 100%;
    min-width: 200px;
}

.pos-payment-methods {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px;
    margin-bottom: 10px;
}

.pos-pm-btn {
    padding: 8px 4px;
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--fg-muted);
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.2s;
}

.pos-pm-btn:hover {
    background: var(--card-hover);
    color: var(--fg);
}

.pos-pm-btn.active {
    background: var(--accent-dim);
    color: var(--accent);
    border-color: var(--accent);
}

.corte-summary {
    font-size: 13px;
}
.corte-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 6px;
}
.corte-row.main {
    font-weight: 700;
    color: var(--accent);
    font-size: 14px;
}

.pos-summary-btn {
    position: absolute;
    top: 0;
    right: 0;
    background: transparent;
    border: none;
    color: var(--fg-dim);
    font-size: 14px;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.2s;
}

.pos-summary-btn:hover {
    color: var(--fg);
    background: var(--bg3);
}

.pos-p-sku {
    font-family: "JetBrains Mono", monospace;
    font-size: 10px;
    color: var(--accent);
    margin-top: 2px;
}

/* ── Reportes ── */
.report-filters-bar {
    display: flex;
    align-items: flex-end;
    gap: 14px;
    margin-bottom: 20px;
    padding: 18px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    flex-wrap: wrap;
}

.report-date-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.report-date-input {
    padding: 9px 12px;
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--fg);
    font-family: inherit;
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s;
}

.report-date-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
}

.report-date-input::-webkit-calendar-picker-indicator {
    filter: invert(0.7);
    cursor: pointer;
}

.report-content {
    display: none;
}

.report-content.active {
    display: block;
}

#reportContentProducts .charts-row {
    grid-template-columns: 1.2fr 0.8fr;
    gap: 14px;
}

#reportContentProducts .table-container {
    overflow-x: auto;
    overflow-y: auto;
    max-height: 380px;
}

#reportContentProducts .compact-table th:nth-child(1),
#reportContentProducts .compact-table td:nth-child(1) {
    width: 40px;
    text-align: center;
}
#reportContentProducts .compact-table th:nth-child(2),
#reportContentProducts .compact-table td:nth-child(2) {
    width: auto;
    white-space: normal;
}
#reportContentProducts .compact-table th:nth-child(3),
#reportContentProducts .compact-table td:nth-child(3) {
    width: 60px;
    text-align: center;
}
#reportContentProducts .compact-table th:nth-child(4),
#reportContentProducts .compact-table td:nth-child(4) {
    width: 90px;
    text-align: right;
}
#reportContentProducts .compact-table th:nth-child(5),
#reportContentProducts .compact-table td:nth-child(5) {
    width: 90px;
    text-align: right;
}

#reportContentProducts .compact-table {
    min-width: unset !important;
    width: 100%;
}

#reportContentPayments .chart-card,
#reportContentCategories .chart-card {
    width: 100% !important;
    max-width: 100% !important;
}

@media (max-width: 1000px) {
    .kpi-grid[style*="repeat(5"] {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}
@media (max-width: 500px) {
    .kpi-grid[style*="repeat(5"] {
        grid-template-columns: 1fr !important;
    }
}

@media (max-width: 1024px) {
    .charts-row {
        grid-template-columns: 1fr;
    }
    #distributionModal .modal-body table {
        font-size: 11px;
    }
}

@media (max-width: 768px) {
    .app {
        padding: 10px 12px 40px;
    }

    .header {
        flex-wrap: wrap;
        gap: 10px;
    }
    .header-left {
        flex: 1 1 100%;
    }
    .header-actions {
        flex: 1 1 100%;
        justify-content: space-between;
        gap: 6px;
    }
    .hide-on-mobile {
        display: none !important;
    }

    .tabs {
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding: 4px;
    }
    .tabs::-webkit-scrollbar {
        display: none;
    }
    .tab {
        flex: 0 0 auto;
        white-space: nowrap;
        padding: 9px 16px;
        font-size: 12px;
    }

    .toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    .toolbar .search-box {
        max-width: 100%;
        width: 100%;
        order: -1;
    }
    .toolbar .filter-select {
        width: 100%;
    }
    .toolbar-info {
        margin-left: 0;
        text-align: center;
        order: 99;
    }

    .kpi-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }
    .kpi-value {
        font-size: 18px;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }
    .modal {
        width: 95vw;
        max-width: 95vw;
        border-radius: 12px 12px 0 0;
        max-height: 90vh;
        overflow-y: auto;
    }
    .modal-overlay {
        padding: 0;
        align-items: flex-end;
    }
    .modal-lg {
        max-width: 95vw;
    }

    .form-input,
    .filter-select {
        min-height: 44px;
        font-size: 16px !important;
    }

    .table-scroll {
        margin: 0 -12px;
        padding: 0 12px;
    }
    table {
        font-size: 12px;
    }
    .action-btn {
        width: 36px;
        height: 36px;
        font-size: 14px;
    }
    th:nth-child(8), td:nth-child(8),
    th:nth-child(7), td:nth-child(7),
    th:nth-child(5), td:nth-child(5) {
        display: none;
    }

    #mobileMoreMenu > .dropdown-menu {
        position: fixed !important;
        top: auto !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        width: 100vw !important;
        min-width: 100vw !important;
        max-width: 100vw !important;
        transform: none !important;
        background: var(--card) !important;
        border: none !important;
        border-top: 1px solid var(--border) !important;
        border-radius: 16px 16px 0 0 !important;
        box-shadow: 0 -4px 30px rgba(0, 0, 0, 0.6) !important;
        z-index: 99999 !important;
        padding: 12px 8px 30px 8px !important;
        margin: 0 !important;
        animation: slideUpMobile 0.3s cubic-bezier(0.32, 0.72, 0, 1) !important;
    }

    .mobile-more-menu .dropdown-item {
        padding: 14px 12px !important;
        font-size: 15px !important;
        border-radius: 8px !important;
    }

    @keyframes slideUpMobile {
        from {
            transform: translateY(100%);
            opacity: 0;
        }
        to {
            transform: translateY(0);
            opacity: 1;
        }
    }

    #contentPurchases .toolbar div[style*="display:flex"] {
        margin-left: 0 !important;
        margin-top: 10px;
        flex-wrap: wrap;
        gap: 6px !important;
        justify-content: flex-start !important;
    }
    #contentPurchases .toolbar div[style*="display:flex"] span {
        width: 100%;
        margin-bottom: 4px;
    }
    #contentPurchases .toolbar div[style*="display:flex"] input {
        flex: 1;
        min-width: 0;
        max-width: none !important;
    }

    #purchTableBody .filter-select {
        min-height: 38px;
        padding: 6px 8px !important;
        font-size: 13px !important;
        width: 100%;
    }

    #contentPurchases .table-container table {
        min-width: unset !important;
    }

    #adminLocations .table-container {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
    }
    #adminLocations table {
        min-width: 600px !important;
    }

    #reportContentProducts .charts-row {
        grid-template-columns: 1fr !important;
        gap: 14px !important;
    }
    #reportContentProducts .chart-wrap {
        height: 250px !important;
    }
    #reportContentProducts .table-container {
        max-height: 300px;
        overflow-y: auto !important;
        overflow-x: auto !important;
        border-radius: var(--radius-sm);
    }
    #reportContentProducts .compact-table {
        min-width: 380px !important;
    }
}

@media (max-width: 480px) {
    .kpi-grid {
        grid-template-columns: 1fr 1fr;
    }
    .kpi-value {
        font-size: 16px;
    }
    .kpi-label {
        font-size: 9px;
    }
    .pos-grid {
        grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
        gap: 8px;
    }
    .pos-product-card {
        padding: 10px;
    }
    .pos-p-name {
        font-size: 12px;
    }
    #purchaseModal .modal-body table input {
        min-height: 40px;
    }
}

/* --- Responsive específico para POS --- */
/* --- Responsive específico para POS --- */
@media (max-width: 900px) {
    .pos-container {
        grid-template-columns: 1fr;
        height: auto;
        min-height: 100vh;
    }

    .pos-catalog {
        min-height: 50vh;
    }

    .pos-cart {
        position: sticky;
        bottom: 0;
        z-index: 50;
        border-top: 3px solid var(--accent);
        border-radius: var(--radius) var(--radius) 0 0;
        box-shadow: 0 -6px 30px rgba(0, 0, 0, 0.4);
    }

    /* Carrito minimizable */
    .pos-cart {
        max-height: 60px;
        overflow: hidden;
        transition: max-height 0.3s ease;
    }

    .pos-cart.expanded {
        max-height: 70vh;
    }

    .pos-cart .pos-cart-body {
        overflow-y: auto;
        max-height: calc(70vh - 60px);
        padding: 12px;
    }

    .pos-cart:not(.expanded) .pos-cart-body {
        display: none;
    }

    /* Header del carrito en una sola fila */
    .pos-cart-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        flex-wrap: nowrap;
        gap: 10px;
        padding: 14px 16px;
        cursor: pointer;
        background: var(--bg2);
        border-bottom: 1px solid var(--border);
        user-select: none;
    }

    .pos-cart-header-left,
    .pos-cart-header-right {
        display: flex;
        align-items: center;
        gap: 8px;
        flex-wrap: nowrap;
    }

    .pos-cart-header-left i {
        font-size: 18px;
        color: var(--accent);
    }

    /* BUSCADOR Y ESCÁNER */
    .pos-catalog .toolbar {
        gap: 8px;
    }
    .pos-catalog .search-box {
        flex: 1;
        max-width: none !important;
        order: unset !important;
    }
    .pos-scan-btn {
        display: none !important;
    }

    /* .pos-scan-fab {
        display: flex !important;
        position: fixed;
        bottom: 80px;
        right: 20px;
        width: 56px;
        height: 56px;
        background: var(--accent);
        border-radius: 50%;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
        z-index: 200;
        transition: all 0.2s;
    }

    .pos-scan-fab i {
        font-size: 24px;
        color: #000;
    }

    .pos-scan-fab:active {
        transform: scale(0.95);
    } */

    /* GRID DE PRODUCTOS */
    .pos-grid {
        grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
        gap: 8px;
        padding: 10px;
    }
    .pos-product-card {
        padding: 10px;
        border-radius: 8px;
    }
    .pos-p-name {
        font-size: 12px;
        -webkit-line-clamp: 2;
    }
    .pos-p-sku {
        font-size: 9px;
    }
    .pos-p-stock {
        font-size: 10px;
    }

    /* ITEMS DEL CARRITO */
    .pos-cart-items {
        padding: 6px 10px;
    }
    .pos-cart-item {
        padding: 6px 0;
        gap: 6px;
    }
    .pos-item-info {
        flex: 1;
        min-width: 0;
    }
    .pos-item-name {
        font-size: 13px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .pos-item-total {
        min-width: 60px;
        text-align: right;
    }
    .pos-btn-qty {
        width: 30px;
        height: 30px;
        font-size: 14px;
    }

    /* TOTALES Y DESCUENTOS */
    .pos-cart-footer {
        padding: 12px;
    }
    .pos-discount-actions {
        gap: 5px;
        margin-bottom: 8px;
    }
    .pos-discount-btn {
        padding: 8px 4px;
        font-size: 12px;
    }
    .pos-cart-total-row {
        font-size: 13px;
    }
    .pos-cart-total-row.main {
        font-size: 16px;
        padding-top: 8px;
        margin-top: 8px;
    }

    /* MÉTODOS DE PAGO */
    .pos-payment-methods {
        grid-template-columns: repeat(3, 1fr);
        gap: 6px;
        margin-bottom: 10px;
    }
    .pos-pm-btn {
        padding: 14px 4px;
        font-size: 13px;
        border-radius: 8px;
    }

    /* BOTÓN COBRAR */
    #btnCheckout {
        padding: 16px !important;
        font-size: 18px !important;
        font-weight: 700 !important;
        border-radius: 8px !important;
        letter-spacing: 0.5px;
    }
}

@media (max-width: 768px) {
    .perm-grid {
        grid-template-columns: 1fr 1fr;
    }
    .admin-subnav {
        width: 100%;
        overflow-x: auto;
        scrollbar-width: none;
    }
    .admin-subnav::-webkit-scrollbar {
        display: none;
    }
    .admin-subnav-btn {
        flex: 0 0 auto;
        white-space: nowrap;
    }
    .kpi-grid[style*="repeat(5"] {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

@media (max-width: 768px) {
    .pos-categories-wrapper {
        flex-wrap: nowrap; /* Evita que bajen */
        overflow-x: auto;
        overflow-y: hidden;
        scrollbar-width: thin;
        -ms-overflow-style: auto;
        padding: 6px 12px 10px 12px;
        gap: 6px;
    }
    
    .pos-categories-wrapper::-webkit-scrollbar {
        height: 4px;
    }
    
    .pos-categories-wrapper::-webkit-scrollbar-track {
        background: var(--bg3);
        border-radius: 4px;
    }
    
    .pos-categories-wrapper::-webkit-scrollbar-thumb {
        background: var(--accent);
        border-radius: 4px;
    }
    
    .pos-cat-chip {
        flex-shrink: 0;
        padding: 5px 12px;
        font-size: 11px;
    }
}

/* ── POS Shift Status Pill ── */
.shift-status-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 16px;
    background: var(--accent-dim);
    color: var(--accent);
    border: 1px solid rgba(0, 214, 143, 0.3);
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 600;
    cursor: default;
    white-space: nowrap;
    user-select: none;
}

.shift-status-pill i {
    font-size: 10px;
    animation: pulse 2s infinite;
}

.btn-shift-close-active {
    border-color: var(--orange) !important;
    color: var(--orange) !important;
}

.btn-shift-close-active:hover {
    background: var(--orange-dim) !important;
    border-color: var(--orange) !important;
}

.btn:disabled {
    opacity: 0.5;
    pointer-events: none;
}

/* ── Password Toggle (Ojo) ── */
.password-wrapper {
    position: relative;
    width: 100%;
}

.password-wrapper .form-input {
    padding-right: 40px !important;
}

.toggle-password {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    color: var(--fg-dim);
    cursor: pointer;
    font-size: 14px;
    padding: 4px;
    transition: color 0.2s;
    line-height: 1;
}

.toggle-password:hover {
    color: var(--accent);
}

/* ── KPI Investment Grid ── */
.kpi-investment-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 4px;
    padding-top: 8px;
    border-top: 1px solid var(--border-light);
}

.kpi-sublabel {
    font-size: 9px;
    color: var(--fg-dim);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: block;
    margin-bottom: 2px;
}

.kpi-investment-col .kpi-value,
.kpi-investment-col .kpi-skeleton {
    font-size: 16px;
}

/* ── ESCÁNER CONTINUO ── */
#scannerContainer {
    z-index: 10000;
}

#reader {
    position: relative;
    background: #000;
    border-radius: 16px;
    overflow: hidden;
}

#reader video {
    width: 100% !important;
    height: auto !important;
    border-radius: 12px;
}

#reader__scan_region {
    position: relative;
}

#reader::before {
    content: '';
    position: absolute;
    top: 0;
    left: 10%;
    width: 80%;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--accent), transparent);
    animation: scanLine 2s ease-in-out infinite;
    pointer-events: none;
    z-index: 10;
}

@keyframes scanLine {
    0% {
        top: 10%;
        opacity: 0;
    }
    50% {
        top: 80%;
        opacity: 1;
    }
    100% {
        top: 10%;
        opacity: 0;
    }
}

#reader::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 80%;
    height: 30%;
    border: 2px solid var(--accent);
    border-radius: 8px;
    pointer-events: none;
    z-index: 10;
    opacity: 0.6;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.3);
}

@media (max-width: 768px) {
    #reader::after {
        width: 90%;
        height: 25%;
    }
    .scanner-controls {
        flex-wrap: wrap;
    }
}

/* Barra de margen para reporte de rentabilidad */
.margin-fill.margin-high {
    background: var(--accent);
}
.margin-fill.margin-mid {
    background: var(--blue);
}
.margin-fill.margin-low {
    background: var(--orange);
}
.margin-fill.margin-very-low {
    background: var(--red);
}

/* ── MODAL DISTRIBUCIÓN MEJORADO ── */
.modal-xl {
    max-width: 95vw;
    width: 95vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

.modal-xl .modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
}

.modal-xl .modal-header,
.modal-xl .modal-footer {
    flex-shrink: 0;
}

#distributionModal .compact-table th {
    position: sticky;
    top: 0;
    background: var(--bg2);
    z-index: 10;
}

#distributionModal .compact-table th:first-child {
    left: 0;
    z-index: 20;
}

#distributionModal .compact-table td:first-child {
    position: sticky;
    left: 0;
    background: var(--card);
    z-index: 5;
}

#distributionModal .compact-table tr:hover td:first-child {
    background: var(--card-hover);
}

#distributionModal .modal-body::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

#distributionModal .modal-body::-webkit-scrollbar-track {
    background: var(--bg);
    border-radius: 4px;
}

#distributionModal .modal-body::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

#distributionModal .modal-body::-webkit-scrollbar-thumb:hover {
    background: var(--border-light);
}

@media (max-width: 768px) {
    .modal-xl {
        max-width: 98vw;
        width: 98vw;
        max-height: 95vh;
    }
    #distributionModal .compact-table {
        font-size: 10px;
    }
    #distributionModal .compact-table th,
    #distributionModal .compact-table td {
        padding: 6px 4px;
    }
}

/* ── /* ── BOTONES MÓVILES DE ACCIONES (Resumen y Devoluciones) ── */
.pos-summary-btn-mobile,
.pos-returns-btn-mobile {
    background: transparent;
    border: none;
    color: var(--fg-muted);
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    font-size: 14px;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.pos-summary-btn-mobile:hover,
.pos-returns-btn-mobile:hover {
    background: var(--bg3);
    color: var(--fg);
}

.pos-returns-btn-mobile {
    color: var(--red);
}

/* Asegurar que el header del carrito tenga todo en una fila */
.pos-cart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: nowrap;
    gap: 10px;
}

.pos-cart-header-left,
.pos-cart-header-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: nowrap;
}

.pos-cart-header-right button {
    z-index: 10;
}

/* El contador de items */
.cart-item-count {
    background: var(--accent);
    color: #000;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 20px;
    margin-left: 6px;
    white-space: nowrap;
}

#cartTotalPreview {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 600;
    color: var(--accent);
    white-space: nowrap;
}

#cartToggleIcon {
    transition: transform 0.2s;
}

.pos-cart.expanded #cartToggleIcon {
    transform: rotate(180deg);
}

/* ── MENÚ MÓVIL ── */
.mobile-more-menu {
    display: none;
    position: relative;
}

@media (max-width: 768px) {
    .mobile-more-menu[style*="display: none"] {
        display: none !important;
    }
    .mobile-more-menu:not([style*="display: none"]) {
        display: inline-flex !important;
    }
}

/* ── BARRA SUPERIOR DEL POS (Una sola fila) ── */
.pos-top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
    padding: 12px 16px;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    flex-wrap: wrap;
}

.pos-location-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg3);
    padding: 4px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.pos-location-wrapper i {
    color: var(--accent);
    font-size: 14px;
}

.pos-location-select {
    background: transparent;
    border: none;
    padding: 8px 4px;
    font-size: 13px;
    font-weight: 500;
    color: var(--fg);
    cursor: pointer;
    outline: none;
}

.pos-location-select:focus {
    outline: none;
}

.pos-shift-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Mini Dashboard compacto */
.pos-shift-dashboard {
    display: flex;
    align-items: center;
    gap: 16px;
    background: var(--bg3);
    padding: 6px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.shift-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0 8px;
    border-right: 1px solid var(--border-light);
}

.shift-stat:last-child {
    border-right: none;
}

.shift-stat-label {
    font-size: 9px;
    color: var(--fg-dim);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.shift-stat-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    font-weight: 600;
    color: var(--accent);
}

/* Banner offline */
.pos-offline-banner {
    margin-bottom: 16px;
    background: rgba(255, 77, 106, 0.1);
    color: var(--red);
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--red);
    text-align: center;
    font-size: 12px;
}

.pos-offline-banner a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
    margin-left: 8px;
}

/* Responsive: En móvil, la barra se envuelve */
@media (max-width: 768px) {
    .pos-top-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }
    
    .pos-location-wrapper,
    .pos-shift-controls,
    .pos-shift-dashboard {
        justify-content: center;
    }
    
    .pos-shift-dashboard {
        justify-content: space-around;
    }
}

/* ── BARRA UNIFICADA (CATEGORÍAS + BUSCADOR) ── */
/* ── BARRA UNIFICADA (CATEGORÍAS + BUSCADOR + ESCÁNER) ── */
.pos-categories-section {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 16px;
    background: var(--bg2);
    border-bottom: 1px solid var(--border);
    flex-wrap: nowrap;
}

/* Contenedor de categorías */
.pos-categories-wrapper {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    flex: 1;
    max-height: 80px; /* Altura máxima para 2-3 líneas de categorías */
    overflow-y: auto; /* Scroll vertical si excede la altura */
    padding: 4px 0;
}

/* Personalizar scrollbar vertical de categorías */
.pos-categories-wrapper::-webkit-scrollbar {
    width: 4px;
    height: 4px;
}

.pos-categories-wrapper::-webkit-scrollbar-track {
    background: var(--bg3);
    border-radius: 4px;
}

.pos-categories-wrapper::-webkit-scrollbar-thumb {
    background: var(--accent);
    border-radius: 4px;
}


/* Acciones desktop (buscador + escáner) */
.pos-actions-desktop {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.pos-search-desktop {
    display: flex;
    align-items: center;
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 6px 12px;
    gap: 8px;
    width: 200px;
}

.pos-search-desktop i {
    color: var(--fg-dim);
    font-size: 12px;
}

.pos-search-input {
    background: transparent;
    border: none;
    outline: none;
    color: var(--fg);
    font-size: 13px;
    width: 100%;
}

.pos-search-input::placeholder {
    color: var(--fg-dim);
}

/* Botón escáner desktop */
.pos-scan-desktop-btn {
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--fg-muted);
    font-size: 16px;
    transition: all 0.2s;
}

.pos-scan-desktop-btn:hover {
    background: var(--card-hover);
    color: var(--accent);
    border-color: var(--accent);
}

/* Acciones móvil (solo ícono búsqueda) */
.pos-actions-mobile {
    display: none;
    flex-shrink: 0;
}

.pos-search-mobile-btn {
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--fg-muted);
    font-size: 16px;
    transition: all 0.2s;
}

.pos-search-mobile-btn:hover {
    background: var(--card-hover);
    color: var(--accent);
    border-color: var(--accent);
}

/* Ocultar buscador original */
#posSearchInput {
    display: none !important;
}

.pos-cat-chip {
    flex-shrink: 0;
    padding: 6px 14px;
    border-radius: 20px;
    background: var(--bg3);
    border: 1px solid var(--border);
    color: var(--fg-muted);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
    user-select: none;
}

/* ── MÓVIL ── */
@media (max-width: 768px) {
    .pos-categories-section {
        padding: 8px 12px;
    }
    
    /* Categorías con scroll horizontal */
    .pos-categories-wrapper {
        flex-wrap: nowrap;
        overflow-x: auto;
        overflow-y: hidden;
        max-height: none; /* Sin restricción de altura en móvil */
        scrollbar-width: thin;
        gap: 6px;
        flex: 1;
    }
    
    .pos-categories-wrapper::-webkit-scrollbar {
        height: 3px;
        width: auto;
    }
    /* Ocultar acciones desktop */
    .pos-actions-desktop {
        display: none;
    }
    
    /* Mostrar acciones móvil */
    .pos-actions-mobile {
        display: block;
    }
}

/* ── MODAL BÚSQUEDA MÓVIL (SIMPLIFICADO) ── */
.mobile-search-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(4px);
    z-index: 20000;
    display: none;
    align-items: center;
    justify-content: center;
}

.mobile-search-content {
    background: var(--card);
    border-radius: 20px;
    width: 90%;
    max-width: 380px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
    animation: fadeScale 0.2s ease;
}

@keyframes fadeScale {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.mobile-search-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 20px 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 10px;
}

.mobile-search-header h3 {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
}

.mobile-search-header h3 i {
    color: var(--accent);
    margin-right: 8px;
}

.mobile-search-close {
    background: transparent;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--fg-muted);
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
}

.mobile-search-close:hover {
    background: var(--bg3);
    color: var(--fg);
}

.mobile-search-body {
    padding: 20px;
}

.mobile-search-body .form-input {
    width: 100%;
    font-size: 16px;
    padding: 12px;
    text-align: center;
}

.mobile-search-hint {
    margin-top: 12px;
    font-size: 11px;
    color: var(--fg-dim);
    text-align: center;
}

.mobile-search-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 0 20px 20px;
}

.mobile-search-body {
    position: relative;
}

.mobile-search-clear {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    color: var(--fg-dim);
    cursor: pointer;
    font-size: 16px;
    padding: 4px;
    border-radius: 50%;
    transition: all 0.2s;
}

.mobile-search-clear:hover {
    color: var(--red);
    background: var(--red-dim);
}

/*icono de mostrar scanner*/
/* ── BOTÓN FLOTANTE DE ESCÁNER (controlado por JS) ── */
.pos-scan-fab {
    display: none; /* Oculto por defecto */
}

@media (max-width: 900px) {
    .pos-scan-fab {
        position: fixed;
        bottom: 80px;
        right: 20px;
        width: 56px;
        height: 56px;
        background: var(--accent);
        border-radius: 50%;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
        z-index: 200;
        transition: all 0.2s;
    }
    
    .pos-scan-fab i {
        font-size: 24px;
        color: #000;
    }
    
    .pos-scan-fab:active {
        transform: scale(0.95);
    }
}

/* Forzar ocultamiento en desktop por si hay conflictos */
@media (min-width: 901px) {
    .pos-scan-fab {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
        pointer-events: none !important;
    }
}


/* ── AUTOCOMPLETE SELECT ── */
.autocomplete-container {
    position: relative;
    width: 100%;
}

.autocomplete-input {
    width: 100%;
    padding-right: 32px;
}

.autocomplete-clear {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    color: var(--fg-dim);
    cursor: pointer;
    font-size: 14px;
    padding: 4px;
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.autocomplete-clear:hover {
    background: var(--bg3);
    color: var(--red);
}

.autocomplete-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    max-height: 250px;
    overflow-y: auto;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    z-index: 1000;
    box-shadow: var(--shadow);
    margin-top: 4px;
}

.autocomplete-option {
    padding: 10px 12px;
    cursor: pointer;
    font-size: 13px;
    color: var(--fg);
    border-bottom: 1px solid var(--border-light);
    transition: background 0.2s;
}

.autocomplete-option:last-child {
    border-bottom: none;
}

.autocomplete-option:hover,
.autocomplete-option.active {
    background: var(--bg3);
}

.autocomplete-option mark {
    background: var(--accent-dim);
    color: var(--accent);
    padding: 0 2px;
    border-radius: 3px;
    font-weight: 500;
}

.autocomplete-empty {
    padding: 12px;
    text-align: center;
    color: var(--fg-dim);
    font-size: 12px;
}

/* ── FILTROS ADMIN (una sola línea con contenedor ajustado) ── */
#adminUsers .toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: nowrap; /* Evitar que se envuelvan */
}

/* Contenedor del autocomplete - debe respetar el flujo */
#adminUsers .autocomplete-container {
    position: relative;
    display: inline-flex;
    width: auto;
    min-width: 160px;
    max-width: 200px;
    flex-shrink: 0;
}

/* Input del autocomplete */
#adminUsers .autocomplete-input {
    width: 100%;
    padding: 9px 28px 9px 12px;
    font-size: 13px;
}

/* Dropdown del autocomplete - debe estar por encima pero no desplazar */
#adminUsers .autocomplete-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 1000;
    max-height: 250px;
    overflow-y: auto;
}

/* Botón de limpiar dentro del autocomplete */
#adminUsers .autocomplete-clear {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
}

/* Select original oculto */
#adminRoleFilter {
    display: none;
}

/* Buscador */
#adminUsers .search-box {
    flex: 1;
    min-width: 180px;
    max-width: 280px;
}

/* Botón nuevo */
#adminUsers .btn-primary {
    flex-shrink: 0;
}

/* Responsive: en móvil sí se envuelve */
@media (max-width: 768px) {
    #adminUsers .toolbar {
        flex-wrap: wrap;
    }
    
    #adminUsers .autocomplete-container {
        min-width: 140px;
    }
    
    #adminUsers .search-box {
        flex: 1 1 100%;
        max-width: none;
        order: -1;
    }
}
/* ── AUTOCOMPLETE SELECT ── */
.autocomplete-container {
    position: relative;
    display: inline-flex;
    width: auto;
    min-width: 160px;
}

.autocomplete-dropdown {
    position: fixed !important;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    max-height: 250px;
    overflow-y: auto;
    z-index: 999999 !important; /* z-index extremadamente alto */
}

/* Asegurar que el dropdown no sea afectado por el contexto del modal */
.modal .autocomplete-dropdown {
    z-index: 999999 !important;
}

/* Tabla de inventario tiene z-index bajo, el dropdown debe estar por encima */
.table-container {
    position: relative;
    z-index: 1;
}

.autocomplete-dropdown {
    z-index: 999999 !important;
}

.modal-body {
    padding: 20px 24px;
    overflow: visible !important; /* Para que el dropdown no se corte */
}

.modal {
    overflow: visible !important;
}

#movModal .modal-body {
    overflow: visible !important;
}

#movModal .modal {
    overflow: visible !important;
}

/* ── MODAL EXTRA GRANDE PARA COMPRAS ── */
.modal-xl {
    max-width: 900px;
    width: 90%;
}

@media (max-width: 768px) {
    .modal-xl {
        max-width: 95%;
        width: 95%;
    }
}

/* ── MODAL TABS ── */
.modal-tabs {
    display: flex;
    gap: 8px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 16px;
}

.modal-tab-btn {
    background: transparent;
    border: none;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 500;
    color: var(--fg-muted);
    cursor: pointer;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    transition: all 0.2s;
}

.modal-tab-btn:hover {
    color: var(--fg);
    background: var(--bg3);
}

.modal-tab-btn.active {
    color: var(--accent);
    border-bottom: 2px solid var(--accent);
}

.modal-tab-content {
    display: none;
}

.modal-tab-content.active {
    display: block !important;
}

/* ── GRÁFICO DE HISTORIAL ── */
#priceHistoryChart {
    width: 100%;
    height: 100%;
    min-height: 200px;
}

/* ── MODAL DE CONFIRMACIÓN (SIEMPRE ARRIBA) ── */
#confirmModal {
    z-index: 10001 !important;
}

#confirmModal .modal-overlay {
    z-index: 10001 !important;
}

/* Asegurar que cualquier modal de confirmación esté por encima */
.modal-overlay {
    z-index: 1000;
}

.modal-overlay.active {
    z-index: 1000;
}

/* El modal de confirmación debe tener prioridad */
#confirmModal.modal-overlay {
    z-index: 10001 !important;
}

/* ── Toast ── */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 999999 !important; /* 🆕 Aumentado para estar por encima de todo */
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 12px 18px;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
    animation: toastIn 0.3s ease;
    min-width: 260px;
    z-index: 999999 !important;
}

/* ── Modal Overlay (reducir un poco para que no tape los toasts) ── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 10000; /* 🆕 Reducido de 100000 a 10000 */
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: all;
}

/* Modal de confirmación debe estar por encima de los modales normales */
#confirmModal.modal-overlay {
    z-index: 10001 !important;
}

/* Dropdowns de autocomplete también */
.autocomplete-dropdown {
    z-index: 999990 !important;
}

/* ── SUPER ADMIN DASHBOARD ── */
.super-dashboard {
    padding: 8px 0;
}

#superSalesChart, #superUsersChart {
    width: 100%;
    height: 100%;
}

/* ── BOTONES DE PERÍODO DE PAGO ── */
.period-btn {
    transition: all 0.2s ease;
}

.period-btn.active {
    background: var(--accent);
    color: #000;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-dim);
}

.period-btn small {
    font-size: 10px;
    opacity: 0.8;
}

/* ── MODAL DE PAGOS ── */
#paymentModal .modal {
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    overflow-y:scroll !important ;
}

#paymentModal .modal-body {
    flex: 1;
    overflow-y: auto;
}

/* Botones de período responsivos */
@media (max-width: 550px) {
    #paymentModal .period-btn {
        font-size: 11px;
        padding: 8px 4px;
    }
    #paymentModal .period-btn small {
        font-size: 9px;
    }
}

/* Tabla de historial compacta */
#paymentModal .compact-table td {
    padding: 8px 6px;
}

/* ── TABLA DE HISTORIAL DE PAGOS ── */
#paymentModal .compact-table {
    width: 100%;
    border-collapse: collapse;
}

#paymentModal .compact-table th,
#paymentModal .compact-table td {
    padding: 10px 8px;
    border-bottom: 1px solid var(--border-light);
    text-align: left;
}

#paymentModal .compact-table th {
    background: var(--bg2);
    position: sticky;
    top: 0;
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--fg-muted);
}

#paymentModal .compact-table tr:hover td {
    background: var(--bg3);
}

/* Scroll horizontal para la tabla */
#paymentModal .table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

/* Estilo para igualar altura de tarjetas de planes */
.pricing-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 2rem;
    align-items: stretch;
}

.pricing-card {
    flex: 1;
    min-width: 280px;
    display: flex;
}

.pricing-card .features-list {
    flex: 1;
}

@media (max-width: 768px) {
    .pricing-grid {
        flex-direction: column;
        align-items: center;
    }
    .pricing-card {
        width: 100%;
        max-width: 400px;
    }
}

.pricing-card > div {
    display: flex;
    flex-direction: column;
    width: 100%;
    min-height: 560px;
}

/* En móvil, eliminar el min-height para que sea natural */
@media (max-width: 768px) {
    .pricing-card > div {
        min-height: auto;
    }
}
/* Badge para el tab de Leads */
#leadsBadge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    margin-left: 8px;
    background: var(--accent);
    color: #000;
    font-size: 11px;
    font-weight: 700;
    border-radius: 40px;
    transition: all 0.2s ease;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

/* Estado cuando hay leads pendientes */
#leadsBadge.has-pending {
    background: var(--orange);
    color: #000;
    animation: pulse-badge 1.5s ease-in-out infinite;
}

/* Animación de pulso para llamar la atención */
@keyframes pulse-badge {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(255, 170, 44, 0.4);
    }
    50% {
        transform: scale(1.1);
        box-shadow: 0 0 0 3px rgba(255, 170, 44, 0.2);
    }
}

/* Tooltip opcional para indicar que hay pendientes */
#leadsBadge.has-pending:hover {
    transform: scale(1.15);
    cursor: help;
}