:root {
    color-scheme: light;
    --bg: #f5f6f7;
    --surface: #ffffff;
    --text: #202326;
    --muted: #687078;
    --line: #dfe3e6;
    --primary: #176b45;
    --primary-hover: #105438;
    --danger: #b42318;
    --warning-bg: #fff7df;
    --warning-border: #e9bf4b;
    --success-bg: #eaf7ef;
    --error-bg: #fff0ef;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
    font-size: 14px;
    letter-spacing: 0;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
.topbar {
    min-height: 58px;
    padding: 0 28px;
    display: flex;
    align-items: center;
    gap: 32px;
    background: #202a27;
    color: white;
}
.brand { color: white; font-weight: 700; font-size: 16px; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.topbar nav { display: flex; align-items: center; gap: 24px; flex: 1; }
.topbar nav a { color: #dce5e1; }
.topbar form { margin: 0; }
.page { max-width: 1320px; margin: 0 auto; padding: 32px 28px 56px; }
.login-page { min-height: 100vh; display: grid; place-items: center; }
.login-panel { width: min(380px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 30px; }
.install-panel { width: min(760px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 30px; }
.install-heading { display: flex; align-items: center; gap: 14px; margin-bottom: 24px; }
.install-mark { width: 42px; height: 42px; display: grid; place-items: center; flex: 0 0 auto; background: var(--primary); color: white; border-radius: 6px; font-size: 20px; font-weight: 800; }
.secret-warning { margin-top: 0; }
.install-form { display: grid; gap: 26px; }
.install-form fieldset { margin: 0; padding: 20px; border: 1px solid var(--line); }
.install-form legend { padding: 0 8px; font-size: 15px; font-weight: 700; }
.install-form legend small { margin-left: 6px; color: var(--muted); font-size: 12px; font-weight: 500; }
.form-grid-two { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.install-actions { display: flex; justify-content: flex-end; }
h1, h2 { margin: 0; letter-spacing: 0; }
h1 { font-size: 24px; line-height: 1.3; }
h2 { font-size: 17px; line-height: 1.4; }
p { color: var(--muted); margin: 7px 0 0; }
.page-heading, .section-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.page-heading { margin-bottom: 26px; }
.section-heading { margin-bottom: 16px; }
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border: 1px solid var(--line); background: var(--surface); margin-bottom: 24px; }
.metric { padding: 20px 22px; border-right: 1px solid var(--line); }
.metric:last-child { border-right: 0; }
.metric span { display: block; color: var(--muted); margin-bottom: 8px; }
.metric strong { font-size: 26px; }
.section-block, .generated-block { background: var(--surface); border: 1px solid var(--line); padding: 22px; margin-top: 20px; }
.generated-block { border-color: #8bbba3; }
.section-block > h2 { margin-bottom: 18px; }
.narrow { max-width: 620px; }
.notice { padding: 12px 14px; border: 1px solid; margin: 0 0 20px; }
.notice-warning { background: var(--warning-bg); border-color: var(--warning-border); }
.notice-success { background: var(--success-bg); border-color: #8cc6a1; }
.notice-error { background: var(--error-bg); border-color: #e1aaa5; color: #8c1c13; }
.form-stack { display: grid; gap: 18px; margin-top: 22px; }
.form-grid { display: grid; grid-template-columns: 1.1fr 1fr 1fr 1.6fr auto; gap: 14px; align-items: end; }
.form-inline { display: flex; align-items: end; flex-wrap: wrap; gap: 16px; }
.form-action { align-self: end; }
label { display: grid; gap: 7px; color: #41474d; font-weight: 600; }
input, textarea {
    width: 100%;
    border: 1px solid #bcc3c7;
    border-radius: 4px;
    background: white;
    color: var(--text);
    padding: 9px 10px;
    font: inherit;
}
input:focus, textarea:focus { outline: 2px solid #88b8a2; border-color: var(--primary); }
textarea { resize: vertical; font-family: Consolas, monospace; line-height: 1.6; }
.button {
    min-height: 36px;
    border: 1px solid #aeb6ba;
    border-radius: 4px;
    background: white;
    color: var(--text);
    padding: 7px 13px;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}
.button:hover { background: #f0f2f2; text-decoration: none; }
.button-primary { background: var(--primary); border-color: var(--primary); color: white; }
.button-primary:hover { background: var(--primary-hover); }
.button-danger { color: var(--danger); }
.button-small { min-height: 30px; padding: 4px 9px; }
.button-quiet { color: white; border-color: #64706c; background: transparent; }
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; white-space: nowrap; }
th, td { text-align: left; padding: 12px 11px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-size: 12px; font-weight: 700; background: #f8f9f9; }
tbody tr:last-child td { border-bottom: 0; }
code { font-family: Consolas, monospace; font-size: 13px; }
.status { display: inline-block; padding: 3px 7px; border-radius: 3px; font-size: 12px; font-weight: 700; }
.status-on { color: #12613d; background: #e3f4ea; }
.status-off { color: #8c1c13; background: #fce8e6; }
.actions { display: flex; gap: 7px; }
.actions form { margin: 0; }
.adjust-form { display: grid; grid-template-columns: 80px auto; gap: 6px; }
.adjust-form input { padding: 5px 7px; }
.card-key-cell { display: flex; align-items: center; gap: 8px; }
.legacy-note { display: block; margin-top: 4px; color: var(--muted); font-size: 12px; }
.empty { color: var(--muted); text-align: center; padding: 28px; }

@media (max-width: 900px) {
    .topbar { align-items: flex-start; flex-wrap: wrap; gap: 14px; padding: 16px 18px; }
    .topbar nav { order: 3; flex-basis: 100%; overflow-x: auto; padding-bottom: 2px; }
    .page { padding: 24px 16px 44px; }
    .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .metric:nth-child(2) { border-right: 0; }
    .metric:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
    .form-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 560px) {
    .topbar nav { gap: 18px; }
    .page-heading { align-items: flex-start; }
    .metrics { grid-template-columns: 1fr; }
    .metric { border-right: 0; border-bottom: 1px solid var(--line); }
    .metric:last-child { border-bottom: 0; }
    .form-grid { grid-template-columns: 1fr; }
    .form-grid-two { grid-template-columns: 1fr; }
    .form-grid-two > span { display: none; }
    .section-block, .generated-block { padding: 16px; }
    .install-panel { padding: 20px 16px; }
    .install-actions .button { width: 100%; }
}
