/* _CHARTWIRE_STYLE_2026_05_29 — chartwire spec §10 F8 themes */

:root {
  --bg: #0a0a0a;
  --fg: #e8e8e8;
  --card-bg: #161616;
  --border: #2a2a2a;
  --bull: #4ade80;
  --bear: #f87171;
  --neutral: #94a3b8;
  --warn: #fbbf24;
  --skip: #6b7280;
  --info: #60a5fa;
  --muted: #525252;
}
body.theme-oled-black {
  --bg: #000000;
  --card-bg: #050505;
  --border: #1a1a1a;
}
body.theme-light {
  --bg: #fafafa;
  --fg: #1a1a1a;
  --card-bg: #ffffff;
  --border: #e2e8f0;
  --muted: #94a3b8;
}

* { box-sizing: border-box; }
body {
  background: var(--bg); color: var(--fg);
  margin: 0; padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

#hdr {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0;
  background: var(--bg);
  z-index: 10;
  gap: 8px;
}
.brand { font-weight: bold; font-size: 16px; }
.health { font-size: 11px; color: var(--neutral); flex: 1; text-align: center; }
.hdr-controls { display: flex; gap: 4px; }
.hdr-controls button {
  background: transparent; border: 1px solid var(--border);
  color: var(--fg); cursor: pointer; padding: 4px 8px;
  border-radius: 4px; font-size: 14px;
}
.hdr-controls button:hover { background: var(--card-bg); }

#focus-banner {
  background: var(--warn); color: #000;
  padding: 10px 12px;
  text-align: center; font-weight: bold;
  border-bottom: 2px solid #d97706;
}
#focus-banner.hidden { display: none; }

main { padding: 8px; max-width: 100vw; }
.loader { text-align: center; padding: 40px; color: var(--neutral); }
.err {
  padding: 24px;
  text-align: center;
  color: var(--bear);
  font-size: 16px;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 8px;
  overflow: hidden;
}
.card.expanded { border-color: var(--info); }
.card-hdr {
  padding: 10px 12px;
  display: grid;
  grid-template-columns: 70px 30px 1fr 80px 60px 60px 20px;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}
.card-hdr:hover { background: rgba(255,255,255,0.02); }
.asset-name { font-weight: bold; font-size: 16px; }
.health-badge { font-size: 18px; }
.verdict {
  color: var(--fg); font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.verdict.skip { color: var(--skip); }
.verdict.wait { color: var(--warn); }
.verdict.buy { color: var(--bull); }
.verdict.sell { color: var(--bear); }
.setup { color: var(--neutral); font-size: 11px; }
.grade { color: var(--neutral); font-size: 12px; text-align: center; }
.grade.a { color: var(--bull); font-weight: bold; }
.grade.b { color: var(--info); }
.grade.c { color: var(--warn); }
.freshness { font-size: 10px; color: var(--neutral); text-align: right; }
.freshness.stale { color: var(--warn); }
.freshness.very-stale { color: var(--bear); }
.toggle { color: var(--neutral); }

.card-body { padding: 8px 12px; }

.divergence-line {
  font-size: 12px; color: var(--neutral);
  margin: 4px 0; font-style: italic;
}

.tape {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  font-size: 13px;
  padding: 6px 0;
}
.tape span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tape .q.q0 { color: var(--skip); }
.tape .q.q80 { color: var(--bull); font-weight: bold; }

.section { margin: 8px 0; padding: 8px 0; border-top: 1px solid var(--border); }
.section-title { font-weight: bold; color: var(--neutral); font-size: 11px; text-transform: uppercase; margin-bottom: 4px; }

.kio-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.kio-table th, .kio-table td { padding: 3px 6px; border-bottom: 1px solid var(--border); text-align: left; }
.kio-table th { color: var(--neutral); font-weight: 500; }
.kio-table td.phase.bull { color: var(--bull); }
.kio-table td.phase.bear { color: var(--bear); }

.mtf-tally { font-size: 12px; color: var(--neutral); margin-top: 4px; }

.candle-name { font-weight: 500; }
.candle-meta { color: var(--neutral); font-size: 11px; }
.candle-interp { font-size: 12px; color: var(--neutral); padding: 4px 0; line-height: 1.4; }
.candle-action { font-size: 13px; font-weight: 500; color: var(--info); }
.confirms { display: flex; flex-wrap: wrap; gap: 4px 8px; font-size: 11px; color: var(--bull); margin-top: 4px; }

.delta-class { padding: 4px 0; }

.fvg-zone {
  font-size: 12px; padding: 3px 0;
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
}
.fvg-zone.bull { color: var(--bull); }
.fvg-zone.bear { color: var(--bear); }
.fvg-zone .status { color: var(--info); font-weight: bold; margin-left: 6px; }

.structure { font-size: 12px; }
.structure-line { padding: 2px 0; }
.structure .price-pos { font-weight: bold; }
.structure .price-pos.inside { color: var(--info); }
.structure .price-pos.outside { color: var(--warn); }

.rd-line { font-size: 12px; padding: 2px 0; }
.rd-line.bull { color: var(--bull); }
.rd-line.bear { color: var(--bear); }
.rd-meaning { font-size: 11px; color: var(--neutral); padding: 2px 0; }

.hint { text-align: center; color: var(--muted); font-size: 11px; padding: 6px 0; }

#ftr {
  display: flex; justify-content: space-between;
  padding: 6px 12px;
  border-top: 1px solid var(--border);
  font-size: 11px; color: var(--neutral);
  background: var(--bg);
}
#connection-status.green { color: var(--bull); }
#connection-status.red { color: var(--bear); }

/* Z Fold 6 unfolded — 7.6" main display ≈ 904 CSS px wide */
@media (min-width: 800px) {
  main { columns: 2; column-gap: 12px; padding: 12px; }
  .card { break-inside: avoid; }
  .card-hdr { grid-template-columns: 80px 30px 1fr 100px 60px 80px 20px; }
}

/* Cover display tight layout — Z Fold 6 cover ≈ 6.3" */
@media (max-width: 480px) {
  .card-hdr { grid-template-columns: 50px 22px 1fr 50px 20px; }
  .setup, .grade { display: none; }
  .tape { grid-template-columns: repeat(2, 1fr); font-size: 11px; }
  .kio-table { font-size: 10px; }
  .kio-table th, .kio-table td { padding: 2px 4px; }
}

/* Offline state */
.offline #cards-container { opacity: 0.7; }
#offline-banner {
  background: var(--bear); color: white;
  padding: 8px; text-align: center;
  font-weight: bold; font-size: 12px;
}

/* _CHARTWIRE_SYNCING_CHIP_2026_05_30 — small "🔄 syncing" pill shown
   during in-flight fetch (resume-on-foreground UX). Hidden by default
   to avoid flashing on every 15s background poll. */
#syncing-chip {
  position: fixed;
  top: 10px;
  right: 10px;
  background: linear-gradient(135deg, rgba(212,175,55,0.15) 0%, rgba(124,58,237,0.25) 100%);
  color: var(--fg);
  border: 1px solid rgba(212, 175, 55, 0.4);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 180ms ease, transform 180ms ease;
  pointer-events: none;
  z-index: 9999;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}
#syncing-chip.visible {
  opacity: 1;
  transform: translateY(0);
}

/* _CHARTWIRE_PUSH_WIRE_2026_05_30 — in-page alert toast */
#alert-toast {
  position: fixed;
  top: 50px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  background: linear-gradient(135deg, var(--royal-gold-soft) 0%, var(--royal-purple-soft) 100%), var(--card-bg);
  border: 2px solid var(--royal-gold);
  border-radius: 8px;
  padding: 10px 16px;
  max-width: 90vw;
  min-width: 280px;
  font-size: 13px;
  color: var(--fg);
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms ease, transform 220ms ease;
  z-index: 10000;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5), 0 0 0 1px rgba(212,175,55,0.4);
}
#alert-toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
#alert-toast.critical {
  border-color: var(--bear);
  box-shadow: 0 8px 24px rgba(0,0,0,0.5), 0 0 16px var(--bear);
}

/* _CONSOLIDATION_BADGE_2026_05_30 — 📦 CONS. chip in card header.
 * _CONSOLIDATION_BADGE_FIT_TO_CARD_2026_05_30 — rides INSIDE the
 * 60px grade grid cell as `.grade.consol-badge` so it doesn't add
 * an 8th element to the 7-column header grid (which was bleeding
 * text into the push countdown). Short text + tight padding fits
 * the 60px column on Z Fold 6 inner display (904 CSS px wide).
 * justify-self:center keeps it centered like the regular grade slot.
 */
.consol-badge,
.grade.consol-badge {
  background: linear-gradient(135deg, rgba(212,175,55,0.22) 0%, rgba(124,58,237,0.28) 100%);
  border: 1px solid rgba(212,175,55,0.55);
  color: var(--fg);
  padding: 1px 4px;
  border-radius: 4px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: clip;
  text-align: center;
  justify-self: center;
  text-shadow: 0 0 4px rgba(212,175,55,0.35);
  max-width: 100%;
}
/* Cover/narrow display: keep badge visible even though plain `.grade`
 * is hidden — surface USR consolidation status on small screens too.
 */
@media (max-width: 480px) {
  .grade.consol-badge { display: inline-block !important; font-size: 8.5px; padding: 1px 3px; }
}

/* _CHARTWIRE_STYLE_PARITY_2026_05_30 — additions for parity fix */
.dim { color: var(--muted); font-size: 11px; }
.closed-banner {
  background: rgba(148, 163, 184, 0.08);
  border-left: 3px solid var(--neutral);
  padding: 6px 8px;
  font-size: 12px;
  color: var(--fg);
}
.freshness.closed {
  background: rgba(148, 163, 184, 0.12);
  color: var(--neutral);
  padding: 1px 6px;
  border-radius: 4px;
  font-weight: 500;
}
.freshness.fresh { color: var(--bull); }
.q-na { color: var(--muted); }
.usr-off {
  color: var(--muted); font-size: 10px;
  background: rgba(107, 114, 128, 0.15);
  padding: 1px 6px; border-radius: 3px;
}
.usr-trade {
  border-left: 3px solid var(--info);
  padding-left: 8px;
}
.usr-trade .section-title { color: var(--info); }
.trade-line { padding: 2px 0; font-size: 12px; }
.trade-src {
  background: rgba(96, 165, 250, 0.12);
  color: var(--info);
  padding: 1px 6px; border-radius: 3px;
  font-size: 10px; margin-left: 4px;
}
.dir-buy { color: var(--bull); font-weight: 600; }
.dir-sell { color: var(--bear); font-weight: 600; }

/* Tape full-name labels + Q tier coloring (chart MAS Elite band) */
.tape .lbl { color: var(--neutral); font-size: 10px; margin-right: 3px; }
.q.full { color: var(--bull); font-weight: 600; }
.q.three-quarter { color: var(--bull); }
.q.half { color: var(--info); }
.q.quarter { color: var(--warn); }
.q.skip { color: var(--skip); }

/* Verdict header chip — EXECUTE / WAIT / SKIP / CLOSED */
.verdict.execute { color: var(--bull); font-weight: 700; }
.verdict.wait { color: var(--warn); }
.verdict.skip { color: var(--skip); }
.verdict.closed { color: var(--neutral); }

/* Delta Class — chart-identical 🧬 banner + → action */
.delta-class-section {
  border-left: 3px solid var(--neutral);
  padding-left: 8px;
}
.delta-class-section.bull { border-left-color: var(--bull); }
.delta-class-section.bear { border-left-color: var(--bear); }
.delta-class-section.mixed { border-left-color: var(--warn); }
.delta-banner { font-size: 13px; font-weight: 600; padding: 2px 0; }
.delta-action {
  font-size: 12px; color: var(--neutral);
  padding-left: 14px; padding-top: 2px;
}
.delta-class-section.bull .delta-banner { color: var(--bull); }
.delta-class-section.bear .delta-banner { color: var(--bear); }
.delta-class-section.mixed .delta-banner { color: var(--warn); }

/* _CHARTWIRE_HIDE_THEME_KEY_2026_05_30 — Sam directive: hide moon (theme
   toggle) and key (admin FAB). Admin minting now via /link Telegram cmd. */
#theme-toggle,
.admin-fab,
#admin-fab,
button.admin-fab,
[id*="admin-fab"] { display: none !important; }

/* _CHARTWIRE_ROYAL_THEME_2026_05_30 — Sam directive: "gold and purple
   tile background ... royal elite look". Subtle, doesn't sacrifice
   readability. Only fires on default dark theme; OLED/light themes
   keep their own minimal aesthetic. */
:root {
  --royal-gold: #d4af37;
  --royal-gold-soft: rgba(212, 175, 55, 0.08);
  --royal-purple: #7c3aed;
  --royal-purple-soft: rgba(124, 58, 237, 0.12);
  --royal-accent: rgba(212, 175, 55, 0.35);
}
body.theme-dark {
  background:
    radial-gradient(ellipse at top left, var(--royal-purple-soft) 0%, transparent 45%),
    radial-gradient(ellipse at bottom right, var(--royal-gold-soft) 0%, transparent 50%),
    var(--bg);
  background-attachment: fixed;
}
body.theme-dark .card {
  background:
    linear-gradient(135deg, rgba(124, 58, 237, 0.04) 0%, transparent 30%, rgba(212, 175, 55, 0.04) 100%),
    var(--card-bg);
  border: 1px solid var(--border);
  border-top: 1px solid rgba(212, 175, 55, 0.18);
  border-left: 1px solid rgba(124, 58, 237, 0.18);
  box-shadow:
    0 1px 0 rgba(212, 175, 55, 0.06) inset,
    0 8px 24px rgba(0, 0, 0, 0.4),
    0 0 0 1px rgba(124, 58, 237, 0.03);
  transition: border-color 180ms ease, box-shadow 180ms ease;
}
body.theme-dark .card:hover {
  border-top-color: rgba(212, 175, 55, 0.35);
  border-left-color: rgba(124, 58, 237, 0.32);
  box-shadow:
    0 1px 0 rgba(212, 175, 55, 0.12) inset,
    0 12px 32px rgba(0, 0, 0, 0.5),
    0 0 0 1px rgba(212, 175, 55, 0.12);
}
body.theme-dark .card.expanded {
  border-top: 1px solid var(--royal-accent);
}
body.theme-dark #hdr {
  background:
    linear-gradient(90deg, rgba(124, 58, 237, 0.10) 0%, rgba(212, 175, 55, 0.06) 100%),
    var(--bg);
  border-bottom: 1px solid rgba(212, 175, 55, 0.18);
}
body.theme-dark #hdr .brand {
  background: linear-gradient(90deg, #d4af37 0%, #fbbf24 50%, #7c3aed 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-weight: 700;
}
body.theme-dark #ftr {
  background:
    linear-gradient(90deg, rgba(212, 175, 55, 0.04) 0%, rgba(124, 58, 237, 0.06) 100%),
    var(--bg);
  border-top: 1px solid rgba(124, 58, 237, 0.15);
}

/* Candle Telegram-formatted block */
.candle-tg {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  white-space: pre-wrap;
  margin: 0;
  padding: 6px 8px;
  background: rgba(255, 255, 255, 0.02);
  border-radius: 4px;
  color: var(--fg);
  line-height: 1.45;
}
