:root {
    --ink: #122033;
    --muted: #526277;
    --line: #d9e0ea;
    --bg: #f3f5f8;
    --card: #ffffff;
    --brand: #0f62fe;
    --brand-dark: #0043ce;
    --nav: #122033;
    --ok: #0e7a45;
    --ok-bg: #e7f6ee;
    --danger: #b42318;
    --danger-bg: #fdecea;
    --warn-bg: #fff6e8;
    --shadow: 0 1px 2px rgba(18, 32, 51, 0.05), 0 10px 28px rgba(18, 32, 51, 0.05);
    --radius: 14px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    margin: 0;
    min-height: 100vh;
    color: var(--ink);
    background: var(--bg);
    font: 15px/1.5 "Segoe UI", "Helvetica Neue", Arial, sans-serif;
}

a { color: var(--brand-dark); }

a:hover { text-decoration: none; }

h1, h2, p { margin-top: 0; }

h1 { font-size: 1.7rem; letter-spacing: -0.03em; line-height: 1.2; }

h2 { font-size: 1.15rem; letter-spacing: -0.02em; }

.skip-link {
    position: absolute;
    left: 12px;
    top: -40px;
    background: #fff;
    color: var(--ink);
    padding: 8px 12px;
    z-index: 5;
}

.skip-link:focus { top: 12px; }

.topbar {
    background: var(--nav);
    color: #fff;
    border-bottom: 3px solid var(--brand);
}

.topbar-inner,
.wrap {
    width: min(1120px, calc(100% - 32px));
    margin: 0 auto;
}

.topbar-inner {
    min-height: 68px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.brand,
.brand-plain {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: inherit;
    font-weight: 700;
    text-decoration: none;
    letter-spacing: -0.02em;
}

.brand-mark {
    width: 32px;
    height: 32px;
    display: inline-grid;
    place-items: center;
    border-radius: 8px;
    background: var(--brand);
    color: #fff;
    font-size: 0.95rem;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.who { color: #d5deea; font-size: 0.92rem; }

.who strong { color: #fff; font-weight: 650; }

.wrap { padding: 28px 0 48px; }

.page-head {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: flex-end;
    margin-bottom: 18px;
}

.lede { color: var(--muted); margin: 6px 0 0; max-width: 62ch; }

.stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
    margin-bottom: 16px;
}

.stat, .card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.stat { padding: 16px 18px; }

.stat span {
    display: block;
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 650;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.stat strong {
    display: block;
    margin-top: 6px;
    font-size: 1.8rem;
    letter-spacing: -0.04em;
    font-variant-numeric: tabular-nums;
}

.card { padding: 18px; margin-bottom: 16px; }

.toolbar {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    margin-bottom: 14px;
}

.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px 16px;
}

.span-2 { grid-column: span 2; }

label {
    display: block;
    font-weight: 650;
    margin-bottom: 6px;
}

.hint { display: block; margin-top: 6px; color: var(--muted); font-size: 0.86rem; font-weight: 400; }

input, select {
    width: 100%;
    min-height: 44px;
    padding: 10px 12px;
    border: 1px solid #c5d0dc;
    border-radius: 10px;
    background: #fff;
    color: var(--ink);
    font: inherit;
}

input:focus, select:focus, button:focus-visible, a:focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: 2px;
}

.actions, .row-actions, .pager {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 8px 14px;
    border-radius: 10px;
    border: 1px solid transparent;
    background: #e8eef6;
    color: var(--ink);
    font: inherit;
    font-weight: 650;
    text-decoration: none;
    cursor: pointer;
}

.btn:hover { filter: brightness(0.97); }

.btn:disabled { opacity: 0.7; cursor: wait; }

.btn-primary { background: var(--brand); color: #fff; }

.btn-primary:hover { background: var(--brand-dark); filter: none; }

.btn-ghost {
    background: transparent;
    border-color: rgba(255, 255, 255, 0.28);
    color: #fff;
}

.btn-danger {
    background: #fff;
    color: var(--danger);
    border-color: #f3c3bd;
}

.btn-small { min-height: 34px; padding: 6px 10px; font-size: 0.86rem; }

.alert {
    border-radius: 12px;
    padding: 12px 14px;
    margin-bottom: 16px;
    border: 1px solid transparent;
}

.alert-success { background: var(--ok-bg); color: #085c34; border-color: #b7e4c9; }

.alert-error { background: var(--danger-bg); color: #8d1d14; border-color: #f5c2c0; }

.alert-info { background: #e8f1ff; color: #0b3f93; border-color: #c9dcff; }

.alert p:last-child { margin-bottom: 0; }

.table-wrap { overflow-x: auto; }

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th, .data-table td {
    text-align: left;
    vertical-align: top;
    padding: 12px 10px;
    border-bottom: 1px solid var(--line);
}

.data-table th {
    color: var(--muted);
    font-size: 0.78rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.data-table tr.is-editing { background: #f3f7ff; }

.short-link {
    display: block;
    color: var(--ink);
    font-weight: 700;
    text-decoration: none;
    word-break: break-all;
}

.muted, .meta { color: var(--muted); }

.truncate {
    display: inline-block;
    max-width: 280px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: bottom;
}

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 700;
}

.badge-on { background: var(--ok-bg); color: var(--ok); }

.badge-off { background: #eef2f6; color: #526277; }

.count {
    font-variant-numeric: tabular-nums;
    font-weight: 700;
}

.empty {
    text-align: center;
    padding: 28px 12px;
    color: var(--muted);
}

.pager { justify-content: space-between; margin-top: 14px; }

.page-link[aria-current="page"] {
    background: var(--nav);
    color: #fff;
}

.confirm {
    border-color: #f3c3bd;
    background: #fffafa;
}

.auth-shell, .status-shell {
    min-height: 100vh;
    display: grid;
    align-content: center;
    justify-items: center;
    padding: 32px 16px;
}

.auth-card, .status-card { width: min(460px, 100%); }

.center-card {
    width: min(560px, 100%);
    margin-left: auto;
    margin-right: auto;
}

.status-shell .brand-plain { margin-bottom: 14px; color: var(--ink); }

.checklist { margin: 0; padding-left: 18px; }

.checklist li + li { margin-top: 8px; }

.footer-note {
    color: var(--muted);
    font-size: 0.86rem;
    margin: 8px 0 0;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

@media (max-width: 800px) {
    .stats, .form-grid { grid-template-columns: 1fr; }
    .span-2 { grid-column: auto; }
    .page-head, .toolbar, .topbar-inner { align-items: stretch; }
    .topbar-inner, .page-head, .toolbar { flex-direction: column; }
    .data-table thead { display: none; }
    .data-table tr {
        display: block;
        border: 1px solid var(--line);
        border-radius: 12px;
        margin-bottom: 12px;
        padding: 6px 0;
    }
    .data-table td {
        display: grid;
        grid-template-columns: 7.2rem 1fr;
        gap: 8px;
        border: 0;
        padding: 8px 12px;
    }
    .data-table td::before {
        content: attr(data-label);
        color: var(--muted);
        font-size: 0.75rem;
        font-weight: 700;
        letter-spacing: 0.03em;
        text-transform: uppercase;
    }
    .truncate { max-width: none; white-space: normal; }
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
}
