/* Insights page — own styles (does not use styles.css / board.css). Light theme only. */
:root {
  --bg: #fbf7f0;
  --card: #ffffff;
  --ink: #2b1d1f;
  --muted: #8a7a73;
  --line: #eadfd2;
  --accent: #7a1f3d;
  --accent-soft: #f4e3e8;
  --gold: #c98a06;
  --gold-soft: #fff4d6;
  --grey: #a39a95;
  --grey-soft: #f3efea;
  --radius: 14px;
  --tap: 44px;
  --hdr-h: 108px;      /* 52px top row + 48px tools row + 8px padding */
  --status-h: 30px;
  --tabs-h: 52px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  color-scheme: light only;
}
@media (min-width: 1000px) {
  :root { --hdr-h: 72px; }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  color-scheme: light only;
}
@media (prefers-color-scheme: dark) {
  html, body { background: #fbf7f0; color: #2b1d1f; color-scheme: light only; }
}
body {
  font: 16px/1.35 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; }
button:disabled { cursor: default; }
h1, h2, h3, p { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  border-radius: 8px;
}
.panel-body:focus-visible { outline-offset: -3px; }

.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.muted { color: var(--muted); }

/* ---------- shell ---------- */
.app {
  height: 100vh;
  height: 100dvh;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: calc(var(--hdr-h) + var(--safe-t)) var(--status-h) var(--tabs-h) minmax(0, 1fr);
  padding-left: var(--safe-l);
  padding-right: var(--safe-r);
  max-width: 1600px;
  margin: 0 auto;
  position: relative;
}
@media (min-width: 1000px) {
  .app { grid-template-rows: calc(var(--hdr-h) + var(--safe-t)) var(--status-h) minmax(0, 1fr); }
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: var(--tap); min-width: var(--tap);
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  color: var(--ink);
  font-weight: 600; font-size: 15px;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover:not(:disabled) { border-color: #d9c8b6; background: #fffdf9; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .4; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover:not(:disabled) { background: var(--card); border-color: var(--line); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: #66182f; border-color: #66182f; }
.btn-icon { padding: 0; width: var(--tap); font-size: 24px; line-height: 1; }
.btn[aria-busy="true"] .refresh-ico { display: inline-block; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- header ---------- */
.hdr {
  grid-row: 1; grid-column: 1;
  padding: var(--safe-t) 12px 8px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-rows: 52px 48px;
  grid-template-areas: "back title lock" "tools tools tools";
  align-items: center;
  column-gap: 8px;
  overflow: hidden;
}
.back { grid-area: back; padding: 0 10px; color: var(--accent); }
.lock-btn { grid-area: lock; padding: 0 12px; color: var(--accent); }
.hdr-title { grid-area: title; min-width: 0; }
.hdr-title h1 { font-size: 20px; line-height: 1.15; font-weight: 750; letter-spacing: -0.01em; }
.hdr-sub { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hdr-title h1, .hdr-sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hdr-tools { grid-area: tools; display: flex; align-items: center; gap: 10px; min-width: 0; }
.updated {
  flex: 1 1 auto; min-width: 0;
  font-size: 13px; color: var(--muted); text-align: right;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  font-variant-numeric: tabular-nums;
}
.lang {
  display: inline-flex; padding: 3px; gap: 2px;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  flex: none;
}
.lang-btn {
  min-width: 46px; min-height: 38px; padding: 0 10px;
  border: 0; border-radius: 9px; background: transparent;
  font-weight: 700; font-size: 14px; color: var(--muted);
}
.lang-btn[aria-pressed="true"] { background: var(--accent); color: #fff; }
.lang-btn:focus-visible { outline-offset: 0; }

@media (min-width: 1000px) {
  .hdr {
    padding: var(--safe-t) 20px 0;
    grid-template-columns: auto minmax(0, 1fr) auto auto;
    grid-template-rows: 72px;
    grid-template-areas: "back title tools lock";
    column-gap: 16px;
  }
  .hdr-title { display: flex; align-items: baseline; gap: 12px; }
  .hdr-title h1 { font-size: 24px; }
  .hdr-sub { font-size: 14px; }
  .updated { flex: none; width: 10.5em; }
}

/* ---------- status banner (space always reserved; shown with visibility) ---------- */
.status {
  grid-row: 2; grid-column: 1;
  margin: 0 12px;
  height: calc(var(--status-h) - 4px);
  padding: 0 12px;
  display: flex; align-items: center;
  border-radius: 10px;
  font-size: 13.5px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  visibility: hidden;
  color: var(--muted);
}
.status.is-on { visibility: visible; }
.status[data-kind="offline"] { background: var(--gold-soft); color: #7a5200; border: 1px solid #f0d9a0; }
.status[data-kind="info"] { background: transparent; }
@media (min-width: 1000px) { .status { margin: 0 20px; } }

/* ---------- tabs (below 1000px) ---------- */
.tabs {
  grid-row: 3; grid-column: 1;
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  margin: 0 12px;
  padding: 4px;
  height: calc(var(--tabs-h) - 6px);
  background: #f3ece2;
  border-radius: 14px;
}
.tab {
  min-height: var(--tap);
  height: 100%;
  border: 0; border-radius: 10px;
  background: transparent;
  font-weight: 650; font-size: 15px; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  padding: 0 6px;
}
.tab[aria-selected="true"] { background: var(--card); color: var(--accent); box-shadow: 0 1px 2px rgba(43, 29, 31, .12); }
.tab:focus-visible { outline-offset: -3px; }
@media (min-width: 1000px) { .tabs { display: none; } }

/* ---------- panels ---------- */
.panels {
  grid-row: 4; grid-column: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  padding: 6px 12px calc(12px + var(--safe-b));
}
.panel {
  grid-row: 1; grid-column: 1;
  min-height: 0; min-width: 0;
  display: none;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
body[data-tab="fair"] #panelFair,
body[data-tab="summary"] #panelSummary,
body[data-tab="forecast"] #panelForecast { display: flex; }

@media (min-width: 1000px) {
  .panels {
    grid-row: 3;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
    padding: 4px 20px calc(20px + var(--safe-b));
  }
  .panel { display: flex; }
  #panelFair { grid-column: 1; }
  #panelSummary { grid-column: 2; }
  #panelForecast { grid-column: 3; }
}

.panel-hd {
  flex: none;
  height: 54px;
  padding: 0 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  border-bottom: 1px solid var(--line);
}
.panel-hd h2 { font-size: 17px; font-weight: 750; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.panel-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 14px 16px 20px;
  display: flex; flex-direction: column; gap: 14px;
}
.panel-body > * { flex: none; }

/* pills */
.pill {
  flex: none;
  display: inline-flex; align-items: center; gap: 6px;
  height: 28px; padding: 0 12px;
  border-radius: 999px;
  font-size: 13px; font-weight: 700;
  background: var(--grey-soft); color: var(--muted);
  white-space: nowrap;
}
.pill::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.pill[data-level="none"]::before { display: none; }
.pill[data-level="ok"] { background: #e8f3ea; color: #2f6b3a; }
.pill[data-level="watch"] { background: var(--gold-soft); color: #8a5d00; }
.pill[data-level="high"] { background: var(--accent-soft); color: var(--accent); }

/* ---------- skeletons ---------- */
.skel {
  border-radius: 12px;
  background: linear-gradient(90deg, #f3ece2 0%, #faf5ee 50%, #f3ece2 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}
.skel-line { height: 16px; border-radius: 8px; }
.skel-w60 { width: 60%; }
.skel-w80 { width: 80%; }
.skel-card { height: 76px; }
.skel-table { height: 170px; }
.skel-fc { height: 190px; }
.skel-chart { height: 190px; }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }
@media (prefers-reduced-motion: reduce) {
  .skel, .btn[aria-busy="true"] .refresh-ico { animation: none; }
}

/* ---------- fairness ---------- */
.basis { font-size: 13px; color: var(--muted); }
.flags { display: flex; flex-direction: column; gap: 10px; }
.flag {
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr);
  column-gap: 10px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--grey-soft);
  border-left: 4px solid var(--grey);
}
.flag-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--grey); margin-top: 6px; }
.flag[data-severity="high"] { background: var(--accent-soft); border-left-color: var(--accent); }
.flag[data-severity="high"] .flag-dot { background: var(--accent); }
.flag[data-severity="watch"] { background: var(--gold-soft); border-left-color: var(--gold); }
.flag[data-severity="watch"] .flag-dot { background: var(--gold); }
.flag-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 3px; }
.flag-name { font-weight: 750; }
.flag-text { font-size: 14.5px; line-height: 1.4; }
.badge {
  display: inline-flex; align-items: center;
  height: 20px; padding: 0 8px;
  border-radius: 999px;
  font-size: 11.5px; font-weight: 700; letter-spacing: .02em; text-transform: uppercase;
  background: rgba(255, 255, 255, .75); color: var(--muted);
  border: 1px solid var(--line);
}
.calm {
  padding: 22px 18px;
  border-radius: 12px;
  background: #f4f8f2;
  border: 1px solid #dbe8d8;
  color: #2f6b3a;
  font-weight: 650;
  text-align: center;
}
.notes { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; color: var(--muted); line-height: 1.4; }

/* ---------- summary ---------- */
.daybar {
  flex: none;
  height: 60px;
  padding: 0 10px;
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 8px;
  border-bottom: 1px solid var(--line);
  background: #fdfaf5;
}
.day-label {
  text-align: center; font-weight: 700; font-size: 15px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.day-label .day-tag { color: var(--accent); font-weight: 650; }
.sum-head { font-weight: 750; font-size: 16.5px; line-height: 1.35; }
.sum-details { display: flex; flex-direction: column; gap: 4px; font-size: 14.5px; }
.section-title { font-size: 12.5px; font-weight: 750; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 6px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
.tech-table { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.tech-table th, .tech-table td { padding: 8px 10px; text-align: right; white-space: nowrap; }
.tech-table th:first-child, .tech-table td:first-child { text-align: left; white-space: normal; }
.tech-table thead th { font-size: 12px; color: var(--muted); font-weight: 700; background: #fdfaf5; border-bottom: 1px solid var(--line); }
.tech-table tbody tr + tr td { border-top: 1px solid #f3ece2; }
.tech-table td:first-child { font-weight: 650; }
.unusual { display: flex; flex-direction: column; gap: 6px; font-size: 14.5px; }
.unusual li { position: relative; padding-left: 16px; }
.unusual li::before { content: ""; position: absolute; left: 2px; top: .55em; width: 7px; height: 7px; border-radius: 50%; background: var(--gold); }
.unusual-none { font-size: 14.5px; color: var(--muted); }
.source { font-size: 12.5px; color: var(--muted); }
.copy-row { display: flex; align-items: center; gap: 12px; }
.copy-row .btn.is-done { background: var(--accent-soft); border-color: #e7c7d2; color: var(--accent); }
.empty { padding: 18px; border-radius: 12px; background: var(--grey-soft); color: var(--muted); text-align: center; }

/* ---------- forecast ---------- */
.banner-rough {
  padding: 10px 12px; border-radius: 12px;
  background: var(--gold-soft); border: 1px solid #f0d9a0; color: #7a5200;
  font-size: 14px; font-weight: 650;
}
.insufficient {
  padding: 22px 18px; border-radius: 12px;
  background: var(--grey-soft); border: 1px solid var(--line);
  font-size: 15px; line-height: 1.45; text-align: center;
}
.fc-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.fc-card {
  border: 1px solid var(--line); border-radius: 12px;
  padding: 12px;
  display: flex; flex-direction: column; gap: 8px;
  background: #fffdfa;
  min-width: 0;
}
.fc-card h3 { font-size: 15px; font-weight: 750; display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 6px; }
.fc-card h3 .muted { font-weight: 550; font-size: 13px; }
.kv { margin: 0; display: flex; flex-direction: column; gap: 6px; }
.kv div { min-width: 0; }
.kv dt { font-size: 11.5px; color: var(--muted); font-weight: 650; text-transform: uppercase; letter-spacing: .03em; }
.kv dd { margin: 0; font-weight: 700; font-size: 15px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.kv dd.big { font-size: 24px; line-height: 1.1; color: var(--accent); }
.fc-basis { font-size: 12.5px; color: var(--muted); line-height: 1.35; }
.fc-pace { font-size: 13px; line-height: 1.35; padding-top: 8px; border-top: 1px dashed var(--line); }
.fc-pace b { display: block; font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.fc-closed { font-size: 14px; color: var(--muted); }

.chart { margin: 0; border: 1px solid var(--line); border-radius: 12px; padding: 12px 10px 8px; }
.chart figcaption { font-size: 13px; font-weight: 750; margin-bottom: 8px; }
.bars {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: 3px;
  align-items: end;
}
.bar-col {
  display: grid;
  grid-template-rows: 16px 110px auto;
  justify-items: center;
  min-width: 0;
}
.bar-val { font-size: 10.5px; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; white-space: nowrap; align-self: end; }
.bar-track { width: 100%; height: 110px; display: flex; align-items: flex-end; justify-content: center; border-bottom: 1px solid var(--line); }
.bar { width: 78%; max-width: 34px; min-height: 2px; border-radius: 5px 5px 0 0; background: #d9c3b4; }
.bar-col[data-rush="1"] .bar { background: var(--accent); }
.bar-col[data-rush="1"] .bar-lbl { color: var(--accent); font-weight: 750; }
.bars-week .bar { background: #c9a98f; }
.bar-col[data-today="1"] .bar { background: var(--accent); }
.bar-lbl { margin-top: 4px; font-size: 10.5px; line-height: 1.15; color: var(--muted); text-align: center; overflow-wrap: anywhere; }
.bar-days { font-size: 10px; color: var(--grey); line-height: 1.2; }
.legend { margin-top: 6px; font-size: 11.5px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; background: var(--accent); display: inline-block; }

/* ---------- lock overlay ---------- */
.overlay {
  grid-row: 2 / -1; grid-column: 1;
  z-index: 5;
  display: flex; align-items: flex-start; justify-content: center;
  padding: 24px 16px calc(24px + var(--safe-b));
  background: rgba(251, 247, 240, .97);
  overflow-y: auto;
}
@media (min-height: 600px) { .overlay { padding-top: 8vh; } }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 10px 30px rgba(43, 29, 31, .08); }
.lock-inner { width: 100%; max-width: 400px; padding: 24px 22px; display: flex; flex-direction: column; gap: 10px; }
.lock-inner h2 { font-size: 20px; }
.lock-msg { min-height: 1.35em; font-size: 14px; font-weight: 650; color: #7a5200; }
.unlock-form { display: flex; flex-direction: column; gap: 8px; }
.unlock-form label { font-size: 14px; font-weight: 700; }
.unlock-row { display: flex; gap: 8px; }
.unlock-row input {
  flex: 1 1 auto; min-width: 0;
  height: 52px; padding: 0 14px;
  border: 1px solid #d9c8b6; border-radius: 12px; background: #fff;
  font-size: 22px; letter-spacing: .2em;
}
.unlock-row input:focus-visible { outline-offset: 0; border-color: var(--accent); }
.unlock-row .btn { min-height: 52px; padding: 0 18px; }
.pin-err { min-height: 1.35em; font-size: 14px; font-weight: 650; color: var(--accent); }
