:root {
    --ink: #0c1016;
    --ink-2: #151c27;
    --panel: rgba(18, 24, 34, 0.86);
    --panel-solid: #171f2b;
    --line: rgba(243, 234, 223, 0.1);
    --text: #f6f1ea;
    --muted: #b7ab9f;
    --coral: #e85840;
    --coral-2: #ff8a72;
    --wine: #881820;
    --navy: #183870;
    --cream: #f4ecdf;
    --ok: #9ad7b8;
    --warn: #e7c27a;
    --bad: #ff9b94;
    --shadow: 0 24px 70px rgba(0, 0, 0, 0.35);
    --serif: "Fraunces", Georgia, serif;
    --sans: "Outfit", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    min-height: 100vh;
    color: var(--text);
    font-family: var(--sans);
    font-weight: 380;
    background:
        radial-gradient(900px 480px at -10% -10%, rgba(24, 56, 112, 0.55), transparent 60%),
        radial-gradient(800px 500px at 110% 110%, rgba(136, 24, 32, 0.45), transparent 55%),
        var(--ink);
    letter-spacing: 0.01em;
}
body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background-image: radial-gradient(rgba(244, 236, 223, 0.035) 0.6px, transparent 0.6px);
    background-size: 3px 3px;
    mask-image: linear-gradient(#000, transparent 90%);
}
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; }

.gate-body { background: #07090d; }
.gate-body::before { display: none; }
.gate {
    min-height: 100vh;
    min-height: 100dvh;
    display: grid;
    grid-template-columns: 1fr 1fr;
}
.gate-bg, .gate-shade { position: fixed; inset: 0; }
.gate-bg {
    background:
        url("../../img/login-bg.jpg") center 42% / cover no-repeat;
    transform: scale(1.03);
}
.gate-shade {
    background: linear-gradient(90deg, rgba(7, 9, 13, 0.18) 0%, rgba(7, 9, 13, 0.34) 50%, rgba(7, 9, 13, 0.72) 50%, rgba(7, 9, 13, 0.82) 100%);
}
.gate-mark {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 48px;
}
.gate-mark img {
    width: min(560px, 82%);
    height: auto;
    filter: drop-shadow(0 24px 48px rgba(0, 0, 0, 0.45));
}
.gate-card {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 64px 9vw;
    background: rgba(10, 13, 18, 0.34);
    border-left: 1px solid rgba(244, 236, 223, 0.14);
    backdrop-filter: blur(22px);
}
.gate-card form {
    width: min(460px, 100%);
    margin-inline: auto;
    text-align: left;
}
.gate-card .field { margin-bottom: 20px; }
.gate-card .field label {
    padding-left: 16px;
    letter-spacing: 0.04em;
}
.gate-card input[type="text"],
.gate-card input[type="password"] {
    appearance: none;
    -webkit-appearance: none;
    height: 56px;
    border-radius: 999px;
    padding: 0 18px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(244, 236, 223, 0.16);
    font-family: var(--sans);
    font-size: 16px;
    letter-spacing: normal;
}
.gate-card input::placeholder { color: rgba(183, 171, 159, 0.7); }
.gate-card .btn {
    width: 100%;
    height: 56px;
    margin-top: 10px;
    padding: 0 18px;
    border-radius: 999px;
}
.eyebrow {
    color: var(--coral-2);
    text-transform: uppercase;
    letter-spacing: 0.18em;
    font-size: 11px;
    margin: 0 0 8px;
}
.shell { display: flex; min-height: 100vh; }
.sidebar {
    width: 258px;
    flex: none;
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 22px 16px 18px;
    border-right: 1px solid var(--line);
    background: rgba(10, 13, 18, 0.78);
    backdrop-filter: blur(18px);
    display: flex;
    flex-direction: column;
    z-index: 20;
}
.side-logo {
    background: var(--cream);
    border-radius: 18px;
    padding: 10px 12px;
    margin-bottom: 18px;
}
.side-logo img { display: block; width: 100%; height: 54px; object-fit: contain; }
.venue-switch { margin-bottom: 16px; }
.venue-switch select, .venue-name {
    width: 100%;
    background: var(--ink-2);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 10px 12px;
}
.venue-name { color: var(--cream); }
.nav-group { margin: 14px 8px 6px; color: var(--muted); font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase; }
.nav a {
    display: flex;
    justify-content: space-between;
    align-items: center;
    text-decoration: none;
    padding: 9px 12px;
    border-radius: 12px;
    color: #ddd4ca;
}
.nav a:hover { background: rgba(244, 236, 223, 0.05); }
.nav a.active {
    background: linear-gradient(90deg, rgba(232, 88, 64, 0.18), transparent);
    color: white;
    box-shadow: inset 2px 0 0 var(--coral);
}
.badge {
    display: inline-flex;
    align-items: center;
    min-width: 18px;
    justify-content: center;
    border-radius: 999px;
    padding: 1px 7px;
    background: var(--wine);
    color: white;
    font-size: 12px;
}
.side-user { margin-top: auto; padding: 12px; color: var(--muted); font-size: 13px; }
.side-user strong { display: block; color: var(--cream); font-weight: 560; }
.main { flex: 1; min-width: 0; padding: 28px 32px 60px; }
.topbar { display: flex; justify-content: space-between; gap: 16px; align-items: flex-end; margin-bottom: 22px; }
.topbar h1 { font-family: var(--serif); font-size: clamp(32px, 4vw, 46px); line-height: 1; margin: 0; font-weight: 560; }
.menu-btn, .btn, button.btn {
    border: 0;
    cursor: pointer;
    border-radius: 999px;
    padding: 10px 16px;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.menu-btn { display: none; background: var(--ink-2); border: 1px solid var(--line); }
.btn-primary { background: linear-gradient(180deg, var(--coral-2), var(--coral)); color: #2a0c08; font-weight: 580; }
.btn-ghost { background: transparent; border: 1px solid var(--line); color: var(--cream); }
.btn-danger { background: #6d2430; color: white; }
.btn-small { padding: 7px 12px; font-size: 14px; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.stat, .panel, .card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 22px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.12);
}
.stat { padding: 18px 18px 16px; }
.stat span { color: var(--muted); font-size: 13px; }
.stat strong { display: block; margin-top: 8px; font-family: var(--serif); font-size: 30px; font-weight: 560; }
.stat em { font-style: normal; color: var(--coral-2); font-size: 13px; }
.grid-2 { display: grid; grid-template-columns: 1.15fr 0.85fr; gap: 14px; }
.panel { padding: 18px 18px 8px; margin-bottom: 14px; }
.panel h2, .card h2 { font-family: var(--serif); font-weight: 560; font-size: 26px; margin: 0 0 8px; }
.muted { color: var(--muted); }
.row-actions, .toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.toolbar { margin-bottom: 14px; }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); font-weight: 500; padding: 8px; }
td { padding: 10px 8px; border-top: 1px solid var(--line); vertical-align: middle; }
tr:hover td { background: rgba(255, 255, 255, 0.015); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow: auto; }

.tag {
    display: inline-flex;
    border-radius: 999px;
    padding: 3px 8px;
    font-size: 12px;
    border: 1px solid var(--line);
    color: var(--cream);
}
.tag.alta, .tag.faltante, .tag.bad { background: rgba(136, 24, 32, 0.55); }
.tag.media, .tag.warn { background: rgba(231, 194, 122, 0.16); color: var(--warn); }
.tag.ok, .tag.sobrante { background: rgba(154, 215, 184, 0.12); color: var(--ok); }
.tag.consumo_vs_venta { background: rgba(24, 56, 112, 0.7); }

.flash, .error {
    border-radius: 16px;
    padding: 12px 14px;
    margin-bottom: 14px;
    white-space: pre-line;
}
.flash.ok, .error.ok { background: rgba(154, 215, 184, 0.12); color: var(--ok); }
.flash.bad, .error, .flash.warn { background: rgba(232, 88, 64, 0.12); color: #ffd0c8; }
.flash.warn { color: var(--warn); }

.fields { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field.full { grid-column: 1 / -1; }
.field label { color: var(--muted); font-size: 13px; }
input[type="text"], input[type="password"], input[type="number"], input[type="date"], input[type="email"], input[type="search"], select, textarea {
    background: #0e141d;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 11px 12px;
    outline: none;
    width: 100%;
}
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: rgba(232, 88, 64, 0.7); }
.check { display: flex; gap: 8px; align-items: center; color: var(--cream); }
.help { color: var(--muted); font-size: 13px; line-height: 1.45; }

.split { display: grid; grid-template-columns: 0.9fr 1.1fr; gap: 16px; align-items: start; }
.paper {
    position: sticky;
    top: 16px;
    background: #efe7dc;
    color: #241910;
    border-radius: 22px;
    padding: 12px;
    min-height: 320px;
}
.paper img, .paper iframe, .paper embed { width: 100%; border: 0; border-radius: 14px; max-height: 78vh; object-fit: contain; background: white; }
.paper iframe, .paper embed { height: 78vh; }
.line-edit input, .line-edit select { padding: 8px; }
.changed input { box-shadow: inset 0 0 0 1px var(--coral); }
.neg td { background: rgba(136, 24, 32, 0.28); }
.pos td { background: rgba(154, 215, 184, 0.08); }

.cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.card { padding: 16px; }
.card strong { font-family: var(--serif); font-size: 28px; display: block; margin: 8px 0; }

.empty { padding: 28px 8px 34px; color: var(--muted); }
.empty h3 { color: var(--cream); font-family: var(--serif); font-size: 28px; margin-bottom: 6px; }

.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.filters input, .filters select { width: auto; min-width: 180px; }

@media (max-width: 1100px) {
    .stats, .grid-2, .split, .cards, .fields { grid-template-columns: 1fr; }
    .paper { position: static; }
}
@media (max-width: 800px) {
    .gate { grid-template-columns: 1fr; align-content: end; }
    .gate-shade {
        background: linear-gradient(180deg, rgba(7, 9, 13, 0.15) 0%, rgba(7, 9, 13, 0.78) 100%);
    }
    .gate-mark { padding: 36px 24px 8px; }
    .gate-mark img { width: min(300px, 78%); }
    .gate-card {
        min-height: auto;
        padding: 28px 22px max(28px, env(safe-area-inset-bottom));
        border-left: 0;
        background: transparent;
    }
}
@media (max-height: 700px) {
    .gate-mark { padding-block: 20px 4px; }
    .gate-card { padding-top: 16px; padding-bottom: 16px; }
}
@media (max-width: 860px) {
    .menu-btn { display: inline-flex; }
    .sidebar { position: fixed; left: 0; transform: translateX(-105%); transition: transform 0.2s ease; }
    .sidebar.open { transform: none; }
    .main { padding: 18px 14px 48px; }
}
