:root {
  color-scheme: light;
  --page: #eef2f2;
  --surface: #fff;
  --ink: #172326;
  --muted: #6a787a;
  --line: #d5dddd;
  --line-strong: #abb8ba;
  --green: #147d64;
  --green-dark: #0d604d;
  --green-soft: #e2f3ed;
  --blue: #276ef1;
  --red: #b42318;
  --red-soft: #fff0ee;
  --amber: #8a5a00;
  font-family: "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
}

* { box-sizing: border-box; letter-spacing: 0; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 320px; color: var(--ink); background: var(--page); }
button, input, select, textarea { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }

.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: #e9eeee; }
.login-panel { width: min(380px, 100%); padding: 28px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); box-shadow: 0 18px 45px rgb(24 45 47 / 12%); }
.login-brand { display: flex; align-items: center; gap: 9px; font-size: 13px; font-weight: 750; }
.login-brand img { width: 34px; height: 34px; border-radius: 7px; }
.login-panel > p { margin: 30px 0 5px; color: var(--green); font-size: 11px; font-weight: 800; }
.login-panel h1 { margin: 0 0 24px; font-size: 28px; }
label { display: grid; gap: 6px; color: #445255; font-size: 11px; font-weight: 700; }
.login-panel label + label { margin-top: 13px; }

input, select, textarea { width: 100%; border: 1px solid var(--line-strong); border-radius: 4px; outline: none; color: var(--ink); background: #fff; }
input, select { height: 39px; padding: 0 10px; }
textarea { padding: 10px; resize: vertical; font-family: Consolas, monospace; font-size: 10px; line-height: 1.45; }
input:focus, select:focus, textarea:focus { border-color: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }

.button { min-height: 35px; padding: 0 13px; border: 1px solid transparent; border-radius: 4px; font-size: 11px; font-weight: 750; }
.button.primary { color: #fff; border-color: var(--green-dark); background: var(--green); }
.button.primary:hover { background: var(--green-dark); }
.button.subtle { color: #344346; border-color: var(--line-strong); background: #fff; }
.login-panel > .button { width: 100%; margin-top: 20px; }
.button:disabled { cursor: wait; opacity: .55; }

.topbar { height: 58px; padding: 0 20px; display: flex; align-items: center; justify-content: space-between; gap: 16px; border-bottom: 1px solid var(--line); background: var(--surface); }
.brand, .top-actions { display: flex; align-items: center; gap: 10px; }
.brand img { width: 30px; height: 30px; border-radius: 6px; }
.brand strong { font-size: 13px; }
.brand span, .top-actions > span { color: var(--muted); font-size: 10px; }
.online { display: flex; align-items: center; gap: 6px; }
.online i { width: 7px; height: 7px; border-radius: 50%; background: var(--green); }
.workspace { min-height: calc(100vh - 58px); display: grid; grid-template-columns: 180px minmax(0, 1fr); }
.sidebar { padding: 18px 12px; border-right: 1px solid var(--line); background: #f7f9f9; }
.sidebar button { width: 100%; height: 38px; padding: 0 12px; border: 0; border-radius: 4px; color: #4b595b; background: transparent; text-align: left; font-size: 11px; font-weight: 700; }
.sidebar button:hover { background: #e8eeee; }
.sidebar button.active { color: #fff; background: var(--green); }
.content { min-width: 0; padding: 26px; }
.view { display: none; }
.view.active { display: block; }
.page-head { min-height: 58px; display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; border-bottom: 1px solid var(--line); }
.page-head p { margin: 0 0 4px; color: var(--green); font-size: 10px; font-weight: 800; }
.page-head h1 { margin: 0; font-size: 22px; }

.metrics { margin-top: 18px; display: grid; grid-template-columns: repeat(4, minmax(130px, 1fr)); gap: 10px; }
.metric { min-height: 92px; padding: 16px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); }
.metric span { color: var(--muted); font-size: 10px; }
.metric strong { display: block; margin-top: 9px; overflow-wrap: anywhere; font-size: 23px; }
.status-band { margin-top: 18px; padding: 15px 16px; display: flex; justify-content: space-between; gap: 14px; border-left: 3px solid var(--green); background: var(--surface); font-size: 11px; }

.toolbar { margin: 16px 0 10px; display: grid; grid-template-columns: minmax(180px, 340px) auto; gap: 7px; justify-content: start; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: 10px; }
th, td { height: 45px; padding: 8px 10px; border-bottom: 1px solid #e5eaea; text-align: left; white-space: nowrap; }
th { color: var(--muted); background: #f6f8f8; font-size: 9px; }
tbody tr:last-child td { border-bottom: 0; }
td .button { min-height: 27px; padding: 0 8px; margin-right: 4px; font-size: 9px; }
.tag { display: inline-flex; align-items: center; min-height: 22px; padding: 0 7px; border-radius: 3px; color: #435153; background: #e9eeee; font-size: 9px; font-weight: 750; }
.tag.good { color: var(--green-dark); background: var(--green-soft); }
.tag.bad { color: var(--red); background: var(--red-soft); }
.table-empty { padding: 30px; margin: 0; color: var(--muted); text-align: center; font-size: 11px; }

.plan-editor { margin-top: 18px; display: grid; gap: 9px; }
.plan-form { padding: 14px; display: grid; grid-template-columns: minmax(140px, 1fr) 110px 110px 80px auto; align-items: end; gap: 9px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); }
.plan-form .check-row { height: 39px; }
.settings-form { max-width: 820px; margin-top: 18px; display: grid; gap: 15px; }
.settings-form.narrow { max-width: 440px; }
.settings-form fieldset { margin: 0; padding: 0; border: 0; }
.settings-form legend { margin-bottom: 7px; color: #445255; font-size: 11px; font-weight: 700; }
.two-col { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.segmented { width: 220px; height: 36px; padding: 2px; display: grid; grid-template-columns: repeat(2, 1fr); border: 1px solid var(--line); border-radius: 4px; background: #edf1f1; }
.segmented label { display: block; }
.segmented input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.segmented span { height: 30px; display: grid; place-items: center; border-radius: 2px; color: var(--muted); font-size: 10px; cursor: pointer; }
.segmented input:checked + span { color: var(--ink); background: #fff; box-shadow: 0 1px 2px rgb(20 36 39 / 14%); }
.settings-form label > span { color: var(--green); font-size: 9px; }
.endpoint-list { padding: 12px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.endpoint-list div { display: grid; grid-template-columns: 84px minmax(0, 1fr); gap: 8px; padding: 4px 0; font-size: 10px; }
.endpoint-list span { color: var(--muted); }
.endpoint-list code { min-width: 0; white-space: normal; overflow-wrap: anywhere; word-break: break-all; }
.check-row { display: flex; align-items: center; gap: 8px; }
.check-row input { width: 15px; height: 15px; }
.form-actions { display: flex; justify-content: flex-end; }

.notice { margin-bottom: 12px; padding: 10px 12px; border-left: 3px solid; font-size: 10px; line-height: 1.5; }
.notice.error { color: #7a271a; border-color: var(--red); background: var(--red-soft); }
.notice.success { color: var(--green-dark); border-color: var(--green); background: var(--green-soft); }

dialog { width: min(440px, calc(100% - 28px)); padding: 0; border: 1px solid var(--line); border-radius: 7px; color: var(--ink); box-shadow: 0 18px 60px rgb(20 36 39 / 22%); }
dialog::backdrop { background: rgb(20 30 32 / 42%); }
dialog form { padding: 18px; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; }
.dialog-head h2 { margin: 0; font-size: 16px; }
.dialog-head button { width: 28px; height: 28px; border: 0; color: var(--muted); background: transparent; font-size: 20px; }
dialog p { color: var(--muted); font-size: 10px; }
dialog label { margin-top: 12px; }
.dialog-actions { margin-top: 18px; display: flex; justify-content: flex-end; gap: 7px; }

@media (max-width: 900px) {
  .metrics { grid-template-columns: repeat(2, minmax(130px, 1fr)); }
  .plan-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .plan-form .button { min-height: 39px; }
}

@media (max-width: 680px) {
  .topbar { padding: 0 12px; }
  .brand span, .online, #admin-name { display: none; }
  .workspace { display: block; }
  .sidebar { padding: 8px; display: flex; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .sidebar button { width: auto; flex: 0 0 auto; }
  .content { padding: 17px 12px; }
  .metrics, .two-col { grid-template-columns: 1fr; }
  .status-band { display: block; }
  .plan-form { grid-template-columns: 1fr; }
}
