/**
 * Unified Monitoring Dashboard Stylesheet
 * Tone & Aesthetics:
 * - Netdata chart density & precision
 * - Datadog structured cards, padding, and subtle borders
 * - LM Studio GUI sleek sidebar, active tabs, and dark/light themes
 */

/* ==========================================================================
   1. Theme Variables & Typography
   ========================================================================== */

:root {
  /* System Font Stack */
  --font-sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  /* Layout dimensions */
  --sidebar-width: 250px;
  --sidebar-collapsed-width: 64px;
  --topbar-height: 56px;

  /* Transitions */
  --transition-speed: 0.18s;
}

/* Dark Theme (Default) */
:root, [data-theme="dark"] {
  --bg-app: #090d16;
  --bg-surface: #0f172a;
  --bg-surface-elevated: #1e293b;
  --bg-surface-hover: #26354a;
  --border-color: #1e293b;
  --border-subtle: #334155;

  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  /* Status Colors */
  --color-success: #10b981;
  --color-success-bg: rgba(16, 185, 129, 0.12);
  --color-warning: #f59e0b;
  --color-warning-bg: rgba(245, 158, 11, 0.14);
  --color-critical: #ef4444;
  --color-critical-bg: rgba(239, 68, 68, 0.16);
  --color-stopped: #64748b;
  --color-stopped-bg: rgba(100, 116, 139, 0.14);

  --color-primary: #3b82f6;
  --color-primary-hover: #2563eb;
  --color-primary-bg: rgba(59, 130, 246, 0.15);

  --card-shadow: 0 1px 3px rgba(0, 0, 0, 0.4), 0 1px 2px rgba(0, 0, 0, 0.3);
}

/* Light Theme */
[data-theme="light"] {
  --bg-app: #f1f5f9;
  --bg-surface: #ffffff;
  --bg-surface-elevated: #f8fafc;
  --bg-surface-hover: #e2e8f0;
  --border-color: #e2e8f0;
  --border-subtle: #cbd5e1;

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;

  /* Status Colors */
  --color-success: #059669;
  --color-success-bg: #ecfdf5;
  --color-warning: #d97706;
  --color-warning-bg: #fffbeb;
  --color-critical: #dc2626;
  --color-critical-bg: #fef2f2;
  --color-stopped: #475569;
  --color-stopped-bg: #f1f5f9;

  --color-primary: #2563eb;
  --color-primary-hover: #1d4ed8;
  --color-primary-bg: #eff6ff;

  --card-shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
}

/* ==========================================================================
   2. Base Reset & Typography
   ========================================================================== */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  height: 100%;
  min-width: 0;
  overflow: hidden;
  font-family: var(--font-sans);
  background-color: var(--bg-app);
  color: var(--text-primary);
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Numbers: Tabular digits to avoid jitter */
.font-mono, .stat-value, .metric-number, .header-live-val, td.text-right {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

a {
  color: inherit;
  text-decoration: none;
}

button, input, select {
  font-family: inherit;
  font-size: inherit;
}

/* Accessible Focus Ring */
*:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ==========================================================================
   3. Application Shell & Layout
   ========================================================================== */

.app-shell {
  display: flex;
  height: 100vh;
  height: 100dvh;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
}

/* Overlay for Mobile Drawer */
.drawer-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  z-index: 99;
}

/* --------------------------------------------------------------------------
   Sidebar (LM Studio style)
   -------------------------------------------------------------------------- */

.app-sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  flex: 0 0 var(--sidebar-width);
  height: 100%;
  background-color: var(--bg-surface);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  transition: width var(--transition-speed) ease, min-width var(--transition-speed) ease;
  z-index: 100;
  user-select: none;
}

/* Sidebar Top Status Header */
.sidebar-status-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sidebar-status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-brand-title {
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-primary);
}

.sidebar-update-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Sidebar Nav Links */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  display: flex;
  flex-direction: column;
}

.nav-row {
  display: flex;
  align-items: center;
}

.nav-row .nav-link {
  flex: 1;
  min-width: 0;
}

.nav-arrow-button {
  width: 28px;
  height: 28px;
  margin-right: 4px;
  padding: 7px;
  border: 0;
  border-radius: 5px;
  color: var(--text-muted);
  background: transparent;
  cursor: pointer;
}

.nav-arrow-button:hover {
  color: var(--text-primary);
  background: var(--bg-surface-hover);
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border-radius: 6px;
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
  transition: background-color var(--transition-speed), color var(--transition-speed);
  cursor: pointer;
}

.nav-link:hover {
  background-color: var(--bg-surface-hover);
  color: var(--text-primary);
}

.nav-link.active {
  background-color: var(--color-primary-bg);
  color: var(--color-primary);
  font-weight: 600;
}

.nav-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.nav-label {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-arrow {
  width: 14px;
  height: 14px;
  transition: transform var(--transition-speed);
}

/* Sidebar Container Sub-tree Accordion */
.sidebar-submenu {
  display: none;
  flex-direction: column;
  padding-left: 20px;
  padding-top: 4px;
  gap: 4px;
}

.nav-item.open .sidebar-submenu {
  display: flex;
}

.nav-item.open .nav-arrow {
  transform: rotate(90deg);
}

.sidebar-cnt-search {
  padding: 4px 6px;
  margin-bottom: 4px;
}

.sidebar-cnt-search input {
  width: 100%;
  padding: 5px 8px;
  font-size: 0.75rem;
  border-radius: 4px;
  border: 1px solid var(--border-color);
  background: var(--bg-surface-elevated);
  color: var(--text-primary);
}

.sidebar-cnt-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 200px;
  overflow-y: auto;
}

.sidebar-cnt-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 4px;
  font-size: 0.8rem;
  color: var(--text-secondary);
  cursor: pointer;
}

.sidebar-cnt-item:hover {
  background: var(--bg-surface-hover);
  color: var(--text-primary);
}

.sidebar-cnt-item.active {
  background: var(--color-primary-bg);
  color: var(--color-primary);
  font-weight: 600;
}

.cnt-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.sidebar-cnt-empty {
  padding: 6px 8px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Sidebar Footer (Collapse Toggle) */
.sidebar-footer {
  padding: 10px 12px;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

/* Collapsed Sidebar Mode */
.sidebar-collapsed .app-sidebar {
  width: var(--sidebar-collapsed-width);
  min-width: var(--sidebar-collapsed-width);
  flex-basis: var(--sidebar-collapsed-width);
}

.sidebar-collapsed .sidebar-brand-title,
.sidebar-collapsed .sidebar-update-info,
.sidebar-collapsed .nav-label,
.sidebar-collapsed .nav-arrow,
.sidebar-collapsed .nav-arrow-button,
.sidebar-collapsed .sidebar-submenu {
  display: none !important;
}

.sidebar-collapsed .sidebar-status-header {
  padding: 12px 8px;
  align-items: center;
}

.sidebar-collapsed .nav-link {
  justify-content: center;
  padding: 10px;
}

.sidebar-collapsed .sidebar-footer {
  justify-content: center;
}

/* --------------------------------------------------------------------------
   Main Workspace & Topbar
   -------------------------------------------------------------------------- */

.app-main {
  flex: 1;
  width: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-app);
}

/* Topbar */
.app-topbar {
  height: var(--topbar-height);
  min-height: var(--topbar-height);
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  gap: 16px;
  z-index: 10;
  min-width: 0;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.topbar-title {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  padding: 6px;
  border-radius: 4px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
  max-width: 100%;
}

/* Connection Error Banner (at viewport top) */
.connection-error-banner {
  background-color: var(--color-critical-bg);
  border-bottom: 1px solid var(--color-critical);
  padding: 10px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  z-index: 20;
}

.error-banner-content {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  overflow: hidden;
}

.error-banner-msg {
  color: var(--color-critical);
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Time Range Button Group */
.time-range-group {
  display: inline-flex;
  background-color: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 2px;
}

.time-range-btn {
  background: none;
  border: none;
  padding: 4px 10px;
  font-size: 0.775rem;
  font-weight: 600;
  color: var(--text-secondary);
  border-radius: 4px;
  cursor: pointer;
  transition: background-color var(--transition-speed), color var(--transition-speed);
}

.time-range-btn:hover {
  color: var(--text-primary);
}

.time-range-btn.active {
  background-color: var(--color-primary);
  color: #ffffff;
}

/* Refresh Interval Indicator */
.topbar-interval-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.interval-badge {
  padding: 2px 7px;
  border-radius: 4px;
  background-color: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
}

/* Main Viewport Container */
.app-viewport {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px 20px;
  width: 100%;
  min-width: 0;
}

.view-content {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 1600px;
  width: 100%;
  min-width: 0;
  margin: 0 auto;
}

/* ==========================================================================
   4. UI Components (Cards, Buttons, Tables, Badges)
   ========================================================================== */

/* Card (Datadog style) */
.card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  box-shadow: var(--card-shadow);
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.card.no-shadow {
  box-shadow: none;
}

.card-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
}

.card-body {
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.card-body.no-padding {
  padding: 0;
}

/* Stat Cards */
.stat-card .card-body {
  padding: 12px 14px;
  gap: 10px;
}

.stat-main {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.1;
}

.stat-main > .stat-value {
  white-space: nowrap;
  flex-shrink: 0;
}

.stat-sub {
  font-size: 0.72rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.io-stat-pair {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.io-label {
  font-size: 0.725rem;
  font-weight: 600;
  color: var(--text-muted);
}

.card-chart-container {
  height: 110px;
  width: 100%;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 14px;
  font-size: 0.825rem;
  font-weight: 600;
  border-radius: 6px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition-speed);
}

.btn-sm {
  padding: 4px 10px;
  font-size: 0.775rem;
}

.btn-primary {
  background-color: var(--color-primary);
  color: #ffffff;
}

.btn-primary:hover {
  background-color: var(--color-primary-hover);
}

.btn-secondary {
  background-color: var(--bg-surface-elevated);
  border-color: var(--border-color);
  color: var(--text-secondary);
}

.btn-secondary:hover {
  background-color: var(--bg-surface-hover);
  color: var(--text-primary);
}

.btn-icon {
  width: 15px;
  height: 15px;
}

.btn-paused {
  background-color: var(--color-warning-bg) !important;
  color: var(--color-warning) !important;
  border-color: var(--color-warning) !important;
}

.btn-success {
  background-color: var(--color-success) !important;
  color: #ffffff !important;
}

/* Badges */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.2;
}

.status-icon {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
}

.status-normal {
  background-color: var(--color-success-bg);
  color: var(--color-success);
}

.status-warning {
  background-color: var(--color-warning-bg);
  color: var(--color-warning);
}

.status-critical {
  background-color: var(--color-critical-bg);
  color: var(--color-critical);
}

.status-stopped {
  background-color: var(--color-stopped-bg);
  color: var(--color-stopped);
}

.status-unknown {
  background-color: var(--color-stopped-bg);
  color: var(--text-muted);
}

.text-normal { color: var(--color-success); }
.text-warning { color: var(--color-warning); }
.text-critical { color: var(--color-critical); }
.text-stopped { color: var(--color-stopped); }
.text-unknown { color: var(--text-muted); }

.badge-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background-color: var(--color-critical);
  color: #ffffff;
  font-size: 0.75rem;
  font-weight: 700;
}

/* Forms */
.form-input, .form-select {
  padding: 6px 10px;
  background-color: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  color: var(--text-primary);
  font-size: 0.85rem;
}

.form-input:focus, .form-select:focus {
  border-color: var(--color-primary);
}

.control-label, .form-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
}

/* Tables */
.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  text-align: left;
}

.data-table th {
  background-color: var(--bg-surface-elevated);
  padding: 9px 14px;
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border-color);
  user-select: none;
}

.data-table th.sortable-th {
  cursor: pointer;
}

.data-table th.sortable-th:hover {
  color: var(--text-primary);
}

.data-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-secondary);
}

.data-table tr:hover td {
  background-color: var(--bg-surface-hover);
  color: var(--text-primary);
}

.data-table tr.highlighted-row td {
  background-color: var(--color-primary-bg);
}

.data-table .clickable-row {
  cursor: pointer;
}

.text-right {
  text-align: right !important;
}

.text-center {
  text-align: center !important;
}

.font-medium {
  font-weight: 600;
  color: var(--text-primary);
}

/* Progress Bars */
.progress-bar-container {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
}

.progress-bar-track {
  height: 8px;
  background-color: var(--bg-surface-elevated);
  border-radius: 4px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  border-radius: 4px;
  background-color: var(--color-primary);
  transition: width 0.3s ease;
}

.progress-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ==========================================================================
   5. Chart Elements (Canvas & Crosshairs)
   ========================================================================== */

.chart-wrapper {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.chart-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.chart-inspect-bar {
  position: absolute;
  top: 0;
  right: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.75rem;
  pointer-events: none;
  background: var(--bg-surface);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--border-color);
}

.inspect-time {
  color: var(--text-muted);
  font-weight: 600;
}

.inspect-item {
  display: flex;
  align-items: center;
  gap: 5px;
}

.inspect-bullet {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.inspect-name {
  color: var(--text-secondary);
}

.inspect-val {
  font-weight: 600;
  color: var(--text-primary);
}

.main-chart-wrapper {
  height: 240px;
  width: 100%;
}

.chart-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.chart-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-live-val {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.chart-legend-row {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.75rem;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--text-secondary);
}

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 2px;
}

/* ==========================================================================
   6. View Specific Styles
   ========================================================================== */

/* Overview View */
.violations-section {
  background-color: var(--color-critical-bg);
  border: 1px solid var(--color-critical);
  border-radius: 8px;
  padding: 12px 16px;
}

.violations-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.violations-header .section-title {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--color-critical);
}

.violations-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.violation-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 0.85rem;
}

.violation-target {
  font-weight: 600;
  color: var(--text-primary);
}

.violation-val {
  font-weight: 700;
  color: var(--color-critical);
}

.violation-limit {
  font-size: 0.775rem;
  color: var(--text-muted);
  margin-left: auto;
}

.summary-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr));
  gap: 14px;
}

.overview-split-grid {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 14px;
}

.container-summary-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  padding: 10px 0;
}

.summary-metric-block {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.metric-label {
  font-size: 0.775rem;
  color: var(--text-muted);
  font-weight: 600;
}

.metric-number {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text-primary);
}

#summary-cnt-cpu {
  display: flex;
  flex-direction: column;
  gap: 2px;
  align-items: flex-end;
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.25;
  white-space: nowrap;
}

#summary-cnt-cpu > span,
.container-cpu-cell > span {
  display: inline-grid;
  grid-template-columns: 3.7rem auto;
  align-items: baseline;
  column-gap: 6px;
  font-size: inherit;
  font-weight: inherit;
}

.cpu-scope {
  color: var(--text-muted);
  font-size: inherit;
  font-weight: inherit;
  text-align: left;
}

/* System View */
.stats-banner-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr));
  gap: 12px;
}

.gpu-device-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 1fr));
  gap: 12px;
  margin-top: 16px;
}

.gpu-device-card {
  min-width: 0;
  padding: 12px 14px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background-color: var(--bg-surface-elevated);
}

.gpu-device-header,
.gpu-device-usage,
.gpu-device-metrics {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.gpu-device-title {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 0.85rem;
  font-weight: 700;
}

.gpu-device-usage {
  margin: 10px 0 8px;
  font-size: 0.82rem;
}

.gpu-device-metrics {
  margin-top: 8px;
  flex-wrap: wrap;
  font-size: 0.72rem;
  color: var(--text-muted);
}

.gpu-vram-fill.status-fill-normal { background-color: var(--color-success); }
.gpu-vram-fill.status-fill-warning { background-color: var(--color-warning); }
.gpu-vram-fill.status-fill-critical { background-color: var(--color-critical); }
.gpu-vram-fill.status-fill-unknown { background-color: var(--color-stopped); }

.mini-stat {
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-title {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
}

/* Containers View */
.filter-bar {
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.filter-group-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.filter-group-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-filters {
  display: flex;
  gap: 4px;
}

.count-indicator {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.container-vram-cell,
.container-cpu-cell {
  display: inline-flex;
  justify-content: flex-end;
  align-items: baseline;
  gap: 8px;
  white-space: nowrap;
  font-size: 0.78rem;
}

.container-cpu-cell {
  flex-direction: column;
  align-items: flex-end;
  gap: 1px;
  line-height: 1.25;
  font-size: 0.78rem;
  font-weight: 500;
}

/* Container Detail */
.detail-header-card {
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.detail-header-top {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.detail-title {
  font-size: 1.25rem;
  font-weight: 700;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.detail-header-top > .btn,
.detail-header-top > #detail-badge {
  flex-shrink: 0;
}

.detail-meta-grid {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 2fr) repeat(3, minmax(90px, 0.75fr));
  gap: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border-color);
  font-size: 0.8rem;
}

.meta-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.meta-label {
  color: var(--text-muted);
  font-size: 0.725rem;
}

.meta-val {
  color: var(--text-primary);
  font-weight: 600;
  display: block;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.meta-value-row {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.meta-value-row .meta-val {
  flex: 1;
}

.meta-copy-btn {
  flex: 0 0 auto;
  padding: 2px 6px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  color: var(--text-muted);
  background: var(--bg-surface-elevated);
  font-size: 0.7rem;
  line-height: 1.3;
  cursor: pointer;
}

.meta-copy-btn:hover {
  color: var(--text-primary);
  border-color: var(--color-primary);
}

.detail-charts-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}

.chart-container-detail {
  height: 200px;
  width: 100%;
}

/* Disk View */
.mounts-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.section-title {
  font-size: 0.95rem;
  font-weight: 700;
}

.mounts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(320px, 100%), 1fr));
  gap: 14px;
}

.mount-card {
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.mount-alert.mount-warning {
  border-color: var(--color-warning);
}

.mount-alert.mount-critical {
  border-color: var(--color-critical);
}

.mount-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}

.mount-header-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.mount-point {
  font-size: 1.1rem;
  font-weight: 700;
}

.mount-fs {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.mount-usage-main {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 4px;
}

.mount-usage-percent {
  font-size: 1.3rem;
  font-weight: 700;
}

.mount-usage-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.mount-footer-row {
  display: flex;
  justify-content: flex-end;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Settings View */
.settings-section .card-body {
  gap: 14px;
}

.form-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 540px;
}

.input-with-action {
  display: flex;
  gap: 8px;
}

.input-with-action input {
  flex: 1;
}

.test-result-box {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  background: var(--bg-surface-elevated);
  font-size: 0.85rem;
}

.test-result-success {
  border-color: var(--color-success);
}

.test-result-failed {
  border-color: var(--color-critical);
}

.thresholds-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.threshold-group {
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background-color: var(--bg-surface-elevated);
}

.threshold-target {
  font-weight: 700;
  font-size: 0.9rem;
}

.threshold-inputs {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.threshold-field {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
}

.threshold-field label {
  width: 32px;
  color: var(--text-muted);
}

.threshold-field input {
  width: 70px;
}

.settings-actions-bar {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 10px 0;
}

/* LLM Engines View */
.engines-layout {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.engines-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(460px, 100%), 1fr));
  gap: 16px;
}

.engine-card {
  display: flex;
  flex-direction: column;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  overflow: hidden;
}

.engine-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
}

.engine-title-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.engine-id-badge {
  font-size: 0.75rem;
  padding: 2px 6px;
  border-radius: 4px;
  background-color: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
}

.engine-metrics-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 12px;
}

.engine-tokens-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 12px;
  border-radius: 6px;
  background-color: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  font-size: 0.8rem;
  margin-bottom: 12px;
}

.token-stat strong {
  color: var(--text-primary);
}

.engine-models-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.section-sub-title {
  font-size: 0.775rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.loaded-models-container {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 28px;
  align-items: center;
}

.loaded-model-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px;
  border-radius: 6px;
  background-color: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  font-size: 0.8rem;
}

.loaded-model-pill .model-name {
  color: var(--text-primary);
  font-weight: 600;
}

.engine-chart-section {
  padding-top: 12px;
  border-top: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.engine-chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.75rem;
}

.engine-chart-container {
  height: 140px;
  width: 100%;
}

/* ==========================================================================
   7. Responsive Design (Mobile / Tablet)
   ========================================================================== */

@media (max-width: 1200px) {
  .summary-cards-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .overview-split-grid {
    grid-template-columns: 1fr;
  }
  .detail-charts-grid {
    grid-template-columns: 1fr;
  }
  .detail-meta-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .thresholds-grid {
    grid-template-columns: 1fr;
  }
  .engines-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .detail-meta-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .app-topbar {
    height: auto;
    min-height: var(--topbar-height);
    flex-wrap: wrap;
    align-content: center;
    padding: 8px 12px;
    gap: 6px;
  }

  .topbar-left,
  .topbar-right {
    width: 100%;
  }

  .mobile-menu-btn {
    display: inline-flex;
  }

  .app-sidebar {
    position: fixed;
    top: 0;
    left: min(-280px, calc(-100vw + 40px));
    width: min(280px, calc(100vw - 40px));
    min-width: min(280px, calc(100vw - 40px));
    height: 100vh;
    height: 100dvh;
    flex-basis: auto;
    box-shadow: 4px 0 16px rgba(0, 0, 0, 0.5);
    transition: left var(--transition-speed) ease;
  }

  .sidebar-collapsed .app-sidebar {
    width: min(280px, calc(100vw - 40px));
    min-width: min(280px, calc(100vw - 40px));
    flex-basis: auto;
  }

  .mobile-drawer-open .app-sidebar {
    left: 0;
  }

  .mobile-drawer-open .drawer-overlay {
    display: block;
  }

  .summary-cards-grid {
    grid-template-columns: 1fr;
  }

  .topbar-right {
    justify-content: space-between;
    gap: 6px;
    overflow-x: auto;
  }

  .time-range-group {
    flex: 1;
    justify-content: space-between;
    min-width: 220px;
  }

  .time-range-btn {
    padding: 5px 7px;
    white-space: nowrap;
  }

  #btn-toggle-pause,
  #btn-toggle-theme {
    flex: 0 0 auto;
    width: 32px;
    height: 32px;
    padding: 7px;
    font-size: 0;
  }

  .topbar-interval-wrap {
    display: none;
  }

  /* Responsive Containers Table: Transform table to Cards */
  .containers-table thead {
    display: none;
  }

  .containers-table, .containers-table tbody, .containers-table tr, .containers-table td {
    display: block;
    width: 100%;
  }

  .containers-table tr {
    margin-bottom: 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-surface-elevated);
    padding: 8px 12px;
  }

  .containers-table td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    border-bottom: 1px solid var(--border-color);
  }

  .containers-table td:last-child {
    border-bottom: none;
  }

  .containers-table td::before {
    content: attr(data-label);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
  }
}
