/* Ported from crypto-dashboard/css/dashboard.css (M3, 2026-07-12) with
   crypto-specific component classes stripped (news, watchlist, degen, trades,
   cycle tables, movers, ETF, DCA calculator) and this repo's enum pill classes
   added (quadrant / theme status / OW-N-UW / DCA verdicts — BUILD-SPEC §6).
   Panel JS and this file are one unit — change together (ARCHITECTURE §7.8). */

/* ── ROOT CONTAINMENT ── */
/* No overflow on html/body — any overflow value (even clip) on the root can break
   position:sticky in Safari/iOS. Overflow is contained inside .content instead. */

:root {
  --navy:       #0f1f35;
  --slate:      #1a2e47;
  --green:      #22c55e;
  --red:        #ef4444;
  --amber:      #f59e0b;
  --body:       #cbd5e1;
  --muted:      #94a3b8;
  --lgrey:      #1a2d42;
  --divider:    #243447;
  --white:      #f1f5f9;
  --pale-green: #86efac;
  --pale-blue:  #93c5fd;
  --bg:         #0a1628;
  --card:       #111f33;

  /* Alias — referenced by macro.js (M4 port from crypto-dashboard, which
     defines this alias in its own :root). Mapped onto --divider; no new
     colour introduced. Missed in the initial M3 CSS strip; added in M4
     when the port surfaced the dependency. */
  --border:     var(--divider);

  --radius:     10px;
  --shadow:     0 1px 6px rgba(0,0,0,0.4);
  --header-h:   41px;   /* 10px padding + 21px line-height + 10px padding */
  --tabs-h:     40px;   /* 10px padding + 18px line-height + 10px padding + 2px border */
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--body);
  font-size: 14px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  /* NO overflow-x here — would break position:sticky */
}

#app { flex: 1; display: flex; flex-direction: column; min-width: 0; width: 100%; }

/* ── HEADER ── */
.header {
  background: var(--navy);
  color: white;
  padding: 10px 16px;
  height: var(--header-h);
  display: flex;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 12px rgba(0,0,0,0.5);
  border-bottom: 1px solid var(--divider);
  width: 100%;
  box-sizing: border-box;
  overflow: hidden;
}
.header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  width: 100%;
}
.header-left { min-width: 0; }
.header h1 {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .5px;
  color: var(--white);
  white-space: nowrap;
  line-height: 1;
}
.header-right {
  font-size: 11px;
  white-space: nowrap;
  flex-shrink: 0;
  text-align: right;
  color: var(--muted);
}

/* ── TABS ── */
.tabs {
  display: flex;
  overflow-x: auto;
  background: var(--slate);
  padding: 0 12px;
  gap: 2px;
  border-bottom: 1px solid var(--divider);
  position: sticky;
  top: var(--header-h);
  z-index: 99;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  width: 100%;
  box-sizing: border-box;
}
.tabs::-webkit-scrollbar { display: none; }
.tabs button {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 10px 14px;
  font-size: 12px;
  font-weight: 500;
  color: #94a3b8;
  cursor: pointer;
  white-space: nowrap;
  transition: color .15s, border-color .15s;
  -webkit-tap-highlight-color: transparent;
  flex-shrink: 0;
}
.tabs button.active { color: var(--white); border-bottom-color: var(--pale-green); }
.tabs button:hover:not(.active) { color: var(--body); }

/* ── LAYOUT ── */
.content {
  max-width: 960px;
  margin: 0 auto;
  padding: 16px 12px 40px;
  flex: 1;
  min-width: 0;          /* prevent flex item expanding beyond viewport */
  overflow-x: hidden;    /* clip overflow — hidden (not clip) creates a real BFC */
  width: 100%;
  box-sizing: border-box;
}
.panel { display: none; }
.panel.active { display: block; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 14px; }

@media(max-width:600px) {
  .grid2, .grid3, .grid4 { grid-template-columns: 1fr 1fr; }
}
@media(max-width:400px) {
  .grid2, .grid3, .grid4 { grid-template-columns: 1fr; }
}

/* ── CARDS ── */
.card {
  background: var(--card);
  border: 1px solid var(--divider);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
  margin-bottom: 14px;
}
.card-title {
  font-size: 10px;
  font-weight: 700;
  color: #7dd3fc;
  text-transform: uppercase;
  letter-spacing: .8px;
  margin-bottom: 10px;
}

/* ── METRIC TILES ── */
.metric { background: var(--lgrey); border: 1px solid var(--divider); border-radius: 8px; padding: 12px; }
.metric .sym { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; margin-bottom: 4px; }
.metric .price { font-size: 20px; font-weight: 700; color: var(--white); }
.metric .chg { font-size: 12px; margin-top: 3px; }
.metric .chg7 { font-size: 11px; color: var(--muted); margin-top: 1px; }

/* ── TABLE ROWS ── */
.row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 7px 0;
  border-bottom: 1px solid var(--divider);
  gap: 8px;
  font-size: 13px;
  flex-wrap: wrap;
}
.row:last-child { border-bottom: none; }
.row .lbl { color: var(--muted); flex-shrink: 0; }
.row .val { font-weight: 600; color: var(--white); text-align: right; }
.row .note { font-size: 11px; color: var(--muted); width: 100%; margin-top: 2px; }

/* ── SIGNAL PILLS ── */
/* Generic pills (macro.js port uses bull/bear/neu/unavail). */
.pill { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.bull { background: rgba(34,197,94,0.2);   color: #4ade80; }
.bear { background: rgba(239,68,68,0.2);   color: #f87171; }
.neu  { background: rgba(148,163,184,0.2); color: #cbd5e1; }
.fade { background: rgba(245,158,11,0.2);  color: #fbbf24; }
.unavail { background: rgba(100,116,139,0.12); color: #64748b; }

/* RRG quadrant badges (sector-history.json `quadrant` enum — D13). */
.quad-leading   { background: rgba(34,197,94,0.2);   color: #4ade80; }
.quad-improving { background: rgba(59,130,246,0.2);  color: #93c5fd; }
.quad-weakening { background: rgba(245,158,11,0.2);  color: #fbbf24; }
.quad-lagging   { background: rgba(239,68,68,0.2);   color: #f87171; }

/* Theme status pills (report `status` enum — BUILD-SPEC §6 tab 2 colors). */
.st-early   { background: rgba(34,197,94,0.2);   color: #4ade80; }
.st-heating { background: rgba(245,158,11,0.2);  color: #fbbf24; }
.st-crowded { background: rgba(251,146,60,0.25); color: #fdba74; }
.st-fading  { background: rgba(239,68,68,0.2);   color: #f87171; }
.st-dormant { background: rgba(148,163,184,0.15); color: #94a3b8; }

/* Sector verdict pills (report OW/N/UW enum — D13). */
.v-ow { background: rgba(34,197,94,0.2);   color: #4ade80; }
.v-n  { background: rgba(148,163,184,0.2); color: #cbd5e1; }
.v-uw { background: rgba(239,68,68,0.2);   color: #f87171; }

/* DCA verdict pills (report ADD_MORE/CONTINUE/SLOW_PACE/PAUSE enum —
   BUILD-SPEC §6 tab 3 colors: green / teal / amber / red). */
.dca-add      { background: rgba(34,197,94,0.2);  color: #4ade80; }
.dca-continue { background: rgba(20,184,166,0.2); color: #2dd4bf; }
.dca-slow     { background: rgba(245,158,11,0.2); color: #fbbf24; }
.dca-pause    { background: rgba(239,68,68,0.2);  color: #f87171; }

/* Momentum labels (sector-history.json `momentum` enum). */
.mom-improving { background: rgba(34,197,94,0.2);  color: #4ade80; }
.mom-fading    { background: rgba(245,158,11,0.2); color: #fbbf24; }

/* ── ACTION PILLS (macro.js port uses action-unavail) ── */
.action-unavail { display: inline-block; padding: 3px 8px; border-radius: 4px; font-size: 11px; font-weight: 700; background: rgba(148,163,184,0.15); color: #64748b; white-space: nowrap; }

/* ── KO BLOCK ── */
.ko { background: rgba(26,45,66,0.9); border-left: 3px solid #3b82f6; border-radius: 0 8px 8px 0; padding: 10px 14px; margin-top: 10px; }
.ko .ko-label { font-size: 10px; font-weight: 700; color: #7dd3fc; text-transform: uppercase; letter-spacing: .5px; margin-bottom: 5px; }
.ko .ko-body  { font-size: 12px; color: #cbd5e1; line-height: 1.7; font-style: italic; }
.ko .ko-bias  { font-size: 12px; font-weight: 700; margin-top: 6px; }

/* ── FLAG ── */
.flag {
  background: rgba(245,158,11,0.12);
  border: 1px solid rgba(245,158,11,0.4);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 12px;
  color: #fcd34d;
  margin-bottom: 10px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  word-break: break-word;
  overflow-wrap: break-word;
  min-width: 0;
}
.flag svg { flex-shrink: 0; margin-top: 1px; }

/* Informational hint — distinct from .flag (amber = problem/warning). Blue =
   FYI only, e.g. Themes tab's "scan pending" notice (BUILD-SPEC §6 tab 2):
   daily momentum has moved since the last weekly narrative, not an error. */
.hint {
  background: rgba(59,130,246,0.10);
  border: 1px solid rgba(59,130,246,0.35);
  border-radius: 8px;
  padding: 7px 12px;
  font-size: 11px;
  color: #93c5fd;
  margin-top: 8px;
  line-height: 1.6;
}

/* ── DATA TABLE (generic; Sectors RRG table in M5) ── */
.data-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; width: 100%; }
.data-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.data-table th {
  background: var(--slate);
  color: #7dd3fc;
  padding: 7px 10px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  border-bottom: 1px solid var(--divider);
  white-space: nowrap;
}
.data-table td { padding: 7px 10px; border-bottom: 1px solid var(--divider); vertical-align: top; color: var(--body); }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: rgba(26,45,66,0.6); }

@media(max-width:500px) {
  .data-table th { font-size: 10px; padding: 6px 8px; }
  .data-table td { font-size: 11px; padding: 6px 8px; }
}

/* ── ABOUT ── */
.about-hero {
  background: linear-gradient(135deg, #0f1f35 0%, #1a2e47 100%);
  border: 1px solid var(--divider);
  border-radius: var(--radius);
  padding: 24px 20px 20px;
  margin-bottom: 16px;
}
.about-hero h2  { font-size: 18px; font-weight: 700; color: var(--white); margin-bottom: 6px; }
.about-hero .sub { font-size: 12px; color: var(--pale-blue); margin-bottom: 14px; }
.about-hero p   { font-size: 13px; color: #cbd5e1; line-height: 1.8; }

@media(max-width:500px) {
  .about-hero { padding: 16px 14px; }
}

.about-section { margin-bottom: 20px; }
.about-section h3 {
  font-size: 11px; font-weight: 700; color: #7dd3fc;
  text-transform: uppercase; letter-spacing: .8px;
  margin-bottom: 10px; padding-bottom: 6px;
  border-bottom: 1px solid var(--divider);
}
.about-tab-grid    { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.about-source-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

@media(max-width:500px) {
  .about-tab-grid    { grid-template-columns: 1fr; }
  .about-source-grid { grid-template-columns: 1fr; }
}

.about-tab-card { background: var(--lgrey); border: 1px solid var(--divider); border-radius: 8px; padding: 12px 14px; }
.about-tab-card .tab-name { font-size: 12px; font-weight: 700; color: var(--pale-green); margin-bottom: 4px; }
.about-tab-card .tab-desc { font-size: 11px; color: #94a3b8; line-height: 1.6; }

.about-source { background: var(--lgrey); border: 1px solid var(--divider); border-radius: 6px; padding: 9px 12px; }
.about-source .src-cat  { font-size: 10px; font-weight: 700; color: #7dd3fc; text-transform: uppercase; letter-spacing: .5px; margin-bottom: 5px; }
.about-source .src-item { font-size: 11px; color: #94a3b8; padding: 2px 0; display: flex; align-items: flex-start; gap: 6px; line-height: 1.5; }
.about-source .src-item::before { content: '\00b7'; color: var(--pale-blue); flex-shrink: 0; }
.about-source .src-name { color: var(--white); font-weight: 600; }

.about-pipeline { display: flex; flex-direction: column; }
.about-step { display: flex; gap: 14px; padding: 10px 0; border-bottom: 1px solid var(--divider); align-items: flex-start; }
.about-step:last-child { border-bottom: none; }
.about-step .step-num {
  background: var(--slate); color: var(--pale-blue); font-size: 11px; font-weight: 700;
  width: 24px; height: 24px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; margin-top: 1px;
}
.about-step .step-body .step-title { font-size: 12px; font-weight: 700; color: var(--white); margin-bottom: 2px; }
.about-step .step-body .step-desc  { font-size: 11px; color: #94a3b8; line-height: 1.6; }

.about-disclaimer {
  background: rgba(245,158,11,0.08); border: 1px solid rgba(245,158,11,0.25);
  border-radius: 8px; padding: 12px 16px; font-size: 11px; color: #94a3b8; line-height: 1.7;
}
.about-disclaimer strong { color: #fbbf24; }

/* ── FOOTER ── */
.footer {
  background: var(--navy); border-top: 1px solid var(--divider);
  padding: 12px 20px; font-size: 10px; color: #64748b;
  text-align: center; line-height: 1.6; margin-top: auto;
  width: 100%;
  box-sizing: border-box;
}

/* ── LOADING / EMPTY STATES ── */
.loading { text-align: center; padding: 60px 20px; color: var(--muted); }
.loading .spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--divider); border-top-color: var(--pale-blue);
  border-radius: 50%; animation: spin .7s linear infinite; margin: 0 auto 16px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.no-chart { text-align: center; padding: 40px 20px; color: var(--muted); font-style: italic; }

.empty-state { text-align: center; padding: 32px 20px; color: var(--muted); }
.empty-state .es-title { font-size: 13px; font-weight: 700; color: var(--body); margin-bottom: 6px; }
.empty-state .es-desc  { font-size: 11px; line-height: 1.7; }

/* Temporary M3 debug dump — removed as panels are built out (M4–M6). */
.debug-pre {
  background: var(--bg); border: 1px dashed var(--divider); border-radius: 8px;
  padding: 10px 12px; font-size: 10px; line-height: 1.5; color: var(--muted);
  overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%;
  white-space: pre;
}

/* ── Data-freshness strip (top of every data panel) ── */
.fresh-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 0 0 14px;
  padding: 7px 12px;
  background: var(--lgrey);
  border: 1px solid var(--divider);
  border-radius: 8px;
}
.fresh-pill {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .02em;
  color: var(--body);
}
.fresh-stamp {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: .01em;
  white-space: nowrap;
}
/* Staleness variants — BUILD-SPEC §6: daily files >3d amber; report >10d stale. */
.fresh-bar.stale { background: rgba(245,158,11,0.10); border-color: rgba(245,158,11,0.4); }
.fresh-bar.stale .fresh-pill,
.fresh-bar.stale .fresh-stamp { color: #fcd34d; }

/* ── SCROLLBAR ── */
::-webkit-scrollbar       { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--slate); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #2d4a6b; }

/* ── GLOBAL MOBILE TWEAKS ── */
@media(max-width:500px) {
  .content { padding: 12px 10px 32px; }
  .card    { padding: 12px 12px; }
}
