/* SytBoard — Syngenta palette (tokens taken 1:1 from the reference Business Review) */
:root {
  --olive: #5f7800;
  --olive-ink: #4b5f00;
  --green: #7fca3f;
  --blue: #334c56;
  --ink: #1d2427;
  --muted: #667074;
  --light: #f5f6f3;
  --line: #dfe4dc;
  --amber: #e6a523;
  --red: #bd6a45;

  --page: #f3f5f2;
  --surface: #ffffff;

  --crit-bg: #f7e9e3; --crit-ink: #8a3f22;
  --warn-bg: #fbf0d3; --warn-ink: #5c4100;
  --good-bg: #eaf1d6; --good-ink: #3f5200;
  --info-bg: #e6edf0; --info-ink: #334c56;

  --radius: 3px;
  --font: Arial, Helvetica, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 150px; }
body { margin: 0; background: var(--page); color: var(--ink); font-family: var(--font); font-size: 14px; line-height: 1.4; }
h1, h2, h3, h4, p { margin: 0; }
button { font: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } * { transition: none !important; animation: none !important; } }

/* ---------- Header & controls ---------- */
.app-header { background: var(--surface); border-bottom: 1px solid var(--line); padding: 14px 24px; display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.kicker { font-size: 12px; letter-spacing: .08em; font-weight: 700; color: var(--olive-ink); text-transform: uppercase; margin-bottom: 4px; }
.app-header .title { font-size: 22px; font-weight: 700; color: var(--blue); }
.user-chip { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 12px; }
.btn { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 6px 12px; color: var(--ink); }
.btn:hover { border-color: var(--olive); }
.btn-primary { background: var(--olive); border-color: var(--olive); color: #fff; }
.btn-primary:hover { background: var(--olive-ink); }

.controls { position: sticky; top: 0; z-index: 20; background: var(--page); border-bottom: 1px solid var(--line); padding: 10px 24px; }
.controls-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; max-width: 1320px; margin: 0 auto; }
.seg { display: inline-flex; max-width: 100%; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.seg button { border: 0; border-right: 1px solid var(--line); background: transparent; padding: 6px 12px; color: var(--ink); }
.seg button:last-child { border-right: 0; }
.seg button[aria-pressed="true"], .seg button[aria-checked="true"] { background: var(--olive); color: #fff; font-weight: 700; }
.custom-range { display: none; align-items: center; gap: 6px; }
.custom-range.open { display: inline-flex; }
.custom-range input { border: 1px solid var(--line); border-radius: var(--radius); padding: 5px 6px; font: inherit; background: var(--surface); }
.compare-note { color: var(--muted); font-size: 12px; }
.sources { display: flex; flex-wrap: wrap; gap: 6px; margin-left: auto; }
.source-chip { display: inline-flex; align-items: center; gap: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; font-size: 12px; color: var(--ink); }
.source-chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.source-chip.ok .dot { background: var(--olive); }
.source-chip.error .dot { background: var(--red); }
.source-chip.not_configured .dot { background: var(--amber); }
.filter-chips { max-width: 1320px; margin: 8px auto 0; display: none; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.filter-chips.open { display: flex; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: var(--blue); color: #fff; border-radius: 999px; padding: 3px 4px 3px 10px; }
.chip button { background: rgba(255,255,255,.18); border: 0; color: #fff; border-radius: 50%; width: 18px; height: 18px; line-height: 1; padding: 0; }
.chip button:hover { background: rgba(255,255,255,.35); }

.section-nav { max-width: 1320px; margin: 0 auto; padding: 10px 24px 0; display: flex; gap: 4px 18px; flex-wrap: wrap; }
.section-nav a { color: var(--blue); text-decoration: none; font-weight: 700; font-size: 13px; padding: 4px 0; border-bottom: 2px solid transparent; }
.section-nav a:hover { border-bottom-color: var(--olive); }

/* ---------- Layout ---------- */
main.deck { max-width: 1320px; margin: 0 auto; padding: 8px 24px 48px; transition: opacity .15s; }
main.deck.loading { opacity: .55; }
.block { margin-top: 28px; }
.block-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.block-head h2 { font-size: 18px; color: var(--blue); }
.block-head p { color: var(--muted); font-size: 12px; }
.grid { display: grid; gap: 16px; }
.g-2-1 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.g-1-1 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.g-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-3-2 { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); }
@media (max-width: 1000px) { .g-2-1, .g-1-1, .g-3, .g-3-2 { grid-template-columns: minmax(0, 1fr); } }

.card { background: var(--surface); border: 1px solid var(--line); border-top: 3px solid var(--olive); border-radius: var(--radius); padding: 14px 16px 16px; min-width: 0; }
.card h3 { font-size: 14px; color: var(--blue); }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.card-head .sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.card-tools { display: flex; gap: 8px; flex-wrap: wrap; }
.card-tools .seg button { padding: 3px 9px; font-size: 12px; }
.empty { color: var(--muted); padding: 18px 4px; font-size: 13px; }
.notice { border-left: 4px solid var(--blue); background: var(--info-bg); color: var(--info-ink); padding: 10px 12px; font-size: 13px; border-radius: 0 var(--radius) var(--radius) 0; }
.notice.crit { border-left-color: var(--red); background: var(--crit-bg); color: var(--crit-ink); }
.notice.warn { border-left-color: var(--amber); background: var(--warn-bg); color: var(--warn-ink); }

/* ---------- Attention list ---------- */
.attention { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.attn { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 4px 12px; align-items: start; border: 1px solid var(--line); border-left: 4px solid var(--blue); border-radius: 0 var(--radius) var(--radius) 0; padding: 9px 12px; background: var(--surface); }
.attn.critical { border-left-color: var(--red); }
.attn.warning { border-left-color: var(--amber); }
.attn.good { border-left-color: var(--olive); }
.attn .t { font-weight: 700; }
.attn .d { grid-column: 2; color: var(--muted); font-size: 13px; }
.attn a { color: var(--blue); font-size: 12px; white-space: nowrap; }
.sev { font-size: 11px; font-weight: 700; letter-spacing: .04em; padding: 2px 7px; border-radius: 2px; text-transform: uppercase; white-space: nowrap; }
.sev.critical { background: var(--crit-bg); color: var(--crit-ink); }
.sev.warning { background: var(--warn-bg); color: var(--warn-ink); }
.sev.good { background: var(--good-bg); color: var(--good-ink); }
.sev.info { background: var(--info-bg); color: var(--info-ink); }
.src-tag { font-size: 11px; color: var(--muted); }

/* ---------- KPI tiles ---------- */
.kpi-group + .kpi-group { margin-top: 16px; }
.kpi-group > h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 8px; }
.kpis { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px 8px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.kpi .label { font-size: 12px; color: var(--muted); }
.kpi .value { font-size: 24px; font-weight: 700; color: var(--ink); line-height: 1.15; }
.kpi .foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 26px; }
.kpi svg { flex: none; }
.kpi .note { font-size: 11px; color: var(--muted); }
.kpi.flag { border-color: var(--red); }
.delta { font-size: 12px; font-weight: 700; white-space: nowrap; }
.delta.good { color: var(--olive-ink); }
.delta.bad { color: var(--crit-ink); }
.delta.neutral { color: var(--muted); }
.kpi-placeholder { border: 1px dashed var(--line); border-radius: var(--radius); padding: 14px; color: var(--muted); font-size: 13px; background: var(--surface); }

/* ---------- Bar tables ---------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th { text-align: left; font-weight: 700; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 4px 8px 6px 0; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.data td { padding: 6px 8px 6px 0; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data tr:last-child td { border-bottom: 0; }
table.data .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.data th.num { text-align: right; }
table.data tr.pick { cursor: pointer; }
table.data tr.pick:hover td, table.data tr.pick:focus-visible td { background: var(--light); }
table.data tr.selected td { background: var(--good-bg); }
table.data td.name { max-width: 260px; min-width: 96px; overflow-wrap: break-word; }
.pick-btn { background: none; border: 0; padding: 0; font: inherit; color: var(--ink); text-align: left; cursor: pointer; }
.pick-btn:hover { text-decoration: underline; text-decoration-color: var(--olive); }
.tasks .meta { display: block; }
.bar-cell { width: 34%; min-width: 90px; }
.bar { height: 8px; background: var(--light); border-radius: 0 4px 4px 0; position: relative; }
.bar > i { display: block; height: 100%; background: var(--olive); border-radius: 0 4px 4px 0; }
.bar > i + i { margin-left: 2px; }
.bar.multi { display: flex; background: var(--light); }
.bar.multi > i { flex: none; }
.bar-note { font-size: 11px; color: var(--muted); }

/* Status meter */
.meter { display: flex; height: 14px; gap: 2px; margin: 4px 0 10px; }
.meter > span { display: block; height: 100%; min-width: 3px; }
.meter > span:first-child { border-radius: 4px 0 0 4px; }
.meter > span:last-child { border-radius: 0 4px 4px 0; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12px; color: var(--ink); }
.legend .k { display: inline-flex; align-items: center; gap: 6px; }
.legend .sw { width: 10px; height: 10px; border-radius: 2px; }
.legend .line-sw { width: 14px; height: 2px; border-radius: 1px; }

/* Funnel */
.funnel-row { display: grid; grid-template-columns: 170px minmax(0, 1fr) 190px 110px; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.funnel-row:last-child { border-bottom: 0; }
.funnel-row .fname { font-weight: 700; }
.funnel-row .fsub { font-size: 11px; color: var(--muted); font-weight: 400; }
.funnel-row .fnum { text-align: right; font-variant-numeric: tabular-nums; }
.funnel-row.silent .bar > i { background: var(--red); }
@media (max-width: 720px) { .funnel-row { grid-template-columns: 1fr 1fr; } .funnel-row .bar-cell { grid-column: 1 / -1; width: auto; } }

/* Linked pillars */
.link-card { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; background: var(--surface); text-align: left; width: 100%; }
.link-card:hover { border-color: var(--olive); }
.link-card h4 { font-size: 13px; color: var(--blue); }
.link-card .row { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--muted); }
.link-card .row b { color: var(--ink); }
.link-card .verdict { font-size: 12px; color: var(--ink); }

.tasks { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.tasks li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 10px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.tasks li:last-child { border-bottom: 0; }
.tasks .tt { overflow-wrap: anywhere; }
.tasks .tt a { color: var(--blue); }
.tasks .meta { grid-column: 1; font-size: 11px; color: var(--muted); }
.tasks .due { font-size: 12px; font-weight: 700; white-space: nowrap; text-align: right; }
.tasks .due.late { color: var(--crit-ink); }

.stat-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat { border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 10px; }
.stat .l { font-size: 11px; color: var(--muted); }
.stat .v { font-size: 18px; font-weight: 700; }

.chart-box { min-height: 260px; }
.foot-note { margin-top: 28px; font-size: 12px; color: var(--muted); max-width: 900px; }

/* ---------- Auth pages ---------- */
body.auth-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.auth-wrap { width: 100%; max-width: 380px; margin: 16px; padding: 32px; background: var(--surface); border: 1px solid var(--line); border-top: 6px solid var(--olive); }
.auth-wrap h1 { font-size: 24px; color: var(--blue); margin: 0 0 20px; }
.input-group { display: flex; flex-direction: column; gap: 4px; margin-bottom: 14px; }
.input-group label { font-size: 12px; font-weight: 700; color: var(--muted); }
.input-group input { font-size: 14px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius); }
.input-group input:focus { outline: none; border-color: var(--olive); }
.auth-wrap button { width: 100%; background: var(--olive); color: #fff; border: none; border-radius: var(--radius); padding: 11px; font-size: 14px; font-weight: 700; margin-top: 6px; }
.auth-wrap button:hover { background: var(--olive-ink); }
.auth-wrap button:disabled { opacity: .6; cursor: default; }
.hint { font-size: 12px; color: var(--muted); margin-top: 14px; line-height: 1.4; }
.error-msg { color: var(--crit-ink); font-size: 13px; margin: 4px 0 8px; }

@media (max-width: 600px) {
  .app-header, .controls, .section-nav, main.deck { padding-left: 16px; padding-right: 16px; }
  .sources { margin-left: 0; }
  #presets { flex-wrap: wrap; }
  #presets button { flex: 1 1 auto; }
  .attn { grid-template-columns: minmax(0, 1fr); }
  .attn .d, .attn a { grid-column: 1; }
  .card { padding-left: 12px; padding-right: 12px; }
  .card-head { flex-wrap: wrap; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-pair { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .block-head { flex-direction: column; align-items: flex-start; gap: 2px; }
  table.data td.name { max-width: 150px; }
}

/* ---------- Executive page ---------- */
.verdict { border: 1px solid var(--line); border-left: 6px solid var(--blue); background: var(--surface); padding: 16px 20px; border-radius: 0 var(--radius) var(--radius) 0; }
.verdict.critical { border-left-color: var(--red); }
.verdict.warning { border-left-color: var(--amber); }
.verdict.good { border-left-color: var(--olive); }
.verdict .v-title { font-size: 20px; font-weight: 700; color: var(--blue); margin-bottom: 6px; }
.verdict p { font-size: 15px; line-height: 1.5; max-width: 980px; }
.decisions { display: flex; flex-direction: column; gap: 12px; }
.decision { background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--blue); border-radius: 0 var(--radius) var(--radius) 0; padding: 12px 16px; }
.decision.high { border-left-color: var(--red); }
.decision.medium { border-left-color: var(--amber); }
.decision header { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.decision h3 { font-size: 15px; color: var(--ink); margin-bottom: 8px; }
.decision .dcols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
.decision h4 { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 2px; }
.decision p { font-size: 13px; line-height: 1.5; }
@media (max-width: 800px) { .decision .dcols { grid-template-columns: minmax(0, 1fr); } }

@media print {
  @page { size: A4; margin: 12mm; }
  body, html { background: #fff; }
  .controls, .section-nav, .user-chip, #x-foot + * { display: none !important; }
  .app-header { border: 0; padding: 0 0 8px; }
  main.deck { padding: 0; max-width: none; }
  .card, .decision, .verdict, .kpi, .notice { break-inside: avoid; }
  .block { margin-top: 18px; }
  .card-tools { display: none; }
}
