:root {
    --bg: #ffffff;
    --fg: #1d2421;
    --muted: #5f6b66;
    --line: #dfe5e2;
    --surface: #f4f7f5;
    --hover: #eef3f0;
    --accent: #1a7f5a;
    --accent-fg: #ffffff;
    --ok: #1a7f5a;
    --ok-bg: #e3f4ec;
    --exp: #9a5b00;
    --exp-bg: #fbf0dc;
    --mark: #fff1a8;
    --shadow: 0 2px 10px rgb(0 0 0 / .08);
    --radius: 24px;
    color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #131816;
        --fg: #e6ece9;
        --muted: #9aa8a2;
        --line: #2b3430;
        --surface: #1b2220;
        --hover: #212a27;
        --accent: #3fb489;
        --accent-fg: #0b1310;
        --ok: #5fd0a4;
        --ok-bg: #173328;
        --exp: #f0b35b;
        --exp-bg: #3a2c15;
        --mark: #5a4d12;
        --shadow: 0 2px 10px rgb(0 0 0 / .4);
    }
}

* { box-sizing: border-box; }

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

body {
    margin: 0;
    background: var(--bg);
    color: var(--fg);
    font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { color: inherit; }

.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: .92em; }
.nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Top bar */
.topbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
}

.lang { margin-left: auto; display: flex; gap: 4px; }

.lang a {
    padding: 4px 8px;
    border-radius: 8px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    letter-spacing: .04em;
}

.lang a:hover { background: var(--hover); }
.lang a[aria-current="true"] { color: var(--accent); background: var(--surface); }

.back {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
}

.back:hover { background: var(--hover); }
.back svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }

main { padding: 0 16px 48px; }

/* Home / search */
.home {
    max-width: 720px;
    margin: 0 auto;
    padding-top: 18vh;
    transition: padding-top .2s ease;
}

.home.has-query { padding-top: 8px; }

.logo { display: block; width: 72px; margin: 0 auto 24px; transition: width .2s ease, margin .2s ease; }
.logo svg { display: block; width: 100%; height: auto; }
.has-query .logo { width: 40px; margin-bottom: 16px; }

.search { position: relative; }

.search .icon {
    position: absolute;
    left: 18px;
    top: 50%;
    width: 20px;
    height: 20px;
    transform: translateY(-50%);
    fill: none;
    stroke: var(--muted);
    stroke-width: 2;
    stroke-linecap: round;
    pointer-events: none;
}

.search input {
    width: 100%;
    height: 52px;
    padding: 0 48px 0 50px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--bg);
    color: var(--fg);
    font: inherit;
    font-size: 17px;
    outline: none;
    box-shadow: var(--shadow);
    -webkit-appearance: none;
    appearance: none;
}

.search input:focus { border-color: var(--accent); }
.search input::-webkit-search-cancel-button { cursor: pointer; }

.spinner {
    position: absolute;
    right: 18px;
    top: 50%;
    width: 18px;
    height: 18px;
    margin-top: -9px;
    border: 2px solid var(--line);
    border-top-color: var(--accent);
    border-radius: 50%;
    opacity: 0;
    transition: opacity .15s;
    animation: spin .7s linear infinite;
}

.loading .spinner { opacity: 1; transition-delay: .2s; }

@keyframes spin { to { transform: rotate(360deg); } }

.status { min-height: 1.4em; margin: 14px 8px 4px; color: var(--muted); font-size: 13px; }

.results { list-style: none; margin: 0; padding: 0; }

.results a {
    display: block;
    padding: 12px 14px;
    border-radius: 12px;
    text-decoration: none;
}

.results a:hover, .results a.active { background: var(--hover); }
.results a.active { outline: 2px solid var(--accent); outline-offset: -2px; }

.name { font-size: 18px; font-weight: 600; color: var(--accent); overflow-wrap: anywhere; }

.meta, .badges { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; margin-top: 4px; }
.meta { color: var(--muted); font-size: 14px; }
.badges { gap: 6px; }

mark { background: var(--mark); color: inherit; border-radius: 3px; }

.chip {
    display: inline-block;
    padding: 1px 8px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface);
    color: var(--fg);
    font-size: 12px;
    white-space: nowrap;
}

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

.badge {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.badge.ok { color: var(--ok); background: var(--ok-bg); }
.badge.exp { color: var(--exp); background: var(--exp-bg); }

.cert { color: var(--muted); font-size: 12px; }

/* Detail */
.detail { max-width: 960px; margin: 0 auto; }
.detail h1 { margin: 8px 0 4px; font-size: clamp(24px, 4vw, 32px); line-height: 1.2; overflow-wrap: anywhere; }
.detail address { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; color: var(--muted); font-style: normal; }

.facts { display: flex; flex-wrap: wrap; gap: 8px 32px; margin: 20px 0 24px; }
.facts div { min-width: 0; }
.facts dt { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
.facts dd { margin: 2px 0 0; }
.facts a { color: var(--accent); text-decoration: none; }

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

.certs { width: 100%; border-collapse: collapse; font-size: 14px; }
.certs th, .certs td { padding: 10px 12px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
.certs th { color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; background: var(--surface); }
.certs tbody tr:last-child td { border-bottom: 0; }
.certs td .chip { margin: 0 4px 4px 0; }
.certs .state { display: block; color: var(--muted); font-size: 12px; }
.certs .is-expired td { color: var(--muted); }

.empty { margin-top: 18vh; text-align: center; color: var(--muted); font-size: 18px; }

@media (max-width: 600px) {
    .home { padding-top: 10vh; }
    .search input { height: 48px; font-size: 16px; }
    .results a { padding: 10px 8px; }
    .certs th, .certs td { padding: 8px; }
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation-duration: 0s !important; }
}
