:root {
  --bg: #f5f7fa;
  --surface: #ffffff;
  --ink: #172033;
  --muted: #5f6f83;
  --line: #dce5ee;
  --blue: #1f4e79;
  --blue-soft: #e9f2f8;
  --teal: #0f766e;
  --teal-soft: #e7f5f2;
  --green: #2f7d42;
  --green-soft: #e8f5e9;
  --amber: #b66a09;
  --amber-soft: #fff4df;
  --red: #b42318;
  --red-soft: #feeceb;
  --shadow: 0 16px 36px rgba(23, 32, 51, 0.08);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  background: var(--bg);
}

body {
  margin: 0;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 24px;
}

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

.topnote {
  max-width: 720px;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.top-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--teal);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: 30px;
  line-height: 1.15;
}

h2 {
  margin-bottom: 0;
  font-size: 21px;
  line-height: 1.2;
}

h3 {
  margin-bottom: 8px;
  font-size: 16px;
}

.mode-switch {
  display: grid;
  grid-template-columns: repeat(3, minmax(96px, 1fr));
  gap: 8px;
  width: min(360px, 100%);
}

.mode,
.primary-button,
.soft-button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 900;
}

.mode.active,
.primary-button {
  border-color: var(--blue);
  background: var(--blue);
  color: #ffffff;
}

.soft-button {
  border-color: #b7ddd6;
  background: var(--teal-soft);
  color: var(--teal);
}

.primary-button:disabled,
.soft-button:disabled {
  cursor: wait;
  opacity: 0.68;
}

.auth-panel {
  display: grid;
  min-height: 520px;
  place-items: center;
}

.auth-card {
  display: grid;
  gap: 22px;
  width: min(620px, 100%);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.auth-card p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.55;
}

.auth-card code {
  color: var(--blue);
  font-weight: 900;
}

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

.helper-text,
.empty-text {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.app-shell {
  display: grid;
  gap: 16px;
}

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

.metric {
  min-height: 110px;
  padding: 18px;
  border: 1px solid var(--line);
  border-left: 5px solid var(--blue);
  border-radius: 8px;
  background: var(--surface);
}

.metric.teal {
  border-left-color: var(--teal);
}

.metric.green {
  border-left-color: var(--green);
}

.metric.amber {
  border-left-color: var(--amber);
}

.metric span,
.metric small {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.metric strong {
  display: block;
  margin: 10px 0 7px;
  font-size: 24px;
  line-height: 1.1;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr) 340px;
  gap: 16px;
}

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

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  min-height: 86px;
  padding: 22px 24px;
  border-bottom: 1px solid var(--line);
}

.panel-header.compact {
  min-height: 78px;
  padding: 18px;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid #b9d6e7;
  border-radius: 999px;
  background: var(--blue-soft);
  color: var(--blue);
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.badge.good {
  border-color: #b8d8be;
  background: var(--green-soft);
  color: var(--green);
}

.badge.warn {
  border-color: #f1ce95;
  background: var(--amber-soft);
  color: var(--amber);
}

.badge.bad {
  border-color: #f0b9b4;
  background: var(--red-soft);
  color: var(--red);
}

.upload-form {
  display: grid;
  gap: 18px;
  padding: 24px;
}

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

.field {
  display: grid;
  gap: 8px;
}

.field span,
.file-box span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

.field input,
.field select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #ffffff;
  color: var(--ink);
}

.file-grid {
  display: grid;
  gap: 12px;
}

.file-box {
  display: grid;
  gap: 8px;
  min-height: 112px;
  padding: 16px;
  border: 1px dashed #9bb7cc;
  border-radius: 8px;
  background: #f8fbfd;
}

.file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.file-control {
  display: flex;
  align-items: center;
  min-height: 38px;
  width: 100%;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  font-size: 14px;
  font-weight: 800;
}

.file-box small {
  color: var(--muted);
  font-size: 12px;
}

.button-row {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.button-row button,
.run-button {
  min-width: 138px;
}

.upload-list {
  display: grid;
  gap: 10px;
  margin: 0 24px 24px;
}

.upload-item {
  display: grid;
  gap: 5px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
  color: var(--muted);
  font-size: 13px;
}

.upload-item strong {
  color: var(--ink);
}

.mini-badge {
  width: fit-content;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--blue-soft);
  color: var(--blue);
  font-size: 11px;
  font-weight: 900;
}

.mini-badge.good,
b.good {
  color: var(--green);
}

.mini-badge.warn,
b.warn {
  color: var(--amber);
}

.run-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  align-items: center;
  margin: 24px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
}

.run-card p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 0 24px 18px;
}

.result-grid article,
.insight-list article {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.result-grid article {
  min-height: 92px;
  padding: 16px;
}

.result-grid span,
.insight-list span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.result-grid strong {
  display: block;
  margin-top: 8px;
  font-size: 22px;
}

.log-box {
  min-height: 184px;
  max-height: 260px;
  overflow: auto;
  margin: 0 24px 24px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #111827;
  color: #d1fae5;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.launch-card {
  margin: 18px;
  padding: 16px;
  border: 1px solid #b8d8be;
  border-radius: 8px;
  background: var(--green-soft);
}

.launch-card.warn {
  border-color: #f1ce95;
  background: var(--amber-soft);
}

.launch-card strong {
  display: block;
  margin-bottom: 8px;
}

.launch-card p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.insight-list {
  display: grid;
  gap: 10px;
  margin: 0 18px 18px;
}

.insight-list article {
  min-height: 108px;
  padding: 14px;
}

.insight-list p {
  margin: 8px 0 0;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.45;
}

.reports-panel,
.audit-panel {
  min-height: auto;
}

.report-layout {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: 16px;
  padding: 18px;
}

.report-list {
  display: grid;
  align-content: start;
  gap: 10px;
}

.report-button {
  display: grid;
  gap: 6px;
  min-height: 62px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfe;
  color: var(--ink);
  text-align: left;
}

.report-button.active {
  border-color: var(--blue);
  background: var(--blue-soft);
}

.report-button span {
  font-weight: 900;
}

.report-button small {
  color: var(--muted);
}

.report-viewer {
  min-height: 460px;
  max-height: 640px;
  overflow: auto;
  margin: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0f172a;
  color: #e5eef8;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
}

.audit-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  padding: 18px;
}

.audit-item {
  display: grid;
  gap: 6px;
  min-height: 76px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
}

.audit-item strong {
  color: var(--ink);
  font-size: 13px;
}

.audit-item span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

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

  .launch-panel {
    grid-column: 1 / -1;
    min-height: auto;
  }

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

@media (max-width: 820px) {
  .shell {
    padding: 16px;
  }

  .topbar,
  .layout,
  .metric-grid,
  .form-grid,
  .result-grid,
  .run-card,
  .report-layout,
  .audit-list {
    grid-template-columns: 1fr;
  }

  .topbar {
    display: grid;
  }

  .top-actions {
    justify-content: flex-start;
  }

  .mode-switch {
    width: 100%;
  }

  .panel {
    min-height: auto;
  }

  .button-row {
    display: grid;
  }

  .report-viewer {
    min-height: 360px;
  }
}

@media (max-width: 520px) {
  h1 {
    font-size: 24px;
  }

  h2 {
    font-size: 19px;
  }

  .mode-switch {
    grid-template-columns: 1fr;
  }

  .panel-header {
    display: grid;
  }
}
