/* PRN Dashboard — clean, government-style data interface */

:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #fafbfc;
  --border: #e1e4e8;
  --border-strong: #c8cdd3;
  --ink: #0b1f3a;
  --ink-muted: #4a5867;
  --ink-soft: #6b7785;
  --accent: #1d4ed8;
  --accent-soft: #e8efff;
  --good: #15803d;
  --bad: #b91c1c;
  --warn: #b45309;
  --shadow: 0 1px 2px rgba(11,31,58,0.04), 0 4px 12px rgba(11,31,58,0.04);
  --radius: 6px;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
}

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

.app {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px 28px 64px;
}

/* Header */
header.top {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}
header.top h1 {
  font-size: 22px;
  font-weight: 600;
  margin: 0 0 4px;
  letter-spacing: -0.01em;
}
header.top .sub {
  font-size: 13px;
  color: var(--ink-muted);
}
header.top .sub a { color: var(--accent); text-decoration: none; }
header.top .sub a:hover { text-decoration: underline; }

.refresh-block {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 12px;
  color: var(--ink-muted);
}
.refresh-block .stamp {
  font-family: var(--mono);
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 6px 10px;
  border-radius: var(--radius);
  color: var(--ink);
}
.refresh-block .stamp .label {
  color: var(--ink-soft);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-right: 6px;
}
.live-badge {
  display: inline-block;
  font-family: var(--sans);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 2px 6px;
  border-radius: 3px;
  margin-left: 8px;
  vertical-align: middle;
  border: 1px solid transparent;
}
.live-badge.live {
  background: #dcfce7;
  color: #14532d;
  border-color: #86efac;
}
.live-badge.cached {
  background: #fef3c7;
  color: #78350f;
  border-color: #fcd34d;
}
.cached-banner {
  display: none;                /* JS shows/hides */
  align-items: flex-start;
  gap: 12px;
  background: #fffbeb;
  border: 1px solid #fcd34d;
  border-left: 4px solid #d97706;
  border-radius: var(--radius);
  padding: 12px 16px;
  margin: 0 0 16px 0;
  font-size: 13px;
  color: #78350f;
  line-height: 1.5;
}
.cached-banner .title {
  font-weight: 600;
  color: #78350f;
  margin-right: 6px;
}
.cached-banner em {
  font-style: normal;
  font-weight: 600;
  background: #fef3c7;
  padding: 1px 4px;
  border-radius: 2px;
}
.cached-banner .pill.live {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 5px;
  background: #dcfce7;
  color: #14532d;
  border: 1px solid #86efac;
  border-radius: 3px;
  letter-spacing: 0.06em;
}
button.refresh {
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 500;
  background: var(--accent);
  color: #fff;
  border: 1px solid var(--accent);
  padding: 8px 14px;
  border-radius: var(--radius);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: background 0.15s, transform 0.05s;
}
button.refresh:hover { background: #1740b0; }
button.refresh:active { transform: translateY(1px); }
button.refresh:disabled { background: var(--ink-soft); border-color: var(--ink-soft); cursor: progress; }
button.refresh .spinner {
  width: 12px; height: 12px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: #fff;
  border-radius: 50%;
  display: none;
  animation: spin 0.8s linear infinite;
}
button.refresh.loading .spinner { display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Spot price strip */
.spot-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
  margin-bottom: 28px;
}
.spot-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: relative;
  border-left: 3px solid var(--accent);
}
.spot-card .name {
  font-size: 12px;
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 500;
}
.spot-card .price {
  font-family: var(--mono);
  font-size: 22px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.01em;
}
.spot-card .range {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-soft);
}
.spot-card .delta {
  font-size: 12px;
  font-family: var(--mono);
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}
.spot-card .delta.up { color: var(--bad); }
.spot-card .delta.down { color: var(--good); }
.spot-card .delta.flat { color: var(--ink-soft); }

/* Carry-over banner */
.carryover-banner {
  background: linear-gradient(180deg, #fffbeb, #fff7d6);
  border: 1px solid #f5d97a;
  border-left: 3px solid #b45309;
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 24px;
  font-size: 13px;
  color: #5b3d05;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
  justify-content: space-between;
}
.carryover-banner .title {
  font-weight: 600;
  color: #4a3000;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.carryover-banner .title::before {
  content: "";
  display: inline-block;
  width: 8px; height: 8px;
  background: #b45309;
  border-radius: 50%;
}
.carryover-banner .meta {
  font-family: var(--mono);
  font-size: 11px;
  color: #7a5410;
}
.carryover-banner a { color: #7c2d12; }

/* Chart grid */
.chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(440px, 1fr));
  gap: 16px;
}
.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px 12px;
  box-shadow: var(--shadow);
}
.chart-card h3 {
  font-size: 14px;
  font-weight: 600;
  margin: 0 0 2px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.chart-card h3 .swatch {
  width: 10px; height: 10px;
  border-radius: 2px;
  display: inline-block;
}
.chart-card .meta {
  font-size: 11px;
  color: var(--ink-soft);
  font-family: var(--mono);
  margin-bottom: 10px;
}

/* Carry-over panel inside chart card */
.carry-panel {
  margin-top: 12px;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--ink-soft);
  border-radius: var(--radius);
  font-size: 12px;
  line-height: 1.45;
}
.carry-panel.signal-tight    { border-left-color: var(--bad); background: #fef5f5; }
.carry-panel.signal-loose    { border-left-color: var(--good); background: #f3faf5; }
.carry-panel.signal-neutral  { border-left-color: var(--warn); background: #fdf9ee; }
.carry-panel.signal-high-risk{ border-left-color: #7f1d1d; background: #fde9e9; }

.carry-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}
.carry-head .lbl {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-muted);
  font-weight: 600;
}
.carry-head .tag {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 7px;
  border-radius: 10px;
  background: var(--ink-muted);
  color: #fff;
}
.carry-head .tag.signal-tight    { background: var(--bad); }
.carry-head .tag.signal-loose    { background: var(--good); }
.carry-head .tag.signal-neutral  { background: var(--warn); }
.carry-head .tag.signal-high-risk{ background: #7f1d1d; }

.carry-figures {
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}
.carry-figures .tonnes {
  font-family: var(--mono);
  font-size: 17px;
  font-weight: 600;
  color: var(--ink);
}
.carry-figures .tonnes .unit {
  font-size: 11px;
  font-weight: 400;
  color: var(--ink-soft);
  margin-left: 3px;
}
.carry-figures .yoy {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
}
.carry-figures .yoy.up { color: var(--good); }
.carry-figures .yoy.down { color: var(--bad); }
.carry-figures .yoy.flat { color: var(--ink-soft); }
.carry-figures .prior {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-soft);
}
.carry-comment {
  color: var(--ink-muted);
  font-size: 12px;
}
.chart-wrap {
  position: relative;
  height: 240px;
}

/* Footer */
footer.notes {
  margin-top: 32px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--ink-soft);
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  justify-content: space-between;
}
footer.notes a { color: var(--accent); text-decoration: none; }
footer.notes a:hover { text-decoration: underline; }

/* Toast */
.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  background: var(--ink);
  color: #fff;
  font-size: 13px;
  padding: 10px 14px;
  border-radius: var(--radius);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
  z-index: 50;
  font-family: var(--mono);
}
.toast.show { opacity: 1; transform: translateY(0); }

@media (max-width: 720px) {
  .app { padding: 16px; }
  header.top { flex-direction: column; align-items: flex-start; }
  .chart-grid { grid-template-columns: 1fr; }
}
