/* Groma Intelligence — design system */

:root {
  /* brand */
  --slate-900: #0a0f15;
  --slate-800: #12171f;
  --slate-700: #1a2332;
  --slate-500: #56647a;
  --slate-400: #7b8699;
  --slate-300: #aab3c2;
  --slate-200: #d0d6df;
  --slate-100: #e7ebf1;
  --slate-50:  #f3f5f8;

  --paper: #faf8f3;
  --paper-2: #f3ede1;
  --paper-3: #e6e1d4;

  --teal-900: #08604f;
  --teal-700: #0d7c66;
  --teal-500: #1aa088;
  --teal-50:  #dff1ec;

  --gold-900: #064e3b;
  --gold-700: #047857;
  --gold-500: #059669;
  --gold-300: #34d399;
  --gold-50:  #ecfdf5;

  --rose: #b4413a;
  --rose-50: #f7e8e6;

  /* type */
  --font-serif: Georgia, 'Times New Roman', serif;
  --font-sans:  Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono:  'JetBrains Mono', 'SF Mono', Consolas, monospace;

  /* radii + shadow */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 20px;
  --sh-1: 0 1px 2px rgba(15,23,32,0.06), 0 1px 3px rgba(15,23,32,0.04);
  --sh-2: 0 4px 12px rgba(15,23,32,0.08);
  --sh-3: 0 12px 32px rgba(15,23,32,0.10);
  --sh-4: 0 24px 56px rgba(15,23,32,0.16);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-sans);
  color: var(--slate-800);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-size: 14px;
  line-height: 1.5;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

/* ═══════════════════════════════════════════════════════════
   APP SHELL — platform layout
   ═══════════════════════════════════════════════════════════ */
.app {
  display: grid;
  grid-template-columns: 64px 1fr;
  grid-template-rows: 56px 1fr;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

/* Left rail */
.rail {
  grid-row: 1 / -1;
  background: var(--slate-800);
  color: var(--paper);
  display: flex; flex-direction: column;
  align-items: center;
  padding: 12px 0;
  gap: 2px;
  border-right: 1px solid var(--slate-700);
}
.rail-logo {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  margin-bottom: 10px;
}
.rail-btn {
  width: 44px; height: 44px;
  border-radius: 10px;
  background: transparent;
  border: 0;
  color: var(--slate-300);
  display: grid; place-items: center;
  cursor: pointer;
  position: relative;
  transition: background 120ms, color 120ms;
}
.rail-btn:hover { background: rgba(255,255,255,0.05); color: var(--paper); }
.rail-btn.active {
  background: rgba(196,154,60,0.18);
  color: var(--gold-500);
}
.rail-btn.active::before {
  content: "";
  position: absolute; left: -12px; top: 10px; bottom: 10px;
  width: 3px; border-radius: 2px;
  background: var(--gold-500);
}
.rail-btn-label {
  position: absolute;
  left: calc(100% + 8px);
  top: 50%; transform: translateY(-50%);
  background: var(--slate-900);
  color: var(--paper);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  white-space: nowrap;
  opacity: 0; pointer-events: none;
  transition: opacity 120ms;
  z-index: 100;
}
.rail-btn:hover .rail-btn-label { opacity: 1; }
.rail-spacer { flex: 1; }

/* Topbar */
.topbar {
  grid-column: 2 / -1;
  background: var(--paper);
  border-bottom: 1px solid var(--paper-3);
  display: flex; align-items: center;
  padding: 0 20px;
  gap: 16px;
}
.top-crumbs {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--slate-500);
}
.top-crumbs strong { color: var(--slate-800); font-weight: 600; }
.top-crumbs svg { color: var(--slate-300); }
.top-spacer { flex: 1; }
.top-search {
  display: flex; align-items: center; gap: 8px;
  background: var(--paper-2);
  border: 1px solid var(--paper-3);
  border-radius: 20px;
  padding: 7px 14px;
  width: 320px;
  font-size: 13px;
  color: var(--slate-500);
}
.top-search input {
  border: 0; background: transparent; outline: none;
  flex: 1; font-size: 13px; color: var(--slate-800);
  font-family: inherit;
}
.top-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px;
  border-radius: 8px;
  font-size: 13px; font-weight: 600;
  border: 1px solid var(--paper-3);
  background: var(--paper);
  color: var(--slate-800); cursor: pointer;
}
.top-btn:hover { background: var(--paper-2); }
.top-btn.primary { background: var(--slate-800); color: var(--paper); border-color: var(--slate-800); }
.top-btn.primary:hover { background: var(--slate-900); }

/* Main */
.main {
  grid-column: 2 / -1;
  grid-row: 2 / -1;
  overflow: hidden;
  display: grid;
  position: relative;
}

/* ═══════════════════════════════════════════════════════════
   DASHBOARD — map + right panel
   ═══════════════════════════════════════════════════════════ */
.dash {
  display: grid;
  grid-template-columns: 1fr 400px;
  height: 100%;
  overflow: hidden;
}
.dash-map { position: relative; overflow: hidden; background: #e7ebf1; }
.dash-panel {
  background: var(--paper);
  border-left: 1px solid var(--paper-3);
  overflow-y: auto;
  padding: 24px;
}

/* Map chrome */
.map-chrome-tl {
  position: absolute; top: 16px; left: 16px;
  display: flex; gap: 6px; z-index: 10;
}
.map-chip {
  padding: 7px 14px;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(15,23,32,0.08);
  border-radius: 20px;
  font-size: 12px; font-weight: 600;
  color: var(--slate-700);
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
}
.map-chip.active {
  background: var(--slate-800);
  color: var(--paper);
  border-color: var(--slate-800);
}
.map-chip-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: currentColor;
}
.map-chrome-br {
  position: absolute; bottom: 16px; right: 16px;
  background: rgba(15,23,32,0.85);
  backdrop-filter: blur(8px);
  color: var(--paper);
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 11px;
  display: flex; gap: 18px;
  z-index: 10;
}
.map-legend-item { display: flex; align-items: center; gap: 6px; }
.map-legend-swatch { width: 8px; height: 8px; border-radius: 50%; }

/* Panel */
.panel-section { margin-bottom: 28px; }
.panel-label {
  font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--slate-500); margin-bottom: 10px;
}
.panel-title {
  font-family: var(--font-serif);
  font-size: 22px;
  color: var(--slate-800);
  letter-spacing: -0.01em;
  line-height: 1.2;
  margin: 0 0 6px;
}
.panel-sub { font-size: 13px; color: var(--slate-500); margin-bottom: 18px; }

.kpi-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
  margin-bottom: 20px;
}
.kpi {
  background: var(--paper-2);
  border: 1px solid var(--paper-3);
  border-radius: 10px;
  padding: 14px;
}
.kpi-label { font-size: 11px; color: var(--slate-500); margin-bottom: 6px; }
.kpi-value {
  font-family: var(--font-serif);
  font-size: 24px;
  color: var(--slate-800);
  letter-spacing: -0.01em; line-height: 1;
}
.kpi-delta { font-family: var(--font-mono); font-size: 11px; color: var(--teal-700); font-weight: 600; margin-top: 4px; }
.kpi-delta.down { color: var(--rose); }

.row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 0;
  border-bottom: 1px dashed var(--paper-3);
  font-size: 13px;
}
.row:last-child { border-bottom: 0; }
.row span { color: var(--slate-500); }
.row strong { font-family: var(--font-mono); font-weight: 500; color: var(--slate-800); }

.bar-row {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 10px;
  font-size: 12px;
}
.bar-row-label { width: 90px; color: var(--slate-700); }
.bar-row-track { flex: 1; height: 8px; background: var(--slate-100); border-radius: 4px; overflow: hidden; }
.bar-row-fill { height: 100%; border-radius: 4px; }
.bar-row-val { width: 44px; text-align: right; font-family: var(--font-mono); font-size: 11px; color: var(--slate-800); }

/* ═══════════════════════════════════════════════════════════
   AVM wizard
   ═══════════════════════════════════════════════════════════ */
.avm-wrap {
  display: grid;
  grid-template-columns: 1fr 380px;
  height: 100%;
}
.avm-body { padding: 32px 40px; overflow-y: auto; }
.avm-side {
  background: var(--paper-2);
  border-left: 1px solid var(--paper-3);
  padding: 28px;
  overflow-y: auto;
}
.avm-steps {
  display: flex; gap: 4px;
  margin-bottom: 32px;
  max-width: 800px;
}
.avm-step {
  flex: 1; padding: 16px 18px;
  background: var(--paper-2);
  border-radius: 10px;
  border: 1px solid var(--paper-3);
  display: flex; align-items: center; gap: 10px;
  font-size: 12px; color: var(--slate-500);
  cursor: pointer;
}
.avm-step.active {
  background: var(--slate-800); color: var(--paper); border-color: var(--slate-800);
}
.avm-step.done {
  background: var(--teal-50); color: var(--teal-700); border-color: var(--teal-500);
}
.avm-step-num {
  width: 22px; height: 22px; border-radius: 50%;
  background: currentColor; opacity: 0.2;
  display: grid; place-items: center;
  font-size: 11px; font-weight: 700;
}
.avm-step.active .avm-step-num { background: var(--gold-500); opacity: 1; color: var(--slate-800); }
.avm-step.done .avm-step-num { background: var(--teal-700); opacity: 1; color: var(--paper); }

.avm-h { font-family: var(--font-serif); font-size: 32px; color: var(--slate-800); margin: 0 0 6px; letter-spacing: -0.02em; }
.avm-sub { font-size: 15px; color: var(--slate-500); margin-bottom: 28px; max-width: 600px; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 18px; max-width: 520px; }
.field label { font-size: 12px; font-weight: 600; color: var(--slate-700); }
.field input, .field select {
  padding: 11px 14px;
  background: var(--paper);
  border: 1px solid var(--paper-3);
  border-radius: 8px;
  font-size: 14px; color: var(--slate-800);
  outline: none; font-family: inherit;
}
.field input:focus, .field select:focus { border-color: var(--teal-700); box-shadow: 0 0 0 3px rgba(13,124,102,0.12); }
.field-row { display: flex; gap: 12px; }
.field-row .field { flex: 1; }

.chip-row { display: flex; gap: 8px; flex-wrap: wrap; }
.chip-pick {
  padding: 8px 14px; border-radius: 20px;
  background: var(--paper); border: 1px solid var(--paper-3);
  font-size: 13px; color: var(--slate-700);
  cursor: pointer; font-family: inherit;
}
.chip-pick.active { background: var(--slate-800); color: var(--paper); border-color: var(--slate-800); }

.avm-result {
  background: linear-gradient(135deg, var(--slate-800), var(--slate-700));
  color: var(--paper);
  border-radius: 16px;
  padding: 28px;
  margin-top: 24px;
  max-width: 620px;
}
.avm-result-value {
  font-family: var(--font-serif);
  font-size: 52px;
  letter-spacing: -0.02em;
  line-height: 1;
  margin: 12px 0 8px;
}
.avm-result-conf {
  font-family: var(--font-mono);
  color: var(--gold-500);
  font-size: 13px;
}

/* ═══════════════════════════════════════════════════════════
   TABLES (portfolio)
   ═══════════════════════════════════════════════════════════ */
.pf-wrap { padding: 24px 32px; overflow-y: auto; height: 100%; }
.pf-head { display: flex; align-items: center; gap: 16px; margin-bottom: 24px; }
.pf-head h1 {
  font-family: var(--font-serif);
  font-size: 30px; margin: 0;
  letter-spacing: -0.02em;
  color: var(--slate-800);
}
.pf-head-spacer { flex: 1; }

.pf-stats {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px;
  margin-bottom: 24px;
}
.pf-stat {
  background: var(--paper);
  border: 1px solid var(--paper-3);
  border-radius: 12px;
  padding: 18px 20px;
}
.pf-stat-label { font-size: 11px; color: var(--slate-500); text-transform: uppercase; letter-spacing: 0.08em; font-weight: 600; margin-bottom: 8px; }
.pf-stat-value { font-family: var(--font-serif); font-size: 28px; letter-spacing: -0.02em; color: var(--slate-800); line-height: 1; }
.pf-stat-delta { font-family: var(--font-mono); font-size: 11px; color: var(--teal-700); font-weight: 600; margin-top: 6px; }
.pf-stat-delta.down { color: var(--rose); }

.pf-table {
  width: 100%;
  background: var(--paper);
  border: 1px solid var(--paper-3);
  border-radius: 12px;
  border-collapse: collapse;
  overflow: hidden;
}
.pf-table th {
  text-align: left;
  padding: 12px 16px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--slate-500);
  background: var(--paper-2);
  border-bottom: 1px solid var(--paper-3);
  font-weight: 600;
}
.pf-table td {
  padding: 14px 16px;
  font-size: 13px;
  color: var(--slate-700);
  border-bottom: 1px solid var(--paper-3);
}
.pf-table tr:last-child td { border-bottom: 0; }
.pf-table tr:hover td { background: var(--paper-2); }
.pf-table .num { font-family: var(--font-mono); color: var(--slate-800); }
.pf-badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px;
  border-radius: 12px;
  font-size: 11px; font-weight: 600;
}
.pf-badge-dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.pf-badge.ok { background: var(--teal-50); color: var(--teal-700); }
.pf-badge.warn { background: var(--gold-50); color: var(--gold-900); }
.pf-badge.risk { background: var(--rose-50); color: var(--rose); }

/* Generic section wrap for views */
.view { padding: 28px 40px; overflow-y: auto; height: 100%; }
.view h1 { font-family: var(--font-serif); font-size: 32px; margin: 0 0 8px; letter-spacing: -0.02em; color: var(--slate-800); }
.view-sub { font-size: 15px; color: var(--slate-500); margin-bottom: 24px; max-width: 620px; }

/* Cards grid */
.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.card {
  background: var(--paper);
  border: 1px solid var(--paper-3);
  border-radius: 12px;
  padding: 20px;
}
.card h3 { font-family: var(--font-serif); font-size: 18px; margin: 0 0 6px; letter-spacing: -0.01em; color: var(--slate-800); font-weight: 400; }
.card p { font-size: 13px; color: var(--slate-500); margin: 0 0 14px; line-height: 1.55; }

.subject-card {
  background: var(--paper);
  border: 1px solid var(--paper-3);
  border-radius: 14px;
  padding: 20px;
  margin-bottom: 20px;
}
.subject-addr { font-size: 12px; color: var(--slate-500); margin-bottom: 4px; }
.subject-name { font-family: var(--font-serif); font-size: 20px; color: var(--slate-800); margin-bottom: 16px; letter-spacing: -0.01em; }
.subject-value { font-family: var(--font-serif); font-size: 40px; letter-spacing: -0.02em; color: var(--slate-800); line-height: 1; margin-bottom: 6px; }
.subject-delta { font-family: var(--font-mono); font-size: 12px; color: var(--teal-700); font-weight: 600; margin-bottom: 16px; }
