:root {
  color-scheme: light;
  --bg: #f5f8fb;
  --surface: #ffffff;
  --surface-muted: #e9f3ff;
  --text: #1d2830;
  --muted: #657586;
  --line: #d4e4f4;
  --primary: #1d7fcf;
  --primary-dark: #0f5f9f;
  --accent: rgba(255, 160, 86, 0.875);
  --danger: #b42318;
  --low: rgb(180 35 24 / 0.775);
  --medium: rgba(255, 160, 86, 0.875);
  --high: #1d74d8;
  --radius-lg: 18px;
  --radius-md: 14px;
  --radius-sm: 12px;
  --shadow: 0 18px 50px rgba(19, 44, 71, 0.1);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  display: flex;
  flex-direction: column;
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button,
input,
select {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

.topbar {
  gap: 24px;
  padding: 16px 32px;
  /*background: rgba(0, 0, 0, 0.125);*/
  color: #0f2f4c;
  border-bottom: 2px solid #76c8ff;
}

.header-container {
  max-width: 1848px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 auto;
}

.topbar p {
  font-size: 32px;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(1.35rem, 2.2vw, 2.1rem);
  line-height: 1.12;
}

h2 {
  font-size: 1.1rem;
}

p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 36px;
  padding: 8px 12px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: var(--radius-md);
  color: #eef7ff;
  background: #0f2f4c;
  white-space: nowrap;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #c7d8e8;
}

.status-dot.ok {
  background: #36a3ff;
}

.status-dot.bad {
  background: #ffb347;
}

.workspace {
  display: grid;
  align-items: start;
  grid-template-columns: minmax(310px, 420px) minmax(0, 1fr);
  gap: 24px;
  width: min(1920px, 100%);
  margin: 0 auto;
  padding: 24px 16px 40px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.site-footer {
  margin-top: auto;
  padding: 18px clamp(16px, 4vw, 48px);
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-weight: 400;
  text-align: center;
}

.control-panel,
.result-panel {
  min-width: 0;
  padding: 20px;
}

.control-panel {
  align-self: start;
}

.control-panel:has(.csv-form:not([hidden])) {
  display: flex;
  flex-direction: column;
  min-height: 520px;
}

.result-panel {
  display: flex;
  flex-direction: column;
  min-height: 520px;
}

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

.panel-head p {
  margin-top: 6px;
}

.switch-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 4px;
  margin-bottom: 12px;
  border-radius: var(--radius-md);
  background: var(--surface-muted);
}

.switch-row.compact {
  margin-bottom: 18px;
}

.switch {
  min-height: 36px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 700;
}

.switch.active {
  background: var(--surface);
  color: var(--primary-dark);
  box-shadow: 0 1px 4px rgba(24, 72, 112, 0.13);
}

.input-form {
  display: grid;
  gap: 14px;
}

.csv-form {
  display: grid;
  flex: 1;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 14px;
  min-height: 0;
}

.field-row {
  display: grid;
  gap: 7px;
}

.field-row label,
.file-title {
  color: #334b5c;
  font-size: 0.9rem;
  font-weight: 700;
}

.field-row.optional label {
  color: var(--muted);
}

input,
select {
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
  border: 1px solid #c8d8e8;
  border-radius: var(--radius-sm);
  background: #ffffff;
  color: var(--text);
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(29, 127, 207, 0.18);
}

.early-only.hidden,
[hidden] {
  display: none !important;
}

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

.primary,
.secondary,
.link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 9px 32px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  font-weight: 800;
  text-decoration: none;
}

.primary {
  flex: 1;
  background: var(--primary);
  color: #ffffff;
}

.primary:hover {
  background: var(--primary-dark);
}

.secondary,
.link-button {
  background: #ffffff;
  border-color: #c8d8e8;
  color: var(--primary);
}

.secondary:hover,
.link-button:hover {
  border-color: var(--primary);
  color: var(--primary);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.file-zone {
  display: grid;
  gap: 8px;
  min-height: 0;
  height: 100%;
  padding: 18px;
  place-content: center;
  justify-items: center;
  border: 1px dashed #95b7d8;
  border-radius: var(--radius-md);
  background: #f7fbff;
  cursor: pointer;
  text-align: center;
}

.file-zone input {
  min-height: auto;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.file-name {
  color: var(--muted);
  word-break: break-word;
}

.result-head {
  align-items: center;
}

.model-note {
  margin-bottom: 12px;
  padding: 12px 14px;
  border-left: 4px solid var(--accent);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  background: #fff8ec;
  color: #563a12;
  line-height: 1.45;
}

.empty-state {
  display: grid;
  flex: 1;
  min-height: 320px;
  place-items: center;
  border: 1px dashed #b8cde1;
  border-radius: var(--radius-lg);
  background: #f7fbff;
  color: var(--muted);
  font-weight: 800;
  text-align: center;
}

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

.summary.empty,
.summary.error {
  display: block;
  padding: 14px;
  border-radius: var(--radius-md);
  background: #f2f7fb;
  color: var(--muted);
}

.summary.error {
  background: #fff1f0;
  color: var(--danger);
}

.metric {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: #fbfdff;
}

.metric span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

.metric strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 1.2rem;
  line-height: 1.15;
}

.table-shell {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
}

table {
  width: 100%;
  min-width: 780px;
  border-collapse: collapse;
  background: #ffffff;
}

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

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #eaf3ff;
  color: #25475f;
  font-size: 0.82rem;
  text-transform: uppercase;
}

td {
  color: #263847;
  line-height: 1.4;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-width: 74px;
  justify-content: center;
  padding: 5px 8px;
  border-radius: 999px;
  color: #ffffff;
  font-weight: 800;
}

.badge.low {
  background: var(--low);
}

.badge.medium {
  background: var(--medium);
}

.badge.high {
  background: var(--high);
}

.probability {
  font-variant-numeric: tabular-nums;
  font-weight: 800;
}

.loading {
  position: relative;
  pointer-events: none;
}

.loading::after {
  content: "";
  width: 16px;
  height: 16px;
  margin-left: 10px;
  border: 2px solid rgba(255, 255, 255, 0.5);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

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

@media (max-width: 680px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
    padding: 8px 28px;
  }

  .topbar p {
    font-size: 22px;
  }

  .status {
    /*width: 100%;*/
    justify-content: center;
    white-space: normal;
    display: none;
  }

  .workspace {
    padding-inline: 12px;
  }

  .control-panel,
  .result-panel {
    padding: 16px;
  }

  .summary {
    grid-template-columns: 1fr 1fr;
  }

  .actions {

  }
  .result-head {
    align-items: stretch;
    flex-direction: column;
  }

  .primary,
  .secondary,
  .link-button {
    /*width: 100%;*/
  }
}

@media (max-width: 430px) {
  .switch-row,
  .summary {
    /*grid-template-columns: 1fr;*/
  }
}
