:root {
    --ui-forest: #0d3027;
    --ui-forest-light: #18483b;
    --ui-green: #21a179;
    --ui-green-bright: #36d399;
    --ui-ink: #14221e;
    --ui-muted: #58655f;
    --ui-bg: #eef4ef;
    --ui-surface: #ffffff;
    --ui-line: #dfe6e0;
    --ui-danger: #d63031;
    --ui-radius: 18px;
    --ui-shadow: 0 14px 38px rgba(13, 48, 39, .10);
}

* { box-sizing: border-box; }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

body.tpv-themed-page {
    min-height: 100vh;
    margin: 0;
    padding: 24px;
    color: var(--ui-ink);
    background:
        radial-gradient(circle at 5% 0, rgba(33, 161, 121, .13), transparent 26rem),
        linear-gradient(180deg, #f7f8f3 0%, var(--ui-bg) 100%);
    font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    -webkit-font-smoothing: antialiased;
}

body.tpv-themed-page > .container,
body.tpv-themed-page > .gastos-shell,
body.tpv-themed-page > .labels-app,
body.tpv-themed-page > .editor-container {
    width: min(100%, 1240px);
    margin-inline: auto;
}

body.tpv-themed-page .container,
body.tpv-themed-page .gastos-shell {
    border: 1px solid rgba(13, 48, 39, .08);
    border-radius: 26px;
    background: rgba(255, 255, 255, .96);
    box-shadow: var(--ui-shadow);
}

body.tpv-themed-page .header,
body.tpv-themed-page .gastos-header,
body.tpv-themed-page .labels-header,
body.tpv-themed-page .top-bar {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin: 0 0 24px;
    padding: 20px 24px;
    border: 0;
    border-radius: 22px;
    color: #fff;
    background:
        radial-gradient(circle at 82% 10%, rgba(54, 211, 153, .18), transparent 18rem),
        linear-gradient(130deg, var(--ui-forest), var(--ui-forest-light));
    box-shadow: 0 16px 38px rgba(13, 48, 39, .17);
}

body.tpv-themed-page .header-left {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 18px;
}

body.tpv-themed-page .header h1,
body.tpv-themed-page .gastos-header h1,
body.tpv-themed-page .top-bar h2 {
    margin: 0;
    color: #fff;
    line-height: 1.12;
    letter-spacing: -.025em;
}

body.tpv-themed-page .gastos-header p { color: rgba(255,255,255,.72); }

.tpv-brand-back {
    width: 168px;
    min-width: 168px;
    min-height: 62px;
    display: grid;
    place-items: center;
    padding: 9px 11px;
    overflow: hidden;
    border: 0;
    border-radius: 14px;
    color: var(--ui-forest);
    background: #fff;
    box-shadow: 0 12px 28px rgba(0, 0, 0, .18);
    text-decoration: none;
    transition: transform .18s ease, box-shadow .18s ease;
}

.tpv-brand-back:hover { transform: translateY(-2px); box-shadow: 0 16px 32px rgba(0,0,0,.22); }
.tpv-brand-back:focus-visible { outline: 3px solid rgba(54,211,153,.55); outline-offset: 3px; }
.tpv-brand-back img { display: block; width: 100%; height: auto; object-fit: contain; }

body.tpv-themed-page input:not([type="checkbox"]):not([type="radio"]):not([type="color"]),
body.tpv-themed-page select,
body.tpv-themed-page textarea {
    min-height: 46px;
    border: 1px solid #ced9d2;
    border-radius: 12px;
    color: var(--ui-ink);
    background: #fbfcfa;
}

body.tpv-themed-page input:focus,
body.tpv-themed-page select:focus,
body.tpv-themed-page textarea:focus {
    border-color: var(--ui-green);
    outline: 0;
    box-shadow: 0 0 0 4px rgba(33, 161, 121, .12);
}

body.tpv-themed-page .form-section,
body.tpv-themed-page .ventas-report-panel,
body.tpv-themed-page .client-card,
body.tpv-themed-page .inventory-card,
body.tpv-themed-page .config-section,
body.tpv-themed-page .expense-form-panel,
body.tpv-themed-page .expenses-table-card {
    border-color: var(--ui-line);
    border-radius: var(--ui-radius);
    box-shadow: 0 9px 28px rgba(13, 48, 39, .07);
}

body.tpv-themed-page .btn-submit,
body.tpv-themed-page .btn-save,
body.tpv-themed-page .btn-add,
body.tpv-themed-page .btn-primary:not(.paper-option),
body.tpv-themed-page .btn-print {
    min-height: 46px;
    border-radius: 12px;
    background: var(--ui-forest);
    box-shadow: 0 8px 20px rgba(13,48,39,.16);
}

body.tpv-themed-page .btn-submit:hover,
body.tpv-themed-page .btn-save:hover,
body.tpv-themed-page .btn-add:hover,
body.tpv-themed-page .btn-primary:hover { background: var(--ui-green); }

body.tpv-themed-page .edit-panel,
body.tpv-themed-page .side-panel-content,
body.tpv-themed-page .modal-content {
    border-radius: 22px 0 0 22px;
}

/* El editor de etiquetas conserva su rejilla, pero comparte cabecera y superficies. */
body.tpv-themed-page .labels-app { max-width: 1500px; }
body.tpv-themed-page .labels-header { border-radius: 22px; }
body.tpv-themed-page .labels-header .header-fields label { color: rgba(255,255,255,.8); }

/* Editor de sala: el lienzo no cambia, solo su marco y controles. */
body.tpv-themed-page.editor-page { padding: 14px; overflow: hidden; }
body.tpv-themed-page.editor-page .editor-container { max-width: none; height: calc(100vh - 28px); border-radius: 22px; overflow: hidden; box-shadow: var(--ui-shadow); }
body.tpv-themed-page.editor-page .top-bar { margin: 0; border-radius: 0; }
body.tpv-themed-page.editor-page .brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
body.tpv-themed-page.editor-page .controls { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
body.tpv-themed-page.product-page .product-header .tpv-brand-back { width: 240px; min-width: 240px; }

/* Recuperación y acceso offline. */
body.tpv-themed-page.auth-page { display: grid; place-items: center; }
body.tpv-themed-page.auth-page .recovery-card,
body.tpv-themed-page.auth-page .login-card {
    border: 1px solid var(--ui-line);
    border-radius: 24px;
    box-shadow: var(--ui-shadow);
}
body.tpv-themed-page.auth-page .tpv-brand-back { width: 190px; margin: 0 auto 20px; }

/* Capa visual del index: no altera su estructura. */
body.tpv-index-page {
    --primary: var(--ui-forest);
    --secondary: var(--ui-green);
    --success: var(--ui-green);
    --bg-light: #f4f7f4;
    --border: var(--ui-line);
    color: var(--ui-ink);
    background: var(--ui-bg);
}

body.tpv-index-page .tpv-container { gap: 8px; padding: 8px; background: var(--ui-bg); }
body.tpv-index-page .ticket-panel,
body.tpv-index-page .catalog-panel {
    overflow: hidden;
    border: 1px solid rgba(13,48,39,.09);
    border-radius: 18px;
    background: #fff;
    box-shadow: 0 8px 26px rgba(13,48,39,.08);
}
body.tpv-index-page .panel-header,
body.tpv-index-page .catalog-header,
body.tpv-index-page .tpv-top-menu,
body.tpv-index-page .categories-nav {
    border-color: var(--ui-line);
}
body.tpv-index-page .tpv-top-menu { border-radius: 14px; background: var(--ui-forest); box-shadow: 0 8px 22px rgba(13,48,39,.15); }
body.tpv-index-page .menu-item { border-radius: 10px; color: rgba(255,255,255,.82); }
body.tpv-index-page .menu-item:hover,
body.tpv-index-page .menu-item.active { color: #fff; background: rgba(255,255,255,.14); }
body.tpv-index-page .search-bar,
body.tpv-index-page .customer-selected-card,
body.tpv-index-page #order-notes-container { border-color: var(--ui-line) !important; border-radius: 14px !important; background: #fbfcfa !important; }
body.tpv-index-page .product-card { border-color: var(--ui-line); border-radius: 16px; box-shadow: 0 6px 18px rgba(13,48,39,.07); }
body.tpv-index-page .cat-pill { border-radius: 999px; }
body.tpv-index-page .modal-content { border-radius: 22px; box-shadow: 0 24px 70px rgba(13,48,39,.24); }

@media (max-width: 900px) {
    body.tpv-themed-page { padding: 14px; }
    body.tpv-themed-page .header,
    body.tpv-themed-page .gastos-header,
    body.tpv-themed-page .labels-header,
    body.tpv-themed-page .top-bar { flex-wrap: wrap; padding: 17px; }
    .tpv-brand-back { width: 145px; min-width: 145px; min-height: 54px; }
}

@media (max-width: 768px) {
    body.tpv-themed-page { padding: 0; background: #fff; }
    body.tpv-themed-page .container,
    body.tpv-themed-page .gastos-shell { width: 100%; margin: 0; padding: 14px; border: 0; border-radius: 0; box-shadow: none; }
    body.tpv-themed-page .header,
    body.tpv-themed-page .gastos-header,
    body.tpv-themed-page .labels-header,
    body.tpv-themed-page .top-bar { align-items: flex-start; flex-direction: column; margin-bottom: 16px; border-radius: 18px; }
    body.tpv-themed-page .header-left { width: 100%; align-items: flex-start; flex-direction: column; }
    body.tpv-themed-page .header > *,
    body.tpv-themed-page .gastos-header > * { max-width: 100%; }
    body.tpv-themed-page .btn-add,
    body.tpv-themed-page .gastos-header > .btn-primary { width: 100%; }
    body.tpv-themed-page .form-grid { grid-template-columns: 1fr; }
    body.tpv-themed-page .edit-content { width: 100%; border-radius: 0; }
    body.tpv-themed-page .allergen-grid { grid-template-columns: repeat(2, minmax(0,1fr)) !important; }
    body.tpv-themed-page .labels-header .header-fields { width: 100%; grid-template-columns: 1fr 1fr; }
    body.tpv-themed-page.editor-page { padding: 0; }
    body.tpv-themed-page.editor-page .editor-container { height: 100vh; border-radius: 0; }
    body.tpv-themed-page.editor-page .brand { width: 100%; flex-wrap: wrap; }
    body.tpv-themed-page.editor-page .controls { width: 100%; justify-content: stretch; }
    body.tpv-themed-page.editor-page .controls button { flex: 1 1 120px; }
    body.tpv-themed-page.product-page .product-header .tpv-brand-back { width: min(230px, 78vw); min-width: 0; }

    body.tpv-index-page .tpv-container { gap: 5px; padding: 5px; }
    body.tpv-index-page .ticket-panel,
    body.tpv-index-page .catalog-panel { border-radius: 14px; }
    body.tpv-index-page .ticket-panel { height: 42vh; }
    body.tpv-index-page .catalog-panel { height: 58vh; padding: 6px; }
    body.tpv-index-page .tpv-top-menu { display: flex; overflow-x: auto; justify-content: flex-start; scrollbar-width: thin; }
    body.tpv-index-page .menu-item { min-width: 68px; flex: 0 0 auto; }
    body.tpv-index-page .catalog-header { gap: 6px; margin-block: 6px; }
    body.tpv-index-page .catalog-header .search-bar { min-width: 0; flex: 1; }
    body.tpv-index-page .btn-exit { padding-inline: 10px; }
    body.tpv-index-page .product-grid { gap: 8px; grid-template-columns: repeat(2, minmax(0,1fr)); }
    body.tpv-index-page .ticket-actions { gap: 4px; overflow-x: auto; }
    body.tpv-index-page .ticket-actions > button { width: 36px !important; height: 36px !important; min-width: 36px; margin-right: 0 !important; }
    body.tpv-index-page .action-buttons { gap: 6px !important; }
    body.tpv-index-page .btn-pay { min-width: 0; font-size: .72rem; }
}

@media (max-width: 420px) {
    .tpv-brand-back { width: 132px; min-width: 132px; }
    body.tpv-themed-page .labels-header .header-fields { grid-template-columns: 1fr; }
    body.tpv-index-page .ticket-panel { height: 44vh; }
    body.tpv-index-page .catalog-panel { height: 56vh; }
    body.tpv-index-page .product-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
    body.tpv-index-page .cat-pill { padding-inline: 10px; }
}

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

/* Etiquetas: cabecera espaciosa, regreso compacto y acción de impresión prioritaria. */
body.tpv-themed-page.labels-page .labels-header {
    display: grid;
    grid-template-columns: 60px minmax(0, 492px) minmax(298px, 1fr);
    align-items: end;
    gap: 10px;
    padding: 14px 16px;
}

body.tpv-themed-page.labels-page .labels-header .tpv-brand-back {
    width: 60px;
    min-width: 60px;
    height: 60px;
    min-height: 60px;
    padding: 6px;
    border-radius: 14px;
}

body.tpv-themed-page.labels-page .labels-header .tpv-brand-back img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

body.tpv-themed-page.labels-page .header-fields {
    grid-template-columns: 108px 108px 38px 120px 86px;
    gap: 8px;
}

body.tpv-themed-page.labels-page .header-fields label { gap: 5px; }
body.tpv-themed-page.labels-page .header-fields select,
body.tpv-themed-page.labels-page .header-fields input { height: 42px; min-height: 42px; padding-inline: 7px; font-size: .72rem; }
body.tpv-themed-page.labels-page .paper-controls { gap: 7px; }
body.tpv-themed-page.labels-page .paper-options { gap: 6px; }
body.tpv-themed-page.labels-page .paper-option,
body.tpv-themed-page.labels-page .custom-paper-option { height: 42px; border-radius: 10px; }
body.tpv-themed-page.labels-page .paper-option { min-width: 54px; padding-inline: 7px; }
body.tpv-themed-page.labels-page .custom-paper-option { min-width: 72px; padding-inline: 5px; }
body.tpv-themed-page.labels-page .custom-paper-option input[type="number"] { width: 100%; }

body.tpv-themed-page.labels-page .btn-print {
    display: flex;
    width: auto;
    min-width: 108px;
    height: 44px;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 0 13px;
    color: #fff;
    background: linear-gradient(135deg, #ff7a36, #e9541d);
    font-size: .88rem;
    font-weight: 900;
    letter-spacing: .02em;
    box-shadow: 0 10px 24px rgba(238, 106, 50, .36);
}

body.tpv-themed-page.labels-page .btn-print i { font-size: 1.05rem; }
body.tpv-themed-page.labels-page .btn-print:hover { background: linear-gradient(135deg, #ff8b50, #c94e20); }

@media (max-width: 900px) {
    body.tpv-themed-page.labels-page .labels-header { grid-template-columns: 68px minmax(0, 1fr); align-items: center; }
    body.tpv-themed-page.labels-page .paper-controls { grid-column: 2; justify-content: flex-start; }
}

@media (max-width: 820px) {
    body.tpv-themed-page.labels-page .labels-header { grid-template-columns: 62px minmax(0, 1fr); padding: 16px; }
    body.tpv-themed-page.labels-page .labels-header .tpv-brand-back { width: 62px; min-width: 62px; height: 62px; min-height: 62px; }
    body.tpv-themed-page.labels-page .header-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    body.tpv-themed-page.labels-page .paper-controls { grid-column: 1 / -1; justify-content: space-between; }
}

@media (max-width: 520px) {
    body.tpv-themed-page.labels-page .labels-header { grid-template-columns: 1fr; gap: 14px; }
    body.tpv-themed-page.labels-page .labels-header .tpv-brand-back { width: 58px; min-width: 58px; height: 58px; min-height: 58px; }
    body.tpv-themed-page.labels-page .header-fields { grid-template-columns: 1fr; }
    body.tpv-themed-page.labels-page .paper-controls { display: grid; grid-template-columns: 1fr; }
    body.tpv-themed-page.labels-page .paper-options { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); width: 100%; }
    body.tpv-themed-page.labels-page .btn-print { width: 100%; }
}
