@font-face {
  font-family: 'DSEG7';
  src: url('/static/fonts/DSEG7Classic-Bold.woff') format('woff');
  font-weight: 700;
  font-style: normal;
  font-display: swap;}
:root {
  --color-count-up: #25A6B2;
  --color-count-down: #DD3333; 
  --bg: #f4f5f4;
  --surface: #22283a;
  --surface-accent: #164e17;
  --border: #263654;
  --border-rtt: #9a9797;
  --border-strong: #34455f;
  --text: #e7ecf5;
  --text-dim: #93a3c2;
  --text-faint: #5f7192;
  --green: #34d399;
  --green-dark: #101a2e;
  --green-text: #34d399;
  --orange: #f5a25d;
  --orange-dark: #e08a3c;
  --red: #f87171;
  --red-bg: #3b1e22;
  --amber: #fbbf24;
  --amber-bg: #3a2f14;
  --radius: 10px;
  --radius-rtt: 10px; 
  --radius-sm: 7px;
  --radius-pill: 10px;
  --font-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-clock: 'DSEG7', var(--font-mono);
  --font-mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
}

a { color: var(--green); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- banner ---------- */
.banner-wrap { position: relative; }
.banner {
  background: var(--bg);
  color: #fff;
  text-align: left;
  padding: 15px 150px 5px;
}
.banner-title { font-size: 21px; font-weight: 700; margin: 0; letter-spacing: -0.01em; }
.banner-sub { font-size: 13px; color: rgba(255,255,255,0.82); margin: 0; }
.banner-stats {
        position: absolute;
	left: 50%;
	transform: translate(-50%);	
	font-size: 12px; 
	color: rgba(255,255,255,0.65); 
	margin: 0; }
.banner-account { position: absolute; top: 18px; right: 24px; font-size: 12.5px; display: flex; align-items: center; gap: 14px; }
.banner-account a { color: rgba(255,255,255,0.85); }

/* ---------- page ---------- */
.page { max-width: 100%; margin: 0 auto; padding: 28px 20px 0px; }

/* ---------- dashboard grid ----------
   Left column (Down Status) 65% | right column (Live Ping + Log stacked) 35%.
   The right column never gets narrower than 480px (the tables and the card
   headers need that much), so below ~1430px wide the split drifts slightly
   from 65:35; under 1100px the columns stack. */
.dashboard-grid-fping {
  display: grid;
  grid-template-columns: minmax(0, 65fr) minmax(480px, 35fr);
  gap: 20px;
  align-items: start;
}
.stack-col {
  display: flex;
  flex-direction: column;
  gap: 20px;
}
@media (max-width: 1100px) {
  .dashboard-grid-fping { grid-template-columns: 1fr; }
}
/* Right column is 480-650px wide up to ~1850px screens: title, buttons and count
   stay on the first row, the filter drops to its own full-width second row. */
@media (min-width: 1101px) and (max-width: 1850px) {
  .stack-col-right .card-head-filter { flex-wrap: wrap; row-gap: 8px; }
  .stack-col-right .card-head-filter .filter-inline-wrap { order: 10; flex: 1 1 100%; }
}

/* Currently Down: fills the full viewport height on its own (left column,
   single card). Live Ping + Recent Log share the right column at a fixed
   65:35 height ratio via flex-grow — not fixed pixel heights, so it stays
   correct if the banner height ever changes. */
.stack-col-left, .stack-col-right {
  height: calc(100vh - 120px);
}
.stack-col-left .card,
.stack-col-right .card {
  display: flex;
  flex-direction: column;
  min-height: 0; /* required for flex children to actually shrink/scroll instead of overflowing */
}
#down-status-card { flex: 1; }
#live-ping-card { flex: 65; }
#recent-log-card { flex: 35; }

.scroll-body {
  max-height: 520px;
  overflow-y: auto;
}
.scroll-body-down {
  flex: 1;
  overflow-y: auto;
}
.scroll-body-live {
  flex: 1;
  overflow-y: auto;
}
#recent-log-card .scroll-body {
  flex: 1;
  max-height: none;
}

/* ---------- marquee device names (only animates when text overflows) ---------- */
.device-cell { overflow: hidden; white-space: nowrap; user-select: none; cursor: pointer;}
/*.device-cell:hover {background: #164e17;};*/
.device-text { display: block; flex: 1; min-width: 0; overflow: hidden; position: relative; }
.device-name-inner { display: inline-block; white-space: nowrap; }
/* A name that doesn't fit shows an ellipsis; it only scrolls while hovered. */
.device-cell.is-marquee .device-name-inner { display: block; overflow: hidden; text-overflow: ellipsis; }
.device-cell.is-marquee:hover .device-name-inner { display: inline-block; overflow: visible; text-overflow: clip; animation: device-marquee 7s linear infinite; }
@keyframes device-marquee {
  0%, 10% { transform: translateX(0); }
  45%, 55% { transform: translateX(var(--marquee-dist, 0px)); }
  90%, 100% { transform: translateX(0); }
}
@media (prefers-reduced-motion: reduce) {
  .device-cell.is-marquee:hover .device-name-inner { display: block; overflow: hidden; text-overflow: ellipsis; animation: none; }
}

/* ---------- banner icon button ---------- */
.banner-clock {
  position: absolute; top: 5px; left: 50%;
  transform: translate( -50%);
  font-family: inherit; font-size: 40px; font-weight: 700; color: #1A9CDB;
}
.banner-icon-btn {
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.25);
  color: #fff;
  border-radius: var(--radius-sm);
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font-sans);
}
.banner-icon-btn:hover { background: rgba(255,255,255,0.2); }

/* ---------- settings modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(15, 20, 17, 0.85);
  display: flex; align-items: center; justify-content: center;
  padding: 24px; z-index: 100;
}
.modal-overlay.hidden { display: none; }
.modal-panel {
  background: var(--bg);
  border: 3px solid var(--border-rtt); border-radius: var(--radius-rtt);
  width: 100%; max-width: 760px;
  max-height: 88vh;
  display: flex; flex-direction: column;
  overflow: hidden;
  box-shadow: 0 12px 32px rgba(0,0,0,0.45);
}
/* Same look as the RTT cards / sound notice: green title bar. */
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 10px 8px 20px; background: var(--green-dark); color: #fff;
  flex-shrink: 0;
}
.modal-head h2 { margin: 0; font-size: 12.5px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.modal-close {
  background: rgba(255, 0, 0, 0.5); border: none; color: #fff; width: 30px; height: 20px;
  border-radius: 4px; font-size: 13px; line-height: 1; cursor: pointer; padding: 0;
}
.modal-close:hover { background: rgba(255, 0, 0, 0.7); }
.modal-body { padding: 20px; overflow-y: auto; }
.modal-body .card:last-child { margin-bottom: 0; }

/* ---------- cards ---------- */
.card { background: #22283a96; border: 0px solid var(--border); border-radius: var(--radius); margin-bottom: 0px; overflow: hidden; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; padding: 16px 20px 16px; }
.card-head h2 { font-size: 15px; font-weight: 700; margin: 0; }
.card-head .count { font-size: 15px; font-weight: 700; }

.card-head-filter { align-items: center; gap: 14px; }
.card-head-filter h2 { flex-shrink: 0; white-space: nowrap; }
.card-head-filter .count { flex-shrink: 0; white-space: nowrap; }
.filter-inline-wrap { flex: 1; position: relative; min-width: 0;}
.filter-inline-wrap input[type=text] {
  width: 100%; box-sizing: border-box; font-family: var(--font-sans); padding-right: 28px;
}
.filter-clear-btn {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  background: none; border: none; color: var(--text-faint); font-size: 16px;
  line-height: 1; cursor: pointer; padding: 2px 6px; display: none;
}
.filter-clear-btn:hover { color: var(--text); }
.filter-clear-btn.visible { display: block; }
.card-desc { padding: 0 20px 14px; margin: 0; font-size: 12.5px; color: var(--text-dim); }
.card-body { padding: 0px 20px 18px; }
/* Table areas of the three main cards: rounded, bordered box like the Trend raw
   log, so the sticky header follows the rounded corners. */
#down-table-container, #ping-stats-table-container, #history-table-container {
  padding: 0; margin: 0 20px 18px;
  border: 1px solid var(--border); border-radius: var(--radius);
}

.inline-date {
  border: none;
  background: none;
  font-family: var(--font-sans);
  font-size: 15px;
  font-weight: 700;
  color: var(--green-text);
  padding: 1px 2px;
  cursor: pointer;
}
.inline-date:focus { outline: none; }

/* ---------- group row (collapsible section item) ---------- */
.group-row {
  background: var(--surface-accent); padding: 11px 18px; display: flex; align-items: center;
  justify-content: space-between; gap: 12px; border-top: 1px solid var(--border); cursor: pointer;
}
.group-row:first-child { border-top: none; }
.group-row .g-left { min-width: 0; }
.group-title { font-weight: 700; color: var(--green-text); text-decoration: underline; font-size: 13.5px; }
.group-meta { font-size: 11.5px; color: var(--text-dim); margin-top: 2px; }
.group-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.group-toggle { font-size: 12px; color: var(--green-text); background: none; border: none; cursor: pointer; font-family: var(--font-sans); font-weight: 600; }
.group-body { padding: 14px 18px 18px; border-top: 1px solid var(--border); }
.group-body.collapsed { display: none; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; gap: 6px; border: none; border-radius: var(--radius-sm); padding: 7px 14px; font-size: 12.5px; font-weight: 600; cursor: pointer; font-family: var(--font-sans); white-space: nowrap; }
.btn-orange { background: var(--orange); color: #fff; }
.btn-orange:hover { background: var(--orange-dark); }
.btn-green { background: var(--green); color: #fff; }
.btn-green:hover { background: var(--green-dark); }
.btn-ghost { background: var(--surface); color: var(--text-dim); border: 1px solid var(--border-strong); }
.btn-ghost:hover { color: var(--text); }
.btn-danger-text { background: none; color: var(--red); border: 1px solid #f0d3d1; padding: 5px 11px; }
.btn-danger-text:hover { background: var(--red-bg); }
.btn:disabled { opacity: 0.5; cursor: default; }
.sparkline-tooltip {
  position: absolute; background: rgba(15,20,17,0.85); color: #fff; padding: 3px 8px;
  border-radius: 4px; font-size: 11px; font-family: var(--font-mono); pointer-events: none; white-space: nowrap;
}

/* ---------- floating RTT cards ---------- */
#floating-cards-layer {
  position: fixed; inset: 0; pointer-events: none; z-index: 90;
}
#floating-cards-layer.dragging {
  background-image: radial-gradient(circle, var(--border-strong) 1px, transparent 1px);
  background-size: 20px 20px;
  cursor: grabbing;
}
#floating-cards-layer.dragging .rtt-card,
#floating-cards-layer.dragging .rtt-card-title,
#floating-cards-layer.dragging .rtt-card-body {
  cursor: grabbing;
}
.rtt-card {
  position: fixed;
  width: 320px;
  background: var(--surface);
  border: 3px solid var(--border-rtt);
  border-radius: var(--radius-rtt);
/*  box-shadow: 0 10px 30px rgba(0,0,0,0.18); */
  pointer-events: auto;
/*  overflow: hidden; */
  display: flex;
  flex-direction: column;
  user-select: none;
}
.rtt-card-title {
  display: flex; align-items: center; justify-content: flex-start;
  padding: 8px 10px 8px 20px; background: var(--green-dark); color: #fff;
  cursor: grab; user-select: none; flex-shrink: 0;
  border-radius: 10px 10px 0px 0px;
}
.rtt-card-title .rtt-card-name {
  font-size: 12.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; flex: 1; min-width: 0; margin-right: 8px;
  display: flex; gap: 6px;
}
.rtt-card-title .rtt-card-devname { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.rtt-card-title .rtt-card-ip { flex-shrink: 0; font-weight: 400; opacity: 0.85; }
.rtt-card-controls { display: flex; gap: 4px; flex-shrink: 0; }
.rtt-card-controls button {
  background: rgba(255, 0, 0, 0.5);; border: none; color: #fff; width: 30px; height: 20px;
  border-radius: 4px; cursor: pointer; font-size: 13px; line-height: 1; padding: 0;
}
.rtt-card-controls button:hover { background: rgba(255,255,255,0.3); }
.rtt-card-body { padding: 10px 12px 12px; cursor: grab; }
.rtt-card.minimized .rtt-card-body { display: none; }
.rtt-card-graph { min-height: 150px; }

.rtt-range-select { position: relative; }
.rtt-range-btn {
  background: rgba(255,255,255,0.15); border: none; color: #fff; padding: 2px 8px;
  border-radius: 4px; cursor: pointer; font-size: 10.5px; font-weight: 600; font-family: var(--font-mono);
}
.rtt-range-btn:hover { background: rgba(255,255,255,0.3); }
.rtt-range-menu {
  display: none; position: absolute; right: 0; background: var(--surface);
  border: 1px solid var(--border); border-radius: 6px; box-shadow: 0 8px 20px rgba(0,0,0,0.18);
  min-width: 60px; z-index: 10; overflow: hidden;
}
.rtt-range-opt {
  padding: 6px 10px; font-size: 11px; color: var(--text); cursor: pointer; font-family: var(--font-mono);
}
.rtt-range-opt:hover { background: var(--surface-accent); }

/* ---------- forms ---------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; font-weight: 600; color: var(--text-dim); margin-bottom: 5px; }
.field .hint { font-size: 11px; color: var(--text-faint); margin-top: 4px; }
input[type=text], input[type=password], textarea, select {
  width: 100%; background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  color: var(--text); padding: 8px 10px; font-family: var(--font-mono); font-size: 12.5px;
}
select { font-family: var(--font-sans); }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--green); }
textarea { resize: vertical; min-height: 110px; line-height: 1.6; }

.pw-wrap { position: relative; }
.pw-toggle { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); background: none; border: none; color: var(--text-faint); font-size: 11px; cursor: pointer; padding: 4px 6px; }
.pw-toggle:hover { color: var(--text); }

.btn-row { display: flex; gap: 8px; align-items: center; margin-top: 12px; flex-wrap: wrap; }
.status-msg { font-size: 12px; }
.status-msg.ok { color: var(--green); }
.status-msg.err { color: var(--red); }

/* ---------- pills / badges ---------- */
.pill { display: flex; width: 100%; align-items: center; gap: 5px; padding: 3px 10px; border-radius: var(--radius-pill); font-size: 11.5px; font-weight: 600; font-family: var(--font-mono); background: var(--surface-accent); color: var(--green-text); max-width: 100%; overflow: hidden; box-sizing: border-box; }
.pill-down { background: var(--red-bg); color: var(--red); }
.dot { width: 6px; margin-right: 8px; height: 6px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.dot-pulse { position: relative; margin-right: 8px;}
.dot-pulse::after { content: ''; position: absolute; inset: -4px; border-radius: 50%; border: 1px solid currentColor; animation: ping 1.6s cubic-bezier(0,0,0.2,1) infinite; }
@keyframes ping { 0% { transform: scale(0.6); opacity: 0.8; } 100% { transform: scale(2); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .dot-pulse::after { animation: none; } }

/* ---------- table ---------- */
table { width: 100%; border-collapse: collapse; table-layout: fixed; }
th { text-align: left; font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-faint); font-weight: 700; padding: 8px 8px; box-shadow: 0 1px 0 0 var(--border); position: sticky; top: 0; background: var(--surface); z-index: 1; }
td { padding: 2px 8px; border-bottom: 1px solid var(--border); font-size: 13px; vertical-align: middle; }
tr:last-child td { border-bottom: none; }
td.mono, .mono { font-family: var(--font-mono); font-size: 12px; color: var(--text-dim); }
.sort-th { cursor: pointer; user-select: none; white-space: nowrap; }
.sort-th:hover { color: var(--text-dim); }
.sort-th .sort-arrow { margin-left: 3px; opacity: 0.6; }
.row-handle { color: var(--text-faint); margin-right: 4px; }
.link-strong { font-weight: 700; color: var(--green-text); text-decoration: underline; }

.empty-state { text-align: center; padding: 26px 20px; color: var(--text-dim); font-size: 13px; }

/* ---------- login ---------- */
.login-shell { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg); }
.login-card { width: 320px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 26px 24px; }
.login-title { font-size: 16px; font-weight: 700; margin: 0 0 2px; color: var(--green-text); }
.login-sub { color: var(--text-dim); font-size: 12px; margin: 0 0 18px; }
.error-box { background: var(--red-bg); color: var(--red); border-radius: var(--radius-sm); padding: 8px 11px; font-size: 12px; margin-bottom: 12px; }
.text-center { text-align: center; }
.rtt-card-toolbar { display: flex; align-items: center; justify-content: center; gap: 6px; margin-bottom: 4px; }
.rtt-card-graph-wrap { position: relative; }
.rtt-card-toolbar {
  position: absolute; top: 0; right: 0; z-index: 5;
  display: flex; align-items: center; gap: 4px;
}
.rtt-card-toolbar button {
  background: rgba(52,211,153,0.12); border: none; color: var(--green-text); width: 20px; height: 20px;
  border-radius: 4px; cursor: pointer; font-size: 13px; line-height: 1; padding: 0;
}
.rtt-card-toolbar button:hover { background: rgba(52,211,153,0.22); }
.rtt-range-btn { width: auto !important; padding: 0 6px !important; font-size: 11px !important; }
.rtt-live-toggle {
  width: auto !important; padding: 0 7px !important; font-size: 10.5px !important;
  display: inline-flex !important; align-items: center; gap: 4px;
}
.rtt-live-dot {
  width: 6px; height: 6px; border-radius: 50%; background: var(--green);
  box-shadow: 0 0 4px var(--green); flex-shrink: 0;
}
.rtt-live-toggle.paused { color: var(--text-faint); }
.rtt-live-toggle.paused .rtt-live-dot { background: var(--text-faint); box-shadow: none; }
.count-up {color: var(--color-count-up);}
.count-down {color: var(--color-count-down);}

.host-cell { cursor: pointer; }
.host-cell:hover { color: var(--green-text); text-decoration: underline dotted; }
.host-cell.copied { color: var(--green-text); font-weight: 700; text-decoration: none; }
/* LIVE PING title pill = WebSocket watchdog indicator */
.ws-pill {
  display: inline-block; padding: 3px 14px; border-radius: 8px;
  background: #3a5a45; color: #fff;
  transition: background-color 0.15s ease;
}
.ws-pill.ws-flash { background: #16a34a; }
.ws-pill.ws-stale { animation: ws-stale-blink 1s step-start infinite; }
@keyframes ws-stale-blink {
  0%, 49% { background: #e0483e; }
  50%, 100% { background: #5a1f1c; }
}
/*#ws-watchdog-dot {
  position: absolute; top: 55px; left: 50%; transform: translate( -50%);width: 10px; height: 10px; border-radius: 50%;
  background: #3a5a45; vertical-align: middle;
  transition: background-color 0.15s ease;
}
#ws-watchdog-dot.ws-flash { background: #4ade80; }
#ws-watchdog-dot.ws-stale { animation: ws-stale-blink 1s step-start infinite; }
@keyframes ws-stale-blink {
  0%, 49% { background: #e0483e; }
  50%, 100% { background: #5a1f1c; }
}
*/
#live-ping-card #ping-stats-table-container {
  flex: 1;
  overflow-y: auto;
  max-height: none;
}

/* Table column widths for the narrow right column. Fixed px for the columns with
   short, predictable content; the Device column (no width) gets whatever is left.
   Applies to both the server-rendered tables and the ones the JS rebuilds. */
#ping-stats-table col:nth-child(1) { width: 56px; }   /* %PL */
#ping-stats-table col:nth-child(3) { width: 124px; }  /* IP */
#ping-stats-table col:nth-child(4) { width: 56px; }   /* Cur */
#history-table-container col:nth-child(1) { width: 92px; }   /* Time */
#history-table-container col:nth-child(3) { width: 124px; }  /* Host / IP */
#history-table-container col:nth-child(4) { width: 84px; }   /* Duration */

.link-pill { font-size: 11px; padding: 1px 6px; margin: 1px 3px 1px 0; }
.link-pill.pill-down { }

/* ---------- Currently Down: CSS Grid instead of <table> ----------
   A single <tr> can no longer be "1 device" now that a group entry
   bundles 2+ devices — nested tables would be needed to keep 1 unit =
   1 row while still holding several devices inside it. Grid avoids that:
   every .down-grid-head/.down-row independently uses the SAME percentage
   grid-template-columns, so columns stay visually aligned down the page
   even though each unit is a structurally separate container. This works
   without CSS Subgrid because the columns are percentage tracks (fractions
   of each row's own width), not auto/content-sized — auto would need
   subgrid to align; percentages don't. */
.down-grid-head, .down-row {
  display: grid;
  /* Device takes the rest; the others are sized for their content (IP up to 15
     chars, HH:MM:SS, durations) and never go below the px minimum. */
  grid-template-columns: minmax(0, 1fr) minmax(125px, 14%) minmax(96px, 11%) minmax(82px, 10%) minmax(88px, 11%);
}
.down-grid-head {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--text-faint); font-weight: 700;
  box-shadow: 0 1px 0 0 var(--border);
  position: sticky; top: 0; background: var(--surface); z-index: 1;
}
.down-grid-head > div { padding: 8px 8px; }
.down-row > div { padding: 2px 8px; font-size: 11px; display: flex; align-items: center; }
.down-row { border-bottom: 1px solid var(--border); }
.down-body > .down-unit:last-child .down-row:last-child { border-bottom: none; }

/* Grouped (link-paired) devices: adjacency is structural (children of one
   unit container) instead of forced via sort-key proximity, so grouping
   is just a border on the container — no first/middle/last row logic. */
.down-unit-group {
  position: relative;
  border: 1px solid var(--text-dim);
  margin: 12px 0 7px 0;
  padding-top: 10px;
  padding-bottom: 7px;
}
.down-unit-group .down-row { border-bottom: 1px dashed var(--border); }
.down-unit-group .down-row:last-child { border-bottom: none; }

/* Group ID label — sits directly on the top border and "cuts" it, like a
   <fieldset><legend>. Matches the notes field convention (ID: <group>).
   background must match the surface behind it (same approximation
   .down-grid-head already uses for its sticky header) so it visually
   breaks the border line instead of just sitting near it. */
.down-unit-group-label {
  position: absolute; top: 0; left: -1px; transform: translateY(-50%);
  background: var(--text-dim); padding: 0 6px;
  font-family: var(--font-mono); font-size: 12px; font-weight: 700;
  letter-spacing: 0.02em; color: #000;
  white-space: nowrap; z-index: 1;
}

/* ---------- Trend & Log popup ---------- */
.btn-xs { padding: 7px 10px; font-size: 14px; }
.hidden { display: none !important; }
.trend-panel { max-width: 1120px; }
.trend-body { display: flex; flex-direction: column; gap: 14px; }
/* No top padding here: a sticky table header sticks at the scroll container's
   padding edge, so with padding-top the rows scrolled through that gap, visible
   above the header. The spacing moves to the first child's margin instead. */
.modal-body.trend-body { padding-top: 0; }
.modal-body.trend-body > :first-child { margin-top: 20px; }
.trend-controls { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.trend-controls label { display: flex; flex-direction: column; gap: 4px; font-size: 11px; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.04em; font-weight: 700; }
.trend-grow { flex: 1 1 180px; }
.trend-input { background: var(--surface); color: var(--text); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 6px 9px; font-family: var(--font-sans); font-size: 13px; text-transform: none; letter-spacing: 0; font-weight: 400; }
.trend-input:focus { outline: none; border-color: var(--orange); }
.trend-error:empty { display: none; }
.trend-error { color: var(--red); font-size: 12.5px; }

.trend-downnow { background: #22283a96; border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 14px; font-size: 12.5px; }
.trend-downnow h3 { margin: 0 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-faint); }
.trend-downnow .none { color: var(--text-dim); }
.trend-dn-list { display: flex; flex-direction: column; gap: 5px; max-height: 150px; overflow-y: auto; }
.trend-dn-item { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.trend-dn-item .meta { color: var(--text-dim); font-family: var(--font-mono); font-size: 12px; }
.trend-badge-multi { background: var(--red-bg); color: var(--red); border: 1px solid var(--red); border-radius: var(--radius-pill); padding: 0 8px; font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; }
.trend-badge-ongoing { background: var(--amber-bg); color: var(--amber); border-radius: var(--radius-pill); padding: 0 8px; font-size: 10.5px; font-weight: 700; }

.trend-tabs { display: flex; align-items: center; gap: 6px; border-bottom: 1px solid var(--border); padding-bottom: 8px; flex-wrap: wrap; }
.trend-tabs-spacer { flex: 1; }
.trend-tab { background: none; border: 1px solid transparent; color: var(--text-dim); border-radius: var(--radius-sm); padding: 6px 14px; font-weight: 700; font-size: 13px; cursor: pointer; font-family: var(--font-sans); }
.trend-tab:hover { color: var(--text); }
.trend-tab.active { background: var(--surface); color: var(--text); border-color: var(--border-strong); }

.trend-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; }
.trend-card { background: #22283a96; border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 14px; }
.trend-card .k { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-faint); font-weight: 700; }
.trend-card .v { font-size: 22px; font-weight: 700; margin-top: 2px; }
.trend-card .s { font-size: 11.5px; color: var(--text-dim); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trend-note { font-size: 12px; color: var(--text-dim); margin-top: 8px; }
.trend-note.warn { color: var(--amber); }
.trend-sortrow { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-dim); margin: 10px 0;}

.trend-charts { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 0 0 10px 0; }
@media (max-width: 800px) { .trend-charts { grid-template-columns: 1fr; } }
.trend-chart { background: #22283a96; border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; min-width: 0; }
.trend-chart h3 { margin: 0 0 10px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-faint); }
.trend-bar-row { display: grid; grid-template-columns: minmax(80px, 38%) 1fr auto; align-items: center; gap: 8px; margin-bottom: 5px; font-size: 12px; }
.trend-bar-row .lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trend-bar-track { background: var(--border); border-radius: 4px; height: 12px; overflow: hidden; }
.trend-bar-fill { background: var(--orange); height: 100%; border-radius: 4px; min-width: 2px; }
.trend-bar-row .val { font-family: var(--font-mono); color: var(--text-dim); font-size: 11.5px; }
.trend-vbars { display: flex; align-items: flex-end; gap: 3px; height: 130px; }
.trend-vbar { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; }
.trend-vbar .fill { width: 100%; background: var(--orange); border-radius: 3px 3px 0 0; min-height: 0; }
.trend-vbar .n { font-size: 10px; color: var(--text-dim); height: 13px; line-height: 13px; }
.trend-vlabels { display: flex; gap: 3px; margin-top: 4px; }
.trend-vlabels span { flex: 1; min-width: 0; text-align: center; font-size: 9.5px; color: var(--text-faint); overflow: hidden; }

#trend-devices table, #trend-raw-body table { table-layout: auto; }
#trend-devices th, #trend-raw-body th { white-space: nowrap; }
#trend-devices td, #trend-raw-body td { padding: 6px 8px; }
#trend-devices td.num, #trend-devices th.num { text-align: right; font-family: var(--font-mono); font-size: 12px; }
#trend-devices tr.dev-row { cursor: pointer; }
#trend-devices tr.dev-row:hover td { background: #ffffff0a; }
#trend-devices tr.trend-detail td { background: #0000002a; padding: 8px 14px 12px; }
.trend-detail table { width: auto; min-width: 60%; }
/* Per-device table: rounded, bordered box like the raw log. overflow: clip (not
   hidden) rounds the corners without becoming a scroll container, so the sticky
   header still sticks to the popup's scroll. */
.trend-box { border: 1px solid var(--border); border-radius: var(--radius); overflow: clip; }
.trend-raw-scroll { max-height: 52vh; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.trend-rawhead { font-size: 12px; color: var(--text-dim); margin-bottom: 6px; }
.trend-loading { padding: 18px; text-align: center; color: var(--text-dim); font-size: 12.5px; }

/* Trend popup: dark panel so the translucent cards read correctly */
.trend-panel { background: #141a2b; }
.trend-dn-scroll { max-height: 190px; overflow-y: auto; }
.trend-dn-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.trend-dn-table th { position: sticky; top: 0; background: #1d2438; text-align: left; padding: 4px 10px 6px 0; font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-faint); border-bottom: 1px solid var(--border); }
.trend-dn-table td { padding: 5px 10px 5px 0; border-bottom: 1px solid rgba(255,255,255,0.05); vertical-align: middle; }
.trend-dn-table tr:last-child td { border-bottom: none; }
.trend-dn-table .r { text-align: right; padding-right: 0; }
.trend-dn-table .mono { color: var(--text-dim); white-space: nowrap; }
.trend-dn-table .pill { width: auto; max-width: 100%; }
.trend-sortrow .trend-input { width: auto; }
.trend-card, .trend-chart, .trend-downnow { background: #1d2438; }
.trend-card .v { color: var(--text); }

/* ---------- Devices popup ---------- */
.devices-panel { max-width: 980px; background: #141a2b; }
.dev-form { background: #1d2438; border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.dev-form h3 { margin: 0; font-size: 13px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-faint); }
.dev-form label { display: flex; flex-direction: column; gap: 4px; font-size: 11px; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.04em; font-weight: 700; }
.dev-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.dev-adv summary { cursor: pointer; font-size: 12.5px; color: var(--text-dim); margin-bottom: 8px; }
#dev-list table { table-layout: auto; }
#dev-list th { white-space: nowrap; }
#dev-list td { padding: 7px 8px; }
/* Rounded, bordered box like the Trend raw log; overflow: clip keeps the sticky header working. */
.dev-box { border: 1px solid var(--border); border-radius: var(--radius); overflow: clip; }
.dev-badge { display: inline-block; border-radius: var(--radius-pill); padding: 0 9px; font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; border: 1px solid var(--border-strong); color: var(--text-dim); }
.dev-badge.external { color: var(--green); border-color: var(--green); }
.dev-badge.cacti { color: var(--amber); border-color: var(--amber); }
.dev-st-up { color: var(--green); font-weight: 700; font-size: 12px; }
.dev-st-down { color: var(--red); font-weight: 700; font-size: 12px; }
.dev-st-wait { color: var(--text-faint); font-size: 12px; }
.dev-actions { white-space: nowrap; text-align: right; }
.dev-actions button { background: none; border: 1px solid var(--border-strong); color: var(--text-dim); border-radius: var(--radius-sm); padding: 3px 9px; font-size: 12px; cursor: pointer; font-family: var(--font-sans); }
.dev-actions button:hover { color: var(--text); }
.dev-actions button.del:hover { color: var(--red); border-color: var(--red); }
.dev-lock { color: var(--text-faint); font-size: 12px; cursor: help; }
.status-msg.ok { color: var(--green); }

/* ---------- header logout icon ---------- */
.banner-logout { display: inline-flex; align-items: center; justify-content: center; padding: 6px 8px; line-height: 0; }

/* ---------- Live Ping head buttons ---------- */
#live-ping-card .card-head .btn-xs { flex-shrink: 0; white-space: nowrap; }

/* ---------- small popups (sound confirm, quick add) ---------- */
.mini-panel { max-width: 440px; background: #141a2b; }
.mini-text { margin: 0 0 16px; font-size: 14px; color: var(--text-dim); }
.add-input { width: 100%; box-sizing: border-box; resize: none; overflow-y: auto; font-family: var(--font-mono); font-size: 14px; line-height: 1.4; }
.add-msg { min-height: 18px; margin-top: 8px; font-size: 12.5px; color: var(--red); }
.add-msg.ok { color: var(--green); }
.banner-user { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12.5px; font-weight: 600; color: rgba(255,255,255,0.7); }
@media (max-width: 640px) { .banner-user { display: none; } }

/* ---------- ping terminal (floating, draggable, resizable) ---------- */
.term-float {
  position: fixed; z-index: 96; width: 560px; height: 360px; min-width: 320px; min-height: 180px;
  display: flex; flex-direction: column; background: #0b0f1a;
  border: 3px solid var(--border-rtt); border-radius: var(--radius-rtt);
}
.term-float.hidden { display: none; }
.term-float.min { height: auto !important; min-height: 0; }
.term-float.min .term, .term-float.min .term-resize { display: none; }
.term-float.moving { user-select: none; opacity: 0.92; }
.term-bar {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px 8px 20px; flex-shrink: 0;
  background: var(--green-dark); color: #fff; cursor: grab; user-select: none; touch-action: none;
  border-radius: 10px 10px 0 0;
}
.term-float.min .term-bar { border-radius: 10px; }
.term-float.moving .term-bar { cursor: grabbing; }
.term-title { flex: 1; font-size: 12.5px; font-weight: 600; }
.term-ctl { display: flex; gap: 4px; }
.term-ctl button {
  background: rgba(255,255,255,0.18); border: none; color: #fff; width: 30px; height: 20px;
  border-radius: 4px; cursor: pointer; font-size: 13px; line-height: 1; padding: 0;
}
.term-ctl button:hover { background: rgba(255,255,255,0.3); }
.term-ctl #term-close { background: rgba(255,0,0,0.5); }
.term { flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 10px 14px 12px;
  font-family: var(--font-mono); font-size: 13px; line-height: 1.5; color: #d6dbe8; }
.term-out { flex: 1; min-height: 0; overflow-y: auto; white-space: pre-wrap; word-break: break-all; padding-bottom: 6px; }
.term-out .t-cmd { color: #7aa2f7; }
.term-out .t-ok { color: var(--green); }
.term-out .t-bad { color: var(--red); }
.term-out .t-dim { color: var(--text-faint); }
.term-line { display: flex; gap: 8px; align-items: center; border-top: 1px solid var(--border); padding-top: 8px; flex-shrink: 0; }
.term-prompt { color: var(--green); font-weight: 700; }
.term-input { flex: 1; min-width: 0; background: none; border: none; outline: none; color: #fff; font: inherit; caret-color: var(--green); }
.term-input[readonly] { color: var(--text-faint); }
.term-resize { position: absolute; right: 0; bottom: 0; width: 18px; height: 18px; cursor: nwse-resize; touch-action: none;
  background: linear-gradient(135deg, transparent 50%, var(--text-faint) 50%, var(--text-faint) 58%, transparent 58%, transparent 72%, var(--text-faint) 72%, var(--text-faint) 80%, transparent 80%); }

/* ---------- sound notice (first load): blurred page, RTT-card style popup ---------- */
.sound-overlay { background: rgba(15, 20, 17, 0.85); cursor: pointer; z-index: 120; }
.sound-card {
  width: 100%; max-width: 380px; cursor: default; background: var(--surface, #fff);
  border: 3px solid var(--border-rtt); border-radius: var(--radius-rtt);
  box-shadow: 0 12px 32px rgba(0,0,0,0.45); overflow: hidden;
}
.sound-head { padding: 8px 20px; background: var(--green-dark); color: #fff; font-size: 12.5px; font-weight: 700; letter-spacing: 0.08em; }
.sound-body { padding: 18px 20px 16px; text-align: center; }
.sound-body p { margin: 0 0 16px; font-size: 14px; line-height: 1.5; color: var(--text-dim); }
.sound-hint { margin-top: 12px; font-size: 11.5px; color: var(--text-faint); }

.dev-hidden td { opacity: 0.45; }
.dev-hidden td.dev-actions { opacity: 1; }
