:root {
    color-scheme: dark;
    --page: #071527;
    --surface: #0b1f3a;
    --panel: #102a44;
    --panel-alt: #0e243b;
    --border: #1f3d63;
    --muted: #93a8c2;
    --text: #eef5ff;
    --input: #081a2f;
    --accent: #449aca;
    --danger: #e45d6d;
}

* {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--page);
    color: var(--text);
    font-family: "Microsoft YaHei UI", "Segoe UI", sans-serif;
    letter-spacing: 0;
}

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

.login-shell {
    display: grid;
    min-height: 100vh;
    place-items: center;
    padding: 24px;
}

.login-panel,
.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 18px 42px rgba(0, 0, 0, .24);
}

.login-panel {
    width: min(420px, 100%);
    padding: 28px;
}

.eyebrow {
    margin: 0 0 6px;
    color: var(--muted);
    font-size: 13px;
}

h1,
h2 {
    margin: 0;
    font-weight: 700;
}

h1 {
    font-size: 28px;
}

h2 {
    font-size: 19px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 22px clamp(16px, 4vw, 42px);
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}

.topbar nav {
    display: flex;
    align-items: center;
    gap: 14px;
    color: var(--muted);
}

.layout {
    width: min(1180px, calc(100% - 32px));
    margin: 24px auto 48px;
    display: grid;
    gap: 18px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
}

.stat {
    min-height: 96px;
    padding: 15px;
    background: var(--panel-alt);
    border: 1px solid color-mix(in srgb, var(--accent), var(--border) 50%);
    border-radius: 8px;
}

.stat strong,
.stat span,
.stat small {
    display: block;
}

.stat strong {
    color: var(--accent);
    margin-bottom: 12px;
}

.stat span {
    font-size: 20px;
}

.stat small {
    margin-top: 5px;
    color: var(--muted);
}

.panel {
    padding: 18px;
}

.panel-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

.panel-head span {
    color: var(--muted);
    font-size: 13px;
}

.form-grid,
.upload-form {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 13px;
}

.field-set {
    display: contents;
}

label {
    display: grid;
    gap: 7px;
    color: var(--muted);
    font-size: 13px;
}

input,
select,
textarea {
    width: 100%;
    min-height: 42px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--input);
    color: var(--text);
    padding: 9px 11px;
    font: inherit;
    font-size: 15px;
}

textarea {
    resize: vertical;
}

.wide {
    grid-column: 1 / -1;
}

button,
.button {
    min-height: 40px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--panel);
    color: var(--text);
    padding: 9px 14px;
    font: inherit;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

button:hover,
.button:hover {
    border-color: var(--accent);
}

.primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #06131f;
    font-weight: 700;
}

.danger {
    border-color: color-mix(in srgb, var(--danger), #ffffff 10%);
    color: #ffd7dd;
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 14px;
}

.actions .button,
.actions form,
.actions button {
    flex: 0 1 auto;
}

.record-list {
    display: grid;
    gap: 10px;
}

.stash-window {
    max-height: 560px;
    overflow-y: auto;
    padding: 2px 6px 2px 2px;
    scrollbar-color: var(--accent) var(--input);
}

.stash-grid {
    display: grid;
    grid-template-columns: repeat(6, calc((100% - 50px) / 6));
    gap: 10px;
    align-items: start;
}

.stash-card {
    min-width: 0;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
    border: 2px solid var(--accent);
    border-radius: 8px;
    background: var(--panel-alt);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .04);
}

.thumb {
    width: 100%;
    aspect-ratio: 4 / 3;
    background: var(--input);
    border-bottom: 1px solid color-mix(in srgb, var(--accent), transparent 40%);
    overflow: hidden;
}

.thumb img {
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    display: block;
    object-fit: contain;
    border: 0;
}

.stash-info {
    display: grid;
    gap: 5px;
    padding: 9px;
}

.stash-info strong,
.stash-info span,
.stash-info small {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.stash-info strong {
    color: var(--accent);
    font-size: 14px;
}

.stash-info span {
    font-size: 13px;
}

.stash-info small {
    color: var(--muted);
    font-size: 12px;
}

.stash-info button {
    width: 100%;
    min-height: 32px;
    padding: 5px 8px;
    font-size: 13px;
}

.log-list {
    display: grid;
    gap: 8px;
}

.log-item {
    display: grid;
    gap: 4px;
    padding: 11px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--panel-alt);
}

.log-item strong {
    color: var(--muted);
    font-size: 13px;
    font-weight: 500;
}

.log-item span {
    line-height: 1.45;
}

.record {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--panel-alt);
}

.record strong,
.record span,
.record small {
    display: block;
}

.record span {
    margin-top: 4px;
}

.record small {
    color: var(--muted);
    margin-top: 5px;
}

.record-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 4px 9px;
    border-radius: 999px;
    font-size: 13px;
}

.badge.pending {
    background: rgba(68, 154, 202, .18);
    color: #9ee2ff;
}

.badge.done {
    background: rgba(132, 160, 84, .18);
    color: #d8ecad;
}

.alert {
    padding: 12px 14px;
    border-radius: 8px;
    border: 1px solid;
}

.alert.success {
    color: #d8ecad;
    background: rgba(132, 160, 84, .16);
    border-color: rgba(132, 160, 84, .45);
}

.alert.error {
    color: #ffd7dd;
    background: rgba(228, 93, 109, .15);
    border-color: rgba(228, 93, 109, .5);
}

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

@media (max-width: 760px) {
    body {
        background: var(--surface);
    }

    .topbar {
        align-items: flex-start;
        flex-direction: column;
        padding: 16px;
        gap: 10px;
    }

    h1 {
        font-size: 23px;
    }

    .layout {
        width: 100%;
        margin: 0;
        padding: 12px;
        gap: 12px;
    }

    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    .stash-window {
        max-height: 520px;
        padding-right: 4px;
    }

    .stash-grid {
        grid-template-columns: repeat(2, calc((100% - 9px) / 2));
        gap: 9px;
    }

    .stat {
        min-height: 82px;
        padding: 12px;
    }

    .stat span {
        font-size: 18px;
    }

    .panel {
        padding: 14px;
        border-radius: 0;
        border-left: 0;
        border-right: 0;
    }

    .panel-head {
        align-items: flex-start;
        flex-direction: column;
        gap: 5px;
    }

    .form-grid,
    .upload-form {
        grid-template-columns: 1fr;
    }

    input,
    select,
    textarea,
    button,
    .button {
        min-height: 46px;
        font-size: 16px;
    }

    .stash-info {
        padding: 8px;
    }

    .stash-info button {
        min-height: 38px;
        font-size: 14px;
    }

    .actions {
        display: grid;
        grid-template-columns: 1fr;
    }

    .actions .button,
    .actions form,
    .actions button {
        width: 100%;
    }

    .record {
        align-items: stretch;
        flex-direction: column;
    }

    .record-meta {
        justify-content: space-between;
    }
}
