:root {
    --bg: #f6f7f9;
    --surface: #ffffff;
    --text: #1d2430;
    --muted: #5b6678;
    --border: #d9dee6;
    --primary: #1f6feb;
    --primary-text: #ffffff;
    --ok: #1a7f37;
    --bad: #c62828;
    --warn-bg: #fff4e5;
    --error-bg: #fdecea;
    --success-bg: #e8f5e9;
    --sidebar: #141a24;
    --sidebar-text: #c9d1dd;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-size: 15px;
    color: var(--text);
}

* { box-sizing: border-box; }

body { margin: 0; background: var(--bg); }

h1 { font-size: 1.6rem; margin: 0 0 .5rem; }
h2 { font-size: 1.15rem; margin: 0 0 .75rem; }
h1:focus { outline: none; }

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

.lead { color: var(--muted); margin-top: 0; max-width: 60rem; }
.hint { color: var(--muted); font-size: .875rem; }
.required { color: var(--bad); margin-left: .15rem; }
.ok { color: var(--ok); }
.bad { color: var(--bad); }

/* Layout */
.shell { display: flex; min-height: 100vh; }

.sidebar {
    width: 230px;
    flex-shrink: 0;
    background: var(--sidebar);
    color: var(--sidebar-text);
    padding: 1.25rem 1rem;
    display: flex;
    flex-direction: column;
    gap: .15rem;
}

.sidebar a { color: var(--sidebar-text); text-decoration: none; padding: .45rem .6rem; border-radius: 6px; }
.sidebar a:hover { background: #222b38; }
.sidebar a.active { background: var(--primary); color: var(--primary-text); }
.sidebar .nav-heading { text-transform: uppercase; font-size: .72rem; letter-spacing: .06em; margin: 1rem .6rem .25rem; color: #7d8899; }

.brand { font-weight: 700; font-size: 1.15rem; color: inherit; text-decoration: none; margin-bottom: .75rem; }
.brand span { font-weight: 400; opacity: .7; }
.sidebar .brand { color: #fff; padding-left: .6rem; }

.signed-in { margin-top: auto; padding: .75rem .6rem 0; border-top: 1px solid #2a3443; font-size: .85rem; }
.signed-in form { margin-top: .4rem; }

.content { flex: 1; padding: 2rem 2.5rem; min-width: 0; max-width: 1200px; }

/* Cards, forms */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1.25rem 1.5rem;
    margin: 1rem 0;
}

label { display: flex; flex-direction: column; gap: .3rem; font-weight: 500; margin-bottom: .9rem; }
label.checkbox { flex-direction: row; align-items: center; font-weight: 400; }

input:not([type=checkbox]):not([type=file]), select, textarea {
    font: inherit;
    padding: .5rem .6rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fff;
    min-width: 0;
}

input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: 1px; }

button, .button {
    font: inherit;
    padding: .55rem 1.1rem;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: #fff;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    color: var(--text);
}

button.primary, .button.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
button.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
button:disabled { opacity: .5; cursor: not-allowed; }
.link-button { background: none; border: none; padding: 0; color: var(--sidebar-text); text-decoration: underline; cursor: pointer; }

fieldset { border: none; padding: 0; margin: 0 0 1rem; }
legend { font-weight: 700; margin-bottom: .6rem; font-size: 1.05rem; }

.form-grid fieldset { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); column-gap: 1.25rem; }
.form-grid legend { grid-column: 1 / -1; }
.actions { display: flex; gap: .75rem; align-items: center; }
.options { display: flex; flex-wrap: wrap; gap: 1.5rem; align-items: flex-end; margin-top: 1rem; }

/* Tables */
table { border-collapse: collapse; width: 100%; margin: .5rem 0 1rem; }
th, td { text-align: left; padding: .5rem .6rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
td.num, th.num { text-align: right; white-space: nowrap; }
table.mapping select, table.mapping input { width: 100%; }
.example { color: var(--muted); font-family: ui-monospace, Consolas, monospace; font-size: .85rem; }

/* Alerts */
.alert { padding: .75rem 1rem; border-radius: 8px; margin: .75rem 0; background: var(--warn-bg); }
.alert-error { background: var(--error-bg); color: #7f1d1d; }
.alert-success { background: var(--success-bg); color: #14532d; }
.alert p { margin: .25rem 0; }

progress { width: 100%; height: 1rem; margin: .5rem 0; }
details { margin: 1rem 0; }
summary { cursor: pointer; font-weight: 600; }

/* Dashboard */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 1rem; margin: 1rem 0; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 1.1rem 1.25rem; text-decoration: none; color: var(--text); }
.tile.attention { border-color: var(--bad); }
.tile-value { display: block; font-size: 1.8rem; font-weight: 700; }
.tile-label { color: var(--muted); }
.actions-list { margin: 0; padding-left: 1.2rem; line-height: 1.9; }

/* Sign-in */
.account { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.account-card { width: 100%; max-width: 440px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 2rem; }
.account-card .brand { display: block; color: var(--text); }
.account-card button.primary { width: 100%; }
.qr svg { width: 200px; height: 200px; display: block; margin: .5rem auto; }
.key code, .recovery-codes code { font-size: 1rem; letter-spacing: .05em; }
.recovery-codes { columns: 2; padding-left: 1.2rem; }

/* Blazor reconnect / error UI */
#blazor-error-ui { background: #ffe8a1; bottom: 0; display: none; left: 0; padding: .6rem 1.25rem; position: fixed; width: 100%; z-index: 1000; }
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: .75rem; top: .5rem; }

/* Moderation (Reports.razor) and Users (Users.razor) */
.confirm { background: var(--warn-bg); border-radius: 8px; padding: .6rem .75rem; max-width: 26rem; }
.confirm p { margin: 0 0 .5rem; }
td .actions { flex-wrap: wrap; gap: .4rem; }
td .actions button, td .actions .button { padding: .35rem .7rem; font-size: .875rem; }
.report-comment { white-space: pre-wrap; overflow-wrap: anywhere; }
.search-form { display: flex; gap: .75rem; align-items: flex-end; }
.search-form label { flex: 1; margin-bottom: 0; }
.chain-invalid { border: 2px solid var(--bad); font-size: 1.05rem; }

/* Promotions (Promotions.razor, EditPromotion.razor) */
.promo-status { display: inline-block; padding: .1rem .5rem; border-radius: 999px; font-size: .8rem; background: var(--bg); border: 1px solid var(--border); }
.promo-status-active { background: var(--success-bg); color: var(--ok); border-color: transparent; }
.promo-status-paused { background: var(--warn-bg); border-color: transparent; }
.promo-status-ended { color: var(--muted); }
tr.promo-report td { background: var(--bg); }
.promo-preview { grid-column: 1 / -1; display: flex; gap: 1rem; align-items: center; max-width: 520px; padding: .9rem; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); }
.promo-preview img { width: 96px; height: 96px; object-fit: cover; border-radius: 8px; flex-shrink: 0; }
.promo-preview-text { display: flex; flex-direction: column; gap: .25rem; min-width: 0; overflow-wrap: anywhere; }
.promo-preview-label { color: var(--muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; }
.form-grid fieldset > p.hint { grid-column: 1 / -1; margin: .5rem 0 0; }
