/* ===========================
   StreamSaaS PWA — Global CSS
   =========================== */

@import url('https://fonts.googleapis.com/css2?family=Space+Mono:wght@400;700&family=Syne:wght@400;500;600;700;800&display=swap');

:root {
    --bg: #080A0E;
    --bg2: #0E1118;
    --bg3: #141820;
    --surface: rgba(255,255,255,0.04);
    --border: rgba(255,255,255,0.07);
    --border2: rgba(255,255,255,0.12);
    --primary: #00D4E0;
    --primary-dim: rgba(0,212,224,0.12);
    --primary-glow: rgba(0,212,224,0.25);
    --accent: #7B5EF8;
    --text: #F0F2F7;
    --text2: #8892A4;
    --text3: #525C6E;
    --success: #00E676;
    --warn: #FFB300;
    --danger: #FF4B55;
    --nav-h: 72px;
    --font-head: 'Syne', sans-serif;
    --font-mono: 'Space Mono', monospace;
    --radius: 18px;
    --radius-sm: 10px;
    --radius-xs: 6px;
}

*, *::before, *::after { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html { font-size: 16px; }

body {
    margin: 0;
    font-family: var(--font-head);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    padding-bottom: calc(var(--nav-h) + 20px);
    background-image:
        radial-gradient(ellipse 60% 40% at 90% -10%, rgba(0,212,224,0.08) 0%, transparent 60%),
        radial-gradient(ellipse 40% 30% at 10% 90%, rgba(123,94,248,0.06) 0%, transparent 50%);
    overscroll-behavior: none;
    -webkit-font-smoothing: antialiased;
}

/* === SYNC PILL === */
.sync-pill {
    position: fixed;
    top: 12px;
    right: 16px;
    z-index: 200;
    background: rgba(0,230,118,0.12);
    border: 1px solid rgba(0,230,118,0.25);
    border-radius: 20px;
    padding: 5px 12px 5px 8px;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-family: var(--font-mono);
    color: var(--success);
    letter-spacing: 0.02em;
    transition: all 0.3s;
}
.sync-pill.offline {
    background: rgba(255,75,85,0.12);
    border-color: rgba(255,75,85,0.25);
    color: var(--danger);
}
.sync-dot {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--success);
    animation: pulse-dot 2s ease infinite;
}
.sync-dot.offline { background: var(--danger); animation: none; }
@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* === HEADER === */
.app-header {
    padding: 20px 20px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.header-greeting {
    margin: 0;
    font-size: 13px;
    color: var(--text2);
    font-weight: 400;
}
.header-name {
    margin: 2px 0 0;
    font-size: 22px;
    font-weight: 800;
    letter-spacing: -0.5px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.biz-badge {
    font-size: 10px;
    font-weight: 700;
    font-family: var(--font-mono);
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    border: 1px solid var(--primary);
    border-radius: 4px;
    padding: 1px 6px;
    -webkit-text-fill-color: initial;
    color: var(--primary);
}
.avatar-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
}
.avatar {
    width: 40px; height: 40px;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 15px;
    color: white;
}

/* === PAGE CONTENT === */
.page-content {
    padding: 20px 16px 0;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

/* === HERO CARD === */
.hero-card {
    background: linear-gradient(145deg, #0E1820 0%, #091318 100%);
    border: 1px solid rgba(0,212,224,0.2);
    border-radius: var(--radius);
    padding: 24px 22px 20px;
    position: relative;
    overflow: hidden;
}
.hero-card::after {
    content: '';
    position: absolute;
    top: -40px; right: -40px;
    width: 160px; height: 160px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(0,212,224,0.12) 0%, transparent 70%);
    pointer-events: none;
}
.hero-label {
    font-size: 12px;
    font-family: var(--font-mono);
    color: var(--primary);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin-bottom: 6px;
}
.hero-amount {
    font-size: 44px;
    font-weight: 800;
    line-height: 1;
    letter-spacing: -2px;
    margin-bottom: 12px;
}
.hero-cents { font-size: 24px; opacity: 0.5; }
.hero-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 18px;
}
.trend-chip {
    font-size: 12px;
    font-family: var(--font-mono);
    padding: 3px 10px;
    border-radius: 20px;
    font-weight: 700;
}
.trend-chip.positive {
    background: rgba(0,230,118,0.12);
    color: var(--success);
    border: 1px solid rgba(0,230,118,0.25);
}
.trend-chip.negative {
    background: rgba(255,75,85,0.12);
    color: var(--danger);
    border: 1px solid rgba(255,75,85,0.25);
}
.hero-sub { font-size: 12px; color: var(--text3); }
.hero-bar {
    height: 4px;
    background: rgba(255,255,255,0.07);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 6px;
}
.hero-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    border-radius: 2px;
    transition: width 1s ease;
}
.hero-bar-labels {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    font-family: var(--font-mono);
    color: var(--text3);
}

/* === STATS ROW === */
.stats-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}
.stat-tile {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px 12px;
    text-align: center;
}
.stat-icon {
    width: 32px; height: 32px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 8px;
    font-size: 14px;
}
.stat-icon.blue { background: rgba(0,136,255,0.15); color: #4FC3F7; }
.stat-icon.green { background: rgba(0,230,118,0.12); color: var(--success); }
.stat-icon.amber { background: rgba(255,179,0,0.12); color: var(--warn); }
.stat-icon.red { background: rgba(255,75,85,0.12); color: var(--danger); }
.stat-val {
    font-size: 24px;
    font-weight: 800;
    line-height: 1;
    margin-bottom: 3px;
    font-family: var(--font-mono);
}
.stat-key {
    font-size: 10px;
    color: var(--text3);
    font-weight: 500;
    letter-spacing: 0.02em;
}

/* === SECTION LABEL === */
.section-label {
    font-size: 12px;
    font-family: var(--font-mono);
    color: var(--text2);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: -6px;
}
.badge-alert {
    background: rgba(255,75,85,0.15);
    color: var(--danger);
    border: 1px solid rgba(255,75,85,0.3);
    font-size: 10px;
    font-weight: 700;
    padding: 1px 7px;
    border-radius: 10px;
}

/* === GLASS CARD === */
.glass-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

/* === QUICK SALE === */
.quick-sale {
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.qs-select-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(0,0,0,0.3);
    border: 1px solid var(--border2);
    border-radius: var(--radius-sm);
    padding: 0 14px;
    position: relative;
}
.qs-icon { color: var(--primary); font-size: 14px; flex-shrink: 0; }
.qs-select {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text);
    font-family: var(--font-head);
    font-size: 14px;
    padding: 13px 0;
    outline: none;
    appearance: none;
    cursor: pointer;
}
.qs-select option { background: #1a1f2e; color: var(--text); }
.qs-arrow { color: var(--text3); font-size: 11px; flex-shrink: 0; }
.qs-date-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px;
}
.qs-date-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.qs-date-field label {
    font-size: 10px;
    font-family: var(--font-mono);
    color: var(--text3);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.qs-date-field input {
    background: rgba(0,0,0,0.3);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    color: var(--text);
    font-family: var(--font-mono);
    font-size: 11px;
    padding: 8px 6px;
    outline: none;
    width: 100%;
    -webkit-appearance: none;
}
.qs-date-field input:focus { border-color: var(--primary); }
.qs-date-field input[type="number"] { -moz-appearance: textfield; }

/* === BUTTONS === */
.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, #007c82 100%);
    color: #000;
    border: none;
    padding: 15px;
    width: 100%;
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 700;
    font-family: var(--font-head);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.1s;
    box-shadow: 0 6px 20px rgba(0,212,224,0.2);
}
.btn-primary:active { transform: scale(0.98); opacity: 0.9; }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-mini {
    background: var(--primary-dim);
    border: 1px solid rgba(0,212,224,0.25);
    color: var(--primary);
    font-family: var(--font-head);
    font-size: 12px;
    font-weight: 600;
    padding: 5px 12px;
    border-radius: 20px;
    cursor: pointer;
    white-space: nowrap;
}

.btn-secondary {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border2);
    padding: 13px;
    width: 100%;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    font-family: var(--font-head);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

/* === PLATFORM LIST === */
.platform-list { padding: 16px 18px; display: flex; flex-direction: column; gap: 14px; }
.platform-item {
    display: flex;
    align-items: center;
    gap: 10px;
}
.platform-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.platform-name { font-size: 13px; font-weight: 600; min-width: 55px; }
.platform-bar-wrap {
    flex: 1;
    height: 4px;
    background: rgba(255,255,255,0.06);
    border-radius: 2px;
    overflow: hidden;
}
.platform-bar { height: 100%; border-radius: 2px; transition: width 1s ease; }
.platform-pct { font-size: 11px; font-family: var(--font-mono); color: var(--text2); min-width: 30px; text-align: right; }

/* === VENCIMIENTOS === */
.venc-list { display: flex; flex-direction: column; gap: 8px; }
.venc-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.venc-card.urgent { border-color: rgba(255,75,85,0.25); background: rgba(255,75,85,0.05); }
.venc-left { display: flex; align-items: center; gap: 10px; }
.venc-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.venc-dot.red { background: var(--danger); box-shadow: 0 0 8px var(--danger); }
.venc-dot.amber { background: var(--warn); }
.venc-name { font-size: 14px; font-weight: 600; }
.venc-detail { font-size: 11px; color: var(--text3); margin-top: 1px; }
.venc-right { display: flex; align-items: center; gap: 10px; }
.venc-days { font-size: 12px; font-family: var(--font-mono); font-weight: 700; }
.venc-days.red { color: var(--danger); }
.venc-days.amber { color: var(--warn); }

/* === BOTTOM NAV === */
.bottom-nav {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: var(--nav-h);
    background: rgba(8,10,14,0.92);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    z-index: 100;
}
.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    text-decoration: none;
    color: var(--text3);
    font-size: 10px;
    font-family: var(--font-mono);
    letter-spacing: 0.03em;
    transition: color 0.2s;
    padding: 8px 0;
}
.nav-item i { font-size: 20px; transition: transform 0.2s; }
.nav-item.active { color: var(--primary); }
.nav-item.active i { transform: scale(1.1); filter: drop-shadow(0 0 6px rgba(0,212,224,0.5)); }

/* === PAGE HEADER (inner views) === */
.page-header {
    padding: 20px 20px 0;
    display: flex;
    align-items: center;
    gap: 14px;
}
.back-btn {
    width: 38px; height: 38px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text2);
    font-size: 14px;
    flex-shrink: 0;
    text-decoration: none;
}
.page-title {
    margin: 0;
    font-size: 20px;
    font-weight: 800;
    letter-spacing: -0.5px;
}

/* === SEARCH INPUT === */
.search-wrap {
    position: relative;
    margin: 0;
}
.search-wrap i {
    position: absolute;
    left: 14px; top: 50%;
    transform: translateY(-50%);
    color: var(--text3);
    font-size: 14px;
    pointer-events: none;
}
.search-input {
    width: 100%;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: var(--font-head);
    font-size: 14px;
    padding: 12px 14px 12px 38px;
    outline: none;
    transition: border-color 0.2s;
}
.search-input::placeholder { color: var(--text3); }
.search-input:focus { border-color: var(--primary); }

/* === FILTER CHIPS === */
.filter-chips {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: none;
}
.filter-chips::-webkit-scrollbar { display: none; }
.chip {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 6px 14px;
    font-size: 12px;
    font-family: var(--font-mono);
    color: var(--text2);
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}
.chip.active {
    background: var(--primary-dim);
    border-color: rgba(0,212,224,0.35);
    color: var(--primary);
}

/* === LIST ITEMS === */
.list-item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: inherit;
    transition: border-color 0.2s;
}
.list-item:active { border-color: var(--border2); }
.list-icon {
    width: 42px; height: 42px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}
.list-body { flex: 1; min-width: 0; }
.list-title { font-size: 14px; font-weight: 700; margin: 0 0 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-sub { font-size: 12px; color: var(--text2); margin: 0; }
.list-right { text-align: right; flex-shrink: 0; }
.list-amount { font-size: 15px; font-weight: 700; font-family: var(--font-mono); }
.list-date { font-size: 11px; color: var(--text3); margin-top: 2px; }

/* === STATUS BADGES === */
.badge {
    font-size: 10px;
    font-weight: 700;
    font-family: var(--font-mono);
    padding: 2px 8px;
    border-radius: 10px;
    display: inline-block;
}
.badge-success { background: rgba(0,230,118,0.12); color: var(--success); border: 1px solid rgba(0,230,118,0.25); }
.badge-warn { background: rgba(255,179,0,0.12); color: var(--warn); border: 1px solid rgba(255,179,0,0.25); }
.badge-danger { background: rgba(255,75,85,0.12); color: var(--danger); border: 1px solid rgba(255,75,85,0.25); }
.badge-muted { background: var(--surface); color: var(--text3); border: 1px solid var(--border); }
.badge-primary { background: var(--primary-dim); color: var(--primary); border: 1px solid rgba(0,212,224,0.25); }

/* === FORM FIELDS === */
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-label {
    font-size: 11px;
    font-family: var(--font-mono);
    color: var(--text3);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.form-input, .form-select {
    background: rgba(0,0,0,0.35);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: var(--font-head);
    font-size: 14px;
    padding: 12px 14px;
    outline: none;
    width: 100%;
    transition: border-color 0.2s;
    -webkit-appearance: none;
}
.form-input:focus, .form-select:focus { border-color: var(--primary); }
.form-select option { background: #1a1f2e; }

/* === TOGGLE === */
.toggle-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
}
.toggle-row:last-child { border-bottom: none; }
.toggle-label { font-size: 14px; font-weight: 500; }
.toggle-sub { font-size: 12px; color: var(--text3); margin-top: 2px; }
.toggle {
    position: relative;
    width: 44px; height: 24px;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: var(--bg3);
    border: 1px solid var(--border2);
    border-radius: 12px;
    transition: 0.3s;
}
.toggle-slider::before {
    content: '';
    position: absolute;
    width: 18px; height: 18px;
    left: 2px; bottom: 2px;
    background: var(--text3);
    border-radius: 50%;
    transition: 0.3s;
}
.toggle input:checked + .toggle-slider { background: var(--primary-dim); border-color: var(--primary); }
.toggle input:checked + .toggle-slider::before { background: var(--primary); transform: translateX(20px); }

/* === DIVIDER === */
.divider { height: 1px; background: var(--border); margin: 0 -16px; }

/* === TOAST === */
.toast {
    position: fixed;
    bottom: calc(var(--nav-h) + 16px);
    left: 50%; transform: translateX(-50%) translateY(20px);
    background: #1e232e;
    border: 1px solid var(--border2);
    border-radius: 30px;
    padding: 10px 20px;
    font-size: 13px;
    font-family: var(--font-mono);
    white-space: nowrap;
    opacity: 0;
    transition: all 0.3s;
    z-index: 999;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.toast-success { border-color: rgba(0,230,118,0.35); color: var(--success); }
.toast.toast-warn { border-color: rgba(255,179,0,0.35); color: var(--warn); }
.toast.toast-danger { border-color: rgba(255,75,85,0.35); color: var(--danger); }

/* === FAB === */
.fab {
    position: fixed;
    bottom: calc(var(--nav-h) + 16px);
    right: 16px;
    width: 54px; height: 54px;
    border-radius: 18px;
    background: linear-gradient(135deg, var(--primary) 0%, #007c82 100%);
    border: none;
    color: #000;
    font-size: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(0,212,224,0.3);
    z-index: 50;
    transition: transform 0.2s;
}
.fab:active { transform: scale(0.94); }

/* === EMPTY STATE === */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text3);
}
.empty-state i { font-size: 40px; margin-bottom: 12px; display: block; }
.empty-state p { font-size: 14px; margin: 0; }

/* === MODAL SHEET === */
.sheet-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    z-index: 500;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}
.sheet-overlay.open { opacity: 1; pointer-events: all; }
.sheet {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: #0E1118;
    border-top: 1px solid var(--border);
    border-radius: 24px 24px 0 0;
    padding: 16px 20px calc(env(safe-area-inset-bottom) + 24px);
    z-index: 501;
    transform: translateY(100%);
    transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1);
    max-height: 90vh;
    overflow-y: auto;
}
.sheet.open { transform: translateY(0); }
.sheet-handle {
    width: 40px; height: 4px;
    background: var(--border2);
    border-radius: 2px;
    margin: 0 auto 20px;
}
.sheet-title { font-size: 18px; font-weight: 800; margin: 0 0 20px; }

/* === UTILITY === */
.mt-0 { margin-top: 0 !important; }
.mb-0 { margin-bottom: 0 !important; }
.text-primary { color: var(--primary); }
.text-muted { color: var(--text2); }
.text-mono { font-family: var(--font-mono); }
.fw-bold { font-weight: 700; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }