/* Cinéalytics. Brand from the Cinépolis Q2 2026 strategy deck: deep blue radial
   field, white C mark, gold rules. Cards stay white for legibility. */
:root {
  color-scheme: light;
  /* Brand */
  --navy: #202e57;
  --gold: #c9a84c;
  --gold-deep: #8b6914;
  --field-center: #2f7bdf;
  --field-1: #2263bf;
  --field-2: #14479b;
  --field-3: #09327f;
  --field-edge: #002169;
  --on-field: #ffffff;
  --on-field-2: rgba(255, 255, 255, 0.78);
  --on-field-3: rgba(255, 255, 255, 0.6);
  --on-field-line: rgba(255, 255, 255, 0.22);
  /* Cards (unchanged) */
  --surface-1: #fcfcfb;
  --surface-2: #f0efec;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --series-1: #2a78d6;
  --series-1-wash: rgba(42, 120, 214, 0.10);
  --good-text: #006300;
  --bad-text: #b42323;
  --status-good: #0ca30c;
  --status-warning: #fab219;
  --status-neutral: #898781;
  --focus: #c9a84c;
  --radius: 10px;
  --font: "Helvetica Neue", Helvetica, system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  min-height: 100vh;
  color: var(--on-field);
  font: 14px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  background-color: var(--field-edge);
  background-image: radial-gradient(ellipse 80% 70% at 50% 42%,
    var(--field-center) 0%, var(--field-1) 20%, var(--field-2) 42%, var(--field-3) 64%, var(--field-edge) 86%);
  background-attachment: fixed;
}
[hidden] { display: none !important; }
code { font-size: 0.92em; }
.muted { color: var(--text-muted); }
.small { font-size: 12px; }

/* ─── Brand lockup: C mark | gold rule | Cinéalytics ─────────────────────── */
.lockup { display: flex; align-items: center; gap: 12px; }
.lockup-mark { height: 30px; width: auto; display: block; }
.gold-rule { width: 2px; align-self: stretch; min-height: 28px; background: var(--gold); border-radius: 1px; }
.lockup-text { display: grid; gap: 1px; }
.product-name { margin: 0; font-size: 19px; font-weight: 700; letter-spacing: -0.01em; color: var(--on-field); line-height: 1.1; }
.product-name span { color: var(--gold); }
.product-tag { margin: 0; font-size: 12px; color: var(--on-field-2); }
.lockup-lg { gap: 20px; }
.lockup-lg .lockup-mark { height: 72px; }
.lockup-lg .gold-rule { width: 3px; min-height: 64px; }
.lockup-lg .product-name { font-size: 46px; }
.lockup-lg .product-tag { font-size: 15px; margin-top: 4px; }

/* Faint wordmark in the corner, like the deck slides */
.corner-wordmark { position: fixed; right: 24px; bottom: 18px; width: 120px; opacity: 0.28; pointer-events: none; z-index: 0; }

/* ─── Buttons & inputs ───────────────────────────────────────────────────── */
.btn { appearance: none; border: 1px solid var(--border); background: var(--surface-1); color: var(--text-primary); font: inherit; font-size: 13px; padding: 7px 12px; border-radius: 8px; cursor: pointer; text-decoration: none; white-space: nowrap; display: inline-flex; align-items: center; }
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: 0.55; cursor: progress; }
.btn-primary { background: var(--navy); border-color: var(--navy); color: #fff; font-weight: 600; }
.btn-primary:hover { background: #2b3d72; }
.btn-ghost { background: transparent; }
.btn-on-dark { background: rgba(255, 255, 255, 0.08); border-color: rgba(255, 255, 255, 0.32); color: var(--on-field); }
.btn-on-dark:hover { background: rgba(255, 255, 255, 0.16); }
.btn-group { display: flex; gap: 6px; }
input, select { font: inherit; font-size: 13px; color: var(--text-primary); background: var(--surface-1); border: 1px solid transparent; border-radius: 8px; padding: 7px 10px; min-height: 34px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ─── Login ──────────────────────────────────────────────────────────────── */
.login { min-height: 100vh; display: grid; place-items: center; padding: 32px 16px; position: relative; z-index: 1; }
.login-inner { width: min(440px, 100%); display: grid; gap: 28px; justify-items: center; }
.login-card { width: 100%; background: var(--surface-1); color: var(--text-primary); border-radius: 14px; padding: 26px 28px 22px;
  display: grid; gap: 10px; border-top: 3px solid var(--gold); box-shadow: 0 18px 50px rgba(0, 12, 50, 0.45); }
.login-card label { font-weight: 600; font-size: 13px; color: var(--text-secondary); }
.login-card input { border: 1px solid var(--border); font-size: 15px; padding: 10px 12px; }
.login-card .btn { justify-content: center; padding: 11px; margin-top: 6px; font-size: 14px; }
.login-error { color: var(--bad-text); min-height: 1.4em; margin: 0; font-size: 13px; }
.login-foot { margin: 0; font-size: 12px; letter-spacing: 0.04em; color: var(--on-field-3); }

/* ─── Top bar ────────────────────────────────────────────────────────────── */
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 28px; padding: 12px 24px;
  background: rgba(0, 24, 84, 0.72); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--on-field-line); }
.tabs { display: flex; gap: 4px; }
.tab { appearance: none; border: 0; background: transparent; color: var(--on-field-2); font: inherit; font-weight: 600;
  padding: 8px 12px 9px; border-radius: 8px 8px 0 0; cursor: pointer; box-shadow: inset 0 -2px 0 transparent; }
.tab:hover { color: var(--on-field); background: rgba(255, 255, 255, 0.07); }
.tab.is-active { color: var(--on-field); box-shadow: inset 0 -2px 0 var(--gold); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
#sync-status { color: var(--on-field-2); }

/* ─── Page (on the blue field) ───────────────────────────────────────────── */
#app { position: relative; z-index: 1; }
.page { max-width: 1320px; margin: 0 auto; padding: 22px 24px 64px; }
.filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; }
.field { display: grid; gap: 4px; }
.field > span { font-size: 12px; color: var(--on-field-2); font-weight: 600; }
.field-grow { flex: 1 1 200px; }
.field-grow input { width: 100%; }
.range-label { margin: 10px 0 20px; color: var(--on-field-2) !important; }
.section-title { display: flex; align-items: center; gap: 10px; font-size: 16px; font-weight: 650; margin: 32px 0 12px; color: var(--on-field); }
.section-title::before { content: ""; width: 3px; height: 18px; background: var(--gold); border-radius: 2px; }
.section-title.first { margin-top: 4px; }
.footnote { margin-top: 28px; max-width: 900px; color: var(--on-field-3) !important; }
.footnote code, .footnote em { color: var(--on-field-2); }

/* ─── Cards (white, as before) ───────────────────────────────────────────── */
.card, .kpi, .trend-card { color: var(--text-primary); box-shadow: 0 1px 2px rgba(0, 12, 50, 0.18); }
.card { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin: 0; }
.card figcaption { font-weight: 600; font-size: 13px; margin-bottom: 10px; }

/* KPI tiles */
.kpis { display: grid; grid-template-columns: repeat(var(--cols, 5), minmax(0, 1fr)); gap: 12px; }
.kpis + .trend-grid, .kpis + .section-title + .trend-grid { margin-top: 12px; }
.trend-grid + .card, .table-toggle + .card, .trend-grid + .table-toggle + .card { margin-top: 12px; }
.kpi { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; min-height: 96px; }
.kpi-label { color: var(--text-secondary); font-size: 12px; font-weight: 600; }
.kpi-value { font-size: 24px; font-weight: 650; margin: 4px 0 2px; letter-spacing: -0.01em; }
.kpi.is-hero .kpi-value { font-size: 30px; }
.kpi-delta { font-size: 12px; color: var(--text-secondary); }
.kpi-delta .up-good, .kpi-delta .down-good { color: var(--good-text); font-weight: 600; }
.kpi-delta .up-bad, .kpi-delta .down-bad { color: var(--bad-text); font-weight: 600; }
.kpi-delta .flat { color: var(--text-secondary); font-weight: 600; }

/* Trend small multiples */
.trend-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.trend-card { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px 10px; }
.trend-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.trend-title { font-weight: 600; font-size: 13px; }
.trend-total { color: var(--text-secondary); font-size: 12px; }
.trend-canvas { position: relative; height: 150px; margin-top: 6px; }
.table-toggle { margin-top: 12px; }
.table-toggle summary { cursor: pointer; color: var(--on-field-2); font-size: 13px; }
.table-toggle summary:hover { color: var(--on-field); }
.table-toggle .table-wrap { margin-top: 10px; color: var(--text-primary); background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius); max-height: 420px; }

/* Top campaigns */
.two-col { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.bar-wrap { position: relative; height: 320px; }

/* Tables */
.table-card { padding: 0; overflow: hidden; }
.table-card .table-wrap { max-height: 560px; }
.table-wrap { overflow: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th, .data-table td { padding: 9px 10px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--grid); }
.data-table th:first-child, .data-table td:first-child { text-align: left; }
.data-table th { position: sticky; top: 0; background: var(--surface-1); color: var(--text-secondary); font-size: 12px; font-weight: 600; z-index: 1; }
.data-table td { font-variant-numeric: tabular-nums; }
.data-table tbody tr:hover td { background: var(--surface-2); }
.data-table tr.total-row td { font-weight: 650; background: var(--surface-2); }
.sortable th { cursor: pointer; user-select: none; }
.sortable th[aria-sort="descending"]::after { content: " ↓"; }
.sortable th[aria-sort="ascending"]::after { content: " ↑"; }
.campaign-name { max-width: 280px; overflow: hidden; text-overflow: ellipsis; display: inline-block; vertical-align: bottom; }
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-secondary); }
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--status-neutral); }
.status.s-active::before, .status.s-enabled::before { background: var(--status-good); }
.status.s-paused::before { background: var(--status-warning); }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--text-primary); color: var(--surface-1); padding: 10px 16px; border-radius: 8px; font-size: 13px; z-index: 50; }
.loading .kpis, .loading .trend-grid, .loading .two-col, .loading .table-card { opacity: 0.6; transition: opacity 0.15s; }

@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(min(var(--cols, 5), 4), minmax(0, 1fr)); }
  .trend-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .topbar { flex-wrap: wrap; gap: 10px; padding: 10px 16px; }
  .topbar-right { margin-left: 0; width: 100%; justify-content: space-between; }
  .page { padding: 16px 16px 48px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .trend-grid, .two-col { grid-template-columns: 1fr; }
  .field, .field select, .field input { width: 100%; }
  .filters .field { flex: 1 1 100%; }
  .btn-group { flex-wrap: wrap; }
  .kpi-value { font-size: 20px; }
  .lockup-lg { gap: 14px; }
  .lockup-lg .lockup-mark { height: 52px; }
  .lockup-lg .gold-rule { min-height: 48px; }
  .lockup-lg .product-name { font-size: 34px; }
  .lockup-lg .product-tag { font-size: 13px; }
  .corner-wordmark { width: 90px; right: 16px; bottom: 12px; }
}
