/* ═══════════════════════════════════════════════════════════════════════════
   Monitor IIS — Control App  |  DaisyUI Night Theme + Custom Components
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Custom colour tokens (complement DaisyUI's night theme) ─────────────── */
:root {
  --green:       #1ed693;
  --green-dim:   #0a7a52;
  --yellow:      #f0a000;
  --yellow-dim:  #8a5d00;
  --red:         #ff4757;
  --red-dim:     #aa1f2e;
  --blue:        #5b8def;
  --blue-dim:    #1a5cb8;
  --teal:        #00d4b0;
  --teal-dim:    #007a66;
  --orange:      #ff9500;
  --purple:      #9d7aff;
  --radius:      8px;
  --radius-lg:   12px;
  --radius-xl:   16px;
  --shadow:      0 8px 32px rgba(0,0,0,.55);
  --shadow-sm:   0 2px 12px rgba(0,0,0,.4);
  /* ── Legacy compat aliases (used in inline styles / old template snippets) ── */
  --text-muted:    oklch(var(--bc) / 0.5);
  --text-primary:  oklch(var(--bc));
  --border:        oklch(var(--b3));
  --surface2:      oklch(var(--b2));
  --surface3:      oklch(var(--b3));
  --accent-warning: var(--yellow);
  --text-faint:    oklch(var(--bc) / 0.35);
}

/* ── Base resets that don't conflict with DaisyUI ────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

::-webkit-scrollbar       { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: oklch(var(--b1)); }
::-webkit-scrollbar-thumb { background: oklch(var(--b3)); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: oklch(var(--bc)/0.3); }

/* ═══ OVERRIDE DaisyUI btn height so our padding controls size ══════════════ */
.btn { height: auto !important; min-height: unset !important; }

/* ── Custom button colours (on top of DaisyUI's .btn base) ──────────────── */
.btn-danger {
  background: var(--red-dim);
  border-color: var(--red-dim);
  color: #fff;
}
.btn-danger:hover { background: #cc2233; box-shadow: 0 4px 14px rgba(255,71,87,.25); }

.btn-danger-ghost {
  background: none;
  border: none;
  color: var(--red);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius);
  transition: background .15s;
}
.btn-danger-ghost:hover { background: rgba(255,71,87,.1); }

/* ═══ SIDEBAR COLLAPSE (desktop) ════════════════════════════════════════════ */
.sidebar-text { transition: opacity .2s, width .2s; }

#app-sidebar.sidebar-collapsed {
  width: 64px !important;
}
#app-sidebar.sidebar-collapsed .sidebar-text {
  opacity: 0;
  width: 0;
  overflow: hidden;
  pointer-events: none;
}
#app-sidebar.sidebar-collapsed .menu li a {
  justify-content: center;
  padding-left: 0;
  padding-right: 0;
}
#app-sidebar.sidebar-collapsed .menu-title { display: none; }

/* Logo icon in sidebar */
.logo-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, rgba(91,141,239,.35), rgba(91,141,239,.12));
  border: 1px solid rgba(91,141,239,.35);
  color: var(--blue);
}

/* ═══ ROLE BADGES ════════════════════════════════════════════════════════════ */
.role-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: .04em;
  white-space: nowrap;
  flex-shrink: 0;
}
.role-admin    { background: rgba(255,71,87,.15);  color: var(--red);    border: 1px solid rgba(255,71,87,.3); }
.role-operator { background: rgba(240,160,0,.12);  color: var(--orange); border: 1px solid rgba(240,160,0,.3); }
.role-viewer   { background: rgba(91,141,239,.1);  color: var(--blue);   border: 1px solid rgba(91,141,239,.2); }

/* ═══ CUSTOM BADGE MODIFIERS (extend DaisyUI .badge) ════════════════════════ */
.badge-pending   { --tw-badge-color: var(--blue); }
.badge-sent      { background: rgba(240,160,0,.15); color: var(--orange); border-color: rgba(240,160,0,.3); }
.badge-collecting{ background: rgba(240,160,0,.15); color: var(--orange); border-color: rgba(240,160,0,.3); }
.badge-uploading { background: rgba(91,141,239,.15); color: var(--blue);  border-color: rgba(91,141,239,.3); }
.badge-ready     { background: rgba(30,214,147,.12); color: var(--green); border-color: rgba(30,214,147,.3); }
.badge-expired   { background: oklch(var(--b3));    color: oklch(var(--bc)/0.4); }
.badge-cancelled { background: oklch(var(--b3));    color: oklch(var(--bc)/0.4); }
.badge-timeout   { background: oklch(var(--b3));    color: oklch(var(--bc)/0.4); }
.badge-critical  { background: rgba(255,71,87,.12); color: var(--red);   border: 1px solid rgba(255,71,87,.3); }
.badge-ghost     { background: transparent; border: 1px solid oklch(var(--b3)); color: oklch(var(--bc)/0.5); }
.badge-running   { background: rgba(91,141,239,.15); color: var(--blue); border: 1px solid rgba(91,141,239,.3); animation: pulse-opacity 1.5s infinite; }
.badge-skipped   { background: oklch(var(--b3)); color: oklch(var(--bc)/0.4); }
.badge-unknown   { background: oklch(var(--b3)); color: oklch(var(--bc)/0.4); }

/* ═══ FORMS ══════════════════════════════════════════════════════════════════ */
.form-group { display: flex; flex-direction: column; gap: 5px; margin-bottom: 16px; }
.form-group label { font-size: 12px; font-weight: 600; color: oklch(var(--bc)/0.65); letter-spacing: .02em; }
.form-control {
  background: oklch(var(--b1));
  border: 1px solid oklch(var(--b3));
  border-radius: var(--radius);
  color: oklch(var(--bc));
  padding: 8px 12px;
  font-size: 13px;
  transition: border-color .18s, box-shadow .18s;
  width: 100%;
  outline: none;
}
.form-control:focus {
  border-color: oklch(var(--p));
  box-shadow: 0 0 0 3px oklch(var(--p)/0.15);
}
.form-control option { background: oklch(var(--b2)); }
.form-check { flex-direction: row !important; align-items: center; gap: 8px; }
.form-check-input { width: 16px; height: 16px; accent-color: oklch(var(--p)); cursor: pointer; }
.form-group-btn { justify-content: flex-end; padding-top: 16px; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }
.form-hint { display: block; font-size: .78rem; color: oklch(var(--bc)/0.4); margin-top: 4px; }
.form-group input[type="text"]:not(.form-control),
.form-group input[type="url"]:not(.form-control),
.form-group input[type="number"]:not(.form-control),
.form-group input[type="password"]:not(.form-control),
.form-group input[type="date"]:not(.form-control),
.form-group select:not(.form-control),
.form-group textarea:not(.form-control) {
  width: 100%;
  padding: 9px 12px;
  background: oklch(var(--b1));
  border: 1px solid oklch(var(--b3));
  border-radius: var(--radius);
  color: oklch(var(--bc));
  font-size: .9rem;
  transition: border-color .2s;
  outline: none;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  border-color: oklch(var(--p));
  box-shadow: 0 0 0 3px oklch(var(--p)/0.12);
}
.form-group input[type="checkbox"], .form-group input[type="radio"] {
  accent-color: oklch(var(--p));
  margin-right: 6px;
}
.form-row  { display: flex; gap: 16px; flex-wrap: wrap; }
.form-group.flex-2 { flex: 2; min-width: 180px; }
.form-group.flex-1 { flex: 1; min-width: 140px; }

/* ─── Rule / Notification form sections ──────────────────────────────────── */
.form-section {
  background: oklch(var(--b2));
  border: 1px solid oklch(var(--b3));
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 20px;
}
.rule-form { max-width: 820px; }
.section-title {
  font-size: 1rem;
  font-weight: 600;
  margin: 0 0 14px;
  color: oklch(var(--bc));
}
.section-desc {
  color: oklch(var(--bc)/0.55);
  font-size: .85rem;
  margin: -6px 0 14px;
}

/* ─── Filter bars ─────────────────────────────────────────────────────────── */
.filter-bar { margin-bottom: 20px; }
.filter-form { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.filter-form select, .filter-form input[type="text"] {
  padding: 8px 10px;
  background: oklch(var(--b2));
  border: 1px solid oklch(var(--b3));
  border-radius: var(--radius);
  color: oklch(var(--bc));
  font-size: .85rem;
  min-width: 140px;
  outline: none;
}
.filter-bar-panel {
  background: oklch(var(--b2));
  border: 1px solid oklch(var(--b3));
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  margin-bottom: 22px;
}
.filter-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.filter-row .form-group { margin-bottom: 0; min-width: 160px; flex: 1; }

/* ═══ PANELS ═════════════════════════════════════════════════════════════════ */
.panel {
  background: oklch(var(--b2));
  border: 1px solid oklch(var(--b3));
  border-radius: var(--radius-lg);
  padding: 22px;
}
.panel-narrow { max-width: 520px; }
.panel-wide   { min-height: 200px; }
.panel-title {
  font-size: 14px;
  font-weight: 700;
  color: oklch(var(--bc));
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  gap: 9px;
}
.two-col-layout {
  display: grid;
  grid-template-columns: 320px minmax(0,1fr);
  gap: 22px;
  align-items: start;
}
@media (max-width: 1100px) { .two-col-layout { grid-template-columns: 1fr; } }

/* ═══ TABLES ══════════════════════════════════════════════════════════════════ */
.table-wrapper, .table-container {
  overflow-x: auto;
  border: 1px solid oklch(var(--b3));
  border-radius: var(--radius-lg);
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table th {
  background: oklch(var(--b2));
  color: oklch(var(--bc)/0.55);
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid oklch(var(--b3));
  white-space: nowrap;
}
.data-table td {
  padding: 11px 14px;
  border-bottom: 1px solid oklch(var(--b3)/0.6);
  vertical-align: middle;
  color: oklch(var(--bc));
}
.data-table tbody tr:hover { background: oklch(var(--p)/0.04); }
.data-table tbody tr:last-child td { border-bottom: none; }
.nowrap { white-space: nowrap; }
.result-count { font-size: 12px; color: oklch(var(--bc)/0.5); margin-top: 8px; }
.actions-cell { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.inline-form  { display: inline; }

/* ═══ TOKEN DISPLAY ══════════════════════════════════════════════════════════ */
.token-cell { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.token-display {
  font-family: monospace;
  font-size: 12px;
  color: oklch(var(--bc)/0.5);
  background: oklch(var(--b1));
  padding: 2px 7px;
  border-radius: 6px;
  border: 1px solid oklch(var(--b3));
}

/* ═══ MODALS ═════════════════════════════════════════════════════════════════ */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.72);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}
.modal-box {
  background: oklch(var(--b2));
  border: 1px solid oklch(var(--b3));
  border-radius: var(--radius-xl);
  width: 460px;
  max-width: calc(100vw - 32px);
  box-shadow: var(--shadow);
  animation: modal-in .18s ease;
}
@keyframes modal-in { from { opacity:0; transform: scale(.96) translateY(8px); } }
.modal-header {
  padding: 20px 22px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid oklch(var(--b3));
}
.modal-header h3 { font-size: 15px; font-weight: 700; color: oklch(var(--bc)); }
.modal-body  { padding: 22px; }
.modal-footer {
  padding: 16px 22px;
  border-top: 1px solid oklch(var(--b3));
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}
.modal-desc { color: oklch(var(--bc)/0.6); font-size: 13px; white-space: pre-line; margin-bottom: 16px; line-height: 1.6; }
.confirm-input-group label { display: block; font-size: 12px; color: oklch(var(--bc)/0.6); margin-bottom: 6px; }
.confirm-input-group input {
  width: 100%;
  background: oklch(var(--b1));
  border: 1px solid oklch(var(--b3));
  border-radius: var(--radius);
  color: oklch(var(--bc));
  padding: 9px 13px;
  font-size: 14px;
  font-family: monospace;
  letter-spacing: .1em;
  font-weight: 700;
  outline: none;
  transition: border-color .18s;
}
.confirm-input-group input:focus {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(255,71,87,.12);
}

/* ═══ FLASH ALERTS (custom, inside flash-area div) ══════════════════════════ */
/* DaisyUI .alert handles this, but keep class aliases */
.alerts { display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; }

/* ═══ EMPTY STATE ════════════════════════════════════════════════════════════ */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 70px 20px;
  color: oklch(var(--bc)/0.5);
  gap: 16px;
  text-align: center;
}
.empty-state svg { opacity: .3; }
.empty-state p   { font-size: 1rem; }

/* ═══ CODE ════════════════════════════════════════════════════════════════════ */
code {
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 12px;
  background: oklch(var(--b3));
  padding: 2px 6px;
  border-radius: 5px;
  color: var(--teal);
}

/* ═══ ERROR PAGE ═════════════════════════════════════════════════════════════ */
.error-page {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; min-height: 60vh; gap: 16px; text-align: center;
}
.error-code { font-size: 96px; font-weight: 900; color: oklch(var(--bc)/0.2); line-height: 1; }

/* ═══ LOGIN PAGE ═════════════════════════════════════════════════════════════ */
/* Handled by login.html using DaisyUI card */

/* ═══ METRIC INLINE ══════════════════════════════════════════════════════════ */
.metric-inline { font-weight: 700; }
.metric-critical { color: var(--red) !important; }
.metric-warning  { color: var(--yellow) !important; }

/* ═══ PULSE DOT & SPINNER ════════════════════════════════════════════════════ */
.pulse-dot {
  display: inline-block;
  width: 8px; height: 8px;
  background: var(--green);
  border-radius: 50%;
  animation: dot-blink 2s ease-in-out infinite;
  box-shadow: 0 0 8px rgba(30,214,147,.8);
  margin-left: 4px;
  vertical-align: middle;
}
.last-update { font-size: 12px; color: oklch(var(--bc)/0.5); }
.spinner {
  display: none;
  width: 16px; height: 16px;
  border: 2px solid oklch(var(--b3));
  border-top-color: oklch(var(--p));
  border-radius: 50%;
  animation: spin .6s linear infinite;
}
.htmx-request .spinner, .htmx-request.spinner { display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ═══ LEGEND ═════════════════════════════════════════════════════════════════ */
.legend { display: flex; gap: 20px; margin-top: 20px; flex-wrap: wrap; }
.legend-item {
  display: flex; align-items: center; gap: 7px;
  font-size: 12px; color: oklch(var(--bc)/0.5);
}

/* ═══ STATUS DOTS ════════════════════════════════════════════════════════════ */
.status-dot, .dot {
  width: 9px; height: 9px; border-radius: 50%;
  flex-shrink: 0; display: inline-block;
}
.dot-ok       { background: var(--green);  box-shadow: 0 0 8px rgba(30,214,147,.7); }
.dot-warning  { background: var(--yellow); box-shadow: 0 0 8px rgba(240,160,0,.7);  animation: dot-blink 2s ease-in-out infinite; }
.dot-critical { background: var(--red);    box-shadow: 0 0 10px rgba(255,71,87,.9); animation: dot-blink 1s ease-in-out infinite; }
.dot-inactive { background: oklch(var(--bc)/0.2); }
.dot-muted    { background: oklch(var(--bc)/0.2); display: inline-block; width: 8px; height: 8px; border-radius: 50%; }
@keyframes dot-blink { 0%,100%{opacity:1} 50%{opacity:.25} }

/* ═══ CLIENT SECTION ═════════════════════════════════════════════════════════ */
.client-section { margin-bottom: 28px; }
.client-section:last-child { margin-bottom: 0; }
.client-section-header {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 14px; padding-bottom: 10px;
  border-bottom: 1px solid oklch(var(--b3));
}
.client-section-title {
  font-size: 14px; font-weight: 800; color: oklch(var(--bc));
  letter-spacing: -.01em; flex: 1;
}
.client-section-count {
  font-size: 11px; color: oklch(var(--bc)/0.5);
  background: oklch(var(--b3)); padding: 3px 10px;
  border-radius: 20px; border: 1px solid oklch(var(--b3));
}

/* ═══ ANDON CARDS ════════════════════════════════════════════════════════════ */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 18px; padding-bottom: 18px;
}
.server-card {
  background: oklch(var(--b2));
  border: 1px solid oklch(var(--b3));
  border-radius: var(--radius-lg);
  padding: 22px;
  transition: border-color .25s, box-shadow .25s, transform .2s;
}
.server-card:hover { transform: translateY(-1px); }
.server-card.status-ok {
  border-color: rgba(30,214,147,.3);
  box-shadow: 0 4px 24px rgba(0,0,0,.3), 0 0 0 1px rgba(30,214,147,.08);
}
.server-card.status-warning {
  border-color: rgba(240,160,0,.4);
  box-shadow: 0 4px 24px rgba(0,0,0,.3), 0 0 16px rgba(240,160,0,.1);
}
.server-card.status-critical {
  border-color: rgba(255,71,87,.5);
  box-shadow: 0 4px 24px rgba(0,0,0,.3), 0 0 16px rgba(255,71,87,.15);
}
.server-card.pulse { animation: card-pulse 2s ease-in-out infinite; }
@keyframes card-pulse {
  0%,100% { box-shadow: 0 4px 24px rgba(0,0,0,.3), 0 0 8px rgba(255,71,87,.15); }
  50%      { box-shadow: 0 4px 24px rgba(0,0,0,.3), 0 0 24px rgba(255,71,87,.4); }
}

/* Card header / footer */
.card-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 20px; }
.card-title  { display: flex; align-items: center; gap: 12px; }
.hostname    { font-size: 15px; font-weight: 700; color: oklch(var(--bc)); letter-spacing: -.01em; }
.card-footer {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 11px; color: oklch(var(--bc)/0.5);
  margin-top: 6px; padding-top: 12px;
  border-top: 1px solid oklch(var(--b3));
}
.lag        { color: oklch(var(--bc)/0.5); }
.lag-critical { color: var(--red) !important; font-weight: 700; }
.ip         { font-family: monospace; color: oklch(var(--bc)/0.3); font-size: 11px; }

/* Server icon */
.srv-icon { width: 42px; height: 42px; border-radius: 12px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.srv-icon svg { width: 20px; height: 20px; }
.srv-icon-ok       { background: rgba(30,214,147,.2);  border: 1px solid rgba(30,214,147,.3);  color: var(--green); }
.srv-icon-warning  { background: rgba(240,160,0,.2);   border: 1px solid rgba(240,160,0,.3);   color: var(--yellow); }
.srv-icon-critical { background: rgba(255,71,87,.2);   border: 1px solid rgba(255,71,87,.3);   color: var(--red); }

/* Metric icons */
.metric-icon { width: 40px; height: 40px; border-radius: 11px; display: flex; align-items: center; justify-content: center; margin-bottom: 10px; }
.metric-icon svg { width: 20px; height: 20px; }
.icon-cpu  { background: rgba(91,141,239,.25);  border: 1px solid rgba(91,141,239,.3);  color: var(--blue); }
.icon-mem  { background: rgba(0,212,176,.25);   border: 1px solid rgba(0,212,176,.3);   color: var(--teal); }
.icon-disk { background: rgba(240,160,0,.25);   border: 1px solid rgba(240,160,0,.3);   color: var(--yellow); }

/* Metrics grid */
.metrics-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 14px; margin-bottom: 16px; }
.metric-label { font-size: 10px; font-weight: 700; color: oklch(var(--bc)/0.5); text-transform: uppercase; letter-spacing: .07em; margin-bottom: 3px; }
.metric-value { font-size: 42px; font-weight: 800; line-height: 1; color: oklch(var(--bc)); }
.metric-unit  { font-size: 18px; font-weight: 400; color: oklch(var(--bc)/0.5); }

/* Progress bars */
.progress-bar { height: 4px; background: oklch(var(--b3)); border-radius: 3px; margin-top: 8px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 3px; transition: width .5s; }
.fill-green  { background: linear-gradient(90deg, var(--teal-dim), var(--green)); }
.fill-yellow { background: linear-gradient(90deg, #a06500, var(--yellow)); }
.fill-red    { background: linear-gradient(90deg, var(--red-dim), var(--red)); }

/* ═══ ALERTS SUMMARY CARDS ═══════════════════════════════════════════════════ */
.alert-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px,1fr));
  gap: 16px; margin-bottom: 24px;
}
.summary-card {
  background: oklch(var(--b2));
  border: 1px solid oklch(var(--b3));
  border-radius: var(--radius-lg);
  padding: 20px; text-align: center;
}
.summary-card .summary-value { display: block; font-size: 2rem; font-weight: 700; line-height: 1.2; }
.summary-card .summary-label { display: block; font-size: .8rem; color: oklch(var(--bc)/0.5); margin-top: 4px; }
.summary-critical { border-left: 4px solid var(--red);   } .summary-critical .summary-value { color: var(--red); }
.summary-warning  { border-left: 4px solid var(--yellow);} .summary-warning  .summary-value { color: var(--yellow); }
.summary-resolved { border-left: 4px solid var(--green); } .summary-resolved .summary-value { color: var(--green); }
.summary-total    { border-left: 4px solid var(--blue);  } .summary-total    .summary-value { color: var(--blue); }

/* Alert row highlight */
.alert-row-critical { background: rgba(255,71,87,.04) !important; border-left: 3px solid var(--red); }

/* ═══ STATS GRID (security page) ════════════════════════════════════════════ */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px,1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: oklch(var(--b2));
  border: 1px solid oklch(var(--b3));
  border-radius: var(--radius-lg);
  padding: 20px; text-align: center;
}
.stat-value { font-size: 2rem; font-weight: 700; }
.stat-label { font-size: .8rem; color: oklch(var(--bc)/0.5); margin-top: 4px; }
.stat-ok       { border-left: 4px solid var(--green); } .stat-ok       .stat-value { color: var(--green); }
.stat-critical { border-left: 4px solid var(--red);   } .stat-critical .stat-value { color: var(--red); }

/* ═══ TOGGLE BUTTON (rules) ══════════════════════════════════════════════════ */
.toggle-btn {
  background: none; border: none; cursor: pointer;
  font-size: 1.1rem; padding: 2px 4px; border-radius: 4px;
  transition: background .15s;
}
.toggle-btn:hover { background: oklch(var(--b3)); }
.toggle-on  { color: var(--green); }
.toggle-off { color: oklch(var(--bc)/0.3); }

/* ═══ ANDON RESPONSE TIME ════════════════════════════════════════════════════ */
.rt-section { margin-bottom: 40px; }
.rt-section-header {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 16px; padding-bottom: 12px;
  border-bottom: 1px solid oklch(var(--b3));
}
.rt-section-title { font-size: 15px; font-weight: 800; color: oklch(var(--bc)); flex: 1; }
.rt-section-count {
  font-size: 11px; color: oklch(var(--bc)/0.5);
  background: oklch(var(--b3)); padding: 3px 10px;
  border-radius: 20px; border: 1px solid oklch(var(--b3));
}
.rt-grid { display: grid; grid-template-columns: repeat(auto-fill,minmax(320px,1fr)); gap: 16px; }
.rt-card {
  background: oklch(var(--b2)); border: 1px solid oklch(var(--b3));
  border-radius: var(--radius-lg); padding: 20px;
  transition: border-color .25s, box-shadow .25s, transform .2s;
}
.rt-card:hover { transform: translateY(-1px); }
.rt-card.status-ok       { border-color: rgba(30,214,147,.3); }
.rt-card.status-warning  { border-color: rgba(240,160,0,.4);  }
.rt-card.status-critical { border-color: rgba(255,71,87,.5);  }
.rt-card.pulse { animation: card-pulse 2s ease-in-out infinite; }
.rt-card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.rt-card-title  { display: flex; align-items: center; gap: 12px; }
.rt-sites-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.rt-sites-table th {
  font-size: 10px; font-weight: 700; color: oklch(var(--bc)/0.3);
  text-transform: uppercase; letter-spacing: .06em;
  padding: 5px 8px; text-align: left; border-bottom: 1px solid oklch(var(--b3));
}
.rt-sites-table td { padding: 9px 8px; border-bottom: 1px solid oklch(var(--b3)/0.5); vertical-align: middle; }
.rt-sites-table tbody tr:last-child td { border-bottom: none; }
.rt-sites-table tbody tr:hover { background: oklch(var(--p)/0.04); }
.rt-port {
  font-family: monospace; font-size: 12px; font-weight: 700; color: var(--blue);
  background: rgba(91,141,239,.1); padding: 2px 8px; border-radius: 6px;
  border: 1px solid rgba(91,141,239,.2);
}
.rt-time          { font-weight: 800; font-size: 15px; }
.rt-time-ok       { color: var(--green); }
.rt-time-warning  { color: var(--yellow); }
.rt-time-critical { color: var(--red); }
.rt-time-inactive { color: oklch(var(--bc)/0.25); }
.rt-muted { color: oklch(var(--bc)/0.45); font-size: 12px; }
.rt-trend         { font-size: 15px; font-weight: 800; }
.rt-trend-up      { color: var(--red); }
.rt-trend-down    { color: var(--green); }
.rt-trend-stable  { color: oklch(var(--bc)/0.25); font-size: 13px; }
.rt-card-footer {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 14px; padding-top: 12px;
  border-top: 1px solid oklch(var(--b3));
  font-size: 11px; color: oklch(var(--bc)/0.5);
}

/* ═══ ANDON FULL CARDS ═══════════════════════════════════════════════════════ */
.full-grid { display: grid; grid-template-columns: repeat(auto-fill,minmax(260px,1fr)); gap: 14px; }
.full-section { margin-bottom: 18px; }
.full-section-header {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 10px; padding-bottom: 6px;
  border-bottom: 1px solid oklch(var(--b3));
}
.full-section-title { font-size: .9rem; font-weight: 700; text-transform: uppercase; color: oklch(var(--bc)/0.5); }
.full-card {
  background: oklch(var(--b2)); border: 1px solid oklch(var(--b3));
  border-radius: var(--radius-lg); padding: 12px;
  transition: border-color .2s, box-shadow .2s;
}
.full-card.status-critical { border-color: var(--red); box-shadow: 0 0 20px rgba(255,71,87,.15); }
.full-card.status-warning  { border-color: var(--yellow); }
.full-card.pulse { animation: card-pulse 2s ease-in-out infinite; }
.full-rt-divider { border: none; border-top: 1px solid oklch(var(--b3)); margin: 7px 0 5px; }
.full-rt-table { width: 100%; border-collapse: collapse; font-size: .75rem; }
.full-rt-table td { padding: 2px 4px; color: oklch(var(--bc)/0.5); }
.full-rt-table td:first-child { color: oklch(var(--bc)/0.3); font-family: monospace; font-size: .72rem; }
.full-metrics { display: grid; grid-template-columns: repeat(3,1fr); gap: 6px; margin: 8px 0 0; }
.full-metric  { display: flex; flex-direction: column; gap: 2px; }
.full-metric-label { font-size: .65rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: oklch(var(--bc)/0.3); }
.full-metric-value { font-size: 1rem; font-weight: 700; color: oklch(var(--bc)); line-height: 1; }

/* ═══ CLIENT FILTER DROPDOWN ═════════════════════════════════════════════════ */
.client-filter-bar {
  display: flex; align-items: center; gap: 14px;
  margin-bottom: 22px; padding: 12px 18px;
  background: oklch(var(--b2)); border: 1px solid oklch(var(--b3));
  border-radius: var(--radius-lg); flex-wrap: wrap;
}
.client-filter-label {
  display: flex; align-items: center; gap: 7px;
  font-size: 12px; font-weight: 700; color: oklch(var(--bc)/0.45);
  text-transform: uppercase; letter-spacing: .04em; white-space: nowrap;
}
.filter-dropdown { position: relative; display: inline-block; }
.filter-dropdown-toggle {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 14px; border: 1px solid oklch(var(--b3));
  border-radius: 8px; background: oklch(var(--b3));
  color: oklch(var(--bc)); font-size: 13px; cursor: pointer;
  min-width: 200px; transition: all .18s;
}
.filter-dropdown-toggle:hover { border-color: oklch(var(--p)/0.4); }
.filter-dropdown-toggle .toggle-count {
  margin-left: auto; font-size: 11px;
  background: oklch(var(--p)/0.15); color: oklch(var(--p));
  padding: 1px 8px; border-radius: 10px; font-weight: 600;
}
.filter-dropdown-toggle .toggle-arrow { margin-left: 4px; font-size: 10px; color: oklch(var(--bc)/0.4); transition: transform .18s; }
.filter-dropdown.open .toggle-arrow { transform: rotate(180deg); }
.filter-dropdown-menu {
  display: none; position: absolute; top: calc(100% + 6px); left: 0;
  min-width: 240px; max-height: 320px; overflow-y: auto;
  background: oklch(var(--b2)); border: 1px solid oklch(var(--b3));
  border-radius: 8px; box-shadow: 0 8px 32px rgba(0,0,0,.4);
  z-index: 100; padding: 6px;
}
.filter-dropdown.open .filter-dropdown-menu { display: block; }
.filter-dropdown-menu .filter-actions {
  display: flex; gap: 8px; padding: 6px 8px 10px;
  border-bottom: 1px solid oklch(var(--b3)); margin-bottom: 4px;
}
.filter-dropdown-menu .filter-actions button {
  font-size: 11px; color: oklch(var(--p)); background: none;
  border: none; cursor: pointer; padding: 2px 0; font-weight: 600;
}
.filter-dropdown-menu .filter-actions button:hover { text-decoration: underline; }
.filter-check-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 6px; cursor: pointer;
  font-size: 13px; color: oklch(var(--bc)); transition: background .12s;
}
.filter-check-item:hover { background: oklch(var(--b3)); }
.filter-check-item input[type="checkbox"] {
  width: 16px; height: 16px; accent-color: oklch(var(--p)); flex-shrink: 0;
}
.filter-check-item .filter-item-name { flex: 1; }
.filter-check-item .filter-item-count {
  font-size: 11px; color: oklch(var(--bc)/0.4);
  background: oklch(var(--b3)); padding: 1px 7px; border-radius: 10px;
}
.filter-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.filter-tag {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px; border-radius: 14px; font-size: 11px; font-weight: 600;
  background: oklch(var(--p)/0.12); border: 1px solid oklch(var(--p)/0.25);
  color: oklch(var(--p));
}
.filter-tag-remove { cursor: pointer; font-size: 14px; opacity: .6; transition: opacity .12s; }
.filter-tag-remove:hover { opacity: 1; }

/* ═══ MISC ════════════════════════════════════════════════════════════════════ */
.nav-badge { margin-left: auto; }
.text-danger { color: var(--red); }
.text-muted  { color: oklch(var(--bc)/0.5); }
.ev-id       { font-family: monospace; font-size: 10px; color: oklch(var(--bc)/0.25); }
.inline-pre  { font-size: .72rem; white-space: pre-wrap; max-height: 100px; overflow-y: auto; background: oklch(var(--b3)); padding: 6px; border-radius: 4px; }

@keyframes pulse-opacity { 0%,100%{opacity:1} 50%{opacity:.5} }
@keyframes pulse { 0%,100%{box-shadow:0 0 0 0 rgba(240,160,0,.4)} 50%{box-shadow:0 0 0 6px rgba(240,160,0,.0)} }

/* ═══ RESPONSIVE ═════════════════════════════════════════════════════════════ */
@media (max-width: 700px) {
  .rt-grid   { grid-template-columns: 1fr; }
  .cards-grid { grid-template-columns: 1fr; }
  .metrics-grid { grid-template-columns: repeat(3,1fr); }
  .metric-value { font-size: 28px; }
  .metric-icon  { width: 32px; height: 32px; border-radius: 8px; }
  .metric-icon svg { width: 16px; height: 16px; }
  .filter-row { flex-direction: column; }
}

/* ═══ TV MODE ════════════════════════════════════════════════════════════════ */
body.tv-mode .drawer-side   { display: none !important; }
body.tv-mode .navbar         { display: none !important; }
body.tv-mode #flash-area     { display: none !important; }
body.tv-mode .drawer {
  grid-template-columns: 0 1fr !important;
}
body.tv-mode .drawer-content main {
  padding: 8px 10px !important;
  height: 100vh;
  overflow: hidden;
}
body.tv-mode .legend,
body.tv-mode .client-filter-bar { display: none !important; }

body.tv-mode #cards-container,
body.tv-mode #rt-container,
body.tv-mode #full-container {
  display: grid !important;
  grid-auto-rows: max-content !important;
  gap: 7px !important;
  align-content: start;
  height: calc(100vh - 28px);
  overflow: hidden;
}
body.tv-mode .client-section,
body.tv-mode .rt-section,
body.tv-mode .full-section,
body.tv-mode .cards-grid,
body.tv-mode .rt-grid,
body.tv-mode .full-grid {
  display: contents !important;
  border: none !important; background: none !important;
  box-shadow: none !important; padding: 0 !important; margin: 0 !important;
}
body.tv-mode .client-section-header,
body.tv-mode .rt-section-header,
body.tv-mode .full-section-header { display: none !important; }

body.tv-mode .server-card,
body.tv-mode .rt-card,
body.tv-mode .full-card {
  padding: 8px 11px !important; margin: 0 !important;
  position: relative; height: auto; min-height: 0;
  display: flex; flex-direction: column; overflow: hidden;
}
body.tv-mode .card-footer,
body.tv-mode .rt-card-footer { margin-top: auto !important; }
body.tv-mode .server-card::before,
body.tv-mode .rt-card::before,
body.tv-mode .full-card::before {
  content: attr(data-client);
  display: block; font-size: .58rem; font-weight: 800;
  letter-spacing: .08em; text-transform: uppercase;
  color: oklch(var(--p)); margin: -1px 0 5px;
  padding-bottom: 3px; border-bottom: 1px solid oklch(var(--b3));
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
body.tv-mode .metrics-grid  { gap: 6px !important; margin: auto 0 !important; }
body.tv-mode .metric-value  { font-size: 22px !important; }
body.tv-mode .metric-label  { font-size: .66rem !important; }
body.tv-mode .metric-unit   { font-size: .7rem !important; }
body.tv-mode .metric-icon   { width: 36px !important; height: 36px !important; margin-bottom: 6px !important; }
body.tv-mode .progress-bar  { height: 4px !important; margin-top: 5px !important; }
body.tv-mode .card-footer, body.tv-mode .rt-card-footer { font-size: .68rem !important; padding-top: 4px !important; margin-top: 6px !important; }
body.tv-mode .hostname      { font-size: .85rem !important; }
body.tv-mode .srv-icon      { width: 26px !important; height: 26px !important; border-radius: 6px !important; }
body.tv-mode .srv-icon svg  { width: 14px !important; height: 14px !important; }
body.tv-mode .card-header, body.tv-mode .rt-card-header { margin-bottom: 8px !important; }
body.tv-mode .rt-sites-table { font-size: .72rem !important; }
body.tv-mode .rt-sites-table th, body.tv-mode .rt-sites-table td { padding: 2px 4px !important; }
body.tv-mode .rt-time       { font-size: .82rem !important; }
body.tv-mode .full-metrics  { gap: 5px !important; margin: 6px 0 0 !important; }
body.tv-mode .full-metric-value { font-size: 1.05rem !important; }
body.tv-mode .full-metric-label { font-size: .6rem !important; }
body.tv-mode .full-rt-divider   { margin: 5px 0 3px !important; }
body.tv-mode .full-rt-table td  { padding: 1px 4px !important; }

/* TV controls */
.tv-exit-btn {
  position: fixed; top: 10px; right: 14px; z-index: 9999;
  display: none; align-items: center; gap: 6px;
  background: oklch(var(--b2)/0.9); border: 1px solid oklch(var(--b3));
  color: oklch(var(--bc)/0.6); padding: 5px 12px;
  border-radius: var(--radius); font-size: .8rem; cursor: pointer;
  backdrop-filter: blur(8px); transition: color .15s, border-color .15s;
}
.tv-exit-btn:hover { color: oklch(var(--bc)); border-color: oklch(var(--p)); }
body.tv-mode .tv-exit-btn { display: flex; }

.tv-page-indicator {
  position: fixed; bottom: 12px; left: 50%; transform: translateX(-50%);
  z-index: 9999; display: none; gap: 8px; align-items: center;
  background: oklch(var(--b2)/0.85); border: 1px solid oklch(var(--b3));
  padding: 4px 16px; border-radius: 20px; font-size: .78rem;
  color: oklch(var(--bc)/0.5); backdrop-filter: blur(6px);
}
body.tv-mode .tv-page-indicator { display: flex; }
.tv-dots { display: flex; gap: 5px; align-items: center; }
.tv-dot  { width: 6px; height: 6px; border-radius: 50%; background: oklch(var(--b3)); transition: background .3s, transform .3s; }
.tv-dot.active { background: oklch(var(--p)); transform: scale(1.4); }
.tv-page-transition { animation: tvFadeIn .3s ease; }
@keyframes tvFadeIn { from{opacity:0;transform:translateY(5px)} to{opacity:1;transform:translateY(0)} }

.tv-timer-bar {
  position: fixed; bottom: 0; left: 0;
  height: 2px; background: oklch(var(--p));
  z-index: 9999; display: none; transition: width linear;
}
body.tv-mode .tv-timer-bar { display: block; }

.tv-config {
  position: fixed; bottom: 10px; right: 14px; z-index: 9999;
  display: none; align-items: center; gap: 10px;
  background: oklch(var(--b2)/0.9); border: 1px solid oklch(var(--b3));
  padding: 5px 12px; border-radius: var(--radius); font-size: .74rem;
  color: oklch(var(--bc)/0.5); backdrop-filter: blur(8px);
}
body.tv-mode .tv-config { display: flex; }
.tv-config.is-auto .tv-config-grp { opacity: .45; }
.tv-config-auto { display: flex; align-items: center; gap: 5px; cursor: pointer; user-select: none; }
.tv-config-auto input { accent-color: oklch(var(--p)); cursor: pointer; }
.tv-config-grp  { display: flex; align-items: center; gap: 4px; }
.tv-config-lbl  { color: oklch(var(--bc)/0.3); text-transform: uppercase; letter-spacing: .05em; font-size: .66rem; }
.tv-config-grp button {
  width: 20px; height: 20px; line-height: 1;
  border: 1px solid oklch(var(--b3)); background: oklch(var(--b2));
  color: oklch(var(--bc)); border-radius: 5px; cursor: pointer; font-size: .9rem; padding: 0;
}
.tv-config-grp button:hover { border-color: oklch(var(--p)); color: oklch(var(--p)); }
.tv-config-grp input[type="number"] {
  width: 34px; text-align: center; background: oklch(var(--b2));
  border: 1px solid oklch(var(--b3)); color: oklch(var(--bc));
  border-radius: 5px; padding: 2px 0; font-size: .76rem;
  -moz-appearance: textfield;
}
.tv-config-grp input[type="number"]::-webkit-inner-spin-button,
.tv-config-grp input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.tv-config-grp input[disabled] { opacity: .5; cursor: not-allowed; }
body.tv-mode.tv-idle .tv-config,
body.tv-mode.tv-idle .tv-exit-btn { opacity: 0; pointer-events: none; transition: opacity 0.5s; }
body.tv-mode .tv-config,
body.tv-mode .tv-exit-btn { transition: opacity 0.2s; }
.tv-htmx-swapping { opacity: 0 !important; transition: opacity 0.15s; }
