/* ============================================================================
   OTPP Watch — self-contained OECTA design system
   Navy #204164 / Amber #f39c12 · Manrope/Newsreader + Inter · no-line rule
   Mobile breakpoint 768px. Mirrors the shared oecta-tokens/components language.
   ============================================================================ */

:root {
  /* Brand */
  --navy:            #204164;
  --navy-deep:       #022b4d;
  --navy-soft:       #2c557f;
  --amber:           #f39c12;
  --amber-deep:      #d6860a;

  /* Surfaces — tonal, no hard lines */
  --surface:         #f4f6f9;   /* app background */
  --surface-2:       #eef2f7;   /* recessed sections */
  --card:            #ffffff;   /* cards */
  --card-tint:       #f8fafc;

  /* Text */
  --ink:             #16202c;
  --ink-2:           #475569;
  --ink-3:           #718295;

  /* Semantic */
  --ok:              #16a34a;
  --warn:            #d97706;
  --danger:          #c0392b;
  --info:            #2563eb;

  /* Theme accents (value lenses) */
  --t-climate:       #1f8a52;   /* green */
  --t-weapons:       #b3261e;   /* red */
  --t-catholic:      #7c3aed;   /* violet */
  --t-labour:        #c2710c;   /* amber-brown */
  --t-rights:        #0e7490;   /* teal */
  --t-other:         #64748b;

  /* Shadows — navy-tinted, never pure black */
  --sh-1: 0 1px 2px rgba(32,65,100,.06), 0 1px 3px rgba(32,65,100,.08);
  --sh-2: 0 4px 12px rgba(32,65,100,.10), 0 2px 4px rgba(32,65,100,.06);
  --sh-3: 0 12px 32px rgba(32,65,100,.14), 0 4px 10px rgba(32,65,100,.08);

  --radius:   14px;
  --radius-s: 10px;
  --radius-xs: 7px;

  --font-display: 'Manrope', system-ui, sans-serif;
  --font-edit:    'Newsreader', Georgia, serif;
  --font-ui:      'Inter', system-ui, sans-serif;
  --font-mono:    'Roboto Mono', ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-ui);
  background: var(--surface);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

/* View routing */
.view { display: none; }
.view.active { display: block; }

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100vh;
  display: grid; place-items: center;
  padding: 24px;
  background:
    radial-gradient(1200px 600px at 50% -10%, rgba(32,65,100,.12), transparent 60%),
    var(--surface);
}
.login-card {
  width: 100%; max-width: 420px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--sh-3);
  padding: 36px 32px;
  text-align: center;
}
.login-seal { width: 64px; height: 64px; margin: 0 auto 14px; }
.login-seal img { width: 100%; height: 100%; object-fit: contain; }
.login-title { font-family: var(--font-display); font-weight: 800; font-size: 1.5rem; color: var(--navy-deep); margin: 0 0 4px; }
.login-sub { color: var(--ink-2); font-size: .9rem; margin: 0 0 24px; }
.login-foot { margin-top: 22px; font-size: .75rem; color: var(--ink-3); }

.btn-google {
  width: 100%; display: flex; align-items: center; justify-content: center; gap: 10px;
  background: #fff; color: #3c4043; font-weight: 600; font-size: .95rem;
  border: none; box-shadow: inset 0 0 0 1.5px #dadce0;
  border-radius: var(--radius-s); padding: 12px; cursor: pointer; transition: box-shadow .15s, transform .05s;
}
.btn-google:hover { box-shadow: inset 0 0 0 1.5px #b9bfc7, var(--sh-1); }
.btn-google:active { transform: translateY(1px); }
.btn-google img { width: 18px; height: 18px; }

.divider { display: flex; align-items: center; gap: 12px; color: var(--ink-3); font-size: .78rem; margin: 18px 0; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: linear-gradient(90deg, transparent, #d6dee8, transparent); }

.field { text-align: left; margin-bottom: 12px; }
.field label { display: block; font-size: .78rem; font-weight: 600; color: var(--ink-2); margin-bottom: 5px; }
.field input {
  width: 100%; padding: 11px 12px; font-size: .95rem; font-family: var(--font-ui);
  background: var(--card-tint); border: none; box-shadow: inset 0 0 0 1.5px #e2e8f0;
  border-radius: var(--radius-s); color: var(--ink);
}
.field input:focus { outline: none; box-shadow: inset 0 0 0 2px var(--navy); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--font-ui); font-weight: 700; font-size: .9rem;
  border: none; border-radius: var(--radius-s); padding: 11px 18px; cursor: pointer;
  transition: transform .05s, box-shadow .15s, background .15s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: linear-gradient(180deg, var(--navy-soft), var(--navy)); color: #fff; box-shadow: var(--sh-1); }
.btn-primary:hover { box-shadow: var(--sh-2); }
.btn-accent { background: linear-gradient(180deg, #f7ad34, var(--amber)); color: #4a2c00; box-shadow: var(--sh-1); }
.btn-ghost { background: transparent; color: var(--navy); box-shadow: inset 0 0 0 1.5px #cdd8e4; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

.error-msg { color: var(--danger); font-size: .82rem; min-height: 1em; margin: 4px 0; }

/* ---------- App shell ---------- */
.app-header {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 14px;
  padding: 12px 22px;
  background: linear-gradient(180deg, var(--navy-deep), var(--navy));
  color: #fff; box-shadow: var(--sh-2);
}
.app-header .seal { width: 36px; height: 36px; flex: 0 0 auto; }
.app-header .seal img { width: 100%; height: 100%; object-fit: contain; }
.app-header .titles { flex: 1; min-width: 0; }
.app-header .name { font-family: var(--font-display); font-weight: 800; font-size: 1.05rem; line-height: 1.1; }
.app-header .sub { font-size: .72rem; opacity: .8; }
.app-header .who { font-size: .78rem; opacity: .85; }
.app-header .signout { background: rgba(255,255,255,.12); color: #fff; border: none; border-radius: 999px; padding: 7px 14px; font-size: .8rem; font-weight: 600; cursor: pointer; }
.app-header .signout:hover { background: rgba(255,255,255,.2); }

.main { max-width: 1180px; margin: 0 auto; padding: 22px; }

/* ---------- Coverage banner (P0 — honesty) ---------- */
.coverage-banner {
  display: flex; gap: 14px; align-items: flex-start;
  background: linear-gradient(180deg, #fff8ec, #fdf1d8);
  box-shadow: inset 0 0 0 1.5px #f3d79a, var(--sh-1);
  border-radius: var(--radius); padding: 14px 18px; margin-bottom: 20px;
}
.coverage-banner .ico { font-size: 1.3rem; line-height: 1; flex: 0 0 auto; }
.coverage-banner .body { font-size: .86rem; color: #6b4e12; }
.coverage-banner .body strong { color: #4a3608; }
.coverage-banner .pct { font-family: var(--font-display); font-weight: 800; color: var(--amber-deep); }

/* ---------- Stat row ---------- */
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 22px; }
.stat {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--sh-1);
  padding: 16px 18px;
}
.stat .v { font-family: var(--font-display); font-weight: 800; font-size: 1.5rem; color: var(--navy-deep); line-height: 1.1; }
.stat .l { font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-3); margin-top: 4px; font-weight: 600; }

/* ---------- Section + cards ---------- */
.section-title { font-family: var(--font-display); font-weight: 800; font-size: 1.05rem; color: var(--navy-deep); margin: 26px 0 12px; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--sh-1); padding: 18px; margin-bottom: 16px; }
.muted { color: var(--ink-3); }
.small { font-size: .8rem; }

/* ---------- Filter chips ---------- */
.lens-bar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.lens-pill {
  font-size: .8rem; font-weight: 600; padding: 6px 13px; border-radius: 999px; cursor: pointer;
  background: var(--card); color: var(--ink-2); box-shadow: inset 0 0 0 1.5px #dde5ee; transition: all .12s;
}
.lens-pill[aria-pressed="true"] { background: var(--navy); color: #fff; box-shadow: var(--sh-1); }

/* ---------- Holdings table ---------- */
.table-wrap { background: var(--card); border-radius: var(--radius); box-shadow: var(--sh-1); overflow: hidden; }
table.holdings { width: 100%; border-collapse: collapse; font-size: .86rem; }
table.holdings thead th {
  background: var(--surface-2); color: var(--ink-2); text-align: left; font-weight: 700;
  font-size: .72rem; text-transform: uppercase; letter-spacing: .03em; padding: 11px 14px;
}
table.holdings tbody td { padding: 11px 14px; background: var(--card); }
table.holdings tbody tr { cursor: pointer; transition: background .1s; }
table.holdings tbody tr:nth-child(even) td { background: var(--card-tint); }
table.holdings tbody tr:hover td { background: #eef4fb; }
table.holdings .name { font-weight: 600; color: var(--ink); }
table.holdings .cusip { font-family: var(--font-mono); font-size: .76rem; color: var(--ink-3); }
table.holdings .val { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.flag-cell { display: flex; flex-wrap: wrap; gap: 4px; }

/* ---------- Flag chips (theme-coded) ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: .7rem; font-weight: 700; padding: 3px 9px; border-radius: 999px;
  color: #fff; white-space: nowrap;
}
.chip.climate  { background: var(--t-climate); }
.chip.weapons  { background: var(--t-weapons); }
.chip.catholic { background: var(--t-catholic); }
.chip.labour   { background: var(--t-labour); }
.chip.rights   { background: var(--t-rights); }
.chip.other    { background: var(--t-other); }
.chip.clean    { background: #e7f3ec; color: var(--ok); box-shadow: inset 0 0 0 1.5px #b6e0c4; }
.chip .conf { font-weight: 500; opacity: .85; font-size: .64rem; }

.conf-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; vertical-align: middle; margin-right: 4px; }
.conf-dot.high { background: var(--ok); }
.conf-dot.low  { background: var(--warn); }

/* ---------- Holding detail ---------- */
.detail-head { display: flex; align-items: flex-start; gap: 14px; margin-bottom: 6px; }
.detail-head .name { font-family: var(--font-display); font-weight: 800; font-size: 1.4rem; color: var(--navy-deep); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 18px; font-size: .85rem; margin: 12px 0; }
.kv dt { color: var(--ink-3); font-weight: 600; }
.kv dd { margin: 0; font-variant-numeric: tabular-nums; }

.fact {
  background: var(--card-tint); border-radius: var(--radius-s); padding: 13px 15px; margin-bottom: 10px;
  box-shadow: inset 3px 0 0 0 var(--navy);
}
.fact .head { font-weight: 700; font-size: .9rem; margin-bottom: 3px; display: flex; align-items: center; gap: 8px; }
.fact .src a { color: var(--info); font-size: .78rem; text-decoration: none; }
.fact .src a:hover { text-decoration: underline; }

/* AI synthesis block — visually distinct, clearly labelled */
.ai-block {
  background: linear-gradient(180deg, #f3f0fb, #efeaf9);
  box-shadow: inset 0 0 0 1.5px #d9cdf3; border-radius: var(--radius); padding: 16px 18px; margin-top: 14px;
}
.ai-label {
  display: inline-flex; align-items: center; gap: 6px; font-size: .68rem; font-weight: 800;
  text-transform: uppercase; letter-spacing: .05em; color: #6b21a8;
  background: #ede4fb; padding: 3px 10px; border-radius: 999px; margin-bottom: 10px;
}
.ai-block .claim { font-family: var(--font-edit); font-size: 1rem; line-height: 1.55; color: #2a2140; margin: 0 0 6px; }
.ai-block .cites { font-size: .76rem; color: #6b5b8a; margin: 0 0 14px; }
.ai-block .cites a { color: var(--info); text-decoration: none; }
.ai-block .cites a:hover { text-decoration: underline; }
.ai-block .verify-note { font-size: .72rem; color: #7a6b95; font-style: italic; margin-top: 6px; }

/* ---------- Commitments tracker ---------- */
.commit { display: flex; gap: 12px; padding: 12px 0; box-shadow: inset 0 -1px 0 #eef2f7; }
.commit:last-child { box-shadow: none; }
.commit .badge { flex: 0 0 auto; font-size: .68rem; font-weight: 800; padding: 4px 9px; border-radius: 999px; height: fit-content; }
.badge.met { background: #e7f3ec; color: var(--ok); }
.badge.partial { background: #fdf1d8; color: var(--warn); }
.badge.gap { background: #fbe7e4; color: var(--danger); }
.commit .txt .t { font-weight: 700; font-size: .9rem; }
.commit .txt .d { font-size: .82rem; color: var(--ink-2); }
.commit .txt .s { font-size: .74rem; }
.commit .txt .s a { color: var(--info); text-decoration: none; }

/* ---------- Toast / spinner ---------- */
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--navy-deep); color: #fff; padding: 11px 20px; border-radius: 999px; box-shadow: var(--sh-3); font-size: .85rem; z-index: 100; opacity: 0; transition: opacity .2s; pointer-events: none; }
.toast.show { opacity: 1; }
.spinner { width: 16px; height: 16px; border: 2.5px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

.back-link { display: inline-flex; align-items: center; gap: 6px; color: var(--navy); font-weight: 600; font-size: .85rem; cursor: pointer; margin-bottom: 14px; background: none; border: none; padding: 0; }

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
  .main { padding: 16px; }
  .app-header { padding: 10px 14px; }
  .app-header .who { display: none; }
  table.holdings { font-size: .8rem; }
  table.holdings thead th, table.holdings tbody td { padding: 9px 10px; }
  table.holdings .colhide { display: none; }
  .stat .v { font-size: 1.25rem; }
}
