:root {
    --bg: #F4F1EC;
    --paper: #FFFFFF;
    --ink: #2D2620;
    --ink-soft: #6E6258;
    --brown: #7A4B2A;
    --brown-dark: #5A3618;
    --gold: #C8A24A;
    --green: #2E7D32;
    --red: #C24C4C;
    --border: #E5DFD5;
    --shadow: 0 4px 14px rgba(60, 35, 15, 0.08);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--ink);
    line-height: 1.45;
}
img { max-width: 100%; display: block; }
a { color: var(--brown); }

/* ============================================================
   LOGIN — "gilded bakery": cálido, artesanal, regio
   ============================================================ */
.login-page {
    position: relative;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    overflow: hidden;
    font-family: 'Outfit', system-ui, -apple-system, sans-serif;
    color: var(--ink);
    background: radial-gradient(125% 95% at 50% -12%, #FCEFD4 0%, #F4E4C4 36%, #E8D0A3 70%, #D9B985 100%);
}
/* halo de luz cálida + brillo dorado inferior */
.login-page::before {
    content: '';
    position: absolute; inset: 0;
    background:
        radial-gradient(58% 48% at 50% 12%, rgba(255, 255, 255, .55), transparent 60%),
        radial-gradient(42% 34% at 86% 84%, rgba(200, 162, 74, .22), transparent 70%);
    pointer-events: none;
}
/* grano fino para textura de papel */
.login-page::after {
    content: '';
    position: absolute; inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.5'/%3E%3C/svg%3E");
    opacity: .35;
    mix-blend-mode: multiply;
    pointer-events: none;
}

.login-card {
    position: relative;
    z-index: 1;
    width: min(404px, 100%);
    padding: 46px 40px 38px;
    text-align: center;
    display: flex;
    flex-direction: column;
    background: linear-gradient(180deg, #FFFDF8, #FBF4E6);
    border: 1px solid rgba(200, 162, 74, .45);
    border-radius: 22px;
    box-shadow:
        0 1px 0 rgba(255, 255, 255, .9) inset,
        0 34px 64px -22px rgba(74, 40, 15, .45),
        0 10px 24px -12px rgba(74, 40, 15, .30);
    animation: loginCardIn .7s cubic-bezier(.22, .61, .36, 1) both;
}
/* borde dorado superior */
.login-card::before {
    content: '';
    position: absolute; top: 0; left: 50%; transform: translateX(-50%);
    width: 62%; height: 3px;
    border-radius: 0 0 4px 4px;
    background: linear-gradient(90deg, transparent, var(--gold) 18%, #F0D89B 50%, var(--gold) 82%, transparent);
}

.login-crest {
    width: 66px; height: 66px;
    margin: 0 auto 22px;
    display: grid; place-items: center;
    border-radius: 50%;
    color: var(--brown-dark);
    background: radial-gradient(circle at 50% 34%, #FBEFD2, #EAD29F);
    box-shadow:
        0 0 0 1px rgba(200, 162, 74, .55),
        0 0 0 6px rgba(255, 255, 255, .65),
        0 0 0 7px rgba(200, 162, 74, .28),
        0 12px 22px -10px rgba(122, 75, 42, .55);
    animation: loginCrestIn .85s .12s cubic-bezier(.34, 1.56, .64, 1) both;
}
.login-crest svg { width: 32px; height: 32px; }

.login-eyebrow {
    margin: 0 0 7px;
    font-size: 11px; font-weight: 600;
    letter-spacing: .34em; text-transform: uppercase;
    color: var(--gold);
}
.login-title {
    margin: 0;
    font-family: 'Fraunces', Georgia, 'Times New Roman', serif;
    font-optical-sizing: auto;
    font-weight: 600;
    font-size: clamp(27px, 7vw, 33px);
    line-height: 1.04;
    letter-spacing: -.01em;
    color: var(--brown-dark);
}
.login-sub {
    margin: 9px 0 26px;
    font-size: 14px;
    color: var(--ink-soft);
}

.login-card .field {
    display: block;
    text-align: left;
    margin-bottom: 15px;
}
.field-label {
    display: block;
    margin-bottom: 7px;
    font-size: 11px; font-weight: 600;
    letter-spacing: .12em; text-transform: uppercase;
    color: var(--ink-soft);
}
.input-wrap { position: relative; display: block; }
.input-wrap input {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 11px;
    background: #FFFDF9;
    padding: 13px 14px;
    font: inherit;
    font-size: 15px;
    color: var(--ink);
    box-shadow: 0 1px 2px rgba(74, 40, 15, .04) inset;
    transition: border-color .2s, box-shadow .2s, background .2s;
}
.input-wrap input::placeholder { color: #BCAF9E; }
.input-wrap input:focus {
    outline: none;
    border-color: var(--gold);
    background: #fff;
    box-shadow: 0 0 0 4px rgba(200, 162, 74, .18);
}
.input-wrap.has-toggle input { padding-right: 48px; }

.pwd-toggle {
    position: absolute;
    top: 50%; right: 7px;
    transform: translateY(-50%);
    width: 34px; height: 34px;
    display: grid; place-items: center;
    border: none; background: transparent;
    border-radius: 8px;
    color: var(--ink-soft);
    cursor: pointer;
    transition: color .18s, background .18s;
}
.pwd-toggle:hover { color: var(--brown); background: rgba(200, 162, 74, .14); }
.pwd-toggle:focus-visible { outline: 2px solid var(--gold); outline-offset: 1px; }
.pwd-toggle svg { width: 20px; height: 20px; }
.pwd-toggle .eye-closed { display: none; }
.pwd-toggle.is-visible .eye-open { display: none; }
.pwd-toggle.is-visible .eye-closed { display: block; }

.login-card .remember {
    display: flex; align-items: center; gap: 11px;
    text-align: left;
    margin: 4px 0 24px;
    font-size: 13.5px;
    color: var(--ink-soft);
    cursor: pointer;
    user-select: none;
}
.login-card .remember input {
    position: absolute;
    width: 1px; height: 1px;
    opacity: 0;
    pointer-events: none;
}
.remember-box {
    flex: none;
    width: 21px; height: 21px;
    display: grid; place-items: center;
    border: 1.5px solid var(--border);
    border-radius: 6px;
    background: #FFFDF9;
    color: #fff;
    transition: background .18s, border-color .18s, box-shadow .18s;
}
.remember-box svg {
    width: 13px; height: 13px;
    opacity: 0; transform: scale(.5);
    transition: opacity .18s, transform .18s;
}
.remember input:checked + .remember-box {
    background: linear-gradient(180deg, var(--gold), #B68A33);
    border-color: #B68A33;
}
.remember input:checked + .remember-box svg { opacity: 1; transform: scale(1); }
.remember input:focus-visible + .remember-box { box-shadow: 0 0 0 4px rgba(200, 162, 74, .25); }
.remember-text em { font-style: normal; font-weight: 600; color: var(--brown); }

.login-submit {
    position: relative;
    overflow: hidden;
    width: 100%;
    display: inline-flex; align-items: center; justify-content: center; gap: 9px;
    padding: 14px 18px;
    border: none;
    border-radius: 12px;
    font: inherit; font-weight: 600; font-size: 15px; letter-spacing: .02em;
    color: #FFF5E2;
    cursor: pointer;
    background: linear-gradient(180deg, #7A4B2A, #5A3618);
    box-shadow: 0 12px 24px -12px rgba(74, 40, 15, .7), 0 1px 0 rgba(255, 255, 255, .15) inset;
    transition: transform .15s, box-shadow .2s, filter .2s;
}
.login-submit svg { width: 18px; height: 18px; transition: transform .2s; }
.login-submit:hover { filter: brightness(1.07); box-shadow: 0 16px 28px -12px rgba(74, 40, 15, .75); }
.login-submit:hover svg { transform: translateX(3px); }
.login-submit:active { transform: translateY(1px); }
.login-submit:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }
/* destello dorado al hover */
.login-submit::after {
    content: '';
    position: absolute; top: 0; left: -120%;
    width: 55%; height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 225, 160, .35), transparent);
    transform: skewX(-20deg);
    transition: left .6s ease;
}
.login-submit:hover::after { left: 150%; }

/* Botón secundario: abrir la presentación TV sin loguearse */
.login-presentation {
    margin-top: 12px;
    width: 100%;
    display: inline-flex; align-items: center; justify-content: center; gap: 9px;
    padding: 12px 18px;
    border: 1.5px solid rgba(200, 162, 74, .55);
    border-radius: 12px;
    font: inherit; font-weight: 600; font-size: 14.5px; letter-spacing: .02em;
    text-decoration: none;
    color: var(--brown-dark);
    background: linear-gradient(180deg, #FFFDF8, #FBF2DE);
    box-shadow: 0 8px 18px -12px rgba(74, 40, 15, .4);
    transition: transform .15s, box-shadow .2s, border-color .2s, background .2s;
}
.login-presentation svg { width: 18px; height: 18px; }
.login-presentation:hover {
    border-color: var(--gold);
    background: linear-gradient(180deg, #FFFBF0, #F7E9CB);
    box-shadow: 0 12px 22px -12px rgba(74, 40, 15, .5);
}
.login-presentation:active { transform: translateY(1px); }
.login-presentation:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }

.login-error {
    display: flex; align-items: center; gap: 9px;
    text-align: left;
    margin-bottom: 16px;
    padding: 11px 13px;
    font-size: 13.5px;
    color: #9A2F2F;
    background: rgba(194, 76, 76, .10);
    border: 1px solid rgba(194, 76, 76, .35);
    border-radius: 10px;
}
.login-error svg { flex: none; width: 18px; height: 18px; }

@keyframes loginCardIn {
    from { opacity: 0; transform: translateY(24px) scale(.985); }
    to   { opacity: 1; transform: none; }
}
@keyframes loginCrestIn {
    from { opacity: 0; transform: scale(.4); }
    to   { opacity: 1; transform: scale(1); }
}

@media (max-width: 420px) {
    .login-card { padding: 38px 26px 30px; }
}
@media (prefers-reduced-motion: reduce) {
    .login-card, .login-crest { animation: none; }
    .login-submit::after { display: none; }
}

/* TOPBAR */
.topbar {
    background: var(--brown-dark);
    color: #F8EAD0;
}
.topbar-bar {
    padding: 0 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 6px;
}
.topbar .brand a {
    color: #F8EAD0;
    font-weight: 700;
    text-decoration: none;
    padding: 14px 0;
    display: inline-block;
}
.topbar nav {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 0 24px;
}
.topbar nav a {
    color: #F8EAD0;
    text-decoration: none;
    padding: 14px 12px;
    font-size: 14px;
    font-weight: 500;
    border-bottom: 2px solid transparent;
}
.topbar nav a:hover { background: rgba(255, 255, 255, 0.08); }
.topbar nav .logout { opacity: 0.85; }
.topbar nav .view-site { color: var(--gold); }
.topbar nav .nav-badge {
    display: inline-block;
    background: var(--red);
    color: #fff;
    border-radius: 999px;
    padding: 1px 7px;
    font-size: 11px;
    font-weight: 700;
    margin-left: 4px;
    line-height: 1.6;
    vertical-align: middle;
}
.topbar .nav-toggle {
    display: none;
    width: 44px;
    height: 44px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
}
.topbar .nav-toggle span {
    display: block;
    width: 22px;
    height: 2px;
    background: #F8EAD0;
    transition: transform 0.2s ease, opacity 0.15s ease;
}
.topbar .nav-toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.topbar .nav-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.topbar .nav-toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 28px 22px 60px;
}
h1 { font-size: 26px; color: var(--brown-dark); margin: 0 0 22px; }
h2 { font-size: 18px; color: var(--brown-dark); margin: 0 0 14px; }

/* DASHBOARD CARDS */
.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 26px;
}
.card {
    background: var(--paper);
    padding: 22px;
    border-radius: 12px;
    box-shadow: var(--shadow);
    text-decoration: none;
    color: var(--ink);
    transition: transform 0.15s ease;
    border-left: 4px solid var(--gold);
}
.card:hover { transform: translateY(-2px); }
.card.warn { border-left-color: var(--red); }
.card .big {
    font-size: 36px;
    font-weight: 700;
    color: var(--brown-dark);
    line-height: 1;
    margin-bottom: 8px;
}
.card small { display: block; color: var(--ink-soft); font-size: 13px; margin-top: 4px; }
.panel {
    background: var(--paper);
    padding: 22px;
    border-radius: 12px;
    box-shadow: var(--shadow);
    margin-bottom: 22px;
}
.actions { display: flex; flex-wrap: wrap; gap: 10px; }

/* BUTTONS */
.btn {
    background: var(--brown);
    color: #fff;
    border: none;
    padding: 10px 18px;
    border-radius: 8px;
    font-weight: 600;
    font-family: inherit;
    font-size: 14px;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
}
.btn:hover { background: var(--brown-dark); }
.btn.alt { background: #fff; color: var(--brown); border: 1px solid var(--border); }
.btn.alt:hover { background: var(--bg); }
.btn.small { padding: 6px 12px; font-size: 13px; }
.btn.danger { background: var(--red); }
.btn.danger:hover { background: #9F3636; }

/* TOOLBAR */
.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 18px;
}
.filter {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.filter select, .filter input, .form-grid input, .form-grid select, .form-grid textarea {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 12px;
    background: #fff;
    font-size: 14px;
    font-family: inherit;
}
.filter button { padding: 8px 14px; }

/* TABLES */
table.data {
    width: 100%;
    border-collapse: collapse;
    background: var(--paper);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow);
}
table.data th, table.data td {
    padding: 12px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
table.data th {
    background: var(--bg);
    font-weight: 600;
    font-size: 13px;
    color: var(--ink-soft);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
table.data tr:last-child td { border-bottom: none; }
table.data tr:hover { background: rgba(200, 162, 74, 0.06); }
.thumb img {
    width: 56px;
    height: 56px;
    object-fit: cover;
    border-radius: 6px;
}
.thumb-empty {
    width: 56px; height: 56px;
    border-radius: 6px;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    color: var(--ink-soft);
}
.actions-cell { display: flex; gap: 6px; flex-wrap: wrap; }
.empty { text-align: center; color: var(--ink-soft); padding: 30px; }

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
}
.badge.ok  { background: #E0F0D6; color: var(--green); }
.badge.off { background: #F1E2E2; color: var(--red); }

/* FORMS */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    background: var(--paper);
    padding: 24px;
    border-radius: 12px;
    box-shadow: var(--shadow);
}
.form-grid label {
    display: flex;
    flex-direction: column;
    font-size: 14px;
    font-weight: 500;
    gap: 6px;
}
.form-grid label.full { grid-column: 1 / -1; }
.form-grid label.checkbox {
    flex-direction: row;
    align-items: center;
    gap: 10px;
    font-weight: 400;
}
.form-grid .full { grid-column: 1 / -1; }
.form-grid input:focus, .form-grid select:focus, .form-grid textarea:focus {
    outline: 2px solid var(--gold);
    border-color: var(--gold);
}
.form-grid .actions { display: flex; gap: 10px; padding-top: 8px; }
.hint {
    font-size: 12px;
    color: var(--ink-soft);
    font-weight: 400;
}
.hint code {
    background: var(--bg);
    padding: 1px 6px;
    border-radius: 3px;
    font-size: 12px;
}
.current-image { margin-top: 12px; display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }

/* FLASH */
.flash {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    border-left: 4px solid var(--brown);
    background: #fff;
}
.flash-ok { border-left-color: var(--green); background: #E0F0D6; color: #1B5C1B; }
.flash-err { border-left-color: var(--red); background: #F8E0E0; color: #7A1F1F; }

/* TOGGLE SWITCH (active/inactive) */
.toggle-form { margin: 0; display: inline-block; }
.toggle-switch {
    border: 1px solid var(--border);
    background: #fff;
    padding: 4px 10px 4px 4px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    font-family: inherit;
    color: var(--ink-soft);
    min-height: 30px;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.toggle-switch .dot {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #BFBFBF;
    transition: background 0.15s ease, transform 0.15s ease;
}
.toggle-switch.on { background: #E8F4DD; border-color: #A6D08A; color: var(--green); }
.toggle-switch.on .dot { background: var(--green); }
.toggle-switch.off { background: #FBECEC; border-color: #E5BFBF; color: var(--red); }
.toggle-switch.off .dot { background: var(--red); }
.toggle-switch:hover { filter: brightness(0.97); }

/* FULL-WIDTH BUTTON ON MOBILE */
.full-on-mobile { width: auto; }

@media (max-width: 700px) {
    .form-grid { grid-template-columns: 1fr; padding: 18px; }
    .container { padding: 20px 14px 60px; }

    /* Topbar with hamburger drawer */
    .topbar-bar { padding: 0 14px; }
    .topbar .nav-toggle { display: flex; }
    .topbar nav {
        max-height: 0;
        overflow: hidden;
        padding: 0 14px;
        flex-direction: column;
        gap: 0;
        transition: max-height 0.25s ease;
        background: rgba(0, 0, 0, 0.15);
    }
    .topbar.open nav { max-height: 60vh; padding: 6px 14px 12px; }
    .topbar nav a {
        padding: 12px 6px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    }
    .topbar nav a:last-child { border-bottom: none; }

    /* Toolbar stacks on mobile */
    .toolbar { flex-direction: column; align-items: stretch; gap: 10px; }
    .filter { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
    .filter select, .filter input { grid-column: 1 / -1; min-height: 42px; }
    .filter .btn { min-height: 42px; }
    .full-on-mobile { width: 100%; text-align: center; padding: 14px; font-size: 15px; }

    /* RESPONSIVE TABLE-AS-CARDS */
    table.data-responsive { background: transparent; box-shadow: none; border-radius: 0; }
    table.data-responsive thead { display: none; }
    table.data-responsive tbody, table.data-responsive tr {
        display: block;
        width: 100%;
    }
    table.data-responsive tr {
        background: var(--paper);
        border-radius: 12px;
        box-shadow: var(--shadow);
        margin-bottom: 14px;
        padding: 14px;
        display: grid;
        grid-template-columns: 76px 1fr;
        column-gap: 14px;
        row-gap: 8px;
        align-items: start;
    }
    table.data-responsive td {
        border: none;
        padding: 0;
        display: block;
        font-size: 14px;
    }
    table.data-responsive td.thumb {
        grid-row: span 5;
        align-self: start;
    }
    table.data-responsive .thumb img,
    table.data-responsive .thumb-empty {
        width: 76px;
        height: 76px;
        border-radius: 8px;
    }
    table.data-responsive td[data-label]:not(.thumb)::before {
        content: attr(data-label);
        display: block;
        font-size: 11px;
        font-weight: 600;
        color: var(--ink-soft);
        text-transform: uppercase;
        letter-spacing: 0.06em;
        margin-bottom: 2px;
    }
    table.data-responsive td.cell-name {
        font-size: 16px;
        font-weight: 600;
        color: var(--brown-dark);
    }
    table.data-responsive td.cell-name::before { display: none; }
    table.data-responsive td.cell-price {
        font-size: 16px;
        font-weight: 700;
        color: var(--brown-dark);
    }
    table.data-responsive td.actions-cell {
        grid-column: 1 / -1;
        display: flex;
        gap: 8px;
        flex-wrap: wrap;
        margin-top: 4px;
        padding-top: 10px;
        border-top: 1px solid var(--border);
    }
    table.data-responsive td.actions-cell::before { display: none; }
    table.data-responsive td.actions-cell .btn { flex: 1; text-align: center; min-height: 42px; padding: 10px; font-size: 14px; }
    table.data-responsive td.actions-cell form { flex: 1; display: flex; }
    table.data-responsive td.actions-cell form .btn { width: 100%; }
    table.data-responsive .toggle-switch { padding: 6px 14px 6px 6px; min-height: 36px; font-size: 13px; }
    table.data-responsive .empty {
        grid-column: 1 / -1;
        text-align: center;
        padding: 30px;
    }
}

/* ============================================================
   RITUAL CRIOLLO — acento rojo carne (override del admin)
   Se mantiene el panel claro/legible; sólo cambia el acento
   dorado por rojo y el fondo del login a tono pizarra.
   ============================================================ */
:root {
    --brown: #B02D1A;   /* enlaces / acentos */
    --gold:  #C0341F;   /* líneas, foco, badges */
}
.login-page {
    background: radial-gradient(125% 95% at 50% -12%, #3A2622 0%, #271C1C 38%, #181318 72%, #100D11 100%);
}
.login-title { font-family: 'Cinzel', 'Fraunces', Georgia, serif; letter-spacing: .02em; }
