/* =============================================================
   MMI Dashboard — style.css
   Dark charcoal / navy / amber professional financial theme
   ============================================================= */

/* ── Variables ──────────────────────────────────────────────── */
:root {
  --bg:         #0f172a;
  --surface:    #1e293b;
  --surface-2:  #263449;
  --navy:       #1e3a5f;
  --amber:      #f59e0b;
  --text:       #f1f5f9;
  --text-muted: #94a3b8;
  --border:     #334155;
  --green:      #16a34a;
  --red:        #dc2626;
  --orange:     #f97316;
  --yellow:     #ca8a04;
  --radius:     10px;
  --shadow:     0 4px 16px rgba(0,0,0,.35);
}

/* ── Reset ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
  line-height: 1.5;
  min-height: 100vh;
}

/* ── Container ───────────────────────────────────────────────── */
.container {
  max-width: 920px;
  margin: 0 auto;
  padding: 0 16px;
}

/* ── Header ──────────────────────────────────────────────────── */
header {
  background: var(--navy);
  border-bottom: 1px solid var(--border);
  padding: 12px 0;
  position: sticky;
  top: 0;
  z-index: 200;
  backdrop-filter: blur(8px);
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-logo {
  font-size: 1.05rem;
  font-weight: 700;
  white-space: nowrap;
  color: var(--text);
}

.header-title {
  flex: 1;
  text-align: center;
  font-size: .75rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.5px;
}

.header-updated {
  font-size: .72rem;
  color: var(--text-muted);
  white-space: nowrap;
  text-align: right;
}

/* ── Cards ───────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
}

.card-label {
  font-size: .68rem;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-muted);
  margin-bottom: 6px;
  font-weight: 600;
}

.card-value {
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

.card-sub {
  font-size: .72rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ── Section spacing ─────────────────────────────────────────── */
section { margin-bottom: 14px; }

.section-title {
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-muted);
  font-weight: 700;
  margin-bottom: 10px;
}

/* ── Grids ───────────────────────────────────────────────────── */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
}

/* ── Hero ────────────────────────────────────────────────────── */
.hero {
  text-align: center;
  padding: 28px 0 20px;
}

#mmi-gauge {
  display: flex;
  justify-content: center;
  margin-bottom: 16px;
}

#mmi-gauge svg {
  width: 100%;
  max-width: 300px;
  height: auto;
  display: block;
}

.signal-badge {
  display: inline-block;
  padding: 9px 32px;
  border-radius: 50px;
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: 2.5px;
  color: #fff;
  margin-bottom: 12px;
  text-shadow: 0 1px 3px rgba(0,0,0,.3);
  transition: background .4s, color .4s;
}

.signal-action {
  font-size: .88rem;
  color: var(--text-muted);
  max-width: 500px;
  margin: 0 auto;
  line-height: 1.65;
}

/* ── Index Row ───────────────────────────────────────────────── */
/* uses .grid-2 */

/* ── Sub-Indicators ──────────────────────────────────────────── */
/* uses .grid-3 */

/* ── Momentum Bar ────────────────────────────────────────────── */
.momentum-section .card-value {
  font-size: 1.3rem;
}

.delta-up   { color: var(--green) !important; }
.delta-down { color: var(--red)   !important; }
.delta-flat { color: var(--text-muted) !important; }

/* ── Analysis Card ───────────────────────────────────────────── */
#analysis-card .card {
  border-left: 4px solid var(--amber);
  transition: border-color .4s;
}

.analysis-text {
  font-size: .9rem;
  color: var(--text-muted);
  line-height: 1.8;
}

/* ── Chart ───────────────────────────────────────────────────── */
.chart-wrapper {
  position: relative;
  height: 280px;
  margin-top: 4px;
}

/* ── History Table ───────────────────────────────────────────── */
.table-section { margin-bottom: 0; }

.table-wrapper {
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  font-size: .84rem;
  min-width: 520px;
}

thead th {
  padding: 11px 14px;
  text-align: left;
  font-size: .67rem;
  text-transform: uppercase;
  letter-spacing: 1.1px;
  color: var(--text-muted);
  font-weight: 700;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  white-space: nowrap;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td      { background: var(--surface-2); }

.mmi-cell { font-weight: 700; }

.zone-badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 4px;
  font-size: .69rem;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: .5px;
}

/* ── Error Banner ────────────────────────────────────────────── */
.error-banner {
  background: rgba(220,38,38,.12);
  border: 1px solid rgba(220,38,38,.5);
  border-radius: var(--radius);
  padding: 11px 16px;
  font-size: .84rem;
  color: #fca5a5;
  margin: 16px 0 4px;
}

/* ── Loading spinner ─────────────────────────────────────────── */
#loading-overlay {
  text-align: center;
  padding: 80px 20px;
}

.spinner {
  width: 38px;
  height: 38px;
  border: 3px solid var(--surface-2);
  border-top-color: var(--amber);
  border-radius: 50%;
  animation: spin .75s linear infinite;
  margin: 0 auto 14px;
}

@keyframes spin { to { transform: rotate(360deg); } }

#loading-overlay p {
  color: var(--text-muted);
  font-size: .88rem;
}

/* ── Footer ──────────────────────────────────────────────────── */
footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 20px 0;
  margin-top: 32px;
  text-align: center;
}

footer p {
  font-size: .78rem;
  color: var(--text-muted);
}

footer a {
  color: var(--amber);
  text-decoration: none;
}

footer a:hover { text-decoration: underline; }

/* ── Main content (hidden until data ready) ──────────────────── */
#main-content { display: none; }

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 640px) {
  .grid-2 { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr 1fr; }
  .header-title { display: none; }
  .card-value { font-size: 1.2rem; }
  .signal-badge { font-size: .95rem; padding: 8px 22px; }
}

@media (max-width: 420px) {
  .grid-3 { grid-template-columns: 1fr; }
}
