/* Company dark theme.
   Brand palette: green #B7FF03 (primary accent), blue #91D8F6 (secondary accent), gray #292929 (panels). */
:root {
    --bg: #1f1f1f;
    --panel: #292929;
    --panel-2: #333333;
    --panel-3: #3a3a3a;
    --border: #3f3f3f;
    --text: #e6e6e6;
    --muted: #a8a8a8;
    --green: #B7FF03;
    --green-hover: #9bdb00;
    --blue: #91D8F6;
    --danger: #ff6b6b;
    --border-strong: #5a5a5a;
}

* { box-sizing: border-box; }

body {
    background: var(--bg);
    color: var(--text);
    font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
    margin: 0;
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
code { color: var(--blue); background: #15171a; padding: .05rem .35rem; border-radius: 4px; }
h1, h2, h3 { font-weight: 650; }

/* ---------- form controls (override Bootstrap for dark) ---------- */
.form-control, .form-select {
    background: #222; color: var(--text); border: 1px solid var(--border);
}
.form-control:focus, .form-select:focus {
    background: #222; color: var(--text);
    border-color: var(--green); box-shadow: 0 0 0 .15rem rgba(183, 255, 3, .2);
}
.form-control::placeholder { color: #777; }
.form-label { font-size: .85rem; color: var(--muted); }
.form-check-input { background-color: #222; border-color: var(--border); }
.form-check-input:checked { background-color: var(--green); border-color: var(--green); }

/* ---------- buttons ---------- */
.btn-accent { background-color: var(--green); color: #15200a; border: 1px solid var(--green); font-weight: 600; }
/* Higher specificity than Bootstrap's .btn:hover/:active so the green background isn't reset to transparent. */
.btn.btn-accent:hover, .btn.btn-accent:focus, .btn.btn-accent:active {
    background-color: var(--green-hover); border-color: var(--green-hover); color: #15200a;
}
.btn-outline { background-color: transparent; border: 1px solid var(--border-strong); color: var(--text); }
.btn.btn-outline:hover, .btn.btn-outline:focus {
    background-color: var(--panel-2); border-color: var(--blue); color: var(--blue);
}
.btn-danger { background: transparent; border: 1px solid rgba(255, 107, 107, .5); color: var(--danger); }
.btn-danger:hover { background: rgba(255, 107, 107, .12); color: var(--danger); }
.btn-link-muted { background: none; border: none; color: var(--muted); }
.btn-link-muted:hover { color: var(--text); }

/* ---------- top nav ---------- */
.app-nav { background: var(--panel); border-bottom: 1px solid var(--border); }
.nav-inner { display: flex; align-items: center; gap: 1rem; max-width: 1200px; margin: 0 auto; padding: .6rem 1rem; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: .5rem; font-weight: 700; color: var(--text); font-size: 1.1rem; }
.brand:hover { text-decoration: none; }
.brand-dot { width: .7rem; height: .7rem; border-radius: 50%; background: var(--green); box-shadow: 0 0 8px var(--green); }
.brand-logo { height: 32px; width: auto; display: block; }
.nav-links { display: flex; gap: .25rem; flex: 1; }
.nav-links a { color: var(--muted); padding: .4rem .7rem; border-radius: 6px; }
.nav-links a:hover { color: var(--text); background: var(--panel-2); text-decoration: none; }
.nav-user { display: flex; align-items: center; gap: .6rem; }
.user-email { color: var(--muted); font-size: .85rem; }
.nav-toggle { display: none; background: none; border: none; color: var(--text); font-size: 1.3rem; cursor: pointer; }

/* ---------- nav dropdown ---------- */
.nav-dd { position: relative; }
.nav-dd-btn { background: none; border: none; color: var(--muted); font: inherit; padding: .4rem .7rem; border-radius: 6px; cursor: pointer; display: inline-flex; align-items: center; gap: .35rem; }
.nav-dd-btn:hover, .nav-dd.open .nav-dd-btn { color: var(--text); background: var(--panel-2); }
.nav-dd-menu { position: absolute; top: 100%; left: 0; margin-top: .3rem; min-width: 190px; background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px; padding: .3rem; display: none; z-index: 50; }
.nav-dd.open .nav-dd-menu { display: block; }
.nav-dd-menu a { display: flex; align-items: center; gap: .45rem; padding: .45rem .6rem; border-radius: 6px; color: var(--muted); white-space: nowrap; }
.nav-dd-menu a:hover { background: var(--panel-3); color: var(--text); text-decoration: none; }
.nav-dd-sep { height: 1px; background: var(--border); margin: .3rem .2rem; }
@media (max-width: 820px) {
    .nav-dd { width: 100%; }
    .nav-dd-menu { position: static; margin-top: .2rem; border: none; padding-left: 1rem; background: transparent; }
}

@media (max-width: 820px) {
    .nav-toggle { display: block; order: 2; margin-left: auto; }
    .nav-user { order: 3; }
    .nav-links { display: none; flex-basis: 100%; flex-direction: column; order: 4; }
    .nav-links.open { display: flex; }
}

/* ---------- layout ---------- */
.app-main { max-width: 1200px; margin: 0 auto; padding: 1.2rem 1rem 3rem; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.page-head h1 { font-size: 1.5rem; margin: 0; }
.sub { font-size: 1.15rem; margin: 1.3rem 0 .6rem; color: var(--blue); }
.sub-minor { font-size: 1rem; color: var(--muted); margin: 1rem 0 .4rem; }
.muted { color: var(--muted); }
.result-block { margin-top: 1.4rem; }
.results-meta { color: var(--muted); font-size: .85rem; margin-bottom: .5rem; }

/* ---------- tables ---------- */
.data-table { width: 100%; border-collapse: collapse; background: var(--panel); color: var(--text); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
/* Neutralize Bootstrap's light table-cell fill (its inset box-shadow) so our dark backgrounds show through. */
.data-table > :not(caption) > * > * { background-color: transparent; box-shadow: none; color: inherit; }
.data-table th, .data-table td { padding: .55rem .7rem; border-bottom: 1px solid var(--border); text-align: left; font-size: .9rem; }
.data-table thead th { background: var(--panel-2); color: var(--muted); text-transform: uppercase; font-size: .72rem; letter-spacing: .04em; }
.data-table tbody tr:hover { background: var(--panel-2); }
.data-table .total { font-weight: 600; color: var(--green); }
.table-scroll { overflow-x: auto; }
.list-scroll { max-height: 22rem; overflow-y: auto; }
.list-scroll thead th { position: sticky; top: 0; background: var(--panel); z-index: 1; }
.tz-chip { display: inline-flex; align-items: center; gap: .25rem; font-size: .74rem; white-space: nowrap; }

/* Session funnel: centered numeric cells, screen-group headers, bold Total/Average footer. */
.flow-table th, .flow-table td { text-align: center; white-space: nowrap; }
.flow-table th:first-child, .flow-table td:first-child { text-align: left; }
.flow-table thead th.screen-group { color: var(--blue); background: var(--panel-3); border-left: 2px solid var(--bg); border-right: 2px solid var(--bg); }
.flow-table tfoot td { font-weight: 600; background: var(--panel-2); border-top: 2px solid var(--border); }
/* Wide-funnel ergonomics: full-width page, compact cells, wrapping action headers, pinned Dates column. */
.app-main--wide { max-width: none; }
.flow-table th, .flow-table td { padding: .4rem .55rem; font-size: .82rem; }
.flow-table thead tr:nth-child(2) th { white-space: normal; min-width: 70px; max-width: 130px; }
.flow-table th:first-child, .flow-table td:first-child { position: sticky; left: 0; z-index: 2; background: var(--panel); }
.flow-table thead th:first-child, .flow-table tfoot td:first-child { background: var(--panel-2); }
.actions { text-align: right; white-space: nowrap; }
.actions .btn { margin-left: .25rem; }
.inline { display: inline; }

/* ---------- filters ---------- */
.filter-panel { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 1rem; margin-bottom: 1.3rem; }
.filter-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: .8rem; }
.field { display: flex; flex-direction: column; gap: .3rem; }
.field label { font-size: .76rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.filter-actions { display: flex; gap: .6rem; margin-top: 1rem; flex-wrap: wrap; }

/* ---------- charts ---------- */
.chart-wrap { position: relative; height: 320px; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: .8rem; margin-bottom: 1rem; }

/* ---------- notices / flash / validation ---------- */
.notice { background: var(--panel-2); border: 1px solid var(--border); border-left: 3px solid var(--blue); padding: .8rem 1rem; border-radius: 6px; margin: 1rem 0; color: var(--muted); }
.flash { background: rgba(183, 255, 3, .08); border: 1px solid rgba(183, 255, 3, .3); color: var(--green); padding: .7rem 1rem; border-radius: 6px; margin-bottom: 1rem; }
.validation-summary { color: var(--danger); margin-bottom: .6rem; }
.validation-summary ul { margin: 0; padding-left: 1.1rem; }

/* ---------- one-time PSK reveal ---------- */
.psk-reveal { background: rgba(145, 216, 246, .08); border: 1px solid rgba(145, 216, 246, .4); border-radius: 8px; padding: 1rem; margin-bottom: 1.2rem; }
.psk-value { display: block; margin-top: .5rem; padding: .6rem .8rem; background: #15171a; border-radius: 6px; color: var(--green); word-break: break-all; font-size: 1rem; }

/* ---------- forms ---------- */
.form-narrow { max-width: 480px; }
.inline-form { display: flex; gap: .5rem; align-items: center; }
.inline-select { max-width: 280px; }

/* ---------- auth ---------- */
.auth-body { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.auth-wrap { width: 100%; max-width: 390px; padding: 1rem; }
.auth-card { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 1.7rem; }
.brand-title { font-size: 1.4rem; margin-bottom: .3rem; color: var(--text); }
.auth-logo { display: block; width: 210px; max-width: 80%; height: auto; margin: 0 auto 1.2rem; }
.auth-card .btn { margin-top: .4rem; }
