:root {
    color-scheme: light;
    --bg: #f5f7f8;
    --panel: #ffffff;
    --text: #172026;
    --muted: #60707a;
    --border: #dfe6ea;
    --primary: #0f766e;
    --primary-dark: #115e59;
    --blue: #2563eb;
    --danger: #b42318;
    --danger-bg: #fff2f0;
    --ok-bg: #eefbf4;
    --warn-bg: #fff8e6;
    --shadow: 0 18px 60px rgba(25, 42, 55, 0.11);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
    background:
        linear-gradient(135deg, rgba(15, 118, 110, 0.09), transparent 34%),
        linear-gradient(315deg, rgba(37, 99, 235, 0.08), transparent 30%),
        var(--bg);
    color: var(--text);
    letter-spacing: 0;
}

.shell {
    width: min(1120px, calc(100% - 32px));
    margin: 0 auto;
    padding: 42px 0;
}

.hero {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 28px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--muted);
    font-weight: 700;
    margin-bottom: 20px;
}

.brand-mark {
    display: inline-grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: var(--text);
    color: #fff;
}

h1 {
    margin: 0;
    font-size: clamp(34px, 5vw, 62px);
    line-height: 1.04;
    max-width: 760px;
}

.hero p {
    max-width: 680px;
    margin: 18px 0 0;
    color: var(--muted);
    font-size: 18px;
    line-height: 1.7;
}

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

.panel {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: var(--shadow);
    padding: 24px;
}

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

h2 {
    margin: 0;
    font-size: 22px;
}

.pill {
    border: 1px solid rgba(15, 118, 110, 0.26);
    color: var(--primary-dark);
    background: #edfdfa;
    border-radius: 999px;
    padding: 6px 10px;
    font-size: 13px;
    font-weight: 700;
}

.pill.subtle {
    border-color: rgba(37, 99, 235, 0.22);
    color: #1d4ed8;
    background: #eff6ff;
}

form {
    display: grid;
    gap: 16px;
}

label {
    display: grid;
    gap: 8px;
    color: var(--muted);
    font-weight: 700;
    font-size: 14px;
}

input {
    width: 100%;
    min-height: 48px;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px 13px;
    font: inherit;
    color: var(--text);
    background: #fbfcfd;
    outline: none;
}

input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.12);
}

button {
    min-height: 48px;
    border: 0;
    border-radius: 8px;
    background: var(--primary);
    color: #fff;
    font: inherit;
    font-weight: 800;
    cursor: pointer;
    padding: 0 18px;
}

.button-link {
    display: inline-grid;
    place-items: center;
    min-height: 48px;
    border-radius: 8px;
    background: var(--primary);
    color: #fff;
    font-weight: 800;
    text-decoration: none;
    padding: 0 18px;
}

.button-link:hover {
    background: var(--primary-dark);
}

button:hover {
    background: var(--primary-dark);
}

button.secondary {
    background: #eef2f6;
    color: var(--text);
}

button.secondary:hover {
    background: #e2e8ef;
}

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

.result,
.notice {
    margin-top: 18px;
    border-radius: 8px;
    padding: 14px;
    border: 1px solid var(--border);
    background: #f8fafb;
    line-height: 1.65;
    word-break: break-word;
}

.notice {
    margin: 0 0 20px;
}

.result.ok {
    border-color: rgba(22, 163, 74, 0.24);
    background: var(--ok-bg);
}

.result.warn {
    border-color: rgba(217, 119, 6, 0.24);
    background: var(--warn-bg);
}

.result.danger,
.notice.danger {
    border-color: rgba(180, 35, 24, 0.24);
    background: var(--danger-bg);
    color: var(--danger);
}

.notice.warning {
    border-color: rgba(234, 179, 8, 0.32);
    background: var(--warn-bg);
    color: var(--text);
}

.notice.warning h3 {
    margin: 0 0 14px;
    font-size: 18px;
}

.notice.warning ul {
    margin: 0;
    padding-left: 22px;
    display: grid;
    gap: 10px;
}

.notice.warning .links {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
}

.notice.warning .links a {
    color: var(--blue);
    text-decoration: none;
    font-weight: 600;
}

.notice.warning .links a:hover {
    text-decoration: underline;
}

.notice.info {
    border-color: rgba(37, 99, 235, 0.3);
    background: #f0f7ff;
    color: var(--text);
}

.notice.info h3 {
    margin: 0 0 12px;
    font-size: 20px;
    color: var(--blue);
    font-weight: 800;
}

.notice.info p {
    margin: 0 0 8px;
    font-size: 16px;
    font-weight: 700;
}

.notice.info .note {
    color: var(--muted);
    font-size: 14px;
    font-weight: 600;
}

.password-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.password-wrapper input {
    padding-right: 44px;
}

.toggle-password {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    color: var(--muted);
    cursor: pointer;
    padding: 6px;
    min-height: auto;
    display: flex;
    align-items: center;
    justify-content: center;
}

.toggle-password:hover {
    color: var(--text);
    background: transparent;
}

.support-info {
    margin-top: 20px;
    padding: 14px;
    background: #f0f7ff;
    border: 1px solid rgba(37, 99, 235, 0.2);
    border-radius: 8px;
    font-size: 14px;
    line-height: 1.8;
    color: var(--text);
}

.support-info strong {
    color: var(--blue);
}

.support-info .note {
    color: var(--muted);
    font-size: 13px;
}

.hidden {
    display: none;
}

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

pre {
    overflow: auto;
    background: #172026;
    color: #eef2f6;
    padding: 14px;
    border-radius: 8px;
}

.kv {
    display: grid;
    grid-template-columns: 96px minmax(0, 1fr);
    gap: 8px 12px;
    margin: 0;
}

.kv dt {
    color: var(--muted);
    font-weight: 700;
}

.kv dd {
    margin: 0;
}

.login-shell {
    width: min(460px, calc(100% - 32px));
    margin: 10vh auto 0;
}

.login-shell h1 {
    font-size: 34px;
    margin-bottom: 20px;
}

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

.admin-top {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 24px;
}

.admin-top h1 {
    font-size: 40px;
}

.admin-nav {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.admin-nav a {
    color: var(--text);
    text-decoration: none;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.72);
    padding: 10px 13px;
    border-radius: 8px;
    font-weight: 800;
}

.admin-nav a.active {
    color: #fff;
    background: var(--text);
    border-color: var(--text);
}

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

.stat {
    display: grid;
    gap: 8px;
    box-shadow: none;
}

.stat span {
    color: var(--muted);
    font-weight: 800;
}

.stat strong {
    font-size: 36px;
}

.admin-section {
    margin-bottom: 18px;
    box-shadow: none;
}

.generated-panel {
    border-color: rgba(15, 118, 110, 0.24);
}

.generated-codes {
    width: 100%;
    min-height: 220px;
    resize: vertical;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
    color: var(--text);
    background: #fbfcfd;
    font: 14px/1.6 ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
}

.generated-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 14px;
}

.admin-form {
    grid-template-columns: 120px 180px 220px minmax(220px, 1fr) 170px;
    align-items: end;
}

select {
    min-height: 48px;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0 12px;
    font: inherit;
    color: var(--text);
    background: #fbfcfd;
}

.filters {
    grid-template-columns: minmax(220px, 1fr) 180px 180px 110px;
    align-items: end;
    margin-bottom: 16px;
}

.table-wrap {
    width: 100%;
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: 8px;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 920px;
    background: #fff;
}

th,
td {
    border-bottom: 1px solid var(--border);
    padding: 12px;
    text-align: left;
    vertical-align: top;
    font-size: 14px;
}

th {
    color: var(--muted);
    background: #f8fafb;
    font-weight: 900;
}

tr:last-child td {
    border-bottom: 0;
}

.status {
    display: inline-block;
    border-radius: 999px;
    padding: 4px 8px;
    font-weight: 800;
    font-size: 12px;
    background: #eef2f6;
}

.status.unused,
.status.success {
    color: #15803d;
    background: #dcfce7;
}

.status.locked,
.status.pending,
.status.submitting {
    color: #1d4ed8;
    background: #dbeafe;
}

.status.failed,
.status.submit_unknown {
    color: #b45309;
    background: #fef3c7;
}

.status.used,
.status.canceled,
.status.disabled {
    color: #475569;
    background: #e2e8f0;
}

.inline-form {
    display: inline-grid;
    margin: 0 4px 4px 0;
}

button.tiny {
    min-height: 32px;
    padding: 0 10px;
    font-size: 13px;
}

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

button.danger-btn:hover {
    background: #991b1b;
}

.row-actions {
    min-width: 180px;
}

@media (max-width: 820px) {
    .shell {
        width: min(100% - 24px, 680px);
        padding: 24px 0;
    }

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

    h1 {
        font-size: 38px;
    }

    .panel {
        padding: 18px;
    }

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

    .admin-top,
    .stats,
    .admin-form,
    .filters {
        grid-template-columns: 1fr;
        display: grid;
    }

    .admin-top {
        align-items: start;
    }
}
