:root {
  --bg: #071224;
  --card: #0e192b;
  --panel: #0b1324;
  --line: rgba(148, 163, 184, .16);
  --line-strong: #334155;
  --text: #e5e7eb;
  --text-dim: #94a3b8;
  --primary: #34c9a8;
  --accent: #2f78e5;
  --danger: #ef4444;
  --warning: #f59e0b;
  --success: #22c55e;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.app {
  max-width: 1250px;
  margin: 28px auto;
  padding: 0 40px;
}

header {
  align-items: center;
  display: flex;
  justify-content: space-between;
  margin-bottom: 30px;
}

.brand {
  align-items: center;
  display: flex;
  gap: 12px;
  font-weight: 700;
}

.brand .logo {
  background: conic-gradient(from 180deg at 50% 50%, var(--accent), var(--primary));
  border-radius: 7px;
  height: 25px;
  width: 25px;
}

.session-center {
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.3;
  margin-top: 2px;
}

.session-center span {
  color: var(--text);
}

.tabs {
  display: inline-flex;
  gap: 12px;
}

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

.tab-btn,
.auth-tab {
  background: #0e2140;
  border: 0;
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
  font-weight: 500;
  padding: 8px 17px;
  transition: background .2s ease, transform .2s ease;
}

.tab-btn:hover,
.auth-tab:hover {
  transform: translateY(-1px);
}

.tab-btn.active,
.auth-tab.active {
  background: linear-gradient(90deg, var(--accent), var(--primary));
  color: #f8fafc;
}

.screen {
  display: none;
}

.screen.active {
  display: block;
}

.triage-screen h1,
.workflow-screen h1 {
  font-size: 25px;
  letter-spacing: .2px;
  margin: 0 0 18px;
}

.muted,
.title-dash {
  color: rgba(229, 231, 235, .55);
  font-weight: 500;
}

.grid {
  display: grid;
  gap: 16px;
}

.grid-2 {
  grid-template-columns: 1.1fr 1fr;
}

.triage-layout {
  gap: 24px;
  grid-template-columns: 574px 1fr;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: none;
  padding: 26px;
}

.triage-form,
.model-result {
  min-height: 762px;
}

.triage-form {
  padding-top: 36px;
}

h1,
h2,
p {
  overflow-wrap: anywhere;
}

h2 {
  color: #c9d2df;
  font-size: 16px;
  margin: 0 0 8px;
}

.triage-form h2:not(:first-child) {
  margin-top: 14px;
}

.row {
  display: flex;
  gap: 14px;
}

.wrap-row {
  flex-wrap: wrap;
}

.field {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
}

.field-wide {
  flex: 2;
}

.field-medium {
  max-width: 260px;
}

.field-small {
  max-width: 240px;
}

.field-range {
  max-width: 230px;
}

.field-date-range {
  max-width: 330px;
}

.range-inputs {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.label {
  color: #c3ccd8;
  font-size: 12px;
  font-weight: 600;
}

.input,
select {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--text);
  font: inherit;
  min-height: 38px;
  outline: none;
  padding: 9px 14px;
  width: 100%;
}

.input:focus,
select:focus {
  border-color: #38bdf8;
  box-shadow: 0 0 0 2px rgba(56, 189, 248, .25);
}

.input-error {
  border-color: rgba(239, 68, 68, .9);
  box-shadow: 0 0 0 2px rgba(239, 68, 68, .2);
}

.actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.btn {
  border: 0;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 700;
  min-height: 40px;
  padding: 10px 14px;
}

.btn.primary {
  background: linear-gradient(90deg, #39c79b, #2f72e7);
  color: #f8fafc;
}

.triage-screen .btn.primary,
.auth-submit {
  width: 100%;
}

.btn.ghost {
  background: #0e2140;
  border: 1px solid rgba(148, 163, 184, .18);
  color: var(--text);
}

.logout-btn {
  min-height: 36px;
  white-space: nowrap;
}

.btn-mini {
  font-size: 12px;
  min-height: 30px;
  padding: 6px 10px;
}

.result-kpis {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(3, 1fr);
  margin-top: 16px;
}

.kpi {
  align-items: center;
  background: #1b2638;
  border: 0;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 88px;
  padding: 14px;
  text-align: center;
}

.kpi .label {
  color: #c6cfdb;
  font-size: 12px;
  font-weight: 500;
}

.kpi .val {
  color: #eef4fb;
  font-size: 20px;
  font-weight: 800;
  line-height: 1.1;
  margin-top: 18px;
}

.footer-note {
  color: #aeb8c6;
  font-size: 12px;
  margin: 14px 0 0;
}

.filter-card {
  margin-bottom: 16px;
  padding-bottom: 14px;
}

table {
  border-collapse: collapse;
  border-radius: 12px;
  font-size: 13px;
  overflow: hidden;
  width: 100%;
}

th,
td {
  border-bottom: 1px solid rgba(255, 255, 255, .06);
  padding: 11px 10px;
  text-align: left;
}

thead th {
  background: rgba(255, 255, 255, .06);
  color: var(--text-dim);
  font-size: 12px;
}

.badge {
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 20px;
  display: inline-block;
  font-size: 12px;
  padding: 6px 8px;
}

.risk-low {
  background: rgba(34, 197, 94, .18);
  color: #d9ffde;
}

.risk-mid {
  background: rgba(245, 158, 11, .22);
  color: #fff1cd;
}

.risk-high {
  background: rgba(239, 68, 68, .22);
  color: #ffdad6;
}

.compact-kpis {
  margin-bottom: 16px;
}

.compact-kpis .kpi {
  min-height: 78px;
}

.detail-list {
  border-top: 1px solid rgba(148, 163, 184, .14);
}

.detail-list > div {
  align-items: center;
  border-bottom: 1px solid rgba(148, 163, 184, .12);
  display: flex;
  gap: 16px;
  justify-content: space-between;
  padding: 10px 0;
}

.detail-list span {
  color: var(--text-dim);
  font-size: 12px;
}

.detail-list strong {
  color: var(--text);
  font-size: 13px;
  font-weight: 650;
  max-width: 68%;
  text-align: right;
}

.detail-list .detail-block {
  align-items: flex-start;
  flex-direction: column;
  gap: 8px;
}

.detail-grid {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  width: 100%;
}

.detail-grid > div {
  background: rgba(255, 255, 255, .035);
  border: 1px solid rgba(148, 163, 184, .1);
  border-radius: 8px;
  padding: 8px 10px;
}

.detail-grid span,
.detail-grid strong {
  display: block;
  max-width: none;
  text-align: left;
}

.detail-grid strong {
  margin-top: 2px;
}

.chart-title {
  margin-top: 16px;
}

.chart {
  height: auto;
  width: 100%;
}

.axis {
  stroke: rgba(255, 255, 255, .2);
  stroke-width: 1;
}

.stroke {
  fill: none;
  stroke: #38bdf8;
  stroke-width: 2;
}

.dot {
  fill: var(--success);
}

.bar {
  fill: #38bdf8;
  opacity: .85;
}

.tick {
  fill: var(--text-dim);
  font-size: 12px;
}

.chart-value {
  fill: var(--text);
  font-size: 14px;
  font-weight: 800;
}

.chart-percent {
  fill: #f8fafc;
  font-size: 11px;
  font-weight: 700;
}

.chart-legend {
  fill: var(--text);
  font-size: 12px;
  font-weight: 700;
}

.summary-kpis {
  grid-template-columns: repeat(3, 1fr);
}

.summary-kpis .kpi {
  min-height: 92px;
}

.summary-kpis .val {
  font-size: 18px;
}

.auth-screen {
  min-height: 100vh;
  padding: 32px 40px;
}

.auth-shell {
  display: grid;
  gap: 24px;
  grid-template-columns: .95fr 1.05fr;
  margin: 0 auto;
  max-width: 980px;
  min-height: calc(100vh - 64px);
  place-content: center;
}

.auth-brand {
  grid-column: 1 / -1;
}

.auth-copy h1 {
  font-size: 34px;
  line-height: 1.1;
  margin: 0 0 14px;
}

.auth-copy p {
  color: #aeb8c6;
  font-size: 16px;
  margin: 0;
  max-width: 430px;
}

.auth-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
}

.auth-tabs {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(3, 1fr);
  margin-bottom: 20px;
}

.auth-tab {
  padding: 10px;
}

.auth-panel {
  display: none;
}

.auth-panel.active {
  display: block;
}

.auth-message {
  min-height: 18px;
}

@media (max-width: 980px) {
  .app,
  .auth-screen {
    padding: 24px 20px;
  }

  .app {
    margin: 0 auto;
  }

  header {
    align-items: flex-start;
    flex-direction: column;
    gap: 16px;
  }

  .tabs {
    flex-wrap: wrap;
  }

  .header-actions {
    align-items: flex-start;
    flex-direction: column;
  }

  .auth-shell,
  .auth-tabs,
  .triage-layout,
  .grid-2,
  .result-kpis,
  .summary-kpis {
    grid-template-columns: 1fr;
  }

  .triage-form,
  .model-result {
    min-height: auto;
  }

  .row {
    flex-direction: column;
    gap: 0;
  }

  .field-medium,
  .field-small,
  .field-range,
  .field-date-range {
    max-width: none;
  }

  .detail-list > div {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }

  .detail-list strong {
    max-width: 100%;
    text-align: left;
  }
}
