:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --ink: #1b2733;
  --ink-soft: #5b6b7b;
  --line: #dbe2e9;
  --brand: #1a7a4c;
  --brand-ink: #ffffff;
  --focus: #0b6bcb;
  --c1: #b3261e;
  --c1-bg: #fdecea;
  --c2: #9a6700;
  --c2-bg: #fff8e1;
  --c3: #0b6bcb;
  --c3-bg: #e8f1fc;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(16, 32, 48, .08), 0 6px 18px rgba(16, 32, 48, .05);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.65 "Segoe UI", "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB", sans-serif;
}

.wrap { width: 100%; max-width: 960px; margin: 0 auto; padding: 0 20px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- header ---------- */
.topbar {
  background: linear-gradient(180deg, #1f6f4a, #17593c);
  color: #fff;
  padding: 22px 0 20px;
}
.brand { margin: 0; font-size: 1.4rem; letter-spacing: .02em; }
.brand a { color: inherit; text-decoration: none; }
.tagline { margin: 4px 0 0; opacity: .85; font-size: .92rem; }

/* ---------- query card ---------- */
.query-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin: -14px 0 18px;
}
#query-form {
  display: grid;
  grid-template-columns: minmax(140px, 180px) 1fr auto;
  gap: 14px;
  align-items: start;
}
.field { display: flex; flex-direction: column; min-width: 0; }
.field label { font-size: .85rem; font-weight: 600; color: var(--ink-soft); margin-bottom: 5px; }
.field-actions { align-self: stretch; justify-content: flex-end; flex-direction: row; gap: 8px; }

select, input[type="text"], input[type="search"] {
  font: inherit;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 11px;
  width: 100%;
  min-width: 0;
}
select:focus-visible,
input:focus-visible,
.btn:focus-visible,
.chip:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
}
.hint { margin: 5px 0 0; font-size: .78rem; color: var(--ink-soft); }

.btn {
  font: inherit;
  cursor: pointer;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 8px;
  padding: 9px 16px;
  white-space: nowrap;
}
.btn:hover { background: #f0f3f6; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); font-weight: 600; }
.btn.primary:hover { background: #15653f; }

/* ---------- combobox ---------- */
.combo { position: relative; }
.suggest {
  position: absolute; z-index: 30; top: calc(100% + 4px); left: 0; right: 0;
  margin: 0; padding: 4px;
  list-style: none;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  max-height: 288px; overflow-y: auto;
}
.suggest li {
  padding: 7px 9px; border-radius: 6px; cursor: pointer;
  display: flex; gap: 9px; align-items: baseline;
}
.suggest li[aria-selected="true"], .suggest li:hover { background: #eaf3ee; }
.suggest .s-code { font-family: ui-monospace, Consolas, monospace; font-weight: 600; flex: none; }
.suggest .s-name { color: var(--ink-soft); font-size: .88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- status ---------- */
.status:empty { display: none; }
.status {
  margin-bottom: 14px; padding: 11px 14px; border-radius: 8px;
  background: #fff8e1; border: 1px solid #f0dfa8; color: #6b5200; font-size: .92rem;
}
.status.error { background: var(--c1-bg); border-color: #f2c3bf; color: #86211a; }

/* ---------- result ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 18px;
}
.card-head { padding: 16px 18px; border-bottom: 1px solid var(--line); }
.code-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.code-big {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 1.5rem; font-weight: 700; letter-spacing: .01em;
}
.card-name { margin: 6px 0 0; font-size: 1.05rem; font-weight: 600; }

.badge {
  font-size: .76rem; font-weight: 700; padding: 3px 9px; border-radius: 999px;
  border: 1px solid transparent; white-space: nowrap;
}
.badge.c1 { background: var(--c1-bg); color: var(--c1); border-color: #f2c3bf; }
.badge.c2 { background: var(--c2-bg); color: var(--c2); border-color: #ecdca6; }
.badge.c3 { background: var(--c3-bg); color: var(--c3); border-color: #c2dcf7; }
.badge.plain { background: #eef1f4; color: var(--ink-soft); border-color: var(--line); }

.meta {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1px; background: var(--line);
  border-bottom: 1px solid var(--line);
}
.meta div { background: #fafbfc; padding: 10px 14px; }
.meta dt { font-size: .74rem; color: var(--ink-soft); font-weight: 600; margin: 0 0 2px; }
.meta dd { margin: 0; font-family: ui-monospace, Consolas, monospace; font-size: .92rem; }

.sections { padding: 4px 18px 16px; }
.sec { padding: 13px 0; border-bottom: 1px dashed var(--line); }
.sec:last-child { border-bottom: 0; }
.sec h3 {
  margin: 0 0 7px; font-size: .95rem;
  display: flex; align-items: center; gap: 7px;
}
.sec h3 .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--brand); flex: none; }
.sec ol, .sec ul { margin: 0; padding-left: 1.35em; }
.sec li { margin: 3px 0; }
.sec .none { color: var(--ink-soft); font-style: italic; }

.flags {
  margin: 0 18px 4px; padding: 10px 13px;
  background: var(--c2-bg); border: 1px solid #ecdca6; border-radius: 8px;
  font-size: .83rem; color: #6b5200;
}
.flags strong { display: block; margin-bottom: 3px; }
.flags ul { margin: 0; padding-left: 1.2em; }
.flags code { font-family: ui-monospace, Consolas, monospace; }

.prov { padding: 10px 18px; background: #f7f9fa; border-top: 1px solid var(--line); font-size: .78rem; color: var(--ink-soft); }
.prov code { font-family: ui-monospace, Consolas, monospace; }

/* ---------- browse ---------- */
.browse { margin-bottom: 22px; }
.browse-head { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 10px; }
.browse-head h2 { margin: 0; font-size: 1.05rem; flex: 1 1 auto; }
.filters { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  font: inherit; font-size: .82rem; cursor: pointer;
  border: 1px solid var(--line); background: #fff; color: var(--ink-soft);
  border-radius: 999px; padding: 4px 12px;
}
.chip[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
#browse-search { flex: 0 1 220px; }

.table-scroll {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: auto; max-height: 60vh;
}
.grid { border-collapse: collapse; width: 100%; font-size: .9rem; }
.grid th, .grid td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--line); }
.grid thead th {
  position: sticky; top: 0; z-index: 2;
  background: #f0f3f6; font-size: .78rem; color: var(--ink-soft);
}
.grid tbody tr { cursor: pointer; }
.grid tbody tr:hover { background: #eaf3ee; }
.grid td:first-child { font-family: ui-monospace, Consolas, monospace; font-weight: 600; white-space: nowrap; }
.grid td:nth-child(5), .grid td:nth-child(6) { font-family: ui-monospace, Consolas, monospace; color: var(--ink-soft); }

/* ---------- footer ---------- */
.footer { padding: 8px 20px 30px; }
.muted { color: var(--ink-soft); font-size: .8rem; }
.warn { border-left: 3px solid var(--c2); padding-left: 10px; }

@media (max-width: 720px) {
  #query-form { grid-template-columns: 1fr; }
  .field-actions { justify-content: stretch; }
  .field-actions .btn { flex: 1; }
  .code-big { font-size: 1.3rem; }
}
