:root {
    --blue: #1d4ed8;
    --blue-dark: #1e3a8a;
    --blue-soft: #e8f0ff;
    --ink: #1f2937;
    --muted: #5b6475;
    --line: #e2e8f0;
    --bg: #f6f8fb;
    --card: #ffffff;
    --warn: #b45309;
    --radius: 10px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    color: var(--ink);
    background: var(--bg);
}
a { color: var(--blue); }
a:hover { color: var(--blue-dark); }
h1 { font-size: 1.9rem; line-height: 1.2; margin: 1.2rem 0 .4rem; }
h2 { font-size: 1.3rem; margin: 2rem 0 .6rem; }
h3 { font-size: 1.05rem; margin: 1.4rem 0 .4rem; }
code, .code { font-family: ui-monospace, "SF Mono", Consolas, "Courier New", monospace; }
.wrap { max-width: 1100px; margin: 0 auto; padding-inline: 16px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.lead { font-size: 1.1rem; color: var(--muted); margin-top: 0; }

/* Header + search */
.site-header { background: var(--card); border-bottom: 1px solid var(--line); padding-bottom: 14px; }
.header-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding-top: 10px; }
.brand img { display: block; height: auto; }
.main-nav { display: flex; gap: 6px 18px; flex-wrap: wrap; }
.main-nav a { text-decoration: none; font-weight: 600; color: var(--ink); }
.main-nav a:hover { color: var(--blue); }
.search-form { position: relative; display: flex; gap: 8px; margin-top: 10px; }
.search-form input {
    flex: 1; min-width: 0; font-size: 1.05rem; padding: 11px 14px;
    border: 1px solid #c3cad6; border-radius: var(--radius); background: #fff;
}
.search-form input:focus { outline: 2px solid var(--blue); outline-offset: 1px; border-color: var(--blue); }
button, .btn {
    display: inline-block; font: inherit; font-weight: 600; cursor: pointer;
    padding: 10px 18px; border-radius: var(--radius); border: 1px solid var(--blue);
    background: var(--blue); color: #fff; text-decoration: none; text-align: center;
}
button:hover, .btn:hover { background: var(--blue-dark); color: #fff; }
.btn-ghost { background: #fff; color: var(--blue); }
.btn-ghost:hover { background: var(--blue-soft); color: var(--blue-dark); }
.btn-small { padding: 5px 10px; font-size: .9rem; }

.suggest {
    position: absolute; top: 100%; left: 0; right: 0; z-index: 50; margin: 4px 0 0; padding: 4px 0;
    list-style: none; background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
    box-shadow: 0 8px 24px rgba(0,0,0,.12); max-height: 60vh; overflow-y: auto;
}
.suggest li { padding: 8px 14px; cursor: pointer; display: flex; gap: 10px; align-items: baseline; }
.suggest li[aria-selected="true"], .suggest li:hover { background: var(--blue-soft); }
.suggest .code { font-weight: 700; color: var(--blue); min-width: 4.2em; }
.suggest .where { color: var(--muted); font-size: .9rem; }

/* Content */
main { padding-bottom: 40px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; margin: 16px 0; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.chip { padding: 4px 12px; border-radius: 999px; background: var(--blue-soft); text-decoration: none; font-size: .95rem; }
.tag { display: inline-block; font-size: .78rem; padding: 1px 7px; margin: 1px 3px 1px 0; border-radius: 999px; background: #eef2f7; color: #374151; white-space: nowrap; }
.tag-warn { background: #fef3c7; color: var(--warn); }
.notice { background: #fffbeb; border: 1px solid #fde68a; border-radius: var(--radius); padding: 10px 14px; }
.breadcrumbs { font-size: .9rem; color: var(--muted); margin-top: 14px; }
.breadcrumbs a { color: var(--muted); }

.table-scroll { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
table.results { border-collapse: collapse; width: 100%; }
.results th { background: var(--blue); color: #fff; text-align: left; padding: 10px 12px; font-weight: 600; white-space: nowrap; }
.results td { padding: 8px 12px; border-top: 1px solid var(--line); vertical-align: top; }
.results tr:hover td { background: #f1f5f9; }
.results .code { font-weight: 700; }
.results tr.retiring td { color: var(--muted); }

.pager { display: flex; gap: 16px; align-items: center; justify-content: center; margin: 16px 0; }

/* Location page */
.code-hero { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 16px; }
.code-hero .big { font-size: 2.6rem; font-weight: 800; letter-spacing: .04em; color: var(--blue); font-family: ui-monospace, Consolas, monospace; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; margin: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 24px; }
.list-cols { columns: 3 220px; padding-left: 0; list-style: none; }
.list-cols li { break-inside: avoid; padding: 2px 0; }

/* Naming builder */
.builder-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 20px; }
.field label { display: block; font-weight: 600; font-size: .92rem; margin-bottom: 3px; }
.field input, .field select {
    width: 100%; font: inherit; padding: 7px 10px; border: 1px solid #c3cad6; border-radius: 8px; background: #fff;
}
.field .hint { font-size: .82rem; color: var(--muted); }
.pattern { font-family: ui-monospace, Consolas, monospace; background: #0f172a; color: #e2e8f0; padding: 10px 14px; border-radius: 8px; overflow-x: auto; }
.types { width: 100%; max-width: 720px; border-collapse: collapse; }
.types th { text-align: left; font-size: .9rem; color: var(--muted); font-weight: 600; padding: 0 4px; }
.types td { padding: 4px; }
.types td:first-child { width: 8em; }
.types td:nth-child(3) { width: 6em; }
.types td:last-child { width: 1%; }
.types input { width: 100%; font: inherit; padding: 6px 8px; border: 1px solid #c3cad6; border-radius: 6px; background: #fff; }
.types input.type-code { font-family: ui-monospace, Consolas, monospace; text-transform: uppercase; }
.toolbar select, .toolbar input { font: inherit; padding: 6px 8px; border: 1px solid #c3cad6; border-radius: 8px; background: #fff; }
.out-names td:first-child { font-family: ui-monospace, Consolas, monospace; font-weight: 700; white-space: nowrap; }
.out-names .warn { color: var(--warn); font-size: .85rem; }
.out-names .ok { color: #047857; font-weight: 600; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0; align-items: center; }
.toast { color: #047857; font-weight: 600; }

/* CTA + footer */
.cta { background: linear-gradient(135deg, #1e3a8a, #1d4ed8); color: #fff; border-radius: var(--radius); padding: 22px 24px; margin: 28px 0; }
.cta h2 { margin-top: 0; color: #fff; }
.cta p { color: #dbe5ff; max-width: 70ch; }
.cta-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.cta .btn { background: #fff; color: var(--blue-dark); border-color: #fff; }
.cta .btn-ghost { background: transparent; color: #fff; border-color: #c7d6ff; }
.cta .btn-ghost:hover { background: rgba(255,255,255,.12); }
.site-footer { background: var(--card); border-top: 1px solid var(--line); padding: 20px 0; font-size: .92rem; color: var(--muted); }
.footer-row { display: flex; justify-content: space-between; gap: 20px; flex-wrap: wrap; }
.site-footer img { max-width: 200px; height: auto; display: block; margin-bottom: 6px; }
.footer-meta { max-width: 420px; }

.faq details { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 16px; margin: 8px 0; }
.faq summary { font-weight: 600; cursor: pointer; }

@media (max-width: 720px) {
    h1 { font-size: 1.5rem; }
    .code-hero .big { font-size: 2rem; }
    .builder-grid, .grid-2 { grid-template-columns: 1fr; }
    .search-form button { padding-inline: 12px; }
    .brand img { width: 130px; }
    .facts { grid-template-columns: 1fr; gap: 0; }
    .facts dd { margin-bottom: 8px; }
    .results th:nth-child(3), .results td:nth-child(3) { display: none; }
}
