/* Monitor 1999 v2 —— 节点窗口、分段进度条、表格、属性对话框 */

/* ───────────────────────────────────────────────────────────── grid */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(272px, 1fr));
  gap: 10px;
}

.node {
  position: relative;
  background: var(--face);
  border: 1px solid var(--dark);
  box-shadow: var(--hard);
  transition: transform 80ms linear, box-shadow 80ms linear;
}
.node:hover { transform: translate(-1px, -1px); box-shadow: 4px 4px 0 rgba(24, 23, 19, 0.2); }
.node:active { transform: translate(0, 0); box-shadow: 2px 2px 0 rgba(24, 23, 19, 0.18); }

.node-title {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 22px;
  padding: 0 5px;
  background: linear-gradient(95deg, var(--title) 0%, var(--title) 55%, var(--title-2) 100%);
  color: var(--title-ink);
  cursor: default;
}
.node.is-off .node-title { background: linear-gradient(95deg, #6d6a64 0%, #9d9991 100%); color: #f2efe8; }
.node-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.node-title .flag { font: 500 9.5px var(--mono); opacity: 0.78; letter-spacing: 0.06em; }
.lamp { width: 9px; height: 9px; flex: none; border: 1px solid var(--dark); background: var(--ok); box-shadow: inset 1px 1px 0 rgba(255, 255, 255, 0.5); }
.lamp.tone-warn { background: #d9a521; }
.lamp.tone-bad { background: var(--bad); }
.lamp.tone-off { background: #7d7a73; }

.node-body { position: relative; padding: 8px 9px 9px; background: var(--paper); }
.node-meta {
  display: flex; align-items: center; gap: 6px;
  font-size: 10px; color: var(--ink-dim);
  white-space: nowrap; overflow: hidden;
}
.node-meta .group { color: var(--ink); background: var(--paper-2); border: 1px solid #ddd8cd; padding: 0 4px; font-size: 9.5px; }
.node-meta .os { overflow: hidden; text-overflow: ellipsis; }

.meters { display: grid; gap: 4px; margin: 7px 0 6px; }
.meter { display: grid; grid-template-columns: 46px 1fr 44px; align-items: center; gap: 6px; }
.meter-label { font-size: 8.5px; letter-spacing: 0.07em; white-space: nowrap; text-transform: uppercase; color: var(--ink-faint); }
.meter-value { font: 500 10.5px var(--mono); text-align: right; font-variant-numeric: tabular-nums; }
.track {
  height: 11px;
  padding: 1px;
  background: var(--paper-2);
  border: 1px solid var(--dark);
  box-shadow: inset 1px 1px 0 var(--lo), inset -1px -1px 0 var(--hi);
}
.fill {
  height: 100%;
  width: calc(var(--pct, 0) * 1%);
  min-width: 2px;
  color: var(--ok);
  background-image: repeating-linear-gradient(90deg, currentColor 0 4px, transparent 4px 6px);
  transition: width 220ms linear;
}
.meter[data-tone="warn"] .fill { color: #c08a10; }
.meter[data-tone="bad"] .fill { color: var(--bad); }
.node.is-off .fill { color: #a9a49a; }
.node.is-off .meters, .node.is-off .net-line { opacity: 0.55; }

.net-line {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding-top: 5px; margin-top: 2px;
  border-top: 1px dotted #d7d2c7;
  font: 400 10px var(--mono);
  color: var(--ink-dim);
  font-variant-numeric: tabular-nums;
}
.net-line b { font-weight: 500; color: var(--ink); }

.lat {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 6px; padding-top: 5px;
  border-top: 1px dotted #d7d2c7;
}
.lat.is-rows { grid-template-columns: 1fr; gap: 2px; }
.lat-cell { padding: 0 6px; border-right: 1px dotted #d7d2c7; min-width: 0; }
.lat-cell:first-child { padding-left: 0; }
.lat-cell:last-child { border-right: 0; padding-right: 0; }
.lat.is-rows .lat-cell { border-right: 0; padding: 0; display: flex; justify-content: space-between; }
.lat-name { display: block; font-size: 8.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lat-value { font: 500 10.5px var(--mono); color: var(--ok); font-variant-numeric: tabular-nums; }
.lat-value.tone-warn { color: #a87400; }
.lat-value.tone-bad { color: var(--bad); }
.lat-value.tone-none { color: #9c968a; }

.stamp {
  position: absolute;
  right: 8px; top: 36px;
  padding: 2px 6px;
  border: 2px solid var(--bad);
  color: var(--bad);
  background: rgba(252, 251, 247, 0.72);
  font: 700 9.5px var(--mono);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  transform: rotate(-8deg);
  pointer-events: none;
}

/* ───────────────────────────────────────────────────────────── table */

.table-scroll { max-height: calc(100vh - 330px); min-height: 260px; overflow: auto; }
table.nodes {
  width: 100%;
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 11px;
  background: var(--paper);
}
table.nodes th {
  position: sticky; top: 0; z-index: 2;
  height: 23px; padding: 0 8px;
  text-align: left; white-space: nowrap;
  background: var(--face);
  border-right: 1px solid var(--lo);
  border-bottom: 1px solid var(--dark);
  box-shadow: inset 1px 1px 0 var(--hi), inset -1px 0 0 var(--hi-2);
  font-size: 9.5px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--ink-dim);
  cursor: default;
  user-select: none;
}
table.nodes th:hover { background: var(--face-2); color: var(--ink); }
table.nodes th.spacer { border-right: 0; box-shadow: inset 1px 1px 0 var(--hi); }
table.nodes td.spacer { border-right: 0; }
table.nodes th.num { text-align: right; }
table.nodes th .arrow { font-family: var(--mono); font-size: 9px; margin-left: 3px; color: var(--title); }
table.nodes td {
  height: 25px; padding: 0 8px;
  border-bottom: 1px solid #eae7df;
  border-right: 1px solid #f1eee7;
  white-space: nowrap;
}
table.nodes td.uptime { font-family: var(--mono); font-size: 10.5px; color: var(--ink-dim); }
table.nodes td.num { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 10.5px; }
table.nodes tbody tr:hover { background: #edf2f8; }
table.nodes tbody tr.is-sel { background: var(--title); }
table.nodes tbody tr.is-sel td { color: #fff; border-bottom-color: rgba(255, 255, 255, 0.2); border-right-color: rgba(255, 255, 255, 0.14); }
table.nodes tbody tr.is-sel .pill, table.nodes tbody tr.is-sel .lat-value { color: inherit; }
table.nodes tbody tr.is-off td { color: var(--ink-faint); }
table.nodes tbody tr.is-off .name { text-decoration: line-through; text-decoration-color: #c9c3b7; }
.name-cell { display: flex; align-items: center; gap: 6px; }
.name { font-weight: 700; }
.pill {
  display: inline-block;
  padding: 0 4px;
  border: 1px solid currentColor;
  font: 500 8.5px var(--mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ok);
}
.pill.tone-warn { color: var(--warn); }
.pill.tone-bad { color: var(--bad); }
.pill.tone-off { color: var(--ink-faint); }

/* ───────────────────────────────────────────────────────────── dialog */

.layer {
  position: fixed; inset: 0;
  z-index: 100;
  display: grid; place-items: center;
  padding: 16px;
  background: rgba(8, 14, 14, 0.45);
}
.layer[hidden] { display: none; }

.dlg {
  display: flex; flex-direction: column;
  width: min(880px, 100%);
  max-height: calc(100vh - 32px);
  background: var(--face);
  border: 2px solid var(--dark);
  box-shadow: 12px 12px 0 rgba(0, 0, 0, 0.32);
}
.dlg.is-max { width: min(1180px, 100%); }
.dlg.is-min .dlg-body, .dlg.is-min .dlg-tabs, .dlg.is-min .dlg-foot { display: none; }

.dlg-title {
  display: flex; align-items: center; gap: 6px;
  height: 24px; padding: 0 3px 0 5px;
  background: linear-gradient(95deg, var(--title) 0%, var(--title) 55%, var(--title-2) 100%);
  color: var(--title-ink);
  font-size: 11.5px; font-weight: 700;
  letter-spacing: 0.03em;
}
.dlg-title .title-text { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dlg-btns { display: flex; gap: 2px; }
.dlg-btn {
  display: grid; place-items: center;
  width: 18px; height: 16px; padding: 0;
  background: var(--face);
  border: 1px solid var(--dark);
  box-shadow: var(--bevel-out);
  color: var(--ink);
  font: 700 10px/1 var(--ui);
  cursor: default;
}
.dlg-btn:active { box-shadow: var(--bevel-in); }

.dlg-tabs { display: flex; gap: 2px; padding: 7px 8px 0; background: var(--face); }
.dlg-tab {
  height: 23px; padding: 0 12px;
  background: var(--face-2);
  border: 1px solid var(--dark); border-bottom: 0;
  border-radius: 3px 3px 0 0;
  font-size: 11px;
  color: var(--ink-dim);
  cursor: default;
}
.dlg-tab:hover { background: var(--face-3); color: var(--ink); }
.dlg-tab.is-on { height: 25px; margin-bottom: -1px; padding-bottom: 2px; background: var(--paper); color: var(--ink); font-weight: 700; }

.dlg-body {
  flex: 1;
  min-height: 0;
  padding: 14px 16px;
  overflow: auto;
  background: var(--paper);
  border-top: 1px solid var(--dark);
}
.dlg-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 8px; background: var(--face); border-top: 1px solid var(--lo); }
.btn {
  height: 23px; min-width: 78px; padding: 0 12px;
  background: var(--face);
  border: 1px solid var(--dark);
  box-shadow: var(--bevel-out);
  font-size: 11.5px;
  cursor: default;
}
.btn:active { box-shadow: var(--bevel-in); }
.btn.primary { font-weight: 700; }

.section-title {
  display: flex; align-items: center; gap: 8px;
  margin: 14px 0 7px;
  font-size: 9.5px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--ink-faint);
}
.section-title::after { content: ""; flex: 1; height: 1px; background: #ddd8cd; }
.section-title:first-child { margin-top: 0; }

.kv { display: grid; grid-template-columns: 132px minmax(0, 1fr); gap: 2px 14px; font-size: 11.5px; }
.kv dt { color: var(--ink-faint); font-size: 10px; letter-spacing: 0.06em; text-transform: uppercase; padding-top: 1px; }
.kv dd { margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kv dd.mono { font-family: var(--mono); font-size: 10.5px; }
.cols-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 26px; }

.chart-box {
  padding: 6px 6px 4px;
  background: #fff;
  border: 1px solid var(--dark);
  box-shadow: inset 1px 1px 0 var(--lo), inset -1px -1px 0 var(--hi);
}
.chart-box canvas { display: block; width: 100%; height: 132px; }
.chart-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 4px; }
.chart-head .k { font-size: 9.5px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-faint); }
.chart-head .v { font: 500 13px var(--mono); }

.ranges { display: flex; gap: 2px; }
.range {
  height: 19px; padding: 0 7px;
  background: var(--face); border: 1px solid var(--dark); box-shadow: var(--bevel-out);
  font: 500 9.5px var(--mono); cursor: default;
}
.range.is-on { box-shadow: var(--bevel-in); background: var(--face-3); font-weight: 700; }

.chart-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.stamp-big {
  display: inline-block;
  padding: 3px 8px;
  border: 2px solid var(--bad);
  color: var(--bad);
  font: 700 11px var(--mono);
  letter-spacing: 0.14em;
  transform: rotate(-3deg);
}
.stamp-big.is-ok { border-color: var(--ok); color: var(--ok); }

@media (max-width: 760px) {
  .grid { grid-template-columns: 1fr; gap: 8px; }
  .cols-2 { grid-template-columns: 1fr; }
  .chart-grid { grid-template-columns: 1fr; }
  .dlg { max-height: calc(100vh - 20px); }
  .dlg-tab { padding: 0 8px; font-size: 10.5px; }
  .table-scroll { max-height: calc(100vh - 380px); }
}

/* ───────────────────────────────────────────────────────────── odds & ends */

.th-btn {
  display: flex; align-items: center; gap: 3px;
  width: 100%; height: 100%; padding: 0;
  border: 0; background: transparent;
  color: inherit; font: inherit; letter-spacing: inherit; text-transform: inherit;
  cursor: default; text-align: left;
}
table.nodes th.num .th-btn { justify-content: flex-end; }
.th-btn:hover { color: var(--ink); }

.node.is-sel { outline: 2px solid var(--title); outline-offset: 1px; }

.stat-row { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 10px; }
.big-stat {
  display: flex; flex-direction: column; gap: 2px;
  padding: 9px 10px;
  background: var(--face);
  border: 1px solid var(--dark);
  box-shadow: var(--bevel-out);
}
.big-stat .k { font-size: 9px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-faint); }
.big-stat .v { font: 500 17px var(--mono); letter-spacing: -0.01em; }
.big-stat .s { font-size: 9.5px; color: var(--ink-dim); }

.expires-row { display: flex; align-items: center; gap: 12px; margin: 4px 0 2px; }
.muted { font-size: 10.5px; color: var(--ink-dim); }

.hint-line { margin-top: 10px; font-size: 10px; color: var(--ink-faint); line-height: 1.5; }

.notes { display: flex; flex-wrap: wrap; gap: 6px; }
.note {
  padding: 5px 8px;
  background: var(--paper-2);
  border: 1px solid #ddd8cd;
  border-left: 3px solid var(--title);
  font-size: 11px;
}

.about p { margin: 0 0 8px; font-size: 11.5px; line-height: 1.6; color: var(--ink-dim); }
.about .about-title { font: 700 13px var(--ui); letter-spacing: 0.04em; color: var(--ink); }

@media (max-width: 760px) {
  .stat-row { grid-template-columns: 1fr; gap: 6px; }
  .big-stat { flex-direction: row; align-items: baseline; gap: 8px; }
  .big-stat .v { font-size: 15px; }
}

/* ───────────────────────────────────────────────────────────── 延迟选项卡 */

.lat-legend { display: flex; flex-wrap: wrap; gap: 4px 10px; justify-content: flex-end; }
.lat-legend-item {
  display: inline-flex; align-items: center; gap: 4px;
  font: 400 9.5px var(--mono);
  color: var(--ink-dim);
  white-space: nowrap;
}
.swatch {
  display: inline-block;
  width: 9px; height: 9px;
  border: 1px solid var(--dark);
  vertical-align: -1px;
}
.lat-table {
  margin-top: 10px;
  background: #fff;
  border: 1px solid var(--dark);
  box-shadow: inset 1px 1px 0 var(--lo), inset -1px -1px 0 var(--hi);
  overflow: hidden;
}
.lat-table table { width: 100%; border-collapse: collapse; }
.lat-table th {
  height: 22px; padding: 0 9px;
  background: var(--face);
  border-bottom: 1px solid var(--dark);
  font-size: 9px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--ink-dim);
  text-align: left;
}
.lat-table th.num { text-align: right; }
.lat-table td {
  height: 24px; padding: 0 9px;
  border-top: 1px solid #eeeae1;
  font: 400 10.5px var(--mono);
  color: var(--ink);
}
.lat-table tr:first-child td { border-top: 0; }
.lat-table td:first-child { font: 700 11px var(--ui); }
.lat-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.lat-table td.is-bad { color: var(--bad); font-weight: 500; }
.lat-table .lat-empty { text-align: center; color: var(--ink-faint); font: 400 10px var(--mono); height: 40px; }

@media (max-width: 760px) {
  .lat-legend { justify-content: flex-start; }
}

/* 表格首列：节点名可能很长（商店预览里就有），必须在列内截断，不能压到 GROUP 上 */
table.nodes td:first-child { overflow: hidden; }
table.nodes .name-cell { min-width: 0; }
table.nodes .name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
table.nodes .name-cell .flag { flex: none; }

/* 一个分组都没有时整行收起（[hidden] 要压过 .groups 的 display:flex） */
.groups[hidden] { display: none; }
