:root {
  --bg: #eef3f7;
  --ink: #101827;
  --muted: #5e6b7d;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --line: #dbe3eb;
  --blue: #2563eb;
  --green: #059669;
  --red: #dc2626;
  --amber: #b7791f;
  --purple: #6d5dfc;
  --shadow: 0 16px 45px rgba(16, 24, 39, 0.1);
  --radius: 8px;
  --font: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: var(--font);
  background:
    linear-gradient(120deg, rgba(37, 99, 235, 0.14), rgba(5, 150, 105, 0.1) 42%, rgba(183, 121, 31, 0.12)),
    var(--bg);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.app-shell {
  min-height: 100vh;
}

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
}

.login-panel {
  width: min(440px, 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
  padding: 28px;
}

.brand-row {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 900;
}

.brand-row.compact {
  font-size: 1.04rem;
}

.brand-mark {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--blue), var(--green) 48%, var(--amber));
  box-shadow: 0 0 0 5px rgba(255, 255, 255, 0.7);
}

.eyebrow {
  margin: 22px 0 7px;
  color: var(--blue);
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 10px;
  font-size: 2.35rem;
  line-height: 1.03;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 1.15rem;
  line-height: 1.1;
  letter-spacing: 0;
}

h3 {
  margin-bottom: 8px;
  font-size: 1rem;
  line-height: 1.2;
}

.login-copy,
.subtitle,
.form-status {
  color: var(--muted);
}

.login-copy {
  margin-bottom: 22px;
  font-weight: 650;
}

.login-form {
  display: grid;
  gap: 10px;
}

.login-form label {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

.login-form input {
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  color: var(--ink);
  padding: 0 12px;
  font-weight: 750;
}

.primary-btn,
.secondary-btn,
.ghost-btn,
.ghost-link {
  min-height: 42px;
  border-radius: var(--radius);
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  font-weight: 900;
}

.primary-btn {
  border: 1px solid var(--ink);
  background: var(--ink);
  color: #ffffff;
}

.secondary-btn,
.ghost-btn,
.ghost-link {
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--ink);
}

.login-form .primary-btn {
  margin-top: 8px;
}

.form-status {
  min-height: 20px;
  margin: 2px 0 0;
  font-size: 0.9rem;
  font-weight: 750;
}

.form-status.error {
  color: var(--red);
}

.dashboard-view {
  width: min(1440px, calc(100% - 32px));
  margin: 0 auto;
  padding: 20px 0 42px;
}

.topbar {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.subtitle {
  margin: 8px 0 0;
  font-size: 0.9rem;
  font-weight: 750;
}

.top-actions,
.button-pair {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 370px 1fr 1fr;
  gap: 14px;
}

.dashboard-grid > * {
  min-width: 0;
}

.status-strip {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

.stat-card,
.agent-panel,
.control-panel,
.scan-panel,
.chart-panel,
.table-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.stat-card {
  min-height: 92px;
  display: grid;
  align-content: center;
  gap: 5px;
  padding: 16px;
}

.stat-card span {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 850;
  text-transform: uppercase;
}

.stat-card strong {
  font-size: 1.55rem;
  line-height: 1;
}

.positive {
  color: var(--green) !important;
}

.negative {
  color: var(--red) !important;
}

.control-panel,
.agent-panel,
.scan-panel,
.chart-panel,
.table-panel {
  padding: 16px;
}

.control-panel {
  display: grid;
  gap: 14px;
}

.scan-panel {
  grid-column: span 2;
}

.chart-panel {
  grid-column: span 2;
}

.wide {
  grid-column: 1 / -1;
}

.agent-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.agent-item {
  min-height: 76px;
  display: grid;
  align-content: center;
  gap: 5px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-soft);
  padding: 12px;
}

.agent-item span {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 900;
  text-transform: uppercase;
}

.agent-item strong {
  font-size: 0.98rem;
  line-height: 1.15;
}

.agent-note {
  margin: 12px 0 0;
  color: var(--muted);
  font-weight: 700;
}

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

.panel-head .eyebrow {
  margin-top: 0;
}

.mode-pill,
.status-pill {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-soft);
  color: var(--muted);
  padding: 5px 10px;
  font-size: 0.78rem;
  font-weight: 900;
  white-space: nowrap;
}

.status-pill.approved {
  border-color: rgba(5, 150, 105, 0.28);
  background: rgba(5, 150, 105, 0.1);
  color: var(--green);
}

.status-pill.review {
  border-color: rgba(37, 99, 235, 0.28);
  background: rgba(37, 99, 235, 0.1);
  color: var(--blue);
}

.status-pill.rejected {
  border-color: rgba(220, 38, 38, 0.28);
  background: rgba(220, 38, 38, 0.09);
  color: var(--red);
}

.stop-btn {
  min-height: 86px;
  border: 1px solid rgba(220, 38, 38, 0.38);
  border-radius: var(--radius);
  background: var(--red);
  color: #ffffff;
  font-size: 1.25rem;
  font-weight: 950;
  letter-spacing: 0;
}

.stop-btn.active {
  background: #ffffff;
  color: var(--red);
}

.risk-list {
  display: grid;
  gap: 8px;
}

.risk-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 750;
}

.risk-row strong {
  color: var(--ink);
}

.pipeline {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}

.stage {
  min-height: 72px;
  display: grid;
  align-content: center;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-soft);
  padding: 10px;
}

.stage span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.stage strong {
  font-size: 0.86rem;
}

.stage.pass {
  border-color: rgba(5, 150, 105, 0.26);
  background: rgba(5, 150, 105, 0.08);
}

.stage.fail {
  border-color: rgba(220, 38, 38, 0.26);
  background: rgba(220, 38, 38, 0.07);
}

.thesis-box {
  min-height: 160px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, rgba(37, 99, 235, 0.07), rgba(5, 150, 105, 0.08)),
    #ffffff;
  padding: 14px;
}

.thesis-box p {
  margin-bottom: 0;
  color: var(--muted);
  font-weight: 650;
}

.equity-chart {
  width: 100%;
  min-height: 220px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #0f172a;
}

.table-wrap {
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 11px 10px;
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

td {
  font-size: 0.9rem;
  font-weight: 650;
}

.signal-list,
.log-list,
.metric-list,
.source-list,
.health-list {
  display: grid;
  gap: 10px;
}

.signal-list,
.log-list {
  max-height: 420px;
  overflow: auto;
}

.signal-item,
.log-item,
.metric-item,
.source-item,
.health-item {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-soft);
  padding: 12px;
}

.signal-item {
  display: grid;
  gap: 8px;
}

.item-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
}

.log-item p,
.signal-item p,
.metric-item p,
.source-item p,
.health-item p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 650;
}

.metric-item {
  display: grid;
  gap: 6px;
}

.metric-row,
.health-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.metric-row strong,
.health-item strong {
  white-space: nowrap;
}

.source-item {
  display: grid;
  gap: 7px;
}

.health-list {
  margin-top: 10px;
}

.health-item.ok {
  border-color: rgba(5, 150, 105, 0.28);
  background: rgba(5, 150, 105, 0.08);
}

.health-item.warn {
  border-color: rgba(183, 121, 31, 0.32);
  background: rgba(183, 121, 31, 0.09);
}

.health-item.stop {
  border-color: rgba(220, 38, 38, 0.3);
  background: rgba(220, 38, 38, 0.08);
}

.compact-list {
  gap: 8px;
}

.empty-state {
  color: var(--muted);
  font-weight: 750;
}

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

  .control-panel,
  .scan-panel,
  .chart-panel {
    grid-column: span 2;
  }

  .status-strip {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .pipeline {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .agent-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .dashboard-view {
    width: min(100% - 20px, 1440px);
  }

  .topbar,
  .panel-head {
    align-items: stretch;
    flex-direction: column;
  }

  .dashboard-grid,
  .status-strip,
  .agent-grid,
  .pipeline {
    grid-template-columns: 1fr;
  }

  .control-panel,
  .scan-panel,
  .chart-panel,
  .wide {
    grid-column: auto;
  }

  .stat-card {
    min-height: 78px;
  }

  h1 {
    font-size: 2rem;
  }
}
