/* Monitoring view */
.mon-view {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 56px);
  overflow-y: auto;
  background: var(--bg);
}

.mon-head {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 24px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  align-items: end;
}
.mon-title-block h1 { margin: 4px 0 4px; font-size: 22px; font-weight: 700; letter-spacing: -0.01em; }
.mon-bc { display: flex; gap: 6px; font-size: 12px; color: var(--text-dim); }
.mon-bc .bc-current { color: var(--text); font-weight: 600; }
.mon-meta {
  display: flex; gap: 8px; align-items: center; font-size: 12px; color: var(--text-dim);
}
.mon-meta b { color: var(--text); font-family: var(--mono); }
.mon-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.seg {
  display: inline-flex;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 3px;
  gap: 2px;
}
.seg button {
  padding: 5px 12px;
  border: 0;
  background: transparent;
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 500;
  border-radius: calc(var(--radius) - 2px);
}
.seg button.active { background: var(--panel); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.15); }

.mon-search {
  height: 32px;
  padding: 0 12px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: inherit;
  font-size: 12px;
  width: 200px;
  outline: none;
}

/* KPIs */
.mon-kpis {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  padding: 16px 24px 0;
}
.mk-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
}
.mk-label { font-size: 9px; font-family: var(--mono); letter-spacing: .1em; color: var(--text-dim); margin-bottom: 6px; font-weight: 700; }
.mk-row { display: flex; justify-content: space-between; align-items: end; gap: 12px; }
.mk-val { font-size: 22px; font-weight: 700; font-family: var(--mono); letter-spacing: -0.02em; line-height: 1; }
.mk-val span { font-size: 11px; font-weight: 500; color: var(--text-dim); margin-left: 2px; }
.mk-bar { margin-top: 8px; height: 4px; background: var(--bg-2); border-radius: 2px; overflow: hidden; }
.mk-bar div { height: 100%; }
.mk-sub { font-size: 10px; color: var(--text-dim); font-family: var(--mono); margin-top: 6px; }
.mk-row .spark { width: 80px; }

/* Alerts strip */
.alerts-strip {
  margin: 16px 24px 0;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.as-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 16px; border-bottom: 1px solid var(--border);
}
.as-title { font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; font-family: var(--mono); display: flex; align-items: center; gap: 8px; }
.as-count { background: oklch(0.62 0.20 28); color: white; font-size: 10px; padding: 1px 6px; border-radius: 999px; }
.as-link { font-size: 12px; color: var(--accent); }
.as-list { list-style: none; margin: 0; padding: 0; }
.alert-row {
  display: grid;
  grid-template-columns: 16px 200px 1fr auto auto auto;
  gap: 12px;
  padding: 8px 16px;
  align-items: center;
  font-size: 12px;
  border-top: 1px solid var(--border);
}
.alert-row:first-child { border-top: 0; }
.sev-dot { width: 8px; height: 8px; border-radius: 50%; }
.sev-dot.sev-crit { background: oklch(0.62 0.20 28); box-shadow: 0 0 6px oklch(0.62 0.20 28 / 0.6); animation: pulse-crit 1.5s infinite; }
.sev-dot.sev-warn { background: oklch(0.78 0.15 75); }
@keyframes pulse-crit { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }
.al-source { font-family: var(--mono); font-weight: 600; font-size: 11px; }
.al-msg { color: var(--text-dim); }
.al-time { font-size: 10px; color: var(--text-muted); font-family: var(--mono); }
.badge-new { background: var(--accent); color: oklch(0.18 0.01 240); font-size: 9px; font-weight: 700; padding: 1px 5px; border-radius: 3px; letter-spacing: .04em; }
.btn.ghost.ack { padding: 3px 10px; height: 24px; font-size: 11px; }
.btn.xs { height: 22px; padding: 0 8px; font-size: 11px; }

/* Body */
.mon-body {
  display: grid;
  grid-template-columns: 1fr 480px;
  gap: 16px;
  padding: 16px 24px;
  flex: 1;
  min-height: 0;
}

.mon-left { display: flex; flex-direction: column; gap: 12px; }
.ml-head { display: flex; justify-content: space-between; align-items: baseline; }
.ml-title { font-size: 13px; font-weight: 700; }
.ml-sub { font-size: 11px; color: var(--text-dim); font-family: var(--mono); }

/* PDU grid */
.pdu-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 10px;
}
.pdu-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px;
  cursor: pointer;
  transition: border-color .15s;
}
.pdu-card:hover { border-color: var(--border-strong); }
.pdu-card.selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.pdu-card.status-warn { border-left: 3px solid oklch(0.78 0.15 75); }
.pdu-card.status-crit { border-left: 3px solid oklch(0.62 0.20 28); }
.pdu-card.status-off { opacity: 0.7; border-left: 3px solid oklch(0.5 0.005 240); }

.pc-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.pc-id { display: flex; gap: 6px; align-items: baseline; }
.pc-rack { font-family: var(--mono); font-weight: 700; font-size: 13px; }
.pc-side { font-family: var(--mono); font-size: 10px; color: var(--text-dim); padding: 1px 5px; background: var(--bg-2); border-radius: 3px; }
.pc-conn { font-size: 9px; font-family: var(--mono); color: var(--text-dim); display: flex; align-items: center; gap: 4px; letter-spacing: .04em; }
.conn-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 4px var(--ok); }
.pc-conn.off .conn-dot { background: var(--text-muted); box-shadow: none; }
.pc-conn.off { color: var(--text-muted); }

.pc-main { display: flex; align-items: baseline; gap: 8px; margin-bottom: 4px; }
.pc-val { font-family: var(--mono); font-weight: 700; font-size: 24px; letter-spacing: -0.02em; }
.pc-val span { font-size: 11px; color: var(--text-dim); margin-left: 1px; }
.pc-amps { font-size: 11px; color: var(--text-dim); font-family: var(--mono); }

.pc-bar { position: relative; height: 6px; background: var(--bg-2); border-radius: 3px; margin: 6px 0 4px; overflow: visible; }
.pc-bar-fill { height: 100%; border-radius: 3px; }
.pc-bar-tick { position: absolute; top: -2px; bottom: -2px; width: 1px; background: oklch(0.78 0.15 75); }
.pc-bar-tick.crit { background: oklch(0.62 0.20 28); }

.pc-meta { display: flex; justify-content: space-between; font-size: 10px; color: var(--text-dim); font-family: var(--mono); margin-bottom: 8px; }
.trend.trend-up { color: oklch(0.78 0.15 75); }
.trend.trend-down { color: var(--ok); }

.pc-spark { margin-bottom: 8px; }
.pc-foot { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding-top: 8px; border-top: 1px dashed var(--border); }
.foot-block { display: flex; flex-direction: column; gap: 1px; }
.foot-label { font-size: 8px; font-family: var(--mono); color: var(--text-muted); letter-spacing: .1em; }
.foot-val { font-family: var(--mono); font-size: 12px; font-weight: 600; }
.foot-val span { color: var(--text-dim); font-size: 10px; }

.pc-off { padding: 16px 0; text-align: center; }
.off-label { font-size: 13px; font-weight: 600; color: var(--text-muted); }
.off-sub { font-size: 10px; color: var(--text-muted); font-family: var(--mono); margin-top: 2px; }

/* Pills */
.pill {
  font-size: 9px; font-family: var(--mono); font-weight: 700;
  padding: 2px 7px; border-radius: 999px; letter-spacing: .06em;
  display: inline-block;
}
.pill.lg { font-size: 10px; padding: 3px 10px; }
.pill-ok { background: color-mix(in oklch, var(--ok) 18%, transparent); color: var(--ok); }
.pill-warn { background: color-mix(in oklch, var(--warn) 18%, transparent); color: var(--warn); }
.pill-crit { background: color-mix(in oklch, var(--danger) 18%, transparent); color: var(--danger); }
.pill-off { background: var(--bg-2); color: var(--text-muted); }

/* PDU table */
.pdu-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  font-size: 12px;
}
.pdu-table th {
  text-align: left;
  font-size: 10px; font-family: var(--mono); letter-spacing: .08em; text-transform: uppercase;
  color: var(--text-dim); font-weight: 700;
  padding: 8px 12px; border-bottom: 1px solid var(--border);
  background: var(--panel-2);
}
.pdu-table td { padding: 8px 12px; border-bottom: 1px solid var(--border); }
.pdu-table tr { cursor: pointer; }
.pdu-table tr:hover { background: var(--bg-2); }
.pdu-table tr.selected { background: color-mix(in oklch, var(--accent) 8%, transparent); }
.row-bar { width: 80px; height: 4px; background: var(--bg-2); border-radius: 2px; overflow: hidden; }
.row-bar div { height: 100%; }

/* Right detail */
.mon-right {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-self: start;
  position: sticky;
  top: 16px;
  max-height: calc(100vh - 88px);
  overflow-y: auto;
}
.mr-head { display: flex; justify-content: space-between; align-items: start; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.mr-title { font-family: var(--mono); font-weight: 700; font-size: 16px; }
.mr-sub { font-size: 11px; color: var(--text-dim); margin-top: 2px; font-family: var(--mono); }
.mr-tabs { display: flex; gap: 2px; padding: 3px; background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius); }
.mr-tabs button { flex: 1; padding: 6px 10px; border: 0; background: transparent; color: var(--text-dim); font-size: 11px; font-weight: 500; border-radius: calc(var(--radius) - 2px); cursor: pointer; }
.mr-tabs button.active { background: var(--panel); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.15); }

.mr-charts { display: flex; flex-direction: column; gap: 12px; }
.chart-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.big-chart {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
}
.bc-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.bc-label { font-size: 10px; font-family: var(--mono); letter-spacing: .08em; color: var(--text-dim); font-weight: 700; }
.bc-now { font-size: 18px; font-family: var(--mono); font-weight: 700; }
.bc-now span { font-size: 11px; color: var(--text-dim); margin-left: 2px; }
.bc-svg { display: block; }
.bc-x-labels { display: flex; justify-content: space-between; margin-top: 4px; font-size: 9px; color: var(--text-muted); font-family: var(--mono); }

/* Outlets */
.outlets {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
}
.outlets-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.oh-title { font-size: 11px; font-family: var(--mono); font-weight: 700; letter-spacing: .04em; }
.oh-sub { font-size: 10px; color: var(--text-dim); font-family: var(--mono); }
.outlets-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 4px;
}
.outlet {
  display: grid;
  grid-template-columns: 28px 8px 1fr 1fr;
  gap: 6px;
  align-items: center;
  padding: 4px 8px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 3px;
  font-size: 10px;
  font-family: var(--mono);
}
.outlet.free { opacity: 0.5; }
.ol-idx { color: var(--text-dim); font-weight: 600; }
.ol-led { width: 6px; height: 6px; border-radius: 50%; background: var(--text-muted); }
.ol-led.on { background: oklch(0.78 0.16 145); box-shadow: 0 0 4px oklch(0.78 0.16 145 / 0.7); }
.ol-load { font-weight: 600; }
.ol-host { color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 9px; }

/* mr-bottom */
.mr-bottom { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.mr-info {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
}
.mr-info-title { font-size: 10px; font-family: var(--mono); letter-spacing: .08em; color: var(--text-dim); font-weight: 700; margin-bottom: 8px; }
.mr-kv { list-style: none; margin: 0 0 10px; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.mr-kv li { display: flex; justify-content: space-between; font-size: 11px; padding: 3px 0; border-bottom: 1px dashed var(--border); }
.mr-kv span { color: var(--text-dim); }
.mr-kv b { font-family: var(--mono); font-weight: 600; }
.mr-info .btn { width: 100%; justify-content: center; height: 28px; font-size: 11px; }

@media (max-width: 1280px) {
  .mon-kpis { grid-template-columns: repeat(3, 1fr); }
  .mon-body { grid-template-columns: 1fr; }
  .mon-right { position: static; max-height: none; }
}
