:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-strong: #eef3f8;
  --text: #17202a;
  --muted: #637083;
  --border: #dbe2ea;
  --accent: #0f766e;
  --accent-strong: #115e59;
  --danger: #b42318;
  --warn: #a15c07;
  --shadow: 0 18px 44px rgba(36, 48, 64, 0.12);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  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;
}

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 20px 0 24px;
}

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

h1 {
  font-size: 28px;
  line-height: 1.2;
  font-weight: 750;
}

h2 {
  font-size: 16px;
  line-height: 1.3;
  font-weight: 720;
}

h3 {
  font-size: 13px;
  line-height: 1.3;
  font-weight: 720;
}

.topbar p,
.results-header p,
.detail-header p {
  margin-top: 8px;
  color: var(--muted);
  font-size: 14px;
}

.file-actions {
  display: flex;
  gap: 10px;
  flex: 0 0 auto;
}

.file-button,
.ghost-button,
.icon-button {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  min-height: 38px;
  border-radius: var(--radius);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 14px;
  cursor: pointer;
}

.file-button {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
  font-weight: 680;
}

.file-button input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
  pointer-events: none;
}

.ghost-button:disabled {
  cursor: not-allowed;
  color: #98a2b3;
  background: #f2f4f7;
}

.icon-button {
  width: 38px;
  padding: 0;
  font-size: 24px;
}

.drop-zone {
  border: 1px dashed #9fb3c8;
  background: #edf6f5;
  border-radius: var(--radius);
  min-height: 84px;
  display: grid;
  place-items: center;
  color: var(--accent-strong);
  margin-bottom: 18px;
}

.drop-zone.is-dragging {
  outline: 3px solid rgba(15, 118, 110, 0.18);
  background: #e2f4f1;
}

.drop-zone div {
  display: flex;
  gap: 10px;
  align-items: baseline;
  flex-wrap: wrap;
  padding: 16px;
}

.drop-zone span {
  color: var(--muted);
  font-size: 14px;
}

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

.metric {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

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

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 24px;
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.workspace {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 18px;
}

.sidebar,
.results,
.detail-panel {
  min-width: 0;
}

.panel,
.results,
.detail-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

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

.field {
  display: grid;
  gap: 6px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 680;
}

.field input,
.field select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-height: 38px;
  padding: 0 10px;
  color: var(--text);
  background: #ffffff;
}

.panel .ghost-button {
  width: 100%;
  margin-top: 14px;
}

.level-list {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.level-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 6px;
  background: var(--surface-strong);
  font-size: 13px;
}

.results {
  overflow: hidden;
}

.results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.table-wrap {
  overflow: auto;
  max-height: 620px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

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

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f9fafb;
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
}

tbody tr {
  cursor: pointer;
}

tbody tr:hover,
tbody tr.is-selected {
  background: #edf6f5;
}

.count-cell {
  width: 82px;
  font-weight: 780;
  color: var(--accent-strong);
}

.type-cell {
  min-width: 260px;
}

.type-cell strong,
.origin-cell strong {
  display: block;
  overflow-wrap: anywhere;
}

.type-cell span,
.time-cell span {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.origin-cell {
  min-width: 320px;
  overflow-wrap: anywhere;
}

.time-cell {
  min-width: 190px;
  color: var(--muted);
}

.empty-cell {
  text-align: center;
  color: var(--muted);
  padding: 42px;
  cursor: default;
}

.detail-panel {
  margin-top: 18px;
  box-shadow: var(--shadow);
}

.detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 18px;
  border-bottom: 1px solid var(--border);
}

.count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 42px;
  height: 26px;
  border-radius: 999px;
  background: var(--accent);
  color: #ffffff;
  font-size: 12px;
  font-weight: 760;
  margin-bottom: 10px;
}

.detail-body {
  display: grid;
  gap: 18px;
  padding: 18px;
  min-width: 0;
}

.detail-body > section {
  min-width: 0;
}

.message-box {
  margin-top: 8px;
  padding: 12px;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: var(--radius);
  color: #7c2d12;
  overflow-wrap: anywhere;
  font-size: 13px;
}

.examples {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 10px;
  margin-top: 8px;
  min-width: 0;
}

.example {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  background: #fbfcfe;
  font-size: 12px;
  color: var(--muted);
  min-width: 0;
  overflow: hidden;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.example strong {
  display: block;
  color: var(--text);
  margin-bottom: 5px;
  overflow-wrap: anywhere;
}

.stack-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

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

pre {
  margin: 8px 0 0;
  padding: 14px;
  width: 100%;
  max-width: 100%;
  max-height: 520px;
  overflow: auto;
  border-radius: var(--radius);
  background: #111827;
  color: #e5e7eb;
  font: 12px/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre;
}

@media (max-width: 980px) {
  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

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

  .panel {
    margin-bottom: 0;
  }
}

@media (max-width: 680px) {
  .app-shell {
    padding: 14px;
  }

  .topbar,
  .results-header {
    align-items: stretch;
    flex-direction: column;
  }

  .file-actions,
  .file-button,
  .results-header .ghost-button {
    width: 100%;
  }

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

  .drop-zone div {
    display: grid;
    text-align: center;
  }

  th,
  td {
    padding: 10px;
  }

  .stack-title {
    align-items: stretch;
    flex-direction: column;
  }

  .stack-actions,
  .stack-actions .ghost-button {
    width: 100%;
  }
}
