/* ============================================================
   Segovia App — Design System v3.0
   Mobile-first PWA · iOS 26 glass aesthetic
   ============================================================ */

/* ── RESET ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', sans-serif;
    -webkit-font-smoothing: antialiased;
    background: #010612;
    color: #eef4ff;
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea {
    font-family: inherit;
    font-size: inherit;
    color: inherit;
    background: none;
    border: none;
    outline: none;
}
img { display: block; max-width: 100%; }

/* ── TOKENS ─────────────────────────────────────────────────── */
:root {
    /* Colores */
    --bg:          #010612;
    --bg-card:     rgba(8,16,36,.70);
    --glass:       rgba(255,255,255,.06);
    --glass-hi:    rgba(255,255,255,.10);
    --border:      rgba(255,255,255,.10);
    --border-hi:   rgba(255,255,255,.20);
    --text:        #eef4ff;
    --text-sub:    rgba(210,228,255,.72);
    --text-muted:  rgba(150,180,230,.52);
    --accent:      rgba(160,200,255,.90);

    /* Semánticos */
    --ok:    #4ade80;  --ok-bg:  rgba(74,222,128,.10);  --ok-bd:  rgba(74,222,128,.28);
    --warn:  #fbbf24;  --warn-bg:rgba(251,191,36,.10);  --warn-bd:rgba(251,191,36,.28);
    --error: #f87171;  --err-bg: rgba(248,113,113,.10); --err-bd: rgba(248,113,113,.28);

    /* Shell */
    --topbar-h:    52px;
    --nav-h:       62px;
    --sidebar-w:   272px;

    /* Radios */
    --r-sm: 12px; --r-md: 16px; --r-lg: 20px; --r-xl: 26px; --r-pill: 999px;
}

/* ── SHELL — modo app ───────────────────────────────────────── */
body.app {
    padding-top: var(--topbar-h);
    padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px));
}

/* ── TOPBAR ─────────────────────────────────────────────────── */
.topbar {
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 100;
    height: var(--topbar-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 14px;
    background: rgba(1,6,18,.82);
    backdrop-filter: blur(24px) saturate(1.5);
    -webkit-backdrop-filter: blur(24px) saturate(1.5);
    border-bottom: 1px solid var(--border);
}
.topbar-brand {
    position: absolute;
    left: 50%; transform: translateX(-50%);
    font-size: 13px;
    font-weight: 900;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--text);
    pointer-events: none;
}
.topbar-btn {
    width: 36px; height: 36px;
    border-radius: 11px;
    border: 1px solid var(--border);
    background: var(--glass);
    display: grid;
    place-items: center;
    cursor: pointer;
    color: var(--text);
    -webkit-tap-highlight-color: transparent;
    position: relative;
    flex-shrink: 0;
}
.topbar-btn:active { background: var(--glass-hi); }
.rank-dot {
    position: absolute;
    bottom: 4px; right: 4px;
    width: 8px; height: 8px;
    border-radius: 50%;
    border: 1.5px solid #010612;
}
.rank-dot.vip, .rank-dot.exclusivo { background: #EF9F27; }
.rank-dot.casa { background: #1D9E75; }

/* ── SIDEBAR ────────────────────────────────────────────────── */
.sb-overlay {
    position: fixed; inset: 0;
    z-index: 200;
    background: rgba(0,0,0,.55);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    opacity: 0;
    visibility: hidden;
    transition: opacity .24s ease, visibility .24s ease;
    -webkit-tap-highlight-color: transparent;
}
.sb-overlay.open {
    opacity: 1;
    visibility: visible;
}
.sb-panel {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 201;
    width: var(--sidebar-w);
    max-width: 85vw;
    background: rgba(3,8,22,.98);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateX(-100%);
    visibility: hidden;
    transition: transform .26s cubic-bezier(.4,0,.2,1), visibility .26s;
    will-change: transform;
}
.sb-panel.open {
    transform: translateX(0);
    visibility: visible;
}
.sb-head {
    padding: calc(var(--topbar-h) + 14px) 18px 16px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.sb-name  { font-size: 16px; font-weight: 800; color: var(--text); }
.sb-phone { font-size: 12px; color: var(--text-muted); font-family: monospace; margin-top: 2px; }
.sb-rank-pill {
    display: inline-flex; align-items: center; gap: 5px;
    margin-top: 8px; padding: 3px 10px;
    background: var(--glass); border: 1px solid var(--border);
    border-radius: var(--r-pill);
    font-size: 11px; font-weight: 700; color: var(--text-sub);
}
.sb-body { flex: 1; overflow-y: auto; padding: 8px 0; overscroll-behavior: contain; }
.sb-section-label {
    padding: 10px 18px 4px;
    font-size: 9px; letter-spacing: .18em; text-transform: uppercase;
    color: var(--text-muted); font-weight: 700;
}
.sb-item {
    display: flex; align-items: center; gap: 10px;
    padding: 11px 18px;
    font-size: 13px; font-weight: 600;
    color: var(--text-sub);
    cursor: pointer;
    transition: background .12s, color .12s;
    -webkit-tap-highlight-color: transparent;
    text-decoration: none;
    border-left: 2.5px solid transparent;
}
.sb-item:active, .sb-item.active {
    background: var(--glass);
    color: var(--text);
}
.sb-item.active { border-left-color: var(--accent); }
.sb-icon { font-size: 17px; width: 22px; text-align: center; flex-shrink: 0; }
.sb-divider { height: 1px; background: var(--border); margin: 6px 0; }
.sb-foot {
    flex-shrink: 0;
    padding: 12px 18px calc(12px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid var(--border);
}
.sb-logout {
    display: flex; align-items: center; gap: 8px;
    padding: 9px 0;
    font-size: 13px; font-weight: 700;
    color: rgba(248,113,113,.70);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    text-decoration: none;
}

/* ── NAV INFERIOR ───────────────────────────────────────────── */
.bottom-nav {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 100;
    height: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: rgba(1,6,18,.92);
    backdrop-filter: blur(24px) saturate(1.5);
    -webkit-backdrop-filter: blur(24px) saturate(1.5);
    border-top: 1px solid var(--border);
    display: grid;
    grid-template-columns: repeat(4, 1fr);
}
.nav-tab {
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 3px;
    font-size: 9px; font-weight: 700;
    letter-spacing: .05em; text-transform: uppercase;
    color: var(--text-muted);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    position: relative;
    text-decoration: none;
    padding: 6px 4px;
    transition: color .14s;
}
.nav-tab.active { color: var(--text); }
.nav-tab.active::before {
    content: '';
    position: absolute;
    top: 0; left: 22%; right: 22%;
    height: 2px;
    background: var(--accent);
    border-radius: 0 0 3px 3px;
}
.nav-tab-icon { font-size: 22px; line-height: 1; }
.nav-tab .pts-dot {
    position: absolute;
    top: 6px; right: calc(50% - 16px);
    width: 7px; height: 7px;
    background: var(--accent);
    border-radius: 50%;
    border: 1.5px solid #010612;
    display: none;
}
.nav-tab.has-pts .pts-dot { display: block; }

/* ── PÁGINA ─────────────────────────────────────────────────── */
.page {
    max-width: 640px;
    margin: 0 auto;
    padding: 16px 16px 24px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

/* ── COMPONENTES ────────────────────────────────────────────── */

/* Cards */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    backdrop-filter: blur(16px) saturate(1.4);
    -webkit-backdrop-filter: blur(16px) saturate(1.4);
    padding: 18px;
}
.card.hero { padding: 22px; }
.card.tight { padding: 14px; }

/* Eyebrow */
.eyebrow {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .22em;
    color: var(--accent);
    opacity: .80;
    margin-bottom: 6px;
}

/* Títulos */
h1 { font-size: clamp(24px,6vw,40px); font-weight: 800; line-height: 1.05; }
h2 { font-size: 18px; font-weight: 800; }
h3 { font-size: 15px; font-weight: 700; }
p  { color: var(--text-sub); line-height: 1.6; font-size: 14px; }

/* Botones */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-height: 44px;
    padding: 10px 18px;
    border-radius: var(--r-pill);
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    white-space: nowrap;
    transition: opacity .14s, transform .12s;
    text-decoration: none;
    border: 1px solid rgba(255,255,255,.18);
    background: var(--glass);
    color: var(--text);
    position: relative;
    isolation: isolate;
    overflow: hidden;
}
.btn::before {
    content: '';
    position: absolute;
    inset: 1px;
    border-radius: inherit;
    background: linear-gradient(175deg, rgba(255,255,255,.14), transparent 44%);
    pointer-events: none;
}
.btn:active { transform: scale(.97); opacity: .88; }

.btn.primary {
    background: linear-gradient(155deg, rgba(236,248,255,.72), rgba(175,210,255,.36));
    border-color: rgba(255,255,255,.48);
    color: #08111e;
    box-shadow: inset 0 1px 0 rgba(255,255,255,.70);
}
.btn.ghost {
    background: rgba(255,255,255,.04);
    border-color: rgba(255,255,255,.10);
    color: var(--text-sub);
}
.btn.danger  { background: rgba(248,113,113,.10); border-color: rgba(248,113,113,.24); color: #fecaca; }
.btn.sm      { min-height: 34px; padding: 6px 14px; font-size: 12px; }
.btn.full    { width: 100%; }
.btn.square  { width: 44px; min-width: 44px; padding: 0; border-radius: var(--r-sm); }

/* Inputs */
.input-wrap { display: flex; flex-direction: column; gap: 6px; }
.input-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .10em; color: var(--text-muted); }
.input {
    width: 100%;
    background: rgba(5,10,28,.60);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: var(--r-sm);
    padding: 12px 14px;
    font-size: 15px;
    transition: border-color .16s, box-shadow .16s;
}
.input:focus { border-color: rgba(150,195,255,.55); box-shadow: 0 0 0 3px rgba(90,150,255,.09); }
.input::placeholder { color: var(--text-muted); }
select.input { appearance: none; -webkit-appearance: none; }

/* Badges */
.badge {
    display: inline-flex;
    padding: 3px 9px;
    border-radius: var(--r-pill);
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .06em;
    background: var(--glass);
    border: 1px solid var(--border);
    color: var(--text-sub);
}
.badge.ok       { background: var(--ok-bg);   border-color: var(--ok-bd);   color: #a7f3c5; }
.badge.warn     { background: var(--warn-bg);  border-color: var(--warn-bd); color: #fde68a; }
.badge.error    { background: var(--err-bg);   border-color: var(--err-bd);  color: #fecaca; }
.badge.claimed  { background: var(--warn-bg);  border-color: var(--warn-bd); color: #fde68a; }
.badge.checked_in { background: var(--ok-bg);  border-color: var(--ok-bd);   color: #a7f3c5; }
.badge.cancelled  { background: var(--err-bg); border-color: var(--err-bd);  color: #fecaca; }

/* Alerts */
.alert {
    border-radius: var(--r-md);
    padding: 12px 16px;
    font-size: 13px;
    font-weight: 700;
    border: 1px solid;
}
.alert.ok    { background: var(--ok-bg);   border-color: var(--ok-bd);   color: #a7f3c5; }
.alert.warn  { background: var(--warn-bg); border-color: var(--warn-bd); color: #fde68a; }
.alert.error { background: var(--err-bg);  border-color: var(--err-bd);  color: #fecaca; }

/* Scan result */
.scan-result {
    border-radius: var(--r-md);
    padding: 14px 16px;
    font-size: 14px;
    font-weight: 700;
    border: 1px solid var(--border);
    background: var(--glass);
    display: none;
    margin-top: 12px;
}
.scan-result.ok    { display: block; background: var(--ok-bg);   border-color: var(--ok-bd);   color: #a7f3c5; }
.scan-result.warn  { display: block; background: var(--warn-bg); border-color: var(--warn-bd); color: #fde68a; }
.scan-result.error { display: block; background: var(--err-bg);  border-color: var(--err-bd);  color: #fecaca; }

/* QR reader */
.qr-reader {
    width: 100%;
    border-radius: var(--r-lg);
    overflow: hidden;
    background: rgba(0,0,0,.3);
    border: 1px solid var(--border);
    min-height: 200px;
    display: grid;
    place-items: center;
}
.qr-reader-placeholder { color: var(--text-muted); font-size: 13px; font-weight: 700; padding: 20px; text-align: center; }

/* Tablas */
.table-wrap { overflow-x: auto; width: 100%; }
table { width: 100%; border-collapse: collapse; min-width: 400px; font-size: 13px; }
th { color: var(--text-muted); font-size: 10px; text-transform: uppercase; letter-spacing: .12em; font-weight: 700; padding: 10px 10px 6px; text-align: left; }
td { padding: 10px; border-top: 1px solid rgba(255,255,255,.05); vertical-align: middle; }

/* Mono */
.mono { font-family: ui-monospace, 'SF Mono', monospace; letter-spacing: .10em; font-weight: 800; }

/* Stats */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(100px,1fr)); gap: 10px; }
.stat { background: var(--glass); border: 1px solid var(--border); border-radius: var(--r-md); padding: 14px 12px; }
.stat-value { font-size: 26px; font-weight: 800; letter-spacing: -.02em; }
.stat-label { font-size: 10px; text-transform: uppercase; letter-spacing: .10em; color: var(--text-muted); font-weight: 700; margin-top: 2px; }

/* Misc */
.section-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .12em; color: var(--text-muted); }
.divider { height: 1px; background: var(--border); }
.muted { color: var(--text-muted); font-size: 13px; }
.full-row { grid-column: 1/-1; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.pill-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* Flash flotante */
.flash-wrap {
    position: fixed;
    top: calc(var(--topbar-h) + 8px);
    left: 50%; transform: translateX(-50%);
    z-index: 300;
    width: min(480px, calc(100% - 24px));
    pointer-events: none;
    transition: opacity .4s;
}

/* Rank backgrounds */
.rank-bg-vip       { background: rgba(239,159,39,.14); }
.rank-bg-exclusivo { background: rgba(239,159,39,.10); }
.rank-bg-casa      { background: rgba(29,158,117,.12); }

/* Animations */
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.55} }
.pulse { animation: pulse 1.4s ease-in-out 4; }

/* ── DESKTOP ─────────────────────────────────────────────────── */
@media (min-width: 640px) {
    .page { padding: 24px 24px 32px; }
    .card { border-radius: var(--r-xl); }
    h1 { font-size: 42px; }
}
@media (min-width: 900px) {
    body.app { padding-left: var(--sidebar-w); }
    .sb-overlay { display: none !important; }
    .sb-panel {
        transform: translateX(0) !important;
        visibility: visible !important;
        transition: none;
    }
    .topbar { left: var(--sidebar-w); }
    #sbOpenBtn { display: none; }
    .bottom-nav { left: var(--sidebar-w); }
}
