/* ==========================================================================
   REGIME, design system (mockup)
   Ciemny fintech, gęsty informacyjnie. Serif do nagłówków (powaga raportu
   analitycznego), mono do liczb (tabular figures), sans do treści.
   ========================================================================== */

:root {
  --bg: #0a0b0f;
  --bg-1: #0d0f14;
  --bg-elevated: #12141b;
  --bg-card: #14161e;
  --bg-card-hover: #181b25;
  --bg-inset: #0c0e13;
  --border: #23262f;
  --border-soft: #1a1c24;
  --border-strong: #33374a;

  --text: #e9eaee;
  --text-dim: #9598a6;
  --text-faint: #5c5f6c;

  --accent: #c9f24b;          /* sygnał / lime, akcja, pozytyw */
  --accent-dim: rgba(201, 242, 75, 0.14);
  --accent-strong: #d9ff5e;

  --info: #6fa8ff;            /* AI / analiza, neutralnie chłodny */
  --info-dim: rgba(111, 168, 255, 0.13);

  --danger: #ff5c6a;
  --danger-dim: rgba(255, 92, 106, 0.14);

  --warning: #ffb454;
  --warning-dim: rgba(255, 180, 84, 0.14);

  --neutral: #9598a6;
  --neutral-dim: rgba(149, 152, 166, 0.12);

  --font-serif: Iowan Old Style, Palatino Linotype, Palatino, Georgia, "Noto Serif", serif;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Mono", "JetBrains Mono", Consolas, "Roboto Mono", monospace;

  --radius-sm: 4px;
  --radius: 8px;
  --radius-lg: 14px;

  --shadow-card: 0 1px 0 rgba(255,255,255,0.02) inset, 0 8px 24px -12px rgba(0,0,0,0.6);
  --shadow-pop: 0 20px 60px -20px rgba(0,0,0,0.7);

  --sidebar-w: 232px;
}

* { box-sizing: border-box; }

html { color-scheme: dark; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  background-image:
    radial-gradient(ellipse 900px 500px at 85% -10%, rgba(111,168,255,0.07), transparent 60%),
    radial-gradient(ellipse 700px 500px at -5% 20%, rgba(201,242,75,0.04), transparent 55%);
  background-attachment: fixed;
}

/* subtle grain overlay for texture without external assets */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 999;
  opacity: 0.025;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='120' height='120'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
}

h1, h2, h3, h4 { font-family: var(--font-serif); font-weight: 600; margin: 0; letter-spacing: 0.2px; }

a { color: inherit; text-decoration: none; }

.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

::selection { background: var(--accent-dim); color: var(--accent-strong); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 8px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: #444a63; }

/* ---------------------------------------------------------------- Layout */

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

.sidebar {
  background: linear-gradient(180deg, var(--bg-1), #0a0b10 60%);
  border-right: 1px solid var(--border-soft);
  padding: 22px 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 6px;
}

.brand-mark {
  width: 30px; height: 30px;
  border-radius: 8px;
  background: conic-gradient(from 220deg, var(--accent), #7ee0c9 40%, var(--info) 70%, var(--accent));
  position: relative;
  flex-shrink: 0;
  box-shadow: 0 0 0 1px rgba(255,255,255,0.06), 0 6px 16px -6px rgba(201,242,75,0.35);
}
.brand-mark::after {
  content: "";
  position: absolute; inset: 5px;
  background: var(--bg-1);
  border-radius: 4px;
  clip-path: polygon(0 100%, 30% 40%, 55% 65%, 78% 20%, 100% 45%, 100% 100%);
}

.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-text strong { font-family: var(--font-serif); font-size: 17px; letter-spacing: 0.5px; }
.brand-text span { font-size: 10px; color: var(--text-faint); text-transform: uppercase; letter-spacing: 1.4px; }

.status-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px 5px 8px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--bg-elevated);
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.6px;
  color: var(--text-dim);
  width: fit-content;
  margin: 0 6px;
}
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--warning); box-shadow: 0 0 0 3px var(--warning-dim); animation: pulse-dot 2.4s ease-in-out infinite; }
.status-pill.live .status-dot { background: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }
.status-pill strong { color: var(--text); }

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.55; transform: scale(0.85); }
}

nav.primary-nav { display: flex; flex-direction: column; gap: 2px; margin-top: 4px; }

.nav-section-label {
  font-size: 10px; text-transform: uppercase; letter-spacing: 1.4px;
  color: var(--text-faint); padding: 10px 10px 6px;
}

.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px;
  border-radius: 7px;
  color: var(--text-dim);
  font-size: 13.5px;
  font-weight: 500;
  position: relative;
  transition: background 0.15s ease, color 0.15s ease;
}
.nav-link:hover { background: var(--bg-card); color: var(--text); }
.nav-link.active { background: var(--bg-card); color: var(--text); box-shadow: inset 0 0 0 1px var(--border); }
.nav-link.active::before {
  content: "";
  position: absolute; left: -16px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 16px; border-radius: 3px;
  background: var(--accent);
}
.nav-link .icon { width: 16px; height: 16px; flex-shrink: 0; opacity: 0.9; }
.nav-link .badge-count {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-faint);
  background: var(--bg-inset);
  border: 1px solid var(--border);
  padding: 1px 6px;
  border-radius: 999px;
}

.sidebar-footer {
  margin-top: auto;
  padding: 12px 10px 2px;
  border-top: 1px solid var(--border-soft);
  display: flex; flex-direction: column; gap: 8px;
}
.capital-mini { display: flex; justify-content: space-between; align-items: baseline; }
.capital-mini .label { font-size: 10.5px; color: var(--text-faint); text-transform: uppercase; letter-spacing: 1px; }
.capital-mini .value { font-family: var(--font-mono); font-size: 15px; color: var(--text); }
.capital-mini .value small { color: var(--text-faint); font-size: 10px; }

.main {
  min-width: 0;
  padding: 26px 34px 60px;
}

.topbar {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 26px;
  gap: 20px;
  flex-wrap: wrap;
}

.page-title { font-size: 25px; }
.page-sub { color: var(--text-dim); font-size: 13px; margin-top: 6px; max-width: 62ch; }

.topbar-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* ------------------------------------------------------------- Buttons */

.btn {
  font-family: var(--font-sans);
  font-size: 13px; font-weight: 600;
  padding: 9px 15px;
  border-radius: 7px;
  border: 1px solid var(--border-strong);
  background: var(--bg-elevated);
  color: var(--text);
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 7px;
  transition: transform 0.12s ease, background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}
.btn:hover { background: var(--bg-card-hover); border-color: #454a63; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--info); outline-offset: 2px; }

.btn-primary { background: var(--accent); border-color: var(--accent); color: #0e1206; }
.btn-primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }

.btn-danger { background: transparent; border-color: rgba(255,92,106,0.4); color: var(--danger); }
.btn-danger:hover { background: var(--danger-dim); border-color: var(--danger); }

.btn-ghost { background: transparent; border-color: transparent; color: var(--text-dim); }
.btn-ghost:hover { background: var(--bg-card); color: var(--text); }

.btn-sm { padding: 6px 10px; font-size: 12px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* --------------------------------------------------------------- Cards */

.grid { display: grid; gap: 18px; }
.grid-cols-4 { grid-template-columns: repeat(4, 1fr); }
.grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid-span-2 { grid-column: span 2; }
.grid-span-3 { grid-column: span 3; }

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 20px;
}
.card-flush { padding: 0; overflow: hidden; }

.card-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 14px; gap: 12px;
}
.card-head h3 { font-size: 14.5px; }
.card-head .hint { font-size: 11.5px; color: var(--text-faint); margin-top: 3px; }

.card-eyebrow {
  font-size: 10.5px; letter-spacing: 1.2px; text-transform: uppercase;
  color: var(--text-faint); margin-bottom: 4px; display: block;
}

/* ------------------------------------------------------------ Stat tile */

.stat-tile { display: flex; flex-direction: column; gap: 8px; }
.stat-tile .stat-value {
  font-family: var(--font-mono); font-size: 27px; color: var(--text);
  letter-spacing: -0.5px;
}
.stat-tile .stat-value.positive { color: var(--accent); }
.stat-tile .stat-value.negative { color: var(--danger); }
.stat-tile .stat-delta { font-size: 12px; font-family: var(--font-mono); display: flex; align-items: center; gap: 5px; }
.stat-tile .stat-delta.positive { color: var(--accent); }
.stat-tile .stat-delta.negative { color: var(--danger); }
.stat-tile .stat-delta.neutral { color: var(--text-faint); }
.stat-foot { font-size: 11px; color: var(--text-faint); }

/* ------------------------------------------------------------------ Tags */

.tag {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 8px;
  border-radius: 5px;
  font-size: 11px; font-weight: 600;
  font-family: var(--font-mono);
  letter-spacing: 0.2px;
  border: 1px solid transparent;
  white-space: nowrap;
}
.tag-long { background: var(--accent-dim); color: var(--accent); border-color: rgba(201,242,75,0.3); }
.tag-short { background: var(--danger-dim); color: var(--danger); border-color: rgba(255,92,106,0.3); }
.tag-info { background: var(--info-dim); color: var(--info); border-color: rgba(111,168,255,0.3); }
.tag-warning { background: var(--warning-dim); color: var(--warning); border-color: rgba(255,180,84,0.3); }
.tag-neutral { background: var(--neutral-dim); color: var(--text-dim); border-color: var(--border-strong); }
.tag-outline { background: transparent; border-color: var(--border-strong); color: var(--text-dim); }

.dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.dot-accent { background: var(--accent); }
.dot-danger { background: var(--danger); }
.dot-warning { background: var(--warning); }
.dot-info { background: var(--info); }
.dot-neutral { background: var(--text-faint); }

/* ------------------------------------------------------------------ Table */

table.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data-table th {
  text-align: left; font-weight: 600; font-size: 10.5px;
  text-transform: uppercase; letter-spacing: 0.8px;
  color: var(--text-faint);
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--bg-card); z-index: 1;
}
table.data-table td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border-soft);
  vertical-align: middle;
  color: var(--text);
}
table.data-table tbody tr { transition: background 0.12s ease; }
table.data-table tbody tr:hover { background: var(--bg-card-hover); }
table.data-table tbody tr:last-child td { border-bottom: none; }
.table-scroll { overflow-x: auto; }
.num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.text-pos { color: var(--accent); }
.text-neg { color: var(--danger); }
.text-dim { color: var(--text-dim); }
.text-faint { color: var(--text-faint); }

.asset-cell { display: flex; align-items: center; gap: 9px; }
.asset-glyph {
  width: 26px; height: 26px; border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono); font-size: 10px; font-weight: 700;
  background: var(--bg-inset); border: 1px solid var(--border-strong);
  color: var(--text-dim);
}

/* ------------------------------------------------------------------ Meter */

.meter { height: 6px; border-radius: 4px; background: var(--bg-inset); overflow: hidden; border: 1px solid var(--border-soft); }
.meter > span { display: block; height: 100%; border-radius: 4px; }
.meter.risk-low > span { background: var(--accent); }
.meter.risk-med > span { background: var(--warning); }
.meter.risk-high > span { background: var(--danger); }

/* ------------------------------------------------------------------ Badges for regime states */

.regime-badge {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 12px; font-weight: 700;
  border: 1px solid transparent;
}
.regime-down { background: var(--danger-dim); color: var(--danger); border-color: rgba(255,92,106,0.35); }
.regime-up { background: var(--accent-dim); color: var(--accent); border-color: rgba(201,242,75,0.35); }
.regime-side { background: var(--neutral-dim); color: var(--text-dim); border-color: var(--border-strong); }

/* ------------------------------------------------------------ Capability strip */

.capability-strip {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 16px;
  margin-bottom: 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border-soft);
  background: var(--bg-inset);
  font-size: 12px; color: var(--text-dim);
}
.cap-item { display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; }
.cap-sep { color: var(--text-faint); }

/* ------------------------------------------------------------------ AI banner */

.ai-banner {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 16px;
  border-radius: var(--radius);
  background: linear-gradient(90deg, var(--info-dim), transparent 90%);
  border: 1px solid rgba(111,168,255,0.28);
  font-size: 12.5px;
  color: #c7dbff;
}
.ai-banner strong { color: #fff; }
.ai-banner .ai-glyph {
  width: 26px; height: 26px; border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #a8c8ff, var(--info));
  flex-shrink: 0;
  box-shadow: 0 0 14px rgba(111,168,255,0.5);
  position: relative;
}
.ai-banner .ai-glyph::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.4);
  animation: ring-pulse 2.6s ease-out infinite;
}
@keyframes ring-pulse {
  0% { transform: scale(0.8); opacity: 0.8; }
  100% { transform: scale(2.1); opacity: 0; }
}

/* ------------------------------------------------------------------ Forms */

.field { display: flex; flex-direction: column; gap: 7px; margin-bottom: 18px; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--text); }
.field .field-hint { font-size: 11.5px; color: var(--text-faint); }
.field input[type="text"], .field input[type="number"], .field input[type="password"], .field select {
  font-family: var(--font-mono);
  background: var(--bg-inset);
  border: 1px solid var(--border-strong);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 13px;
  width: 100%;
}
.field input:focus, .field select:focus { outline: none; border-color: var(--info); box-shadow: 0 0 0 3px var(--info-dim); }
.field-row { display: flex; gap: 14px; }
.field-row .field { flex: 1; }

.slider-row { display: flex; align-items: center; gap: 14px; }
input[type="range"] {
  -webkit-appearance: none; appearance: none;
  flex: 1; height: 4px; border-radius: 4px;
  background: var(--border-strong);
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--accent);
  border: 2px solid #0e1206;
  cursor: pointer;
  box-shadow: 0 0 0 3px rgba(201,242,75,0.25);
}
.slider-value { font-family: var(--font-mono); font-size: 13px; min-width: 52px; text-align: right; color: var(--text); }

.toggle-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 0;
  border-bottom: 1px solid var(--border-soft);
}
.toggle-row:last-child { border-bottom: none; }
.toggle-copy strong { display: block; font-size: 13px; }
.toggle-copy span { font-size: 11.5px; color: var(--text-faint); }

.switch { position: relative; width: 40px; height: 22px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .track {
  position: absolute; inset: 0; background: var(--border-strong); border-radius: 999px;
  transition: background 0.15s ease; cursor: pointer;
}
.switch .track::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 18px; height: 18px; border-radius: 50%;
  background: #cfd2db; transition: transform 0.15s ease;
}
.switch input:checked + .track { background: var(--accent-dim); box-shadow: inset 0 0 0 1px var(--accent); }
.switch input:checked + .track::after { transform: translateX(18px); background: var(--accent); }

.mode-select { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.mode-option {
  border: 1px solid var(--border-strong);
  background: var(--bg-inset);
  border-radius: var(--radius);
  padding: 14px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.mode-option.selected { border-color: var(--accent); background: var(--accent-dim); }
.mode-option h4 { font-size: 13px; margin-bottom: 5px; font-family: var(--font-sans); }
.mode-option p { font-size: 11.5px; color: var(--text-faint); margin: 0; }
.mode-option .mode-radio {
  width: 15px; height: 15px; border-radius: 50%;
  border: 1.5px solid var(--border-strong);
  margin-bottom: 10px; position: relative;
}
.mode-option.selected .mode-radio { border-color: var(--accent); }
.mode-option.selected .mode-radio::after {
  content: ""; position: absolute; inset: 3px; border-radius: 50%; background: var(--accent);
}

/* ------------------------------------------------------------------ Misc */

.divider { height: 1px; background: var(--border-soft); margin: 22px 0; border: none; }

.kv-list { display: flex; flex-direction: column; gap: 11px; }
.kv-row { display: flex; justify-content: space-between; align-items: center; font-size: 12.5px; }
.kv-row .k { color: var(--text-faint); }
.kv-row .v { font-family: var(--font-mono); color: var(--text); }

.footer-note {
  margin-top: 40px;
  padding-top: 18px;
  border-top: 1px solid var(--border-soft);
  display: flex; justify-content: space-between; align-items: center;
  font-size: 11px; color: var(--text-faint);
  flex-wrap: wrap; gap: 8px;
}
.footer-note .disclaimer { max-width: 60ch; }

.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 11.5px; color: var(--text-dim); }
.legend-item { display: flex; align-items: center; gap: 6px; }
.legend-swatch { width: 10px; height: 3px; border-radius: 2px; }

.tooltip-note {
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 12px 14px;
  font-size: 12px;
  color: var(--text-dim);
  background: var(--bg-inset);
}

.reason-text { font-size: 12.5px; color: var(--text-dim); line-height: 1.6; }

.flag-list { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.flag-item {
  display: flex; align-items: flex-start; gap: 8px;
  font-size: 12px; color: var(--text-dim);
  padding: 8px 10px;
  background: var(--bg-inset);
  border-radius: 6px;
  border: 1px solid var(--border-soft);
}
.flag-item.severe { border-color: rgba(255,92,106,0.3); color: #ffc4ca; }

.section-title {
  font-size: 12px; text-transform: uppercase; letter-spacing: 1.2px;
  color: var(--text-faint); margin: 30px 0 14px; display: flex; align-items: center; gap: 10px;
}
.section-title::after { content: ""; flex: 1; height: 1px; background: var(--border-soft); }

.pnl-live { display: inline-flex; align-items: center; gap: 6px; }
.pnl-live .blip { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); animation: pulse-dot 1.8s ease-in-out infinite; }

canvas { display: block; max-width: 100%; }

.chip-row { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  padding: 6px 12px; border-radius: 999px; font-size: 12px;
  border: 1px solid var(--border-strong); color: var(--text-dim);
  cursor: pointer; background: var(--bg-inset);
  transition: all 0.15s ease;
}
.chip.active { border-color: var(--accent); color: var(--accent); background: var(--accent-dim); }
.chip:hover { color: var(--text); }

/* ------------------------------------------------------------- Animations */

@keyframes fade-up {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
.reveal { animation: fade-up 0.5s cubic-bezier(0.16,1,0.3,1) both; }
.reveal-1 { animation-delay: 0.03s; }
.reveal-2 { animation-delay: 0.08s; }
.reveal-3 { animation-delay: 0.13s; }
.reveal-4 { animation-delay: 0.18s; }
.reveal-5 { animation-delay: 0.23s; }
.reveal-6 { animation-delay: 0.28s; }

/* ------------------------------------------------------------- Responsive */

@media (max-width: 1180px) {
  .grid-cols-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-cols-3 { grid-template-columns: repeat(2, 1fr); }
  .grid-span-2, .grid-span-3 { grid-column: span 2; }
}

@media (max-width: 880px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: relative; height: auto; }
  .main { padding: 20px; }
  .grid-cols-4, .grid-cols-3, .grid-cols-2 { grid-template-columns: 1fr; }
  .grid-span-2, .grid-span-3 { grid-column: span 1; }
}
