/* Khloe's - Panel de gestión */
:root {
    --bg: #0e0c14;
    --bg-2: #14111c;
    --surface: #1a1624;
    --surface-2: #221d2e;
    --line: rgba(255, 255, 255, 0.09);
    --line-strong: rgba(255, 255, 255, 0.16);
    --ink: #f5f4f7;
    --ink-soft: #c9c5d2;
    --ink-muted: #8f8a9b;
    --pink: #ff2a8d;
    --pink-soft: rgba(255, 42, 141, 0.14);
    --ok: #22c55e;
    --ok-soft: rgba(34, 197, 94, 0.15);
    --warn: #f59e0b;
    --warn-soft: rgba(245, 158, 11, 0.16);
    --bad: #ef4444;
    --bad-soft: rgba(239, 68, 68, 0.15);
    --radius: 14px;
    --shadow: 0 10px 30px -18px rgba(0, 0, 0, 0.7);
    color-scheme: dark;
}

html[data-theme="light"] {
    --bg: #f6f2f5;
    --bg-2: #efe9ee;
    --surface: #ffffff;
    --surface-2: #f8f4f7;
    --line: rgba(40, 20, 40, 0.1);
    --line-strong: rgba(40, 20, 40, 0.18);
    --ink: #1b1320;
    --ink-soft: #3d3542;
    --ink-muted: #6f6775;
    --pink: #e0157a;
    --pink-soft: rgba(224, 21, 122, 0.1);
    --shadow: 0 10px 30px -20px rgba(60, 20, 50, 0.35);
    color-scheme: light;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

body {
    background: var(--bg);
    color: var(--ink);
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}

h1, h2, h3 { font-weight: 700; letter-spacing: -0.01em; }
button { font: inherit; color: inherit; cursor: pointer; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--pink); outline-offset: 2px; }

/* ---------- Botones y campos ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 10px 16px; border-radius: 10px; border: 1px solid transparent;
    font-weight: 600; font-size: 0.92rem; text-decoration: none;
    transition: transform .15s, background-color .15s, border-color .15s, opacity .15s;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: linear-gradient(135deg, #ff2a8d, #ff5a6e); color: #fff; }
.btn-primary:hover:not(:disabled) { filter: brightness(1.08); }
.btn-ghost { background: transparent; border-color: var(--line-strong); color: var(--ink); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-ok { background: var(--ok-soft); color: var(--ok); border-color: rgba(34, 197, 94, 0.35); }
.btn-bad { background: var(--bad-soft); color: var(--bad); border-color: rgba(239, 68, 68, 0.35); }
.btn-sm { padding: 6px 10px; font-size: 0.82rem; border-radius: 8px; }
.btn-block { width: 100%; }

.icon-btn {
    width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--line);
    background: var(--surface); display: inline-grid; place-items: center;
}
.icon-btn:hover { background: var(--surface-2); }

.link-btn { background: none; border: none; color: var(--ink-muted); text-decoration: underline; padding: 6px; }
.link-btn:hover { color: var(--ink); }

input, select, textarea {
    width: 100%; padding: 10px 12px; border-radius: 10px;
    border: 1px solid var(--line-strong); background: var(--bg-2); color: var(--ink);
    font: inherit; min-height: 42px;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--pink); box-shadow: 0 0 0 3px var(--pink-soft); }
input[type="checkbox"] { width: 18px; height: 18px; min-height: 0; accent-color: var(--pink); }
label { display: block; font-size: 0.82rem; font-weight: 600; color: var(--ink-soft); }
label input, label select { margin-top: 6px; font-weight: 400; }
.check { display: flex; align-items: center; gap: 10px; font-size: 0.92rem; font-weight: 500; }
.check input { margin: 0; }
.muted { color: var(--ink-muted); font-size: 0.9rem; }
.sub { color: var(--ink-muted); font-size: 0.82rem; }
.only-sm { display: none; }

/* ---------- Acceso ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card {
    width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--line);
    border-radius: 20px; padding: 28px; box-shadow: var(--shadow);
}
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.auth-brand img { border-radius: 50%; }
.auth-brand strong { display: block; font-size: 1rem; }
.auth-brand span { color: var(--ink-muted); font-size: 0.82rem; }
.auth-step h1 { font-size: 1.35rem; margin-bottom: 6px; }
.auth-text { color: var(--ink-soft); font-size: 0.92rem; margin-bottom: 18px; }
.auth-step label { margin-top: 14px; }
.auth-step .btn { margin-top: 20px; }
.auth-hint { color: var(--ink-muted); font-size: 0.82rem; margin-top: 10px; }
.auth-qr { background: #fff; width: 216px; height: 216px; padding: 12px; margin: 0 auto 6px; border-radius: 12px; line-height: 0; }
.auth-qr svg { width: 192px; height: 192px; display: block; }
.auth-clave { font-family: ui-monospace, Menlo, Consolas, monospace; font-weight: 700; text-align: center; word-break: break-all; user-select: all; margin-top: 4px; }
.code-input { text-align: center; letter-spacing: 8px; font-size: 1.3rem; font-weight: 600; }
.auth-error { margin-top: 16px; padding: 10px 12px; border-radius: 10px; background: var(--bad-soft); color: var(--bad); font-size: 0.88rem; }
#a-otra { display: block; margin: 14px auto 0; }

/* ---------- Estructura del panel ---------- */
.app { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.side {
    position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column;
    background: var(--surface); border-right: 1px solid var(--line); padding: 18px 14px;
}
.side-brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; }
.side-brand img { border-radius: 50%; }
.side-brand strong { display: block; line-height: 1.1; }
.side-brand span { color: var(--ink-muted); font-size: 0.78rem; }
.side-nav { display: grid; gap: 4px; }
.nav-btn {
    display: flex; align-items: center; gap: 12px; text-align: left; width: 100%;
    padding: 11px 12px; border-radius: 10px; background: none; border: none; color: var(--ink-soft);
    font-weight: 500;
}
.nav-btn i { width: 18px; text-align: center; color: var(--ink-muted); }
.nav-btn:hover { background: var(--surface-2); }
.nav-btn.active { background: var(--pink-soft); color: var(--ink); }
.nav-btn.active i { color: var(--pink); }
.nav-badge { margin-left: auto; background: var(--pink); color: #fff; font-size: 0.72rem; padding: 1px 7px; border-radius: 999px; }
.side-foot { margin-top: auto; display: grid; gap: 10px; padding-top: 14px; border-top: 1px solid var(--line); }
.side-user { color: var(--ink-muted); font-size: 0.85rem; padding: 0 6px; }
.side-foot-btns { display: flex; gap: 8px; }

.main { padding: 24px 28px 60px; min-width: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.topbar h1 { font-size: 1.5rem; }
.topbar-actions { display: flex; gap: 8px; }
.view { display: none; }
.view.active { display: block; animation: aparece .25s ease; }
@keyframes aparece { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.notice { background: var(--warn-soft); border: 1px solid rgba(245, 158, 11, 0.35); color: var(--ink); padding: 12px 14px; border-radius: var(--radius); margin-bottom: 16px; font-size: 0.9rem; }

/* ---------- Tarjetas y paneles ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 18px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.card small { color: var(--ink-muted); font-size: 0.8rem; font-weight: 600; }
.card strong { display: block; font-size: 1.6rem; margin-top: 4px; letter-spacing: -0.02em; }
.card .sub { color: var(--ink-muted); font-size: 0.8rem; }
.pos { color: var(--ok); } .neg { color: var(--bad); }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.panel { min-width: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
.grid-2 .panel { margin-bottom: 0; }
.panel h2 { font-size: 1rem; margin-bottom: 12px; }
.panel.flush { padding: 0; overflow: hidden; }

.list { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.empty { color: var(--ink-muted); font-size: 0.9rem; padding: 10px 2px; }
.item {
    display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px;
    background: var(--surface-2); border: 1px solid var(--line); text-align: left; width: 100%;
}
button.item:hover { border-color: var(--line-strong); }
.item > * { flex-shrink: 0; }
.item > .item-main { flex-shrink: 1; }
.item-time { font-weight: 700; min-width: 50px; font-variant-numeric: tabular-nums; }
.item-main { flex: 1; min-width: 0; }
.item-main strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-main span { display: block; color: var(--ink-muted); font-size: 0.82rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.badge { display: inline-block; font-size: 0.72rem; font-weight: 700; padding: 3px 9px; border-radius: 999px; text-transform: uppercase; letter-spacing: .03em; white-space: nowrap; }
.badge-confirmada { background: var(--ok-soft); color: var(--ok); }
.badge-pendiente { background: var(--warn-soft); color: var(--warn); }
.badge-cancelada { background: var(--bad-soft); color: var(--bad); }
.badge-gris { background: var(--surface-2); color: var(--ink-muted); }

.filters { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.filters input:only-child { grid-column: 1 / -1; }

/* ---------- Listas tipo tabla ---------- */
.table-list { display: block; }
.row {
    display: grid; grid-template-columns: 112px minmax(0, 1.3fr) minmax(0, 1.6fr) 84px 124px 84px;
    gap: 12px; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); width: 100%;
    background: none; border-left: 0; border-right: 0; border-top: 0; text-align: left;
}
.row:last-child { border-bottom: 0; }
button.row:hover { background: var(--surface-2); }
.row .num { font-variant-numeric: tabular-nums; font-weight: 600; }
.row .sub { color: var(--ink-muted); font-size: 0.82rem; }
.row .ellip { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.row.cols-caja { grid-template-columns: 112px minmax(0, 2fr) 120px 110px 52px; }
.row.cols-clienta { grid-template-columns: minmax(0, 1.4fr) 140px 70px 110px 130px; }
.row.head { color: var(--ink-muted); font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; background: var(--surface-2); }

/* ---------- Caja ---------- */
.month-nav { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.month-nav strong { min-width: 150px; text-align: center; font-size: 1.05rem; }
.bars { display: flex; align-items: flex-end; gap: 4px; height: 150px; padding-top: 6px; }
.bar-col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 2px; height: 100%; min-width: 0; }
.bar { width: 100%; max-width: 18px; border-radius: 4px 4px 0 0; min-height: 0; }
.bar.in { background: var(--ok); } .bar.out { background: var(--bad); }
.bar-day { font-size: 0.62rem; color: var(--ink-muted); }

/* ---------- Calendario ---------- */
#calendario { min-height: 560px; }
.fc { --fc-border-color: var(--line); --fc-page-bg-color: transparent; --fc-neutral-bg-color: var(--surface-2); --fc-today-bg-color: var(--pink-soft); --fc-list-event-hover-bg-color: var(--surface-2); font-size: 0.88rem; }
.fc .fc-button { background: var(--surface-2); border: 1px solid var(--line-strong); color: var(--ink); text-transform: capitalize; box-shadow: none !important; }
.fc .fc-button-primary:not(:disabled).fc-button-active, .fc .fc-button:hover { background: var(--pink); border-color: var(--pink); color: #fff; }
.fc .fc-toolbar-title { font-size: 1.1rem; text-transform: capitalize; }
.fc-event { cursor: pointer; border: 0; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; color: var(--ink-muted); font-size: 0.82rem; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; }
.dot-ok { background: var(--ok); } .dot-pend { background: var(--warn); } .dot-block { background: var(--ink-muted); }

/* ---------- Formularios ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.span-2 { grid-column: 1 / -1; }
.form-error { color: var(--bad); font-size: 0.88rem; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 8px; background: var(--pink-soft); border-radius: 999px; padding: 4px 6px 4px 12px; font-size: 0.82rem; }
.chip button { background: none; border: none; width: 22px; height: 22px; border-radius: 50%; }
.chip button:hover { background: var(--bad-soft); color: var(--bad); }

/* ---------- Ventanas ---------- */
.modal { position: fixed; inset: 0; z-index: 50; background: rgba(8, 6, 12, 0.62); display: grid; place-items: center; padding: 16px; overflow-y: auto; }
.modal-box { position: relative; width: 100%; max-width: 560px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 18px; padding: 24px; box-shadow: 0 30px 80px -30px rgba(0, 0, 0, 0.8); max-height: calc(100vh - 32px); overflow-y: auto; }
.modal-box h2 { margin-bottom: 16px; font-size: 1.15rem; padding-right: 36px; }
.modal-close { position: absolute; top: 14px; right: 14px; width: 34px; height: 34px; border-radius: 50%; border: none; background: var(--surface-2); }
.kv { display: grid; grid-template-columns: 120px 1fr; gap: 8px 12px; margin: 14px 0; font-size: 0.92rem; }
.kv dt { color: var(--ink-muted); }
.kv dd { margin: 0; word-break: break-word; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.hist { display: grid; gap: 6px; margin-top: 8px; max-height: 240px; overflow-y: auto; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-weight: 600; font-size: 0.9rem; z-index: 100; box-shadow: var(--shadow); max-width: calc(100vw - 32px); }
.toast.error { background: var(--bad); color: #fff; }

/* ---------- Móvil ---------- */
@media (max-width: 900px) {
    .app { grid-template-columns: 1fr; }
    .side {
        position: fixed; top: auto; bottom: 0; left: 0; right: 0; height: auto; z-index: 30;
        flex-direction: row; align-items: center; padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
        border-right: 0; border-top: 1px solid var(--line);
    }
    .side-brand, .side-user { display: none; }
    .side-nav { display: flex; flex: 1; gap: 2px; overflow-x: auto; scrollbar-width: none; }
    .nav-btn { flex-direction: column; gap: 3px; padding: 8px 10px; font-size: 0.68rem; flex: 1; min-width: 62px; align-items: center; text-align: center; position: relative; }
    .nav-btn i { width: auto; font-size: 1.05rem; }
    .nav-badge { position: absolute; top: 2px; right: 10px; margin: 0; }
    .side-foot { display: none; }
    .only-sm { display: inline-grid; }
    .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    .card { padding: 12px 14px; }
    .card strong { font-size: 1.25rem; }
    .item { flex-wrap: wrap; row-gap: 6px; }
    .item-main { flex-basis: 45%; }
    .nav-btn { min-width: 0; padding: 8px 4px; }
    .main { padding: 16px 14px 100px; }
    .grid-2 { grid-template-columns: minmax(0, 1fr); }
    .filters { grid-template-columns: 1fr; }
    .hide-sm { display: none; }
    .row, .row.cols-caja, .row.cols-clienta { grid-template-columns: 1fr auto; row-gap: 4px; }
    .row.head { display: none; }
    .row > :nth-child(n+3):not(.row-actions) { grid-column: 1; }
    .row-actions { grid-column: 2; grid-row: 1 / span 3; flex-direction: column; justify-content: center; }
    .form-grid { grid-template-columns: 1fr; }
    .span-2 { grid-column: 1; }
    .kv { grid-template-columns: 100px 1fr; }
}

/* ---------- Caja ampliada ---------- */
.caja-bar { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 14px; }
.caja-bar .month-nav { margin: 0; }
.caja-actions { display: flex; gap: 8px; margin-left: auto; flex-wrap: wrap; }
.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.seg button { background: none; border: none; padding: 7px 14px; border-radius: 8px; font-weight: 600; font-size: 0.88rem; color: var(--ink-muted); }
.seg button.active { background: var(--pink-soft); color: var(--ink); }
.filters-caja { grid-template-columns: 2fr 1fr 1fr; }
.catbars { display: grid; gap: 10px; }
.catbar-head { display: flex; justify-content: space-between; gap: 10px; font-size: 0.88rem; margin-bottom: 4px; }
.catbar-head span:last-child { font-variant-numeric: tabular-nums; font-weight: 600; }
.catbar-track { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.catbar-fill { height: 100%; border-radius: 99px; background: linear-gradient(90deg, #ff2a8d, #ff5a6e); }
.catbar-fill.in { background: linear-gradient(90deg, #16a34a, #22c55e); }
.row.cols-caja { grid-template-columns: 112px minmax(0, 2fr) minmax(0, 1fr) 110px 110px 84px; }
.item .item-main span.sub { white-space: normal; }
@media (max-width: 900px) {
    .caja-actions { margin-left: 0; width: 100%; }
    .caja-actions .btn { flex: 1; }
    .filters-caja { grid-template-columns: 1fr; }
    .row.cols-caja { grid-template-columns: 1fr auto; }
}
