:root {
    color-scheme: light;
    --primary: #3d5c2e;
    --primary-strong: #2a3f20;
    --primary-light: #5a7348;
    --accent: #c4a35a;
    --accent-strong: #9a7b3c;
    --danger: #8b2914;
    --danger-bg: #f5ddd8;
    --warning-bg: #f0e4c8;
    --ok-bg: #d8e8d0;
    --border: #9aab8c;
    --surface: #f4f0e6;
    --surface-alt: #ebe5d6;
    --text: #1a2318;
    --muted: #5c6b52;
    --sidebar-text: #e8edd8;
    font-family: "Segoe UI", Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

* {
    box-sizing: border-box;
}

html {
    overflow-x: clip;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    margin: 0;
    background-color: #3a4a32;
    background-image:
        radial-gradient(ellipse 120px 80px at 15% 25%, rgba(74, 93, 58, 0.95) 0%, transparent 70%),
        radial-gradient(ellipse 100px 90px at 75% 15%, rgba(58, 74, 47, 0.9) 0%, transparent 70%),
        radial-gradient(ellipse 140px 70px at 55% 65%, rgba(90, 115, 72, 0.85) 0%, transparent 70%),
        radial-gradient(ellipse 90px 100px at 25% 80%, rgba(45, 58, 36, 0.9) 0%, transparent 70%),
        radial-gradient(ellipse 110px 85px at 85% 75%, rgba(61, 92, 46, 0.8) 0%, transparent 70%),
        linear-gradient(160deg, #2d3a26 0%, #3d4f34 40%, #4a5c3f 100%);
    background-attachment: fixed;
    color: var(--text);
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: clip;
}

body.nav-open {
    overflow: hidden;
    touch-action: none;
}

.shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 270px;
    background:
        linear-gradient(180deg, rgba(26, 35, 24, 0.97) 0%, rgba(42, 63, 32, 0.98) 100%),
        radial-gradient(ellipse 80px 60px at 30% 20%, rgba(74, 93, 58, 0.5) 0%, transparent 70%),
        radial-gradient(ellipse 70px 50px at 70% 60%, rgba(58, 74, 47, 0.4) 0%, transparent 70%);
    color: white;
    padding: 1.5rem;
    border-right: 3px solid var(--accent);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.25);
}

.brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .45rem;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid rgba(196, 163, 90, 0.35);
    text-align: center;
}

.brand-logo {
    width: min(100%, 118px);
    height: auto;
    display: block;
    margin: 0 auto .15rem;
    filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.35));
}

.brand strong {
    font-size: 1.05rem;
    letter-spacing: 0.04em;
    color: var(--accent);
}

.brand small {
    color: var(--sidebar-text);
    opacity: 0.85;
}

.nav-menu {
    display: grid;
    gap: .4rem;
}

.nav-menu a {
    color: var(--sidebar-text);
    text-decoration: none;
    padding: .8rem 1rem;
    border-radius: .65rem;
    border: 1px solid transparent;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: .6rem;
    transition: background .15s, border-color .15s, color .15s;
}

.nav-icon {
    color: var(--accent);
    font-size: .65rem;
}

.nav-menu a.active {
    background: rgba(196, 163, 90, 0.18);
    border-color: rgba(196, 163, 90, 0.45);
    color: #fff;
}

.nav-menu a:hover {
    background: rgba(90, 115, 72, 0.45);
    border-color: rgba(196, 163, 90, 0.3);
    color: #fff;
}

.content {
    flex: 1;
    min-width: 0;
}

.top-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 1rem 2rem;
    border-bottom: 2px solid var(--primary);
    background: linear-gradient(90deg, var(--surface) 0%, var(--surface-alt) 100%);
    color: var(--muted);
    font-weight: 600;
}

.operation-mode {
    color: var(--primary-strong);
    background: var(--ok-bg);
    border: 1px solid var(--primary-light);
    border-radius: 999px;
    padding: .4rem .9rem;
    font-size: .9rem;
}

.page-body {
    padding: 2rem;
}

h1 {
    color: #f4f0e6;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
    margin-top: 0;
}

h2 {
    display: flex;
    align-items: center;
    gap: .65rem;
    margin-top: 0;
    color: var(--primary-strong);
}

.panel,
.card {
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: .85rem;
    padding: 1.25rem;
    margin-bottom: 1.25rem;
    box-shadow: 0 6px 20px rgba(26, 35, 24, 0.12);
}

.panel-editing {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(196, 163, 90, 0.25), 0 8px 24px rgba(26, 35, 24, 0.15);
    background: linear-gradient(180deg, #faf7ef 0%, var(--surface) 100%);
}

.step-panel {
    border-left: 5px solid var(--primary);
}

.step-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2rem;
    height: 2rem;
    padding: 0 .5rem;
    border-radius: 999px;
    background: var(--primary);
    color: #fff;
    font-weight: 800;
    font-size: .95rem;
    flex-shrink: 0;
}

.step-badge.edit {
    background: var(--accent-strong);
    color: #fff;
}

.grid {
    display: grid;
    gap: 1rem;
}

.two-columns {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.cards {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.product-entry,
.filters {
    grid-template-columns: 2fr 3fr 1fr 1fr 1fr;
    align-items: end;
}

.client-entry,
.stock-filters {
    grid-template-columns: 2fr 1fr 1fr;
    align-items: end;
}

.stock-recuento {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: .35rem .7rem;
    margin: .85rem 0 1rem;
    padding: .85rem 1.1rem;
    background: var(--ok-bg);
    border: 2px solid #a8c49c;
    border-radius: .75rem;
    color: #2d5a24;
    font-weight: 600;
}

.stock-recuento-label {
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-size: .9rem;
}

.stock-recuento-total {
    font-size: 1.65rem;
    color: var(--primary-strong);
    line-height: 1;
}

.table-cards tfoot th,
.table-cards tfoot td {
    background: var(--surface-alt);
    font-weight: 700;
    text-transform: none;
    letter-spacing: normal;
}

.table-cards tfoot th:empty,
.table-cards tfoot td:empty {
    display: none;
}

.client-form {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-items: end;
    margin-bottom: 1rem;
}

.clu-form,
.sale-header {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-items: end;
}

.client-filters {
    grid-template-columns: 2fr 1fr;
    align-items: end;
    margin-bottom: 1rem;
}

.sales-filters {
    grid-template-columns: 1fr 1fr 3fr 1fr auto;
    align-items: end;
}

.stock-form {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-items: end;
    margin-bottom: 1rem;
}

.metric-label {
    display: block;
    color: var(--muted);
    margin-bottom: .35rem;
    font-size: .9rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.card strong {
    font-size: 1.8rem;
    color: var(--primary-strong);
}

.warning-card {
    background: var(--warning-bg);
    border-color: #c9a84a;
}

.danger-card {
    background: var(--danger-bg);
    color: var(--danger);
    border-color: #c47a6a;
}

.saldo-pendiente {
    color: var(--danger);
}

.input {
    width: 100%;
    box-sizing: border-box;
    border: 2px solid var(--border);
    border-radius: .55rem;
    padding: .7rem .8rem;
    margin-top: .35rem;
    background: #fff;
    color: var(--text);
    font-size: 1rem;
    transition: border-color .15s, box-shadow .15s;
}

.input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(61, 92, 46, 0.2);
}

label {
    font-weight: 700;
    color: var(--primary-strong);
    font-size: .92rem;
}

.button,
.link-button {
    border: 0;
    border-radius: .55rem;
    padding: .75rem 1.1rem;
    min-height: 44px;
    touch-action: manipulation;
    background: var(--surface-alt);
    color: var(--text);
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    font-weight: 700;
    font-size: .95rem;
    border: 2px solid var(--border);
    transition: transform .1s, box-shadow .15s, background .15s;
}

.button:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(26, 35, 24, 0.15);
}

.button.primary {
    background: linear-gradient(180deg, var(--primary-light) 0%, var(--primary) 100%);
    color: white;
    border-color: var(--primary-strong);
}

.button.primary:hover:not(:disabled) {
    background: linear-gradient(180deg, var(--primary) 0%, var(--primary-strong) 100%);
}

.button.ghost {
    background: transparent;
    border: 2px solid var(--border);
    color: var(--primary-strong);
}

.button.btn-edit {
    background: var(--accent);
    color: var(--primary-strong);
    border-color: var(--accent-strong);
    padding: .45rem .85rem;
    font-size: .85rem;
}

.button.btn-edit:hover:not(:disabled) {
    background: #d4b36a;
}

.button.btn-delete {
    background: var(--danger-bg);
    color: var(--danger);
    border-color: #c47a6a;
    padding: .45rem .85rem;
    font-size: .85rem;
}

.button.btn-delete:hover:not(:disabled) {
    background: #e8b8ae;
}

.button:disabled {
    cursor: not-allowed;
    opacity: .5;
    transform: none;
    box-shadow: none;
}

.link-button {
    background: transparent;
    color: var(--primary);
    padding: 0;
    border: 0;
    font-weight: 700;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid var(--border);
    border-radius: .65rem;
    max-width: 100%;
}

.table-wrap > table {
    min-width: 0;
}

.table-cards {
    min-width: 100%;
}

.confirm-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.25rem;
    background: rgba(10, 14, 8, 0.62);
    backdrop-filter: blur(2px);
}

.ui-dialog {
    border: none;
    padding: 0;
    margin: auto;
    max-width: calc(100vw - 2.5rem);
    max-height: calc(100dvh - 2.5rem);
    overflow: visible;
    background: transparent;
    color: var(--text);
}

.ui-dialog::backdrop {
    background: rgba(10, 14, 8, 0.62);
    backdrop-filter: blur(2px);
}

.ui-dialog:not([open]) {
    display: none;
}

.confirm-panel {
    width: min(100%, 400px);
    margin: 0;
    padding: 1.5rem 1.35rem 1.25rem;
    text-align: center;
    background: linear-gradient(180deg, #faf7ef 0%, var(--warning-bg) 100%);
    border: 2px solid #c9a84a;
    border-radius: .9rem;
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.35);
    animation: confirm-pop .18s ease-out;
}

.confirm-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 3rem;
    height: 3rem;
    margin: 0 auto .75rem;
    border-radius: 999px;
    background: #6b4f0a;
    color: #fff;
    font-size: 1.6rem;
    font-weight: 800;
    line-height: 1;
}

.confirm-panel h3 {
    margin: 0 0 .65rem;
    color: #6b4f0a;
    font-size: 1.15rem;
    justify-content: center;
}

.confirm-panel p {
    margin: 0 0 1.25rem;
    color: var(--text);
    line-height: 1.45;
}

.confirm-actions {
    display: flex;
    flex-wrap: wrap;
    gap: .65rem;
    justify-content: center;
}

.confirm-actions .button {
    min-width: 7.5rem;
}

@keyframes confirm-pop {
    from {
        opacity: 0;
        transform: scale(0.94) translateY(8px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.alert-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    z-index: 2100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.25rem;
    background: rgba(10, 14, 8, 0.62);
    backdrop-filter: blur(2px);
}

.alert-panel {
    width: min(100%, 420px);
    margin: 0;
    padding: 1.5rem 1.35rem 1.25rem;
    text-align: center;
    border-radius: .9rem;
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.35);
    animation: confirm-pop .18s ease-out;
}

.alert-panel.error {
    background: linear-gradient(180deg, #fff5f5 0%, #f8d7da 100%);
    border: 2px solid #b85c5c;
}

.alert-panel.warning {
    background: linear-gradient(180deg, #faf7ef 0%, var(--warning-bg) 100%);
    border: 2px solid #c9a84a;
}

.alert-panel.success {
    background: linear-gradient(180deg, #f4fff6 0%, #d4edda 100%);
    border: 2px solid #4a7c59;
}

.alert-panel.info {
    background: linear-gradient(180deg, #f7fbff 0%, #d9ecf7 100%);
    border: 2px solid #5a7f9a;
}

.alert-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 3rem;
    height: 3rem;
    margin: 0 auto .75rem;
    border-radius: 999px;
    color: #fff;
    font-size: 1.45rem;
    font-weight: 800;
    line-height: 1;
}

.alert-panel.error .alert-icon {
    background: #9b3b3b;
}

.alert-panel.warning .alert-icon {
    background: #6b4f0a;
}

.alert-panel.success .alert-icon {
    background: #2f6b3f;
}

.alert-panel.info .alert-icon {
    background: #3d6278;
}

.alert-panel h3 {
    margin: 0 0 .65rem;
    font-size: 1.15rem;
}

.alert-panel.error h3 {
    color: #7a2e2e;
}

.alert-panel.warning h3 {
    color: #6b4f0a;
}

.alert-panel.success h3 {
    color: #2f6b3f;
}

.alert-panel.info h3 {
    color: #3d6278;
}

.alert-message {
    margin: 0 0 1.25rem;
    color: var(--text);
    line-height: 1.45;
    white-space: pre-line;
}

.alert-actions {
    display: flex;
    justify-content: center;
}

.alert-actions .button {
    min-width: 8rem;
}

.menu-toggle,
.nav-backdrop {
    display: none;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    text-align: left;
    border-bottom: 1px solid var(--border);
    padding: .8rem;
    vertical-align: top;
}

th {
    background: linear-gradient(180deg, #e0e8d8 0%, #d4dcc8 100%);
    color: var(--primary-strong);
    font-size: .85rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

tbody tr:hover {
    background: rgba(216, 232, 208, 0.35);
}

.alert {
    border-radius: .75rem;
    padding: 1rem 1.1rem;
    margin-bottom: 1rem;
    border: 2px solid transparent;
    font-weight: 600;
}

.alert-danger,
.danger-row {
    background: var(--danger-bg);
    color: var(--danger);
    border-color: #d4a59a;
}

.alert-success {
    background: var(--ok-bg);
    color: #2d5a24;
    border-color: #a8c49c;
}

.alert-info {
    background: #e8f0f8;
    color: #1a4a6e;
    border-color: #a8c4dc;
}

.badge {
    display: inline-flex;
    border-radius: 999px;
    padding: .35rem .7rem;
    font-weight: 800;
    font-size: .8rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.badge.danger {
    background: var(--danger-bg);
    color: var(--danger);
}

.badge.warning {
    background: var(--warning-bg);
    color: #6b4f0a;
}

.badge.ok {
    background: var(--ok-bg);
    color: #2d5a24;
}

.badge.muted {
    background: #e4e8de;
    color: var(--muted);
}

.clu-card {
    margin-top: 1rem;
    padding: .85rem 1rem;
    border-radius: .75rem;
    border: 1px solid transparent;
}

.clu-card.ok {
    background: var(--ok-bg);
    border-color: #a8c49c;
}

.clu-card.warning {
    background: var(--warning-bg);
    color: #6b4f0a;
    border-color: #d4b86a;
}

.clu-card.expired {
    background: var(--danger-bg);
    color: var(--danger);
    border-color: #d4a59a;
}

.subpanel {
    border: 2px dashed var(--border);
    border-radius: .85rem;
    padding: 1rem;
    margin: 1rem 0;
    background: rgba(255, 255, 255, 0.5);
}

.checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    margin-bottom: .75rem;
    font-weight: 700;
    color: var(--primary-strong);
}

.warning-row {
    background: var(--warning-bg);
    color: #6b4f0a;
}

.product-alerts {
    display: grid;
    gap: .75rem;
    margin: 1rem 0;
}

.totals {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 2rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 2px solid var(--border);
}

.totals > div {
    display: grid;
    gap: .3rem;
    text-align: right;
}

.totals strong {
    font-size: 1.4rem;
    color: var(--primary-strong);
}

.section-header,
.actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.section-header {
    margin-bottom: 1rem;
}

.section-actions {
    display: flex;
    align-items: center;
    gap: .75rem;
    flex-wrap: wrap;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.button.disabled {
    pointer-events: none;
    opacity: .55;
}

.hint {
    color: var(--muted);
    margin-top: -.5rem;
}

.section-header h2,
.section-header p {
    margin: 0;
}

.section-header p,
td small {
    color: var(--muted);
    font-weight: 500;
}

td small {
    display: block;
    margin-top: .25rem;
}

.actions {
    justify-content: flex-start;
    margin-top: 1rem;
    flex-wrap: wrap;
}

.row-actions {
    display: grid;
    gap: .5rem;
}

.sale-detail-row > td {
    background: var(--surface-alt);
    padding: 0;
}

.sale-detail {
    padding: 1rem;
}

.sale-detail table {
    background: white;
}

.ticket {
    max-width: 420px;
    background: white;
    padding: 1.5rem;
    border: 1px solid var(--border);
}

.ticket header,
.ticket footer {
    text-align: center;
}

.ticket small {
    display: block;
    color: var(--muted);
}

.login-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 2rem;
    background:
        radial-gradient(ellipse 200px 150px at 20% 30%, rgba(74, 93, 58, 0.6) 0%, transparent 70%),
        radial-gradient(ellipse 180px 140px at 80% 70%, rgba(58, 74, 47, 0.5) 0%, transparent 70%),
        linear-gradient(160deg, #2d3a26 0%, #3d4f34 50%, #4a5c3f 100%);
}

.login-card {
    width: min(100%, 420px);
    border: 2px solid var(--accent);
    text-align: center;
}

.login-brand {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    margin: 0 0 1rem;
}

.login-brand picture {
    display: block;
    margin: 0 auto;
    line-height: 0;
}

.login-logo {
    display: block;
    margin: 0 auto;
    width: min(72%, 200px);
    max-width: 200px;
    height: auto;
    border-radius: 1rem;
    border: 2px solid rgba(196, 163, 90, 0.55);
    box-shadow: 0 8px 22px rgba(26, 35, 24, 0.22);
    background: #1a2318;
}

.login-card h1 {
    margin: 0 0 .65rem;
    color: var(--primary-strong);
    text-shadow: none;
    text-align: center;
    font-size: 1.35rem;
}

.login-card > p {
    text-align: center;
    color: var(--muted);
    margin-top: 0;
}

.login-card .button.primary {
    width: 100%;
    margin-top: .5rem;
}

.login-card label {
    display: block;
    margin-bottom: 1rem;
    text-align: left;
}

.pwa-install {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2200;
    padding: .75rem max(.75rem, env(safe-area-inset-right)) max(.75rem, env(safe-area-inset-bottom)) max(.75rem, env(safe-area-inset-left));
    pointer-events: none;
}

.pwa-install-card {
    pointer-events: auto;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: .85rem;
    max-width: 560px;
    margin: 0 auto;
    padding: 1rem 1.1rem;
    background: linear-gradient(180deg, #faf7ef 0%, var(--surface) 100%);
    border: 2px solid var(--accent);
    border-radius: .9rem;
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.28);
}

.pwa-install-copy {
    flex: 1 1 180px;
    min-width: 0;
}

.pwa-install-copy strong {
    display: block;
    color: var(--primary-strong);
    margin-bottom: .25rem;
}

.pwa-install-copy p {
    margin: 0;
    color: var(--muted);
    font-size: .92rem;
    line-height: 1.35;
}

.pwa-install-actions {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
}

.pwa-install-actions .button {
    min-height: 42px;
}

@media (display-mode: standalone), (display-mode: fullscreen) {
    .pwa-install {
        display: none !important;
    }
}

.user-chip {
    margin-bottom: 1.5rem;
    padding: .85rem 1rem;
    border-radius: .75rem;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(196, 163, 90, 0.25);
}

.user-chip small {
    color: var(--sidebar-text);
    opacity: 0.85;
}

.logout-button {
    margin-top: 1.5rem;
    width: 100%;
    color: var(--sidebar-text);
    border-color: rgba(196, 163, 90, 0.35);
}

.logout-button:hover:not(:disabled) {
    background: rgba(139, 41, 20, 0.25);
    border-color: #c47a6a;
    color: #f5ddd8;
}

.client-selected {
    margin-top: 1rem;
}

.sale-checklist {
    list-style: none;
    padding: .85rem 1rem;
    margin: 1rem 0;
    display: grid;
    gap: .45rem;
    background: var(--surface-alt);
    border-radius: .65rem;
    border: 1px solid var(--border);
}

.sale-checklist .ok {
    color: #2d5a24;
    font-weight: 700;
}

.sale-checklist .pending {
    color: var(--muted);
}

.sale-hint {
    color: var(--muted);
    margin: 0 0 1rem;
    font-weight: 600;
}

.sale-hint {
    color: var(--muted);
    margin: 0 0 1rem;
    font-weight: 600;
}

.page-intro {
    color: #e8edd8;
    margin: -.5rem 0 1.25rem;
    font-size: 1.05rem;
}

.venta-flash {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.venta-rapida {
    border-left-width: 6px;
}

.venta-guardar {
    text-align: center;
}

.venta-guardar .button-xl {
    width: 100%;
    max-width: 420px;
    margin-top: 1rem;
    font-size: 1.15rem;
    padding: 1rem 1.5rem;
}

.venta-acciones-finales {
    display: grid;
    gap: .75rem;
    justify-items: center;
    margin-top: 1rem;
}

.venta-acciones-finales .button-xl {
    width: 100%;
    max-width: 420px;
    font-size: 1.05rem;
    padding: .95rem 1.25rem;
}

.cliente-venta-nuevo {
    border-color: var(--accent);
    background: rgba(255, 255, 255, .65);
}

.venta-detalle-mini {
    margin-top: 1rem;
}

.venta-total-inline {
    justify-content: flex-end;
    margin-top: .75rem;
    padding-top: 0;
    border-top: 0;
}

.page-body > p {
    color: #e8edd8;
}

@media (max-width: 980px) {
    .menu-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        position: fixed;
        top: max(.75rem, env(safe-area-inset-top));
        left: max(.75rem, env(safe-area-inset-left));
        z-index: 1100;
        width: 2.75rem;
        height: 2.75rem;
        padding: 0;
        border-radius: .65rem;
        background: var(--primary);
        color: #fff;
        border: 2px solid var(--accent);
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
        font-size: 1.2rem;
        line-height: 1;
    }

    .nav-backdrop {
        display: none;
        position: fixed;
        inset: 0;
        z-index: 1040;
        border: 0;
        padding: 0;
        background: rgba(10, 14, 8, 0.55);
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }

    .shell.nav-open .nav-backdrop {
        display: block;
    }

    .shell {
        display: block;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        z-index: 1050;
        width: min(290px, 88vw);
        height: 100vh;
        height: 100dvh;
        margin: 0;
        padding: calc(1.25rem + env(safe-area-inset-top)) 1rem calc(1.5rem + env(safe-area-inset-bottom));
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        border-right: 3px solid var(--accent);
        border-bottom: 0;
        transform: translateX(-105%);
        transition: transform .25s ease;
        box-shadow: 8px 0 32px rgba(0, 0, 0, 0.35);
        visibility: hidden;
        pointer-events: none;
    }

    .shell.nav-open .sidebar {
        transform: translateX(0);
        visibility: visible;
        pointer-events: auto;
    }

    .content {
        width: 100%;
        max-width: 100%;
    }

    .top-row {
        position: sticky;
        top: 0;
        z-index: 100;
        flex-wrap: wrap;
        gap: .5rem;
        padding: .85rem max(1rem, env(safe-area-inset-right)) .85rem 3.75rem;
        box-shadow: 0 2px 10px rgba(26, 35, 24, 0.12);
    }

    .top-row-title {
        flex: 1 1 100%;
        font-size: .9rem;
        line-height: 1.35;
    }

    .operation-mode {
        font-size: .8rem;
        padding: .35rem .7rem;
    }

    .page-body {
        padding: 1rem max(1rem, env(safe-area-inset-right)) calc(1.5rem + env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
    }

    h1 {
        font-size: 1.55rem;
        line-height: 1.25;
    }

    .page-intro {
        font-size: .98rem;
    }

    .cards {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .two-columns,
    .client-entry,
    .client-form,
    .clu-form,
    .client-filters,
    .product-entry,
    .filters,
    .sale-header,
    .sales-filters,
    .stock-filters,
    .stock-form {
        grid-template-columns: 1fr;
    }

    .section-header {
        flex-direction: column;
        align-items: stretch;
    }

    .section-header .actions,
    .section-header .button {
        width: 100%;
    }

    .section-header label {
        width: 100%;
    }

    .venta-flash {
        flex-direction: column;
        align-items: stretch;
    }

    .venta-flash .button {
        width: 100%;
    }

    .totals {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }

    .totals > div {
        text-align: left;
    }

    .row-actions {
        min-width: 0;
        display: flex;
        flex-wrap: wrap;
        gap: .5rem;
    }

    th,
    td {
        padding: .6rem .5rem;
        font-size: .86rem;
    }

    .card strong {
        font-size: 1.45rem;
    }

    .login-shell {
        padding: 1rem;
        align-items: flex-start;
        padding-top: max(2rem, env(safe-area-inset-top));
        padding-bottom: max(1rem, env(safe-area-inset-bottom));
    }

    .login-logo {
        width: min(58%, 168px);
        max-width: 168px;
        border-radius: .85rem;
    }

    /* Listados: filas como tarjetas en lugar de tabla horizontal */
    .table-cards thead {
        display: none;
    }

    .table-cards,
    .table-cards tbody {
        display: block;
        width: 100%;
    }

    .table-cards > tbody > tr:not(.sale-detail-row) {
        display: block;
        margin: 0 0 .85rem;
        padding: .85rem 1rem;
        background: #fff;
        border: 2px solid var(--border);
        border-radius: .75rem;
        box-shadow: 0 3px 10px rgba(26, 35, 24, 0.08);
    }

    .table-cards > tbody > tr:not(.sale-detail-row):last-child {
        margin-bottom: 0;
    }

    .table-cards > tbody > tr:not(.sale-detail-row):hover {
        background: #fff;
    }

    .table-cards > tbody > tr.danger-row:not(.sale-detail-row),
    .table-cards > tbody > tr.warning-row:not(.sale-detail-row) {
        border-left-width: 5px;
    }

    .table-cards > tbody > tr.danger-row:not(.sale-detail-row) {
        background: var(--danger-bg);
        border-left-color: var(--danger);
    }

    .table-cards > tbody > tr.warning-row:not(.sale-detail-row) {
        background: var(--warning-bg);
        border-left-color: #c9a84a;
    }

    .table-cards > tbody > tr:not(.sale-detail-row) > td {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        gap: .75rem;
        border-bottom: 1px solid rgba(154, 171, 140, 0.45);
        padding: .55rem 0;
        text-align: right;
    }

    .table-cards > tbody > tr:not(.sale-detail-row) > td:last-child {
        border-bottom: 0;
        padding-bottom: 0;
    }

    .table-cards > tbody > tr:not(.sale-detail-row) > td:first-child {
        padding-top: 0;
    }

    .table-cards > tbody > tr:not(.sale-detail-row) > td[data-label]::before {
        content: attr(data-label);
        flex: 0 0 auto;
        max-width: 42%;
        text-align: left;
        font-weight: 800;
        font-size: .78rem;
        text-transform: uppercase;
        letter-spacing: 0.03em;
        color: var(--muted);
    }

    .table-cards > tbody > tr:not(.sale-detail-row) > td:not([data-label]),
    .table-cards > tbody > tr:not(.sale-detail-row) > td[data-label=""],
    .table-cards > tbody > tr:not(.sale-detail-row) > td.row-actions {
        display: block;
        text-align: left;
    }

    .table-cards > tbody > tr:not(.sale-detail-row) > td:not([data-label])::before,
    .table-cards > tbody > tr:not(.sale-detail-row) > td[data-label=""]::before {
        display: none;
    }

    .table-cards > tbody > tr:not(.sale-detail-row) > td[colspan] {
        display: block;
        text-align: left;
    }

    .table-cards > tbody > tr:not(.sale-detail-row) > td[colspan]::before {
        display: none;
    }

    .table-cards > tbody > tr:not(.sale-detail-row) > td.row-actions,
    .table-cards > tbody > tr:not(.sale-detail-row) > td:has(.row-actions) {
        padding-top: .75rem;
        margin-top: .25rem;
        border-top: 1px dashed var(--border);
        border-bottom: 0;
    }

    .table-cards > tbody > tr:not(.sale-detail-row) > td .row-actions {
        width: 100%;
    }

    .table-cards > tbody > tr:not(.sale-detail-row) > td .button,
    .table-cards > tbody > tr:not(.sale-detail-row) > td .link-button {
        flex: 1 1 auto;
        min-width: calc(50% - .35rem);
    }

    .table-cards tfoot {
        display: block;
        margin-top: .75rem;
        padding: .85rem 1rem;
        background: var(--surface-alt);
        border: 2px solid var(--border);
        border-radius: .75rem;
    }

    .table-cards tfoot tr,
    .table-cards tfoot th {
        display: block;
        width: 100%;
        border: 0;
        padding: .25rem 0;
        background: transparent;
        text-align: left;
        text-transform: none;
        letter-spacing: normal;
        font-size: .95rem;
    }

    .table-cards > tbody > tr.sale-detail-row {
        display: block;
        margin: -.55rem 0 .85rem;
        padding: 0;
        border: 0;
        background: transparent;
        box-shadow: none;
    }

    .table-cards > tbody > tr.sale-detail-row > td {
        display: block;
        padding: 0;
        border: 0;
    }

    .sale-detail {
        border: 2px solid var(--border);
        border-radius: .75rem;
        background: var(--surface-alt);
    }

    .table-wrap:has(.table-cards) {
        border: 0;
        background: transparent;
        overflow: visible;
    }
}

@media (max-width: 560px) {
    .cards {
        grid-template-columns: 1fr;
    }

    .page-body {
        padding: .85rem max(.85rem, env(safe-area-inset-right)) calc(1.25rem + env(safe-area-inset-bottom)) max(.85rem, env(safe-area-inset-left));
    }

    .panel,
    .card {
        padding: 1rem;
    }

    .input,
    .button,
    select.input {
        font-size: 16px;
    }

    .button.btn-edit,
    .button.btn-delete {
        min-height: 44px;
        padding: .55rem .85rem;
        font-size: .9rem;
    }

    .link-button {
        min-height: auto;
        padding: .35rem 0;
    }

    .actions {
        flex-direction: column;
        align-items: stretch;
    }

    .actions .button,
    .actions .link-button {
        width: 100%;
    }

    .section-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .section-actions .button {
        width: 100%;
    }

    td .button,
    td .link-button {
        width: 100%;
    }

    .row-actions {
        min-width: 0;
        flex-direction: column;
    }

    .row-actions .button,
    .row-actions .link-button {
        width: 100%;
        min-width: 0;
    }

    .sale-detail {
        padding: .75rem;
    }

    .sale-detail table {
        font-size: .82rem;
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .step-badge {
        min-width: 1.75rem;
        height: 1.75rem;
        font-size: .85rem;
    }

    h2 {
        font-size: 1.1rem;
        flex-wrap: wrap;
    }

    .confirm-actions .button,
    .alert-actions .button {
        width: 100%;
        min-width: 0;
    }

    .venta-acciones-finales .button-xl,
    .venta-guardar .button-xl {
        max-width: none;
    }

    .pwa-install-card {
        flex-direction: column;
        align-items: stretch;
    }

    .pwa-install-actions {
        flex-direction: column;
    }

    .pwa-install-actions .button {
        width: 100%;
    }
}

@media print {
    body {
        background: white;
    }

    .no-print,
    .sidebar,
    .top-row,
    .button {
        display: none !important;
    }

    .shell,
    .content,
    .page-body {
        display: block;
        padding: 0;
        margin: 0;
    }

    h1 {
        color: #000;
        text-shadow: none;
    }

    .panel,
    .card,
    .ticket {
        box-shadow: none;
        border-color: #999;
        break-inside: avoid;
    }

    .print-area {
        margin: 0;
    }
}
