/* ============================================================
   AI Ad Network — Design System
   ------------------------------------------------------------
   One shared stylesheet. Every admin page (and the login /
   account pages) inherits these styles via the SAME class names
   the pages already use. Edit tokens below to re-theme globally.
   Fonts (Sora + Space Mono) are self-hosted in ../fonts/ — no CDNs.
   ============================================================ */

/* ===================== SELF-HOSTED FONTS ===================== */
/* Sora ships as a single variable woff2 covering 400–800.
   Space Mono is static (separate 400 / 700 files).
   font-display: swap + the system-ui fallback in --font / --font-mono
   means the UI renders fine even if a .woff2 is missing. */
@font-face {
    font-family: 'Sora';
    font-style: normal;
    font-weight: 400 800;
    font-display: swap;
    src: url('../fonts/sora-latin.woff2') format('woff2');
}
@font-face {
    font-family: 'Space Mono';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('../fonts/spacemono-400-latin.woff2') format('woff2');
}
@font-face {
    font-family: 'Space Mono';
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url('../fonts/spacemono-700-latin.woff2') format('woff2');
}

:root {
    /* ---- CpmBid brand palette (matches cpmbid-homepage.html) ---- */
    /* Surfaces & lines */
    --bg:            #f4f7fb;   /* page tint (homepage --bg-2) */
    --surface:       #ffffff;   /* cards / panels (homepage --bg/--card) */
    --surface-2:     #f0f6fc;   /* subtle sky tint (homepage --card-hi) */
    --border:        rgba(28,27,86,.10);   /* homepage --line */
    --border-strong: rgba(28,27,86,.18);

    /* Text */
    --text:          #10112b;
    --text-muted:    #5c6076;
    --text-subtle:   #8a8fa3;
    --navy:          #1c1b56;   /* headings */

    /* Brand accent — sky blue */
    --accent:        #29aae1;   /* sky */
    --accent-hover:  #1f8fc2;   /* sky-dark */
    --accent-soft:   #e6f5fc;
    --accent-text:   #1f8fc2;

    /* Brand gradients (135deg, same as the homepage) */
    --grad-sky:  linear-gradient(135deg, #29aae1, #1f8fc2);
    --grad-navy: linear-gradient(135deg, #1c1b56, #2a2870);
    --glow:      rgba(41,170,225,.30);   /* soft sky glow */

    /* Status colours (text + soft background) */
    --ok:        #0a7c43;  --ok-bg:     #e9f7ef;  --ok-border:   #bfe6cf;
    --warn:      #b45309;  --warn-bg:   #fdf4e7;  --warn-border: #f3dcb5;
    --danger:    #d32f2f;  --danger-bg: #fdecec;  --danger-border:#f6cccc;

    /* Shape */
    --radius:    18px;
    --radius-sm: 10px;
    --radius-lg: 24px;
    --pill:      999px;
    --max:       1200px;   /* content max width */

    /* Depth — soft sky glow over a faint navy ambient */
    --shadow-sm: 0 1px 2px rgba(28,27,86,.05);
    --shadow:    0 8px 26px var(--glow);
    --shadow-lg: 0 20px 50px rgba(28,27,86,.18);

    /* Type — Sora for UI text, Space Mono for accents; both fall back
       to system-ui (and a monospace stack) if a font file is missing. */
    --font:      'Sora', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-mono: 'Space Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

    /* Spacing scale */
    --s1: 4px;  --s2: 8px;  --s3: 12px;  --s4: 16px;  --s5: 24px;  --s6: 32px;  --s7: 48px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.55;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3 { letter-spacing: -0.013em; color: var(--navy); }
h1 { font-size: 22px; font-weight: 680; }
h2 { font-size: 16px; font-weight: 650; }
h3 { font-size: 14px; font-weight: 650; }
a { color: var(--accent-text); }
.muted { color: var(--text-muted); }
/* Space Mono accent utility (mirrors the homepage's .mono class) */
.mono { font-family: var(--font-mono); }
code {
    background: var(--surface-2); border: 1px solid var(--border);
    padding: 1px 6px; border-radius: 6px; font-size: 12.5px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    overflow-wrap: anywhere; word-break: break-word;
}

/* ===================== BUTTONS ===================== */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 9px 15px; border: 1px solid transparent; border-radius: var(--radius-sm);
    background: var(--accent); color: #fff;
    font-family: inherit; font-size: 13.5px; font-weight: 550; line-height: 1;
    text-decoration: none; cursor: pointer; white-space: nowrap;
    transition: background .15s ease, border-color .15s ease, box-shadow .15s ease, transform .02s ease;
    box-shadow: var(--shadow-sm);
}
.btn:hover  { background: var(--accent-hover); }
.btn:active { transform: translateY(0.5px); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }

.btn.ghost {
    background: var(--surface); color: var(--text); border-color: var(--border-strong);
}
.btn.ghost:hover { background: var(--surface-2); border-color: var(--text-subtle); }

.btn.small { padding: 7px 11px; font-size: 12.5px; border-radius: 7px; }

.btn.ok     { background: var(--ok); }
.btn.ok:hover     { background: #086a39; }
.btn.warn   { background: var(--warn); }
.btn.warn:hover   { background: #97470a; }
.btn.danger { background: var(--danger); }
.btn.danger:hover { background: #b71c1c; }

/* ===================== TOP BAR ===================== */
.topbar {
    position: sticky; top: 0; z-index: 20;
    height: 56px; padding: 0 var(--s5);
    background: rgba(255,255,255,.85); backdrop-filter: saturate(180%) blur(8px);
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
}
.topbar .brand {
    display: inline-flex; align-items: center; gap: 11px;
    text-decoration: none; color: var(--navy);
}
.topbar .brand .brand-img {
    height: 34px; width: 34px; object-fit: contain; flex-shrink: 0;
}
.topbar .brand .brand-tx { display: flex; flex-direction: column; line-height: 1.05; }
/* Wordmark: Sora 800, "Bid" picked out in sky-dark — same as the homepage */
.topbar .brand .brand-name {
    font-weight: 800; font-size: 18px; letter-spacing: .01em; color: var(--navy);
}
.topbar .brand .brand-name b { color: var(--accent-hover); font-weight: 800; }
.topbar .brand .brand-slogan {
    font-family: var(--font-mono); font-size: 8.5px; font-weight: 400;
    letter-spacing: .04em; text-transform: uppercase; color: var(--text-muted);
}
/* Page title in the top bar (the brand now lives in the sidebar) */
.topbar-title { margin: 0; font-size: 16px; font-weight: 680; color: var(--navy); letter-spacing: -0.01em; }
.topbar-right { display: flex; align-items: center; gap: var(--s3); }
.topbar .who { color: var(--text-muted); font-size: 13px; }

/* Top-right user dropdown (pure CSS via <details>/<summary>, no JS). */
.user-menu { position: relative; }
.user-menu > summary {
    list-style: none; cursor: pointer;
    display: inline-flex; align-items: center; gap: 6px;
    padding: 6px 10px; border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm); background: var(--surface);
    color: var(--text); font-size: 13px; box-shadow: var(--shadow-sm);
}
.user-menu > summary::-webkit-details-marker { display: none; }   /* hide default ▸ marker */
.user-menu > summary .user-avatar {
    display: inline-flex; align-items: center; justify-content: center;
    width: 22px; height: 22px; flex-shrink: 0;
    border-radius: 50%; background: var(--accent-soft); color: var(--accent-hover);
}
.user-menu > summary .user-avatar svg { width: 14px; height: 14px; }
.user-menu > summary:hover { background: var(--surface-2); border-color: var(--text-subtle); }
.user-menu > summary .chevron { width: 14px; height: 14px; color: var(--text-subtle); transition: transform .15s ease; }
.user-menu[open] > summary .chevron { transform: rotate(180deg); }
.user-menu-pop {
    position: absolute; right: 0; top: calc(100% + 6px); z-index: 50;
    min-width: 168px; padding: 6px;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-sm); box-shadow: var(--shadow);
}
.user-menu-pop a {
    display: block; padding: 9px 12px; border-radius: var(--radius-sm);
    color: var(--text-muted); text-decoration: none; font-size: 13px;
}
.user-menu-pop a:hover { background: var(--accent-soft); color: var(--text); }

/* ===================== SHELL: SIDEBAR + CONTENT ===================== */
.admin-shell { display: flex; align-items: stretch; min-height: calc(100vh - 56px); }

/* Clean white sidebar with dark text — the CpmBid brand sits at the top,
   sky-blue marks the active/hovered item only. */
.sidebar {
    width: 248px; flex-shrink: 0;
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: var(--s4) var(--s3);
}

/* Brand lockup at the top of the sidebar (logo + wordmark) */
.sidebar-brand {
    display: flex; align-items: center; gap: 11px;
    text-decoration: none;
    padding: 4px 12px var(--s4);
    margin-bottom: var(--s3);
    border-bottom: 1px solid var(--border);
}
.sidebar-brand .brand-img { height: 36px; width: 36px; object-fit: contain; flex-shrink: 0; }
.sidebar-brand .brand-tx { display: flex; flex-direction: column; line-height: 1.05; }
.sidebar-brand .brand-name { font-weight: 800; font-size: 19px; letter-spacing: .01em; color: var(--navy); }
.sidebar-brand .brand-name b { color: var(--accent-hover); font-weight: 800; }
.sidebar-brand .brand-slogan {
    font-family: var(--font-mono); font-size: 8.5px; font-weight: 400;
    letter-spacing: .04em; text-transform: uppercase; color: var(--text-muted);
}

.sidebar ul { list-style: none; margin: 0; padding: 0; }
.sidebar li { margin-bottom: 2px; }
.sidebar a {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px; border-radius: var(--radius-sm);
    border-left: 3px solid transparent;
    color: var(--text-muted); text-decoration: none;
    font-size: 13.5px; font-weight: 550;
    transition: background .12s ease, color .12s ease, border-color .12s ease;
}
.sidebar a:hover { background: var(--accent-soft); color: var(--text); }
.sidebar a:hover .nav-icon { color: var(--accent); }
.sidebar a.active {
    background: var(--accent-soft);
    border-left-color: var(--accent);
    color: var(--accent-text);
}
.sidebar a.active .nav-icon { color: var(--accent); }
.sidebar .nav-icon { display: inline-flex; width: 18px; height: 18px; color: var(--text-subtle); flex-shrink: 0; }
.sidebar .nav-icon svg { width: 18px; height: 18px; }
.sidebar .nav-label { flex: 1; }

.content { flex: 1; padding: var(--s6); max-width: 1080px; }
.container { max-width: 960px; margin: 0 auto; padding: var(--s6) var(--s5); }

.page-title { margin: 0 0 var(--s2); font-size: 24px; font-weight: 700; }

/* ===================== CARDS ===================== */
.card-block {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: var(--s5);
    box-shadow: var(--shadow-sm);
    margin-bottom: var(--s5);
}
.card-block h2 { margin-top: 0; margin-bottom: var(--s3); }

/* Navy "hero" treatment for a feature card-block — matches .metric.hero
   (same gradient, radius, shadow). Text goes light; form fields stay white. */
.card-block.card-hero {
    background: var(--grad-navy);
    border: none;
    color: #fff;
    box-shadow: var(--shadow);
}
.card-block.card-hero h2 { color: #fff; }
.card-block.card-hero .muted,
.card-block.card-hero .ref-sub { color: rgba(255, 255, 255, .8); }
.card-block.card-hero label { color: rgba(255, 255, 255, .92); }
.card-block.card-hero a { color: #fff; }
/* Keep form controls readable (white field, dark text) on the navy hero. */
.card-block.card-hero input,
.card-block.card-hero select,
.card-block.card-hero textarea {
    background: #fff;
    color: var(--text);
}

/* ===================== STAT CARDS ===================== */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--s4); margin: var(--s5) 0; }
.stat {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: var(--s5);
    box-shadow: var(--shadow-sm);
}
.stat-num { font-size: 28px; font-weight: 400; letter-spacing: -0.02em; color: var(--navy); font-family: var(--font-mono); }
.stat-label { color: var(--text-muted); font-size: 12px; margin-top: var(--s1); text-transform: uppercase; letter-spacing: .5px; }

/* ===================== TABLES ===================== */
.table {
    width: 100%; border-collapse: separate; border-spacing: 0;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm);
}
.table th, .table td { padding: 12px 16px; text-align: left; font-size: 13.5px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th {
    background: var(--surface-2); color: var(--text-subtle);
    font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .6px;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--surface-2); }

/* ----- Report breakdown tables (publisher + advertiser reports) ----- */
/* The card frames the table, so the table drops its own border/shadow and
   sits flush inside a titled header. */
.table-card { padding: 0; overflow: hidden; }
.table-card-head { padding: var(--s4) var(--s4) var(--s3); }
.table-card-head h2 { margin: 0; font-size: 15px; font-weight: 680; color: var(--navy); letter-spacing: -0.01em; }
.table-card-head .muted { margin: 4px 0 0; font-size: 12.5px; }

.report-table { border: none; border-radius: 0; box-shadow: none; }
.report-table th, .report-table td { padding: 13px 16px; }     /* comfortable rows */
.report-table thead th { border-top: 1px solid var(--border); }
/* Numeric columns: right-aligned, even-width figures, never wrapped. */
.report-table td.num, .report-table th.num {
    text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap;
}
.report-table tbody tr:hover { background: var(--accent-soft); }
/* Totals row stands out: bold navy on a tinted band with a strong top rule. */
.report-table tfoot td {
    font-weight: 700; color: var(--navy);
    background: var(--surface-2);
    border-top: 2px solid var(--border-strong); border-bottom: none;
}

/* key/value detail table */
.kv { width: 100%; border-collapse: collapse; }
.kv th { text-align: left; width: 160px; padding: 9px 0; color: var(--text-muted); font-weight: 550; font-size: 13px; vertical-align: top; }
.kv td { padding: 9px 0; font-size: 13.5px; border-bottom: 1px solid var(--border); }

/* ===================== BADGES ===================== */
.badge {
    display: inline-flex; align-items: center;
    padding: 2px 9px; border-radius: var(--pill);
    font-size: 11.5px; font-weight: 600; line-height: 1.6;
    border: 1px solid transparent;
}
.badge-ok    { background: var(--ok-bg);     color: var(--ok);          border-color: var(--ok-border); }
.badge-warn  { background: var(--warn-bg);   color: var(--warn);        border-color: var(--warn-border); }
.badge-bad   { background: var(--danger-bg); color: var(--danger);      border-color: var(--danger-border); }
.badge-brand { background: var(--accent-soft); color: var(--accent-text); border-color: var(--accent-soft); }

/* Fraud risk levels (admin fraud dashboard): low → critical */
.badge-risk-low      { background: var(--surface-2); color: var(--text-muted); border-color: var(--border); }
.badge-risk-medium   { background: var(--warn-bg);   color: var(--warn);       border-color: var(--warn-border); }
.badge-risk-high     { background: var(--danger-bg); color: var(--danger);     border-color: var(--danger-border); }
.badge-risk-critical { background: var(--danger);    color: #fff;              border-color: var(--danger); }

/* ===================== FORMS ===================== */
label { display: block; margin: var(--s3) 0 0; font-size: 13px; font-weight: 600; color: var(--text); }
label input, label select, label textarea,
.filters input, .filters select, .filters textarea,
.setting-input input, .setting-input select,
.action-form input[type="text"], .action-form input[type="number"],
.reject-form input[type="text"] {
    font-family: inherit; font-size: 14px; color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
    padding: 9px 12px;
    transition: border-color .15s ease, box-shadow .15s ease;
}
label input, label select, label textarea { display: block; width: 100%; margin-top: 6px; font-weight: 400; }
label textarea { resize: vertical; min-height: 120px; line-height: 1.5; }
input:focus, select:focus, textarea:focus {
    outline: none; border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}
input::placeholder { color: var(--text-subtle); }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s4); }

/* ---- Targeting controls (checkbox groups + multi-selects) ---- */
.t-group { margin: var(--s4) 0; }
.t-group > .t-label { font-size: 13px; font-weight: 600; color: var(--text); }
.t-group .t-hint { font-weight: 400; color: var(--text-muted); font-size: 12.5px; }
.check-grid { display: flex; flex-wrap: wrap; gap: 9px 18px; margin: 8px 0 0; }
.check-grid label { display: flex; align-items: center; gap: 7px; margin: 0; font-weight: 500; font-size: 13.5px; }
.check-grid input[type="checkbox"] { display: inline-block; width: auto; margin: 0; }
select[multiple] { display: block; width: 100%; margin-top: 6px; min-height: 150px; padding: 6px;
    font-family: inherit; font-size: 14px; color: var(--text);
    background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); }

/* ===================== FILTER BAR ===================== */
.filters { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; margin-bottom: var(--s4); }
.filters input[type="text"] { min-width: 240px; }

/* Report-builder filter bar: evenly sized dropdowns + bottom-aligned Apply. */
.report-filters {
    align-items: flex-end; gap: var(--s3);
    padding: var(--s4); margin-bottom: var(--s5);
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow-sm);
}
.report-filters label { margin: 0; flex: 1 1 168px; min-width: 150px; font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .4px; }
.report-filters .btn { flex: 0 0 auto; }

/* ===================== DATE-RANGE PICKER ===================== */
/* Shared component (app/views/partials/daterange.php) used on the publisher +
   advertiser dashboards and reports. A compact dropdown button on the left
   plus a reveal-on-select custom range form. */
.daterange {
    display: flex; flex-wrap: wrap; align-items: center; gap: var(--s3);
    margin-bottom: var(--s5);
}

/* --- The dropdown (button + menu) --- */
.daterange-dd { position: relative; }
.daterange-toggle {
    display: inline-flex; align-items: center; gap: 9px;
    padding: 9px 13px; min-width: 168px;
    background: var(--surface); border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm); cursor: pointer;
    font-family: inherit; font-size: 13.5px; font-weight: 600; color: var(--navy);
    box-shadow: var(--shadow-sm); transition: all .12s ease;
}
.daterange-toggle:hover { border-color: var(--accent); background: var(--surface-2); }
.daterange-toggle:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.daterange-cal { display: inline-flex; width: 16px; height: 16px; color: var(--accent); flex-shrink: 0; }
.daterange-current { flex: 1; text-align: left; white-space: nowrap; }
.daterange-caret { display: inline-flex; width: 15px; height: 15px; color: var(--text-muted); transition: transform .15s ease; }
.daterange-dd.open .daterange-caret { transform: rotate(180deg); }

.daterange-menu {
    position: absolute; top: calc(100% + 6px); right: 0; z-index: 30;
    display: none; min-width: 210px; padding: 6px;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-sm); box-shadow: var(--shadow);
}
.daterange-dd.open .daterange-menu { display: block; }
.daterange-item {
    display: flex; align-items: center; justify-content: space-between; gap: var(--s4);
    width: 100%; padding: 9px 11px; margin: 0;
    background: none; border: none; border-radius: 8px;
    font-family: inherit; font-size: 13.5px; font-weight: 500; color: var(--text);
    text-align: left; text-decoration: none; cursor: pointer; transition: all .1s ease;
}
.daterange-item:hover { background: var(--accent-soft); color: var(--accent-text); }
.daterange-item.active { background: var(--accent-soft); color: var(--accent-text); font-weight: 650; }
.daterange-check { color: var(--accent); font-weight: 700; }

/* --- The reveal-on-select custom range form --- */
.daterange-custom {
    display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2);
    padding-left: var(--s3); border-left: 1px solid var(--border);
}
.daterange-custom.is-hidden { display: none; }
.daterange-field { display: flex; align-items: center; gap: 6px; margin: 0; font-weight: 400; }
.daterange-field span { font-size: 13px; }
.daterange-field input[type="date"] {
    font-family: inherit; font-size: 13.5px; color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
    padding: 7px 10px;
}

/* --- Page header row: title on the left, date picker top-right --- */
.page-head {
    display: flex; align-items: flex-start; justify-content: space-between;
    gap: var(--s4); flex-wrap: wrap; margin-bottom: var(--s5);
}
.page-head-text { min-width: 0; }            /* let the title/subtitle wrap */
.page-head .daterange { margin-bottom: 0; margin-left: auto; }  /* stay right, even when wrapped */

/* ===================== PAGINATION ===================== */
.pager { display: flex; align-items: center; gap: var(--s4); margin-top: var(--s5); color: var(--text-muted); font-size: 13px; }

/* ===================== DETAIL / ACTION FORMS ===================== */
.detail-actions { display: flex; gap: var(--s2); margin-bottom: var(--s4); flex-wrap: wrap; }
.action-form { display: flex; gap: var(--s2); align-items: center; margin: var(--s3) 0; flex-wrap: wrap; }
.action-form input[type="text"] { min-width: 280px; }

/* ===================== APPROVALS ===================== */
.approve-cell { display: flex; flex-direction: column; gap: var(--s2); align-items: flex-start; }
.reject-form { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.reject-form input[type="text"] { min-width: 190px; font-size: 13px; padding: 7px 10px; }

/* ===================== SETTINGS ===================== */
.settings-jump { display: flex; flex-wrap: wrap; gap: var(--s2); margin-bottom: var(--s5); }
.settings-jump a {
    font-size: 12.5px; padding: 6px 12px; background: var(--surface); color: var(--text-muted);
    border: 1px solid var(--border); border-radius: var(--pill); text-decoration: none;
    transition: all .12s ease;
}
.settings-jump a:hover { background: var(--accent-soft); color: var(--accent-text); border-color: var(--accent-soft); }

.setting-row { display: flex; gap: var(--s5); align-items: flex-start; padding: var(--s3) 0; border-bottom: 1px solid var(--border); }
.setting-row:last-of-type { border-bottom: none; }
.setting-label { flex: 1; font-weight: 600; font-size: 13.5px; display: flex; flex-direction: column; gap: 2px; }
.setting-desc { font-weight: 400; font-size: 12px; color: var(--text-muted); }
.setting-input { width: 320px; max-width: 45%; }
.setting-input input, .setting-input select { width: 100%; }

/* ===================== FLASH / ALERTS ===================== */
.flash, .alert {
    padding: 11px 15px; border-radius: var(--radius-sm); font-size: 13.5px;
    margin-bottom: var(--s4); border: 1px solid transparent;
}
.flash-success { background: var(--ok-bg);     color: var(--ok);     border-color: var(--ok-border); }
.flash-warn    { background: var(--warn-bg);   color: var(--warn);   border-color: var(--warn-border); }
.flash-error, .alert { background: var(--danger-bg); color: var(--danger); border-color: var(--danger-border); }
.alert ul { margin: 6px 0 0; padding-left: 18px; }

/* read-only code/snippet field (e.g. verification meta tag, ad code) */
.code-field {
    width: 100%; padding: 10px 12px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px;
    color: var(--text); background: var(--surface-2);
    border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
}
textarea.code-field { resize: vertical; line-height: 1.5; }

/* dashed placeholder showing an ad zone's dimensions */
.ad-preview {
    border: 2px dashed var(--border-strong); border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    color: var(--text-subtle); font-size: 12px; background: var(--surface-2);
}

/* ===================== DANGER ZONE ===================== */
.danger-zone { border-color: var(--danger-border); }
.danger-zone h2 { color: var(--danger); }
.danger-zone hr { border: none; border-top: 1px solid var(--border); margin: var(--s4) 0; }
.danger-zone h3 { margin-bottom: var(--s1); }

/* ===================== SIDEBAR PENDING BADGE ===================== */
.nav-badge {
    background: var(--danger); color: #fff; font-size: 11px; font-weight: 700;
    border-radius: var(--pill); padding: 1px 7px; line-height: 1.5;
}

/* ===================== CHART ===================== */
.chart-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: var(--s4); }
.chart-tab {
    padding: 6px 13px; border: 1px solid var(--border); background: var(--surface);
    border-radius: var(--pill); font-family: inherit; font-size: 12.5px; font-weight: 550;
    color: var(--text-muted); cursor: pointer; transition: all .12s ease;
}
.chart-tab:hover { background: var(--surface-2); color: var(--text); }
.chart-tab.active { background: var(--accent-soft); color: var(--accent-text); border-color: var(--accent-soft); }

.chart-wrap { position: relative; }
.chart-canvas { width: 100%; height: 280px; display: block; }

.chart-tip {
    position: absolute; display: none; z-index: 5; pointer-events: none;
    transform: translate(-50%, -100%);
    background: var(--navy); color: #fff; padding: 7px 11px; border-radius: 8px;
    font-size: 12px; white-space: nowrap; box-shadow: var(--shadow);
}
.chart-tip .tip-date { opacity: .75; font-size: 11px; margin-bottom: 2px; }
.chart-tip .tip-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }

/* ===================== TOPBAR BALANCE PILL ===================== */
.topbar-balance {
    font-size: 13px; font-weight: 650; color: var(--text);
    background: var(--surface-2); border: 1px solid var(--border);
    padding: 5px 12px; border-radius: var(--pill);
}

/* ===================== PUBLISHER DASHBOARD METRICS ===================== */
.dash-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s4); margin-bottom: var(--s5); }
/* Even rows on smaller screens: 3 → 2 → 1 columns */
@media (max-width: 1000px) { .dash-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px)  { .dash-grid { grid-template-columns: 1fr; } }

/* Modifier for a 4-card row (e.g. the reports summary): 4 → 2 → 1 columns,
   so four cards stay even and never leave a lone card on its own row. */
.dash-grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1000px) { .dash-grid.cols-4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px)  { .dash-grid.cols-4 { grid-template-columns: 1fr; } }

/* Modifier for an even 2-card row (e.g. the funds balance summary): 2 → 1. */
.dash-grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 560px)  { .dash-grid.cols-2 { grid-template-columns: 1fr; } }

/* Modifier for a 5-card row (e.g. the advertiser reports summary): 5 → 3 → 2 → 1,
   so the five cards stay even across screen sizes. */
.dash-grid.cols-5 { grid-template-columns: repeat(5, 1fr); }
@media (max-width: 1100px) { .dash-grid.cols-5 { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 760px)  { .dash-grid.cols-5 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px)  { .dash-grid.cols-5 { grid-template-columns: 1fr; } }

/* Modifier for a 6-card row (advertiser reports summary, with Viewability):
   6 → 3 → 2 → 1, so the six cards stay even across screen sizes. */
.dash-grid.cols-6 { grid-template-columns: repeat(6, 1fr); }
@media (max-width: 1200px) { .dash-grid.cols-6 { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 760px)  { .dash-grid.cols-6 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px)  { .dash-grid.cols-6 { grid-template-columns: 1fr; } }
.metric {
    position: relative; background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: var(--s5); box-shadow: var(--shadow-sm);
}
.metric-label { font-size: 11.5px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; font-weight: 600; }
.metric-value { font-size: 26px; font-weight: 400; letter-spacing: -0.02em; margin-top: 8px; line-height: 1.1; font-family: var(--font-mono); }
.metric-cap { font-size: 12px; color: var(--text-subtle); margin-top: 5px; }
.metric-icon {
    position: absolute; top: var(--s5); right: var(--s5);
    width: 34px; height: 34px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    background: var(--accent-soft); color: var(--accent);
}
.metric-icon svg { width: 18px; height: 18px; }

/* Highlighted "hero" card (balance) */
.metric.hero { background: var(--grad-navy); border: none; color: #fff; box-shadow: var(--shadow); }
.metric.hero .metric-label { color: rgba(255,255,255,.85); }
.metric.hero .metric-cap   { color: rgba(255,255,255,.8); }
.metric.hero .metric-icon  { background: rgba(255,255,255,.18); color: #fff; }

/* ===================== IMPERSONATION BANNER ===================== */
.imp-banner {
    background: var(--warn-bg); color: var(--warn); border-bottom: 1px solid var(--warn-border);
    text-align: center; padding: 9px 16px; font-size: 13px; font-weight: 600;
}
.imp-banner a { color: var(--warn); text-decoration: underline; margin-left: 8px; }

/* ===================== FOOTER ===================== */
.page-foot { text-align: center; color: var(--text-subtle); font-size: 12px; padding: var(--s6) var(--s5); }

/* ===================== LOGIN / AUTH ===================== */
.auth-page {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    padding: var(--s4);
    background:
        radial-gradient(1200px 600px at 50% -10%, rgba(41,170,225,.12) 0%, transparent 60%),
        var(--bg);
}
.auth-card {
    background: var(--surface); width: 100%; max-width: 400px; padding: var(--s6);
    border: 1px solid var(--border); border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
}
.auth-title { margin: 0; font-size: 22px; font-weight: 700; text-align: center; }
.auth-sub { margin: 6px 0 var(--s5); text-align: center; color: var(--text-muted); font-size: 13.5px; }
.auth-card .btn { width: 100%; margin-top: var(--s5); padding: 11px 15px; font-size: 14px; }

/* Branded header at the top of the auth card — same wordmark as the panels,
   sized up and centred for the login screen. */
.auth-brand {
    display: flex; flex-direction: column; align-items: center; gap: 8px;
    text-align: center; margin-bottom: var(--s5);
}
.auth-brand .brand-img { height: 56px; width: 56px; object-fit: contain; }
.auth-brand .brand-name {
    font-weight: 800; font-size: 26px; letter-spacing: .01em; color: var(--navy); line-height: 1.05;
}
.auth-brand .brand-name b { color: var(--accent-hover); font-weight: 800; }
.auth-brand .brand-slogan {
    font-family: var(--font-mono); font-size: 10px; font-weight: 400;
    letter-spacing: .08em; text-transform: uppercase; color: var(--text-muted);
}

/* ===================== RESPONSIVE ===================== */
/* Mobile-only chrome. Hidden on desktop so the layout stays byte-identical;
   the mobile drawer below switches these on. The scrim is built by panel.js. */
.nav-toggle { display: none; }
.sidebar-scrim { display: none; }

@media (max-width: 720px) {
    .stat-grid { grid-template-columns: repeat(2, 1fr); }

    /* Hamburger button in the topbar (first child, before the title). */
    .nav-toggle {
        display: inline-flex; align-items: center; justify-content: center;
        flex: 0 0 auto; width: 38px; height: 38px; margin-right: var(--s2);
        padding: 0; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
        background: var(--surface); color: var(--text); cursor: pointer;
    }
    .nav-toggle:hover { background: var(--surface-2); border-color: var(--text-subtle); }
    .nav-toggle svg { width: 20px; height: 20px; }

    /* Sidebar becomes an off-canvas drawer that slides in over everything. */
    .sidebar {
        position: fixed; top: 0; left: 0; z-index: 200;
        width: 260px; max-width: 84vw; height: 100vh;
        overflow-y: auto; -webkit-overflow-scrolling: touch;
        border-right: 1px solid var(--border);
        transform: translateX(-100%);
        transition: transform .22s ease;
    }
    .sidebar.open { transform: translateX(0); box-shadow: var(--shadow); }

    /* Dimmed overlay behind the open drawer (above topbar's z-index 20). */
    .sidebar-scrim {
        position: fixed; inset: 0; z-index: 150;
        background: rgba(15, 23, 42, .45);
    }
    .sidebar-scrim.show { display: block; }

    /* Lock background scroll while the drawer is open (toggled by panel.js). */
    body.nav-open { overflow: hidden; }

    .content { padding: var(--s4); }
    .container { padding: var(--s5) var(--s4); }
    .filters input[type="text"] { min-width: 0; flex: 1; }
    .setting-row { flex-direction: column; gap: 6px; }
    .setting-input { width: 100%; max-width: 100%; }
    .table { display: block; overflow-x: auto; white-space: nowrap; }

    /* The wide table above forces white-space:nowrap on every cell. Let the
       long-text cells (payout details, fraud reasons, etc.) wrap again — they
       carry .wrap-cell and overrule the inherited nowrap on mobile. */
    .table td.wrap-cell { white-space: normal; word-break: break-word; }

    /* --- Stacked-card reflow for the heaviest wide tables --- */
    /* Each row becomes a card; each cell shows its column header (data-label)
       on the left and the value on the right. Opt-in via .cards-mobile, so
       tables without it keep the horizontal-scroll treatment above. */
    .table.cards-mobile { overflow-x: visible; white-space: normal; }
    .table.cards-mobile thead { display: none; }
    .table.cards-mobile tbody,
    .table.cards-mobile tfoot { display: block; }
    .table.cards-mobile tr {
        display: block; margin-bottom: var(--s3);
        padding: 4px var(--s3);
        border: 1px solid var(--border); border-radius: var(--radius-sm);
        background: var(--surface);
    }
    .table.cards-mobile td {
        display: flex; justify-content: space-between; align-items: baseline; gap: var(--s4);
        padding: 8px 0; text-align: right;
        border-bottom: 1px solid var(--border);
    }
    .table.cards-mobile tr td:last-child { border-bottom: none; }
    .table.cards-mobile td::before {
        content: attr(data-label);
        flex: 0 0 auto; text-align: left;
        font-weight: 600; color: var(--text-muted);
    }
    /* Label-less cells (empty action column, full-width empty-state rows). */
    .table.cards-mobile td:not([data-label])::before,
    .table.cards-mobile td[data-label=""]::before { content: none; }
    .table.cards-mobile td[colspan] { justify-content: flex-start; text-align: left; }

    /* Stack 2-col forms and neutralize fixed min-widths so nothing overflows. */
    .grid { grid-template-columns: 1fr; }
    .action-form input[type="text"],
    .reject-form input[type="text"] { min-width: 0; width: 100%; }
    .report-filters label { flex-basis: 100%; min-width: 0; }

    /* Collapse inline-styled grids to one column (backups S3 fields, the 2-col
       2FA backup-code list). !important is needed to beat the inline style. */
    .grid,
    [style*="grid-template-columns:1fr 1fr"],
    [style*="repeat(2,max-content)"] { grid-template-columns: 1fr !important; }

    /* Neutralize inline min-widths on the deposits/payouts approve+reject rows
       (raw inline styles the .action-form/.reject-form rule above can't reach). */
    [style*="min-width:240px"],
    [style*="min-width:140px"] { min-width: 0 !important; }

    /* Admin topbar search: full-width below the title instead of crowding it. */
    /* The topbar is a single non-wrapping flex row, so a full-width search can't
       drop to its own line — it just crowds the title. Let it shrink to share the
       row instead (min-width:0 allows shrinking below its content width). It is
       hidden outright below 600px by the admin header CSS. */
    .topbar-search { flex: 1 1 140px; min-width: 0; max-width: none; margin: 0 var(--s3); }
}
