:root {
    --bg: #f6f7fb;
    --card: #ffffff;
    --ink: #172033;
    --muted: #6b7280;
    --primary: #1f7a8c;
    --primary-2: #0f3d56;
    --accent: #f6ae2d;
    --danger: #e63946;
    --success: #2a9d8f;
    --line: #e5e7eb;
    --shadow: 0 18px 50px rgba(15, 23, 42, .08);
}

* { box-sizing: border-box; }
body { font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; color: var(--ink); }
.auth-body {
    min-height: 100vh;
    background:
        radial-gradient(circle at top left, rgba(246, 174, 45, .25), transparent 32rem),
        linear-gradient(135deg, #0f3d56 0%, #1f7a8c 52%, #f6f7fb 52%, #f6f7fb 100%);
}
.app-body { background: var(--bg); }

.auth-card {
    width: min(980px, calc(100% - 2rem));
    margin: 6vh auto;
    overflow: hidden;
    border: 0;
    border-radius: 28px;
    box-shadow: var(--shadow);
}
.auth-hero {
    min-height: 100%;
    color: #fff;
    padding: 3rem;
    background: linear-gradient(160deg, rgba(15, 61, 86, .98), rgba(31, 122, 140, .95));
}
.auth-hero .logo-circle,
.brand-icon {
    width: 46px;
    height: 46px;
    border-radius: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, .16);
    color: #fff;
}
.auth-form { padding: 3rem; background: #fff; }

.app-shell { min-height: 100vh; display: flex; }
.sidebar {
    width: 270px;
    min-height: 100vh;
    background: #0f172a;
    color: #fff;
    padding: 1.25rem;
    position: sticky;
    top: 0;
}
.brand {
    display: flex;
    align-items: center;
    gap: .75rem;
    color: #fff;
    text-decoration: none;
    font-weight: 800;
    font-size: 1.05rem;
    padding: .5rem .25rem 1.25rem;
}
.brand-icon { background: linear-gradient(135deg, var(--primary), var(--accent)); }
.side-nav { display: grid; gap: .35rem; }
.side-nav a {
    color: rgba(255,255,255,.78);
    text-decoration: none;
    padding: .85rem 1rem;
    border-radius: 16px;
    display: flex;
    align-items: center;
    gap: .7rem;
    transition: .2s ease;
}
.side-nav a:hover, .side-nav a.active { background: rgba(255,255,255,.11); color: #fff; }
.side-nav a.disabled { opacity: .45; pointer-events: none; }
.sidebar-footer {
    margin-top: auto;
    padding: 1rem;
    border-radius: 18px;
    background: rgba(255,255,255,.08);
}
.main-panel { flex: 1; min-width: 0; }
.topbar { background: rgba(246, 247, 251, .88); backdrop-filter: blur(12px); border-bottom: 1px solid rgba(229,231,235,.8); }
.content-wrap { padding: 1.25rem; }
@media (min-width: 992px) { .content-wrap { padding: 2rem; } }

.page-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.5rem; }
.page-heading h1 { font-weight: 800; margin: 0; letter-spacing: -.02em; }
.page-heading p { color: var(--muted); margin: .25rem 0 0; }

.stat-card, .panel-card, .pos-card {
    background: var(--card);
    border: 1px solid rgba(229,231,235,.75);
    border-radius: 24px;
    box-shadow: 0 10px 30px rgba(15,23,42,.04);
}
.stat-card { padding: 1.25rem; height: 100%; }
.stat-icon {
    width: 46px; height: 46px; border-radius: 16px;
    display: inline-flex; align-items: center; justify-content: center;
    background: rgba(31,122,140,.12); color: var(--primary);
    margin-bottom: .8rem;
}
.stat-card h3 { font-size: 1.75rem; font-weight: 800; margin: 0; }
.stat-card span { color: var(--muted); }
.panel-card { padding: 1.25rem; }

.btn-primary { --bs-btn-bg: var(--primary); --bs-btn-border-color: var(--primary); --bs-btn-hover-bg: var(--primary-2); --bs-btn-hover-border-color: var(--primary-2); }
.btn-warning { --bs-btn-bg: var(--accent); --bs-btn-border-color: var(--accent); }
.form-control, .form-select { border-radius: 14px; padding: .72rem .9rem; }
.form-control:focus, .form-select:focus { border-color: var(--primary); box-shadow: 0 0 0 .2rem rgba(31,122,140,.14); }
.table { vertical-align: middle; }
.badge-soft { background: rgba(31,122,140,.11); color: var(--primary); border: 1px solid rgba(31,122,140,.16); }

.pos-grid { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(360px, .8fr); gap: 1rem; }
@media (max-width: 991px) { .pos-grid { grid-template-columns: 1fr; } }
.pos-card { padding: 1rem; }
.search-results {
    position: absolute;
    z-index: 20;
    left: 0;
    right: 0;
    top: calc(100% + .5rem);
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 18px;
    box-shadow: var(--shadow);
    overflow: hidden;
    display: none;
}
.search-item {
    width: 100%;
    border: 0;
    background: #fff;
    text-align: left;
    padding: .85rem 1rem;
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    border-bottom: 1px solid #f1f5f9;
}
.search-item:hover { background: #f8fafc; }
.cart-table th { color: var(--muted); font-weight: 700; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; }
.qty-control { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.qty-control button { border: 0; background: #f8fafc; width: 30px; height: 30px; }
.qty-control input { width: 54px; border: 0; text-align: center; outline: 0; }
.total-box {
    background: linear-gradient(135deg, #0f3d56, #1f7a8c);
    color: #fff;
    border-radius: 24px;
    padding: 1.25rem;
}
.total-box .total { font-size: clamp(2rem, 8vw, 3rem); font-weight: 900; line-height: 1; }
.ticket-preview { background: #fff; border: 1px dashed #cbd5e1; border-radius: 18px; padding: 1rem; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .88rem; }
.empty-cart { border: 1px dashed #cbd5e1; border-radius: 20px; padding: 2rem; text-align: center; color: var(--muted); }

@media print {
    body * { visibility: hidden; }
    #ticketToPrint, #ticketToPrint *, .printable-area, .printable-area * { visibility: visible; }
    #ticketToPrint { position: absolute; left: 0; top: 0; width: 280px; }
    .printable-area { position: absolute; left: 0; top: 0; width: 100%; }
}

.summary-line {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: .55rem 0;
}
.summary-line span { color: var(--muted); }
.mini-info-card {
    background: #f8fafc;
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 1rem;
    height: 100%;
}
.purchase-table-wrap .form-control,
.purchase-table-wrap .form-select {
    min-width: 90px;
}
.import-help-card {
    border: 1px dashed #cbd5e1;
    border-radius: 20px;
    padding: 1rem;
    background: #f8fafc;
}
@media (max-width: 767px) {
    .page-heading { align-items: stretch; flex-direction: column; }
    .page-heading .btn { width: 100%; }
}
@media print {
    .no-print,
    .sidebar,
    .topbar,
    .page-heading,
    .btn,
    form { display: none !important; }
    .app-shell { display: block; }
    .main-panel { width: 100%; }
    .content-wrap { padding: 0; }
    .panel-card, .printable-area { box-shadow: none; border: 0; border-radius: 0; }
}

.nav-section-label {
    color: rgba(255,255,255,.42);
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .08em;
    font-weight: 800;
    margin: 1rem .75rem .25rem;
}
.sidebar { overflow-y: auto; }
.side-nav a { padding: .72rem .9rem; border-radius: 14px; }
.product-thumb {
    width: 54px;
    height: 54px;
    border-radius: 14px;
    object-fit: cover;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    flex: 0 0 auto;
}
.product-thumb-sm {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    object-fit: cover;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
}
.quick-product-card {
    display: inline-flex;
    align-items: center;
    gap: .65rem;
    text-align: left;
    min-width: 210px;
    max-width: 280px;
    padding: .55rem .7rem;
    border-radius: 16px;
}
.quick-product-card img { width: 46px; height: 46px; border-radius: 14px; object-fit: cover; }
.search-item.with-photo { align-items: center; justify-content: flex-start; }
.search-item.with-photo .search-info { flex: 1; min-width: 0; }
.image-drop-preview {
    border: 1px dashed #cbd5e1;
    border-radius: 20px;
    background: #f8fafc;
    padding: .85rem;
    text-align: center;
}
.image-drop-preview img {
    width: 100%;
    max-height: 210px;
    object-fit: contain;
    border-radius: 16px;
    background: white;
}
.form-section-title {
    font-size: .78rem;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--muted);
    font-weight: 800;
    margin-bottom: .75rem;
}
.import-preview-table { font-size: .88rem; }
.import-preview-table td, .import-preview-table th { white-space: nowrap; }
.kpi-strip {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1rem;
}
@media (max-width: 991px) { .kpi-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 575px) { .kpi-strip { grid-template-columns: 1fr; } }
.settings-tabs .nav-link { border-radius: 999px; }
.payment-row {
    background: #f8fafc;
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: .75rem;
}
.credit-badge-danger { background:#fee2e2; color:#991b1b; border:1px solid #fecaca; }
.credit-badge-warning { background:#fef3c7; color:#92400e; border:1px solid #fde68a; }
.ticket-paper {
    max-width: 360px;
    margin: 0 auto;
    border: 1px dashed #cbd5e1;
    padding: 1rem;
    border-radius: 12px;
    background: #fff;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* V4: productos por fases y cliente en POS */
.page-tabs .nav-link {
    border-radius: 999px;
    font-weight: 800;
    padding: .8rem 1rem;
}
.product-wizard-steps {
    gap: .5rem;
}
.product-wizard-steps .nav-link {
    border-radius: 18px;
    background: #f8fafc;
    color: var(--muted);
    border: 1px solid var(--line);
    display: inline-flex;
    align-items: center;
    gap: .55rem;
    font-weight: 800;
}
.product-wizard-steps .nav-link span {
    width: 28px;
    height: 28px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #e2e8f0;
    color: #0f172a;
}
.product-wizard-steps .nav-link.active {
    background: linear-gradient(135deg, #0d6efd, #1f7a8c);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 10px 24px rgba(13,110,253,.18);
}
.product-wizard-steps .nav-link.active span {
    background: rgba(255,255,255,.22);
    color: #fff;
}
.product-wizard-content {
    min-height: 390px;
}
.product-table-wrap .product-thumb-sm {
    width: 52px;
    height: 52px;
}
.customer-results {
    left: 0;
    right: 0;
    top: calc(100% + .25rem);
    z-index: 1080;
}
.customer-item {
    justify-content: flex-start !important;
    text-align: left;
}
.selected-customer {
    margin-top: .65rem;
    border: 1px solid #bfdbfe;
    background: #eff6ff;
    border-radius: 16px;
    padding: .75rem .9rem;
    color: #172554;
}
.ticket-lines {
    display: grid;
    gap: .35rem;
}
.ticket-line {
    display: grid;
    grid-template-columns: 3.7rem minmax(0, 1fr) 5.2rem;
    gap: .45rem;
    align-items: start;
}
.ticket-line > :last-child {
    text-align: right;
}
.ticket-line-head {
    font-weight: 900;
    border-bottom: 1px solid #cbd5e1;
    padding-bottom: .25rem;
    text-transform: uppercase;
    font-size: .78rem;
}
.ticket-line small {
    color: #64748b;
}
.ticket-total {
    border-top: 1px solid #cbd5e1;
    margin-top: .35rem;
    padding-top: .35rem;
    font-weight: 900;
}
.ticket-legend {
    margin-top: .5rem;
    padding: .35rem .5rem;
    border: 1px dashed #cbd5e1;
    border-radius: 8px;
    text-align: center;
    font-size: .78rem;
    color: #334155;
}
@media (max-width: 575px) {
    .product-wizard-steps .nav-link {
        width: 100%;
        justify-content: flex-start;
    }
    .ticket-line {
        grid-template-columns: 3.2rem minmax(0, 1fr) 4.6rem;
    }
}

/* V5: tabs, dashboard, promociones, API y documentos */
.module-tabs {
    gap: .5rem;
    flex-wrap: wrap;
}
.module-tabs .nav-link {
    border: 1px solid var(--line);
    background: #fff;
    color: #334155;
    box-shadow: 0 8px 20px rgba(15, 23, 42, .04);
}
.module-tabs .nav-link.active {
    background: linear-gradient(135deg, #0d6efd, #1f7a8c);
    border-color: transparent;
    color: #fff;
}
.chart-card canvas {
    width: 100% !important;
    max-height: 310px;
}
.promo-badge {
    background: #ecfeff;
    color: #155e75;
    border: 1px solid #a5f3fc;
    font-weight: 800;
}
.promo-pill {
    display: inline-flex;
    align-items: center;
    gap: .25rem;
    border-radius: 999px;
    background: #fff7ed;
    color: #9a3412;
    border: 1px solid #fed7aa;
    padding: .14rem .5rem;
    font-size: .76rem;
    font-weight: 800;
    margin-left: .35rem;
}
.code-help {
    background: #0f172a;
    color: #e2e8f0;
    border-radius: 16px;
    padding: 1rem;
    white-space: pre-wrap;
    word-break: break-word;
    min-height: 96px;
}
.license-status-card {
    border-left: 6px solid #1f7a8c;
}
.license-status-card.blocked { border-left-color: #dc3545; }
.license-status-card.demo { border-left-color: #f59e0b; }
.license-status-card.active { border-left-color: #198754; }
.document-actions .btn,
.confirm-payment {
    border-radius: 14px;
    font-weight: 800;
}
@media (max-width: 767px) {
    .confirm-payment { width: 100%; }
    .modal-footer { gap: .5rem; }
}

/* V6: seleccion visual de promociones, perfil y panel oculto */
.promo-select-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: .75rem;
    max-height: 430px;
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: .75rem;
    background: #f8fafc;
}
.promo-select-grid.compact {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    max-height: 320px;
}
.promo-option-card {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .75rem;
    border: 1px solid var(--line);
    background: #fff;
    border-radius: 16px;
    cursor: pointer;
    transition: transform .12s ease, border-color .12s ease, box-shadow .12s ease;
}
.promo-option-card:hover {
    transform: translateY(-1px);
    border-color: rgba(31,122,140,.45);
}
.promo-option-card.selected {
    border-color: #0d6efd;
    box-shadow: 0 8px 20px rgba(13,110,253,.12);
    background: #eff6ff;
}
.promo-option-card input {
    width: 1.15rem;
    height: 1.15rem;
    flex: 0 0 auto;
}
.promo-option-card img,
.promo-option-icon {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    object-fit: cover;
    background: #e0f2fe;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #155e75;
    flex: 0 0 auto;
}
.promo-option-info {
    min-width: 0;
    display: grid;
    gap: .1rem;
}
.promo-option-info strong {
    line-height: 1.15;
}
.promo-option-info small {
    color: #64748b;
}
.promo-all-products-card {
    border: 1px dashed #67e8f9;
    background: #ecfeff;
    border-radius: 18px;
    padding: 1.25rem;
    display: flex;
    gap: 1rem;
    align-items: center;
}
.dev-only-card {
    border: 1px solid #fde68a;
    background: #fffbeb;
    border-radius: 18px;
    padding: 1rem;
}
@media (max-width: 575px) {
    .promo-select-grid { grid-template-columns: 1fr; }
}

/* V7: mejoras de lectura, footer, seleccion modal y manual */
.content-wrap { overflow-x: hidden; }
.module-tabs .nav-link,
.page-tabs .nav-link,
.product-wizard-steps .nav-link {
    color: #1f2937 !important;
    font-weight: 800;
}
.module-tabs .nav-link.active,
.page-tabs .nav-link.active,
.product-wizard-steps .nav-link.active {
    color: #ffffff !important;
}
.app-footer {
    margin-top: 2rem;
    padding: 1rem 0 .25rem;
    color: #64748b;
    text-align: center;
    font-weight: 700;
    border-top: 1px solid rgba(203,213,225,.75);
}
.promo-selected-summary {
    min-height: 58px;
}
.promo-select-grid.modal-grid {
    max-height: 62vh;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
}
.product-pick-card .promo-product-img {
    cursor: zoom-in;
}
.manual-module-card {
    border: 1px solid var(--line);
    border-radius: 20px;
    padding: 1rem;
    background: #fff;
    height: 100%;
}
.manual-module-card h3 {
    font-size: 1.05rem;
    font-weight: 900;
}
.manual-module-card ul { margin-bottom: 0; }
.subscription-status-line {
    display: grid;
    grid-template-columns: 180px minmax(0, 1fr);
    gap: .75rem;
    padding: .45rem 0;
    border-bottom: 1px solid #eef2f7;
}
@media (max-width: 575px) {
    .promo-select-grid.modal-grid { grid-template-columns: 1fr; }
    .subscription-status-line { grid-template-columns: 1fr; }
}
.license-status-card.bloqueado,
.license-status-card.vencido { border-left-color: #dc3545; }
.license-status-card.activo { border-left-color: #198754; }
