:root {
  color-scheme: light;
  --bg: #f6f7f8;
  --surface: #ffffff;
  --surface-soft: #eef3f1;
  --ink: #17201c;
  --muted: #66736f;
  --line: #d9e0dd;
  --accent: #0f766e;
  --accent-dark: #115e59;
  --amber: #b45309;
  --red: #b42318;
  --blue: #1d4ed8;
  --shadow: 0 18px 50px rgba(23, 32, 28, 0.08);
  font-family:
    "Segoe UI",
    Tahoma,
    Arial,
    sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.topbar {
  align-items: center;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  min-height: 76px;
  padding: 14px clamp(18px, 3vw, 36px);
  position: sticky;
  top: 0;
  z-index: 5;
}

.eyebrow,
.topbar h1,
.panel-head h2,
.result-toolbar h2 {
  margin: 0;
}

.eyebrow {
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.topbar h1 {
  font-size: clamp(1.35rem, 2vw, 1.85rem);
  line-height: 1.2;
}

.status-pill {
  align-items: center;
  background: var(--surface-soft);
  border: 1px solid #c7d5d1;
  border-radius: 999px;
  color: var(--accent-dark);
  display: inline-flex;
  font-size: 0.9rem;
  font-weight: 700;
  min-height: 34px;
  padding: 0 14px;
  white-space: nowrap;
}

.status-pill.busy {
  background: #fff7ed;
  border-color: #fed7aa;
  color: var(--amber);
}

.status-pill.error {
  background: #fef3f2;
  border-color: #fecdca;
  color: var(--red);
}

.workspace {
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(310px, 410px) minmax(0, 1fr);
  margin: 0 auto;
  max-width: 1540px;
  min-height: calc(100vh - 76px);
  padding: 18px;
}

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

.input-panel {
  align-self: start;
  position: sticky;
  top: 94px;
}

.panel-head,
.result-toolbar {
  align-items: flex-start;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 18px;
  justify-content: space-between;
  padding: 18px;
}

.panel-head p,
.result-toolbar p {
  color: var(--muted);
  margin: 6px 0 0;
}

.analysis-form {
  display: grid;
  gap: 16px;
  padding: 18px;
}

.field {
  border: 0;
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
}

.field span,
.field legend {
  color: #34423e;
  font-size: 0.92rem;
  font-weight: 800;
}

.field input[type="text"],
.field input[type="file"],
.field textarea,
.filter-row input,
.filter-row select {
  background: #fbfcfc;
  border: 1px solid #cfd8d5;
  border-radius: 6px;
  color: var(--ink);
  min-height: 42px;
  outline: none;
  padding: 10px 12px;
  width: 100%;
}

.field input:focus,
.field textarea:focus,
.filter-row input:focus,
.filter-row select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.13);
}

.field textarea {
  line-height: 1.65;
  min-height: 190px;
  resize: vertical;
}

.file-field small {
  color: var(--muted);
}

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

.chip-grid label {
  align-items: center;
  background: #fbfcfc;
  border: 1px solid #d4ddda;
  border-radius: 6px;
  color: #2d3a36;
  display: flex;
  gap: 8px;
  min-height: 38px;
  padding: 0 10px;
}

.chip-grid input,
.segmented input {
  accent-color: var(--accent);
}

.segmented {
  background: #edf3f1;
  border: 1px solid #cfdad6;
  border-radius: 8px;
  display: grid;
  gap: 4px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  padding: 4px;
}

.segmented label {
  min-width: 0;
}

.segmented input {
  position: absolute;
  opacity: 0;
}

.segmented span {
  align-items: center;
  border-radius: 6px;
  color: #40504b;
  display: flex;
  font-weight: 800;
  justify-content: center;
  min-height: 38px;
  padding: 0 6px;
}

.segmented input:checked + span {
  background: var(--surface);
  box-shadow: 0 8px 18px rgba(23, 32, 28, 0.09);
  color: var(--accent-dark);
}

.primary-action,
.toolbar-actions button,
.tabs button,
.filter-row button,
.copy-case {
  border: 1px solid transparent;
  border-radius: 6px;
  font-weight: 800;
  min-height: 40px;
  padding: 0 14px;
}

.primary-action {
  background: var(--accent);
  color: white;
}

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

.primary-action:disabled,
.toolbar-actions button:disabled {
  cursor: not-allowed;
  opacity: 0.56;
}

.toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.toolbar-actions button,
.filter-row button,
.copy-case {
  background: #f7faf9;
  border-color: #cfd8d5;
  color: #26332f;
}

.toolbar-actions button:not(:disabled):hover,
.filter-row button:hover,
.copy-case:hover {
  border-color: var(--accent);
  color: var(--accent-dark);
}

.progress-wrap {
  border-bottom: 1px solid var(--line);
  padding: 14px 18px;
}

.progress-bar {
  background: #e4ebe8;
  border-radius: 999px;
  height: 9px;
  overflow: hidden;
}

.progress-bar span {
  animation: progressPulse 1.5s ease-in-out infinite;
  background: linear-gradient(90deg, var(--accent), var(--blue));
  display: block;
  height: 100%;
  width: 42%;
}

.progress-wrap p {
  color: var(--muted);
  margin: 8px 0 0;
}

.progress-line {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.progress-line button {
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: 6px;
  color: var(--amber);
  font-weight: 800;
  min-height: 34px;
  padding: 0 12px;
}

@keyframes progressPulse {
  0% {
    transform: translateX(110%);
  }

  100% {
    transform: translateX(-245%);
  }
}

.tabs {
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 10px 18px;
}

.tabs button {
  background: transparent;
  color: var(--muted);
  white-space: nowrap;
}

.tabs button.active {
  background: var(--surface-soft);
  color: var(--accent-dark);
}

.empty-state {
  align-items: center;
  color: var(--muted);
  display: grid;
  gap: 8px;
  justify-items: center;
  min-height: 420px;
  padding: 38px;
  text-align: center;
}

.empty-state strong {
  color: var(--ink);
  font-size: 1.2rem;
}

.result-content {
  padding: 18px;
}

.hidden {
  display: none !important;
}

.metric-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  margin-bottom: 18px;
}

.metric {
  background: #fbfcfc;
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 84px;
  padding: 14px;
}

.metric span {
  color: var(--muted);
  display: block;
  font-size: 0.82rem;
  font-weight: 800;
}

.metric strong {
  display: block;
  font-size: 1.35rem;
  margin-top: 6px;
}

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

.section-block {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.section-block.full {
  grid-column: 1 / -1;
}

.section-block h3,
.test-card h3,
.risk-row h3 {
  font-size: 1rem;
  margin: 0 0 10px;
}

.section-block p {
  line-height: 1.8;
  margin: 0;
}

.clean-list {
  display: grid;
  gap: 8px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.clean-list li {
  background: #fbfcfc;
  border: 1px solid #e1e7e4;
  border-radius: 6px;
  line-height: 1.65;
  padding: 9px 10px;
}

.filter-row {
  align-items: center;
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(160px, 1fr) 140px 180px 116px;
  margin-bottom: 14px;
}

.test-list {
  display: grid;
  gap: 12px;
}

.test-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.test-card header {
  align-items: flex-start;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 10px;
}

.badge {
  background: var(--surface-soft);
  border-radius: 999px;
  color: #2d4944;
  display: inline-flex;
  font-size: 0.78rem;
  font-weight: 800;
  line-height: 1.2;
  padding: 5px 9px;
}

.badge.priority-p0,
.badge.priority-critical,
.badge.priority-blocking,
.badge.risk-high {
  background: #fef3f2;
  color: var(--red);
}

.badge.priority-p1,
.badge.priority-important,
.badge.risk-medium {
  background: #fff7ed;
  color: var(--amber);
}

.badge.priority-p2,
.badge.priority-nice-to-have,
.badge.risk-low {
  background: #eff8ff;
  color: var(--blue);
}

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

.case-detail div {
  background: #fbfcfc;
  border: 1px solid #e1e7e4;
  border-radius: 6px;
  line-height: 1.7;
  min-width: 0;
  padding: 10px;
}

.case-detail div.full {
  grid-column: 1 / -1;
}

.case-detail strong {
  color: #34423e;
  display: block;
  margin-bottom: 4px;
}

.case-detail ol,
.case-detail ul {
  margin: 0;
  padding-inline-start: 20px;
}

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

.risk-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 8px;
  padding: 14px;
}

.risk-row p {
  line-height: 1.75;
  margin: 0;
}

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

.mini-list {
  background: #fbfcfc;
  border: 1px solid #e1e7e4;
  border-radius: 6px;
  line-height: 1.65;
  padding: 10px;
}

.mini-list strong {
  display: block;
  margin-bottom: 6px;
}

.mini-list ul,
.mini-list p {
  margin: 0;
}

.source-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 8px;
  line-height: 1.7;
  padding: 12px;
}

.source-row code {
  direction: ltr;
  display: inline-block;
  text-align: left;
}

.toast {
  background: #17201c;
  border-radius: 8px;
  bottom: 18px;
  color: white;
  padding: 11px 14px;
  position: fixed;
  right: 18px;
  z-index: 20;
}

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

  .input-panel {
    position: static;
  }

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

@media (max-width: 720px) {
  .topbar {
    align-items: flex-start;
    gap: 12px;
  }

  .workspace {
    padding: 10px;
  }

  .panel-head,
  .result-toolbar,
  .test-card header,
  .progress-line {
    display: grid;
  }

  .toolbar-actions {
    justify-content: stretch;
  }

  .toolbar-actions button,
  .primary-action {
    width: 100%;
  }

  .metric-grid,
  .content-grid,
  .case-detail,
  .filter-row,
  .data-plan-grid,
  .chip-grid {
    grid-template-columns: 1fr;
  }
}
