:root {
    --bg: #f5f6fa;
    --surface: #ffffff;
    --text: #1c1e26;
    --muted: #6b7280;
    --border: #e2e4ea;
    --primary: #4f46e5;
    --primary-text: #ffffff;
    --danger: #dc2626;
    --success: #16a34a;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #14151c;
        --surface: #1d1f2a;
        --text: #ecedf3;
        --muted: #9297a8;
        --border: #2c2f3d;
        --primary: #818cf8;
        --primary-text: #14151c;
        --danger: #f87171;
        --success: #4ade80;
    }
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.topbar .brand {
    font-weight: 700;
    color: var(--text);
    text-decoration: none;
}

.topbar nav a {
    color: var(--muted);
    text-decoration: none;
    margin-left: 1.25rem;
}

.topbar nav a:hover { color: var(--primary); }

.container {
    max-width: 480px;
    margin: 2.5rem auto;
    padding: 0 1.25rem;
}

h1 { font-size: 1.5rem; margin-bottom: .5rem; }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1.25rem;
    margin-top: 1rem;
}

form { display: flex; flex-direction: column; gap: .5rem; margin-top: 1rem; }

label { font-size: .875rem; color: var(--muted); }

input[type="text"],
input[type="email"],
input[type="password"],
textarea {
    padding: .6rem .7rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    font-size: 1rem;
    font-family: inherit;
}

textarea {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    resize: vertical;
}

.btn {
    display: inline-block;
    padding: .6rem 1rem;
    border-radius: 8px;
    border: none;
    background: var(--primary);
    color: var(--primary-text);
    font-size: .95rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    margin-top: .5rem;
}

.btn.secondary { background: transparent; color: var(--primary); border: 1px solid var(--primary); }
.btn.danger { background: var(--danger); color: #fff; }

.status-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: .75rem; }
.status-list li { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }

.codes-list {
    list-style: none;
    padding: 0;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .5rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.codes-list li {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: .4rem .6rem;
    text-align: center;
}

.code-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: .9rem;
}

.code-table th, .code-table td {
    text-align: left;
    padding: .5rem .6rem;
    border-bottom: 1px solid var(--border);
}

.code-table .code-cell { font-size: 1.15rem; font-weight: 700; letter-spacing: .05em; }

.tabs { display: flex; gap: .5rem; margin: 1rem 0; }

.tab {
    padding: .4rem .8rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--muted);
    cursor: pointer;
    font-size: .85rem;
}

.tab.active { border-color: var(--primary); color: var(--primary); font-weight: 600; }

.qr-box { display: inline-block; }
.qr-box canvas, .qr-box img { max-width: 100%; border-radius: 8px; }

code {
    background: var(--bg);
    padding: .2rem .4rem;
    border-radius: 4px;
    word-break: break-all;
}

.warning { color: var(--danger); }
.success { color: var(--success); }
#msg { min-height: 1.2rem; font-size: .9rem; }
