:root {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --ink: #1b2230;
  --ink-soft: #566074;
  --muted: #8a93a6;
  --line: #e4e8ef;
  --brand: #1b57d6;
  --brand-dark: #113c99;
  --brand-tint: #eaf0fe;
  --ok: #1a7f52;
  --ok-tint: #e5f4ec;
  --warn: #9a5b00;
  --warn-tint: #fbf0da;
  --err: #b23636;
  --err-tint: #fbe8e8;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(20, 30, 50, .06), 0 6px 20px rgba(20, 30, 50, .05);
  --maxw: 1040px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.55;
  font-size: 16px;
  /* Sticky footer: the page fills at least the viewport and main takes up the free space. */
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

body > main { flex: 1 0 auto; }
body > .site-header,
body > .site-footer { flex-shrink: 0; }

.container {
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 20px;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { line-height: 1.2; color: var(--ink); }
h1 { font-size: 2rem; margin: .2em 0 .4em; letter-spacing: -.02em; }
h2 { font-size: 1.35rem; margin: 1.6em 0 .6em; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }

/* Header */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 62px;
}
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); font-size: 1.15rem; }
.brand:hover { text-decoration: none; }
.brand-mark {
  display: inline-grid; place-items: center;
  width: 30px; height: 30px; border-radius: 8px;
  background: var(--brand); color: #fff; font-size: 1rem;
}
.brand-name strong { color: var(--brand); }
.site-nav { display: flex; gap: 22px; }
.site-nav a { color: var(--ink-soft); font-weight: 500; }
.site-nav a:hover { color: var(--brand); text-decoration: none; }

/* Hero */
.hero { padding: 64px 0 40px; }
.hero p.lead { font-size: 1.2rem; color: var(--ink-soft); max-width: 60ch; }
.hero-actions { margin-top: 26px; display: flex; gap: 12px; flex-wrap: wrap; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 11px 20px; border-radius: var(--radius);
  font-weight: 600; font-size: .98rem; cursor: pointer;
  border: 1px solid transparent; transition: .15s;
}
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); text-decoration: none; }
.btn-ghost { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { border-color: var(--brand); color: var(--brand); text-decoration: none; }

/* Cards / grid */
.grid { display: grid; gap: 18px; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
}
.card h3 { margin: 0 0 6px; font-size: 1.08rem; }
.card p { margin: 0; color: var(--ink-soft); }

/* Search form */
.search-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
}
.form-row { display: flex; gap: 10px; flex-wrap: wrap; }
.form-row .grow { flex: 1 1 320px; }
label { display: block; font-weight: 600; font-size: .85rem; color: var(--ink-soft); margin-bottom: 6px; }
input[type=text], input[type=search], input[type=email], select {
  width: 100%; padding: 11px 13px; font-size: 1rem;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: #fff; color: var(--ink);
}
input:focus, select:focus { outline: 2px solid var(--brand-tint); border-color: var(--brand); }

/* Result list */
.result {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px 20px; margin-bottom: 14px;
}
.result-head { display: flex; justify-content: space-between; gap: 16px; align-items: baseline; flex-wrap: wrap; }
.result-name { font-size: 1.1rem; font-weight: 650; margin: 0; }
.pid { font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; font-size: .9rem; color: var(--brand-dark); background: var(--brand-tint); padding: 2px 8px; border-radius: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.chip { font-size: .8rem; background: var(--bg); border: 1px solid var(--line); border-radius: 100px; padding: 3px 11px; color: var(--ink-soft); }
.flag { font-size: .8rem; color: var(--muted); }

/* Tables */
table.data { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
table.data th, table.data td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.data th { background: var(--bg); font-size: .82rem; text-transform: uppercase; letter-spacing: .03em; color: var(--ink-soft); }
table.data tr:last-child td { border-bottom: none; }
code, .mono { font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; font-size: .88rem; }

/* Alerts */
.alert { border-radius: var(--radius); padding: 14px 16px; margin: 16px 0; border: 1px solid; }
.alert-info { background: var(--brand-tint); border-color: #cfe0fd; color: var(--brand-dark); }
.alert-ok { background: var(--ok-tint); border-color: #c6e7d4; color: var(--ok); }
.alert-warn { background: var(--warn-tint); border-color: #f0dcae; color: var(--warn); }
.alert-err { background: var(--err-tint); border-color: #f2c9c9; color: var(--err); }

/* SMP service details */
details.svc {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); margin-bottom: 10px;
}
details.svc > summary {
  cursor: pointer; padding: 14px 18px; display: flex; flex-wrap: wrap;
  align-items: center; gap: 8px; list-style: none;
}
details.svc > summary::-webkit-details-marker { display: none; }
details.svc > summary::before { content: "▸"; color: var(--muted); margin-right: 2px; }
details.svc[open] > summary::before { content: "▾"; }
details.svc[open] > summary { border-bottom: 1px solid var(--line); }
.svc-name { font-weight: 650; margin-right: 6px; }
.svc-body { padding: 14px 18px 18px; }
.svc-docid { word-break: break-all; color: var(--ink-soft); margin: 0 0 10px; }
.svc-endpoint { margin-top: 12px; }
.svc-section { font-size: .95rem; margin: 18px 0 4px; color: var(--ink-soft); }
details.sig-details { margin: 12px 0; border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 14px; background: var(--bg); }
details.sig-details > summary { cursor: pointer; font-weight: 600; font-size: .9rem; color: var(--ink-soft); display: flex; align-items: center; gap: 8px; }
details.sig-details[open] > summary { margin-bottom: 6px; }
.svc-endpoint td { word-break: break-all; }

.badge {
  display: inline-block; font-size: .75rem; font-weight: 600;
  padding: 2px 9px; border-radius: 100px;
  background: var(--brand-tint); color: var(--brand-dark);
}
.badge-ok { background: var(--ok-tint); color: var(--ok); }
.badge-warn { background: var(--warn-tint); color: var(--warn); }
.badge-err { background: var(--err-tint); color: var(--err); }

/* Code list labels */
.dt-name { font-weight: 600; }
.dt-id { word-break: break-all; margin-top: 2px; }
.scheme-label { font-size: .85rem; color: var(--ink-soft); }

/* Batch lookup */
textarea.batch-input {
  width: 100%; padding: 11px 13px; font-size: .92rem; resize: vertical;
  border: 1px solid var(--line); border-radius: var(--radius); background: #fff; color: var(--ink);
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
}
textarea.batch-input:focus { outline: 2px solid var(--brand-tint); border-color: var(--brand); }
.checkbox-label { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; color: var(--ink); padding-bottom: 10px; }
.batch-stats { display: flex; flex-wrap: wrap; gap: 8px; }
.table-scroll { width: 100%; overflow-x: auto; }
.batch-table td { word-break: break-word; }
.batch-table details summary { cursor: pointer; color: var(--brand); }
.batch-doclist { margin: 6px 0 0; padding-left: 18px; font-size: .85rem; }
.batch-error { color: var(--err); margin-top: 4px; }

/* Pagination */
.pager { display: flex; gap: 10px; align-items: center; margin-top: 20px; }

/* Footer */
.site-footer { border-top: 1px solid var(--line); margin-top: 64px; background: var(--surface); }
.footer-inner { display: flex; justify-content: space-between; align-items: center; padding: 22px 0; flex-wrap: wrap; gap: 10px; color: var(--ink-soft); font-size: .9rem; }
.footer-links { display: flex; gap: 18px; align-items: center; }

/* HTMX loading indicator */
.htmx-indicator { opacity: 0; transition: opacity .2s; }
.htmx-request .htmx-indicator { opacity: 1; }

@media (max-width: 760px) {
  .grid-3 { grid-template-columns: 1fr; }
  .site-nav { gap: 6px 14px; font-size: .92rem; flex-wrap: wrap; justify-content: flex-end; }
  .header-inner { height: auto; min-height: 62px; padding: 8px 0; gap: 12px; }
  .hero { padding: 40px 0 28px; }
  h1 { font-size: 1.6rem; }
}
