.top-links { display: flex; gap: 4px; margin-left: 8px; }
.top-links a { padding: 6px 10px; border-radius: 6px; color: var(--muted); text-decoration: none; font-size: 14px; }
.top-links a:hover { background: var(--panel); color: var(--ink); }
.top-links a[aria-current="page"] { color: var(--teal-dark); background: var(--teal-tint); font-weight: 500; }

.page-head { display: flex; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h1 { margin: 0; font-size: 22px; font-weight: 600; }
.page-head p { margin: 4px 0 0; color: var(--muted); max-width: 70ch; }
.page-head .spacer { flex: 1; }
.page-head .acts { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.channels { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.channel-card { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 16px; display: flex; flex-direction: column; gap: 6px; }
.channel-card a.name { font-weight: 600; color: var(--ink); text-decoration: none; font-size: 15px; }
.channel-card a.name:hover { color: var(--teal-dark); text-decoration: underline; }
.channel-card .meta { color: var(--muted); font-size: 12.5px; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip { font-size: 11.5px; padding: 1px 7px; border-radius: 9px; background: #fdf0e3; color: var(--muted); }
.chip.switch, .chip.slider { background: #fff4dc; color: #8a5a00; }
.chip.sensor { background: var(--teal-tint); color: var(--teal-dark); }

.keys { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; margin-bottom: 18px; }
.key-box { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.key-box .lbl { font-size: 12.5px; color: var(--muted); }
.key-box .val { font-family: var(--mono); font-size: 14px; margin: 3px 0 6px; word-break: break-all; }
.key-box .acts { display: flex; gap: 12px; }

.widgets { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.widget { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; min-width: 0; }
.widget h3 { margin: 0; font-size: 14px; font-weight: 600; }
.widget .sub { color: var(--muted); font-size: 12px; margin: 2px 0 8px; }
.widget .big { font-size: 30px; font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1.1; }
.widget .big small { font-size: 14px; color: var(--muted); font-weight: 400; margin-left: 3px; }
.widget .empty-note { color: var(--muted); font-size: 13px; padding: 26px 0; text-align: center; }
.line-chart { position: relative; margin-top: 8px; }
.line-chart svg { display: block; width: calc(100% - 34px); margin-left: 34px; height: 150px; overflow: visible; }
.line-chart .grid line { stroke: #fdf0e3; }
.line-chart .axis text { fill: var(--muted); font-size: 10.5px; font-family: var(--sans); }
.line-chart .series { fill: none; stroke: var(--teal); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.line-chart .cross { stroke: #c9ae94; stroke-width: 1; }
.line-chart .dot { fill: var(--teal); stroke: #fff; stroke-width: 2; }

.switch-btn {
  display: inline-flex; align-items: center; gap: 10px; border: 1px solid var(--line); background: #fff; border-radius: 30px;
  padding: 6px 16px 6px 6px; cursor: pointer; font-weight: 500; margin-top: 10px;
}
.switch-btn .knob { width: 44px; height: 24px; border-radius: 12px; background: #ead5bf; position: relative; transition: background .15s; }
.switch-btn .knob::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: left .15s; }
.switch-btn[aria-pressed="true"] .knob { background: var(--teal); }
.switch-btn[aria-pressed="true"] .knob::after { left: 23px; }
.slider-row { display: flex; align-items: center; gap: 12px; margin-top: 12px; }
.slider-row input { flex: 1; accent-color: var(--teal); }
.slider-row output { font-family: var(--mono); min-width: 3ch; text-align: right; }

.howto { margin-top: 22px; }
.howto pre { background: var(--code-bg); color: #e6e6e6; border-radius: 8px; padding: 12px 14px; overflow-x: auto; font-family: var(--mono); font-size: 12.5px; line-height: 1.55; margin: 8px 0 0; }
.field-table { width: 100%; border-collapse: collapse; margin-top: 8px; }
.field-table td, .field-table th { padding: 5px 6px 5px 0; text-align: left; font-size: 13px; vertical-align: middle; }
.field-table th { color: var(--muted); font-weight: 500; }
.field-table input, .field-table select { width: 100%; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.field-table td:first-child { width: 60px; color: var(--muted); }
.check-row { display: flex !important; align-items: center; gap: 8px; color: var(--ink) !important; font-size: 13.5px !important; margin-top: 14px !important; }
.check-row input { width: 16px !important; height: 16px; accent-color: var(--teal); }

.chart-tip {
  position: fixed; z-index: 60; pointer-events: none; transform: translate(-50%, calc(-100% - 12px));
  background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 5px 9px; font-size: 12.5px;
  box-shadow: 0 6px 16px rgb(30 42 50 / .12); white-space: nowrap;
}
.live-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); margin-right: 6px; box-shadow: 0 0 0 3px rgb(30 158 90 / .18); }

@media (max-width: 640px) {
  .top-links { display: none; }
  .widgets { grid-template-columns: 1fr; }
}

.key-safety { margin-top: 18px; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 14px 18px; }
.key-safety h2 { font-size: 16px; margin: 0 0 6px; }
.key-safety ul { margin: 0; padding-left: 20px; color: #364153; font-size: 13.5px; line-height: 1.55; }
.key-safety li.warn { color: #8a5a00; font-weight: 500; }
