:root {
    --bg: #f5f6f8;
    --panel: #ffffff;
    --text: #1d242d;
    --muted: #6b7280;
    --line: #d9dee7;
    --primary: #16775f;
    --primary-strong: #0f5d4a;
    --blue: #2367b1;
    --amber: #9a6400;
    --red: #b73535;
    --green-soft: #e9f7f2;
    --amber-soft: #fff4db;
    --red-soft: #fdecec;
    --shadow: 0 10px 30px rgba(20, 30, 45, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Arial, "Noto Sans TC", sans-serif;
    line-height: 1.5;
}

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

button {
    border: 0;
    border-radius: 8px;
    cursor: pointer;
    min-height: 40px;
    padding: 0 14px;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--text);
    min-height: 40px;
    padding: 8px 10px;
}

textarea {
    resize: vertical;
}

code,
pre {
    font-family: Consolas, "Liberation Mono", monospace;
}

pre {
    margin: 0;
    overflow: auto;
    background: #20242b;
    color: #f6f8fb;
    border-radius: 8px;
    padding: 14px;
}

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

.login-panel {
    width: min(420px, 100%);
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
    padding: 28px;
}

.topbar {
    min-height: 84px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 18px clamp(16px, 3vw, 36px);
    background: #fff;
    border-bottom: 1px solid var(--line);
}

.topbar h1,
.login-panel h1 {
    margin: 0;
    font-size: clamp(24px, 3vw, 34px);
    letter-spacing: 0;
}

.eyebrow {
    color: var(--primary);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0;
    margin: 0 0 6px;
}

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

.page {
    width: min(1400px, 100%);
    margin: 0 auto;
    padding: 22px clamp(14px, 3vw, 36px) 48px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(130px, 1fr));
    gap: 12px;
    margin-bottom: 18px;
}

.stat,
.panel,
.alert {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.stat {
    padding: 15px;
}

.stat span,
.label,
label span {
    display: block;
    color: var(--muted);
    font-size: 13px;
    margin-bottom: 6px;
}

.stat strong {
    display: block;
    font-size: 28px;
}

.stat.good {
    background: var(--green-soft);
    border-color: #b7e2d3;
}

.stat.warn {
    background: var(--amber-soft);
    border-color: #efd59c;
}

.stat.danger {
    background: var(--red-soft);
    border-color: #efc4c4;
}

.two-col {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 18px;
    margin-bottom: 18px;
}

.panel {
    padding: 18px;
    box-shadow: var(--shadow);
}

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

.panel h2 {
    margin: 0;
    font-size: 18px;
    letter-spacing: 0;
}

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

.form-grid.compact,
.form-grid .wide,
.full {
    grid-column: 1 / -1;
}

.primary {
    background: var(--primary);
    color: #fff;
    font-weight: 700;
}

.primary:hover {
    background: var(--primary-strong);
}

.secondary {
    background: var(--blue);
    color: #fff;
}

.ghost {
    background: #eef1f5;
    color: var(--text);
}

.danger-outline {
    background: #fff;
    color: var(--red);
    border: 1px solid #dfb0b0;
}

.copy-btn {
    background: #fff;
    color: var(--primary);
    border: 1px solid #a9d8ca;
}

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

.alert.success {
    background: var(--green-soft);
    border-color: #b7e2d3;
}

.alert.error {
    background: var(--red-soft);
    border-color: #efc4c4;
}

.alert.key {
    align-items: flex-start;
    background: #edf5ff;
    border-color: #bdd6f2;
}

.alert.key code {
    flex: 1;
    overflow-wrap: anywhere;
}

.snippet-stack {
    display: grid;
    gap: 14px;
}

.table-wrap {
    overflow-x: auto;
}

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

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

th {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

td small {
    display: block;
    color: var(--muted);
    margin-top: 3px;
}

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
}

.badge.active {
    background: var(--green-soft);
    color: var(--primary-strong);
}

.badge.suspended {
    background: var(--amber-soft);
    color: var(--amber);
}

details summary {
    color: var(--blue);
    cursor: pointer;
    font-weight: 700;
}

.inline-edit {
    display: grid;
    min-width: 280px;
    gap: 8px;
    margin-top: 10px;
}

.rotate-form {
    margin-top: 8px;
}

.button-row {
    display: flex;
    gap: 8px;
}

.danger-text {
    color: var(--red);
}

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

.event {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--line);
}

.event:last-child {
    border-bottom: 0;
    padding-bottom: 0;
}

.event small {
    display: block;
    color: var(--muted);
}

.dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-top: 7px;
    background: var(--blue);
    flex: 0 0 10px;
}

.dot.ok {
    background: var(--primary);
}

.dot.bad {
    background: var(--red);
}

.empty {
    color: var(--muted);
    text-align: center;
}

@media (max-width: 980px) {
    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .two-col {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .topbar {
        align-items: flex-start;
        flex-direction: column;
    }

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

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

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