/* ==========================================================================
   Design tokens - dark is the default/primary theme; :root carries dark
   values directly (not inside a media query) so an unconfigured page
   shows dark immediately, no flash. Light is an override, either
   explicit (data-theme="light") or via prefers-color-scheme when no
   explicit choice has been made yet (:root:not([data-theme])).
   ========================================================================== */

:root {
  --bg-page: #0b0e14;
  --bg-header: #11151d;
  --bg-sidebar: #11151d;
  --bg-card: #151a23;
  --bg-card-elevated: #1a212c;
  --bg-input: #0f1319;
  --bg-hover: #1c2330;
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text-primary: #eef1f6;
  --text-secondary: #aab2c0;
  --text-muted: #6b7383;
  --accent: #4c8dff;
  --accent-hover: #6ea1ff;
  --success: #35c97a;
  --warning: #e4a63a;
  --danger: #f0605b;
  --info: #4c8dff;
  /* Read by chart-scale-consuming canvas code via getComputedStyle() at
     draw time (canvas has no CSS cascade of its own) - dark-theme grid
     lines are white-based and visible against the near-black
     --bg-input; the light-theme overrides below flip this to a dark-
     based line, since a white line at low opacity is invisible on a
     near-white background (confirmed missing in a prior audit). */
  --chart-grid: rgba(255, 255, 255, 0.12);
  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.35);
  --radius: 14px;
  --radius-sm: 8px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --header-height: 56px;
  --bottom-nav-height: 60px;
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    --bg-page: #f4f6f9;
    --bg-header: #ffffff;
    --bg-sidebar: #ffffff;
    --bg-card: #ffffff;
    --bg-card-elevated: #ffffff;
    --bg-input: #f4f6f9;
    --bg-hover: #eef1f6;
    --border-subtle: rgba(15, 23, 42, 0.14);
    --border-strong: rgba(15, 23, 42, 0.28);
    --text-primary: #10151f;
    --text-secondary: #4b5563;
    --text-muted: #8a93a3;
    --chart-grid: rgba(15, 23, 42, 0.14);
    --shadow-card: 0 1px 2px rgba(15, 23, 42, 0.06), 0 6px 18px rgba(15, 23, 42, 0.08);
    color-scheme: light;
  }
}

:root[data-theme="light"] {
  --bg-page: #f4f6f9;
  --bg-header: #ffffff;
  --bg-sidebar: #ffffff;
  --bg-card: #ffffff;
  --bg-card-elevated: #ffffff;
  --bg-input: #f4f6f9;
  --bg-hover: #eef1f6;
  --border-subtle: rgba(15, 23, 42, 0.14);
  --border-strong: rgba(15, 23, 42, 0.28);
  --text-primary: #10151f;
  --text-secondary: #4b5563;
  --text-muted: #8a93a3;
  --chart-grid: rgba(15, 23, 42, 0.14);
  --shadow-card: 0 1px 2px rgba(15, 23, 42, 0.06), 0 6px 18px rgba(15, 23, 42, 0.08);
  color-scheme: light;
}

/* Fixes the bug where any element also carrying a `display` value from a
   class (e.g. `.tabs { display: flex }`) ignored the `hidden` attribute -
   author-origin `display` rules otherwise beat the UA default
   `[hidden] { display: none }` at equal specificity. Applies globally so
   this class of bug can't recur on a new component. */
[hidden] { display: none !important; }

/* Generic fallback so any focusable element gets a visible ring even
   where no component-specific :focus-visible rule exists; more specific
   selectors elsewhere (e.g. .nav-item:focus-visible) still take
   precedence via specificity, this only fills gaps. */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Applied for exactly one focus event when JS restores focus to a modal's
   opener button after a mouse-driven close - without this, browsers can
   mark that script-triggered .focus() call as focus-visible even though
   the whole interaction was pointer-driven, leaving a ring on a button
   the user only ever clicked. */
.suppress-focus-ring:focus-visible { outline: none; }

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  background: var(--bg-page);
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  overflow-x: hidden;
}

h1, h2, h3, p { margin: 0; }

/* Typography scale */
.text-page-title { font-size: 20px; font-weight: 700; letter-spacing: -0.01em; }
.text-section-title { font-size: 15px; font-weight: 700; }
.text-card-title { font-size: 14px; font-weight: 700; color: var(--text-primary); }
.text-body { font-size: 14px; color: var(--text-primary); }
.text-secondary { font-size: 13px; color: var(--text-secondary); }
.text-muted { font-size: 12px; color: var(--text-muted); }
.text-metric { font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }
.text-badge { font-size: 11px; font-weight: 700; text-transform: none; }

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--accent);
  color: #fff;
  padding: 8px 12px;
  z-index: 200;
  border-radius: 0 0 var(--radius-sm) 0;
}
.skip-link:focus { left: 0; }

::selection { background: rgba(76, 141, 255, 0.35); }

@media (prefers-reduced-motion: no-preference) {
  * { scrollbar-color: var(--border-strong) transparent; }
}
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 999px; }
::-webkit-scrollbar-track { background: transparent; }

/* ==========================================================================
   App shell / header
   ========================================================================== */

.app-shell { display: flex; flex-direction: column; min-height: 100vh; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: var(--safe-top) 16px 0;
  background: var(--bg-header);
  border-bottom: 1px solid var(--border-subtle);
}
.topbar-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.topbar-brand { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.topbar-brand .name { font-size: 14px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-brand .place { font-size: 11px; color: var(--text-muted); }

.status-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.status-dot.ok { background: var(--success); box-shadow: 0 0 0 3px rgba(53, 201, 122, 0.18); }
.status-dot.warn { background: var(--warning); box-shadow: 0 0 0 3px rgba(228, 166, 58, 0.18); }
.status-dot.bad { background: var(--danger); box-shadow: 0 0 0 3px rgba(240, 96, 91, 0.18); }
.status-dot.unknown { background: var(--text-muted); }

.updated-chip {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}
.updated-chip[data-stale="true"] { color: var(--warning); }

/* User menu */
.user-menu { position: relative; }
.user-menu-button {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 4px 10px 4px 4px;
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-card);
  color: var(--text-primary);
  cursor: pointer;
}
.user-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
}
.user-menu-popover {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 220px;
  background: var(--bg-card-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 8px;
  z-index: 30;
}
.user-menu-popover .menu-item {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: none;
  background: none;
  color: var(--text-primary);
  font-size: 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: left;
  min-height: 40px;
}
.user-menu-popover .menu-item:hover,
.user-menu-popover .menu-item:focus-visible { background: var(--bg-hover); }
.user-menu-popover .menu-section-label {
  font-size: 11px;
  color: var(--text-muted);
  padding: 8px 12px 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.user-menu-popover .theme-options { display: flex; gap: 4px; padding: 4px 8px 8px; }
.theme-option {
  flex: 1;
  min-height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--bg-input);
  color: var(--text-secondary);
  font-size: 12px;
  cursor: pointer;
}
.theme-option[aria-pressed="true"] { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ==========================================================================
   Banners
   ========================================================================== */

.banner {
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}
.banner a, .banner .btn-link { color: inherit; text-decoration: underline; }
.banner-warn { background: rgba(228, 166, 58, 0.14); color: var(--warning); }
.banner-error { background: rgba(240, 96, 91, 0.14); color: var(--danger); }

/* ==========================================================================
   Navigation - desktop single row, medium with popover "Ещё", mobile
   bottom nav + bottom sheet. Root cause of the old "Ещё does nothing"
   bug: an element with both `.tabs` (display:flex) and `[hidden]` never
   actually hid, because the global [hidden] rule above didn't exist yet.
   ========================================================================== */

.nav-desktop {
  display: none;
  gap: 2px;
  padding: 0 16px;
  background: var(--bg-header);
  border-bottom: 1px solid var(--border-subtle);
}
.nav-item {
  min-height: 44px;
  padding: 0 14px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 2px solid transparent;
}
.nav-item:hover { color: var(--text-primary); }
.nav-item[aria-current="page"] { color: var(--accent); border-bottom-color: var(--accent); }
.nav-item:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

.nav-more-wrap { position: relative; }
.nav-more-popover {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 200px;
  background: var(--bg-card-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 6px;
  z-index: 30;
}
.nav-more-popover .nav-item {
  display: block;
  width: 100%;
  text-align: left;
  border-radius: var(--radius-sm);
  border-bottom: none;
}
.nav-more-popover .nav-item:hover,
.nav-more-popover .nav-item:focus-visible { background: var(--bg-hover); }

@media (min-width: 900px) {
  .nav-desktop.nav-desktop-wide { display: flex; }
  .nav-desktop.nav-desktop-wide .nav-more-wrap { display: none; }
  .nav-desktop.nav-desktop-medium { display: none; }
}
@media (min-width: 640px) and (max-width: 899px) {
  .nav-desktop.nav-desktop-medium { display: flex; }
}
@media (max-width: 639px) {
  .nav-desktop { display: none; }
}

/* Mobile bottom nav - display:none is the base/desktop state; shown only
   under 640px (below). Deliberately NOT the other way around (base
   display:flex + a ">=900px { display:none }" override) - CSS source
   order matters for equal-specificity rules, and an unconditional
   `display` declared later in the file always wins regardless of which
   media query "should" apply, which is exactly the bug that made the
   old two-row nav impossible to fix by only touching [hidden]. */
.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: none;
  background: var(--bg-header);
  border-top: 1px solid var(--border-subtle);
  padding-bottom: var(--safe-bottom);
}
@media (max-width: 639px) {
  .bottom-nav { display: flex; }
}
.bottom-nav-item {
  flex: 1;
  min-height: var(--bottom-nav-height);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border: none;
  background: none;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}
.bottom-nav-item[aria-current="page"] { color: var(--accent); }
.bottom-nav-item .dot { width: 6px; height: 6px; }

/* Bottom sheet ("Ещё" on mobile) */
.sheet-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 40;
}
.bottom-sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 41;
  background: var(--bg-card-elevated);
  border-radius: 20px 20px 0 0;
  padding: 8px 8px calc(16px + var(--safe-bottom));
  box-shadow: var(--shadow-card);
}
.bottom-sheet-handle {
  width: 36px; height: 4px; border-radius: 999px;
  background: var(--border-strong);
  margin: 8px auto 12px;
}
.bottom-sheet .menu-item {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  padding: 10px 16px;
  border: none;
  background: none;
  color: var(--text-primary);
  font-size: 15px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: left;
}
.bottom-sheet .menu-item:hover,
.bottom-sheet .menu-item:focus-visible { background: var(--bg-hover); }
.bottom-sheet .menu-item[aria-current="page"] { color: var(--accent); }

/* Info modal (help drawer) - unlike the bottom sheet, this is shown at
   ALL widths, so it gets its own overlay class rather than reusing
   .sheet-overlay (which is deliberately mobile-only). Inherits the
   current theme like every other component here - no separate
   unstyled page. */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 50;
}
.info-modal {
  position: fixed;
  z-index: 51;
  background: var(--bg-card-elevated);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-card);
  color: var(--text-primary);
  overflow-y: auto;
}
.info-modal-header {
  display: flex;
  justify-content: flex-end;
  padding: 10px;
  position: sticky;
  top: 0;
  background: var(--bg-card-elevated);
}
.info-modal-body { padding: 4px 24px 24px; }
.info-modal-body h2 { font-size: 17px; margin-bottom: 10px; }
.info-modal-body p { font-size: 14px; color: var(--text-secondary); line-height: 1.5; margin: 0 0 12px; }
.info-modal-body p:last-child { margin-bottom: 0; }

@media (min-width: 640px) {
  .info-modal {
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 480px;
    max-height: 80vh;
    border-radius: var(--radius);
  }
}
@media (max-width: 639px) {
  .info-modal {
    left: 0;
    right: 0;
    bottom: 0;
    max-height: 80vh;
    border-radius: 20px 20px 0 0;
    padding-bottom: var(--safe-bottom);
  }
}

@media (min-width: 640px) {
  .sheet-overlay, .bottom-sheet { display: none !important; }
}

/* ==========================================================================
   Layout
   ========================================================================== */

#main-content {
  flex: 1;
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 20px 16px calc(24px + var(--safe-bottom));
}
@media (max-width: 639px) {
  #main-content { padding: 14px 12px calc(var(--bottom-nav-height) + 16px + var(--safe-bottom)); }
}

.tab-panel[hidden] { display: none; }

.row { display: grid; gap: 12px; margin-bottom: 12px; }
.row-3 { grid-template-columns: repeat(3, 1fr); }
.row-4 { grid-template-columns: repeat(4, 1fr); }
.row-wide-plus-two { grid-template-columns: 2fr 1fr 1fr; }
@media (max-width: 899px) {
  .row-3, .row-4, .row-wide-plus-two { grid-template-columns: 1fr; }
}
@media (min-width: 640px) and (max-width: 899px) {
  .row-3, .row-4 { grid-template-columns: repeat(2, 1fr); }
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
  /* Grid rows stretch same-row items to equal height by default - that's
     what turned Diagnostics (5 cards of very different natural heights)
     into a layout with huge empty columns. Each card sizes to its own
     content instead. */
  align-items: start;
}

/* Alert-log cards (long, variable-width text) get their own full-width
   row instead of being squeezed into one ~280px grid column, which is
   what turned their content into a narrow vertical ribbon. */
.card-wide { grid-column: 1 / -1; }

/* ==========================================================================
   Cards
   ========================================================================== */

.card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 16px;
  min-height: 120px;
  display: flex;
  flex-direction: column;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.card:hover, .card:focus-within { border-color: var(--border-strong); }
.card-elevated { background: var(--bg-card-elevated); }
.diag-card-compact .card-header { margin-bottom: 8px; }
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  gap: 8px;
}
.card-footer {
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid var(--border-subtle);
  font-size: 12px;
  color: var(--text-muted);
}

.metric-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px solid transparent;
}
.metric-row .label { font-size: 13px; color: var(--text-secondary); }
.metric-row .value {
  font-size: 14px;
  font-weight: 600;
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
/* Explicit opt-in for values that ARE long and should wrap (masked SSH
   addresses, error text) - short numeric metrics like "0,44 Мбит/с"
   must never break mid-value. */
.metric-row .value.value-wrap { white-space: normal; overflow-wrap: break-word; text-overflow: clip; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; }
.badge-ok { background: rgba(53, 201, 122, 0.14); color: var(--success); }
.badge-ok::before { background: var(--success); }
.badge-warn { background: rgba(228, 166, 58, 0.14); color: var(--warning); }
.badge-warn::before { background: var(--warning); }
.badge-bad { background: rgba(240, 96, 91, 0.14); color: var(--danger); }
.badge-bad::before { background: var(--danger); }
.badge-unknown { background: var(--bg-hover); color: var(--text-muted); }
.badge-unknown::before { background: var(--text-muted); }

.progress { height: 8px; border-radius: 999px; background: var(--bg-input); overflow: hidden; margin: 6px 0 4px; }
.progress-fill { height: 100%; width: 0%; background: var(--success); transition: width 0.3s ease; }
.progress-fill.warn { background: var(--warning); }
.progress-fill.bad { background: var(--danger); }

.muted { color: var(--text-muted); font-size: 13px; }
.empty-state { color: var(--text-muted); font-size: 13px; padding: 10px 0; }
.empty-card { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }

/* ==========================================================================
   Buttons / inputs
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-block { width: 100%; }
.btn-secondary { background: var(--bg-hover); color: var(--text-primary); border-color: var(--border-subtle); }
.btn-danger { background: rgba(240, 96, 91, 0.14); color: var(--danger); border-color: rgba(240, 96, 91, 0.3); }
.btn-ghost { background: transparent; color: var(--text-secondary); border-color: var(--border-subtle); }
.btn-link { background: none; color: var(--accent); text-decoration: underline; min-height: 32px; padding: 4px 2px; border-radius: var(--radius-sm); }
.btn-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; min-height: 40px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-input);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.btn-icon:hover, .btn-icon[aria-pressed="true"] { color: var(--text-primary); background: var(--bg-hover); }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--text-secondary); margin-bottom: 6px; }
.field input {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 15px;
}
.field input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.password-field { position: relative; display: flex; gap: 6px; }
.password-field input { flex: 1; }

.spinner {
  width: 16px; height: 16px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .spinner { animation: none; }
  .progress-fill { transition: none; }
}

.inline-alert {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-top: 12px;
}
.inline-alert-error { background: rgba(240, 96, 91, 0.12); color: var(--danger); }
.inline-alert-neutral { background: var(--bg-hover); color: var(--text-secondary); }
.inline-alert-neutral strong { color: var(--text-primary); }
.btn-spaced-top { margin-top: 10px; }

/* ==========================================================================
   Login screen - shares the app shell's background/tokens
   ========================================================================== */

.login-body { align-items: center; justify-content: center; }
.login-card {
  width: 100%;
  max-width: 380px;
  margin: 10vh auto;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 28px;
}
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.brand-badge {
  width: 36px; height: 36px; border-radius: 10px;
  background: var(--accent);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
}
.login-title { font-size: 18px; font-weight: 700; }
.login-subtitle { font-size: 12px; color: var(--text-muted); }
.login-footnote { margin-top: 18px; font-size: 12px; color: var(--text-muted); text-align: center; }

/* ==========================================================================
   Diagnostics / lists / incidents
   ========================================================================== */

.incident-list, .diag-list { list-style: none; margin: 0; padding: 0; }
.incident-list li, .diag-list li {
  padding: 10px 0;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 13px;
}
.incident-list li:last-child, .diag-list li:last-child { border-bottom: none; }
.list-row { display: flex; justify-content: space-between; gap: 10px; }
.list-row .primary { font-weight: 600; }

/* Alert items (severity + translated text) get a compact meta-line for
   the timestamp instead of a cramped space-between right column - that
   combination is what squeezed long alert text into a narrow ribbon on
   anything less than a very wide card. */
.alert-meta { font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }
.alert-row { display: flex; align-items: flex-start; gap: 8px; flex-wrap: wrap; }
.alert-text { flex: 1 1 260px; min-width: 0; }

.filter-select {
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  font-size: 12px;
}
.filter-select:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* Legacy VPS alert lines are translated to plain Russian by default; the
   untouched original line is only ever revealed behind this toggle. */
.alert-details { margin-top: 4px; }
.alert-details summary {
  cursor: pointer;
  font-size: 12px;
  color: var(--accent);
  list-style: none;
  border-radius: var(--radius-sm);
}
.alert-details summary::-webkit-details-marker { display: none; }
/* <summary> keeps its own UA default focus ring in some browsers even
   with an author :focus-visible outline set elsewhere - override it
   explicitly, in the interface's own accent/radius, instead of relying
   on the generic fallback to reach a non-standard interactive element. */
.alert-details summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.alert-details[open] summary { margin-bottom: 6px; }
.alert-raw {
  margin: 0;
  padding: 8px 10px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  font-size: 11px;
  color: var(--text-secondary);
  white-space: pre-wrap;
  word-break: break-word;
}

/* ==========================================================================
   Charts
   ========================================================================== */

/* height is intentionally not a bare fixed px on every breakpoint - see
   the responsive rules below - but always has *some* explicit height so
   ResizeObserver has a stable box to report before the first draw. */
canvas.line-chart {
  width: 100%;
  height: 160px;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  display: block;
  cursor: crosshair;
}
@media (max-width: 639px) {
  canvas.line-chart { height: 180px; }
}
.chart-legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12px; color: var(--text-muted); margin-top: 8px; }
.chart-legend span { display: flex; align-items: center; gap: 6px; }
.legend-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: none; }
.legend-cpu { background: var(--accent); }
.legend-ram { background: var(--success); }
.legend-rx { background: var(--warning); }
.legend-tx { background: var(--danger); }
/* Current value shown right in the legend, next to its own dot/label -
   updated on every refresh so the number nearest the eye is always the
   live one, not just a trend line with no readable current figure. */
.legend-value { font-variant-numeric: tabular-nums; color: var(--text-primary); font-weight: 600; }

/* Real statistical min/avg/max for the visible window, not just scale
   midpoints - read directly from the same data the line is drawn from. */
.chart-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}

/* Custom tooltip for hover/tap on a chart - deliberately not a native
   <title> (no touch support, inconsistent styling) and not a charting
   library (CSP/bundle-size constraints) - one shared floating element,
   repositioned per chart, plain text content only (no HTML injection
   surface). */
.chart-tooltip {
  position: fixed;
  z-index: 40;
  pointer-events: none;
  background: var(--bg-card-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-card);
  padding: 6px 10px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-primary);
  white-space: nowrap;
}
@media (prefers-reduced-motion: no-preference) {
  .chart-tooltip { transition: opacity 0.1s ease; }
}
@media (prefers-reduced-motion: reduce) {
  .chart-tooltip { transition: none; }
}

.footer { text-align: center; padding: 16px; }

.skeleton-row {
  height: 14px;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--bg-hover) 25%, var(--border-strong) 50%, var(--bg-hover) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.4s ease infinite;
  margin: 8px 0;
}
@keyframes skeleton-shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .skeleton-row { animation: none; } }

@media (max-width: 380px) {
  .card-grid { grid-template-columns: 1fr; }
}
