:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --text: #1c2430;
  --muted: #657386;
  --line: #d8dee7;
  --accent: #1f6feb;
  --accent-strong: #185abc;
  --danger: #b42318;
  --warn: #946200;
  --ok: #0f6b4f;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", Arial, sans-serif;
  font-size: 15px;
}

.shell {
  width: min(1120px, calc(100% - 32px));
  margin: 24px auto 48px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 18px;
}

h1, h2, p {
  margin: 0;
}

h1 {
  font-size: 30px;
  line-height: 1.1;
}

h2 {
  font-size: 18px;
  line-height: 1.25;
}

p {
  color: var(--muted);
  margin-top: 4px;
}

.status-pill {
  border: 1px solid var(--line);
  background: #eef4ff;
  color: #1a4f9c;
  padding: 7px 10px;
  border-radius: 6px;
  white-space: nowrap;
}

.panel, .log-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  margin-top: 14px;
}

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

.upload-row, .generate-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.file-picker {
  flex: 1;
  min-height: 44px;
  display: flex;
  align-items: center;
  border: 1px dashed #aab6c6;
  border-radius: 8px;
  background: #fbfcfe;
  padding: 0 14px;
  cursor: pointer;
}

.file-picker input {
  display: none;
}

button, .download-all, .secondary-action {
  min-height: 40px;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  padding: 0 14px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}

button:hover, .download-all:hover, .secondary-action:hover {
  background: var(--accent-strong);
}

button:disabled {
  opacity: .55;
  cursor: not-allowed;
}

.secondary-action {
  background: #eef4ff;
  border: 1px solid #b8c9e8;
  color: #1a4f9c;
  white-space: nowrap;
}

.secondary-action:hover {
  background: #dfeaff;
}

.secondary-action[aria-disabled="true"] {
  opacity: .6;
  pointer-events: none;
}

.progress {
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: #e9edf3;
  margin-top: 14px;
}

.progress div {
  width: 45%;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  animation: slide 1.1s linear infinite;
}

@keyframes slide {
  0% { transform: translateX(-110%); }
  100% { transform: translateX(260%); }
}

.metrics {
  display: flex;
  gap: 10px;
  color: var(--muted);
  white-space: nowrap;
}

.metrics span {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 8px;
}

.issue-groups {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
}

.issue-severity {
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
}

.issue-severity summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 12px;
  cursor: pointer;
  font-weight: 700;
  list-style-position: inside;
}

.issue-severity summary b {
  border-radius: 999px;
  min-width: 28px;
  padding: 3px 8px;
  text-align: center;
  font-size: 13px;
}

.issue-severity.error summary {
  background: #fff3f1;
  color: var(--danger);
}

.issue-severity.error summary b {
  background: #f7d6d2;
}

.issue-severity.warning summary {
  background: #fff8e6;
  color: var(--warn);
}

.issue-severity.warning summary b {
  background: #f4e4b8;
}

.issue-category {
  border-top: 1px solid var(--line);
  padding: 12px;
}

.issue-category h3 {
  margin: 0 0 8px;
  font-size: 14px;
}

.issue-row {
  display: grid;
  grid-template-columns: minmax(92px, 140px) 1fr;
  gap: 10px;
  padding: 8px 0;
  border-top: 1px solid #eef1f5;
}

.issue-row:first-of-type {
  border-top: 0;
}

.issue-row strong {
  color: var(--text);
}

.issue-row span, .issue-empty {
  color: var(--muted);
}

.issue-empty {
  border-top: 1px solid var(--line);
  padding: 12px;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
}

.file-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 10px;
}

.file-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.file-item a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

.current-stage {
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfe;
  padding: 10px 12px;
  color: var(--text);
  font-weight: 600;
}

.log-details {
  margin-top: 10px;
}

.log-details summary {
  cursor: pointer;
  color: var(--accent);
  font-weight: 600;
}

.log-panel pre {
  margin: 10px 0 0;
  white-space: pre-wrap;
  font-family: Consolas, "Courier New", monospace;
  color: var(--muted);
}

@media (max-width: 720px) {
  .topbar, .panel-head, .upload-row, .generate-row {
    align-items: stretch;
    flex-direction: column;
  }

  .metrics {
    white-space: normal;
  }

  button, .download-all {
    justify-content: center;
  }

  .secondary-action {
    justify-content: center;
    width: 100%;
  }

  .issue-row {
    grid-template-columns: 1fr;
    gap: 3px;
  }
}
