/* CTT Board KPI Hub — skinned to match the CTT One Platform design system
   (https://ctt-one-platform.pages.dev/): warm cream canvas, paper surfaces,
   Georgia serif, navy panels, blue links, yellow CTAs, coral secondary accent,
   uppercase letter-spaced tags, editorial square cards with coloured top borders.
   RAG colours remain the loudest signal for anything carrying KPI meaning. */

:root {
  /* One Platform tokens (verbatim) */
  --blue: #0874bb;
  --blue-deep: #07598f;
  --navy: #092e4b;
  --yellow: #ffd33d;
  --coral: #ef5d51;
  --coral-deep: #b13a30;
  --cream: #f6f1e7;
  --paper: #fffdf8;
  --ink: #172832;
  --muted: #687881;
  --line: #dcd8cf;
  --sky: #dcecf4;
  --sand: #e9dfd0;
  --ochre: #9b5c0a;
  --serif: Georgia, "Times New Roman", serif;

  /* RAG — vivid and dominant; harmonised with the warm palette */
  --rag-green: #1e7d46;
  --rag-green-soft: #e2efe3;
  --rag-amber: #c47f00;
  --rag-amber-soft: #f4e8cf;
  --rag-red: #c0392b;
  --rag-red-soft: #f7e1dd;
  --rag-none: #93a0ad;
  --rag-none-soft: #edeae2;

  --maxw: 1120px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: var(--serif);
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--cream);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--yellow); }
:focus-visible { outline: 3px solid var(--yellow); outline-offset: 2px; }

.tag-style { font-size: 11px; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase; }

/* ---------- Header (cream, typographic brand like One Platform) ---------- */
.app-header { background: var(--cream); border-bottom: 1px solid var(--line); }
.app-header__range { display: none; }
.app-header__inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 18px 24px 16px;
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}
.brand { text-decoration: none; display: flex; align-items: center; gap: 14px; }
.brand__logo { display: inline-flex; flex: none; }
.brand__logo img { display: block; height: 46px; width: auto; }
.brand__words { display: flex; flex-direction: column; border-left: 1px solid var(--line); padding-left: 14px; }
.brand__title {
  font-size: 14px; font-weight: 700; letter-spacing: 0.18em;
  text-transform: uppercase; color: var(--blue);
}
.brand__sub { font-style: italic; font-size: 13px; color: var(--muted); margin-top: 2px; }

.nav { display: flex; gap: 8px; margin-left: auto; flex-wrap: wrap; }
.nav a {
  font-family: var(--serif);
  font-size: 11px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 9px 18px;
  text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.nav a:hover { border-color: var(--blue); }
.nav a.active { background: var(--navy); border-color: var(--navy); color: #fff; }

.dev-identity {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--muted);
  background: var(--paper); border: 1px solid var(--line);
  padding: 6px 10px; border-radius: 999px;
}
.dev-identity select, .dev-identity input {
  font-family: var(--serif); font-size: 12px;
  border: 1px solid var(--line); border-radius: 6px; padding: 4px 8px;
  background: #fff; color: var(--ink);
}
.dev-identity input[type="email"] { width: 185px; }
.dev-identity .tag {
  font-size: 10px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--coral-deep);
}

/* Preview-mode banner */
.mode-banner {
  background: var(--sand); color: var(--ochre);
  border-bottom: 1px solid var(--line);
  font-size: 13.5px; font-style: italic;
  text-align: center; padding: 9px 24px; line-height: 1.5;
}
.mode-banner strong { font-style: normal; font-weight: 700; }
.mode-banner em { font-style: normal; font-weight: 700; }
@media print { .mode-banner { display: none !important; } }

/* ---------- Layout ---------- */
.view { flex: 1; width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 40px 24px 64px; }
.loading { color: var(--muted); font-style: italic; padding: 40px 0; }

.page-head { margin-bottom: 30px; }
.page-head h1 {
  font-weight: 400;
  font-size: clamp(1.9rem, 3.6vw, 2.6rem);
  letter-spacing: -0.02em;
  line-height: 1.05;
  margin-bottom: 10px;
}
.page-head .meta { color: var(--muted); font-size: 15px; display: flex; flex-wrap: wrap; gap: 8px 18px; align-items: center; }
.caveat {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--sand); color: var(--ochre);
  border-radius: 999px;
  font-size: 12.5px; font-style: italic; padding: 5px 14px;
}
.caveat::before { content: "•"; color: var(--coral); font-style: normal; }

/* ---------- Dashboard grid (2x3, like One Platform channel cards) ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
@media (max-width: 960px) { .kpi-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .kpi-grid { grid-template-columns: 1fr; } }

.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-top: 3px solid var(--rag-none);
  padding: 22px 22px 20px;
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: inherit;
  transition: box-shadow 0.2s ease, transform 0.15s ease;
}
.card:hover { box-shadow: 0 10px 30px rgba(9, 46, 75, 0.1); transform: translateY(-2px); }
.card--green { border-top-color: var(--rag-green); }
.card--amber { border-top-color: var(--rag-amber); }
.card--red { border-top-color: var(--rag-red); }

.card__top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.card__index { font-size: 10px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.card__name { font-weight: 400; font-size: 1.35rem; letter-spacing: -0.01em; color: var(--ink); margin: 4px 0 2px; line-height: 1.15; }
.card__q { font-size: 14px; color: var(--muted); font-style: italic; margin-bottom: 16px; }

.rag-pill {
  flex: none;
  font-size: 10px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase;
  padding: 4px 11px; border-radius: 999px; white-space: nowrap;
}
.rag-pill--green { background: var(--rag-green-soft); color: var(--rag-green); }
.rag-pill--amber { background: var(--rag-amber-soft); color: var(--ochre); }
.rag-pill--red { background: var(--rag-red-soft); color: var(--rag-red); }
.rag-pill--none { background: var(--rag-none-soft); color: var(--muted); }

.headline { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: auto; }
.headline--stack { grid-template-columns: 1fr; }
.metric { background: var(--cream); border: 1px solid var(--line); padding: 12px 14px; }
.metric__label { font-size: 11.5px; color: var(--muted); line-height: 1.35; margin-bottom: 6px; }
.metric__value { font-size: 1.5rem; letter-spacing: -0.01em; color: var(--ink); display: flex; align-items: center; gap: 8px; line-height: 1.1; }
.metric__value .dot { width: 11px; height: 11px; border-radius: 50%; flex: none; }
.dot--green { background: var(--rag-green); }
.dot--amber { background: var(--rag-amber); }
.dot--red { background: var(--rag-red); }

.card__cta {
  margin-top: 16px;
  font-size: 11px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--blue);
  border-bottom: 1px solid var(--line);
  padding-bottom: 3px;
  align-self: flex-start;
  transition: border-color 0.15s ease;
}
.card:hover .card__cta { border-bottom-color: var(--blue); }

/* ---------- Footer ---------- */
.app-footer { border-top: 1px solid var(--line); background: var(--cream); }
.app-footer__inner {
  max-width: var(--maxw); margin: 0 auto; padding: 26px 24px 34px;
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  font-size: 13.5px; color: var(--muted);
}
.app-footer__inner span:first-child { font-style: italic; }
.app-footer__inner span:last-child { font-size: 11px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; font-style: normal; }

/* ---------- KPI detail ---------- */
.back {
  font-size: 11px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--blue); text-decoration: none;
  border-bottom: 1px solid var(--line); padding-bottom: 2px;
}
.back:hover { border-bottom-color: var(--blue); }
.detail-head { margin-bottom: 34px; }
.detail-title { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin: 16px 0 14px; }
.detail-title h1 { font-weight: 400; font-size: clamp(1.9rem, 3.6vw, 2.6rem); letter-spacing: -0.02em; line-height: 1.05; margin: 4px 0 4px; }
.detail-title__right { display: flex; align-items: center; gap: 12px; flex: none; padding-top: 8px; }

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--serif);
  font-size: 11px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase;
  text-decoration: none; cursor: pointer;
  border-radius: 999px; padding: 13px 24px; border: 1px solid transparent;
  transition: background 0.15s ease, transform 0.15s ease, border-color 0.15s ease;
}
.btn--primary { background: var(--yellow); color: var(--navy); }
.btn--primary:hover { background: #f3c322; transform: translateY(-1px); }
.btn--primary:disabled { opacity: 0.6; transform: none; cursor: default; }
.btn--ghost { background: var(--paper); color: var(--ink); border-color: var(--line); }
.btn--ghost:hover { border-color: var(--blue); }
.btn--sm { padding: 8px 16px; }

.section { margin: 34px 0; }
.section h2 { font-weight: 400; font-size: 1.7rem; letter-spacing: -0.02em; margin-bottom: 16px; }
.section h2 .muted, .muted { color: var(--muted); font-size: 0.72em; font-style: italic; font-weight: 400; letter-spacing: 0; text-transform: none; }
.section__head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.section__head h2 { margin-bottom: 16px; }
.q-pick { font-size: 11px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); display: inline-flex; align-items: center; gap: 10px; }
.q-pick select { font-family: var(--serif); font-size: 14px; padding: 7px 12px; border: 1px solid var(--line); background: var(--paper); color: var(--ink); }

.headline--detail { grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 560px) { .headline--detail { grid-template-columns: 1fr; } }
.metric--lg { background: var(--paper); padding: 22px 24px; }
.metric--lg .metric__value { font-size: 2.3rem; }
.metric__foot { font-size: 12.5px; font-style: italic; color: var(--muted); margin-top: 8px; }
.metric__foot b { font-style: normal; }

.trend { margin-top: 16px; border-top: 1px dashed #c9c3b8; padding-top: 14px; }
.trend--empty { color: var(--muted); font-size: 13px; font-style: italic; border-top: 1px dashed #c9c3b8; }
.spark { display: block; }
.spark path { stroke: var(--blue); }
.spark circle { fill: var(--blue); }
.trend__labels { display: flex; justify-content: space-between; gap: 6px; margin-top: 6px; }
.trend__labels span { display: flex; flex-direction: column; font-size: 12.5px; }
.trend__labels b { color: var(--ink); font-weight: 700; }
.trend__labels i { color: var(--muted); font-style: italic; font-size: 11px; }
.trend--chips { display: flex; flex-wrap: wrap; gap: 8px; }
.tchip { display: inline-flex; flex-direction: column; align-items: flex-start; font-size: 13px; font-weight: 700; padding: 6px 12px; }
.tchip i { font-style: italic; font-weight: 400; font-size: 11px; opacity: 0.85; }
.tchip--green { background: var(--rag-green-soft); color: var(--rag-green); }
.tchip--amber { background: var(--rag-amber-soft); color: var(--ochre); }
.tchip--red { background: var(--rag-red-soft); color: var(--rag-red); }
.tchip--none { background: var(--rag-none-soft); color: var(--muted); }

.ref-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 34px 0; }
@media (max-width: 780px) { .ref-grid { grid-template-columns: 1fr; } }
.panel { background: var(--paper); border: 1px solid var(--line); padding: 26px 28px; }
.panel h3 {
  font-size: 11px; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--blue-deep); margin: 22px 0 8px;
}
.panel h3:first-child { margin-top: 0; }
.panel p { font-size: 15.5px; line-height: 1.55; }
.assurance { margin: 0; padding-left: 22px; }
.assurance li { margin: 8px 0; font-size: 15.5px; line-height: 1.5; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); background: var(--paper); }
table.history { border-collapse: collapse; width: 100%; font-size: 14px; }
table.history th {
  text-align: left;
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--muted); background: var(--cream);
  padding: 12px 16px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
table.history td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.history tr:last-child td { border-bottom: none; }
.mono { font-size: 12.5px; color: var(--muted); }
.nowrap { white-space: nowrap; }
table.history .dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 7px; vertical-align: middle; }

/* ---------- Edit ---------- */
.edit-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
@media (max-width: 560px) { .edit-list { grid-template-columns: 1fr; } }
.edit-pick {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--paper); border: 1px solid var(--line); border-top: 3px solid var(--blue);
  padding: 20px 22px; text-decoration: none; color: inherit;
  transition: box-shadow 0.2s ease, transform 0.15s ease;
}
.edit-pick:hover { box-shadow: 0 10px 30px rgba(9, 46, 75, 0.1); transform: translateY(-2px); }
.edit-pick strong { font-weight: 400; font-size: 1.25rem; letter-spacing: -0.01em; }

.edit-form { background: var(--paper); border: 1px solid var(--line); padding: 8px 28px; margin-top: 8px; }
.form-row { display: grid; grid-template-columns: 250px 1fr 1fr; gap: 20px; align-items: start; padding: 20px 0; border-bottom: 1px solid var(--line); }
.form-row:last-child { border-bottom: none; }
.form-row--top { background: var(--cream); margin: 0 -28px; padding: 20px 28px; }
@media (max-width: 680px) { .form-row { grid-template-columns: 1fr; gap: 8px; } }
.form-row label { font-size: 15px; font-weight: 700; padding-top: 8px; }
.req { color: var(--coral); }
.form-control input, .form-control select, .form-control textarea {
  font-family: var(--serif); font-size: 15px; width: 100%;
  padding: 10px 12px; border: 1px solid var(--line); background: #fff; color: var(--ink);
}
.form-control input:focus, .form-control select:focus, .form-control textarea:focus {
  outline: 3px solid var(--yellow); outline-offset: 0; border-color: var(--yellow);
}
.input-affix { display: flex; align-items: stretch; }
.affix { display: inline-flex; align-items: center; padding: 0 12px; background: var(--sand); border: 1px solid var(--line); color: var(--muted); font-weight: 700; }
.input-affix .affix { border-left: none; }
.input-affix .affix--pre { border-left: 1px solid var(--line); border-right: none; }
.prev { font-size: 13.5px; font-style: italic; color: var(--muted); padding-top: 10px; }
.prev strong { font-style: normal; color: var(--ink); }
.err { color: var(--coral-deep); font-size: 13px; margin-top: 6px; }
.form-actions { display: flex; align-items: center; gap: 14px; padding: 22px 0; }
.save-msg { font-size: 14px; font-style: italic; }
.save-msg--ok { color: var(--rag-green); }
.save-msg--err { color: var(--coral-deep); }

/* ---------- Inline editing ---------- */
.edit-hint {
  background: var(--sky); color: var(--blue-deep);
  padding: 10px 16px; font-size: 14px; font-style: italic; margin-top: 14px;
}
.metric--edit .inline-input,
.metric--edit .input-affix { margin: 6px 0 2px; }
.metric--edit .inline-input {
  font-family: var(--serif); font-size: 1.3rem; color: var(--ink);
  width: 100%; padding: 9px 12px; border: 1px solid var(--line); background: #fff;
}
.metric--edit .inline-input:focus { outline: 3px solid var(--yellow); outline-offset: 0; }
.edit-badge {
  font-size: 9px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--blue-deep); background: var(--sky); padding: 2px 8px; border-radius: 999px;
  vertical-align: middle;
}

.editable-text { position: relative; }
.et-edit {
  font-family: var(--serif); font-size: 10px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--blue); background: transparent;
  border: 1px dashed #c9c3b8; border-radius: 999px;
  padding: 2px 11px; margin-left: 8px; cursor: pointer; white-space: nowrap;
  transition: border-color 0.15s ease;
}
.et-edit:hover { border-color: var(--blue); }
.et-display h1 { display: inline; }
.et-editor { margin: 8px 0; }
.et-input {
  font-family: var(--serif); font-size: 15px; width: 100%;
  padding: 10px 12px; border: 1px solid var(--line); background: #fff;
  outline: 3px solid var(--yellow); resize: vertical;
}
.et-actions { display: flex; gap: 8px; margin-top: 8px; }

.kbadge {
  font-size: 9px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--coral-deep); background: #fce4e1; padding: 2px 7px; border-radius: 4px;
}

/* toast */
.toast {
  position: fixed; left: 50%; bottom: 28px;
  transform: translateX(-50%) translateY(20px);
  background: var(--navy); color: #fff;
  font-family: var(--serif); font-size: 13.5px; font-style: italic;
  padding: 11px 22px; border-radius: 999px;
  box-shadow: 0 10px 30px rgba(9, 46, 75, 0.3);
  opacity: 0; pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease; z-index: 50;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast--err { background: var(--coral-deep); font-style: normal; }

/* ---------- Report ---------- */
.report-toolbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.report-toolbar h1 { font-weight: 400; font-size: clamp(1.9rem, 3.6vw, 2.4rem); letter-spacing: -0.02em; margin-bottom: 4px; }
.report-toolbar .muted { font-size: 14px; }

.report { background: var(--paper); border: 1px solid var(--line); padding: 40px 44px; }
.report__header {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 20px;
  border-bottom: 3px solid var(--navy); padding-bottom: 20px; margin-bottom: 24px;
}
.report__logo { display: block; height: 60px; width: auto; margin-bottom: 6px; }
.report__sub { display: block; font-size: 12px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.report__meta { text-align: right; font-size: 13.5px; color: var(--muted); }
.report__meta b { display: block; font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink); }
.report__meta div { margin-bottom: 8px; }
.report__caveat { background: var(--sand); color: var(--ochre); font-size: 13.5px; font-style: italic; padding: 10px 16px; margin-bottom: 24px; }
.report__footer { margin-top: 28px; border-top: 1px solid var(--line); padding-top: 16px; font-size: 12.5px; font-style: italic; color: var(--muted); }

.rpt-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.rpt-kpi { border: 1px solid var(--line); border-top: 3px solid var(--rag-none); padding: 18px 20px; background: #fff; }
.rpt-kpi--green { border-top-color: var(--rag-green); }
.rpt-kpi--amber { border-top-color: var(--rag-amber); }
.rpt-kpi--red { border-top-color: var(--rag-red); }
.rpt-kpi__head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 14px; }
.rpt-kpi__idx { font-size: 9.5px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.rpt-kpi__head h3 { font-weight: 400; font-size: 1.3rem; letter-spacing: -0.01em; margin: 3px 0 3px; }
.rpt-kpi__q { font-size: 13px; font-style: italic; color: var(--muted); }
.rpt-kpi__metrics { display: flex; flex-direction: column; gap: 9px; }
.rpt-metric { display: flex; justify-content: space-between; align-items: center; gap: 12px; border-top: 1px dashed #c9c3b8; padding-top: 9px; }
.rpt-metric:first-child { border-top: none; padding-top: 0; }
.rpt-metric__label { font-size: 13.5px; color: var(--muted); }
.rpt-metric__value { font-weight: 700; font-size: 1.1rem; display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
.rpt-metric__value .dot { width: 10px; height: 10px; border-radius: 50%; }

/* ---------- Print ---------- */
@media print {
  @page { size: A4; margin: 14mm; }
  .app-header, .app-footer, .report-toolbar, .dev-identity, .mode-banner, .toast { display: none !important; }
  body { background: #fff; }
  .view { padding: 0; max-width: none; }
  .report { border: none; padding: 0; }
  .rpt-grid { gap: 10px; }
  .rpt-kpi { break-inside: avoid; }
  .report__header, .report__caveat { break-after: avoid; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ---------- Misc ---------- */
.placeholder { color: var(--muted); font-style: italic; background: var(--paper); border: 1px dashed #c9c3b8; padding: 32px; }
.error { color: var(--coral-deep); background: var(--rag-red-soft); border: 1px solid #eac6bf; padding: 20px; }
