/* ═══════════════════════════════════════════════════════════════════════════
   VinzaPanel — Premium Dark Theme
   ═══════════════════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

/* ── Design Tokens ─────────────────────────────────────────────────────────── */
:root {
  /* Colors */
  --color-bg-primary: #0a0e1a;
  --color-bg-secondary: #0f1526;
  --color-bg-card: #131928;
  --color-bg-hover: #1a2035;
  --color-bg-active: #1e2640;
  --color-border: rgba(255, 255, 255, 0.06);
  --color-border-active: rgba(99, 179, 237, 0.3);

  /* Brand */
  --color-brand: #3b82f6;
  --color-brand-light: #60a5fa;
  --color-brand-dark: #2563eb;
  --color-brand-glow: rgba(59, 130, 246, 0.3);

  /* Accent */
  --color-success: #10b981;
  --color-warning: #f59e0b;
  --color-danger: #ef4444;
  --color-info: #06b6d4;
  --color-purple: #8b5cf6;

  /* Setup-wizard surfaces — theme-aware overlays so the wizard reads correctly in
     both themes (replaces bare rgba(255,255,255,…) overlays that vanish on light). */
  --wiz-tint: rgba(255, 255, 255, 0.03);
  --wiz-tint-2: rgba(255, 255, 255, 0.06);
  --wiz-line: rgba(255, 255, 255, 0.10);
  --wiz-line-strong: rgba(255, 255, 255, 0.20);

  /* Text */
  --color-text-primary: #f0f4ff;
  --color-text-secondary: #94a3b8;
  --color-text-muted: #475569;

  /* Sidebar */
  --sidebar-width: 237px;
  --sidebar-collapsed: 70px;
  --topbar-height: 64px;

  /* Shadows */
  --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.4);
  --shadow-glow: 0 0 20px var(--color-brand-glow);
  --shadow-danger: 0 0 20px rgba(239, 68, 68, 0.2);

  /* Transitions */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 250ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);

  /* Radius */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;
}

/* ── Reset & Base ──────────────────────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 15px;
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--color-bg-primary);
  color: var(--color-text-primary);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--color-brand-light);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover:not(.btn) {
  color: var(--color-brand);
}

code,
pre {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
}

/* ── Scrollbar ─────────────────────────────────────────────────────────────── */
::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}

::-webkit-scrollbar-track {
  background: var(--color-bg-secondary);
}

::-webkit-scrollbar-thumb {
  background: var(--color-bg-active);
  border-radius: 99px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--color-brand);
}

/* ══════════════════════════════════════════════════════════════════════════════
   LAYOUT
   ══════════════════════════════════════════════════════════════════════════════ */

.panel-layout {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ────────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  min-height: 100vh;
  background: var(--color-bg-secondary);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  z-index: 100;
  transition: width var(--transition-normal);
  overflow: hidden;
}

.sidebar.collapsed {
  width: var(--sidebar-collapsed);
}

/* Sidebar Logo */
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--color-border);
  min-height: var(--topbar-height);
  flex-shrink: 0;
}

.sidebar-logo-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--color-brand), var(--color-purple));
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
  box-shadow: var(--shadow-glow);
}

.sidebar-logo-text {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: opacity var(--transition-normal), width var(--transition-normal);
}

.sidebar-logo-text .brand-name {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--color-text-primary);
  white-space: nowrap;
  letter-spacing: -0.02em;
}

.sidebar-logo-text .brand-version {
  font-size: 0.7rem;
  color: var(--color-text-muted);
  font-weight: 500;
}

/* Sidebar Navigation */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px 0;
}

.nav-section-label {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  padding: 16px 18px 6px;
  white-space: nowrap;
  overflow: hidden;
  transition: opacity var(--transition-normal), font-size .22s ease, color .22s ease, letter-spacing .22s ease;
}

.nav-section-label.sec-collapsed {
  font-size: 0.78rem;
  letter-spacing: 0.05em;
  color: var(--color-text-secondary);
}

.sidebar.collapsed .nav-section-label {
  opacity: 0;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 7px 18px;
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
  white-space: nowrap;
  overflow: hidden;
  border-radius: 0;
  margin: 1px 8px;
  border-radius: var(--radius-md);
}

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

.nav-item.active {
  color: var(--color-brand-light);
  background: rgba(59, 130, 246, 0.12);
  font-weight: 500;
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 60%;
  background: var(--color-brand);
  border-radius: 0 3px 3px 0;
}

.nav-item-icon {
  font-size: 1rem;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.nav-item-label {
  font-size: 0.8rem;
  transition: opacity var(--transition-normal);
}

.nav-item-badge {
  margin-left: auto;
  background: var(--color-brand);
  color: white;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 99px;
  min-width: 18px;
  text-align: center;
  transition: opacity var(--transition-normal);
}

.sidebar.collapsed .nav-item-label,
.sidebar.collapsed .nav-item-badge {
  opacity: 0;
}

/* Sidebar Bottom */
.sidebar-bottom {
  padding: 12px 8px;
  border-top: 1px solid var(--color-border);
}

/* ── Main Content ───────────────────────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-width, 237px);
  /* Explicit width so the content area always spans the viewport minus the
     fixed sidebar. Do NOT rely on flex:1 alone: some engines (seen on
     Chrome/Android tablets) collapse a lone flex child whose only siblings are
     position:fixed, shrinking the whole panel to a narrow left column. */
  width: calc(100% - var(--sidebar-width, 237px));
  flex: 1 1 auto;
  min-width: 0;
  box-sizing: border-box;
  transition: margin-left var(--transition-normal), width var(--transition-normal);
}

.main-content.sidebar-collapsed {
  margin-left: var(--sidebar-collapsed, 70px);
  width: calc(100% - var(--sidebar-collapsed, 70px));
}

/* ── Topbar ─────────────────────────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-height);
  background: var(--color-bg-secondary);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(10px);
}

.topbar-toggle {
  background: none;
  border: none;
  color: var(--color-text-secondary);
  cursor: pointer;
  padding: 8px;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
  font-size: 1.1rem;
}

.topbar-toggle:hover {
  background: var(--color-bg-hover);
  color: var(--color-text-primary);
}

.topbar-breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.875rem;
  color: var(--color-text-secondary);
}

.topbar-breadcrumb .current {
  color: var(--color-text-primary);
  font-weight: 500;
}

.topbar-spacer {
  flex: 1;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-btn {
  background: none;
  border: none;
  color: var(--color-text-secondary);
  cursor: pointer;
  padding: 0 10px;
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
  font-size: 0.9rem;
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
}

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

.topbar-btn .notif-dot {
  position: absolute;
  top: 6px;
  right: 8px;
  width: 7px;
  height: 7px;
  background: var(--color-danger);
  border-radius: 50%;
  border: 2px solid var(--color-bg-secondary);
}

/* User Menu */
.user-menu {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--transition-fast);
  border: 1px solid var(--color-border);
}

.user-menu:hover {
  background: var(--color-bg-hover);
}

.user-avatar {
  width: 26px;
  height: 26px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--color-brand), var(--color-purple));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}

.user-info {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.user-info .user-name {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-text-primary);
}

.user-info .user-role {
  font-size: 0.6rem;
  color: var(--color-text-muted);
  text-transform: capitalize;
}

/* ── Page Content ───────────────────────────────────────────────────────────── */
.page-content {
  padding: 24px;
  /* Never let a wide plugin page (a large table, a fit-to-content terminal,
     a long unbroken string…) overflow horizontally and blow out the layout
     width — on tablets that triggers the browser's fit-to-width zoom-out,
     shrinking the whole panel. `clip` clips without creating a scroll
     container (no overflow-y side effect, unlike `hidden`). */
  overflow-x: clip;
  max-width: 100%;
}

.page-header {
  margin-bottom: 24px;
  display: flex;
  align-items: center;          /* vertically centre action buttons against the title block */
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.page-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--color-text-primary);
  letter-spacing: -0.02em;
  line-height: 1.2;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Page-title icons: one uniform, subtle (non-brand) colour and size across every
   page. The !important overrides the assorted inline colours / margin utilities
   used in templates so all page-title icons render identically. */
.page-title > i {
  color: var(--color-text-muted) !important;
  font-size: 0.88em;
  margin: 0 !important;
  flex-shrink: 0;
}

.page-subtitle {
  font-size: 0.875rem;
  color: var(--color-text-muted);
  margin-top: 4px;
}

/* ══════════════════════════════════════════════════════════════════════════════
   COMPONENTS
   ══════════════════════════════════════════════════════════════════════════════ */

/* ── Cards ──────────────────────────────────────────────────────────────────── */
.card {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-card);
  transition: border-color var(--transition-fast);
}

.card:hover {
  border-color: rgba(255, 255, 255, 0.1);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

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

.card-subtitle {
  font-size: 0.78rem;
  color: var(--color-text-muted);
  margin-top: 2px;
}

/* ── Stat Cards ─────────────────────────────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 20px;
  position: relative;
  overflow: hidden;
  cursor: pointer;
  transition: all var(--transition-normal);
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--stat-color, var(--color-brand));
  opacity: 0.7;
  transition: opacity var(--transition-fast);
}

.stat-card:hover {
  transform: translateY(-2px);
  border-color: var(--stat-color, var(--color-brand));
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.stat-card:hover::before {
  opacity: 1;
}

.stat-icon {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  background: rgba(var(--stat-color-rgb, 59, 130, 246), 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  color: var(--stat-color, var(--color-brand));
  margin-bottom: 12px;
}

.stat-value {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--color-text-primary);
  line-height: 1;
  margin-bottom: 4px;
  font-variant-numeric: tabular-nums;
}

.stat-label {
  font-size: 0.78rem;
  color: var(--color-text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stat-trend {
  position: absolute;
  top: 16px;
  right: 16px;
  font-size: 0.75rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 3px;
}

.stat-trend.up {
  color: var(--color-success);
}

.stat-trend.down {
  color: var(--color-danger);
}

/* Circular Progress */
.stat-progress {
  width: 48px;
  height: 48px;
  position: absolute;
  bottom: 16px;
  right: 16px;
}

/* ── Progress Bar ───────────────────────────────────────────────────────────── */
.progress-bar {
  height: 6px;
  background: var(--color-bg-hover);
  border-radius: 99px;
  overflow: hidden;
  margin-top: 10px;
}

.progress-fill {
  height: 100%;
  border-radius: 99px;
  background: var(--progress-color, var(--color-brand));
  transition: width 0.5s ease;
  position: relative;
  overflow: hidden;
}

.progress-fill::after {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
  animation: shimmer 2s infinite;
}

@keyframes shimmer {
  0% {
    left: -100%;
  }

  100% {
    left: 100%;
  }
}

/* ── Buttons ────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 500;
  font-family: inherit;
  line-height: 1.2;   /* fixed so <a> and <button> buttons are the same height (body is 1.6) */
  cursor: pointer;
  border: none;
  transition: all var(--transition-fast);
  white-space: nowrap;
  text-decoration: none;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: linear-gradient(135deg, var(--color-brand), var(--color-brand-dark));
  color: white;
  box-shadow: 0 4px 12px var(--color-brand-glow);
}

.btn-primary:hover:not(:disabled) {
  box-shadow: 0 6px 20px rgba(59, 130, 246, 0.5);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--color-bg-hover);
  color: var(--color-text-secondary);
  border: 1px solid var(--color-border);
}

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

.btn-danger {
  background: rgba(239, 68, 68, 0.15);
  color: var(--color-danger);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.btn-danger:hover:not(:disabled) {
  background: rgba(239, 68, 68, 0.25);
  box-shadow: var(--shadow-danger);
}

.btn-success {
  background: rgba(16, 185, 129, 0.15);
  color: var(--color-success);
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.btn-success:hover:not(:disabled) {
  background: rgba(16, 185, 129, 0.25);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
}

.btn-lg {
  padding: 12px 24px;
  font-size: 1rem;
}

.btn-icon {
  padding: 8px;
}

/* ── Badges / Tags ──────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.badge-success {
  background: rgba(16, 185, 129, 0.15);
  color: var(--color-success);
}

.badge-danger {
  background: rgba(239, 68, 68, 0.15);
  color: var(--color-danger);
}

.badge-warning {
  background: rgba(245, 158, 11, 0.15);
  color: var(--color-warning);
}

.badge-info {
  background: rgba(6, 182, 212, 0.15);
  color: var(--color-info);
}

.badge-brand {
  background: rgba(59, 130, 246, 0.15);
  color: var(--color-brand-light);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.status-dot.active {
  background: var(--color-success);
  box-shadow: 0 0 6px var(--color-success);
}

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

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

/* ── Table ──────────────────────────────────────────────────────────────────── */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.table thead {
  background: var(--color-bg-hover);
  border-bottom: 1px solid var(--color-border);
}

.table th {
  padding: 12px 16px;
  text-align: left;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  white-space: nowrap;
}

.table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-border);
  color: var(--color-text-secondary);
  vertical-align: middle;
}

.table tbody tr {
  transition: background var(--transition-fast);
}

.table tbody tr:hover {
  background: var(--color-bg-hover);
}

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

/* ── Forms ──────────────────────────────────────────────────────────────────── */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--color-text-secondary);
  margin-bottom: 6px;
  letter-spacing: 0.01em;
}

.form-control {
  width: 100%;
  padding: 10px 14px;
  background: var(--color-bg-primary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-text-primary);
  font-size: 0.875rem;
  font-family: inherit;
  transition: all var(--transition-fast);
  outline: none;
}

.form-control:focus {
  border-color: var(--color-brand);
  box-shadow: 0 0 0 3px var(--color-brand-glow);
}

.form-control::placeholder {
  color: var(--color-text-muted);
}

select.form-control {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2394a3b8'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
  padding-right: 36px;
}

.form-help {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  margin-top: 4px;
}

.form-error {
  font-size: 0.75rem;
  color: var(--color-danger);
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ── Modal ──────────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: fadeIn var(--transition-fast) ease;
}

.modal {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 520px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.6);
  animation: slideUp var(--transition-normal) ease;
}

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

.modal-title {
  font-size: 1rem;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
  font-size: 1.1rem;
  transition: all var(--transition-fast);
}

.modal-close:hover {
  color: var(--color-text-primary);
  background: var(--color-bg-hover);
}

.modal-body {
  padding: 24px;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--color-border);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* ── Toast Notifications ────────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 14px 18px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-width: 320px;
  max-width: 440px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  pointer-events: all;
  animation: slideInRight var(--transition-normal) ease;
  border-left: 3px solid var(--toast-color, var(--color-brand));
}

.toast-icon {
  font-size: 1.1rem;
  color: var(--toast-color, var(--color-brand));
  flex-shrink: 0;
  margin-top: 1px;
}

.toast-content {
  flex: 1;
}

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

.toast-msg {
  font-size: 0.8rem;
  color: var(--color-text-secondary);
  margin-top: 2px;
}

/* ── Dropdown ───────────────────────────────────────────────────────────────── */
.dropdown {
  position: relative;
  display: inline-block;
}

.dropdown-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
  min-width: 180px;
  z-index: 150;
  overflow: hidden;
  animation: slideDown var(--transition-fast) ease;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  font-size: 0.875rem;
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
  background: none;
  border: none;
  width: 100%;
  text-align: left;
  font-family: inherit;
}

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

.dropdown-item.danger {
  color: var(--color-danger);
}

.dropdown-item.danger:hover {
  background: rgba(239, 68, 68, 0.1);
}

.dropdown-divider {
  height: 1px;
  background: var(--color-border);
  margin: 4px 0;
}

/* ── Empty State ────────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--color-text-muted);
}

.empty-state-icon {
  font-size: 3rem;
  margin-bottom: 16px;
  opacity: 0.4;
}

.empty-state-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--color-text-secondary);
  margin-bottom: 8px;
}

.empty-state-text {
  font-size: 0.875rem;
  max-width: 300px;
  margin: 0 auto 20px;
}

/* ── Loading / Skeleton ─────────────────────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, var(--color-bg-card) 25%, var(--color-bg-hover) 50%, var(--color-bg-card) 75%);
  background-size: 200% 100%;
  animation: skeletonWave 1.5s infinite;
  border-radius: var(--radius-sm);
}

@keyframes skeletonWave {
  0% {
    background-position: 200% 0;
  }

  100% {
    background-position: -200% 0;
  }
}

/* ── Chart Container ────────────────────────────────────────────────────────── */
.chart-container {
  position: relative;
  height: 200px;
}

/* Terminal UI is the unified .vp-terminal* component (see vp-terminal section).
   The legacy per-plugin .terminal-* classes were removed — the terminal plugin
   now uses .vp-terminal chrome + its own full-height frame in its assets. */

/* ── Animations ─────────────────────────────────────────────────────────────── */
@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes slideUp {
  from {
    transform: translateY(20px);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes slideDown {
  from {
    transform: translateY(-10px);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes slideInRight {
  from {
    transform: translateX(20px);
    opacity: 0;
  }

  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes pulse {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.5;
  }
}

.animate-pulse {
  animation: pulse 2s infinite;
}

/* ── Grid Utilities ─────────────────────────────────────────────────────────── */
.grid {
  display: grid;
  gap: 16px;
}

.grid-2 {
  grid-template-columns: repeat(2, 1fr);
}

.grid-3 {
  grid-template-columns: repeat(3, 1fr);
}

.grid-4 {
  grid-template-columns: repeat(4, 1fr);
}

@media (max-width: 1200px) {
  .grid-4 {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 900px) {

  .grid-3,
  .grid-4 {
    grid-template-columns: 1fr;
  }

  .stat-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ── Mobile Sidebar Overlay ───────────────────────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(2px);
  z-index: 99;
}

.sidebar-overlay.active {
  display: block;
}

/* ── Responsive — Tablet (≤ 768px) ──────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    width: var(--sidebar-width) !important;
    transition: transform var(--transition-normal);
    z-index: 200;
  }

  .sidebar.mobile-open {
    transform: translateX(0);
    box-shadow: 4px 0 32px rgba(0, 0, 0, 0.6);
  }

  .sidebar.collapsed {
    width: var(--sidebar-width) !important;
    transform: translateX(-100%);
  }

  .sidebar.collapsed .nav-item-label,
  .sidebar.collapsed .nav-item-badge,
  .sidebar.collapsed .nav-section-label {
    opacity: 1;
  }

  .main-content {
    margin-left: 0 !important;
  }

  .topbar {
    padding: 0 12px;
    gap: 8px;
  }

  .topbar-breadcrumb .current {
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .user-info {
    display: none;
  }

  .license-badge span:last-child {
    display: none;
  }

  .page-content {
    padding: 16px;
  }

  .stat-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .toast-container {
    left: 12px;
    right: 12px;
    bottom: 12px;
  }

  .toast {
    min-width: unset;
    max-width: 100%;
    width: 100%;
  }

  .filter-bar {
    padding: 10px 12px;
  }

  .filter-search {
    max-width: 100%;
  }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
}

/* ── Responsive — Mobile (≤ 480px) ──────────────────────────────────────── */
@media (max-width: 480px) {
  .grid-2,
  .stat-grid {
    grid-template-columns: 1fr;
  }

  .topbar-breadcrumb {
    display: none;
  }

  .update-badge {
    display: none;
  }

  .topbar-actions {
    gap: 4px;
  }

  .modal {
    margin: 8px;
  }
}

/* ── Utilities ──────────────────────────────────────────────────────────────── */
.flex {
  display: flex;
}

.flex-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

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

.gap-2 {
  gap: 8px;
}

.gap-3 {
  gap: 12px;
}

.gap-4 {
  gap: 16px;
}

.mt-1 {
  margin-top: 4px;
}

.mt-2 {
  margin-top: 8px;
}

.mt-4 {
  margin-top: 16px;
}

.mt-6 {
  margin-top: 24px;
}

.mb-2 {
  margin-bottom: 8px;
}

.mb-4 {
  margin-bottom: 16px;
}

.mb-6 {
  margin-bottom: 24px;
}

.text-muted {
  color: var(--color-text-muted);
}

.text-sm {
  font-size: 0.8rem;
}

.text-xs {
  font-size: 0.72rem;
}

.font-mono {
  font-family: 'JetBrains Mono', monospace;
}

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.w-full {
  width: 100%;
}

/* ── Page Transitions ───────────────────────────────────────────────────────── */
.page-content {
  animation: fadeIn 0.2s ease;
}

/* ── Plugin Cards ───────────────────────────────────────────────────────────── */
.plugin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.plugin-card {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 20px;
  transition: all var(--transition-normal);
  position: relative;
  overflow: hidden;
}

.plugin-card:hover {
  border-color: var(--color-brand);
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(59, 130, 246, 0.15);
}

.plugin-card-header {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 14px;
}

.plugin-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  background: var(--color-bg-hover);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  flex-shrink: 0;
  overflow: hidden;
}

.plugin-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.plugin-meta {
  flex: 1;
}

.plugin-name {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--color-text-primary);
}

.plugin-version {
  font-size: 0.72rem;
  color: var(--color-text-muted);
  margin-top: 2px;
}

.plugin-desc {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  line-height: 1.5;
  margin-bottom: 16px;
}

.plugin-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 14px;
  border-top: 1px solid var(--color-border);
}

.plugin-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.72rem;
  font-weight: 600;
}

/* ── Service Status Cards ───────────────────────────────────────────────────── */
.service-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--color-border);
}

.service-item:last-child {
  border-bottom: none;
}

.service-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: var(--color-bg-hover);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}

.service-info {
  flex: 1;
}

.service-name {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-text-primary);
}

.service-detail {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  margin-top: 1px;
}

.service-actions {
  display: flex;
  gap: 6px;
}

/* ── Utility ─────────────────────────────────────────────────────────────── */
.hidden {
  display: none !important;
}

/* ── File Manager ────────────────────────────────────────────────────────── */
.fm-table-wrap {
  max-height: 62vh;
  overflow-y: auto;
  overflow-x: auto;
  border-radius: 0 0 var(--radius) var(--radius);
}

.fm-table-wrap table thead th {
  position: sticky;
  top: 0;
  background: var(--color-bg-card);
  z-index: 2;
}

.fm-crumb {
  cursor: pointer;
  color: var(--color-text-secondary);
  padding: 2px 4px;
  border-radius: 4px;
  transition: color var(--transition-fast), background var(--transition-fast);
}

.fm-crumb:hover {
  color: var(--color-text-primary);
  background: var(--color-bg-hover);
}

.fm-row:hover {
  background: var(--color-bg-hover);
}

.btn-dots {
  background: none;
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 4px;
  transition: color var(--transition-fast), background var(--transition-fast);
}

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

/* ── Context Menu ────────────────────────────────────────────────────────── */
.ctx-menu {
  position: fixed;
  z-index: 9999;
  min-width: 170px;
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .6);
  padding: 4px 0;
  user-select: none;
}

.ctx-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 14px;
  font-size: 0.85rem;
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
}

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

.ctx-item i {
  width: 14px;
  text-align: center;
}

.ctx-item.ctx-danger {
  color: var(--color-danger);
}

.ctx-item.ctx-danger:hover {
  background: rgba(239, 68, 68, .12);
  color: var(--color-danger);
}

.ctx-separator {
  height: 1px;
  background: var(--color-border);
  margin: 3px 0;
}

/* ── Card Body ───────────────────────────────────────────────────────────── */
.card-body {
  padding: 20px;
}

/* ── Spacing Utilities ───────────────────────────────────────────────────── */
.p-4 { padding: 16px; }
.p-6 { padding: 24px; }
.pt-4 { padding-top: 16px; }
.pb-4 { padding-bottom: 16px; }
.mr-1 { margin-right: 4px; }
.mr-2 { margin-right: 8px; }
.mb-1 { margin-bottom: 4px; }
.mb-3 { margin-bottom: 12px; }
.mb-5 { margin-bottom: 20px; }
.mt-3 { margin-top: 12px; }
.mt-5 { margin-top: 20px; }
.gap-1 { gap: 4px; }
.gap-5 { gap: 20px; }
.gap-6 { gap: 24px; }

/* ── Typography Utilities ────────────────────────────────────────────────── */
.font-semibold { font-weight: 600; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-brand { color: var(--color-brand); }
.text-danger { color: var(--color-danger); }
.text-success { color: var(--color-success); }
.text-warning { color: var(--color-warning); }

/* ── Flex Utilities ──────────────────────────────────────────────────────── */
.flex-col {
  display: flex;
  flex-direction: column;
}

/* ── Icon Utilities ──────────────────────────────────────────────────────── */
.icon-16 {
  width: 16px;
  height: 16px;
}

/* ── Section Title ───────────────────────────────────────────────────────── */
.section-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--color-text-primary);
  border-bottom: 1px solid var(--color-border);
  padding-bottom: 12px;
  margin-bottom: 20px;
}

/* ── Button Extra Small ──────────────────────────────────────────────────── */
.btn-xs {
  padding: 4px 8px;
  font-size: 0.72rem;
  border-radius: var(--radius-sm);
}

/* ── Preset Badge (scheduler, firewall) ──────────────────────────────────── */
.preset-badge {
  background: var(--color-bg-hover);
  color: var(--color-text-secondary);
  border: 1px solid var(--color-border);
  padding: 4px 8px;
  font-size: 0.72rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  font-weight: 500;
}

.preset-badge:hover {
  background: var(--color-brand-glow);
  color: var(--color-brand-light);
  border-color: var(--color-brand);
}

.preset-active {
  background: var(--color-brand);
  color: white;
  border-color: var(--color-brand);
}

/* ── Component Tabs (components pages) ──────────────────────────────────── */
.cp-tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.cp-tab-btn {
  padding: 7px 18px;
  border-radius: 7px;
  border: none;
  background: transparent;
  color: var(--color-text-muted);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}

.cp-tab-btn:hover {
  background: rgba(59, 130, 246, 0.1);
  color: var(--color-brand);
}

.cp-tab-btn.active {
  background: var(--color-brand);
  color: #fff;
}

/* ── Component Spinner ───────────────────────────────────────────────────── */
@keyframes cp-spin {
  to { transform: rotate(360deg); }
}

.cp-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: cp-spin 0.6s linear infinite;
  vertical-align: middle;
  margin-right: 5px;
}

/* ── Unified terminal component (vp-terminal) ─────────────────────────────────
   Single source of truth for every terminal-style output / log / console pane
   across the panel and plugins. Terminals stay dark in both themes (terminal
   convention). Markup:

     <div class="vp-terminal">                 wrapper  (+ vp-terminal-sm | -lg)
       <div class="vp-terminal-bar">           optional macOS-style title bar
         <span class="vp-dot r"></span>
         <span class="vp-dot y"></span>
         <span class="vp-dot g"></span>
         <span class="vp-terminal-title">label</span>
       </div>
       <pre class="vp-terminal-body" data-placeholder="No output yet…">…</pre>
     </div>

   Text-state modifiers on .vp-terminal-body: .is-success .is-error .is-muted
──────────────────────────────────────────────────────────────────────────── */
.vp-terminal {
  --vp-term-bg: #0d1117;          /* output background        */
  --vp-term-bar-bg: #161b22;      /* title-bar background     */
  --vp-term-fg: #d1d5db;          /* default output text      */
  --vp-term-h: clamp(160px, 32vh, 320px);  /* body height (medium / default) */
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin: 14px 0;
  max-width: 100%;
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.45);
}

.vp-terminal-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: var(--vp-term-bar-bg);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.vp-terminal-bar .vp-dot { width: 10px; height: 10px; border-radius: 50%; flex: 0 0 auto; }
.vp-terminal-bar .vp-dot.r { background: #ff5f56; }
.vp-terminal-bar .vp-dot.y { background: #ffbd2e; }
.vp-terminal-bar .vp-dot.g { background: #27c93f; }
.vp-terminal-title,
.vp-terminal-bar code {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.5);
  margin-left: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.vp-terminal-body {
  margin: 0;
  background: var(--vp-term-bg);
  color: var(--vp-term-fg);
  padding: clamp(10px, 2.5vw, 16px);
  font-family: 'JetBrains Mono', ui-monospace, 'Courier New', monospace;
  font-size: clamp(0.7rem, 0.4rem + 0.4vw, 0.78rem);
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
  overflow: auto;
  min-height: 60px;
  max-height: var(--vp-term-h, clamp(160px, 32vh, 320px));
  -webkit-overflow-scrolling: touch;
}

/* Size variants — adjust the scrollable body height only */
.vp-terminal-sm { --vp-term-h: clamp(90px, 18vh, 160px); }
.vp-terminal-lg { --vp-term-h: clamp(280px, 55vh, 520px); }

/* Output-state text tints */
.vp-terminal-body.is-success { color: #a3e635; }
.vp-terminal-body.is-error   { color: #f87171; }
.vp-terminal-body.is-muted   { color: #94a3b8; }

/* Empty-state placeholder (set data-placeholder on the body) */
.vp-terminal-body:empty::before {
  content: attr(data-placeholder);
  color: rgba(255, 255, 255, 0.28);
}

/* Custom scrollbar to match the dark chrome */
.vp-terminal-body::-webkit-scrollbar { width: 10px; height: 10px; }
.vp-terminal-body::-webkit-scrollbar-track { background: transparent; }
.vp-terminal-body::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  border: 2px solid var(--vp-term-bg);
}
.vp-terminal-body::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.22); }

/* Responsive: tighten chrome on small screens */
@media (max-width: 640px) {
  .vp-terminal { margin: 10px 0; }
  .vp-terminal-bar { padding: 6px 10px; }
  .vp-terminal-title,
  .vp-terminal-bar code { font-size: 0.68rem; }
}

/* ── Extended Margin Utilities ───────────────────────────────────────────── */
.mr-3 { margin-right: 12px; }
.mr-4 { margin-right: 16px; }
.mr-5 { margin-right: 20px; }
.mr-6 { margin-right: 6px; }
.mr-7 { margin-right: 7px; }

/* ── Compound Utility Classes (extracted from templates) ─────────────────── */
.label-upper {
  font-size: .75rem;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
}

.label-muted-sm {
  font-size: .75rem;
  color: var(--color-text-muted);
  margin-bottom: 4px;
}

.stat-val-lg {
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1.2;
}

.flex-row-14 {
  display: flex;
  align-items: center;
  gap: 14px;
}

.card-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 20px;
}

/* ── Pagination ──────────────────────────────────────────────────────────── */
.pagination-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-top: 1px solid var(--color-border);
  flex-wrap: wrap;
  gap: 12px;
}

.pagination-info {
  font-size: 0.78rem;
  color: var(--color-text-muted);
}

.pagination {
  display: flex;
  align-items: center;
  gap: 4px;
}

.page-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--color-text-secondary);
  background: var(--color-bg-hover);
  border: 1px solid var(--color-border);
  text-decoration: none;
  transition: all var(--transition-fast);
  cursor: pointer;
  user-select: none;
}

.page-btn:hover {
  background: var(--color-bg-active);
  color: var(--color-text-primary);
  border-color: var(--color-brand);
}

.page-btn.active {
  background: var(--color-brand);
  color: #fff;
  border-color: var(--color-brand);
}

.page-btn.disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

.page-ellipsis {
  border: none;
  background: none;
  cursor: default;
}

/* ── List Filter Bar ─────────────────────────────────────────────────────── */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--color-border);
  flex-wrap: wrap;
  background: var(--color-bg-card);
}

.filter-search {
  position: relative;
  flex: 1;
  min-width: 180px;
  max-width: 320px;
}

.filter-search i {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-text-muted);
  font-size: 0.8rem;
  pointer-events: none;
}

.filter-search input {
  padding-left: 32px;
}

.filter-select {
  min-width: 140px;
}

.filter-sep {
  width: 1px;
  height: 24px;
  background: var(--color-border);
  flex-shrink: 0;
}

.filter-count {
  font-size: 0.78rem;
  color: var(--color-text-muted);
  margin-left: auto;
  white-space: nowrap;
}

/* ════════════════════════════════════════════════════════════════════════
   Responsive layer — tables · forms · grids
   Layout-only rules using shared variables, so this block is identical in
   panel_light.css and panel_dark.css. Keep the two copies in sync.
   ════════════════════════════════════════════════════════════════════════ */

/* `.table-responsive` was referenced by templates but never defined — give it
   (and `.table-wrapper`) horizontal scroll so wide data tables never push the
   page sideways on any viewport. */
.table-responsive,
.table-wrapper,
.plugin-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
}

.table-responsive > table,
.table-wrapper > table {
  min-width: 100%;
}

/* ── Tablet (≤ 1024px) ──────────────────────────────────────────────────────
   Dense fixed-column grids (3- and 4-up card rows, e.g. inline stat grids)
   relax to two columns before the full single-column collapse kicks in at
   768px. Declared BEFORE the 768px block so the 1fr rule below wins on phones.
   `auto-fit`/`auto-fill` grids size themselves and are intentionally left alone. */
@media (max-width: 1024px) {
  .page-content [style*="repeat(3"],
  .page-content [style*="repeat(4"] {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  /* Two-column "main + fixed sidebar" page splits stack on tablet so the
     fluid main column never gets squeezed by the fixed side panel. */
  .page-content [style*="1fr 380px"],
  .page-content [style*="1fr 360px"],
  .page-content [style*="1fr 340px"],
  .page-content [style*="1fr 300px"],
  .page-content [style*="320px 1fr"] {
    grid-template-columns: 1fr !important;
  }
}

/* ── Tablet & phone (≤ 768px) ───────────────────────────────────────────── */
@media (max-width: 768px) {
  /* Tables: scroll inside their own box instead of stretching the page.
     The block + overflow technique keeps header/body cells aligned. */
  .page-content table {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Forms & grids: collapse every inline multi-column grid to a single
     column. A stylesheet `!important` overrides the inline declaration.
     `auto-fit`/`auto-fill` grids already shrink to one column on their own,
     so they are excluded to preserve their fluid multi-column behaviour. */
  .page-content [style*="grid-template-columns"]:not([style*="auto-fit"]):not([style*="auto-fill"]) {
    grid-template-columns: 1fr !important;
  }

  /* Inline flex rows (filter/search bars, button groups) wrap instead of
     overflowing, and fixed-width inputs shrink to fit. */
  .page-content [style*="display:flex"],
  .page-content [style*="display: flex"] {
    flex-wrap: wrap;
  }

  .page-content input[style*="width"],
  .page-content select[style*="width"],
  .page-content textarea[style*="width"] {
    max-width: 100%;
  }

  /* Media & preformatted content never force horizontal overflow. */
  .page-content img { max-width: 100%; height: auto; }
  .page-content pre { max-width: 100%; overflow-x: auto; }
}
