:root {
    color-scheme: light;
    --background: #f3f5f8;
    --surface: #ffffff;
    --surface-soft: #f8fafc;
    --border: #dce2e9;
    --text: #18212f;
    --muted: #667085;
    --primary: #2457d6;
    --primary-hover: #1947ba;
    --danger: #c52f3f;
    --focus: #8bb3ff;
    --shadow: 0 14px 36px rgba(19, 33, 68, 0.1);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    height: 100%;
    overflow: hidden;
}

body {
    margin: 0;
    min-width: 320px;
    height: 100vh;
    height: 100dvh;
    color: var(--text);
    background: var(--background);
}

button,
input,
select {
    font: inherit;
}

button,
input,
select {
    border: 1px solid var(--border);
    border-radius: 8px;
}

button {
    min-height: 36px;
    padding: 0 13px;
    color: var(--text);
    background: var(--surface);
    cursor: pointer;
}

button:hover:not(:disabled) {
    border-color: #aeb8c6;
    background: var(--surface-soft);
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
    outline: 3px solid var(--focus);
    outline-offset: 1px;
}

button:disabled {
    cursor: wait;
    opacity: 0.55;
}

input,
select {
    width: 100%;
    min-height: 38px;
    padding: 7px 10px;
    color: var(--text);
    background: var(--surface);
}

label {
    display: block;
    margin: 16px 0 7px;
    font-size: 0.9rem;
    font-weight: 650;
}

h1,
h2,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 4px;
    font-size: 1.45rem;
}

h2 {
    margin-bottom: 0;
    font-size: 1.15rem;
}

.shell {
    display: flex;
    width: min(1440px, 100%);
    height: 100%;
    min-height: 0;
    margin: 0 auto;
    padding: 18px;
    overflow: hidden;
}

.login-card {
    width: min(410px, 100%);
    max-height: 100%;
    margin: auto;
    padding: 32px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.muted,
.field-help {
    color: var(--muted);
}

.field-help {
    margin: 6px 0 0;
    font-size: 0.82rem;
}

.full-width {
    width: 100%;
    margin-top: 22px;
}

.primary {
    border-color: var(--primary);
    color: #fff;
    background: var(--primary);
}

.primary:hover:not(:disabled) {
    border-color: var(--primary-hover);
    color: #fff;
    background: var(--primary-hover);
}

.danger-quiet,
.row-actions .delete-action {
    color: var(--danger);
}

.form-error {
    min-height: 20px;
    margin: 12px 0 0;
    color: var(--danger);
    font-size: 0.88rem;
}

.app-panel {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    width: 100%;
    min-width: 0;
    height: 100%;
    min-height: 0;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.topbar {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 15px 18px;
    border-bottom: 1px solid var(--border);
}

.brand-copy {
    min-width: 150px;
}

.topbar .muted {
    display: flex;
    flex-wrap: wrap;
    gap: 5px 12px;
    margin-bottom: 0;
    font-size: 0.85rem;
}

#admin-label:not(:empty)::before {
    content: "管理员：";
}

.top-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 9px;
}

.search-panel {
    display: grid;
    flex: 0 0 auto;
    grid-template-columns: minmax(180px, 1fr) minmax(180px, 1fr) auto;
    align-items: end;
    gap: 10px;
    padding: 12px 18px;
    border-bottom: 1px solid var(--border);
    background: var(--surface-soft);
}

.search-field {
    margin: 0;
}

.search-field > span,
.page-size-control > span {
    display: block;
    margin-bottom: 5px;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 650;
}

.search-actions {
    display: flex;
    gap: 8px;
}

.notice {
    flex: 0 0 auto;
    margin: 10px 18px 0;
    padding: 8px 11px;
    border: 1px solid #b8d2ff;
    border-radius: 8px;
    color: #17438f;
    background: #eef5ff;
}

.notice.error {
    border-color: #f1b7bd;
    color: #8f1e2b;
    background: #fff1f2;
}

.table-region {
    position: relative;
    display: flex;
    flex: 1 1 auto;
    min-height: 0;
    margin-top: 10px;
    overflow: hidden;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}

.table-wrap {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
    overflow: auto;
    overscroll-behavior: contain;
}

table {
    width: 100%;
    min-width: 880px;
    border-collapse: collapse;
}

th,
td {
    padding: 11px 14px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: middle;
}

th {
    position: sticky;
    top: 0;
    z-index: 3;
    color: var(--muted);
    background: var(--surface-soft);
    font-size: 0.78rem;
    letter-spacing: 0.035em;
    text-transform: uppercase;
}

td {
    font-size: 0.91rem;
    background: var(--surface);
}

tbody tr:hover td {
    background: #f9fbfd;
}

td a {
    color: var(--primary);
    text-decoration: none;
}

td a:hover {
    text-decoration: underline;
}

.password-value {
    display: inline-block;
    min-width: 88px;
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
}

.row-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    min-width: 310px;
}

.row-actions button {
    min-height: 32px;
    padding: 0 9px;
    font-size: 0.8rem;
}

.actions-column {
    width: 340px;
}

th.actions-column,
td:last-child {
    position: sticky;
    right: 0;
    box-shadow: -1px 0 0 var(--border);
}

th.actions-column {
    z-index: 4;
    background: var(--surface-soft);
}

td:last-child {
    z-index: 1;
}

.empty-state {
    padding: 52px 20px;
    color: var(--muted);
    text-align: center;
}

.list-loading {
    position: absolute;
    z-index: 6;
    top: 12px;
    left: 50%;
    padding: 7px 12px;
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--muted);
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 4px 14px rgba(19, 33, 68, 0.08);
    font-size: 0.82rem;
    transform: translateX(-50%);
}

.pagination {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 9px 14px;
    padding: 11px 18px;
}

.pagination span {
    color: var(--muted);
    font-size: 0.88rem;
}

.pagination-summary,
.pagination-buttons,
.page-numbers,
.page-size-control {
    display: flex;
    align-items: center;
    gap: 7px;
}

.pagination-summary {
    min-width: 190px;
}

.page-size-control {
    margin: 0;
    font-size: 0.84rem;
}

.page-size-control > span {
    margin: 0;
}

.page-size-control select {
    width: auto;
    min-height: 34px;
    padding: 5px 28px 5px 9px;
}

.pagination-buttons,
.page-numbers {
    flex-wrap: wrap;
}

.pagination-buttons button,
.page-number {
    min-width: 36px;
    min-height: 34px;
    padding: 0 10px;
}

.page-number.active {
    border-color: var(--primary);
    color: #fff;
    background: var(--primary);
    opacity: 1;
}

.page-ellipsis {
    min-width: 20px;
    text-align: center;
}

dialog {
    width: min(480px, calc(100% - 28px));
    padding: 0;
    max-height: calc(100vh - 28px);
    max-height: calc(100dvh - 28px);
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 14px;
    color: var(--text);
    background: var(--surface);
    box-shadow: var(--shadow);
}

dialog::backdrop {
    background: rgba(16, 24, 40, 0.48);
}

.dialog-form {
    max-height: calc(100vh - 30px);
    max-height: calc(100dvh - 30px);
    padding: 24px;
    overflow-y: auto;
}

.dialog-form > header,
.dialog-form > footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.dialog-form > footer {
    justify-content: flex-end;
    margin-top: 22px;
}

.icon-button {
    min-width: 38px;
    padding: 0;
    border: 0;
    font-size: 1.4rem;
}

.password-input {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
}

.password-input button {
    min-height: 42px;
}

.account-label {
    margin: 14px 0 0;
    color: var(--muted);
    word-break: break-all;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

[hidden] {
    display: none !important;
}

@media (max-width: 820px) {
    .shell {
        width: 100%;
        padding: 10px;
    }

    .topbar {
        align-items: center;
        flex-wrap: wrap;
        padding: 12px;
    }

    .top-actions {
        justify-content: flex-end;
    }

    .search-panel {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
        padding: 10px 12px;
    }

    .search-actions {
        grid-column: 1 / -1;
        justify-content: flex-end;
    }

    .pagination {
        padding: 9px 12px;
    }

    .pagination-buttons {
        width: 100%;
        justify-content: flex-end;
    }

    th,
    td {
        padding: 10px 12px;
    }
}

@media (max-width: 560px) {
    .login-card {
        padding: 24px;
    }

    .brand-copy,
    .top-actions {
        width: 100%;
    }

    .top-actions {
        justify-content: flex-start;
    }

    .search-panel {
        grid-template-columns: 1fr;
    }

    .search-actions {
        grid-column: auto;
    }

    .pagination-summary {
        min-width: 0;
        width: 100%;
    }

    .pagination-buttons {
        justify-content: flex-start;
    }
}
