:root {
  --bg: #f2f4f3;
  --surface: #ffffff;
  --surface-soft: #f7f9f8;
  --sidebar: #202624;
  --text: #17211b;
  --muted: #69736e;
  --line: #dce2df;
  --green: #16825d;
  --green-soft: #e6f3ed;
  --blue: #2866c7;
  --blue-soft: #e9f0fb;
  --amber: #a86215;
  --amber-soft: #fff2dc;
  --red: #b43838;
  --red-soft: #faeaea;
  --shadow: 0 10px 28px rgba(21, 31, 26, .07);
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--bg); }
body { margin: 0; min-height: 100vh; color: var(--text); background: var(--bg); font-family: "Microsoft YaHei UI", "PingFang SC", Arial, sans-serif; letter-spacing: 0; }
button, input, select { font: inherit; letter-spacing: 0; }
button, a { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid rgba(40, 102, 199, .28); outline-offset: 2px; }
[hidden] { display: none !important; }

.eyebrow { margin: 0 0 7px; color: var(--green); font: 700 11px/1.2 Bahnschrift, "Arial Narrow", sans-serif; letter-spacing: 1.4px; }
.brand-lockup { display: flex; align-items: center; gap: 10px; font-weight: 700; white-space: nowrap; }
.brand-mark { display: inline-grid; place-items: center; width: 32px; height: 32px; color: #fff; background: var(--green); border-radius: 6px; font: 800 18px/1 Bahnschrift, sans-serif; }
.brand-lockup.inverse { color: #fff; }

.login-view { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--bg); position: relative; overflow: hidden; }
.login-view::before { content: ""; position: fixed; inset: 0 auto 0 0; width: 34%; background: var(--sidebar); }
.login-panel { width: min(760px, 100%); min-height: 470px; display: grid; grid-template-columns: 1.05fr 1fr; gap: 56px; align-items: center; padding: 54px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); position: relative; z-index: 1; }
.login-panel > .brand-lockup { position: absolute; top: 28px; left: 30px; }
.login-copy h1 { margin: 0; max-width: 330px; font: 700 clamp(36px, 6vw, 58px)/1.05 Bahnschrift, "Microsoft YaHei UI", sans-serif; }
.login-form { display: grid; gap: 18px; }
label { display: grid; gap: 7px; color: var(--muted); font-size: 13px; font-weight: 600; }
input, select { width: 100%; min-height: 44px; border: 1px solid var(--line); border-radius: 6px; background: #fff; color: var(--text); padding: 10px 12px; }
input:hover, select:hover { border-color: #bec8c3; }
.form-error { min-height: 18px; margin: -4px 0 0; color: var(--red); font-size: 12px; }

.primary-button, .danger-button, .quiet-button, .icon-button, .text-button, .nav-button { border: 0; cursor: pointer; }
.primary-button { min-height: 46px; color: #fff; background: var(--green); border-radius: 6px; font-weight: 700; }
.primary-button:hover { background: #126d4e; }
.danger-button { min-height: 40px; padding: 0 16px; color: #fff; background: var(--red); border-radius: 6px; font-weight: 700; }
.quiet-button { min-height: 38px; padding: 0 13px; color: var(--text); background: var(--surface-soft); border: 1px solid var(--line); border-radius: 6px; }
.quiet-button:hover { border-color: #bbc6c0; }
.icon-button { display: inline-grid; place-items: center; width: 40px; height: 40px; flex: 0 0 40px; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 6px; font-size: 22px; }
.text-button { min-height: 34px; padding: 0; color: var(--blue); background: transparent; font-weight: 700; }
.text-button.danger-text { color: var(--red); }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 220px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 24px 18px 18px; background: var(--sidebar); color: #fff; }
.sidebar nav { display: grid; gap: 5px; margin-top: 36px; }
.nav-button { width: 100%; min-height: 44px; display: flex; align-items: center; justify-content: space-between; padding: 0 12px; border-radius: 6px; color: #bfc8c4; background: transparent; text-align: left; }
.nav-button small { min-width: 24px; text-align: right; font: 700 12px/1 ui-monospace, Consolas, monospace; }
.nav-button:hover, .nav-button[aria-current="page"] { color: #fff; background: #303936; }
.nav-button[aria-current="page"] { box-shadow: inset 3px 0 var(--green); }
.sidebar-foot { margin-top: auto; padding-top: 18px; border-top: 1px solid #38413e; display: flex; align-items: center; justify-content: space-between; gap: 10px; color: #cbd2cf; font-size: 13px; }
.inverse-button { min-height: 32px; color: #dce2df; background: transparent; border-color: #46504c; }

.workspace { min-width: 0; }
.topbar { min-height: 104px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 22px clamp(20px, 4vw, 52px); background: rgba(242, 244, 243, .94); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; backdrop-filter: blur(10px); }
.topbar h1 { margin: 0; font: 700 25px/1.2 Bahnschrift, "Microsoft YaHei UI", sans-serif; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.sync-label { color: var(--muted); font: 600 12px/1.2 ui-monospace, Consolas, monospace; white-space: nowrap; }
.page-content { padding: 28px clamp(20px, 4vw, 52px) 56px; }

.metric-band { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: 8px; background: var(--surface); overflow: hidden; }
.metric { min-width: 0; padding: 18px 20px; border-right: 1px solid var(--line); }
.metric:last-child { border-right: 0; }
.metric span { display: block; color: var(--muted); font-size: 12px; }
.metric strong { display: block; margin-top: 7px; font: 700 27px/1 Bahnschrift, ui-monospace, sans-serif; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.section-head { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin: 34px 0 14px; }
.section-head h2 { margin: 0; font-size: 17px; }
.section-head p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.site-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.site-card { min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 16px 20px; padding: 20px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
.site-card:hover { border-color: #c0cac5; box-shadow: 0 8px 20px rgba(21, 31, 26, .05); }
.site-name { min-width: 0; }
.site-name h3 { margin: 0; font-size: 16px; overflow-wrap: anywhere; }
.site-name p { margin: 6px 0 0; color: var(--muted); font: 12px/1.4 ui-monospace, Consolas, monospace; overflow-wrap: anywhere; }
.status-chip { align-self: start; display: inline-flex; align-items: center; gap: 7px; min-height: 26px; padding: 0 9px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.status-chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status-healthy { color: var(--green); background: var(--green-soft); }
.status-unhealthy { color: var(--red); background: var(--red-soft); }
.status-pending, .status-unknown { color: var(--amber); background: var(--amber-soft); }
.site-metrics { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(2, 1fr); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.site-metrics div { padding: 13px 0; }
.site-metrics div + div { padding-left: 18px; border-left: 1px solid var(--line); }
.site-metrics span { color: var(--muted); font-size: 11px; }
.site-metrics strong { display: block; margin-top: 4px; font: 700 20px/1 Bahnschrift, ui-monospace, sans-serif; }
.site-actions { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 34px; }
.site-actions a { color: var(--blue); text-decoration: none; font-size: 13px; font-weight: 700; }
.pending-card { background: transparent; border-style: dashed; }
.pending-card .site-metrics { display: none; }

.pulse-board { border: 1px solid var(--line); border-radius: 8px; background: var(--surface); overflow: hidden; }
.pulse-row { min-height: 56px; display: grid; grid-template-columns: minmax(145px, 220px) minmax(180px, 1fr) 56px; align-items: center; gap: 16px; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.pulse-row:last-child { border-bottom: 0; }
.pulse-label { min-width: 0; font-size: 13px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pulse-bars { height: 30px; display: grid; grid-template-columns: repeat(14, minmax(3px, 1fr)); align-items: end; gap: 4px; }
.pulse-bars i { display: block; min-height: 2px; background: var(--green); border-radius: 2px 2px 0 0; opacity: .76; }
.pulse-bars .bar-h-0 { height: 2px; }
.pulse-bars .bar-h-1 { height: 5px; }
.pulse-bars .bar-h-2 { height: 7px; }
.pulse-bars .bar-h-3 { height: 10px; }
.pulse-bars .bar-h-4 { height: 12px; }
.pulse-bars .bar-h-5 { height: 15px; }
.pulse-bars .bar-h-6 { height: 18px; }
.pulse-bars .bar-h-7 { height: 20px; }
.pulse-bars .bar-h-8 { height: 23px; }
.pulse-bars .bar-h-9 { height: 25px; }
.pulse-bars .bar-h-10 { height: 28px; }
.pulse-total { text-align: right; color: var(--muted); font: 700 12px/1 ui-monospace, Consolas, monospace; }

.back-button { display: inline-flex; align-items: center; gap: 7px; margin-bottom: 18px; color: var(--blue); background: transparent; border: 0; padding: 0; cursor: pointer; font-weight: 700; }
.detail-head { display: flex; align-items: start; justify-content: space-between; gap: 20px; margin-bottom: 20px; }
.detail-head h2 { margin: 0; font-size: 22px; }
.detail-head p { margin: 7px 0 0; color: var(--muted); font: 12px ui-monospace, Consolas, monospace; }
.detail-actions { display: flex; gap: 8px; }
.detail-actions a { display: inline-flex; align-items: center; min-height: 38px; padding: 0 12px; border: 1px solid var(--line); border-radius: 6px; color: var(--blue); background: var(--surface); text-decoration: none; font-size: 13px; font-weight: 700; }
.period-tabs { display: inline-flex; padding: 3px; margin: 22px 0 14px; background: #e5e9e7; border-radius: 7px; }
.period-tabs button { min-width: 82px; min-height: 34px; border: 0; border-radius: 5px; color: var(--muted); background: transparent; cursor: pointer; }
.period-tabs button[aria-selected="true"] { color: var(--text); background: var(--surface); box-shadow: 0 1px 4px rgba(21, 31, 26, .1); font-weight: 700; }
.detail-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(260px, .7fr); gap: 14px; }
.panel { min-width: 0; padding: 18px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
.panel h3 { margin: 0 0 16px; font-size: 15px; }
.trend-chart { height: 190px; display: grid; grid-template-columns: repeat(14, minmax(12px, 1fr)); align-items: end; gap: 7px; border-bottom: 1px solid var(--line); }
.trend-column { height: 100%; display: flex; flex-direction: column; justify-content: end; align-items: center; gap: 6px; min-width: 0; }
.trend-column i { width: 70%; min-height: 2px; background: var(--blue); border-radius: 3px 3px 0 0; }
.trend-column .bar-h-0 { height: 2px; }
.trend-column .bar-h-1 { height: 16px; }
.trend-column .bar-h-2 { height: 31px; }
.trend-column .bar-h-3 { height: 47px; }
.trend-column .bar-h-4 { height: 62px; }
.trend-column .bar-h-5 { height: 78px; }
.trend-column .bar-h-6 { height: 94px; }
.trend-column .bar-h-7 { height: 109px; }
.trend-column .bar-h-8 { height: 125px; }
.trend-column .bar-h-9 { height: 140px; }
.trend-column .bar-h-10 { height: 156px; }
.trend-column span { color: var(--muted); font: 10px/1 ui-monospace, Consolas, monospace; }
.status-list { display: grid; gap: 13px; }
.status-line { display: grid; grid-template-columns: 44px 1fr auto; gap: 10px; align-items: center; font-size: 12px; }
.status-line code { font-weight: 700; }
.status-track { height: 7px; background: #edf0ee; overflow: hidden; border-radius: 5px; }
.status-track i { display: block; height: 100%; background: var(--amber); }
.status-track .bar-w-1 { width: 10%; }
.status-track .bar-w-2 { width: 20%; }
.status-track .bar-w-3 { width: 30%; }
.status-track .bar-w-4 { width: 40%; }
.status-track .bar-w-5 { width: 50%; }
.status-track .bar-w-6 { width: 60%; }
.status-track .bar-w-7 { width: 70%; }
.status-track .bar-w-8 { width: 80%; }
.status-track .bar-w-9 { width: 90%; }
.status-track .bar-w-10 { width: 100%; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { padding: 13px 14px; border-bottom: 1px solid var(--line); text-align: left; font-size: 12px; vertical-align: middle; }
th { color: var(--muted); background: var(--surface-soft); font-weight: 700; }
tr:last-child td { border-bottom: 0; }
td code { font: 600 12px ui-monospace, Consolas, monospace; }
.frequency-flag { display: inline-block; margin-left: 8px; padding: 3px 6px; color: var(--amber); background: var(--amber-soft); border-radius: 4px; font-size: 10px; font-weight: 700; }
.empty-state { padding: 44px 20px; color: var(--muted); text-align: center; border: 1px dashed var(--line); border-radius: 8px; }

.ban-toolbar { display: grid; grid-template-columns: minmax(180px, 1fr) 190px 150px auto; gap: 10px; padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
.ban-toolbar label { gap: 5px; }
.ban-toolbar button { align-self: end; min-height: 44px; }
.scope-check { align-self: end; min-height: 44px; display: flex; grid-auto-flow: column; align-items: center; justify-content: center; gap: 8px; padding: 0 12px; border: 1px solid var(--line); border-radius: 6px; color: var(--text); background: var(--surface-soft); }
.scope-check input { width: 16px; min-height: 16px; margin: 0; }

.dialog { width: min(480px, calc(100% - 28px)); padding: 0; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 24px 70px rgba(13, 22, 17, .25); }
.dialog::backdrop { background: rgba(17, 25, 21, .5); backdrop-filter: blur(2px); }
.dialog form { display: grid; gap: 16px; padding: 22px; }
.dialog-head { display: flex; align-items: start; justify-content: space-between; gap: 16px; }
.dialog-head h2 { margin: 0; font-size: 21px; }
fieldset { margin: 0; padding: 0; border: 0; }
legend { margin-bottom: 7px; color: var(--muted); font-size: 13px; font-weight: 600; }
.segmented { display: grid; grid-template-columns: 1fr 1fr; padding: 3px; background: #e7ebe9; border-radius: 7px; }
.segmented label { display: block; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span { display: grid; place-items: center; min-height: 36px; border-radius: 5px; color: var(--muted); cursor: pointer; }
.segmented input:checked + span { color: var(--text); background: #fff; box-shadow: 0 1px 4px rgba(21, 31, 26, .11); font-weight: 700; }
.dialog-actions { display: flex; justify-content: end; gap: 8px; margin-top: 4px; }
.toast { position: fixed; right: 20px; bottom: 20px; z-index: 30; max-width: min(360px, calc(100vw - 40px)); padding: 12px 15px; color: #fff; background: var(--sidebar); border-radius: 6px; box-shadow: var(--shadow); font-size: 13px; }
.loading { min-height: 220px; display: grid; place-items: center; color: var(--muted); }

@media (max-width: 980px) {
  .metric-band { grid-template-columns: repeat(2, 1fr); }
  .metric:nth-child(2) { border-right: 0; }
  .metric:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .site-grid, .detail-grid { grid-template-columns: 1fr; }
  .ban-toolbar { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 720px) {
  .login-view { background: var(--bg); }
  .login-view::before { display: none; }
  .login-panel { min-height: 520px; grid-template-columns: 1fr; gap: 28px; padding: 76px 26px 30px; }
  .login-copy h1 { font-size: 39px; }
  .app-shell { display: block; }
  .sidebar { position: static; width: 100%; height: auto; display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 14px; padding: 14px 16px; }
  .sidebar nav { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; margin: 0; }
  .sidebar-foot { position: absolute; top: 14px; right: 16px; border: 0; margin: 0; padding: 0; }
  .sidebar-foot > span { display: none; }
  .topbar { min-height: 84px; padding: 16px; }
  .topbar h1 { font-size: 21px; }
  .sync-label { display: none; }
  .page-content { padding: 20px 16px 42px; }
  .site-grid { grid-template-columns: 1fr; }
  .pulse-row { grid-template-columns: minmax(110px, 1fr) 1.5fr; gap: 10px; padding: 10px 12px; }
  .pulse-total { display: none; }
  .detail-head { display: grid; }
  .detail-actions { flex-wrap: wrap; }
  .ban-toolbar { grid-template-columns: 1fr; }
  .scope-check { justify-content: start; }
}

@media (max-width: 440px) {
  .metric-band { grid-template-columns: 1fr 1fr; }
  .metric { padding: 15px 14px; }
  .metric strong { font-size: 23px; }
  .site-card { padding: 17px; }
  .period-tabs { width: 100%; }
  .period-tabs button { flex: 1; min-width: 0; }
  .trend-chart { gap: 4px; }
  .trend-column span { display: none; font-size: 8px; }
  .trend-column:nth-child(3n+1) span, .trend-column:last-child span { display: block; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
