:root {
    --ink: #10233e;
    --ink-soft: #536275;
    --line: #e4e8ed;
    --paper: #ffffff;
    --canvas: #f5f6f8;
    --red: #c5232d;
    --red-dark: #a91d25;
    --blue: #173f70;
    --blue-dark: #102e53;
    --ice: #f7f9fb;
    --success: #26785b;
    --shadow: 0 18px 45px rgba(18, 34, 54, .08);
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
    font-family:
        Inter,
        ui-sans-serif,
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;
    color: var(--ink);
    background: var(--canvas);
}

button,
input {
    font: inherit;
}

button {
    cursor: pointer;
}

.login-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(340px, .95fr) minmax(480px, 1.05fr);
    background: var(--paper);
}

.login-brand {
    position: relative;
    overflow: hidden;
    padding: 54px clamp(42px, 7vw, 96px);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    color: #fff;
    background:
        radial-gradient(
            circle at 80% 18%,
            rgba(255, 255, 255, .12),
            transparent 24%
        ),
        linear-gradient(
            145deg,
            var(--blue-dark),
            var(--blue) 58%,
            #23588e
        );
}

.login-brand::after {
    content: "";
    position: absolute;
    width: 420px;
    height: 420px;
    border-radius: 50%;
    right: -220px;
    bottom: -150px;
    border: 78px solid rgba(197, 35, 45, .85);
}

.brand-mark,
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 11px;
    font-weight: 850;
    letter-spacing: .12em;
}

.brand-dot {
    width: 12px;
    height: 12px;
    flex: 0 0 auto;
    border-radius: 50%;
    background: var(--red);
    box-shadow: 0 0 0 5px rgba(197, 35, 45, .14);
}

.login-copy {
    position: relative;
    z-index: 1;
    max-width: 600px;
}

.eyebrow,
.topbar-kicker,
.status-label,
.nav-section {
    font-size: 11px;
    letter-spacing: .13em;
    font-weight: 800;
}

.login-copy .eyebrow {
    color: rgba(255,255,255,.72);
}

.login-copy h1 {
    max-width: 540px;
    margin: 20px 0 22px;
    font-size: clamp(42px, 5vw, 68px);
    line-height: .98;
    letter-spacing: -.045em;
}

.login-copy p {
    max-width: 510px;
    margin: 0;
    color: rgba(255,255,255,.78);
    font-size: 17px;
    line-height: 1.7;
}

.brand-footer {
    position: relative;
    z-index: 1;
    font-size: 11px;
    letter-spacing: .12em;
    color: rgba(255,255,255,.52);
}

.login-panel {
    padding: 42px;
    display: grid;
    place-items: center;
    background:
        linear-gradient(
            180deg,
            #fff,
            #fbfcfd
        );
}

.login-card {
    width: min(100%, 430px);
}

.mobile-brand {
    display: none;
}

.login-card .eyebrow {
    color: var(--red);
}

.login-card h2 {
    margin: 12px 0 5px;
    font-size: 38px;
    letter-spacing: -.035em;
}

.muted {
    margin: 0 0 34px;
    color: var(--ink-soft);
}

.login-form {
    display: grid;
    gap: 21px;
}

.login-form label {
    display: grid;
    gap: 8px;
    color: #354358;
    font-size: 13px;
    font-weight: 700;
}

.login-form input {
    width: 100%;
    height: 52px;
    padding: 0 15px;
    border: 1px solid #ccd4dd;
    border-radius: 10px;
    background: #fff;
    color: var(--ink);
    outline: none;
    transition:
        border-color .15s ease,
        box-shadow .15s ease;
}

.login-form input:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 4px rgba(23,63,112,.09);
}

.password-field {
    position: relative;
}

.password-field input {
    padding-right: 65px;
}

.password-toggle {
    position: absolute;
    right: 8px;
    top: 8px;
    height: 36px;
    padding: 0 10px;
    border: 0;
    border-radius: 7px;
    background: var(--ice);
    color: var(--blue);
    font-size: 12px;
    font-weight: 800;
}

.button {
    min-height: 42px;
    padding: 0 17px;
    border-radius: 9px;
    border: 0;
    font-weight: 750;
    transition:
        transform .15s ease,
        background .15s ease;
}

.button:active {
    transform: translateY(1px);
}

.button-primary {
    background: var(--red);
    color: #fff;
}

.button-primary:hover {
    background: var(--red-dark);
}

.button-full {
    width: 100%;
    min-height: 52px;
}

.button-ghost {
    border: 1px solid var(--line);
    background: #fff;
    color: var(--ink);
}

.alert {
    margin: 0 0 20px;
    padding: 13px 15px;
    border-radius: 9px;
    font-size: 13px;
    line-height: 1.5;
}

.alert-error {
    color: #92242b;
    background: #fff2f3;
    border: 1px solid #f2c9cd;
}

.login-help {
    margin: 26px 0 0;
    color: #8490a0;
    font-size: 12px;
    line-height: 1.6;
    text-align: center;
}

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 255px minmax(0, 1fr);
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 27px 20px 22px;
    display: flex;
    flex-direction: column;
    color: #fff;
    background: var(--blue-dark);
}

.sidebar-brand {
    height: 52px;
    padding: 0 11px;
    margin-bottom: 30px;
}

.sidebar-nav {
    display: grid;
    gap: 5px;
}

.nav-section {
    margin: 24px 12px 8px;
    color: rgba(255,255,255,.36);
}

.nav-item {
    min-height: 45px;
    padding: 0 12px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
    color: rgba(255,255,255,.74);
    text-decoration: none;
    font-size: 14px;
    font-weight: 650;
}

.nav-item.active {
    color: #fff;
    background: rgba(255,255,255,.1);
}

.nav-item.disabled {
    opacity: .45;
    cursor: default;
}

.nav-icon {
    width: 22px;
    text-align: center;
}

.sidebar-bottom {
    margin-top: auto;
}

.sidebar-version {
    padding: 10px 12px;
    color: rgba(255,255,255,.34);
    font-size: 10px;
    letter-spacing: .1em;
}

.workspace {
    min-width: 0;
}

.topbar {
    height: 82px;
    padding: 0 34px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    border-bottom: 1px solid var(--line);
    background: rgba(255,255,255,.96);
}

.topbar-kicker {
    color: #7b8796;
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 12px;
}

.avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: #e9eef5;
    color: var(--blue);
    font-size: 13px;
    font-weight: 850;
}

.user-meta {
    min-width: 0;
    display: grid;
}

.user-meta strong {
    font-size: 13px;
}

.user-meta span {
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #7d8997;
    font-size: 11px;
}

.mobile-menu {
    display: none;
}

.content {
    padding: 42px clamp(28px, 4vw, 58px) 60px;
}

.welcome {
    max-width: 760px;
}

.welcome .eyebrow {
    color: var(--red);
}

.welcome h1 {
    margin: 10px 0 12px;
    font-size: clamp(36px, 4vw, 52px);
    letter-spacing: -.045em;
}

.welcome p {
    margin: 0;
    color: var(--ink-soft);
    line-height: 1.7;
}

.status-grid {
    margin-top: 38px;
    display: grid;
    grid-template-columns: repeat(3, minmax(0,1fr));
    gap: 16px;
}

.status-card {
    min-height: 178px;
    padding: 23px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 8px 22px rgba(18,34,54,.035);
}

.status-label {
    color: #8591a0;
}

.status-card strong {
    display: block;
    margin: 16px 0 10px;
    font-size: 22px;
    letter-spacing: -.025em;
}

.status-card p {
    margin: 0;
    color: var(--ink-soft);
    line-height: 1.55;
    font-size: 13px;
}

.empty-state {
    margin-top: 18px;
    padding: 26px;
    display: flex;
    align-items: center;
    gap: 20px;
    border: 1px dashed #ccd4dd;
    border-radius: 14px;
    background: rgba(255,255,255,.65);
}

.empty-icon {
    width: 48px;
    height: 48px;
    flex: 0 0 auto;
    border-radius: 12px;
    display: grid;
    place-items: center;
    color: var(--blue);
    background: #eaf0f7;
    font-size: 24px;
}

.empty-state h2 {
    margin: 0 0 5px;
    font-size: 17px;
}

.empty-state p {
    margin: 0;
    color: var(--ink-soft);
    font-size: 13px;
}

@media (max-width: 900px) {
    .login-shell {
        grid-template-columns: 1fr;
    }

    .login-brand {
        display: none;
    }

    .login-panel {
        min-height: 100vh;
        padding: 28px;
    }

    .mobile-brand {
        display: block;
        margin-bottom: 48px;
        color: var(--blue);
        font-weight: 900;
        letter-spacing: .13em;
    }

    .app-shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: fixed;
        z-index: 20;
        width: 255px;
        transform: translateX(-100%);
        transition: transform .2s ease;
    }

    body.menu-open .sidebar {
        transform: translateX(0);
    }

    .mobile-menu {
        display: inline-grid;
        place-items: center;
        width: 40px;
        height: 40px;
        border: 1px solid var(--line);
        border-radius: 8px;
        background: #fff;
    }

    .topbar {
        padding: 0 20px;
        justify-content: flex-start;
    }

    .topbar > div:nth-child(2) {
        flex: 1;
    }

    .user-meta {
        display: none;
    }

    .content {
        padding: 30px 20px 50px;
    }

    .status-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 560px) {
    .topbar-kicker,
    .avatar {
        display: none;
    }

    .user-menu {
        margin-left: auto;
    }

    .welcome h1 {
        font-size: 36px;
    }
}

/* FASE 3 - BLOQUE A */

.topbar-context {
    min-width: 230px;
}

.current-local {
    display: grid;
    gap: 3px;
}

.current-local span,
.local-switcher label > span {
    display: block;
    color: #8490a0;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .13em;
}

.current-local strong {
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 14px;
}

.local-switcher label {
    display: grid;
    gap: 5px;
}

.local-switcher select {
    min-width: 220px;
    height: 38px;
    padding: 0 34px 0 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--ink);
    font: inherit;
    font-size: 13px;
    font-weight: 700;
    outline: none;
}

.local-switcher select:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(23,63,112,.08);
}

@media (max-width: 900px) {
    .topbar-context {
        min-width: 0;
        flex: 1;
    }

    .local-switcher select {
        width: 100%;
        min-width: 120px;
        max-width: 230px;
    }
}

@media (max-width: 560px) {
    .current-local span,
    .local-switcher label > span {
        display: none;
    }

    .local-switcher select {
        max-width: 155px;
    }
}

/* =====================================================
   FASE 3 - BLOQUE B2
   ===================================================== */

.alert-success {
    border: 1px solid #bee2d4;
    color: #24664f;
    background: #eef9f5;
}

.panel-section {
    margin-top: 34px;
}

.section-heading {
    margin-bottom: 24px;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 24px;
}

.section-heading.compact {
    margin-bottom: 18px;
}

.section-heading h1 {
    margin: 8px 0 7px;
    font-size: clamp(32px, 4vw, 46px);
    line-height: 1;
    letter-spacing: -.04em;
}

.section-heading h2 {
    margin: 5px 0;
}

.section-heading p {
    margin: 0;
    color: var(--ink-soft);
}

.module-grid {
    display: grid;
    grid-template-columns:
        repeat(3, minmax(0,1fr));
    gap: 12px;
}

.module-card {
    padding: 18px;
    border-radius: 12px;
    display: grid;
    gap: 7px;
    border: 1px solid var(--line);
    background: #fff;
}

.module-card strong {
    font-size: 12px;
}

.module-card span {
    font-size: 12px;
    color: var(--ink-soft);
}

.module-card.enabled {
    border-color: #b9ddd0;
}

.disabled-module {
    opacity: .48;
}

.admin-form {
    display: grid;
    gap: 20px;
}

.form-card {
    padding: 25px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #fff;
    box-shadow:
        0 8px 22px
        rgba(18,34,54,.035);
}

.form-card > h2 {
    margin: 0 0 22px;
    font-size: 20px;
}

.form-grid {
    display: grid;
    grid-template-columns:
        repeat(2, minmax(0,1fr));
    gap: 18px;
}

.form-grid label {
    display: grid;
    gap: 7px;
    color: #3e4a5b;
    font-size: 12px;
    font-weight: 750;
}

.form-grid label.wide {
    grid-column: 1 / -1;
}

.form-grid input,
.form-grid textarea,
.admin-form select {
    width: 100%;
    min-height: 44px;
    border: 1px solid #ced5de;
    border-radius: 8px;
    padding: 10px 12px;
    color: var(--ink);
    background: #fff;
    outline: none;
}

.form-grid textarea {
    resize: vertical;
}

.form-grid input:focus,
.form-grid textarea:focus {
    border-color: var(--blue);
    box-shadow:
        0 0 0 3px
        rgba(23,63,112,.08);
}

.form-actions {
    display: flex;
    justify-content: flex-end;
}

.form-note {
    margin: 20px 0 0;
    padding: 13px 15px;
    border-radius: 9px;
    color: var(--ink-soft);
    background: var(--ice);
    font-size: 12px;
    line-height: 1.6;
}

.catalog-layout {
    display: grid;
    grid-template-columns:
        minmax(310px, .72fr)
        minmax(400px, 1.28fr);
    gap: 18px;
    align-items: start;
}

.data-list {
    display: grid;
    gap: 10px;
}

.data-row {
    padding: 15px 0;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 18px;
    border-bottom: 1px solid var(--line);
}

.data-row:last-child {
    border-bottom: 0;
}

.data-row-main {
    min-width: 0;
}

.data-row-main > strong {
    display: block;
    margin-bottom: 7px;
}

.data-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 12px;
}

.data-meta span {
    color: var(--ink-soft);
    font-size: 11px;
}

.button-danger {
    min-height: 36px;
    color: #a5252d;
    border: 1px solid #efc4c7;
    background: #fff4f5;
}

.empty-mini {
    padding: 30px;
    border: 1px dashed var(--line);
    border-radius: 10px;
    color: var(--ink-soft);
    text-align: center;
    font-size: 13px;
}

@media (max-width: 1050px) {
    .catalog-layout {
        grid-template-columns: 1fr;
    }

    .module-grid {
        grid-template-columns:
            repeat(2, minmax(0,1fr));
    }
}

@media (max-width: 650px) {
    .form-grid,
    .module-grid {
        grid-template-columns: 1fr;
    }

    .form-grid label.wide {
        grid-column: auto;
    }

    .form-card {
        padding: 19px;
    }

    .data-row {
        flex-direction: column;
    }
}

.edit-record {
    margin-left: auto;
}

.edit-record summary {
    cursor: pointer;
    color: var(--blue);
    font-size: 12px;
    font-weight: 750;
    list-style: none;
}

.edit-record summary::-webkit-details-marker {
    display: none;
}

.edit-record[open] {
    width: min(620px, 100%);
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--ice);
}

.edit-form {
    margin-top: 16px;
}

@media (max-width: 650px) {
    .edit-record[open] {
        width: 100%;
    }
}


/*
 * ==========================================================
 * ENLAMESA_PHASE8_ORDER_BOARD
 * ==========================================================
 */

.orders-page {
    display: grid;
    gap: 20px;
}

.orders-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.orders-toolbar span {
    color: var(--ink-soft);
    font-size: .8rem;
}

.orders-board {
    display: grid;
    grid-template-columns:
        repeat(4, minmax(230px, 1fr));
    gap: 14px;
    align-items: start;
    overflow-x: auto;
    padding-bottom: 8px;
}

.orders-lane {
    min-width: 230px;
    padding: 13px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: var(--ice);
}

.orders-lane-header {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.orders-lane-header h2 {
    margin: 0;
    font-size: .98rem;
}

.orders-lane-header p {
    margin: 3px 0 0;
    color: var(--ink-soft);
    font-size: .75rem;
}

.orders-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 28px;
    padding: 0 8px;
    border-radius: 999px;
    background: var(--paper);
    border: 1px solid var(--line);
    font-weight: 700;
    font-size: .78rem;
}

.orders-stack {
    display: grid;
    gap: 10px;
}

.orders-empty {
    padding: 18px 10px;
    border: 1px dashed var(--line);
    border-radius: 12px;
    color: var(--ink-soft);
    text-align: center;
    font-size: .78rem;
}

.order-card {
    display: grid;
    gap: 9px;
    padding: 13px;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow:
        0 6px 18px
        rgba(18, 34, 54, .05);
}

.order-card-header {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    align-items: flex-start;
}

.order-state {
    padding: 3px 8px;
    border-radius: 999px;
    background: #eef1f4;
    font-size: .68rem;
    font-weight: 700;
    white-space: nowrap;
}

.order-state-nuevo,
.order-state-confirmado {
    background: #fff0bf;
}

.order-state-preparacion {
    background: #ddeaff;
}

.order-state-listo {
    background: #dff3e8;
}

.order-state-entregado {
    background: #e7ebef;
}

.order-state-cancelado {
    background: #f4dfe2;
}

.order-customer {
    font-weight: 650;
    font-size: .88rem;
}

.order-meta {
    display: flex;
    gap: 8px;
    color: var(--ink-soft);
    font-size: .74rem;
    text-transform: capitalize;
}

.order-meta span + span::before {
    content: "·";
    margin-right: 8px;
}

.order-total {
    font-size: 1rem;
}

.order-detail-link {
    font-size: .78rem;
    font-weight: 700;
}

.order-actions {
    display: grid;
    gap: 7px;
}

.order-actions form {
    margin: 0;
}

.order-actions .button {
    width: 100%;
}

.orders-readonly {
    display: grid;
    gap: 3px;
    padding: 13px 15px;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: var(--ice);
    color: var(--ink-soft);
    font-size: .82rem;
}

.order-detail-panel {
    display: grid;
    gap: 15px;
    padding: 18px;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 16px;
}

.order-detail-grid {
    display: grid;
    grid-template-columns:
        repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.order-definition {
    display: grid;
    grid-template-columns:
        minmax(90px, .7fr)
        minmax(0, 1.3fr);
    gap: 8px 12px;
}

.order-definition dt {
    color: var(--ink-soft);
    font-size: .78rem;
}

.order-definition dd {
    margin: 0;
    font-size: .82rem;
    overflow-wrap: anywhere;
}

.order-items,
.order-history {
    display: grid;
}

.order-item,
.order-history-row {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    padding: 10px 0;
    border-bottom: 1px solid var(--line);
}

.order-item:last-child,
.order-history-row:last-child {
    border-bottom: 0;
}

.order-item > div:first-child,
.order-history-row > div:first-child {
    display: grid;
    gap: 3px;
}

.order-item span,
.order-history-row span,
.order-history-row time {
    color: var(--ink-soft);
    font-size: .75rem;
}

.order-item ul {
    margin: 3px 0 0;
    padding-left: 18px;
    color: var(--ink-soft);
    font-size: .75rem;
}

.order-item-price {
    display: grid;
    gap: 3px;
    text-align: right;
    white-space: nowrap;
}


@media (max-width: 1150px) {

    .orders-board {
        grid-template-columns:
            repeat(2, minmax(240px, 1fr));
    }

}


@media (max-width: 650px) {

    .orders-board {
        display: flex;
        overflow-x: auto;
        scroll-snap-type: x proximity;
    }

    .orders-lane {
        flex:
            0 0
            min(84vw, 310px);
        scroll-snap-align: start;
    }

    .order-detail-grid {
        grid-template-columns: 1fr;
    }

    .order-definition {
        grid-template-columns: 1fr;
        gap: 3px;
    }

}


/*
 * ==========================================================
 * ENLAMESA_PHASE9_BILLING
 * ==========================================================
 */

.billing-grid {
    display: grid;
    grid-template-columns:
        repeat(3, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.billing-card {
    display: grid;
    gap: 10px;
    padding: 20px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: var(--surface);
}

.billing-main-value {
    font-size: 1.35rem;
}

.billing-card p {
    margin: 0;
    opacity: .75;
}

.billing-metrics {
    display: grid;
    grid-template-columns:
        repeat(4, minmax(0, 1fr));
    gap: 12px;
}

.billing-metric {
    display: grid;
    gap: 8px;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 14px;
}

.billing-metric span {
    font-size: .82rem;
    opacity: .7;
}

.billing-metric strong {
    font-size: 1.3rem;
}

.billing-list {
    display: grid;
    gap: 10px;
}

.billing-row {
    display: grid;
    grid-template-columns:
        minmax(0, 1.4fr)
        minmax(150px, .7fr)
        minmax(160px, .8fr);
    gap: 16px;
    align-items: center;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 14px;
}

.billing-row > div {
    display: grid;
    gap: 5px;
}

.billing-row span,
.billing-row small {
    opacity: .72;
}

.billing-row-amount {
    text-align: right;
}

.billing-state {
    text-transform: uppercase;
    font-size: .75rem;
    letter-spacing: .04em;
}

.billing-payment-action {
    justify-items: end;
}

.billing-payment-action small {
    text-align: right;
    max-width: 220px;
}

.billing-provider-note {
    display: grid;
    gap: 6px;
    margin-top: 22px;
    padding: 16px;
    border: 1px dashed var(--border);
    border-radius: 14px;
}

.billing-provider-note span {
    opacity: .72;
}

button:disabled {
    cursor: not-allowed;
    opacity: .55;
}

@media (max-width: 980px) {
    .billing-grid,
    .billing-metrics {
        grid-template-columns:
            repeat(2, minmax(0, 1fr));
    }

    .billing-row {
        grid-template-columns: 1fr;
    }

    .billing-row-amount,
    .billing-payment-action {
        text-align: left;
        justify-items: start;
    }

    .billing-payment-action small {
        text-align: left;
    }
}

@media (max-width: 620px) {
    .billing-grid,
    .billing-metrics {
        grid-template-columns: 1fr;
    }
}
