/* ===== Theme tokens ===== */
:root,
:root[data-theme="dark"] {
    --bg: #0f1420;
    --panel: #171e2e;
    --panel-2: #1e2740;
    --line: #2a3550;
    --text: #e6ebf5;
    --muted: #8a97b3;
    --accent: #e0322d;
    --accent-2: #3b82f6;
    --good: #22c55e;
    --shadow: 0 2px 12px rgba(0, 0, 0, .35);
}
:root[data-theme="light"] {
    --bg: #f4f6fb;
    --panel: #ffffff;
    --panel-2: #eef2f9;
    --line: #dde3ee;
    --text: #1a2236;
    --muted: #647089;
    --accent: #e0322d;
    --accent-2: #2563eb;
    --good: #16a34a;
    --shadow: 0 2px 10px rgba(20, 30, 60, .08);
}

/* ===== Accent palettes (orthogonal to light/dark; declared after the theme
   blocks so they win the tie on --accent / --accent-2). ===== */
:root[data-accent="crimson"] { --accent: #e0322d; --accent-2: #3b82f6; }
:root[data-accent="ocean"]   { --accent: #2563eb; --accent-2: #06b6d4; }
:root[data-accent="emerald"] { --accent: #059669; --accent-2: #10b981; }
:root[data-accent="violet"]  { --accent: #7c3aed; --accent-2: #a855f7; }
:root[data-accent="sunset"]  { --accent: #ea580c; --accent-2: #f59e0b; }
:root[data-accent="teal"]    { --accent: #0d9488; --accent-2: #14b8a6; }

* { box-sizing: border-box; }
body {
    margin: 0; background: var(--bg); color: var(--text);
    font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    transition: background .25s ease, color .25s ease;
}

/* ===== Topbar (slim) ===== */
.topbar {
    display: flex; align-items: center; justify-content: space-between;
    /* Background/border stay full-width; content lines up with the 1280px body. */
    padding: 8px max(20px, calc((100% - 1280px) / 2 + 20px));
    background: var(--panel); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; }
.logo {
    width: 28px; height: 28px; border-radius: 7px; background: var(--accent);
    color: #fff; font-weight: 800; font-size: 16px;
    display: grid; place-items: center;
}
.topbar h1 { font-size: 15px; margin: 0; font-weight: 600; }
/* tagline tucked inline next to the title to save vertical space */
.brand > div { display: flex; align-items: baseline; gap: 10px; }
.sub { margin: 0; color: var(--muted); font-size: 12px; }

.topbar-right { display: flex; align-items: center; gap: 10px; }
.user-chip {
    font-size: 12px; font-weight: 600; color: var(--muted);
    max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.logout-btn {
    font-size: 12px; font-weight: 600; color: var(--text); text-decoration: none;
    background: var(--panel-2); border: 1px solid var(--line);
    padding: 6px 12px; border-radius: 7px; transition: background .2s;
}
.logout-btn:hover { background: var(--line); }

/* ===== Colour-theme picker ===== */
.theme-picker { position: relative; display: inline-flex; }
.palette-menu {
    position: absolute; top: calc(100% + 8px); right: 0; z-index: 80;
    min-width: 176px; padding: 6px;
    background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
    box-shadow: var(--shadow, 0 10px 28px rgba(0,0,0,.18));
}
.palette-menu[hidden] { display: none; }
.palette-title { font-size: 11px; color: var(--muted); font-weight: 600; padding: 4px 10px 6px; }
.palette-opt {
    display: flex; align-items: center; gap: 10px; width: 100%;
    background: transparent; border: 0; color: var(--text); cursor: pointer;
    padding: 8px 10px; border-radius: 7px; font-size: 13px; font-weight: 500; text-align: left;
}
.palette-opt:hover { background: var(--panel-2); }
.palette-opt.active { background: var(--panel-2); }
.palette-opt.active::after { content: '✓'; margin-left: auto; color: var(--accent); font-weight: 700; }
.palette-sw {
    width: 16px; height: 16px; border-radius: 50%; flex-shrink: 0;
    background: linear-gradient(135deg, var(--sw) 0 50%, var(--sw2) 50% 100%);
    box-shadow: inset 0 0 0 1px rgba(0,0,0,.15);
}
.theme-toggle {
    width: 32px; height: 32px; border-radius: 50%;
    background: var(--panel-2); border: 1px solid var(--line);
    cursor: pointer; font-size: 15px; line-height: 1; color: var(--text);
    display: grid; place-items: center; transition: background .2s;
}
.theme-toggle:hover { background: var(--line); }
:root[data-theme="dark"] .ico-light { display: none; }
:root[data-theme="light"] .ico-dark { display: none; }

/* ===== Grouped nav ===== */
.tabs {
    position: relative;
    display: flex; align-items: center; gap: 4px;
    /* Match the body column so the nav aligns under the logo, not the screen edge. */
    padding: 6px max(20px, calc((100% - 1280px) / 2 + 20px));
    background: var(--panel); border-bottom: 1px solid var(--line);
}
.nav-items { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }

/* Pin the Tools group to the far right of the nav, independent of the saved
   nav-order (which reorders the analytics groups). flex order + auto margin
   push it to the end/right on desktop; on the mobile column it just falls
   last. */
.nav-group[data-group="tools"] { order: 100; margin-left: auto; }
@media (max-width: 760px) {
    .nav-group[data-group="tools"] { margin-left: 0; }
}

/* "New" badge on the Tools menu button. */
.nav-new {
    font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
    line-height: 1; color: #fff; background: var(--accent);
    border-radius: 999px; padding: 2px 6px; margin-left: 6px;
}

/* Realtime pill + group buttons share one look */
.tab, .nav-group-btn {
    background: transparent; border: 1px solid transparent; color: var(--muted);
    padding: 7px 13px; font-size: 13px; font-weight: 600; cursor: pointer;
    line-height: 1.2; border-radius: 8px; white-space: nowrap;
    display: inline-flex; align-items: center; gap: 5px;
}
.tab:hover, .nav-group-btn:hover { color: var(--text); background: var(--panel-2); }
.nav-items > .tab.active { color: #fff; background: var(--accent); }
.nav-group.has-active > .nav-group-btn { color: var(--text); background: var(--panel-2); box-shadow: inset 0 -2px 0 var(--accent); }
.nav-caret { font-size: 10px; opacity: .7; transition: transform .15s ease; }
.nav-group.open .nav-caret { transform: rotate(180deg); }

/* Dropdown menu */
.nav-group { position: relative; }
.nav-menu {
    display: none; position: absolute; top: calc(100% + 6px); left: 0; z-index: 60;
    min-width: 210px; padding: 6px;
    background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
    box-shadow: var(--shadow, 0 10px 28px rgba(0,0,0,.16));
}
.nav-group.open .nav-menu { display: block; }
.nav-menu .tab {
    display: flex; width: 100%; justify-content: flex-start;
    padding: 8px 10px; border-radius: 6px; font-weight: 500; color: var(--text);
}
.nav-menu .tab:hover { background: var(--panel-2); }
.nav-menu .tab.active { color: var(--accent); background: var(--accent-soft, rgba(226,75,74,.12)); font-weight: 600; }

/* Mobile hamburger — hidden on desktop */
.nav-toggle {
    display: none; align-items: center; gap: 6px;
    background: transparent; border: 1px solid var(--line); color: var(--text);
    padding: 7px 12px; font-size: 13px; font-weight: 600; border-radius: 8px; cursor: pointer;
}
.nav-toggle-ico { font-size: 15px; line-height: 1; }

@media (max-width: 860px) {
    .tabs { flex-wrap: wrap; padding: 8px 12px; }
    .nav-toggle { display: inline-flex; }
    .nav-items {
        display: none; flex-direction: column; align-items: stretch;
        width: 100%; gap: 2px; margin-top: 8px;
    }
    .tabs.open .nav-items { display: flex; }
    .nav-items > .tab, .nav-group { width: 100%; }
    .nav-group-btn { width: 100%; justify-content: space-between; }
    .nav-caret { margin-left: auto; }
    /* Menus flow inline as accordions instead of floating */
    .nav-menu {
        position: static; min-width: 0; width: 100%;
        box-shadow: none; border: 0; border-left: 2px solid var(--line);
        border-radius: 0; margin: 2px 0 4px 10px; padding: 2px 0;
    }
}

main { max-width: 1280px; margin: 0 auto; padding: 16px 20px 24px; }

/* ===== Footer credits ===== */
.app-footer {
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
    margin-top: 8px; padding: 14px max(20px, calc((100% - 1280px) / 2 + 20px));
    border-top: 1px solid var(--line); background: var(--panel);
    color: var(--muted); font-size: 12px;
}
.credit-label { font-weight: 700; color: var(--text); }
.credit-sep { color: var(--muted); opacity: .6; }
.credit-names { color: var(--text); }
.credit-empty { color: var(--muted); font-style: italic; font-weight: 400; }
.credit-tail { margin-left: auto; color: var(--muted); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* Embedded Stock Image Search tool (Tools menu). The iframe fills the width
   and takes a tall viewport-relative height; the tool scrolls internally
   (its own infinite scroll lives inside the iframe's own window). */
.tool-frame {
    width: 100%;
    height: calc(100vh - 170px);
    min-height: 560px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
    display: block;
}

/* ===== Filters ===== */
.filters {
    display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end;
    background: var(--panel); border: 1px solid var(--line);
    border-radius: 14px; padding: 16px; margin-bottom: 20px; box-shadow: var(--shadow);
}
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
select {
    background: var(--panel-2); color: var(--text); border: 1px solid var(--line);
    border-radius: 8px; padding: 8px 10px; min-width: 130px; font-size: 14px;
}
.btn {
    background: var(--accent); color: #fff; border: 0; border-radius: 8px;
    padding: 9px 16px; font-weight: 600; cursor: pointer; transition: opacity .2s;
}
.btn:hover { opacity: .9; }
.btn.ghost { background: transparent; border: 1px solid var(--line); color: var(--text); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.last-updated { margin-left: auto; align-self: center; color: var(--muted); font-size: 12px; }

/* ===== Stat cards ===== */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 20px; }
.card {
    background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
    padding: 16px; box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.card::before {
    content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--accent);
}
.card .k { color: var(--muted); font-size: 12px; }
.card .v { font-size: 24px; font-weight: 700; margin-top: 6px; font-variant-numeric: tabular-nums; }

/* ===== Sub-tabs ===== */
.subtabs {
    display: inline-flex; gap: 4px; padding: 4px; margin-bottom: 18px;
    background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px;
}
.subtab {
    background: transparent; border: 0; color: var(--muted); cursor: pointer;
    padding: 8px 16px; font-size: 13px; font-weight: 600; border-radius: 7px; transition: all .15s;
}
.subtab:hover { color: var(--text); }
.subtab.active { background: var(--panel); color: var(--text); box-shadow: var(--shadow); }
.subtab-panel { display: none; }
.subtab-panel.active { display: block; }

/* ===== Chart controls (subtabs + line/bar toggle) ===== */
.chart-controls { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.ctype { display: inline-flex; gap: 2px; padding: 3px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; margin-bottom: 18px; }
.ctype-btn { background: transparent; border: 0; color: var(--muted); cursor: pointer; padding: 5px 12px; font-size: 12px; font-weight: 600; border-radius: 6px; }
.ctype-btn:hover { color: var(--text); }
.ctype-btn.active { background: var(--panel); color: var(--text); box-shadow: var(--shadow); }

/* ===== Charts ===== */
.charts {
    display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; margin-bottom: 22px;
}
.charts.stacked { grid-template-columns: 1fr; }
.charts.stacked .chart-box { height: 340px; }
.chart-card {
    background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
    padding: 16px; box-shadow: var(--shadow);
}
.chart-card.wide { grid-column: 1 / -1; }
.chart-card h3 { margin: 0 0 12px; font-size: 14px; font-weight: 600; }
.chart-box { position: relative; height: 280px; }
@media (max-width: 760px) {
    .charts { grid-template-columns: 1fr; }
    .chart-card.wide { grid-column: auto; }
}

/* ===== Data section (always-visible table) ===== */
.data-section { margin-top: 24px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.f-export { flex: 0 0 auto; }
.section-title { font-size: 14px; font-weight: 600; margin: 0 0 12px; color: var(--text); }

/* ===== Table ===== */
.table-wrap { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; overflow-x: auto; box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; min-width: 880px; }
th, td { padding: 11px 14px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; font-variant-numeric: tabular-nums; }
th:first-child, td:first-child { text-align: left; position: sticky; left: 0; background: var(--panel); }
thead th { color: var(--muted); font-size: 12px; font-weight: 600; }
thead th.sortable { cursor: pointer; user-select: none; }
thead th.sortable:hover { color: var(--text); }
.sort-arrow { color: var(--accent); font-size: 11px; }
tbody tr:hover { background: var(--panel-2); }
tbody tr:hover td:first-child { background: var(--panel-2); }
.empty { padding: 40px; text-align: center; color: var(--muted); }

/* ===== Realtime ===== */
.rt-bar {
    display: flex; align-items: center; gap: 12px;
    margin: 0 0 12px; padding: 0;
}
.rt-updated { color: var(--muted); font-size: 12px; }
.rt-countdown {
    margin-left: auto; cursor: pointer; user-select: none;
    font-size: 16px; font-weight: 700; color: var(--text);
    font-variant-numeric: tabular-nums; background: var(--panel);
    border: 1px solid var(--line); border-radius: 999px; padding: 8px 16px;
    min-width: 78px; text-align: center; box-shadow: var(--shadow); transition: background .15s;
}
.rt-countdown:hover { background: var(--panel-2); }
.delta { font-size: 12px; font-weight: 600; }
.delta.up { color: var(--good); }
.delta.down { color: var(--accent); }
.total-row td { font-weight: 700; background: var(--panel-2); border-bottom: 2px solid var(--line); }
.total-row td:first-child { background: var(--panel-2); }
.story-title { font-weight: 500; }
.story-link { color: var(--accent-2); text-decoration: none; }
.story-link:hover { text-decoration: underline; }
/* Left-align + wrap the Title column (3rd col) in the Top Stories table */
#panel-top_stories th:nth-child(3),
#panel-top_stories td:nth-child(3) { text-align: left; white-space: normal; max-width: 760px; }
/* Left-align the Author column (2nd col) in the Author Stats table */
#panel-author_stats th:nth-child(2),
#panel-author_stats td:nth-child(2) { text-align: left; white-space: normal; }
/* Left-align the Title column (header + cells) in the stories table */
.stories-table th:nth-child(2),
.stories-table td:nth-child(2) { text-align: left; white-space: normal; max-width: 720px; }

/* ===== Author drill-down modal ===== */
.author-link { color: var(--accent-2); text-decoration: none; font-weight: 500; cursor: pointer; }
.author-link:hover { text-decoration: underline; }
.modal-overlay {
    position: fixed; inset: 0; z-index: 1000; background: rgba(0, 0, 0, .55);
    display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow-y: auto;
}
.modal-overlay[hidden] { display: none; }
.modal {
    position: relative; width: 100%; max-width: 880px; background: var(--bg);
    border: 1px solid var(--line); border-radius: 16px; padding: 22px; box-shadow: var(--shadow);
}
.modal-close {
    position: absolute; top: 12px; right: 14px; width: 32px; height: 32px; border-radius: 50%;
    background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
    font-size: 20px; line-height: 1; cursor: pointer;
}
.modal-close:hover { background: var(--line); }
.modal-head { margin-bottom: 16px; padding-right: 40px; }
.modal-head h2 { margin: 0 0 4px; font-size: 20px; }
.am-sub { color: var(--muted); font-size: 13px; }
.am-rank {
    display: inline-block; margin-top: 10px; padding: 6px 14px; border-radius: 999px;
    background: var(--accent); color: #fff; font-weight: 700; font-size: 13px;
}
.am-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 12px; margin-bottom: 18px; }
.modal .chart-card { margin-bottom: 16px; }
.am-filters { position: absolute; top: 16px; right: 60px; display: flex; gap: 12px; align-items: flex-end; margin: 0; z-index: 2; }
.am-filters select { min-width: 104px; padding: 6px 8px; }
.am-filters .field label { font-size: 10px; }
@media (max-width: 640px) {
    .am-filters { position: static; margin: 4px 0 16px; }
}

/* ===== Source icons (Social Platform) ===== */
.src-ico { display: inline-flex; vertical-align: -2px; margin-right: 5px; }
.src-ico svg { width: 13px; height: 13px; }

/* ===== Pager ===== */
.pager { display: flex; align-items: center; justify-content: center; gap: 16px; margin: 20px 0; color: var(--muted); }

/* ===== Targets admin ===== */
.tg-addbar { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; }
.tg-newauthor {
    flex: 1; max-width: 320px; padding: 9px 12px; font-size: 14px; color: var(--text);
    background: var(--panel-2); border: 1px solid var(--line); border-radius: 9px; outline: none;
}
.tg-newauthor:focus { border-color: var(--accent-2); }
.tg-table td .tg-uv, .tg-table td .tg-pv {
    width: 130px; padding: 7px 9px; font-size: 13px; color: var(--text);
    background: var(--panel-2); border: 1px solid var(--line); border-radius: 7px; text-align: right;
}
.tg-table td .tg-uv:focus, .tg-table td .tg-pv:focus { border-color: var(--accent-2); outline: none; }
.tg-table td:first-child, .tg-table th:first-child { text-align: left; }
.tg-active-wrap { display: inline-flex; }
.tg-active { width: 18px; height: 18px; accent-color: var(--good); cursor: pointer; }
.tg-savebar { display: flex; align-items: center; gap: 14px; margin: 16px 0; }
.tg-saved { color: var(--good); font-size: 13px; font-weight: 600; }
.tg-modetabs { margin-bottom: 14px; }
.tg-statustabs { margin: 0 0 12px; }

/* ===== Realtime delta cards (positive / neutral / negative) ===== */
/* Realtime top bar: channel selector sits just before the countdown, right-aligned. */
.rt-bar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.rt-focus-wrap { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.rt-focus-wrap select { min-width: 130px; padding: 6px 8px; font-size: 13px; }

.rt-good { color: var(--good); }
.rt-bad  { color: var(--accent); }
.rt-flat { color: var(--muted); }
.rt-card-good::before { background: var(--good) !important; }
.rt-card-bad::before  { background: var(--accent) !important; }
.rt-card-flat::before { background: var(--muted) !important; }

/* ===== Insights tab ===== */
.ins-loading { color: var(--muted); padding: 40px 0; text-align: center; }
.ins-kpis .card .ins-kpi-foot { margin-top: 8px; display: flex; align-items: center; gap: 8px; }
.ins-vs { color: var(--muted); font-size: 11px; }
.ins-delta { font-size: 12px; font-weight: 700; padding: 2px 7px; border-radius: 20px; white-space: nowrap; }
.ins-delta.good { color: var(--good); background: color-mix(in srgb, var(--good) 15%, transparent); }
.ins-delta.bad  { color: var(--accent); background: color-mix(in srgb, var(--accent) 15%, transparent); }
.ins-delta.flat { color: var(--muted); background: var(--panel-2); }

/* Insights tables: fit their container and wrap, never scroll horizontally */
#panel-insights .table-wrap { overflow-x: visible; }
#panel-insights table { min-width: 0; }
#panel-insights th, #panel-insights td { white-space: normal; padding: 9px 11px; word-break: break-word; }
#panel-insights th:first-child, #panel-insights td:first-child { position: static; }
#panel-insights th, #panel-insights td { vertical-align: middle; }
/* Top-stories: left-align the story title; keep #/Users tight, centered, no wrap */
#panel-insights .ins-stories th:nth-child(2), #panel-insights .ins-stories td:nth-child(2) { text-align: left; }
#panel-insights .ins-stories th:first-child, #panel-insights .ins-stories td:first-child { text-align: center; width: 32px; white-space: nowrap; }
#panel-insights .ins-stories th:last-child, #panel-insights .ins-stories td:last-child { text-align: right; white-space: nowrap; width: 1%; }

/* Findings — grouped into 3 horizon columns */
/* Key findings as stacked horizontal sections (Day / Last 30d / Week / Year). */
.findings-sections { margin-bottom: 22px; }
.findings-section { margin-bottom: 20px; }
/* Fluid masonry-style flow: cards pack down columns instead of a rigid grid. */
.findings-row { columns: 3 260px; column-gap: 14px; }
.findings-row .finding-group {
    break-inside: avoid; -webkit-column-break-inside: avoid; page-break-inside: avoid;
    width: 100%; margin: 0 0 14px;
}
.findings-col { display: flex; flex-direction: column; gap: 10px; }
.findings-col-h { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); margin: 0 0 2px; font-weight: 700; }
.findings-empty { color: var(--muted); font-size: 12px; padding: 6px 0; }

/* Grouped findings (clubbed by analysis category, shown as bullets) */
.finding-group { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 11px 14px; box-shadow: var(--shadow); }
.finding-group-h { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); margin-bottom: 7px; }
.finding-list { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 6px; list-style: disc; }
.finding-li { font-size: 13px; line-height: 1.45; }
.finding-li.good::marker { color: var(--good); }
.finding-li.bad::marker  { color: var(--accent); }
.finding-li.warn::marker { color: var(--accent-2); }
.finding-li.neutral::marker { color: var(--muted); }

/* Findings list */
.findings { display: flex; flex-direction: column; gap: 8px; margin-bottom: 22px; }
.finding {
    display: flex; align-items: flex-start; gap: 10px;
    background: var(--panel); border: 1px solid var(--line); border-left-width: 4px;
    border-radius: 10px; padding: 10px 14px; box-shadow: var(--shadow);
}
.finding.good { border-left-color: var(--good); }
.finding.bad  { border-left-color: var(--accent); }
.finding.warn { border-left-color: var(--accent-2); }
.finding.neutral { border-left-color: var(--muted); }
.finding-tag {
    flex: none; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px;
    color: var(--muted); background: var(--panel-2); border-radius: 6px; padding: 3px 7px; margin-top: 1px;
}
.finding-text { font-size: 13px; line-height: 1.45; }

/* Two-column layout blocks */
.ins-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 22px; }
.ins-cols > * { min-width: 0; }  /* allow children to shrink so tables don't blow out the page */
@media (max-width: 900px) { .ins-cols { grid-template-columns: 1fr; } }
.ins-card {
    background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
    padding: 16px 18px; box-shadow: var(--shadow); margin-bottom: 22px;
}
.ins-cols .ins-card { margin-bottom: 0; }
.ins-card .section-title { margin-top: 0; }

/* Time comparisons */
.ins-periods { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; margin-bottom: 22px; }
.ins-period { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; box-shadow: var(--shadow); min-width: 0; overflow: hidden; }
.ins-period-head { font-size: 13px; font-weight: 700; margin-bottom: 8px; display: flex; flex-direction: column; gap: 2px; }
.ins-period-head span { color: var(--muted); font-weight: 500; font-size: 11px; white-space: normal; line-height: 1.35; }
/* fixed layout so the table always fits its card and can never widen the page */
table.ins-mini { width: 100%; min-width: 0; border-collapse: collapse; font-size: 13px; }
table.ins-mini th, table.ins-mini td { text-align: right; padding: 5px 6px; white-space: nowrap; }
table.ins-mini th:first-child, table.ins-mini td:first-child { text-align: left; }
table.ins-mini th:last-child, table.ins-mini td:last-child { padding-left: 10px; }
table.ins-mini thead th { color: var(--muted); font-size: 11px; font-weight: 600; border-bottom: 1px solid var(--line); }
table.ins-mini tbody th { text-align: left; font-weight: 600; color: var(--text); }
table.ins-mini .ins-prev { color: var(--muted); }

/* Mix charts */
.ins-mix-charts { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.ins-mix-charts > *, .ins-ct-wrap > * { min-width: 0; }
@media (max-width: 560px) { .ins-mix-charts { grid-template-columns: 1fr; } }
.ins-chart-t { font-size: 12px; color: var(--muted); text-align: center; margin-bottom: 4px; }
.ins-chart .chart-box { height: 210px; }

/* Targets */
.ins-target { margin-bottom: 14px; }
.ins-target-row { display: flex; justify-content: space-between; font-size: 13px; font-weight: 600; margin-bottom: 5px; }
.progress { height: 9px; background: var(--panel-2); border-radius: 20px; overflow: hidden; }
.progress-bar { height: 100%; border-radius: 20px; }
.progress-bar.good { background: var(--good); }
.progress-bar.warn { background: var(--accent-2); }
.progress-bar.bad  { background: var(--accent); }
.ins-target-meta { font-size: 12px; color: var(--muted); margin-top: 4px; }
.ins-target-meta b { color: var(--text); }

/* Content type block */
.ins-ct-wrap { display: grid; grid-template-columns: 360px 1fr; gap: 16px; align-items: start; }
@media (max-width: 820px) { .ins-ct-wrap { grid-template-columns: 1fr; } }
.ins-ct-chart { height: 240px; }

/* Author movers */
.ins-movers { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.ins-mover { font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 20px; border: 1px solid var(--line); }
.ins-mover.good { color: var(--good); }
.ins-mover.bad  { color: var(--accent); }

/* ---- Author Daily grid (authors × day story-count pivot) ---- */
.ad-wrap { overflow-x: auto; }
.ad-table { border-collapse: collapse; min-width: max-content; }
.ad-table th, .ad-table td {
    padding: 7px 12px; text-align: right; white-space: nowrap;
    border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums;
}
.ad-table thead th { font-weight: 600; color: var(--muted); }
.ad-authorhead, .ad-name {
    position: sticky; left: 0; z-index: 1; text-align: left;
    background: var(--panel); min-width: 190px; max-width: 260px;
    overflow: hidden; text-overflow: ellipsis;
}
.ad-total { font-weight: 700; }
.ad-cell.ad-zero { color: var(--muted); opacity: .45; }
.ad-totalrow td { font-weight: 700; border-top: 2px solid var(--line); background: var(--bg); }
.ad-totalrow .ad-name { background: var(--bg); }

/* ---- Author Daily grid — enhanced (sticky edges, heat-map, weekday headers) ---- */
/* Scroll box that fills the viewport height (feels "opened", not a small fixed
   box) and scrolls INTERNALLY. This keeps the horizontal collapse intact
   (overflow-x) AND freezes the header + first column while you scroll the rows,
   which is impossible if the header must instead pin to the whole page. */
.ad-wrap {
    max-height: calc(100vh - 190px);
    overflow: auto;
    border: 1px solid var(--line); border-radius: 10px;
}
.ad-table thead th {
    position: sticky; top: 0; z-index: 2; background: var(--panel);
    text-align: center; vertical-align: bottom;
}
.ad-authorhead { z-index: 4; text-align: left; }
.ad-sortable { cursor: pointer; user-select: none; }
.ad-sortable:hover { color: var(--accent); }
.ad-sarrow { font-size: 0.85em; color: var(--accent); }
.ad-day { min-width: 46px; }
.ad-day.ad-weekend { background: color-mix(in srgb, var(--muted) 14%, var(--panel)); }
.ad-dnum { display: block; font-weight: 700; color: var(--text); }
.ad-dow  { display: block; font-size: 11px; font-weight: 500; color: var(--muted); }
/* Summary columns (Total, Total UV, UV Target/Achieved/%) scroll with the grid —
   too many to pin individually; only the Author column stays frozen. */
.ad-ab { font-size: 10px; font-weight: 700; letter-spacing: .04em; color: var(--muted); opacity: .55; }
.ad-total { font-weight: 700; background: var(--panel); border-left: 1px solid var(--line); }
.ad-sep { border-left: 2px solid var(--line) !important; }
.ad-totalhead { }
.ad-name .ad-rank {
    display: inline-block; min-width: 20px; margin-right: 8px;
    color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums;
}
.ad-body tr:hover .ad-name,
.ad-body tr:hover .ad-total { background: color-mix(in srgb, var(--accent) 10%, var(--panel)); }
.ad-body tr:hover td:not([style]) { background: color-mix(in srgb, var(--accent) 8%, transparent); }
.ad-totalrow td {
    position: sticky; bottom: 0; z-index: 2; background: var(--bg);
    font-weight: 700; border-top: 2px solid var(--line);
}
.ad-totalrow .ad-name, .ad-totalrow .ad-total { z-index: 3; }

/* Author Daily — left-align author names/header (beats the .ad-table td right-align) */
.ad-table td.ad-name, .ad-table th.ad-authorhead { text-align: left; }

/* ---- Author Daily — solid Excel-style frozen panes ---- */
.ad-wrap { position: relative; }
.ad-table { border-collapse: separate; border-spacing: 0; }
.ad-table thead th {
    position: sticky; top: 0; z-index: 3; background: var(--panel);
    box-shadow: inset 0 -1px 0 var(--line);
}
.ad-table td.ad-name {
    position: sticky; left: 0; z-index: 4; background: var(--panel);
    box-shadow: 1px 0 0 var(--line);
}
.ad-table th.ad-authorhead {
    position: sticky; left: 0; top: 0; z-index: 6; background: var(--panel);
    box-shadow: 1px 0 0 var(--line), inset 0 -1px 0 var(--line);
}
.ad-table td.ad-total { background: var(--panel); }
.ad-table th.ad-totalhead {
    position: sticky; top: 0; z-index: 6; background: var(--panel);
    box-shadow: inset 0 -1px 0 var(--line);
}
.ad-totalrow td {
    position: sticky; bottom: 0; z-index: 3; background: var(--bg);
    box-shadow: inset 0 1px 0 var(--line);
}
.ad-totalrow td.ad-name { z-index: 5; }
.ad-totalrow td.ad-total { z-index: 5; }

/* fix: frozen Author/Total cells must stay OPAQUE on hover (the generic
   tr:hover td:not([style]) rule was making them translucent, so day values
   bled through the frozen columns while scrolling). */
.ad-body tr:hover td.ad-name,
.ad-body tr:hover td.ad-total { background: color-mix(in srgb, var(--accent) 12%, var(--panel)); }

/* ---- Monthly Stats: compare-previous-period delta strip ---- */
.cmp-strip { margin: 4px 0 14px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); }
.cmp-head { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.cmp-grid { display: flex; flex-wrap: wrap; gap: 10px; }
.cmp-item { flex: 1 1 160px; min-width: 140px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; }
.cmp-item .cmp-label { font-size: 12px; color: var(--muted); }
.cmp-item .cmp-val { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.cmp-item .cmp-prev { font-size: 11px; color: var(--muted); margin-top: 2px; }
.cmp-item .ins-delta { display: inline-block; margin-top: 2px; font-size: 12px; font-weight: 600; }

/* ---- Author Ranking leaderboard ---- */
.ar-podium { display: flex; gap: 12px; flex-wrap: wrap; margin: 6px 0 16px; }
.ar-podium-card { flex: 1 1 180px; min-width: 160px; text-align: center; padding: 14px 12px;
    border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
.ar-p1 { border-color: #e6b800; box-shadow: 0 0 0 1px #e6b80033 inset; }
.ar-medal { font-size: 28px; line-height: 1; }
.ar-pname { font-weight: 700; margin-top: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ar-ppct { display: inline-block; margin-top: 4px; font-size: 18px; font-weight: 800; }
.ar-pmeta { font-size: 11px; color: var(--muted); margin-top: 2px; }
/* Fixed layout so columns don't reflow when switching channels; the Ach % graph
   column is left width-less so it absorbs the remaining, adjustable space. */
.ar-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.ar-table th:nth-child(3), .ar-table td:nth-child(3),
.ar-table th:nth-child(4), .ar-table td:nth-child(4) { width: 15%; }
.ar-table th:nth-child(6), .ar-table td:nth-child(6) { width: 84px; }
.ar-table th, .ar-table td { padding: 9px 12px; text-align: right; border-bottom: 1px solid var(--line);
    white-space: nowrap; font-variant-numeric: tabular-nums; }
.ar-table th { color: var(--muted); font-weight: 600; }
.ar-rankh, .ar-rank { text-align: center; width: 44px; font-weight: 700; }
.ar-nameh, .ar-name { text-align: left; width: 22%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ar-bar-wrap { position: relative; display: flex; align-items: center; gap: 8px; justify-content: flex-end; min-width: 160px; }
.ar-bar { height: 8px; border-radius: 4px; background: var(--accent); }
.ar-bar.good { background: var(--good, #2e9e5b); }
.ar-bar.warn { background: #e0a000; }
.ar-bar.bad  { background: #d05050; }
.ar-pct { min-width: 52px; text-align: right; }
.ar-notarget { margin-top: 14px; }
.ar-nt-head { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.ar-nt-list { display: flex; flex-wrap: wrap; gap: 8px; }
.ar-nt-item { font-size: 12px; color: var(--muted); border: 1px solid var(--line); border-radius: 6px; padding: 3px 8px; }
.ar-nt-item em { font-style: normal; color: var(--text); font-weight: 600; }

/* ===================== Core-Update RCA tab ===================== */
.rca-verdict {
    border: 1px solid var(--line); border-left: 6px solid var(--muted);
    background: var(--panel); border-radius: 10px; padding: 16px 18px;
    margin-bottom: 18px; box-shadow: var(--shadow);
}
.rca-cat-algorithmic_content_reassessment { border-left-color: var(--accent); }
.rca-cat-algorithmic_broad { border-left-color: #e67e22; }
.rca-cat-technical_or_manual { border-left-color: #9b59b6; }
.rca-cat-volatility { border-left-color: var(--accent-2); }
.rca-cat-stable { border-left-color: var(--good); }
.rca-verdict-top { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.rca-badge {
    font-size: 11px; font-weight: 700; letter-spacing: .04em;
    padding: 3px 8px; border-radius: 20px; color: #fff; background: var(--muted);
}
.rca-conf-high { background: var(--accent); }
.rca-conf-medium { background: #e67e22; }
.rca-conf-low { background: var(--accent-2); }
.rca-cat-label { color: var(--muted); font-size: 12px; text-transform: capitalize; }
.rca-headline { font-size: 18px; font-weight: 700; margin-bottom: 6px; }
.rca-points { margin: 6px 0 0; padding-left: 18px; color: var(--text); }
.rca-points li { margin: 3px 0; }

.rca-chart-card { padding: 14px 16px; }
.rca-chart-wrap { position: relative; height: 320px; margin-top: 8px; }
.rca-legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 10px; font-size: 12px; color: var(--muted); }
.rca-leg-item { display: inline-flex; align-items: center; gap: 6px; }
.rca-leg-item i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; background: var(--muted); }
.rca-u-core i { background: rgba(192,57,43,.55); }
.rca-u-spam i { background: rgba(230,126,34,.55); }
.rca-u-helpful_content i { background: rgba(155,89,182,.55); }
.rca-u-discover i { background: rgba(41,128,185,.55); }

.rca-note { color: var(--muted); font-size: 12px; margin: 4px 0 10px; }
.rca-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.rca-table th, .rca-table td { padding: 7px 10px; border-bottom: 1px solid var(--line); text-align: left; }
.rca-table th.num, .rca-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.rca-table tr.rca-collapsed td { background: rgba(192,57,43,.08); font-weight: 600; }
.rca-table td.neg { color: var(--accent); }
.rca-table td.pos { color: var(--good); }

.rca-srcs { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-top: 6px; }
.rca-src { display: flex; justify-content: space-between; align-items: baseline;
    padding: 10px 12px; background: var(--panel-2); border-radius: 8px; }
.rca-src span { color: var(--muted); font-size: 13px; }
.rca-src b { font-size: 16px; }
.rca-src b.neg { color: var(--accent); }
.rca-src b.pos { color: var(--good); }

.rca-actions ol { margin: 6px 0 0; padding-left: 20px; }
.rca-actions li { margin: 5px 0; }
.rca-sections, .rca-actions { margin-top: 16px; }

/* ---- RCA: richer explanation + examples + glossary ---- */
.rca-narrative { margin: 8px 0 0; line-height: 1.55; color: var(--text); }
.rca-explainer {
    margin: 12px 0 4px; padding: 12px 14px; border-radius: 8px;
    background: var(--panel-2); border: 1px dashed var(--line);
    line-height: 1.55; color: var(--text); font-size: 13.5px;
}
.rca-explainer-tag {
    display: block; font-size: 11px; font-weight: 700; letter-spacing: .05em;
    text-transform: uppercase; color: var(--muted); margin-bottom: 5px;
}
.rca-evidence-label {
    margin-top: 12px; font-size: 11px; font-weight: 700; letter-spacing: .05em;
    text-transform: uppercase; color: var(--muted);
}
.rca-howto { margin-top: 10px; font-size: 12px; color: var(--muted); line-height: 1.5; }

.rca-playbook { margin: 6px 0 0; padding-left: 22px; }
.rca-playbook li { margin: 12px 0; }
.rca-pb-title { font-weight: 700; font-size: 14px; }
.rca-pb-detail { margin: 3px 0 6px; color: var(--text); line-height: 1.5; font-size: 13px; }
.rca-pb-example {
    background: var(--panel-2); border-left: 3px solid var(--accent-2);
    padding: 8px 10px; border-radius: 6px; font-size: 12.5px; color: var(--text); line-height: 1.5;
}
.rca-pb-example span {
    display: inline-block; font-size: 10px; font-weight: 700; letter-spacing: .05em;
    text-transform: uppercase; color: var(--accent-2); margin-right: 6px;
}

.rca-glossary { margin-top: 16px; }
.rca-glossary summary { cursor: pointer; font-weight: 700; color: var(--text); }
.rca-glossary summary::marker { color: var(--muted); }
.rca-glossary dl { margin: 10px 0 0; }
.rca-glossary dt { font-weight: 700; font-size: 13px; margin-top: 10px; }
.rca-glossary dd { margin: 2px 0 0; color: var(--muted); font-size: 12.5px; line-height: 1.5; }

/* ===================== Content QC tab (RSS thin-content) ===================== */
.qc-kpis { margin-bottom: 16px; }
.qc-caveat {
    background: var(--panel-2); border: 1px dashed var(--line); border-radius: 8px;
    padding: 10px 14px; margin-bottom: 14px; font-size: 12.5px; color: var(--muted); line-height: 1.5;
}
.qc-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.qc-table th, .qc-table td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.qc-table th.num, .qc-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.qc-table tbody tr:hover { background: var(--panel-2); }
.qc-title a { color: var(--text); text-decoration: none; font-weight: 600; }
.qc-title a:hover { color: var(--accent-2); text-decoration: underline; }
.qc-time { color: var(--muted); white-space: nowrap; }
.qc-src { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .03em; }
.qc-badge { display: inline-block; font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 20px; color: #fff; }
.qc-ok { background: var(--good); }
.qc-warn { background: #e67e22; }
.qc-bad { background: var(--accent); }
.qc-flat { background: var(--muted); }
.qc-pager { display: flex; align-items: center; gap: 12px; margin-top: 12px; color: var(--muted); font-size: 13px; }
.qc-pager .btn[disabled] { opacity: .45; cursor: default; }

/* Content QC list: fixed layout so long headlines don't push key columns off-screen */
.qc-table-wrap { overflow-x: auto; }
.qc-table.qc-list { table-layout: fixed; }
.qc-table.qc-list th:nth-child(1), .qc-table.qc-list td:nth-child(1) { width: 32%; }   /* Story */
.qc-table.qc-list th:nth-child(2), .qc-table.qc-list td:nth-child(2) { width: 12%; }   /* Section */
.qc-table.qc-list th:nth-child(3), .qc-table.qc-list td:nth-child(3) { width: 9%;  }   /* Type */
.qc-table.qc-list th:nth-child(4), .qc-table.qc-list td:nth-child(4) { width: 15%; }   /* Author */
.qc-table.qc-list th:nth-child(5), .qc-table.qc-list td:nth-child(5) { width: 11%; }   /* Filed */
.qc-table.qc-list th:nth-child(6), .qc-table.qc-list td:nth-child(6) { width: 10%; white-space: nowrap; }  /* Words (coloured by verdict) */
.qc-table.qc-list th:nth-child(7), .qc-table.qc-list td:nth-child(7) { width: 11%; white-space: nowrap; }  /* In Sitemap */
/* Coloured word-count pill: tabular figures, sits right-aligned in its cell. */
.qc-badge.qc-wc { font-variant-numeric: tabular-nums; min-width: 42px; text-align: center; }
/* Word-count colour legend above the list. */
.qc-legend { display: flex; align-items: center; flex-wrap: wrap; gap: 14px; margin: 4px 2px 10px; font-size: 12px; color: var(--muted); }
.qc-legend-lbl { font-weight: 600; color: var(--text); }
.qc-legend-item { display: inline-flex; align-items: center; gap: 6px; }

/* ===== Management dashboard (channel × month UV/PV grid) ===== */
.mg-bar { align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.mg-toggle { display: inline-flex; gap: 4px; }
.mg-mbtn { background: var(--panel-2); border: 1px solid var(--line); color: var(--muted);
    padding: 7px 12px; border-radius: 8px; font-size: 13px; font-weight: 600; cursor: pointer; }
.mg-mbtn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.mg-caption { margin-left: auto; color: var(--muted); font-size: 12px; font-weight: 600; }
.mg-grid { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 900px; }
.mg-grid th, .mg-grid td { padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.mg-grid th.num, .mg-grid td.num { text-align: right; font-variant-numeric: tabular-nums; }
.mg-grid th.mg-ch, .mg-grid td.mg-ch { text-align: left; position: sticky; left: 0;
    background: var(--panel); font-weight: 600; z-index: 1; }
.mg-grid thead th { color: var(--muted); font-size: 11px; font-weight: 600;
    text-transform: uppercase; letter-spacing: .03em; }
.mg-grid td.mg-total, .mg-grid th.mg-total { font-weight: 700; border-left: 1px solid var(--line); }
.mg-grid .total-row td { font-weight: 700; border-top: 2px solid var(--line); background: var(--panel-2); }
.mg-grid .total-row .mg-ch { background: var(--panel-2); }
.mg-na { color: var(--muted); }
.mg-fresh { font-size: 11px; color: var(--muted); text-align: right; margin: -2px 2px 12px; }

/* ===== Recipients settings ===== */
.settings-wrap { max-width: 760px; }
.set-card { padding: 16px 18px; margin-bottom: 16px; }
.set-hint { color: var(--muted); font-size: 12px; margin: 2px 0 12px; }
.set-mgmt, .set-overall { width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px;
    background: var(--panel-2); color: var(--text); font-size: 13px; resize: vertical; font-family: inherit; }
.set-row { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.set-lang { width: 110px; font-weight: 600; font-size: 13px; }
.set-editor { flex: 1; padding: 8px 11px; border: 1px solid var(--line); border-radius: 8px;
    background: var(--panel-2); color: var(--text); font-size: 13px; }
.set-mgmt:focus, .set-overall:focus, .set-editor:focus { border-color: var(--accent-2); outline: none; }

/* ---- Credit tags (chip input) ---- */
.set-tags {
    display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
    padding: 8px 10px; min-height: 46px; cursor: text;
    border: 1px solid var(--line); border-radius: 8px; background: var(--panel-2);
}
.set-tags:focus-within { border-color: var(--accent-2); }
.set-tag {
    display: inline-flex; align-items: center; gap: 7px;
    background: var(--accent-2); color: #fff;
    border-radius: 999px; padding: 5px 6px 5px 13px; font-size: 13px; font-weight: 500;
}
.set-tag-x {
    display: inline-flex; align-items: center; justify-content: center;
    width: 18px; height: 18px; padding: 0; border: 0; border-radius: 50%;
    background: rgba(255, 255, 255, .25); color: #fff; cursor: pointer;
    font-size: 15px; line-height: 1;
}
.set-tag-x:hover { background: rgba(255, 255, 255, .45); }
.set-tag-input {
    flex: 1; min-width: 150px; border: 0; outline: none; background: transparent;
    color: var(--text); font-size: 13px; font-family: inherit; padding: 4px 2px;
}
.set-actions { display: flex; align-items: center; gap: 14px; }
.set-status, .set-dir-status { color: var(--muted); font-size: 12px; }

/* ---- Author directory ---- */
.set-dir-count { color: var(--muted); font-weight: 500; font-size: 13px; }
.set-dir-wrap { border: 1px solid var(--line); border-radius: 8px; margin-bottom: 12px; overflow: hidden; }
.set-dir { width: 100%; border-collapse: collapse; font-size: 13px; }
.set-dir thead th { position: sticky; top: 0; background: var(--panel-2); text-align: left;
    font-size: 11px; letter-spacing: .04em; text-transform: uppercase; color: var(--muted);
    padding: 8px 10px; border-bottom: 1px solid var(--line); }
.set-dir tbody td { padding: 6px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.set-dir tbody tr:last-child td { border-bottom: 0; }
.set-dir-name, .set-dir-email, .set-dir-ch { width: 100%; padding: 6px 9px; border: 1px solid var(--line);
    border-radius: 7px; background: var(--panel-2); color: var(--text); font-size: 13px; font-family: inherit; }
.set-dir-name:focus, .set-dir-email:focus, .set-dir-ch:focus { border-color: var(--accent-2); outline: none; }
.set-dir th:nth-child(1), .set-dir td:nth-child(1) { width: 34%; }
.set-dir th:nth-child(2), .set-dir td:nth-child(2) { width: 38%; }
.set-dir th:nth-child(3), .set-dir td:nth-child(3) { width: 20%; }
.set-dir-x { width: 8%; text-align: center; }
.set-dir-del { border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 14px; line-height: 1; padding: 4px 6px; border-radius: 6px; }
.set-dir-del:hover { color: #c0392b; background: rgba(192,57,43,.1); }
.set-dir-tag { display: inline-block; margin-left: 6px; font-size: 10px; color: var(--accent-2);
    border: 1px solid var(--accent-2); border-radius: 4px; padding: 0 4px; vertical-align: middle; opacity: .8; }
.btn-ghost { background: transparent; border: 1px solid var(--line); color: var(--text); }

/* ---- Navigation order (drag & drop) ---- */
.nav-order { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.no-group { border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2); padding: 6px; }
.no-ghead { display: flex; align-items: center; gap: 8px; padding: 7px 8px; font-weight: 700; font-size: 13px; cursor: grab; }
.no-items { display: flex; flex-direction: column; gap: 4px; padding: 2px 4px 4px; }
.no-item {
    display: flex; align-items: center; gap: 8px; cursor: grab;
    padding: 7px 10px; font-size: 13px; border-radius: 7px;
    background: var(--panel); border: 1px solid var(--line);
}
.no-grip { color: var(--muted); font-size: 14px; cursor: grab; line-height: 1; }
.no-dragging { opacity: .45; }
.no-group.no-dragging { outline: 2px dashed var(--accent-2); }
.no-item.no-dragging { outline: 2px dashed var(--accent-2); }
.mg-exclude { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin-bottom: 12px; box-shadow: var(--shadow); }
.mg-ex-lbl { font-size: 12px; font-weight: 700; color: var(--text); margin-bottom: 8px; }
.mg-ex-lbl span { font-weight: 500; color: var(--muted); }
.mg-ex-list { display: flex; flex-wrap: wrap; gap: 8px 16px; }
.mg-ex-item { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text); cursor: pointer; white-space: nowrap; }
.mg-ex-item input { cursor: pointer; }
.mg-ex-c { color: var(--muted); font-variant-numeric: tabular-nums; }
.mg-proj-title { margin: 24px 2px 10px; font-size: 15px; font-weight: 700; color: var(--text); }
.mg-proj-sub { font-weight: 500; font-size: 12px; color: var(--muted); margin-left: 8px; }
.mg-proj-formula { margin: 0 2px 12px; padding: 10px 12px; font-size: 12px; line-height: 1.5;
    color: var(--muted); background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; }
.mg-proj-formula code { display: block; margin: 4px 0; padding: 6px 8px; font-size: 12px;
    color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 6px; white-space: normal; }
.mg-grid.mg-projgrid { min-width: 560px; }
.mg-grid .mg-proj-val { color: var(--accent); font-weight: 700; }
.mg-grid .delta.up { color: var(--good); }
.mg-grid .delta.down { color: var(--accent); }
/* Trim long headlines to one line with an ellipsis (full title on hover). */
.qc-table.qc-list td { overflow: hidden; }
.qc-table.qc-list .qc-title { max-width: 0; }
.qc-table.qc-list .qc-title a {
    display: block; font-weight: 600;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.qc-table.qc-list .qc-src { text-overflow: ellipsis; white-space: nowrap; }

/* Content QC — author grid */
.qc-table.qc-authors .qc-author { font-weight: 600; }
.qc-pctcell { white-space: nowrap; }
.qc-pctcell b { display: inline-block; min-width: 42px; }
.qc-bar { display: inline-block; vertical-align: middle; width: 90px; height: 8px;
    background: var(--panel-2); border-radius: 5px; overflow: hidden; margin-left: 8px; }
.qc-bar span { display: block; height: 100%; border-radius: 5px; }

/* Content QC — story-type badges */
.qc-type { display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 8px;
    border-radius: 20px; border: 1px solid var(--line); color: var(--text); white-space: nowrap; }
.qc-t-article { background: rgba(34,197,94,.14); border-color: rgba(34,197,94,.4); }   /* real text */
.qc-t-gallery { background: rgba(230,126,34,.14); border-color: rgba(230,126,34,.4); }
.qc-t-video   { background: rgba(59,130,246,.14); border-color: rgba(59,130,246,.4); }
.qc-t-photo   { background: rgba(155,89,182,.16); border-color: rgba(155,89,182,.4); }
.qc-t-photoslide { background: rgba(20,184,166,.16); border-color: rgba(20,184,166,.4); }
.qc-t-other   { background: var(--panel-2); }

/* Content QC — threshold editor */
.qc-thresholds input[type=number] { width: 110px; background: var(--panel-2); color: var(--text);
    border: 1px solid var(--line); border-radius: 7px; padding: 6px 8px; font-size: 14px; }
.qc-thresholds .qc-th-actions { display: flex; gap: 8px; }
.qc-thresholds .btn { padding: 6px 12px; }
.qc-inherit { font-size: 11px; color: var(--muted); font-weight: 400; }
.qc-th-foot { margin-top: 14px; }

/* Content QC — type mix by day */
/* Type-mix table: fixed Day + number columns, flexible Mix (bar) column. */
.qc-table.qc-mixtable { table-layout: fixed; width: 100%; min-width: 0; }
.qc-table.qc-mixtable th:first-child, .qc-table.qc-mixtable td:first-child { width: 96px; }   /* Day */
.qc-table.qc-mixtable th.num, .qc-table.qc-mixtable td.num { width: 96px; }                    /* type % + Total */
.qc-mix-cell { width: auto; }        /* the bar column takes whatever space is left */
.qc-mix-cell .qc-mix { min-width: 120px; }
.qc-mix { display: flex; width: 100%; height: 14px; border-radius: 5px; overflow: hidden; background: var(--panel-2); }
.qc-mix-seg { height: 100%; }
.qc-mix-seg.qc-t-article { background: #22c55e; }
.qc-mix-seg.qc-t-gallery { background: #e67e22; }
.qc-mix-seg.qc-t-video   { background: #3b82f6; }
.qc-mix-seg.qc-t-photo   { background: #9b59b6; }
.qc-mix-seg.qc-t-photoslide { background: #14b8a6; }
.qc-mix-seg.qc-t-other   { background: #8a97b3; }
.qc-mix-c { color: var(--muted); font-size: 11px; }
.qc-mix-legend { display: flex; flex-wrap: wrap; gap: 14px; margin: 6px 0 12px; font-size: 12px; color: var(--muted); }
.qc-leg { display: inline-flex; align-items: center; gap: 6px; }
.qc-leg i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.qc-leg i.qc-t-article { background: #22c55e; }
.qc-leg i.qc-t-gallery { background: #e67e22; }
.qc-leg i.qc-t-video   { background: #3b82f6; }
.qc-leg i.qc-t-photo   { background: #9b59b6; }
.qc-leg i.qc-t-photoslide { background: #14b8a6; }
.qc-leg i.qc-t-other   { background: #8a97b3; }

/* Content QC — Web Stories type color (teal) */
.qc-t-webstories { background: rgba(236,72,153,.16); border-color: rgba(236,72,153,.45); }
.qc-mix-seg.qc-t-webstories { background: #ec4899; }
.qc-leg i.qc-t-webstories { background: #ec4899; }

/* Content QC — thresholds "how to read this" note */
.qc-th-help { margin: 6px 0 14px; padding: 10px 14px; background: var(--panel-2);
    border: 1px dashed var(--line); border-radius: 8px; font-size: 13px; }
.qc-th-help summary { cursor: pointer; font-weight: 600; color: var(--text); }
.qc-th-help p { margin: 8px 0; line-height: 1.55; color: var(--text); }
.qc-th-help ul { margin: 6px 0 0; padding-left: 18px; }
.qc-th-help li { margin: 4px 0; color: var(--muted); }
.qc-th-help a { color: var(--accent-2); }

/* Insights: date range shown next to a finding-group label */
.finding-group-meta { font-weight: 500; font-size: 10.5px; color: var(--muted); text-transform: none; letter-spacing: 0; }

/* Insights: date range hoisted onto the findings column header */
.findings-col-meta { font-weight: 500; font-size: 11px; color: var(--muted); text-transform: none; letter-spacing: 0; margin-left: 6px; }

/* Explanatory note banner inside a stats view (e.g. Monthly Author Stats) */
.view-note {
    background: var(--panel-2); border: 1px dashed var(--line); border-left: 3px solid var(--accent-2);
    border-radius: 8px; padding: 10px 14px; margin: 0 0 18px; font-size: 12.5px;
    line-height: 1.55; color: var(--muted);
}
.view-note b { color: var(--text); font-weight: 600; }

/* ---------------- First Party Data ---------------- */
.fp-table th, .fp-table td { text-align: right; padding: 8px 12px; white-space: nowrap; }
.fp-table th:first-child, .fp-table td.fp-date { text-align: left; position: sticky; left: 0; background: var(--panel); }
.fp-table th.fp-total, .fp-table td.fp-total { background: color-mix(in srgb, var(--accent) 7%, var(--panel)); font-weight: 700; }
.fp-cell { display: inline-flex; flex-direction: column; align-items: flex-end; line-height: 1.15; }
.fp-c { font-weight: 600; }
.fp-d { font-size: 11px; }
.fp-up { color: #2E7D32; }
.fp-down { color: #C0392B; }
.fp-flat { color: var(--muted); }

/* ---------------- Team Chat (floating launcher + docked popover) ---------------- */
.chat-fab {
    position: fixed; right: 22px; bottom: 22px; z-index: 900;
    width: 56px; height: 56px; border-radius: 50%; border: none; cursor: pointer;
    background: var(--accent); color: #fff; font-size: 24px; line-height: 1;
    box-shadow: 0 6px 20px rgba(0,0,0,0.28);
    display: flex; align-items: center; justify-content: center;
    transition: transform .15s ease, box-shadow .15s ease;
}
.chat-fab:hover { transform: translateY(-2px); box-shadow: 0 10px 26px rgba(0,0,0,0.34); }
.chat-fab.open { transform: scale(0.94); }
.chat-fab-ico { pointer-events: none; }
.chat-fab-badge {
    position: absolute; top: -3px; right: -3px; min-width: 20px; height: 20px; padding: 0 5px;
    background: #ef4444; color: #fff; border-radius: 10px; font-size: 11px; font-weight: 700;
    display: flex; align-items: center; justify-content: center; box-shadow: 0 0 0 2px var(--bg);
}

.chat-dock {
    position: fixed; right: 22px; bottom: 90px; z-index: 900;
    width: 370px; max-width: calc(100vw - 32px);
    height: 560px; max-height: calc(100vh - 130px);
    background: var(--panel); border: 1px solid var(--line); border-radius: 16px;
    box-shadow: 0 18px 50px rgba(0,0,0,0.32); overflow: hidden;
    display: flex; flex-direction: column;
}
.chat-dhead { display: flex; align-items: center; gap: 10px; padding: 12px; border-bottom: 1px solid var(--line); }
.chat-back { background: none; border: none; font-size: 22px; line-height: 1; cursor: pointer; color: var(--text); padding: 0 4px; }
.chat-dhead-av { width: 34px; height: 34px; font-size: 12px; }
.chat-dhead-main { flex: 1; min-width: 0; }
.chat-dhead-title { font-weight: 700; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-dhead-sub { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 5px; margin-top: 1px; }
.chat-mute, .chat-clear { background: none; border: none; font-size: 15px; line-height: 1; cursor: pointer; padding: 0 2px; opacity: 0.8; }
.chat-mute:hover, .chat-clear:hover { opacity: 1; }
.chat-close { background: none; border: none; font-size: 22px; line-height: 1; cursor: pointer; color: var(--muted); padding: 0 4px; }
.chat-close:hover { color: var(--text); }

.chat-listpane, .chat-convpane { display: flex; flex-direction: column; min-height: 0; flex: 1; }
/* The class rules above set display, which would otherwise beat the [hidden]
   attribute — force hidden elements to actually hide. */
.chat-dock[hidden], .chat-fab-badge[hidden], .chat-listpane[hidden], .chat-convpane[hidden],
.chat-dhead-av[hidden], .chat-back[hidden], .chat-emojis[hidden], .chat-clear[hidden] { display: none !important; }
.chat-search { margin: 10px 12px 6px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: var(--text); font-size: 13px; }
.chat-search:focus { outline: none; border-color: var(--accent); }
.chat-users { overflow-y: auto; flex: 1; padding: 4px 6px 8px; }
.chat-nousers, .chat-empty { color: var(--muted); font-size: 13px; padding: 18px; text-align: center; }
.chat-sec { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 8px 12px 4px; }
.chat-user, .chat-group { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; cursor: pointer; }
.chat-user:hover, .chat-group:hover { background: color-mix(in srgb, var(--accent) 8%, transparent); }
.chat-gav { background: linear-gradient(135deg, #64748b, #475569) !important; font-size: 18px; }
.chat-sender { display: block; font-size: 11px; font-weight: 700; color: var(--accent); margin-bottom: 2px; }
.chat-row.mine .chat-sender { color: rgba(255,255,255,0.9); }
.chat-avatar {
    position: relative; flex: 0 0 auto; width: 38px; height: 38px; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 13px; font-weight: 700; color: #fff;
    background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 55%, #6d28d9));
}
.chat-user-meta { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.chat-user-name { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-user-sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: #9aa3b2; box-shadow: 0 0 0 2px var(--panel); }
.chat-dot.online { background: #22c55e; }
.chat-avatar .chat-dot { position: absolute; right: -1px; bottom: -1px; }
.chat-unread { margin-left: auto; background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; min-width: 18px; height: 18px; border-radius: 9px; display: inline-flex; align-items: center; justify-content: center; padding: 0 5px; }
.chat-when { margin-left: auto; flex: 0 0 auto; font-size: 11px; color: var(--muted); white-space: nowrap; }

.chat-msgs { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 4px; background: var(--bg); }
.chat-daysep { text-align: center; margin: 8px 0 4px; }
.chat-daysep span { font-size: 11px; color: var(--muted); background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 2px 10px; }
.chat-row { display: flex; }
.chat-row.mine { justify-content: flex-end; }
.chat-bubble {
    max-width: 78%; padding: 7px 11px; border-radius: 13px;
    font-size: 13.5px; line-height: 1.4; word-wrap: break-word; overflow-wrap: anywhere;
    background: var(--panel); border: 1px solid var(--line);
    display: inline-flex; flex-direction: column;
}
.chat-btext { white-space: normal; }
.chat-row.mine .chat-bubble { background: var(--accent); color: #fff; border-color: transparent; }
.chat-time { align-self: flex-end; font-size: 10px; opacity: 0.6; margin-top: 3px; line-height: 1; }
.chat-compose { display: flex; gap: 6px; padding: 10px; border-top: 1px solid var(--line); align-items: flex-end; position: relative; }
.chat-input { flex: 1; min-width: 0; resize: none; border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; font: inherit; font-size: 13.5px; line-height: 1.35; background: var(--panel); color: var(--text); min-height: 38px; max-height: 120px; box-sizing: border-box; overflow-y: auto; }
.chat-input::placeholder { white-space: nowrap; text-overflow: ellipsis; overflow: hidden; }
.chat-input:focus { outline: none; border-color: var(--accent); }
.chat-emoji { flex: 0 0 auto; background: none; border: none; font-size: 19px; line-height: 1; cursor: pointer; padding: 4px 2px; opacity: 0.85; }
.chat-emoji:hover { opacity: 1; }
.chat-emojis { position: absolute; bottom: calc(100% + 6px); left: 10px; right: 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 12px 30px rgba(0,0,0,0.25); padding: 8px; display: flex; flex-wrap: wrap; gap: 2px; max-height: 168px; overflow-y: auto; z-index: 5; }
.chat-emoji-opt { background: none; border: none; font-size: 20px; line-height: 1; cursor: pointer; padding: 4px; border-radius: 8px; }
.chat-emoji-opt:hover { background: color-mix(in srgb, var(--accent) 12%, transparent); }
.chat-send { align-self: stretch; }
.chat-status { font-size: 12px; color: #C0392B; padding: 0 12px; }
.chat-status:not(:empty) { padding-bottom: 8px; }

@media (max-width: 480px) {
    .chat-dock { right: 12px; left: 12px; width: auto; bottom: 84px; height: calc(100vh - 120px); }
    .chat-fab { right: 16px; bottom: 16px; }
}
