:root {
  color-scheme: light;
  --bg: #f5f7f6;
  --panel: #ffffff;
  --panel-2: #f1f5f3;
  --line: #dbe4df;
  --text: #16201d;
  --muted: #5f6c68;
  --accent: #0f766e;
  --accent-2: #2563eb;
  --accent-soft: rgba(15, 118, 110, 0.1);
  --accent-line: rgba(15, 118, 110, 0.28);
  --good: #167a4a;
  --warn: #b76d14;
  --bad: #b83a3a;
  --shadow: 0 18px 40px rgba(22, 32, 29, 0.08);
  --radius: 8px;
}

html[data-accent="cyan"] {
  --accent: #0f766e;
  --accent-2: #2563eb;
}

html[data-accent="green"] {
  --accent: #167a4a;
  --accent-2: #0f766e;
}

html[data-accent="amber"] {
  --accent: #b7791f;
  --accent-2: #2563eb;
}

html[data-accent="rose"] {
  --accent: #b83a3a;
  --accent-2: #2563eb;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(900px 500px at 100% -10%, rgba(37, 99, 235, 0.06), transparent 55%),
    radial-gradient(700px 400px at 0% 110%, rgba(15, 118, 110, 0.06), transparent 55%),
    var(--bg);
  font: 14px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

button,
textarea,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
  color: inherit;
}

button:disabled {
  opacity: 0.65;
  cursor: wait;
}

.shell {
  width: min(1360px, calc(100% - 24px));
  margin: 0 auto;
  padding: 18px 0 36px;
}

.topbar {
  display: grid;
  gap: 8px;
  align-items: start;
  margin-bottom: 16px;
  padding: 20px 22px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.92);
  border-top: 4px solid var(--accent);
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}

.headline {
  min-width: 0;
}

.eyebrow {
  display: inline-block;
  margin-bottom: 4px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.headline h1 {
  margin: 0;
  font-size: 30px;
  line-height: 1.2;
}

.headline p {
  margin: 6px 0 0;
  color: var(--muted);
  max-width: 820px;
}

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

.panel {
  min-width: 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, #ffffff 0%, #fbfcfb 100%);
  box-shadow: var(--shadow);
}

.input-panel {
  grid-column: 1 / 2;
}

.stats-panel {
  grid-column: 2 / 3;
  align-self: start;
}

.notice-panel {
  grid-column: 1 / -1;
}

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

.panel h2 {
  margin: 0;
  font-size: 15px;
  letter-spacing: 0.2px;
}

.counter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.panel-note {
  margin: -6px 0 12px;
  color: var(--muted);
}

textarea {
  width: 100%;
  min-height: 180px;
  padding: 15px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfb;
  color: var(--text);
  resize: vertical;
  outline: none;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  line-height: 1.7;
}

textarea:focus,
input:focus {
  border-color: var(--accent-line);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
}

.hint {
  min-width: 0;
  color: var(--muted);
}

.buttons {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 16px;
  border-radius: 8px;
  font-weight: 700;
}

.btn.ghost {
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--muted);
}

.btn.primary {
  border: 1px solid var(--accent-line);
  background: var(--accent);
  color: #fff;
}

.btn.primary:hover {
  filter: brightness(1.02);
}

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

.summary {
  grid-column: 1 / -1;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.stat {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff 0%, #f9fbfa 100%);
  box-shadow: var(--shadow);
}

.stat .label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}

.stat .value {
  margin-top: 6px;
  font-size: 20px;
  font-weight: 800;
}

.stat.ok .value {
  color: var(--good);
}

.stat.warn .value {
  color: var(--warn);
}

.stat.bad .value {
  color: var(--bad);
}

.notice {
  margin: 0;
  padding: 12px 14px;
  border-left: 4px solid var(--bad);
  background: rgba(184, 58, 58, 0.06);
  color: var(--bad);
  border-radius: 6px;
  font-weight: 700;
}

.workspace {
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr);
  gap: 16px;
  grid-column: 1 / -1;
}

.buckets {
  align-self: start;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, #ffffff 0%, #fafcfb 100%);
  box-shadow: var(--shadow);
}

.bucket {
  width: 100%;
  min-height: 42px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px;
  cursor: pointer;
}

.bucket.active {
  color: #fff;
  background: var(--accent);
}

.bucket b {
  min-width: 28px;
  text-align: right;
}

.result-panel {
  min-width: 0;
}

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

.search-field {
  display: grid;
  gap: 6px;
  min-width: 220px;
  color: var(--muted);
}

.search-field span {
  font-size: 12px;
  font-weight: 700;
}

.search-field input {
  width: 100%;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  background: #fff;
}

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

.result-table {
  width: 100%;
  min-width: 900px;
  border-collapse: collapse;
  background: #fff;
}

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

.result-table th {
  position: sticky;
  top: 0;
  background: #f8faf9;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.result-table td {
  color: var(--text);
}

.result-table tbody tr:hover {
  background: #fbfcfb;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
}

.dim {
  color: var(--muted);
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.pill.ok {
  background: rgba(22, 122, 74, 0.1);
  color: var(--good);
}

.pill.warn {
  background: rgba(183, 109, 20, 0.1);
  color: var(--warn);
}

.pill.bad {
  background: rgba(184, 58, 58, 0.1);
  color: var(--bad);
}

.pill.neutral {
  background: rgba(94, 106, 104, 0.1);
  color: var(--muted);
}

.empty-row td {
  color: var(--muted);
  text-align: center;
  padding: 20px 12px;
}

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

  .input-panel,
  .stats-panel,
  .notice-panel,
  .summary {
    grid-column: auto;
  }

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

@media (max-width: 720px) {
  .shell {
    width: min(100% - 16px, 1280px);
    padding-top: 8px;
  }

  .topbar {
    grid-template-columns: 1fr;
    justify-items: start;
  }

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

  .buttons {
    width: 100%;
  }

  .btn {
    flex: 1;
  }

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

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