:root {
    --bg: #f6f7f9;
    --fg: #1d2330;
    --muted: #5d6677;
    --card: #fff;
    --border: #d5d9e0;
    --accent: #0b5cad;
    --accent-fg: #fff;
    --ok-bg: #e3f4e7;
    --ok-fg: #14532d;
    --err-bg: #fbe4e4;
    --err-fg: #7f1d1d;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #14171c;
        --fg: #e6e9ef;
        --muted: #9aa3b2;
        --card: #1d2229;
        --border: #333a45;
        --accent: #5aa0e6;
        --accent-fg: #0b1220;
        --ok-bg: #16331f;
        --ok-fg: #b7e4c4;
        --err-bg: #3c1b1b;
        --err-fg: #f5c2c2;
    }
}

* { box-sizing: border-box; }

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

a { color: var(--accent); }

.container { max-width: 64rem; margin: 0 auto; padding: 1rem; }

.site-header { background: var(--card); border-bottom: 1px solid var(--border); }
.site-header .container { display: flex; align-items: center; gap: 1.5rem; }
.brand { font-weight: 700; font-size: 1.2rem; color: var(--fg); text-decoration: none; }
nav a { margin-right: 1rem; }

.user-box { margin-left: auto; display: flex; align-items: center; gap: 0.75rem; }
.user-box button { margin-top: 0; }

.login-box { max-width: 24rem; margin: 3rem auto; padding: 1.5rem; background: var(--card); border: 1px solid var(--border); border-radius: 4px; }
.login-box input { max-width: none; }

h1 { font-size: 1.6rem; margin: 0 0 1rem; }

form label { display: block; margin: 0.75rem 0 0.25rem; font-weight: 600; }
input, select, textarea {
    width: 100%;
    max-width: 28rem;
    padding: 0.5rem;
    font: inherit;
    color: var(--fg);
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 4px;
}

button, .button {
    display: inline-block;
    margin-top: 1rem;
    padding: 0.5rem 1rem;
    font: inherit;
    color: var(--accent-fg);
    background: var(--accent);
    border: 0;
    border-radius: 4px;
    text-decoration: none;
    cursor: pointer;
}

table { width: 100%; border-collapse: collapse; background: var(--card); }
th, td { padding: 0.5rem; text-align: left; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; }

h2 { font-size: 1.2rem; margin: 1.5rem 0 0.5rem; }

.qr { display: block; width: 15rem; height: 15rem; background: #fff; padding: 0.5rem; border: 1px solid var(--border); }
.secret { font-size: 1.1rem; letter-spacing: 0.05em; }
.codes { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr)); gap: 0.5rem; max-width: 28rem; }
.codes code { font-size: 1.1rem; }

.flash-ok, .flash-error { padding: 0.75rem 1rem; margin-bottom: 1rem; border-radius: 4px; }
.flash-ok { background: var(--ok-bg); color: var(--ok-fg); }
.flash-error { background: var(--err-bg); color: var(--err-fg); }

.search-box input { width: 14rem; }
.inline-search { display: flex; gap: 0.5rem; align-items: center; margin-bottom: 1rem; }
.inline-search button { margin-top: 0; }
.filters { flex-wrap: wrap; }
.filters select { width: auto; max-width: 16rem; }
table.audit td { vertical-align: top; }
table.audit pre { margin: 0; font: 0.85rem/1.4 ui-monospace, Consolas, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }
.pager { display: flex; gap: 1rem; margin-top: 1rem; }

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.page-head h1 { margin: 0; }
.page-head .button { margin-top: 0; }
.actions { display: flex; align-items: center; gap: 0.75rem; }

input.invalid, textarea.invalid { border-color: var(--err-fg); }
.field-error { margin: 0.25rem 0 0; color: var(--err-fg); }

.danger { background: var(--err-fg); color: var(--err-bg); }
ul.plain { margin: 0; padding: 0; list-style: none; }
td.notes { white-space: pre-wrap; }
.project-section { margin-top: 2rem; }

.subnav { margin-bottom: 1rem; }
.subnav a { margin-right: 1rem; }
label.check { display: flex; align-items: center; gap: 0.5rem; font-weight: 400; }
label.check.indent { margin-left: 1.5rem; }
input[type=checkbox], input[type=radio] { width: auto; }
fieldset { max-width: 28rem; margin: 1rem 0 0; border: 1px solid var(--border); border-radius: 4px; }
.muted { color: var(--muted); }
