/* Trading Intelligence — executive navy/cyan identity, responsive. */

:root {
  --bg: #070d18;
  --bg-soft: #0b1220;
  --panel: #0e1729;
  --panel-2: #121d33;
  --border: #1e2c47;
  --border-soft: #17243c;
  --text: #e6edf7;
  --muted: #8ea3c0;
  --accent: #38bdf8;
  --accent-2: #22d3ee;
  --good: #34d399;
  --warn: #fbbf24;
  --bad: #f87171;
  --radius: 14px;
  --shadow: 0 18px 40px -24px rgba(0, 0, 0, .9);
}

* { box-sizing: border-box; }

/* The `hidden` attribute must win over component display rules
   (.login-screen sets display:grid, which would otherwise keep it painted). */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(900px 500px at 12% -10%, rgba(56, 189, 248, .14), transparent 60%),
    radial-gradient(700px 420px at 95% 0%, rgba(34, 211, 238, .08), transparent 55%);
  pointer-events: none;
  z-index: 0;
}

h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 1.45rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.02rem; }
p { margin: 0; }
a { color: var(--accent); }

.muted { color: var(--muted); }
.small { font-size: .875rem; }
.tiny { font-size: .78rem; }
code {
  background: rgba(56, 189, 248, .1);
  color: var(--accent);
  padding: .1em .35em;
  border-radius: 5px;
  font-size: .85em;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* ───────── Login ───────── */
.login-screen {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(420px, 100%);
  background: linear-gradient(180deg, var(--panel), var(--bg-soft));
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 34px 28px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.login-card h1 { margin-top: 6px; }
.login-card .brand-mark { margin-bottom: 2px; }

.brand-mark {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 13px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #04121f;
  font-weight: 800;
  letter-spacing: -.03em;
}
.brand-mark.small { width: 34px; height: 34px; border-radius: 10px; font-size: .78rem; }

/* ───────── Shell ───────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(7, 13, 24, .86);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-soft);
}

.topbar-inner {
  max-width: 1240px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  background: none;
  border: 0;
  color: inherit;
  cursor: pointer;
  padding: 0;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; text-align: left; }
.brand-text strong { font-size: .95rem; }
.brand-text small { color: var(--muted); font-size: .72rem; }

.nav { display: flex; gap: 4px; margin-left: 8px; flex-wrap: wrap; }

.nav-link {
  background: none;
  border: 1px solid transparent;
  color: var(--muted);
  padding: 7px 12px;
  border-radius: 9px;
  font-size: .875rem;
  cursor: pointer;
  transition: .14s ease;
  font-family: inherit;
}
.nav-link:hover { color: var(--text); background: var(--panel); }
.nav-link.active { color: var(--accent); background: rgba(56, 189, 248, .1); border-color: rgba(56, 189, 248, .25); }

.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: .74rem;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--muted);
  white-space: nowrap;
}
.chip .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--warn); box-shadow: 0 0 10px var(--warn); }
.chip-live { color: #ffd9a8; border-color: rgba(251, 191, 36, .3); background: rgba(251, 191, 36, .07); }

.container { position: relative; z-index: 1; max-width: 1240px; margin: 0 auto; padding: 26px 20px 60px; }

.view-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.view-head > div:first-child { display: flex; flex-direction: column; gap: 3px; }

/* ───────── Layout ───────── */
.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); }
.grid.kpis { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); margin-bottom: 18px; }

.panel {
  background: linear-gradient(180deg, var(--panel), var(--bg-soft));
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.kpi {
  background: linear-gradient(180deg, var(--panel), var(--bg-soft));
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.kpi .label { font-size: .76rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
.kpi .value { font-size: 1.65rem; font-weight: 700; letter-spacing: -.02em; }
.kpi .sub { font-size: .8rem; color: var(--muted); }

/* ───────── Lists ───────── */
.list { display: flex; flex-direction: column; gap: 8px; }

.row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 13px;
  border: 1px solid var(--border-soft);
  border-radius: 11px;
  background: rgba(18, 29, 51, .45);
  cursor: pointer;
  transition: .14s ease;
  text-align: left;
  width: 100%;
  color: inherit;
  font-family: inherit;
  font-size: inherit;
}
.row:hover { border-color: rgba(56, 189, 248, .35); background: rgba(56, 189, 248, .05); }
.row.static { cursor: default; }
.row.static:hover { border-color: var(--border-soft); background: rgba(18, 29, 51, .45); }

.row-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.row-title { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: .93rem; }
.row-sub { font-size: .78rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-side { display: flex; align-items: center; gap: 8px; margin-left: auto; flex-shrink: 0; }

.ticker-tag {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .76rem;
  padding: 2px 7px;
  border-radius: 6px;
  background: rgba(56, 189, 248, .12);
  color: var(--accent);
  border: 1px solid rgba(56, 189, 248, .2);
}

/* ───────── Badges ───────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: .72rem;
  font-weight: 650;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--muted);
  white-space: nowrap;
  letter-spacing: .01em;
}
.badge.buy, .badge.overweight { color: #a7f3d0; background: rgba(52, 211, 153, .13); border-color: rgba(52, 211, 153, .35); }
.badge.hold { color: #fde68a; background: rgba(251, 191, 36, .12); border-color: rgba(251, 191, 36, .32); }
.badge.underweight, .badge.sell { color: #fecaca; background: rgba(248, 113, 113, .13); border-color: rgba(248, 113, 113, .34); }
.badge.review { color: #c4b5fd; background: rgba(167, 139, 250, .13); border-color: rgba(167, 139, 250, .34); }
.badge.running { color: #bae6fd; background: rgba(56, 189, 248, .13); border-color: rgba(56, 189, 248, .35); }
.badge.queued { color: var(--muted); }
.badge.success { color: #a7f3d0; background: rgba(52, 211, 153, .1); border-color: rgba(52, 211, 153, .28); }
.badge.failed { color: #fecaca; background: rgba(248, 113, 113, .1); border-color: rgba(248, 113, 113, .3); }

/* ───────── Buttons ───────── */
.btn {
  font-family: inherit;
  font-size: .875rem;
  font-weight: 600;
  padding: 9px 15px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
  transition: .14s ease;
  white-space: nowrap;
}
.btn:hover { border-color: rgba(56, 189, 248, .45); }
.btn.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: transparent;
  color: #04121f;
}
.btn.primary:hover { filter: brightness(1.07); }
.btn.ghost { background: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); }
.btn.small { padding: 6px 11px; font-size: .8rem; }
.btn.full { width: 100%; justify-content: center; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn.danger:hover { border-color: rgba(248, 113, 113, .5); color: #fecaca; }

/* ───────── Forms ───────── */
.field { display: flex; flex-direction: column; gap: 6px; font-size: .82rem; color: var(--muted); }
.field > span { font-weight: 600; letter-spacing: .01em; }
.field .hint { font-size: .74rem; line-height: 1.45; }

input, select, textarea {
  font-family: inherit;
  font-size: .9rem;
  color: var(--text);
  background: #0a1524;
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 9px 11px;
  width: 100%;
  transition: .14s ease;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, .13);
}
input::placeholder { color: #5b6f8d; }

.form-panel { display: flex; flex-direction: column; gap: 18px; }
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
}

.analysts { border: 1px solid var(--border-soft); border-radius: 11px; padding: 12px 14px; display: flex; flex-direction: row; flex-wrap: wrap; gap: 16px; }
.analysts legend { font-size: .8rem; color: var(--muted); padding: 0 6px; }
.check { display: inline-flex; align-items: center; gap: 7px; font-size: .87rem; color: var(--text); cursor: pointer; }
.check input { width: auto; accent-color: var(--accent); }

.form-actions { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.form-error { color: var(--bad); font-size: .85rem; min-height: 1.1em; margin: 0; }
.inline-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.inline-form input, .inline-form select { width: auto; min-width: 150px; }

/* ───────── Run detail ───────── */
.back { margin-bottom: 14px; }

.run-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.run-title { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.run-title h2 { font-size: 1.6rem; }

.progress {
  height: 6px;
  background: var(--panel-2);
  border-radius: 999px;
  overflow: hidden;
  margin: 12px 0 6px;
}
.progress > span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width .5s ease;
}
.progress.indeterminate > span {
  width: 35% !important;
  animation: slide 1.4s ease-in-out infinite;
}
@keyframes slide { 0% { margin-left: -35%; } 100% { margin-left: 100%; } }

.stage-line { display: flex; justify-content: space-between; font-size: .8rem; color: var(--muted); gap: 10px; flex-wrap: wrap; }

.metric-row { display: flex; gap: 22px; flex-wrap: wrap; margin-top: 4px; }
.metric { display: flex; flex-direction: column; }
.metric .label { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.metric .value { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .95rem; }

.section-block { border: 1px solid var(--border-soft); border-radius: 12px; overflow: hidden; background: rgba(18, 29, 51, .35); }
.section-block + .section-block { margin-top: 10px; }
.section-block > summary {
  cursor: pointer;
  padding: 13px 16px;
  font-weight: 600;
  font-size: .92rem;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.section-block > summary::-webkit-details-marker { display: none; }
.section-block > summary::after { content: "+"; color: var(--muted); font-weight: 400; font-size: 1.1rem; }
.section-block[open] > summary { border-bottom: 1px solid var(--border-soft); }
.section-block[open] > summary::after { content: "−"; }

.md { padding: 16px; font-size: .9rem; overflow-wrap: anywhere; }
.md h1, .md h2, .md h3, .md h4 { margin: 1.1em 0 .5em; line-height: 1.3; }
.md h1 { font-size: 1.25rem; }
.md h2 { font-size: 1.12rem; }
.md h3 { font-size: 1rem; color: var(--accent); }
.md p { margin: .55em 0; }
.md ul, .md ol { margin: .5em 0; padding-left: 1.3em; }
.md li { margin: .25em 0; }
.md strong { color: #fff; }
.md hr { border: 0; border-top: 1px solid var(--border-soft); margin: 1.1em 0; }
.md blockquote { margin: .7em 0; padding: .3em 0 .3em 1em; border-left: 3px solid var(--accent); color: var(--muted); }
.md table { width: 100%; border-collapse: collapse; margin: .8em 0; font-size: .84rem; display: block; overflow-x: auto; }
.md th, .md td { border: 1px solid var(--border-soft); padding: 7px 9px; text-align: left; }
.md th { background: rgba(56, 189, 248, .07); }
.md pre { background: #050b14; padding: 12px; border-radius: 9px; overflow-x: auto; font-size: .82rem; }
.md code { background: rgba(56, 189, 248, .1); }

.empty { padding: 26px 14px; text-align: center; color: var(--muted); font-size: .86rem; }

.notice {
  border: 1px solid rgba(56, 189, 248, .25);
  background: rgba(56, 189, 248, .06);
  border-radius: 11px;
  padding: 12px 14px;
  font-size: .85rem;
  color: #cfe6fb;
}
.notice.error { border-color: rgba(248, 113, 113, .35); background: rgba(248, 113, 113, .08); color: #fecaca; }
.notice.warn { border-color: rgba(251, 191, 36, .3); background: rgba(251, 191, 36, .07); color: #fde68a; }

.footer {
  position: relative;
  z-index: 1;
  max-width: 1240px;
  margin: 0 auto;
  padding: 18px 20px 34px;
  border-top: 1px solid var(--border-soft);
  display: flex;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  font-size: .78rem;
  color: var(--muted);
}

.toast {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 11px 18px;
  border-radius: 11px;
  font-size: .86rem;
  box-shadow: var(--shadow);
  z-index: 60;
  max-width: min(92vw, 520px);
}

/* ───────── Table-ish cost rows ───────── */
.mini-table { width: 100%; border-collapse: collapse; font-size: .84rem; }
.mini-table th {
  text-align: left;
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  padding: 6px 8px;
  border-bottom: 1px solid var(--border-soft);
  font-weight: 600;
}
.mini-table td { padding: 8px; border-bottom: 1px solid rgba(30, 44, 71, .5); }
.mini-table tr:last-child td { border-bottom: 0; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.right { text-align: right; }

@media (max-width: 860px) {
  .topbar-inner { flex-wrap: wrap; gap: 10px; }
  .nav { order: 3; width: 100%; margin: 0; overflow-x: auto; flex-wrap: nowrap; padding-bottom: 2px; }
  .nav-link { white-space: nowrap; }
  .topbar-right { margin-left: auto; }
  .grid.two { grid-template-columns: 1fr; }
  /* Keep the "live trading disabled" signal on every breakpoint. */
  .chip-live { font-size: .68rem; padding: 4px 8px; }
}

@media (max-width: 560px) {
  .container { padding: 18px 14px 50px; }
  .view-head { align-items: stretch; }
  .kpi .value { font-size: 1.4rem; }
  .brand-text small { display: none; }
  .form-actions { flex-direction: column; align-items: stretch; }
  .form-actions .btn { width: 100%; }
  .row-side .badge:nth-child(2) { display: none; }
  .micro-hide { display: none; }
}
