:root {
    --bg: #f6f7fb;
    --surface: #ffffff;
    --text: #1d2130;
    --muted: #6b7185;
    --border: #e3e5ee;
    --accent: #ee6123;
    --accent-hover: #d4521a;
    --accent-soft: #fdeee6;
    --danger: #c62828;
    --danger-soft: #fdecec;
    --success: #2e7d32;
    --radius: 10px;
    color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #12141b;
        --surface: #1b1e28;
        --text: #e8eaf2;
        --muted: #9aa0b4;
        --border: #2c3040;
        --accent-soft: #3a2419;
        --danger-soft: #3a1e1e;
        --success: #66bb6a;
    }
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

a { color: var(--accent); }

h1:focus { outline: none; }

.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.topbar-inner, .page {
    max-width: 960px;
    margin: 0 auto;
    padding: 0 16px;
}

.topbar-inner {
    display: flex;
    align-items: center;
    gap: 24px;
    height: 60px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--text);
    text-decoration: none;
}

.brand .tld { color: var(--accent); }
.brand img { border-radius: 7px; }

.nav { display: flex; gap: 16px; margin-left: auto; }
.nav a { color: var(--muted); text-decoration: none; font-weight: 500; }
.nav a:hover, .nav a.active { color: var(--text); }

.page { padding-top: 32px; padding-bottom: 64px; }

.hero { text-align: center; margin: 24px 0 32px; }
.hero h1 { font-size: 2.25rem; margin: 0 0 8px; }
.hero p { color: var(--muted); margin: 0; }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 20px;
}

.card h2 { font-size: 1.1rem; margin: 0 0 16px; }

.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.row > .grow { flex: 1 1 280px; min-width: 0; }

input:not([type]), input[type=text], input[type=url], input[type=password], input[type=search], select {
    width: 100%;
    padding: 12px 14px;
    font-size: 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg);
    color: var(--text);
}

input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 12px 20px;
    font-size: 1rem;
    font-weight: 600;
    border: 1px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    background: var(--accent);
    color: #fff;
    text-decoration: none;
    white-space: nowrap;
}

.btn:hover { background: var(--accent-hover); }
.btn:disabled { opacity: .6; cursor: default; }
.btn.secondary { background: transparent; color: var(--text); border-color: var(--border); }
.btn.secondary:hover { background: var(--bg); }
.btn.danger { background: var(--danger); }
.btn.small { padding: 6px 12px; font-size: .875rem; }

.error { color: var(--danger); background: var(--danger-soft); padding: 10px 14px; border-radius: 8px; margin-top: 12px; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.result { display: flex; gap: 24px; flex-wrap: wrap; align-items: flex-start; }
.result .details { flex: 1 1 300px; min-width: 0; }
.result .short-url { font-size: 1.4rem; font-weight: 700; word-break: break-all; }
.result img { width: 160px; height: 160px; border-radius: 8px; background: #fff; padding: 6px; }

.badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: .8rem;
    font-weight: 600;
    background: var(--accent-soft);
    color: var(--accent);
}

.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.success { background: color-mix(in srgb, var(--success) 16%, transparent); color: var(--success); }

.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 20px; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 20px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.kpi .value { font-size: 1.75rem; font-weight: 700; }
.kpi .label { color: var(--muted); font-size: .875rem; }

.chart { display: flex; align-items: flex-end; gap: 2px; height: 180px; padding-top: 8px; }
.chart .bar { flex: 1; background: var(--accent); border-radius: 3px 3px 0 0; min-height: 2px; opacity: .85; }
.chart .bar:hover { opacity: 1; }
.chart-axis { display: flex; justify-content: space-between; color: var(--muted); font-size: .8rem; margin-top: 6px; }

.breakdown { list-style: none; margin: 0; padding: 0; }
.breakdown li { position: relative; padding: 6px 10px; margin-bottom: 4px; border-radius: 6px; overflow: hidden; display: flex; justify-content: space-between; gap: 12px; }
.breakdown li .fill { position: absolute; inset: 0 auto 0 0; background: var(--accent-soft); z-index: 0; }
.breakdown li span { position: relative; z-index: 1; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { color: var(--muted); font-weight: 600; font-size: .875rem; white-space: nowrap; }
td.url { max-width: 320px; }
.table-wrap { overflow-x: auto; }
.nowrap, .badge { white-space: nowrap; }
td.actions { text-align: right; }
td.actions .row { justify-content: flex-end; gap: 6px; }
input[type=checkbox], input[type=radio] { flex-shrink: 0; }

/* The admin tables have up to nine columns: give them more room than the 960px reading width. */
body:has(.admin-bar) .page, body:has(.admin-bar) .topbar-inner { max-width: 1180px; }

.pager { display: flex; justify-content: space-between; align-items: center; margin-top: 16px; }

/* Blazor template defaults */
.valid.modified:not([type=checkbox]) { outline: 1px solid #26b050; }
.invalid { outline: 1px solid #e50000; }
.validation-message { color: #e50000; }

.blazor-error-boundary {
    background: #b32121;
    padding: 1rem;
    color: white;
}

.blazor-error-boundary::after { content: "An error has occurred."; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; overflow-x: auto; scrollbar-width: none; }
.tabs button { white-space: nowrap; flex-shrink: 0; }
.tabs button {
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--muted);
    font: inherit;
    font-weight: 600;
    padding: 10px 14px;
    margin-bottom: -1px;
    cursor: pointer;
}
.tabs button:hover { color: var(--text); }
.tabs button.active { color: var(--text); border-bottom-color: var(--accent); }
input[type=checkbox] { accent-color: var(--accent); width: 16px; height: 16px; }
.badge.muted-badge { background: var(--border); color: var(--muted); }
.choice { display: grid; gap: 10px; }
input[type=radio] { accent-color: var(--accent); width: 16px; height: 16px; }
input[type=number] {
    padding: 8px 10px;
    font-size: 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg);
    color: var(--text);
}
input[type=number]:disabled { opacity: .5; }
.notes { margin: 16px 0 0; padding-left: 18px; font-size: .875rem; display: grid; gap: 4px; }

/* Admin sign-in and forms */
.auth-card { max-width: 440px; margin: 40px auto; }
.auth-card h1 { font-size: 1.5rem; margin: 0 0 16px; }
.form-grid { display: grid; gap: 14px; }
.form-grid.narrow { max-width: 420px; }
.form-grid label { display: grid; gap: 6px; font-weight: 500; }
.hint { font-size: .85rem; font-weight: 400; }
.notice { background: var(--accent-soft); color: var(--text); padding: 10px 14px; border-radius: 8px; margin: 0 0 16px; }
.admin-bar { justify-content: space-between; margin-bottom: 12px; }
.logout-form { margin: 0; }
.secret { margin-top: 16px; padding: 14px; border: 1px dashed var(--accent); border-radius: 8px; background: var(--accent-soft); }
.secret code { word-break: break-all; }

.danger-box { margin-top: 16px; padding: 16px; border: 2px solid var(--danger); border-radius: 8px; background: var(--danger-soft); }
.danger-box h3 { margin: 0 0 8px; color: var(--danger); }
.danger-box p, .danger-box ul { margin: 0 0 10px; }
