:root {
  --bg: #f6f7fb;
  --panel: #ffffff;
  --text: #172033;
  --muted: #657086;
  --line: #e5e9f2;
  --accent: #273c75;
  --good: #19764a;
  --warn: #9a6700;
  --bad: #b42318;
  --shadow: 0 16px 40px rgba(19, 35, 70, .08);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 270px;
  background: #111827;
  color: #fff;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}
.brand { display: flex; gap: 12px; align-items: center; }
.brand-mark {
  width: 42px; height: 42px; border-radius: 12px;
  background: #fff; color: #111827; display: grid; place-items: center; font-weight: 800;
}
.brand span { display: block; color: #aab4c5; font-size: 12px; margin-top: 3px; }
nav { display: grid; gap: 6px; }
nav a {
  color: #d3d9e7; text-decoration: none; padding: 11px 12px; border-radius: 10px; font-weight: 600;
}
nav a:hover, nav a.active { background: rgba(255,255,255,.11); color: #fff; }
.market-switcher {
  display: grid;
  gap: 7px;
  color: #aab4c5;
  font-size: 12px;
  font-weight: 700;
}
.market-switcher select {
  width: 100%;
  border: 1px solid rgba(255,255,255,.18);
  background: #0b1220;
  color: #fff;
  border-radius: 8px;
  padding: 10px 11px;
  font: inherit;
}
.refresh-panel {
  display: grid;
  gap: 7px;
}
.refresh-panel button {
  border: 1px solid rgba(255,255,255,.18);
  background: #1f2a3d;
  color: #fff;
  border-radius: 8px;
  padding: 10px 11px;
  font-weight: 800;
  cursor: pointer;
}
.refresh-panel button:hover:not(:disabled) { background: #2b3a54; }
.refresh-panel button:disabled { cursor: wait; opacity: .65; }
.refresh-panel span {
  min-height: 16px;
  color: #aab4c5;
  font-size: 12px;
  line-height: 1.35;
}
.import-dialog {
  width: min(520px, calc(100vw - 32px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  color: var(--text);
  box-shadow: 0 24px 70px rgba(17, 24, 39, .28);
}
.import-dialog::backdrop { background: rgba(17, 24, 39, .62); }
.import-dialog form { display: grid; gap: 16px; padding: 24px; }
.dialog-heading { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; }
.dialog-heading h3 { margin-bottom: 4px; }
.dialog-heading p, .dialog-note, .import-status { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.45; }
.import-dialog label { display: grid; gap: 7px; color: var(--muted); font-size: 12px; font-weight: 700; }
.import-dialog input, .import-dialog select {
  width: 100%;
  border: 1px solid #cfd6e3;
  border-radius: 6px;
  padding: 10px 11px;
  background: #fff;
  color: var(--text);
  font: inherit;
}
.custom-instrument-fields { display: grid; grid-template-columns: 1fr 2fr; gap: 12px; }
.admin-login-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.icon-button {
  width: 34px;
  height: 34px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
}
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; }
.dialog-actions button { border-radius: 6px; padding: 9px 14px; font-weight: 700; cursor: pointer; }
.secondary-button { border: 1px solid #cfd6e3; background: #fff; color: var(--text); }
.primary-button { border: 1px solid var(--accent); background: var(--accent); color: #fff; }
.dialog-actions button:disabled { cursor: wait; opacity: .65; }
.import-status { min-height: 19px; color: var(--warn); }
@media (max-width: 520px) {
  .custom-instrument-fields, .admin-login-fields { grid-template-columns: 1fr; }
}
.disclaimer { margin-top: auto; color: #aab4c5; font-size: 12px; line-height: 1.5; }
.main { margin-left: 270px; padding: 32px; max-width: 1480px; }
.freshness-banner {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  border: 1px solid #ead08c;
  background: #fff7df;
  color: var(--warn);
  border-radius: 10px;
  padding: 11px 14px;
  margin-bottom: 18px;
  font-size: 13px;
  line-height: 1.45;
}
.freshness-banner.ok {
  border-color: #bfe8cf;
  background: #eaf8f0;
  color: var(--good);
}
.freshness-banner strong {
  color: inherit;
  white-space: nowrap;
}
.page-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 24px; }
h1 { font-size: 38px; margin: 4px 0; letter-spacing: -0.04em; }
h2 { font-size: 32px; margin: 0; letter-spacing: -0.03em; }
h3 { margin: 0 0 16px; font-size: 18px; }
.eyebrow { margin: 0; text-transform: uppercase; letter-spacing: .11em; color: var(--accent); font-weight: 800; font-size: 12px; }
.muted { color: var(--muted); margin: 4px 0 0; }
.chart-note { color: var(--muted); font-size: 13px; line-height: 1.45; margin: -8px 0 16px; }
.updated { background: var(--panel); border: 1px solid var(--line); padding: 12px 16px; border-radius: 14px; color: var(--muted); }
.hero-card, .card, .score-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
}
.hero-card { padding: 26px; margin-bottom: 20px; display: grid; gap: 14px; }
.summary-text { margin: 0; color: var(--muted); font-size: 17px; line-height: 1.65; max-width: 980px; }
.score-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 16px; margin-bottom: 20px; }
.score-card { padding: 18px; }
.score-card .score { font-size: 34px; font-weight: 800; margin: 10px 0 4px; }
.score-card .label { display: inline-flex; padding: 5px 10px; border-radius: 100px; background: #eef2ff; font-weight: 800; font-size: 12px; }
.score-card .label.opportunity { color: #0f5132; background: #d9f7e7; }
.score-card .label.neutral { color: #1d4ed8; background: #dbeafe; }
.score-card .label.warning { color: #8a5a00; background: #fff2cc; }
.score-card .label.risk { color: #991b1b; background: #fee2e2; }
.score-card ul { margin: 12px 0 0; padding-left: 18px; color: var(--muted); font-size: 13px; line-height: 1.45; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.data-status-card { grid-column: 1 / -1; }
.card { padding: 20px; }
.chart-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.chart-card { min-height: 390px; }
canvas { max-height: 310px; }
.is-unavailable {
  position: relative;
  filter: grayscale(.85);
}
.is-unavailable canvas,
.is-unavailable table {
  opacity: .28;
}
.chart-unavailable {
  position: absolute;
  inset: 50% 18px auto;
  transform: translateY(-50%);
  border: 1px dashed #9aa4b5;
  background: rgba(255,255,255,.92);
  color: var(--muted);
  border-radius: 8px;
  padding: 14px 16px;
  text-align: center;
  font-size: 13px;
  line-height: 1.45;
  box-shadow: 0 8px 24px rgba(17,24,39,.08);
}
.radar-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 24px;
  margin-bottom: 20px;
  padding: 22px;
}
.radar-chart-wrap {
  min-height: 520px;
}
.radar-chart-wrap canvas {
  max-height: 450px;
}
.date-list-panel {
  border-left: 1px solid var(--line);
  padding-left: 20px;
}
.date-list {
  display: grid;
  gap: 8px;
  max-height: 452px;
  overflow-y: auto;
  padding-right: 4px;
}
.date-list button {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: 8px;
  padding: 9px 10px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  cursor: pointer;
  text-align: left;
}
.date-list button:hover,
.date-list button:focus,
.date-list button.active {
  border-color: var(--accent);
  background: #f0f4ff;
  outline: none;
}
.date-list span {
  font-weight: 700;
}
.date-list strong {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}
.change-group { margin-top: 12px; }
.change-group h4 { margin: 0 0 6px; font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--text); }
.small { font-size: 13px; }
.change-row, .reading { display: flex; justify-content: space-between; gap: 12px; border-top: 1px solid var(--line); padding: 12px 0; color: var(--muted); }
.change-row:first-child, .reading:first-child { border-top: 0; }
.badge { border-radius: 999px; padding: 4px 9px; font-size: 12px; font-weight: 800; }
.badge.improved { color: var(--good); background: #eaf8f0; }
.badge.deteriorated { color: var(--bad); background: #fff0ef; }
.badge.stable { color: var(--warn); background: #fff7df; }
.reading-grid { display: grid; gap: 0; }
.latest-reading-row { align-items: center; }
.reading-description {
  display: grid;
  gap: 4px;
  min-width: 0;
}
.reading-description small {
  line-height: 1.4;
}
.reading-result {
  display: grid;
  justify-items: end;
  gap: 6px;
  flex: 0 0 132px;
}
.reading-value { color: var(--text); font-weight: 700; }
.reading-status {
  display: inline-flex;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 800;
  text-align: center;
}
.reading-status.opportunity { color: var(--good); background: #eaf8f0; }
.reading-status.neutral { color: #1d4ed8; background: #dbeafe; }
.reading-status.warning { color: var(--warn); background: #fff7df; }
.reading-status.risk { color: var(--bad); background: #fff0ef; }
.source-ok,
.source-warning {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 700;
}
.source-ok { color: var(--good); background: #eaf8f0; border-color: #bfe8cf; }
.source-warning { color: var(--warn); background: #fff7df; border-color: #ead08c; }
.reading small { color: var(--muted); font-weight: 500; }
.reading em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}
.data-source-row.stale em,
.data-source-row.warning em,
.data-source-row.missing em { color: var(--bad); font-weight: 700; }
.data-source-row.mock em { color: var(--warn); font-weight: 700; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; border-bottom: 1px solid var(--line); padding: 11px 8px; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; }
.status { font-weight: 800; }
.prose { max-width: 900px; line-height: 1.7; color: var(--muted); }
.prose h2 { color: var(--text); font-size: 22px; margin-top: 24px; }
@media (max-width: 1100px) {
  .sidebar { position: static; width: auto; }
  .main { margin-left: 0; padding: 20px; }
  .score-grid, .two-col, .chart-grid { grid-template-columns: 1fr; }
  .radar-panel { grid-template-columns: 1fr; }
  .date-list-panel { border-left: 0; border-top: 1px solid var(--line); padding-left: 0; padding-top: 18px; }
}
@media (max-width: 560px) {
  .latest-reading-row { align-items: flex-start; }
  .reading-result { flex-basis: 104px; }
}
