@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600;700&display=swap');

:root {
    --bg: #0a0f1a;
    --bg-subtle: #0e1422;
    --surface: #141c2b;
    --surface-hover: #1a2538;
    --surface-raised: #1e293b;
    --border: #1e2d42;
    --border-light: #2a3a52;
    --text: #e8ecf4;
    --text-secondary: #8a9bb5;
    --text-muted: #5a6a82;
    --accent: #5ba8a0;
    --accent-glow: rgba(91, 168, 160, .12);
    --accent-dim: #4a8f88;
    --amber: #c4a45a;
    --amber-dim: rgba(196, 164, 90, .1);
    --red: #c45a5a;
    --red-dim: rgba(196, 90, 90, .1);
    --blue: #5a8fb8;
    --green: #5ab87a;
    --purple: #8878a8;
    --pink: #a87888;
    --orange: #b8926a;
    --radius: 10px;
    --radius-sm: 6px;
    --font: 'Outfit', -apple-system, sans-serif;
    --mono: 'JetBrains Mono', 'Fira Code', monospace;
    --shadow: 0 1px 3px rgba(0,0,0,.4), 0 0 0 1px var(--border);
    --shadow-lg: 0 4px 24px rgba(0,0,0,.5);
    --transition: .2s cubic-bezier(.4,0,.2,1);
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html { color-scheme: dark; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse at 20% 0%, rgba(91,168,160,.03) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 100%, rgba(90,143,184,.02) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

/* ===== LOGIN ===== */
.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    position: relative;
}
.login-wrap::before {
    content: '';
    position: absolute;
    top: -40%; left: -20%;
    width: 140%; height: 140%;
    background: radial-gradient(circle at 30% 40%, rgba(0,212,170,.08), transparent 60%),
                radial-gradient(circle at 70% 60%, rgba(56,189,248,.06), transparent 50%);
    pointer-events: none;
}
.login-card {
    position: relative;
    width: 380px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 2.5rem 2rem;
    box-shadow: var(--shadow-lg);
}
.login-brand { text-align: center; margin-bottom: 2rem; }
.login-brand h1 {
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: -.02em;
    color: var(--text);
}
.login-brand p { color: var(--text-muted); font-size: .85rem; margin-top: .25rem; font-weight: 300; letter-spacing: .5px; text-transform: uppercase; }
.login-field { margin-bottom: 1rem; }
.login-field label { display: block; font-size: .75rem; color: var(--text-secondary); margin-bottom: .35rem; font-weight: 500; text-transform: uppercase; letter-spacing: .5px; }
.login-field input {
    width: 100%;
    padding: .7rem .85rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: var(--font);
    font-size: .9rem;
    transition: border-color var(--transition);
    outline: none;
}
.login-field input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.btn-login {
    width: 100%;
    padding: .75rem;
    background: var(--accent);
    color: var(--bg);
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: .9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    margin-top: .5rem;
}
.btn-login:hover { background: var(--accent-dim); }
.btn-login:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.login-error { color: var(--red); text-align: center; margin-top: .75rem; font-size: .8rem; display: none; }

/* ===== APP SHELL ===== */
#app { display: none; min-height: 100vh; position: relative; z-index: 1; }
#app.active { display: flex; }

/* ===== SIDEBAR ===== */
.sidebar {
    width: 240px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    position: fixed;
    top: 0; left: 0; bottom: 0;
    display: flex;
    flex-direction: column;
    z-index: 200;
    overflow-y: auto;
}
.sidebar-brand {
    padding: 1.5rem 1.25rem 1rem;
    border-bottom: 1px solid var(--border);
}
.sidebar-brand h2 {
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: -.01em;
    color: var(--text);
}
.sidebar-brand span { display: block; font-size: .7rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1.5px; font-weight: 500; margin-top: .15rem; }

.sidebar-nav { padding: .5rem 0; flex: 1; }
.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: .65rem 1.25rem;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: .85rem;
    font-weight: 400;
    border-left: 3px solid transparent;
    transition: all var(--transition);
}
.sidebar-nav a .ico { width: 16px; height: 16px; flex-shrink: 0; opacity: .6; }
.sidebar-nav a svg.ico { display: block; }
.sidebar-nav a:hover { color: var(--text); background: var(--surface-hover); }
.sidebar-nav a.active {
    color: var(--accent);
    background: var(--accent-glow);
    border-left-color: var(--accent);
    font-weight: 500;
}
.sidebar-nav a.active .ico { opacity: 1; }

.sidebar-footer { padding: 1rem 1.25rem; border-top: 1px solid var(--border); }
.btn-logout {
    width: 100%;
    padding: .5rem;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-family: var(--font);
    font-size: .78rem;
    cursor: pointer;
    transition: all var(--transition);
}
.btn-logout:hover { border-color: var(--red); color: var(--red); }

/* ===== MAIN ===== */
.main {
    margin-left: 240px;
    flex: 1;
    padding: 1.5rem 2rem;
    min-width: 0;
    position: relative;
}

/* ===== FILTERS BAR ===== */
.filters-bar {
    display: flex;
    align-items: center;
    gap: .75rem;
    flex-wrap: wrap;
    padding: .85rem 1.15rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
}
.filter-group { display: flex; align-items: center; gap: .35rem; }
.filter-group label { font-size: .7rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; font-weight: 500; white-space: nowrap; }
.filter-input {
    padding: .4rem .6rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 5px;
    color: var(--text);
    font-family: var(--mono);
    font-size: .8rem;
    outline: none;
    transition: border-color var(--transition);
}
.filter-input:focus { border-color: var(--accent); }
select.filter-input { font-family: var(--font); }
.btn-apply {
    padding: .4rem 1.15rem;
    background: var(--accent);
    color: var(--bg);
    border: none;
    border-radius: 5px;
    font-family: var(--font);
    font-size: .8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    margin-left: auto;
}
.btn-apply:hover { filter: brightness(1.15); }

/* ===== KPIS ===== */
.kpi-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(155px, 1fr));
    gap: .75rem;
    margin-bottom: 1.5rem;
}
.kpi {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: .9rem 1rem;
    position: relative;
    overflow: hidden;
}
.kpi::before {
    content: '';
    position: absolute;
    top: 0; left: 0;
    width: 3px;
    height: 100%;
    background: var(--accent);
    opacity: .5;
    border-radius: 3px 0 0 3px;
}
.kpi-label {
    display: block;
    font-size: .65rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .8px;
    font-weight: 500;
}
.kpi-value {
    display: block;
    font-family: var(--mono);
    font-size: 1.45rem;
    font-weight: 700;
    color: var(--text);
    margin-top: .15rem;
    letter-spacing: -.02em;
}
.kpi-value small {
    font-size: .7rem;
    color: var(--text-secondary);
    font-weight: 400;
}
.kpi.accent-amber::before { background: var(--amber); }
.kpi.accent-red::before { background: var(--red); }
.kpi.accent-blue::before { background: var(--blue); }
.kpi.accent-purple::before { background: var(--purple); }

/* ===== VIEW TOGGLE (global) ===== */
.view-toggle {
    display: flex;
    gap: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
    margin-left: auto;
}
.view-btn {
    padding: .35rem .75rem;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-family: var(--font);
    font-size: .7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .5px;
    cursor: pointer;
    transition: all var(--transition);
}
.view-btn:hover { color: var(--text); background: var(--surface-hover); }
.view-btn.active { color: var(--bg); background: var(--accent); }

/* ===== CHARTS ===== */
.chart-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.chart-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.15rem;
}
.chart-panel h3 {
    font-size: .78rem;
    color: var(--text-secondary);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: .5px;
    margin-bottom: .85rem;
    padding-bottom: .5rem;
    border-bottom: 1px solid var(--border);
}
.chart-panel canvas { max-height: 280px; }
.chart-panel.full { grid-column: 1 / -1; }

/* ===== TABLES ===== */
.tbl-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.15rem;
    margin-bottom: 1rem;
    overflow-x: auto;
}
.tbl-panel h3 {
    font-size: .78rem;
    color: var(--text-secondary);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: .5px;
    margin-bottom: .75rem;
}
.tbl-note {
    font-size: .7rem;
    color: var(--text-muted);
    margin-top: .5rem;
    line-height: 1.4;
}
table { width: 100%; border-collapse: collapse; }
th {
    text-align: left;
    padding: .55rem .65rem;
    font-size: .68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-light);
    white-space: nowrap;
}
td {
    padding: .5rem .65rem;
    font-size: .83rem;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
td.mono { font-family: var(--mono); font-size: .8rem; }
tr:hover td { background: var(--surface-hover); }
.txt-r { text-align: right; }

/* ===== PAGE SECTIONS ===== */
.page { display: none; }
.page.active { display: block; }
.page-title {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -.02em;
    margin-bottom: 1.25rem;
    color: var(--text);
}

/* ===== TIMELINE ===== */
.timeline-wrap {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 1rem;
    overflow-x: auto;
}
.timeline-track {
    position: relative;
    height: 42px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    overflow: hidden;
}
.tl-bar {
    position: absolute;
    top: 3px;
    height: 36px;
    border-radius: 4px;
    font-size: .68rem;
    color: #fff;
    font-weight: 500;
    display: flex;
    align-items: center;
    padding: 0 6px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: default;
    transition: opacity var(--transition);
    box-shadow: inset 0 1px 0 rgba(255,255,255,.15);
}
.tl-bar:hover { opacity: .85; }

/* ===== BADGES ===== */
.badge { padding: .15rem .55rem; border-radius: 4px; font-size: .72rem; font-weight: 600; font-family: var(--mono); }
.badge-ok { background: rgba(52,211,153,.15); color: var(--green); }
.badge-warn { background: var(--amber-dim); color: var(--amber); }
.badge-err { background: var(--red-dim); color: var(--red); }

/* ===== TWO COLS ===== */
.two-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1rem; }

/* ===== INLINE DAY PICKER ===== */
.inline-pick { display: flex; align-items: center; gap: .5rem; margin-bottom: 1.25rem; }
.btn-sm {
    padding: .4rem .9rem;
    background: var(--accent);
    color: var(--bg);
    border: none;
    border-radius: 5px;
    font-family: var(--font);
    font-weight: 600;
    font-size: .8rem;
    cursor: pointer;
}

/* ===== EMPTY/LOADING ===== */
.empty { text-align: center; padding: 2rem; color: var(--text-muted); font-size: .85rem; }
#loading-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(10,15,26,.6);
    backdrop-filter: blur(2px);
    z-index: 9999;
    align-items: center;
    justify-content: center;
}
#loading-overlay.show { display: flex; }
.spinner {
    width: 36px; height: 36px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== CALENDAR GRID ===== */
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-bottom: 1rem; }
.cal-cell {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    font-family: var(--mono);
    font-size: .75rem;
    font-weight: 500;
    border: 1px solid var(--border);
    background: var(--bg);
}
.cal-cell.ok { background: rgba(52,211,153,.15); border-color: var(--green); color: var(--green); }
.cal-cell.warn { background: var(--amber-dim); border-color: var(--amber); color: var(--amber); }
.cal-cell.err { background: var(--red-dim); border-color: var(--red); color: var(--red); }
.cal-cell.empty { border-color: transparent; background: transparent; }

/* ===== TEAM CARDS ===== */
.team-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.15rem;
}
.team-card h3 {
    font-size: .9rem;
    font-weight: 600;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: .5rem;
}
.team-card h3 .dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    display: inline-block;
}
.team-stat { display: flex; justify-content: space-between; padding: .4rem 0; border-bottom: 1px solid var(--border); font-size: .83rem; }
.team-stat:last-child { border-bottom: none; }
.team-stat .lbl { color: var(--text-secondary); }
.team-stat .val { font-family: var(--mono); font-weight: 600; }

/* ===== PRODUCT SELECTOR ===== */
.prod-select {
    width: 100%;
    max-width: 500px;
    padding: .55rem .75rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: var(--font);
    font-size: .88rem;
    outline: none;
    margin-bottom: 1.25rem;
}
.prod-select:focus { border-color: var(--accent); }

/* ===== HEATMAP ===== */
.heatmap-cell {
    padding: .35rem .5rem;
    text-align: center;
    font-family: var(--mono);
    font-size: .78rem;
    font-weight: 500;
    border-radius: 3px;
}

/* ===== MOBILE ===== */
.mobile-toggle {
    display: none;
    position: fixed;
    top: .75rem; left: .75rem;
    z-index: 300;
    width: 38px; height: 38px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 1.2rem;
    cursor: pointer;
    align-items: center;
    justify-content: center;
}

@media (max-width: 900px) {
    .mobile-toggle { display: flex; }
    .sidebar { transform: translateX(-100%); transition: transform .25s ease; }
    .sidebar.open { transform: translateX(0); }
    .main { margin-left: 0; padding: 1rem; padding-top: 3.5rem; }
    .kpi-row { grid-template-columns: repeat(2, 1fr); }
    .chart-grid, .two-cols { grid-template-columns: 1fr; }
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
