:root {
  color-scheme: light;
  --ink: #182d26;
  --muted: #52665d;
  --line: #dce6df;
  --surface: #fff;
  --background: #f1f5f0;
  --forest: #112d26;
  --accent: #216348;
  --soft: #e5f2e9;
  --danger: #9b352e;
  font: 16px/1.55 system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--background); color: var(--ink); }
button, input, select { font: inherit; }
button, select { cursor: pointer; }
button:disabled { opacity: .55; cursor: default; }
button, .ghost { font-weight: 650; border-radius: 9px; padding: .55rem .9rem; white-space: nowrap; }
button { border: 1px solid transparent; }
input, select { min-width: 0; padding: .62rem .75rem; color: var(--ink); border: 1px solid #acbeb2; border-radius: 9px; background: #fff; }
select { appearance: none; padding-right: 2.15rem; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='9' viewBox='0 0 12 9'%3E%3Cpath d='m2 2 4 4 4-4' fill='none' stroke='%23216348' stroke-width='1.5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right .72rem center; }
a { color: var(--accent); text-underline-offset: .2em; }
:focus-visible { outline: 3px solid #399473; outline-offset: 3px; }
h1, h2, h3, p, dl { margin: 0; }
h1 { font-size: clamp(1.7rem, 4vw, 2.3rem); line-height: 1.2; letter-spacing: -.035em; }
h2 { font-size: 1.2rem; line-height: 1.35; }
h3 { font-size: 1rem; }
p { color: var(--muted); }
.wrap { width: min(1200px, 100% - 2rem); margin-inline: auto; }
.masthead { background: var(--forest); color: #fff; }
.masthead-inner { min-height: 76px; display: flex; justify-content: space-between; align-items: center; gap: .75rem; }
.brand { display: flex; align-items: center; gap: .7rem; font-weight: 750; line-height: 1.22; }
.brand-mark { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 13px; background: #bde6cc; color: var(--forest); font-size: 1.18rem; }
.brand small { display: block; margin-top: .18rem; color: #bfdbcf; font-size: .875rem; font-weight: 500; }
.ghost { background: transparent; color: #fff; border: 1px solid #799589; text-decoration: none; font-size: .9rem; }
main { padding-block: clamp(1.25rem, 4vw, 2.55rem) 3rem; }
.heading, .section-heading { display: flex; align-items: center; justify-content: space-between; gap: .75rem; }
.heading p, .section-heading p { margin-top: .3rem; }
.dashboard-grid { margin-top: 1.2rem; display: grid; grid-template-columns: minmax(230px, 280px) minmax(0, 1fr); align-items: start; gap: 1rem; }
.stack, .sidebar { display: grid; gap: .9rem; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: clamp(1rem, 3vw, 1.5rem); min-width: 0; }
.narrow { width: min(100%, 530px); margin: clamp(.5rem, 8vh, 4rem) auto 0; padding: clamp(1.25rem, 5vw, 2.2rem); }
.narrow p, .narrow form { margin-top: .85rem; }
.narrow a { display: inline-block; margin-top: 1rem; }
.narrow form { gap: .45rem; }
.narrow button { margin-top: .3rem; }
.primary { background: var(--accent); color: white; }
.secondary { background: #f5f8f5; color: var(--accent); border-color: var(--line); }
.danger { color: #fff; background: var(--danger); }
.link-button { color: var(--muted); background: transparent; text-decoration: underline; text-underline-offset: .2em; }
.input:focus { border-color: var(--accent); }
.sidebar h2 + p { margin-top: .35rem; }
.pair-form { display: flex; gap: .4rem; margin-block: .75rem .35rem; }
.pair-form input { width: 100%; font-variant-numeric: tabular-nums; letter-spacing: .12em; }
.notice:empty { display: none; }
.notice { margin-top: .55rem; font-size: .92rem; }
.notice.error { color: var(--danger); }
.device-list { display: grid; gap: .45rem; margin-top: .7rem; }
.device-option { display: flex; text-align: left; align-items: center; justify-content: space-between; gap: .35rem; width: 100%; padding: .55rem .65rem; background: #f5f8f5; color: var(--ink); border-color: transparent; }
.device-option[aria-pressed="true"] { background: var(--soft); border-color: #82af9a; }
.device-option strong { display: block; overflow: hidden; text-overflow: ellipsis; }
.device-option small { display: block; color: var(--muted); font-weight: 500; }
.device-option > span:first-child { min-width: 0; }
.pill { border-radius: 100px; background: #eef1ee; color: #546159; font-size: .875rem; padding: .14rem .58rem; white-space: nowrap; }
.pill.online { color: #185036; background: #dbf0e2; }
.empty { display: grid; place-content: center; min-height: 235px; text-align: center; gap: .4rem; }
.metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .55rem; margin-block: .9rem; }
.metrics > div { border: 1px solid #e2ebe4; border-radius: 11px; padding: .6rem .75rem; background: #f7f9f7; overflow-wrap: anywhere; }
dt { font-size: .875rem; color: var(--muted); }
dd { margin: .2rem 0 0; font-weight: 730; font-variant-numeric: tabular-nums; }
.device-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.charts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.chart { margin-top: .45rem; padding: .55rem .7rem; background: #f7f9f7; border: 1px solid var(--line); border-radius: 10px; max-height: 20rem; overflow-y: auto; }
.chart-row { display: grid; grid-template-columns: 3rem minmax(15px, 1fr) 5.15rem; align-items: center; gap: .4rem; min-height: 1.85rem; color: var(--muted); font-size: .875rem; font-variant-numeric: tabular-nums; }
.chart-row output { text-align: right; }
.bar-track { display: block; background: #e5eee8; border-radius: 5px; height: .55rem; }
.bar { display: block; height: 100%; background: #489373; border-radius: inherit; }
#traffic-chart .bar { background: #527f9b; }
.table-heading { margin-top: 1.1rem; }
.table-heading p, .footnote { font-size: .875rem; }
.footnote { margin-top: .6rem; }
.table-scroll { overflow-x: auto; }
table { width: 100%; min-width: 410px; border-collapse: collapse; text-align: left; margin-top: .35rem; }
th, td { padding: .5rem .4rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .875rem; color: var(--muted); }
td:not(:first-child) { font-variant-numeric: tabular-nums; white-space: nowrap; }
td small { display: block; color: var(--muted); overflow-wrap: anywhere; }
.code { margin-top: 1rem; padding: .7rem 1rem; text-align: center; color: var(--forest); background: var(--soft); border-radius: 10px; font: 750 2.1rem/1.25 ui-monospace, monospace; letter-spacing: .2em; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
@media (max-width: 800px) { .dashboard-grid { grid-template-columns: 1fr; } .sidebar { grid-template-columns: 1fr 1fr; } }
@media (max-width: 570px) {
  .sidebar, .charts { grid-template-columns: 1fr; }
  .metrics { grid-template-columns: 1fr; }
  .metrics > div { display: flex; justify-content: space-between; gap: .65rem; }
  dd { margin: 0; text-align: right; }
  .pair-form { max-width: 26rem; }
}
