/* LAV Pulse theme v3 — spark-software.de look: neutral monochrome chrome,
   Inter typeface, colour reserved for data (orange / indigo / green). */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;450;500;600;700;800&display=swap');
:root {
  color-scheme: light;
  --surface-1: #ffffff;
  --surface-2: #f7f7f6;
  --page: #f2f2f0;
  --page-tint: #ececea;
  --text-primary: #0d0d0c;
  --text-secondary: #4c4b48;
  --text-muted: #8a8985;
  --grid: #e6e5e2;
  --baseline: #c9c8c4;
  --border: rgba(13, 13, 12, 0.09);
  --series-1: #eb6834;   /* spark orange — data series 1 & brand mark */
  --series-2: #6e62e5;   /* indigo — data series 2 */
  --series-3: #12a06e;   /* green — data series 3 */
  --good-text: #0d7a33;
  --bad-text: #c03434;
  --warn-text: #8a5a00;
  --accent: #131312;             /* chrome accent: near-black, spark-style */
  --accent-soft: rgba(13, 13, 12, 0.055);
  --accent-strong: #000000;
  --btn-bg: #131312;             /* primary buttons: black pill, white text */
  --btn-fg: #ffffff;
  --radius: 16px;
  --shadow-card: 0 1px 2px rgba(15, 15, 14, 0.03), 0 12px 30px -22px rgba(15, 15, 14, 0.18);
  --shadow-pop: 0 8px 28px rgba(15, 15, 14, 0.14);
  --topbar-bg: rgba(242, 242, 240, 0.85);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    color-scheme: dark;
    --surface-1: #171716;
    --surface-2: #1e1e1c;
    --page: #0d0d0c;
    --page-tint: #131312;
    --text-primary: #f4f4f2;
    --text-secondary: #b9b8b3;
    --text-muted: #7f7e79;
    --grid: #262624;
    --baseline: #3a3936;
    --border: rgba(255, 255, 255, 0.1);
    --series-1: #ee7440;
    --series-2: #8577f0;
    --series-3: #1fbd82;
    --good-text: #3ecf6b;
    --bad-text: #ef7070;
    --warn-text: #f0b429;
    --accent: #f4f4f2;            /* chrome accent flips to white on dark */
    --accent-soft: rgba(255, 255, 255, 0.08);
    --accent-strong: #ffffff;
    --btn-bg: #f4f4f2;            /* spark dark sections use white buttons */
    --btn-fg: #131312;
    --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.4), 0 14px 34px -18px rgba(0, 0, 0, 0.65);
    --shadow-pop: 0 8px 28px rgba(0, 0, 0, 0.55);
    --topbar-bg: rgba(13, 13, 12, 0.85);
  }
}
/* Forced dark via the in-app theme switch (independent of OS setting) */
:root[data-theme='dark'] {
  color-scheme: dark;
  --surface-1: #171716;
  --surface-2: #1e1e1c;
  --page: #0d0d0c;
  --page-tint: #131312;
  --text-primary: #f4f4f2;
  --text-secondary: #b9b8b3;
  --text-muted: #7f7e79;
  --grid: #262624;
  --baseline: #3a3936;
  --border: rgba(255, 255, 255, 0.1);
  --series-1: #ee7440;
  --series-2: #8577f0;
  --series-3: #1fbd82;
  --good-text: #3ecf6b;
  --bad-text: #ef7070;
  --warn-text: #f0b429;
  --accent: #f4f4f2;
  --accent-soft: rgba(255, 255, 255, 0.08);
  --accent-strong: #ffffff;
  --btn-bg: #f4f4f2;
  --btn-fg: #131312;
  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.4), 0 14px 34px -18px rgba(0, 0, 0, 0.65);
  --shadow-pop: 0 8px 28px rgba(0, 0, 0, 0.55);
  --topbar-bg: rgba(13, 13, 12, 0.85);
}

* { box-sizing: border-box; }
html, body, #root { height: 100%; }
body {
  margin: 0;
  font-family: var(--app-font, 'Inter'), 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  background: linear-gradient(180deg, var(--page-tint) 0%, var(--page) 380px);
  background-attachment: fixed;
  background-color: var(--page);
  color: var(--text-primary);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: 'cv05', 'cv11';
}
h1, h2, h3 { letter-spacing: -0.01em; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }
::selection { background: var(--accent-soft); }

.layout { display: flex; height: 100%; }

/* ── Sidebar ─────────────────────────────── */
.sidebar {
  width: 244px; flex: 0 0 244px;
  border-right: 1px solid var(--border);
  background: var(--surface-1);
  display: flex; flex-direction: column;
  overflow-y: auto;
}
.brand {
  padding: 18px 16px 16px;
  font-weight: 750; font-size: 16px; letter-spacing: 0.2px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
}
.logo-mark {
  width: 34px; height: 34px; border-radius: 10px; flex: 0 0 34px;
  background: var(--btn-bg); color: var(--btn-fg);
  font-size: 13px; font-weight: 800; letter-spacing: 0;
  display: grid; place-items: center;
  box-shadow: 0 4px 14px -6px rgba(15, 15, 14, 0.4);
}
.brand span { color: var(--series-1); }
.nav-collapse {
  margin-left: auto; border: 1px solid var(--border); background: var(--surface-1);
  color: var(--text-muted); border-radius: 8px; width: 26px; height: 26px; flex: 0 0 26px;
  cursor: pointer; font-size: 13px; line-height: 1; padding: 0;
}
.nav-collapse:hover { color: var(--text-primary); border-color: var(--text-muted); }
.nav-ic {
  width: 22px; height: 22px; flex: 0 0 22px; display: inline-grid; place-items: center;
  font-size: 13px; color: var(--text-muted); border-radius: 7px;
}
.nav-item.active .nav-ic { color: var(--text-primary); }
.layout.nav-min .sidebar { width: 72px; flex: 0 0 72px; }
.layout.nav-min .nav-lbl, .layout.nav-min .nav-label { display: none; }
.layout.nav-min .brand { flex-direction: column; gap: 8px; padding: 14px 8px 12px; }
.layout.nav-min .nav-collapse { margin-left: 0; }
.layout.nav-min .nav-item { justify-content: center; padding: 8px 0; border-left: 0; }
.layout.nav-min .nav-section { padding: 10px 8px; }
.brand small { display: block; font-weight: 450; color: var(--text-muted); font-size: 11px; margin-top: 1px; letter-spacing: 0.3px; }
.nav-section { padding: 10px 10px; }
.nav-label {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.9px;
  color: var(--text-muted); padding: 8px 8px 6px; font-weight: 650;
}
.nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 9px; border-radius: 9px; cursor: pointer;
  color: var(--text-secondary); font-size: 13px;
  border-left: 2px solid transparent;
  transition: background 0.12s ease, color 0.12s ease;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.nav-item:hover { background: var(--accent-soft); color: var(--text-primary); }
.nav-item.active {
  background: var(--accent-soft); color: var(--text-primary); font-weight: 650;
  border-left-color: var(--accent);
}
.nav-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--baseline); flex: 0 0 7px; margin: 0 4px; }
.nav-item.active .nav-dot { background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* site initials chips */
.chip {
  width: 22px; height: 22px; border-radius: 7px; flex: 0 0 22px;
  display: grid; place-items: center;
  font-size: 9.5px; font-weight: 750; letter-spacing: 0.3px; color: #fff;
}
.chip.c0 { background: linear-gradient(135deg, #eb6834, #d1531f); }
.chip.c1 { background: linear-gradient(135deg, #6e62e5, #5449c9); }
.chip.c2 { background: linear-gradient(135deg, #12a06e, #0d8258); }

/* small secondary buttons (View all, pagination) */
.mini-btn {
  border: 1px solid var(--border); background: var(--surface-1); color: var(--text-secondary);
  border-radius: 9px; padding: 4px 10px; font-size: 11.5px; font-weight: 600;
  font-family: inherit; cursor: pointer; white-space: nowrap;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}
.mini-btn:hover { background: var(--accent-soft); color: var(--text-primary); border-color: var(--text-muted); }

/* analyst narrative bullets under monitoring cards */
.mon-narr { margin-top: 10px; border-top: 1px solid var(--border); padding-top: 8px; }
.mon-narr-b {
  font-size: 12.5px; line-height: 1.5; color: var(--text-secondary);
  margin: 4px 0; padding-left: 14px; position: relative;
}
.mon-narr-b::before { content: '•'; position: absolute; left: 2px; color: var(--series-1); font-weight: 700; }

/* site heat map (squarified treemap) */
.hm-g .hm-rect { transition: filter 0.12s ease, opacity 0.12s ease; }
.hm-g:hover .hm-rect { filter: brightness(1.1); stroke: var(--text-primary); stroke-width: 1.5; }
.ai-card-out .ai-summary { margin-top: 8px; }

/* media asset thumbnails */
.mthumb {
  width: 30px; height: 30px; border-radius: 6px; object-fit: cover;
  border: 1px solid var(--border); display: inline-block; vertical-align: middle; margin-right: 7px;
}

/* small legend swatches (donut / series legends) */
.chip-dot { width: 10px; height: 10px; border-radius: 3px; flex: 0 0 10px; display: inline-block; }
.chip-dot.c0 { background: var(--series-1); }
.chip-dot.c1 { background: var(--series-2); }
.chip-dot.c2 { background: var(--series-3); }

/* ── Main ────────────────────────────────── */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 13px 22px; border-bottom: 1px solid var(--border);
  background: var(--topbar-bg);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  position: sticky; top: 0; z-index: 10;
  flex-wrap: wrap;
}
.topbar h1 { font-size: 17px; margin: 0; font-weight: 700; letter-spacing: -0.2px; }
.topbar .sub { color: var(--text-muted); font-size: 12px; margin-top: 2px; }
.topbar-right { display: flex; gap: 8px; align-items: center; }

.range-picker {
  display: flex; gap: 2px; background: var(--page); border: 1px solid var(--border);
  border-radius: 10px; padding: 2px;
}
.range-picker button {
  border: 0; background: transparent; color: var(--text-secondary);
  padding: 5px 11px; border-radius: 8px; cursor: pointer; font-size: 12.5px;
  transition: background 0.12s ease, color 0.12s ease;
}
.range-picker button:hover { color: var(--text-primary); }
.range-picker button.active {
  background: var(--surface-2); color: var(--text-primary); font-weight: 650;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.chat-toggle {
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text-primary);
  border-radius: 10px; padding: 6px 13px; cursor: pointer; font-size: 13px; font-weight: 650;
  display: flex; align-items: center; gap: 6px;
  transition: background 0.12s ease, border-color 0.12s ease, transform 0.1s ease;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}
.chat-toggle:hover { background: var(--accent-soft); border-color: var(--accent); }
.chat-toggle:active { transform: scale(0.98); }
.chat-toggle .spark { color: var(--accent); }

.content { flex: 1; overflow-y: auto; padding: 22px; scroll-behavior: smooth; }

/* ── Cards & grid ────────────────────────── */
.grid { display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); }
.grid > * { min-width: 0; } /* cards may shrink; wide innards scroll inside */
.grid.tiles { grid-template-columns: repeat(auto-fit, minmax(172px, 1fr)); }
.grid.two { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); }
@media (max-width: 1100px) { .grid.two { grid-template-columns: minmax(0, 1fr); } }

.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-card);
  position: relative;
}

/* per-graph download button — appears on hover, bottom-right */
.card-dl {
  position: absolute; bottom: 10px; right: 10px; z-index: 3;
  width: 27px; height: 27px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface-1);
  color: var(--text-muted); cursor: pointer; font-size: 13px;
  display: grid; place-items: center;
  opacity: 0; transition: opacity 0.12s ease, color 0.12s ease;
}
.card:hover > .card-dl, .grid.tiles:hover > .card-dl { opacity: 1; }
.card-dl:hover { color: var(--text-primary); border-color: var(--text-muted); }
@media print { .card-dl { display: none; } }
.card h3 {
  margin: 0 0 12px; font-size: 12px; font-weight: 700; color: var(--text-secondary);
  text-transform: uppercase; letter-spacing: 0.7px;
  display: flex; align-items: center; gap: 6px;
}
.card h3::before {
  content: ''; width: 8px; height: 8px; border-radius: 3px; flex: 0 0 8px;
  background: var(--series-1);
}
.card h3 .crumb, .card h3 a.ext { text-transform: none; letter-spacing: 0; }
.card .note { color: var(--text-muted); font-size: 12px; line-height: 1.45; }

/* stat tile */
.tile { position: relative; overflow: hidden; }
.tile::after {
  content: ''; position: absolute; inset: 0 auto auto 0; height: 3px; width: 100%;
  background: linear-gradient(90deg, var(--series-1), transparent 70%);
  opacity: 0.55;
}
.tile .label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.7px; font-weight: 650; }
.tile .value { font-size: 27px; font-weight: 780; margin: 4px 0 4px; letter-spacing: -0.5px; }
.tile .delta { font-size: 12px; font-weight: 650; }
.delta.up { color: var(--good-text); }
.delta.down { color: var(--bad-text); }
.delta.flat { color: var(--text-muted); }

/* horizontal bar rows */
.bar-row {
  display: grid; grid-template-columns: 132px 1fr 62px; gap: 10px; align-items: center;
  padding: 4px 6px; margin: 0 -6px; border-radius: 8px;
}
.bar-row .bar-label { font-size: 12.5px; color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: 13px; border-radius: 4px; position: relative; background: color-mix(in srgb, var(--grid) 40%, transparent); }
.bar-fill {
  height: 100%; border-radius: 4px; min-width: 2px; max-width: 100%;
  background: linear-gradient(90deg, var(--series-1), color-mix(in srgb, var(--series-1) 78%, var(--accent-strong)));
}
.bar-row .bar-value { font-size: 12px; color: var(--text-secondary); text-align: right; font-variant-numeric: tabular-nums; }
.bar-row.clickable { cursor: pointer; transition: background 0.1s ease; }
.bar-row.clickable:hover { background: var(--accent-soft); }
.bar-row.linked { grid-template-columns: 132px 1fr 62px 20px; }
.bar-row.wide { grid-template-columns: minmax(260px, 48%) 1fr 62px; }
a.ext { color: var(--accent); font-size: 12px; font-weight: 650; text-align: center; border-radius: 5px; padding: 0 2px; }
a.ext:hover { background: var(--accent-soft); }
.bar-row a.ext { visibility: hidden; }
.bar-row:hover a.ext { visibility: visible; }
.crumb { color: var(--accent); font-weight: 650; }

/* table */
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th {
  text-align: left; font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.7px;
  color: var(--text-muted); font-weight: 700; padding: 7px 9px; border-bottom: 1px solid var(--grid);
  cursor: pointer; user-select: none; white-space: nowrap;
}
table.data td { padding: 8px 9px; border-bottom: 1px solid color-mix(in srgb, var(--grid) 60%, transparent); font-variant-numeric: tabular-nums; }
table.data tr:last-child td { border-bottom: 0; }
table.data tr.clickable { cursor: pointer; }
table.data tr.clickable:hover td { background: var(--accent-soft); }
table.data tr.clickable td:first-child { border-radius: 8px 0 0 8px; }
table.data tr.clickable td:last-child { border-radius: 0 8px 8px 0; }
table.data .site-name { font-weight: 650; font-variant-numeric: normal; }
table.data .num { text-align: right; }

/* chart */
.chart-wrap { position: relative; }
.chart-wrap svg { display: block; width: 100%; }
.chart-tip {
  position: absolute; pointer-events: none; display: none; z-index: 5;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px;
  padding: 8px 11px; font-size: 12px; box-shadow: var(--shadow-pop);
}
.chart-tip .t-date { color: var(--text-muted); margin-bottom: 3px; }
.chart-tip .t-row { display: flex; align-items: center; gap: 6px; }
.chart-tip .t-swatch { width: 8px; height: 8px; border-radius: 2px; background: var(--series-1); }
.chart-tip b { font-variant-numeric: tabular-nums; }

/* email × release join box */
.email-join {
  background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
  border-radius: 10px; padding: 9px 12px; font-size: 12.5px; margin: 8px 0;
  color: var(--text-primary);
}

/* chat drawer */
.chat-overlay {
  position: fixed; inset: 0; z-index: 60;
  background: color-mix(in srgb, var(--page) 45%, rgba(10, 8, 6, 0.55));
  backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px);
  display: flex; align-items: center; justify-content: center;
  animation: overlay-in 0.16s ease;
}
@keyframes overlay-in { from { opacity: 0; } to { opacity: 1; } }
.chat-modal {
  width: 75vw; height: 76vh; max-width: 1320px; min-width: 320px;
  background: var(--surface-1); border: 1px solid var(--border); border-radius: 18px;
  box-shadow: var(--shadow-pop); display: flex; flex-direction: column; overflow: hidden;
  animation: modal-in 0.18s cubic-bezier(0.2, 0.9, 0.3, 1.1);
}
@keyframes modal-in { from { opacity: 0; transform: translateY(14px) scale(0.985); } to { opacity: 1; transform: none; } }
@media (max-width: 900px) { .chat-modal { width: 96vw; height: 92vh; } }
.chat-head { padding: 14px 18px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.chat-head-actions { display: flex; gap: 8px; align-items: center; }
.chat-clear {
  font-size: 11.5px !important; font-weight: 650; color: var(--text-secondary) !important;
  border: 1px solid var(--border) !important; border-radius: 999px !important; padding: 4px 12px !important;
}
.chat-clear:hover { border-color: var(--accent) !important; color: var(--accent) !important; background: var(--accent-soft) !important; }
.chat-modal .msg { max-width: 82%; font-size: 13.5px; }
.chat-modal .chat-body { padding: 18px 22px; }
.chat-modal .chat-suggest { padding: 0 22px 10px; }
.chat-modal .chat-input { padding: 14px 22px; }
.chat-head b { font-size: 13.5px; }
.chat-head button { border: 0; background: none; color: var(--text-muted); cursor: pointer; font-size: 16px; border-radius: 6px; padding: 2px 6px; }
.chat-head button:hover { background: var(--accent-soft); color: var(--text-primary); }
.chat-body { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 92%; flex-shrink: 0; border-radius: 14px; padding: 9px 13px; font-size: 13px; line-height: 1.5; overflow-x: auto; }
.msg.user { align-self: flex-end; background: var(--btn-bg); color: var(--btn-fg); border-bottom-right-radius: 5px; }
.msg.assistant { align-self: flex-start; background: var(--page); border: 1px solid var(--border); border-bottom-left-radius: 5px; }
.msg.assistant table { border-collapse: collapse; margin: 6px 0; font-size: 12px; }
.msg.assistant th, .msg.assistant td { border: 1px solid var(--grid); padding: 3px 7px; }
.msg.assistant p { margin: 5px 0; }
.msg.assistant h1, .msg.assistant h2, .msg.assistant h3 { font-size: 13.5px; margin: 8px 0 4px; }
.msg.assistant ul, .msg.assistant ol { margin: 4px 0; padding-left: 18px; }
.msg.assistant code { background: var(--accent-soft); border-radius: 4px; padding: 0 4px; }
.chat-suggest { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 14px 8px; }
.chat-suggest button {
  border: 1px solid var(--border); background: var(--page); color: var(--text-secondary);
  border-radius: 999px; padding: 4px 11px; font-size: 11.5px; cursor: pointer;
  transition: background 0.12s ease;
}
.chat-suggest button:hover { background: var(--accent-soft); color: var(--text-primary); }
.chat-input { display: flex; gap: 8px; padding: 12px 14px; border-top: 1px solid var(--border); }
.chat-input textarea {
  flex: 1; resize: none; border: 1px solid var(--border); background: var(--page); color: var(--text-primary);
  border-radius: 11px; padding: 9px 11px; font-family: inherit; font-size: 13px; min-height: 40px; max-height: 110px;
}
.chat-input textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.chat-input button {
  border: 0; background: var(--btn-bg); color: var(--btn-fg);
  border-radius: 11px; padding: 0 15px; font-weight: 650; cursor: pointer;
}
.chat-input button:disabled { opacity: 0.5; cursor: default; }
.typing { color: var(--text-muted); font-size: 12px; padding: 0 2px; flex-shrink: 0; }
/* live AI progress */
.chat-prog {
  flex-shrink: 0; align-self: flex-start; width: min(420px, 92%);
  background: var(--page); border: 1px solid var(--border); border-radius: 14px;
  border-bottom-left-radius: 5px; padding: 11px 14px; font-size: 12.5px;
}
.chat-prog-done { color: var(--text-muted); margin: 2px 0; font-size: 12px; }
.chat-prog-now { color: var(--text-primary); font-weight: 600; margin: 4px 0 8px; display: flex; align-items: center; gap: 8px; }
.chat-prog-pct { margin-left: auto; color: var(--text-muted); font-weight: 650; font-variant-numeric: tabular-nums; }
.chat-prog-track { height: 6px; border-radius: 3px; background: color-mix(in srgb, var(--grid) 55%, transparent); overflow: hidden; }
.chat-prog-fill { height: 100%; border-radius: 3px; background: var(--series-1); transition: width 0.35s ease; }
.chat-spin {
  width: 12px; height: 12px; flex: 0 0 12px; border-radius: 50%;
  border: 2px solid var(--grid); border-top-color: var(--series-1);
  animation: chat-spin 0.8s linear infinite;
}
@keyframes chat-spin { to { transform: rotate(360deg); } }

.msg .dl-link {
  display: inline-block; background: var(--btn-bg); color: var(--btn-fg) !important;
  border-radius: 999px; padding: 6px 14px; font-weight: 650; font-size: 12.5px;
  margin: 4px 0; text-decoration: none;
}
.msg .dl-link:hover { filter: brightness(1.15); }

.demo-badge {
  font-size: 10px; font-weight: 750; letter-spacing: 0.6px; color: var(--series-2);
  border: 1px solid currentColor; border-radius: 6px; padding: 1px 6px; text-transform: uppercase;
}
.loading { color: var(--text-muted); padding: 44px; text-align: center; }
.err { color: var(--bad-text); padding: 20px; }

/* login */
.login-wrap { display: grid; place-items: center; height: 100%; }
.login-wrap .card { width: 310px; }
.login-wrap input {
  width: 100%; padding: 9px; border-radius: 9px; border: 1px solid var(--border);
  background: var(--page); color: inherit; font-family: inherit;
}
.login-wrap button { margin-top: 10px; }

/* insights */
.insights { display: flex; flex-direction: column; gap: 10px; }
.insight { display: flex; gap: 10px; align-items: flex-start; }
.ins-ic {
  flex: 0 0 auto; display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 750; border-radius: 7px; padding: 2px 8px;
  border: 1px solid currentColor; margin-top: 1px;
  background: color-mix(in srgb, currentColor 7%, transparent);
}
.ins-ic.up { color: var(--good-text); }
.ins-ic.down { color: var(--bad-text); }
.ins-ic.watch { color: var(--warn-text); }
.ins-ic.info { color: var(--text-muted); }
.ins-lbl { font-size: 10px; letter-spacing: 0.5px; text-transform: uppercase; }
.ins-fact { font-size: 13.5px; color: var(--text-primary); line-height: 1.4; }
.ins-sugg { font-size: 12.5px; color: var(--text-secondary); margin-top: 2px; line-height: 1.4; }
.ai-summary { max-width: 100%; margin-top: 10px; }

.prov-badge {
  font-size: 10px; font-weight: 750; letter-spacing: 0.5px; text-transform: uppercase;
  color: var(--text-muted); border: 1px solid var(--border); border-radius: 6px; padding: 1px 6px;
  background: var(--page);
}
.rep-select {
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text-primary);
  border-radius: 10px; padding: 7px 11px; font-family: inherit; font-size: 13px;
}
.back-link {
  border: 1px solid var(--border); background: var(--page); color: var(--text-secondary);
  border-radius: 8px; padding: 4px 11px; font-size: 12px; cursor: pointer; margin-bottom: 8px;
  transition: background 0.12s ease;
}
.back-link:hover { background: var(--accent-soft); color: var(--text-primary); }

/* card header row: title + search / metric toggle */
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.card-head h3 { margin: 0; }
.card-search {
  border: 1px solid var(--border); background: var(--page); color: var(--text-primary);
  border-radius: 9px; padding: 5px 11px; font-size: 12px; font-family: inherit; width: 180px;
  transition: border-color 0.12s ease, width 0.15s ease;
}
.card-search:focus { outline: none; border-color: var(--accent); width: 220px; }
.card-search::placeholder { color: var(--text-muted); }
.metric-toggle { display: flex; gap: 2px; background: var(--page); border: 1px solid var(--border); border-radius: 9px; padding: 2px; }
.metric-toggle button {
  border: 0; background: transparent; color: var(--text-secondary);
  padding: 3px 9px; border-radius: 7px; cursor: pointer; font-size: 11.5px;
  transition: background 0.12s ease, color 0.12s ease;
}
.metric-toggle button:hover { color: var(--text-primary); }
.metric-toggle button.active { background: var(--surface-2); color: var(--text-primary); font-weight: 650; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12); }

/* modal (page & campaign dossiers) */
.modal-overlay {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(12, 10, 8, 0.55);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  display: grid; place-items: center; padding: 28px;
  animation: lp-fade 0.14s ease;
}
.modal {
  background: var(--surface-1); border: 1px solid var(--border); border-radius: 18px;
  box-shadow: var(--shadow-pop);
  width: min(880px, 100%); max-height: min(84vh, 900px);
  display: flex; flex-direction: column; position: relative;
  animation: lp-rise 0.16s ease;
}
.modal-close {
  position: absolute; top: 12px; right: 12px; z-index: 2;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text-muted);
  border-radius: 9px; width: 30px; height: 30px; cursor: pointer; font-size: 14px;
}
.modal-close:hover { background: var(--accent-soft); color: var(--text-primary); }
.modal-body { padding: 20px 22px; overflow-y: auto; }
@keyframes lp-fade { from { opacity: 0; } }
@keyframes lp-rise { from { opacity: 0; transform: translateY(10px) scale(0.99); } }

/* PR snapshot strip */
.snap-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(205px, 1fr)); gap: 10px; }
.snap {
  display: flex; gap: 11px; align-items: center;
  background: var(--page); border: 1px solid var(--border); border-radius: 12px; padding: 11px 13px;
  min-width: 0; cursor: pointer;
  transition: border-color 0.12s ease, transform 0.12s ease, background 0.12s ease;
}
.snap:hover { border-color: var(--accent); background: var(--accent-soft); transform: translateY(-1px); }
.snap-ic { font-size: 19px; flex: 0 0 auto; }
.snap-v { font-size: 15px; font-weight: 750; letter-spacing: -0.2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.snap-l {
  font-size: 10.5px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.4px;
  font-weight: 650; margin-top: 2px; line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

/* click-through highlight pulse */
@keyframes lp-flash {
  0% { box-shadow: 0 0 0 0 rgba(235, 104, 52, 0.55); }
  100% { box-shadow: 0 0 0 14px rgba(235, 104, 52, 0); }
}
.card-flash { animation: lp-flash 0.9s ease 2; border-color: var(--accent) !important; }

/* dossier facts row */
.facts-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.fact-pill {
  background: var(--page); border: 1px solid var(--border); border-radius: 999px;
  padding: 4px 12px; font-size: 12px; color: var(--text-secondary);
}
.fact-pill b { color: var(--text-primary); }

/* GA4 search results */
.ga4-results { border-top: 1px dashed var(--grid); margin-top: 8px; padding-top: 8px; }
.ga4-result {
  display: flex; justify-content: space-between; gap: 10px; align-items: center;
  padding: 6px 8px; border-radius: 8px; cursor: pointer; font-size: 12.5px;
}
.ga4-result:hover { background: var(--accent-soft); }
.ga4-result .num { color: var(--text-muted); font-variant-numeric: tabular-nums; }

/* auth & admin forms */
.auth-form { display: flex; flex-direction: column; gap: 9px; }
.auth-in {
  border: 1px solid var(--border); background: var(--page); color: var(--text-primary);
  border-radius: 10px; padding: 10px 12px; font-family: inherit; font-size: 13.5px;
}
.auth-in:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.btn-primary {
  border: 0; background: var(--btn-bg); color: var(--btn-fg);
  border-radius: 999px; padding: 10px 18px; font-weight: 650; font-size: 13.5px; cursor: pointer;
  transition: transform 0.1s ease, filter 0.12s ease;
}
.btn-primary:hover { filter: brightness(1.08); }
.btn-primary:active { transform: scale(0.98); }
.status-badge {
  font-size: 10.5px; font-weight: 750; letter-spacing: 0.4px; text-transform: uppercase;
  border-radius: 6px; padding: 2px 8px; border: 1px solid currentColor;
}
.st-active { color: var(--good-text); }
.st-pending { color: var(--warn-text); }
.st-disabled { color: var(--text-muted); }
.row-pending td { background: color-mix(in srgb, var(--warn-text) 6%, transparent); }

/* scrollbars */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: color-mix(in srgb, var(--baseline) 55%, transparent); border-radius: 6px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: var(--baseline); border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

/* Market multi-select popover (myNewspress monitoring filter) */
.mkt-pop {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 60;
  min-width: 240px; max-width: 320px;
  max-height: min(70vh, 480px); overflow: auto;
  background: var(--surface, var(--page)); border: 1px solid var(--border);
  border-radius: 12px; padding: 10px 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
  text-align: left; font-size: 13px;
}
/* Pops anchored to a LEFT-side button open rightward, never off-screen. */
.mkt-pop.left { left: 0; right: auto; }
/* Not enough room below → the pop opens UPWARD from the button. */
.mkt-pop.up { top: auto; bottom: calc(100% + 6px); }
.mkt-opt {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 4px; border-radius: 8px; cursor: pointer; user-select: none;
  color: var(--text-primary); white-space: nowrap;
}
.mkt-opt:hover { background: color-mix(in srgb, var(--grid) 40%, transparent); }
.mkt-opt input { accent-color: var(--series-1); cursor: pointer; }
.mkt-opt .note { margin-left: auto; color: var(--text-muted); font-size: 11.5px; padding-left: 10px; }

/* Donut legends (sentiment / media type) — dot + name left, values right */
.sent-leg {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 2px; border-radius: 8px; cursor: pointer;
  font-size: 15px; white-space: nowrap;
}
.sent-leg:hover { background: color-mix(in srgb, var(--grid) 40%, transparent); }
.sent-leg .sent-name { text-transform: capitalize; color: var(--text-primary); }
.sent-leg .sent-val {
  margin-left: auto; font-weight: 650; color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

/* Emphasised bars — key charts like Share of Voice */
.bar-row.big { font-size: 15px; }
.bar-row.big .bar-label { font-weight: 650; font-size: 14.5px; }
.bar-row.big .bar-track { height: 17px; }
.bar-row.big .bar-value { font-size: 15.5px; font-weight: 750; }

/* Section divider between web analytics and the media-monitoring section */
.mon-divider {
  display: flex; align-items: center; gap: 16px;
  margin: 40px 0 8px; user-select: none;
}
.mon-divider > span {
  display: flex; align-items: baseline; gap: 12px;
  font-size: 21px; font-weight: 800; letter-spacing: 0.3px;
  color: var(--text-primary); white-space: nowrap;
}
.mon-divider .mon-divider-sub {
  font-size: 12.5px; font-weight: 600; letter-spacing: 1.6px;
  text-transform: uppercase; color: var(--text-muted);
}
.mon-divider::before, .mon-divider::after {
  content: ''; flex: 1; height: 3px; border-radius: 2px;
}
.mon-divider::before { background: linear-gradient(90deg, transparent, var(--series-2)); }
.mon-divider::after { background: linear-gradient(90deg, var(--series-2), transparent); }

/* ══ Mobile responsiveness ═══════════════════════════════════════════ */
.nav-burger { display: none; }
.nav-scrim { display: none; }

@media (max-width: 860px) {
  /* Sidebar becomes an off-canvas drawer with a scrim */
  .sidebar {
    position: fixed; top: 0; bottom: 0; left: 0; z-index: 80;
    width: min(280px, 84vw); flex: 0 0 auto;
    transform: translateX(-105%); transition: transform 0.22s ease;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.35);
    padding-bottom: env(safe-area-inset-bottom, 0);
  }
  .layout.nav-open .sidebar { transform: translateX(0); }
  .layout.nav-open .nav-scrim {
    display: block; position: fixed; inset: 0; z-index: 75;
    background: rgba(10, 8, 6, 0.45);
    -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
  }
  /* the desktop collapse mode is meaningless in a drawer */
  .layout.nav-min .sidebar { width: min(280px, 84vw); }
  .layout.nav-min .nav-lbl, .layout.nav-min .nav-label { display: block; }
  .layout.nav-min .brand { flex-direction: row; gap: 10px; padding: 18px 16px 16px; }
  .layout.nav-min .nav-item { justify-content: flex-start; padding: 11px 9px; border-left: 2px solid transparent; }
  .nav-collapse { display: none; }
  .nav-burger {
    display: inline-grid; place-items: center;
    width: 40px; height: 40px; flex: 0 0 40px;
    border: 1px solid var(--border); background: var(--surface-1);
    color: var(--text-primary); border-radius: 10px;
    font-size: 17px; cursor: pointer; padding: 0;
  }
  .nav-item { padding: 11px 9px; font-size: 14px; } /* touch targets */

  .topbar { padding: 10px 12px; gap: 8px; padding-top: max(10px, env(safe-area-inset-top, 0)); }
  .topbar h1 { font-size: 15.5px; }
  .topbar .sub { font-size: 11px; max-width: 58vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .topbar-right { width: 100%; flex-wrap: wrap; row-gap: 6px; }
  .range-picker { max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .range-picker::-webkit-scrollbar { display: none; }
  .range-picker button { padding: 7px 10px; }
  .chat-toggle { padding: 7px 11px; min-height: 38px; }
  .mini-btn { padding: 7px 12px; font-size: 12px; min-height: 34px; }

  .content { padding: 12px; padding-bottom: max(14px, env(safe-area-inset-bottom, 0)); }
  .card { padding: 14px; }
  .grid.two { grid-template-columns: minmax(0, 1fr); }
  .grid.tiles { grid-template-columns: repeat(auto-fit, minmax(136px, 1fr)); }

  .bar-row { grid-template-columns: 98px 1fr 52px; gap: 8px; }
  .bar-row.wide { grid-template-columns: minmax(104px, 36%) 1fr 52px; }
  .bar-row.linked { grid-template-columns: 98px 1fr 52px 20px; }
  .bar-row.big { font-size: 13.5px; }
  .bar-row.big .bar-label { font-size: 13px; }
  .bar-row.big .bar-value { font-size: 13.5px; }
  .bar-row a.ext { visibility: visible; } /* no hover on touch */
  .card-dl { opacity: 1 !important; } /* keep per-card download reachable */
  .sent-leg { font-size: 13.5px; white-space: normal; }

  table.data { font-size: 12px; display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table.data th, table.data td { padding: 7px 7px; }

  .modal-overlay { padding: 8px; align-items: end; }
  .modal { width: 100%; max-height: 94vh; border-radius: 16px; }
  .modal-body { padding: 14px 14px max(14px, env(safe-area-inset-bottom, 0)); }

  /* market picker becomes a centred bottom sheet — anchored popovers run
     off-screen next to edge buttons on phones */
  .mkt-pop {
    position: fixed; left: 12px; right: 12px; top: auto; bottom: 14px;
    min-width: 0; max-width: none; max-height: 62vh; overflow: auto;
    z-index: 90; box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.3);
    padding-bottom: max(10px, env(safe-area-inset-bottom, 0));
  }
  .mon-divider > span { font-size: 17px; gap: 8px; flex-wrap: wrap; }
  .mon-divider .mon-divider-sub { letter-spacing: 1px; }
  .card-search, .list-q { width: 96px !important; }
}

@media (max-width: 480px) {
  .topbar .sub { display: none; }
  .grid.tiles { grid-template-columns: 1fr 1fr; }
  .bar-row { grid-template-columns: 84px 1fr 48px; }
  .bar-row.wide { grid-template-columns: minmax(90px, 34%) 1fr 48px; }
  .fact-pill { font-size: 11.5px; }
}

/* Wide innards (SVG charts, KPI snap rows, tables) pan inside their card on
   small screens instead of stretching the page. */
@media (max-width: 860px) {
  .chart-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .snap-row { grid-template-columns: 1fr 1fr; }
  .card > svg, .chart-wrap > svg { max-width: 100%; height: auto; }
}
@media (max-width: 480px) {
  .snap-row { grid-template-columns: 1fr; }
}

/* ══ Smart loading skeleton ═══════════════════════════════════════════ */
.load-smart { display: flex; flex-direction: column; gap: 14px; }
.load-status {
  display: flex; align-items: center; gap: 10px;
  font-size: 13.5px; font-weight: 650; color: var(--text-secondary);
  padding: 2px 2px 4px;
}
.load-status-txt { animation: load-txt-in 0.4s ease; }
@keyframes load-txt-in { from { opacity: 0; transform: translateY(3px); } }
.skel-wrap { pointer-events: none; }
.skel-line {
  height: 12px; border-radius: 6px;
  background: linear-gradient(90deg, color-mix(in srgb, var(--grid) 55%, transparent) 25%, color-mix(in srgb, var(--grid) 30%, transparent) 40%, color-mix(in srgb, var(--grid) 55%, transparent) 55%);
  background-size: 300% 100%;
  animation: skel-shimmer 1.4s ease-in-out infinite;
  margin: 7px 0;
}
.skel-line.skel-big { height: 26px; border-radius: 8px; }
.skel-row { display: grid; grid-template-columns: 110px 1fr; gap: 10px; align-items: center; padding: 5px 0; }
.skel-row .skel-line { margin: 0; }
.skel-track { height: 13px; border-radius: 4px; background: color-mix(in srgb, var(--grid) 30%, transparent); overflow: hidden; }
.skel-fill {
  height: 100%; border-radius: 4px;
  background: linear-gradient(90deg, color-mix(in srgb, var(--grid) 65%, transparent) 25%, color-mix(in srgb, var(--grid) 40%, transparent) 40%, color-mix(in srgb, var(--grid) 65%, transparent) 55%);
  background-size: 300% 100%;
  animation: skel-shimmer 1.4s ease-in-out infinite;
}
.skel-chart { display: flex; align-items: flex-end; gap: 6px; height: 150px; }
.skel-bar {
  flex: 1; border-radius: 4px 4px 0 0;
  background: color-mix(in srgb, var(--grid) 50%, transparent);
  animation: skel-pulse 1.6s ease-in-out infinite;
}
@keyframes skel-shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }
@keyframes skel-pulse { 0%, 100% { opacity: 0.55; } 50% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .skel-line, .skel-fill, .skel-bar { animation: none; }
}
