:root {
    --bg: #08090a;
    --shell: #0f1011;
    --panel: #1c1c1f;
    --elev: #191a1b;
    --text: #f7f8f8;
    --muted: #8a8f98;
    --faint: #62666d;
    --accent: #5e6ad2;
    --accent-hover: #828fff;
    --accent-soft: rgba(94, 106, 210, 0.16);
    --line: rgba(255, 255, 255, 0.08);
    --line-strong: rgba(255, 255, 255, 0.12);
    --ok: #4cb782;
    --ok-soft: rgba(76, 183, 130, 0.14);
    --danger: #eb5757;
    --danger-soft: rgba(235, 87, 87, 0.12);
    --r-sm: 6px;
    --r-md: 12px;
    --topbar: 48px;
    --sidebar: 244px;
    --shadow: 0 0 0 1px var(--line), 0 12px 32px rgba(0, 0, 0, 0.35);
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    color-scheme: dark;
    background: var(--bg);
}

html,
body {
    margin: 0;
    min-height: 100%;
}

body {
    font-family: Inter, ui-sans-serif, system-ui, sans-serif;
    font-feature-settings: "cv01", "ss03";
    font-size: 13px;
    line-height: 1.45;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input,
select,
textarea {
    font: inherit;
    color: inherit;
}

button {
    cursor: pointer;
}

::selection {
    background: rgba(94, 106, 210, 0.35);
}

:focus {
    outline: none;
}

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.topbar {
    height: var(--topbar);
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 16px;
    background: var(--shell);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 20;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 13px;
    letter-spacing: -0.02em;
    flex-shrink: 0;
}

.brand-mark {
    width: 18px;
    height: 18px;
    border-radius: 5px;
    background: var(--accent);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
}

.topbar-search {
    flex: 1;
    max-width: 420px;
}

.kbd {
    font-size: 11px;
    color: var(--faint);
    border: 1px solid var(--line);
    border-radius: 4px;
    padding: 1px 5px;
    margin-left: 8px;
}

.page {
    width: min(1080px, calc(100% - 40px));
    margin: 0 auto;
    padding: 28px 0 80px;
}

.page-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
}

.page-head h1,
.admin-head h1,
.auth-card h1 {
    margin: 0;
    font-size: 22px;
    font-weight: 600;
    letter-spacing: -0.04em;
}

.sub {
    margin: 6px 0 0;
    color: var(--muted);
}

.crumb {
    color: var(--muted);
    margin: 0 0 14px;
}

.crumb a:hover {
    color: var(--text);
}

.cmd {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 32px;
    padding: 0 10px 0 12px;
    background: var(--elev);
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    transition: border-color 150ms ease, box-shadow 150ms ease;
}

.cmd:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.cmd input {
    flex: 1;
    background: transparent;
    border: 0;
    padding: 0;
    min-width: 0;
}

.cmd input:focus {
    outline: none;
}

.cmd input::placeholder {
    color: var(--faint);
}

.field {
    margin: 0 0 14px;
}

.field label,
.field-label {
    display: block;
    margin-bottom: 6px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 500;
}

.control,
.field input[type="text"],
.field input[type="email"],
.field input[type="password"],
.field input[type="number"],
.field input[type="file"],
.field select,
.field textarea {
    width: 100%;
    background: var(--elev);
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    padding: 7px 10px;
    min-height: 32px;
    transition: border-color 150ms ease, box-shadow 150ms ease;
}

.field input[type="file"] {
    padding: 4px;
}

.field input[type="file"]::file-selector-button {
    background: var(--shell);
    color: var(--text);
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    height: 28px;
    margin-right: 10px;
    padding: 0 10px;
}

.field textarea {
    min-height: 110px;
    resize: vertical;
    line-height: 1.5;
}

.field input:focus,
.field select:focus,
.field textarea:focus,
.control:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.field-error {
    margin: 6px 0 0;
    color: var(--danger);
    font-size: 12px;
}

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.toolbar .control {
    width: auto;
    min-width: 160px;
}

.check {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text);
    font-size: 13px;
    margin: 4px 0 12px;
}

.check input {
    accent-color: var(--accent);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 32px;
    padding: 0 12px;
    border: 1px solid transparent;
    border-radius: var(--r-sm);
    background: var(--accent);
    color: #fff;
    font-weight: 500;
    letter-spacing: -0.01em;
    transition: background 150ms ease, transform 80ms ease, border-color 150ms ease;
}

.btn:hover {
    background: var(--accent-hover);
}

.btn:active {
    transform: scale(0.97);
}

.btn-ghost {
    background: transparent;
    border-color: var(--line);
    color: var(--text);
}

.btn-ghost:hover {
    background: rgba(255, 255, 255, 0.04);
}

.btn-danger {
    background: transparent;
    border-color: var(--line);
    color: var(--danger);
}

.btn-danger:hover {
    background: var(--danger-soft);
}

.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
}

.list {
    overflow: hidden;
}

.row {
    display: grid;
    grid-template-columns: 140px 88px 1fr 140px;
    align-items: center;
    gap: 12px;
    min-height: 40px;
    padding: 0 14px;
    border-bottom: 1px solid var(--line);
    color: inherit;
}

.row:last-child {
    border-bottom: 0;
}

.row:hover {
    background: rgba(255, 255, 255, 0.03);
}

.row-head {
    color: var(--faint);
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    min-height: 32px;
}

.row-head:hover {
    background: transparent;
}

.des {
    font-weight: 600;
    letter-spacing: -0.02em;
}

.muted {
    color: var(--muted);
}

.faint {
    color: var(--faint);
}

.nums {
    font-variant-numeric: tabular-nums;
    text-align: right;
    color: var(--muted);
}

.chip {
    display: inline-flex;
    align-items: center;
    height: 20px;
    padding: 0 7px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--muted);
    font-size: 12px;
    white-space: nowrap;
    justify-self: start;
    width: max-content;
}

.dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--ok);
    display: inline-block;
}

.dot-off {
    background: var(--faint);
}

.empty {
    padding: 48px 16px;
    text-align: center;
    color: var(--muted);
}

.empty p {
    margin: 0;
}

.empty .faint {
    margin-top: 6px;
}

.detail {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: 24px;
    align-items: start;
}

.props {
    padding: 4px 0;
}

.prop {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--line);
    font-size: 13px;
}

.prop:last-child {
    border-bottom: 0;
}

.prop dt {
    margin: 0;
    color: var(--muted);
}

.prop dd {
    margin: 0;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.photo {
    margin: 0;
    border-bottom: 1px solid var(--line);
}

.photo img {
    display: block;
    width: 100%;
    height: auto;
}

.body-copy {
    color: #d0d6e0;
    line-height: 1.6;
    max-width: 42em;
}

.section-title {
    margin: 28px 0 12px;
    font-size: 13px;
    font-weight: 500;
    color: var(--muted);
}

.admin {
    display: grid;
    grid-template-columns: var(--sidebar) 1fr;
    min-height: 100vh;
}

.sidebar {
    background: var(--shell);
    border-right: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    padding: 12px 10px 12px;
    position: sticky;
    top: 0;
    height: 100vh;
}

.sidebar .brand {
    height: 32px;
    padding: 0 8px;
    margin-bottom: 12px;
}

.nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav a {
    display: flex;
    align-items: center;
    height: 32px;
    padding: 0 10px;
    border-radius: var(--r-sm);
    color: var(--muted);
}

.nav a:hover {
    background: rgba(255, 255, 255, 0.04);
    color: var(--text);
}

.nav a.active {
    background: var(--accent-soft);
    color: var(--accent-hover);
}

.sidebar-foot {
    margin-top: auto;
    padding: 10px 8px 4px;
    border-top: 1px solid var(--line);
}

.sidebar-foot .who {
    display: block;
    color: var(--muted);
    font-size: 12px;
    margin-bottom: 8px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.admin-main {
    min-width: 0;
}

.admin-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 18px 28px 8px;
}

.admin-body {
    padding: 12px 28px 48px;
}

.stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

.stat {
    padding: 14px 16px;
}

.stat b {
    display: block;
    font-size: 22px;
    letter-spacing: -0.04em;
    font-variant-numeric: tabular-nums;
}

.stat span {
    color: var(--muted);
    font-size: 12px;
}

.toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.toolbar .cmd {
    flex: 1;
    max-width: 320px;
}

.actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 18px;
}

.flash {
    margin: 0 0 14px;
    padding: 9px 12px;
    border-radius: var(--r-sm);
    border: 1px solid var(--line);
    background: var(--ok-soft);
    color: var(--ok);
}

.flash-error {
    background: var(--danger-soft);
    color: var(--danger);
}

.auth {
    width: 100%;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.auth-card {
    width: min(380px, 100%);
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    padding: 28px 24px 24px;
}

.auth-card .brand {
    margin-bottom: 24px;
}

.auth-card h1 {
    font-size: 18px;
    margin-bottom: 18px;
}

.auth-card .btn {
    width: 100%;
    margin-top: 8px;
}

.form-panel {
    padding: 18px 18px 8px;
}

.inline-form {
    display: inline;
}

.admin-table .row {
    grid-template-columns: 1.1fr 120px 1.2fr 140px 100px;
}

.mfr-table .row {
    grid-template-columns: 1fr 80px;
}

@media (max-width: 860px) {
    .kbd {
        display: none;
    }
    .row,
    .admin-table .row,
    .mfr-table .row {
        grid-template-columns: 1fr 1fr;
        padding: 10px 14px;
        gap: 6px 12px;
    }

    .row-head {
        display: none;
    }

    .detail-main {
        min-width: 0;
    }

    .props-panel {
        order: -1;
    }

    .detail,
    .grid-2,
    .grid-3,
    .stats,
    .admin {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: sticky;
        height: auto;
        flex-direction: row;
        align-items: center;
        gap: 12px;
        padding: 8px 12px;
    }

    .sidebar .brand {
        margin: 0;
    }

    .nav {
        flex-direction: row;
        overflow-x: auto;
    }

    .sidebar-foot {
        border: 0;
        margin: 0 0 0 auto;
        padding: 0;
        display: flex;
        align-items: center;
        gap: 8px;
    }

    .sidebar-foot .who {
        display: none;
    }

    .page {
        width: calc(100% - 28px);
    }

    .admin-head,
    .admin-body {
        padding-left: 16px;
        padding-right: 16px;
    }
}
