:root {
    --bg: #f4f0e8;
    --surface: rgba(255, 252, 247, 0.9);
    --surface-strong: #fffdf9;
    --surface-muted: #f8f3eb;
    --surface-ink: #fff8ef;
    --border: rgba(27, 45, 75, 0.12);
    --border-strong: rgba(27, 45, 75, 0.2);
    --text: #162033;
    --text-muted: #5f6b82;
    --text-soft: #8b94a7;
    --primary: #213a63;
    --primary-strong: #172945;
    --primary-soft: #e8eefb;
    --accent: #c07b36;
    --success-bg: #ebf7ef;
    --success-text: #21633f;
    --danger-bg: #fff0ed;
    --danger-text: #9d3326;
    --shadow-soft: 0 24px 50px rgba(18, 31, 53, 0.08);
    --shadow-strong: 0 32px 80px rgba(18, 31, 53, 0.16);
    --radius-xl: 8px;
    --radius-lg: 8px;
    --radius-md: 8px;
    --radius-sm: 8px;
    --content-width: 1320px;
    --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
}

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

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--text);
    font-family: Georgia, "Times New Roman", "Noto Serif SC", "Songti SC", serif;
    background:
        radial-gradient(circle at top left, rgba(192, 123, 54, 0.12), transparent 24%),
        radial-gradient(circle at bottom right, rgba(33, 58, 99, 0.16), transparent 30%),
        linear-gradient(180deg, #f8f4ed 0%, var(--bg) 52%, #efe8dd 100%);
}

h1,
h2,
h3,
p {
    margin: 0;
}

a {
    color: inherit;
}

button,
input,
select {
    font: inherit;
}

button,
.button-link {
    min-height: 46px;
    border: 1px solid var(--primary);
    border-radius: var(--radius-sm);
    padding: 0 18px;
    font-size: 14px;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition:
        transform 180ms var(--ease-out),
        background-color 180ms var(--ease-out),
        color 180ms var(--ease-out),
        border-color 180ms var(--ease-out),
        box-shadow 180ms var(--ease-out);
}

button:hover,
.button-link:hover {
    transform: translateY(-1px);
}

button:focus-visible,
.button-link:focus-visible,
input:focus-visible,
select:focus-visible,
.modal-close:focus-visible,
.modal-backdrop:focus-visible {
    outline: 3px solid rgba(33, 58, 99, 0.24);
    outline-offset: 3px;
}

button {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 12px 24px rgba(33, 58, 99, 0.18);
}

button.secondary,
.button-link.secondary-link {
    background: transparent;
    color: var(--primary);
    border-color: var(--border-strong);
    box-shadow: none;
}

button.ghost {
    min-height: 36px;
    padding: 0 12px;
    border-radius: var(--radius-sm);
    border-color: rgba(33, 58, 99, 0.14);
    background: #fff;
    color: var(--primary);
    box-shadow: none;
}

button.ghost:hover,
button.secondary:hover,
.button-link.secondary-link:hover {
    background: rgba(33, 58, 99, 0.06);
}

button.ghost-danger {
    color: var(--danger-text);
    border-color: rgba(157, 51, 38, 0.16);
}

input,
select {
    width: 100%;
    min-height: 48px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0 14px;
    background: rgba(255, 255, 255, 0.84);
    color: var(--text);
    font-size: 15px;
    transition:
        border-color 180ms var(--ease-out),
        box-shadow 180ms var(--ease-out),
        background-color 180ms var(--ease-out);
}

input:focus,
select:focus {
    border-color: rgba(33, 58, 99, 0.36);
    box-shadow: 0 0 0 4px rgba(33, 58, 99, 0.08);
    background: #fff;
}

label {
    display: grid;
    gap: 8px;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-muted);
}

[hidden] {
    display: none !important;
}

.eyebrow,
.section-kicker,
.metric-label {
    font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--accent);
}

.section-heading {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 22px;
}

.section-heading h2 {
    font-size: clamp(1.65rem, 2vw, 2rem);
    line-height: 1.08;
}

.section-heading p {
    max-width: 420px;
    color: var(--text-muted);
    font-size: 14px;
    line-height: 1.65;
    text-align: right;
}

.panel {
    background: var(--surface);
    border: 1px solid rgba(255, 255, 255, 0.55);
    border-radius: var(--radius-xl);
    padding: 24px;
    box-shadow: var(--shadow-soft);
    backdrop-filter: blur(18px);
}

.notice {
    border: 1px solid rgba(33, 58, 99, 0.14);
    background: rgba(232, 238, 251, 0.9);
    color: var(--primary-strong);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    font-size: 14px;
    line-height: 1.6;
}

.notice.error {
    border-color: rgba(157, 51, 38, 0.14);
    background: rgba(255, 240, 237, 0.94);
    color: var(--danger-text);
}

.field-error {
    color: var(--danger-text);
    font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    font-size: 13px;
    line-height: 1.5;
}

.admin-shell {
    width: min(calc(100% - 32px), var(--content-width));
    margin: 0 auto;
    padding: 28px 0 48px;
}

.admin-hero {
    display: flex;
    justify-content: space-between;
    gap: 28px;
    padding: 32px;
    margin-bottom: 24px;
    border: 1px solid rgba(255, 255, 255, 0.55);
    border-radius: var(--radius-xl);
    background:
        linear-gradient(135deg, rgba(255, 253, 249, 0.92), rgba(246, 239, 228, 0.9)),
        linear-gradient(160deg, rgba(33, 58, 99, 0.08), transparent 42%);
    box-shadow: var(--shadow-soft);
}

.hero-copy {
    max-width: 720px;
    display: grid;
    gap: 14px;
}

.hero-copy h1 {
    font-size: clamp(2.3rem, 4vw, 4rem);
    line-height: 0.98;
    letter-spacing: -0.03em;
}

.hero-copy p {
    max-width: 620px;
    font-size: 16px;
    line-height: 1.8;
    color: var(--text-muted);
}

.hero-actions {
    display: flex;
    align-items: start;
    gap: 12px;
    flex-wrap: wrap;
}

.dashboard-grid {
    display: grid;
    gap: 20px;
}

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}

.metric-card {
    padding: 22px;
    border-radius: var(--radius-lg);
    background: var(--surface-strong);
    border: 1px solid rgba(255, 255, 255, 0.5);
    box-shadow: 0 16px 36px rgba(18, 31, 53, 0.06);
}

.metric-value {
    display: block;
    margin-top: 10px;
    font-size: clamp(2rem, 3vw, 2.75rem);
    line-height: 1;
    font-weight: 700;
}

.metric-card p {
    margin-top: 12px;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-muted);
}

.spotlight-panel {
    background:
        linear-gradient(135deg, rgba(255, 250, 242, 0.96), rgba(255, 255, 255, 0.92)),
        radial-gradient(circle at top right, rgba(192, 123, 54, 0.12), transparent 28%);
}

.generated-codes {
    display: grid;
    gap: 12px;
}

.generated-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.generated-hint {
    color: var(--text-muted);
    font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    font-size: 13px;
    line-height: 1.6;
}

.generated-code-list {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

code {
    display: inline-flex;
    align-items: center;
    min-height: 38px;
    padding: 0 14px;
    border-radius: var(--radius-sm);
    background: var(--surface-ink);
    border: 1px solid rgba(33, 58, 99, 0.12);
    color: var(--primary-strong);
    font-family: "Cascadia Code", "Consolas", monospace;
    font-size: 13px;
    letter-spacing: 0.02em;
}

.table-panel {
    overflow: hidden;
}

.utility-panel {
    background:
        linear-gradient(135deg, rgba(251, 248, 242, 0.96), rgba(255, 255, 255, 0.9)),
        radial-gradient(circle at right top, rgba(33, 58, 99, 0.08), transparent 25%);
}

.section-heading.compact {
    margin-bottom: 18px;
}

.toolbar-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.6fr) repeat(2, minmax(180px, 220px)) minmax(140px, 160px) auto;
    gap: 14px;
    align-items: end;
}

.toolbar-field {
    gap: 10px;
}

.toolbar-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.batch-form {
    display: grid;
    gap: 18px;
}

.batch-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.check-all {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    font-size: 14px;
    font-weight: 600;
    color: var(--primary-strong);
    letter-spacing: normal;
    text-transform: none;
}

.check-all input,
.select-col input[type="checkbox"] {
    width: 18px;
    min-height: 18px;
    height: 18px;
    margin: 0;
    accent-color: var(--primary);
}

.batch-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: end;
}

.batch-field {
    gap: 10px;
    min-width: 170px;
}

.batch-field select,
.batch-field input {
    width: 100%;
    min-width: 160px;
}

.batch-days-field {
    min-width: 170px;
    transition:
        opacity 180ms var(--ease-out),
        transform 180ms var(--ease-out),
        max-width 180ms var(--ease-out),
        margin 180ms var(--ease-out);
}

.batch-days-field span {
    font-size: 11px;
    letter-spacing: 0.08em;
}

.batch-days-field input {
    min-width: 170px;
}

.table-meta {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    color: var(--text-muted);
    font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    font-size: 13px;
}

.table-footer {
    display: grid;
    gap: 16px;
    margin-top: 18px;
}

.table-wrap {
    overflow-x: auto;
    border: 1px solid rgba(33, 58, 99, 0.08);
    border-radius: var(--radius-lg);
    background: rgba(255, 255, 255, 0.56);
    position: relative;
}

.table-empty {
    padding: 40px 24px;
    text-align: center;
    font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

.table-empty strong {
    display: block;
    font-size: 16px;
    color: var(--primary-strong);
}

.table-empty p {
    margin-top: 8px;
    color: var(--text-muted);
    font-size: 14px;
    line-height: 1.7;
}

.static-empty {
    border: 1px dashed rgba(33, 58, 99, 0.14);
    border-radius: var(--radius-lg);
    background: rgba(255, 255, 255, 0.42);
}

.license-table {
    width: 100%;
    min-width: 980px;
    border-collapse: separate;
    border-spacing: 0;
    font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

.license-table thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    padding: 16px 18px;
    text-align: left;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-soft);
    background: rgba(248, 243, 235, 0.96);
    border-bottom: 1px solid rgba(33, 58, 99, 0.08);
}

.select-col {
    width: 56px;
    text-align: center;
}

.select-col input[type="checkbox"] {
    justify-self: center;
}

.license-table tbody td {
    padding: 18px;
    font-size: 14px;
    border-bottom: 1px solid rgba(33, 58, 99, 0.06);
    vertical-align: top;
}

.license-table tbody tr {
    transition: background-color 180ms var(--ease-out);
}

.license-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.74);
}

.license-table tbody tr:last-child td {
    border-bottom: 0;
}

.license-cell {
    display: grid;
    gap: 8px;
}

.license-cell span {
    font-size: 12px;
    color: var(--text-soft);
}

.mono-cell {
    font-family: "Cascadia Code", "Consolas", monospace;
    font-variant-numeric: tabular-nums;
    color: var(--primary-strong);
    white-space: nowrap;
}

.status {
    display: inline-flex;
    align-items: center;
    min-height: 32px;
    padding: 0 12px;
    border-radius: var(--radius-sm);
    font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    background: var(--success-bg);
    color: var(--success-text);
}

.status.disabled {
    background: var(--danger-bg);
    color: var(--danger-text);
}

.action-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.action-group form {
    margin: 0;
}

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
}

.pagination-link {
    min-height: 42px;
    min-width: 42px;
    padding: 0 14px;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(33, 58, 99, 0.12);
    background: rgba(255, 255, 255, 0.68);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    font-size: 14px;
    font-weight: 600;
    transition:
        background-color 180ms var(--ease-out),
        border-color 180ms var(--ease-out),
        color 180ms var(--ease-out);
}

.pagination-link:hover {
    background: rgba(33, 58, 99, 0.06);
}

.pagination-link.is-current {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.pagination-link.disabled {
    pointer-events: none;
    opacity: 0.45;
}

.modal-shell {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: grid;
    place-items: center;
    padding: 24px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 220ms var(--ease-out);
}

.modal-shell:target,
.modal-shell.force-open,
.modal-shell.is-open {
    pointer-events: auto;
    opacity: 1;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(22, 32, 51, 0.48);
    backdrop-filter: blur(8px);
}

.modal-card {
    position: relative;
    z-index: 1;
    width: min(520px, 100%);
    transform: translateY(18px) scale(0.98);
    transition: transform 220ms var(--ease-out);
    box-shadow: var(--shadow-strong);
}

.modal-shell:target .modal-card,
.modal-shell.force-open .modal-card,
.modal-shell.is-open .modal-card {
    transform: translateY(0) scale(1);
}

.modal-header {
    display: flex;
    align-items: start;
    justify-content: space-between;
    gap: 16px;
}

.modal-header h2 {
    margin-top: 8px;
    font-size: 2rem;
    line-height: 1.05;
}

.modal-close {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(33, 58, 99, 0.06);
    color: var(--primary);
    text-decoration: none;
    font-size: 26px;
    line-height: 1;
}

.modal-copy {
    margin-top: 14px;
    color: var(--text-muted);
    font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    font-size: 14px;
    line-height: 1.7;
}

.modal-form {
    margin-top: 22px;
    display: grid;
    gap: 16px;
}

.form-grid {
    display: grid;
    gap: 14px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    flex-wrap: wrap;
}

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

.login-stage {
    width: min(100%, 1120px);
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(360px, 440px);
    gap: 28px;
    align-items: stretch;
}

.login-brand {
    padding: 40px;
    border-radius: var(--radius-xl);
    background:
        linear-gradient(150deg, rgba(255, 252, 247, 0.92), rgba(245, 236, 224, 0.88)),
        radial-gradient(circle at top left, rgba(192, 123, 54, 0.14), transparent 30%);
    border: 1px solid rgba(255, 255, 255, 0.5);
    box-shadow: var(--shadow-soft);
    display: grid;
    align-content: center;
    gap: 16px;
}

.login-brand h1 {
    font-size: clamp(2.2rem, 4vw, 4.2rem);
    line-height: 0.98;
    letter-spacing: -0.04em;
}

.login-brand p {
    max-width: 560px;
    font-size: 16px;
    line-height: 1.85;
    color: var(--text-muted);
}

.login-points {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 6px;
}

.login-points span {
    min-height: 38px;
    padding: 0 14px;
    border-radius: var(--radius-sm);
    display: inline-flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.58);
    border: 1px solid rgba(33, 58, 99, 0.08);
    color: var(--primary);
    font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    font-size: 13px;
    font-weight: 600;
}

.login-panel {
    padding: 28px;
    display: grid;
    align-content: center;
}

.stack-form {
    display: grid;
    gap: 12px;
}

.narrow {
    width: min(360px, 100%);
}

@media (max-width: 1024px) {
    .admin-hero,
    .section-heading,
    .login-stage {
        grid-template-columns: 1fr;
        display: grid;
    }

    .admin-hero {
        padding: 28px;
    }

    .hero-actions {
        justify-content: start;
    }

    .section-heading p {
        max-width: none;
        text-align: left;
    }

    .metrics-grid {
        grid-template-columns: 1fr;
    }

    .toolbar-grid {
        grid-template-columns: 1fr;
    }

    .toolbar-actions {
        justify-content: start;
    }

    .batch-toolbar {
        align-items: stretch;
    }

    .batch-actions {
        width: 100%;
    }

    .batch-actions select,
    .batch-actions input,
    .batch-days-field,
    .batch-actions button {
        width: 100%;
    }

    .batch-days-field input {
        min-width: 0;
    }
}

@media (max-width: 720px) {
    .admin-shell {
        width: min(calc(100% - 20px), var(--content-width));
        padding-top: 18px;
    }

    .admin-hero,
    .login-brand,
    .login-panel,
    .panel {
        padding: 20px;
        border-radius: var(--radius-xl);
    }

    .hero-copy h1,
    .login-brand h1 {
        font-size: 2.3rem;
    }

    .section-heading h2,
    .modal-header h2 {
        font-size: 1.6rem;
    }

    .hero-actions,
    .modal-actions,
    .toolbar-actions,
    .generated-toolbar,
    .table-meta {
        width: 100%;
        flex-direction: column;
        align-items: stretch;
    }

    .hero-actions > *,
    .modal-actions > *,
    .toolbar-actions > *,
    .generated-toolbar > *,
    button,
    .button-link {
        width: 100%;
    }

    .license-table {
        min-width: 840px;
    }
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    *,
    *::before,
    *::after {
        animation: none !important;
        transition: none !important;
    }
}
