/* ── Design tokens ────────────────────────────────────────── */
:root {
  --sidebar-w:      248px;
  --topbar-h:       56px;

  /* Palette */
  --primary:        #6366f1;
  --primary-dark:   #4f46e5;
  --primary-light:  #e0e7ff;
  --success:        #10b981;
  --danger:         #ef4444;
  --warning:        #f59e0b;

  /* Surfaces */
  --bg:             #f1f5f9;
  --surface:        #ffffff;
  --border:         #e2e8f0;
  --border-light:   #f1f5f9;

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

  /* Sidebar */
  --sidebar-bg:         #0f172a;
  --sidebar-hover:      rgba(255,255,255,.06);
  --sidebar-active:     rgba(99,102,241,.18);
  --sidebar-text:       #94a3b8;
  --sidebar-active-text:#c7d2fe;

  /* Shadows */
  --shadow-xs:  0 1px 2px rgba(15,23,42,.04);
  --shadow-sm:  0 1px 3px rgba(15,23,42,.08), 0 1px 2px rgba(15,23,42,.04);
  --shadow-md:  0 4px 6px rgba(15,23,42,.06), 0 2px 4px rgba(15,23,42,.04);
  --shadow-lg:  0 10px 24px rgba(15,23,42,.10), 0 4px 8px rgba(15,23,42,.06);

  /* Radii */
  --radius-sm:  6px;
  --radius-md:  10px;
  --radius-lg:  14px;
  --radius-xl:  20px;
  --radius-pill:99px;
}

/* ── Base ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  font-size: 0.875rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ── App shell ────────────────────────────────────────────── */
#app-shell {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar overlay (mobile) ─────────────────────────────── */
#sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .45);
  backdrop-filter: blur(2px);
  z-index: 190;
  animation: fadeIn .2s ease;
}
#sidebar-overlay.active { display: block; }

/* ── Sidebar ──────────────────────────────────────────────── */
#sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  z-index: 200;
  transition: transform .25s cubic-bezier(.4,0,.2,1);
}

.sidebar-brand {
  padding: 1.25rem 1rem 1.125rem;
  font-size: 1rem;
  font-weight: 700;
  color: #f8fafc;
  letter-spacing: -.01em;
  display: flex;
  align-items: center;
  gap: .5rem;
  border-bottom: 1px solid rgba(255,255,255,.07);
  flex-shrink: 0;
}

.sidebar-brand > i {
  font-size: 1.2rem;
  color: var(--primary);
  background: rgba(99,102,241,.15);
  padding: .325rem;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.sidebar-brand .brand-sub {
  display: block;
  font-size: .625rem;
  font-weight: 400;
  color: var(--sidebar-text);
  letter-spacing: .06em;
  text-transform: uppercase;
  line-height: 1;
  margin-top: 2px;
}

.sidebar-close-btn {
  display: none;
  margin-left: auto;
  background: transparent;
  border: none;
  color: var(--sidebar-text);
  font-size: 1rem;
  line-height: 1;
  padding: .25rem;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background .15s, color .15s;
}
.sidebar-close-btn:hover {
  background: rgba(255,255,255,.08);
  color: #f8fafc;
}

.sidebar-nav {
  flex: 1;
  padding: .625rem .75rem;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}

.sidebar-nav .nav-section {
  font-size: .6rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: rgba(148,163,184,.45);
  padding: .875rem .5rem .25rem;
}

.sidebar-nav .nav-item {
  display: flex;
  align-items: center;
  gap: .625rem;
  padding: .5rem .75rem;
  color: var(--sidebar-text);
  text-decoration: none;
  border-radius: var(--radius-sm);
  transition: background .15s, color .15s;
  cursor: pointer;
  font-size: .8125rem;
  font-weight: 500;
  position: relative;
}

.sidebar-nav .nav-item::before {
  content: '';
  position: absolute;
  left: 0; top: 50%;
  transform: translateY(-50%) scaleY(0);
  width: 3px;
  height: 60%;
  background: var(--primary);
  border-radius: 0 3px 3px 0;
  transition: transform .15s cubic-bezier(.4,0,.2,1);
}

.sidebar-nav .nav-item:hover {
  background: var(--sidebar-hover);
  color: #e2e8f0;
}

.sidebar-nav .nav-item.active {
  background: var(--sidebar-active);
  color: var(--sidebar-active-text);
}

.sidebar-nav .nav-item.active::before {
  transform: translateY(-50%) scaleY(1);
}

.sidebar-nav .nav-item.active i {
  color: var(--primary);
}

.sidebar-nav .nav-item i {
  width: 1.125rem;
  font-size: .9375rem;
  flex-shrink: 0;
}

/* ── Sidebar footer / user ────────────────────────────────── */
.sidebar-footer {
  padding: .75rem;
  border-top: 1px solid rgba(255,255,255,.07);
  flex-shrink: 0;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: .625rem;
  padding: .5rem .625rem;
  border-radius: var(--radius-sm);
}

.sidebar-user-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(99,102,241,.2);
  border: 1px solid rgba(99,102,241,.3);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #c7d2fe;
  font-size: .875rem;
  flex-shrink: 0;
}

.sidebar-user-info {
  flex: 1;
  overflow: hidden;
}

.sidebar-user-name {
  font-size: .8rem;
  font-weight: 600;
  color: #e2e8f0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-role {
  font-size: .65rem;
  color: var(--sidebar-text);
  letter-spacing: .02em;
}

.sidebar-logout-btn {
  background: transparent;
  border: none;
  color: var(--sidebar-text);
  font-size: .875rem;
  padding: .25rem;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background .15s, color .15s;
  flex-shrink: 0;
}
.sidebar-logout-btn:hover {
  background: rgba(239,68,68,.15);
  color: #fca5a5;
}

/* ── Topbar ───────────────────────────────────────────────── */
#topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 1.25rem;
  gap: .75rem;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 0 var(--border), var(--shadow-xs);
}

.topbar-toggle {
  display: none;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 1.25rem;
  padding: .25rem .375rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background .15s, color .15s;
  line-height: 1;
}
.topbar-toggle:hover {
  background: var(--bg);
  color: var(--text-primary);
}

#topbar-breadcrumb {
  display: flex;
  align-items: center;
  gap: .5rem;
  overflow: hidden;
}

#topbar-title {
  font-size: .9rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  gap: .4rem;
}

.topbar-spacer { flex: 1; }

.topbar-actions {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-shrink: 0;
}

.topbar-icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 1rem;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background .15s, color .15s;
}
.topbar-icon-btn:hover {
  background: var(--bg);
  color: var(--text-primary);
}

.topbar-divider {
  width: 1px;
  height: 20px;
  background: var(--border);
  margin: 0 .125rem;
}

.topbar-user-btn {
  display: flex;
  align-items: center;
  gap: .5rem;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: .25rem .625rem .25rem .375rem;
  cursor: pointer;
  transition: background .15s, border-color .15s;
  color: var(--text-secondary);
  font-size: .8125rem;
  font-weight: 500;
}
.topbar-user-btn:hover {
  background: var(--bg);
  border-color: #cbd5e1;
  color: var(--text-primary);
}

.topbar-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .75rem;
  flex-shrink: 0;
}

.topbar-username {
  max-width: 100px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-logout-icon {
  font-size: .75rem;
  opacity: .6;
}

/* ── Main content ─────────────────────────────────────────── */
#main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.page-body {
  padding: 1.75rem;
  flex: 1;
}

/* ── Page headings (generated by JS) ─────────────────────── */
.page-body h5.fw-bold {
  font-size: .9375rem;
  font-weight: 700;
  letter-spacing: -.01em;
  color: var(--text-primary);
}

/* ── Login ────────────────────────────────────────────────── */
#login-screen {
  min-height: 100vh;
  background: var(--sidebar-bg);
  background-image:
    radial-gradient(ellipse 80% 60% at 50% -10%, rgba(99,102,241,.35) 0%, transparent 70%),
    radial-gradient(ellipse 60% 40% at 90% 110%, rgba(79,70,229,.2) 0%, transparent 60%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: rgba(255,255,255,.04);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid rgba(255,255,255,.10) !important;
  border-radius: var(--radius-xl) !important;
  box-shadow: var(--shadow-lg), 0 0 0 1px rgba(99,102,241,.15) !important;
  padding: 2.25rem !important;
  color: #f8fafc;
  animation: slideUp .35s cubic-bezier(.4,0,.2,1);
}

.login-logo-wrap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 68px;
  height: 68px;
  background: rgba(99,102,241,.15);
  border: 1px solid rgba(99,102,241,.25);
  border-radius: var(--radius-lg);
  animation: pulse-ring 3s ease-in-out infinite;
}

.login-logo { font-size: 2.25rem; color: var(--primary); }

.login-card h4 {
  color: #f8fafc;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -.02em;
}

.login-card .text-muted {
  color: var(--sidebar-text) !important;
  font-size: .8125rem;
}

.login-card .form-label {
  color: #cbd5e1;
  font-size: .8rem;
  font-weight: 500;
  margin-bottom: .35rem;
}

.login-card .form-control,
.login-card .input-group-text {
  background: rgba(255,255,255,.07);
  border-color: rgba(255,255,255,.12);
  color: #f8fafc;
}

.login-card .input-group-text {
  color: var(--sidebar-text);
  border-right: none;
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}

.login-card .form-control {
  border-left: none;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.login-card .form-control::placeholder { color: rgba(255,255,255,.25); }
.login-card .form-control:focus {
  background: rgba(255,255,255,.1);
  border-color: var(--primary);
  color: #f8fafc;
  box-shadow: 0 0 0 3px rgba(99,102,241,.2);
}
.login-card .input-group:focus-within .input-group-text {
  border-color: var(--primary);
  background: rgba(255,255,255,.1);
}

.login-card .btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  font-weight: 600;
  letter-spacing: -.01em;
  padding: .625rem 1rem;
  border-radius: var(--radius-sm);
  transition: background .15s, box-shadow .15s, transform .1s;
}
.login-card .btn-primary:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
  box-shadow: 0 0 0 4px rgba(99,102,241,.25);
}
.login-card .btn-primary:active { transform: translateY(1px); }

/* ── Bootstrap overrides ──────────────────────────────────── */
.card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

.card-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border-light);
  border-radius: var(--radius-md) var(--radius-md) 0 0 !important;
  padding: .75rem 1rem;
  font-weight: 600;
  font-size: .8125rem;
  color: var(--text-primary);
}

.card-body { padding: 1rem; }

.btn {
  font-family: 'Inter', sans-serif;
  font-weight: 500;
  border-radius: var(--radius-sm);
  font-size: .8125rem;
  transition: all .15s;
}

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
}
.btn-primary:hover, .btn-primary:focus {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
  box-shadow: 0 0 0 3px rgba(99,102,241,.2);
}

.btn-outline-secondary {
  border-color: var(--border);
  color: var(--text-secondary);
}
.btn-outline-secondary:hover {
  background: var(--bg);
  border-color: #cbd5e1;
  color: var(--text-primary);
}

.btn-outline-primary {
  border-color: var(--primary);
  color: var(--primary);
}
.btn-outline-primary:hover {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary-dark);
}

.btn-outline-danger {
  border-color: #fca5a5;
  color: var(--danger);
}
.btn-outline-danger:hover {
  background: #fee2e2;
  border-color: var(--danger);
  color: var(--danger);
}

.form-control, .form-select {
  border-color: var(--border);
  border-radius: var(--radius-sm);
  font-size: .8125rem;
  color: var(--text-primary);
  transition: border-color .15s, box-shadow .15s;
}
.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99,102,241,.12);
}

.input-group-text {
  background: var(--bg);
  border-color: var(--border);
  color: var(--text-muted);
  font-size: .8125rem;
}

.form-label {
  font-size: .8rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: .3rem;
}

.modal-content {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}

.modal-header {
  border-bottom: 1px solid var(--border-light);
  padding: 1.125rem 1.25rem;
}

.modal-footer {
  border-top: 1px solid var(--border-light);
  padding: .875rem 1.25rem;
}

.modal-title {
  font-size: .9375rem;
  font-weight: 700;
  letter-spacing: -.01em;
}

.nav-tabs {
  border-bottom: 2px solid var(--border);
  gap: .125rem;
}

.nav-tabs .nav-link {
  font-size: .8125rem;
  font-weight: 500;
  color: var(--text-secondary);
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  padding: .5rem .875rem;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  transition: color .15s, border-color .15s;
}
.nav-tabs .nav-link:hover { color: var(--text-primary); }
.nav-tabs .nav-link.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  background: transparent;
  font-weight: 600;
}

.pagination .page-link {
  border-color: var(--border);
  color: var(--text-secondary);
  font-size: .75rem;
  border-radius: var(--radius-sm) !important;
  margin: 0 1px;
  transition: all .12s;
}
.pagination .page-item.active .page-link {
  background: var(--primary);
  border-color: var(--primary);
}
.pagination .page-link:hover {
  background: var(--bg);
  color: var(--primary);
}

.list-group-item {
  border-color: var(--border-light);
  font-size: .8125rem;
  padding: .625rem 1rem;
}

/* ── Tables ───────────────────────────────────────────────── */
.table {
  font-size: .8125rem;
  color: var(--text-primary);
}

.table > :not(caption) > * > * {
  padding: .625rem .875rem;
  border-bottom-color: var(--border-light);
}

.table thead th {
  font-weight: 600;
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border) !important;
  background: var(--surface);
  white-space: nowrap;
}

.table-hover tbody tr {
  cursor: pointer;
  transition: background .1s;
}

.table-hover tbody tr:hover > * { background: #f8fafc; }

/* ── Stat cards ───────────────────────────────────────────── */
.stat-card {
  border: 1px solid var(--border) !important;
  border-radius: var(--radius-md) !important;
  box-shadow: var(--shadow-sm) !important;
  transition: box-shadow .2s, transform .2s;
  overflow: hidden;
  background: var(--surface);
}

.stat-card:hover {
  box-shadow: var(--shadow-md) !important;
  transform: translateY(-2px);
}

.stat-card .card-body {
  padding: 1.25rem !important;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.stat-card .stat-icon {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  font-size: 1.375rem;
  flex-shrink: 0;
}

.stat-card .stat-icon.color-primary { background: var(--primary-light); color: var(--primary); }
.stat-card .stat-icon.color-success { background: #d1fae5; color: var(--success); }
.stat-card .stat-icon.color-danger  { background: #fee2e2; color: var(--danger); }
.stat-card .stat-icon.color-info    { background: #e0f2fe; color: #0284c7; }
.stat-card .stat-icon.color-warning { background: #fef3c7; color: var(--warning); }

.stat-card .stat-body { flex: 1; min-width: 0; }

.stat-card .stat-value {
  font-size: 1.875rem;
  font-weight: 800;
  letter-spacing: -.04em;
  line-height: 1.1;
  color: var(--text-primary);
}

.stat-card .stat-label {
  font-size: .7rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .07em;
  margin-top: 2px;
}

/* ── Status badges ────────────────────────────────────────── */
.badge {
  font-weight: 600;
  font-size: .7rem;
  letter-spacing: .02em;
  border-radius: var(--radius-pill);
  padding: .25em .65em;
}

.badge-online  { background: #d1fae5; color: #065f46; }
.badge-offline { background: #fee2e2; color: #991b1b; }
.badge-pending   { background: #f1f5f9; color: #475569; border: 1px solid var(--border); }
.badge-executing { background: #fef3c7; color: #92400e; }
.badge-done      { background: #d1fae5; color: #065f46; }
.badge-failed    { background: #fee2e2; color: #991b1b; }
.badge-cancelled { background: #f1f5f9; color: var(--text-muted); }

/* ── Status dot ───────────────────────────────────────────── */
.status-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: middle;
  flex-shrink: 0;
}

.dot-online {
  background: var(--success);
  box-shadow: 0 0 0 2px rgba(16,185,129,.2);
  animation: pulse-dot 2.5s ease-in-out infinite;
}

.dot-offline { background: var(--danger); }

/* ── Tags ─────────────────────────────────────────────────── */
.tag-badge {
  display: inline-flex;
  align-items: center;
  background: var(--primary-light);
  color: var(--primary-dark);
  border: 1px solid #c7d2fe;
  padding: .175rem .55rem;
  border-radius: var(--radius-pill);
  font-size: .7rem;
  font-weight: 500;
  margin: 2px;
  letter-spacing: .01em;
}

/* ── Parameters table ─────────────────────────────────────── */
.param-name {
  font-family: 'JetBrains Mono', 'Fira Code', 'Courier New', monospace;
  font-size: .75rem;
  color: var(--text-secondary);
}
.param-value { word-break: break-all; color: var(--text-primary); }

/* ── Empty state ──────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 3.5rem 1rem;
  color: var(--text-muted);
}

.empty-state i {
  font-size: 2.5rem;
  display: block;
  margin-bottom: .875rem;
  opacity: .35;
}

/* ── Network cards ─────────────────────────────────────────── */
.network-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  align-items: stretch;
}

.network-card {
  min-width: 0;
}

.network-card-wide {
  grid-column: 1 / -1;
}

.network-card .card {
  min-height: 100%;
}

.network-card .table {
  table-layout: fixed;
}

.network-card .table td {
  padding: .5rem .875rem;
  vertical-align: middle;
}

.network-card .table td:first-child {
  width: 42%;
}

.network-card .table td:last-child {
  overflow-wrap: anywhere;
}

/* ── Toast ────────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  z-index: 9999;
  width: 320px;
  display: flex;
  flex-direction: column;
  gap: .5rem;
}

#toast-container .toast {
  border-radius: var(--radius-md) !important;
  font-size: .8125rem;
  font-weight: 500;
  border: none !important;
  box-shadow: var(--shadow-lg) !important;
  animation: slideInRight .25s cubic-bezier(.4,0,.2,1);
}

/* ── Device header card ───────────────────────────────────── */
.dev-header-shell {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.dev-header-main {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  min-width: 0;
}

.dev-header-title-block {
  flex: 1;
  min-width: 0;
}

.dev-header-device-icon {
  width: 56px;
  height: 56px;
  background: var(--primary-light);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.75rem;
  color: var(--primary);
  flex-shrink: 0;
}

.dev-header-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: .75rem 1rem;
}

.dev-header-field .field-label {
  font-size: .7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  display: block;
  margin-bottom: 2px;
}

.dev-header-field .field-value {
  font-size: .8125rem;
  font-weight: 600;
  color: var(--text-primary);
  overflow-wrap: anywhere;
}

.pon-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .35rem;
}

.pon-status,
.pon-metric {
  display: inline-flex;
  align-items: baseline;
  gap: .2rem;
  min-height: 24px;
  padding: .2rem .45rem;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  background: var(--bg-tertiary);
  line-height: 1;
}

.pon-status {
  align-items: center;
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
}

.pon-status.is-up {
  color: var(--success);
  border-color: rgba(25, 135, 84, .22);
  background: rgba(25, 135, 84, .08);
}

.pon-status.is-down {
  color: var(--danger);
  border-color: rgba(220, 53, 69, .22);
  background: rgba(220, 53, 69, .08);
}

.pon-metric-label {
  font-size: .68rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
}

.pon-metric-value {
  font-size: .82rem;
  font-weight: 700;
  color: var(--text-primary);
}

.pon-metric-unit {
  font-size: .68rem;
  font-weight: 600;
  color: var(--text-muted);
}

.dev-header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  padding-top: .75rem;
  border-top: 1px solid var(--border-light);
}

.dev-header-actions .btn {
  min-height: 32px;
  white-space: nowrap;
}

.live-pill {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .25rem .55rem;
  border: 1px solid rgba(25, 135, 84, .22);
  border-radius: 999px;
  background: rgba(25, 135, 84, .08);
  color: var(--success);
  font-size: .72rem;
  font-weight: 700;
  white-space: nowrap;
}

.live-pill span {
  width: .45rem;
  height: .45rem;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 4px rgba(25, 135, 84, .12);
}

.dev-ops-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(185px, 1fr));
  gap: .6rem;
  margin-top: 1rem;
}

.ops-card {
  display: flex;
  gap: .55rem;
  align-items: flex-start;
  min-width: 0;
  padding: .65rem .75rem;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
}

.ops-card > i {
  color: var(--primary);
  font-size: 1rem;
  line-height: 1.2;
  margin-top: .08rem;
  flex-shrink: 0;
}

.ops-card > div {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: .12rem;
}

.ops-label {
  font-size: .66rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
}

.ops-card strong {
  font-size: .8rem;
  line-height: 1.25;
  color: var(--text-primary);
  overflow-wrap: anywhere;
}

.ops-card small {
  font-size: .7rem;
  color: var(--text-muted);
  overflow-wrap: anywhere;
}

/* ── Page fade-in ─────────────────────────────────────────── */
.page-body > * {
  animation: fadeIn .2s ease;
}

/* ── Misc ─────────────────────────────────────────────────── */
.clickable { cursor: pointer; }
.border-end { border-color: var(--border) !important; }
.bi.fs-1 { line-height: 1; }
.spinner-border.text-primary { color: var(--primary) !important; }

/* ── KV editor ────────────────────────────────────────────── */
.kv-row {
  display: flex;
  gap: .5rem;
  margin-bottom: .375rem;
  align-items: center;
}
.kv-row input { flex: 1; }

/* ── Scrollbar (Webkit) ───────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ── Focus ring ───────────────────────────────────────────── */
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ── Task result rows ─────────────────────────────────────── */
.task-result-row td {
  border-top: none !important;
  background: #f8fafc;
}

.task-result {
  font-size: .8rem;
  color: var(--text-secondary);
  padding: .375rem .5rem;
  border-left: 3px solid var(--primary-light);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: var(--primary-light);
  line-height: 1.6;
}

.task-result strong { color: var(--text-primary); }

/* ── Card footer ──────────────────────────────────────────── */
.card-footer {
  background: var(--surface);
  border-top: 1px solid var(--border-light) !important;
  padding: .5rem 1rem;
  font-size: .75rem;
  color: var(--text-muted);
}

/* ── font-monospace utility ───────────────────────────────── */
.font-monospace {
  font-family: 'JetBrains Mono', 'Fira Code', 'Courier New', monospace;
}

/* ── Keyframe animations ──────────────────────────────────── */
@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(16px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes pulse-dot {
  0%, 100% { box-shadow: 0 0 0 2px rgba(16,185,129,.2); }
  50%       { box-shadow: 0 0 0 4px rgba(16,185,129,.12); }
}

@keyframes pulse-ring {
  0%, 100% { box-shadow: 0 0 0 0 rgba(99,102,241,.15); }
  50%       { box-shadow: 0 0 0 8px rgba(99,102,241,.0); }
}

/* ── Responsive: tablet ───────────────────────────────────── */
@media (max-width: 1024px) {
  :root { --sidebar-w: 220px; }
}

/* ── Responsive: mobile ───────────────────────────────────── */
@media (max-width: 767px) {
  #sidebar {
    transform: translateX(-100%);
    box-shadow: none;
  }

  #sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-lg), 4px 0 24px rgba(0,0,0,.25);
  }

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

  #main-content {
    margin-left: 0;
  }

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

  .topbar-username {
    display: none;
  }

  .page-body {
    padding: 1rem;
  }

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

  .network-grid {
    grid-template-columns: 1fr;
  }

  .topbar-icon-btn { display: none; }
  .topbar-divider  { display: none; }

  /* Keep theme toggle visible on mobile */
  #theme-toggle-btn { display: flex !important; }
}

/* ════════════════════════════════════════════════════════════
   Dark theme
   ════════════════════════════════════════════════════════════ */
[data-theme="dark"] {
  color-scheme: dark;

  /* ── Custom surfaces ──────────────────────────────────────── */
  --bg:           #0d1117;
  --surface:      #161b22;
  --border:       #30363d;
  --border-light: #21262d;

  /* ── Custom text ──────────────────────────────────────────── */
  --text-primary:   #e6edf3;
  --text-secondary: #8b949e;
  --text-muted:     #6e7681;

  /* ── Custom primary tint ──────────────────────────────────── */
  --primary-light: rgba(99,102,241,.18);

  /* ── Sidebar ──────────────────────────────────────────────── */
  --sidebar-bg:         #010409;
  --sidebar-hover:      rgba(255,255,255,.05);
  --sidebar-active:     rgba(99,102,241,.2);
  --sidebar-text:       #8b949e;
  --sidebar-active-text:#c7d2fe;

  /* ── Shadows ──────────────────────────────────────────────── */
  --shadow-xs: 0 1px 2px rgba(0,0,0,.4);
  --shadow-sm: 0 1px 3px rgba(0,0,0,.5), 0 1px 2px rgba(0,0,0,.4);
  --shadow-md: 0 4px 8px rgba(0,0,0,.5), 0 2px 4px rgba(0,0,0,.3);
  --shadow-lg: 0 10px 24px rgba(0,0,0,.6), 0 4px 8px rgba(0,0,0,.4);

  /* ── Bootstrap 5 variable overrides ──────────────────────── */
  --bs-body-color:        #e6edf3;
  --bs-body-bg:           #0d1117;
  --bs-secondary-color:   #8b949e;
  --bs-tertiary-color:    #6e7681;
  --bs-secondary-bg:      #161b22;
  --bs-tertiary-bg:       #21262d;
  --bs-border-color:      #30363d;
  --bs-border-color-translucent: rgba(255,255,255,.1);
  --bs-emphasis-color:    #f0f6fc;
  --bs-heading-color:     #e6edf3;
  --bs-link-color:        #a5b4fc;
  --bs-link-hover-color:  #c7d2fe;
  --bs-code-color:        #f0883e;
  /* Card */
  --bs-card-bg:            #161b22;
  --bs-card-border-color:  #30363d;
  --bs-card-cap-bg:        rgba(255,255,255,.03);
  --bs-card-color:         #e6edf3;
  /* Table */
  --bs-table-color:        #e6edf3;
  --bs-table-bg:           transparent;
  --bs-table-border-color: #30363d;
  --bs-table-striped-bg:   rgba(255,255,255,.025);
  --bs-table-hover-bg:     rgba(255,255,255,.04);
  /* Form */
  --bs-form-control-bg:    rgba(255,255,255,.04);
  --bs-input-bg:           rgba(255,255,255,.04);
  --bs-input-color:        #e6edf3;
  --bs-input-border-color: #30363d;
  --bs-input-placeholder-color: #6e7681;
  /* Modal */
  --bs-modal-bg:            #161b22;
  --bs-modal-border-color:  #30363d;
  --bs-modal-header-border-color: #30363d;
  --bs-modal-footer-border-color: #30363d;
  /* List group */
  --bs-list-group-bg:           #161b22;
  --bs-list-group-border-color: #30363d;
  --bs-list-group-color:        #e6edf3;
  --bs-list-group-action-color: #8b949e;
  /* Dropdown */
  --bs-dropdown-bg:         #161b22;
  --bs-dropdown-border-color: #30363d;
  --bs-dropdown-link-color: #e6edf3;
  --bs-dropdown-link-hover-color: #e6edf3;
  --bs-dropdown-link-hover-bg: rgba(255,255,255,.06);
  /* Nav tabs */
  --bs-nav-tabs-border-color: #30363d;
  --bs-nav-tabs-link-active-bg: #161b22;
  --bs-nav-tabs-link-active-border-color: #30363d #30363d #161b22;
  /* Pagination */
  --bs-pagination-bg:           #161b22;
  --bs-pagination-border-color: #30363d;
  --bs-pagination-color:        #8b949e;
  --bs-pagination-hover-bg:     rgba(255,255,255,.06);
  --bs-pagination-hover-color:  #e6edf3;
  --bs-pagination-disabled-bg:  #161b22;
  --bs-pagination-disabled-color: #6e7681;
}

/* ── Dark: body & backgrounds ────────────────────────────── */
[data-theme="dark"] body {
  background: var(--bg);
  color: var(--text-primary);
}

/* ── Dark: Bootstrap utility overrides ───────────────────── */
[data-theme="dark"] .text-muted,
[data-theme="dark"] .text-secondary {
  color: var(--text-muted) !important;
}
[data-theme="dark"] .text-dark {
  color: var(--text-primary) !important;
}
[data-theme="dark"] .text-body {
  color: var(--text-primary) !important;
}
[data-theme="dark"] .text-body-secondary {
  color: var(--text-secondary) !important;
}
[data-theme="dark"] .text-body-tertiary {
  color: var(--text-muted) !important;
}
[data-theme="dark"] h1, [data-theme="dark"] h2,
[data-theme="dark"] h3, [data-theme="dark"] h4,
[data-theme="dark"] h5, [data-theme="dark"] h6,
[data-theme="dark"] .h1, [data-theme="dark"] .h2,
[data-theme="dark"] .h3, [data-theme="dark"] .h4,
[data-theme="dark"] .h5, [data-theme="dark"] .h6 {
  color: var(--text-primary);
}
[data-theme="dark"] p,
[data-theme="dark"] span,
[data-theme="dark"] label,
[data-theme="dark"] li,
[data-theme="dark"] td,
[data-theme="dark"] th {
  color: inherit;
}
[data-theme="dark"] .small,
[data-theme="dark"] small {
  color: inherit;
}
[data-theme="dark"] .bg-light {
  background-color: var(--surface) !important;
}
[data-theme="dark"] .bg-white {
  background-color: var(--surface) !important;
}
[data-theme="dark"] .border {
  border-color: var(--border) !important;
}
[data-theme="dark"] .border-bottom {
  border-bottom-color: var(--border) !important;
}
[data-theme="dark"] hr {
  border-color: var(--border);
  opacity: 1;
}

/* ── Dark: cards ─────────────────────────────────────────── */
[data-theme="dark"] .card {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text-primary);
}

[data-theme="dark"] .card-header,
[data-theme="dark"] .bg-white {
  background: var(--surface) !important;
  color: var(--text-primary);
}

[data-theme="dark"] .card-body {
  color: var(--text-primary);
}

[data-theme="dark"] .card-title {
  color: var(--text-primary);
}

[data-theme="dark"] .card-text {
  color: var(--text-secondary);
}

[data-theme="dark"] .card-footer {
  background: var(--surface);
  border-top-color: var(--border) !important;
}

/* ── Dark: topbar ─────────────────────────────────────────── */
[data-theme="dark"] #topbar {
  background: var(--surface);
  border-bottom-color: var(--border);
}

[data-theme="dark"] .topbar-toggle,
[data-theme="dark"] .topbar-icon-btn {
  color: var(--text-secondary);
}
[data-theme="dark"] .topbar-toggle:hover,
[data-theme="dark"] .topbar-icon-btn:hover {
  background: rgba(255,255,255,.06);
  color: var(--text-primary);
}

[data-theme="dark"] .topbar-user-btn {
  border-color: var(--border);
  color: var(--text-secondary);
}
[data-theme="dark"] .topbar-user-btn:hover {
  background: rgba(255,255,255,.06);
  color: var(--text-primary);
}

[data-theme="dark"] .topbar-avatar {
  background: rgba(99,102,241,.2);
  color: #c7d2fe;
}

[data-theme="dark"] .topbar-divider {
  background: var(--border);
}

/* ── Dark: tables ─────────────────────────────────────────── */
[data-theme="dark"] .table {
  color: var(--text-primary);
  --bs-table-bg: transparent;
  --bs-table-striped-bg: transparent;
  --bs-table-hover-bg: transparent;
}

[data-theme="dark"] .table > :not(caption) > * > * {
  border-bottom-color: var(--border-light);
  background: transparent;
}

[data-theme="dark"] .table thead th {
  background: var(--surface);
  color: var(--text-muted);
  border-bottom-color: var(--border) !important;
}

[data-theme="dark"] .table-hover tbody tr:hover > * {
  background: rgba(255,255,255,.03) !important;
}

[data-theme="dark"] .task-result-row td {
  background: rgba(255,255,255,.02) !important;
}

[data-theme="dark"] .task-result {
  background: rgba(99,102,241,.1) !important;
  border-left-color: rgba(99,102,241,.35);
  color: var(--text-secondary);
}

/* ── Dark: forms ──────────────────────────────────────────── */
[data-theme="dark"] .form-control,
[data-theme="dark"] .form-select {
  background-color: #1c2128 !important;
  border-color: var(--border) !important;
  color: var(--text-primary) !important;
}

/* form-select: replace dark arrow SVG with a light-colored one */
[data-theme="dark"] .form-select {
  --bs-form-select-bg-img: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%238b949e' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
  background-image: var(--bs-form-select-bg-img), none;
}

/* native <select> options */
[data-theme="dark"] select,
[data-theme="dark"] select option,
[data-theme="dark"] select optgroup {
  background-color: #1c2128;
  color: var(--text-primary);
}

[data-theme="dark"] .form-control::placeholder {
  color: var(--text-muted) !important;
}

[data-theme="dark"] .form-control:focus,
[data-theme="dark"] .form-select:focus {
  background-color: #21262d !important;
  border-color: var(--primary) !important;
  color: var(--text-primary) !important;
  box-shadow: 0 0 0 3px rgba(99,102,241,.15);
}

[data-theme="dark"] .form-control:disabled,
[data-theme="dark"] .form-select:disabled {
  background-color: rgba(255,255,255,.03) !important;
  color: var(--text-muted) !important;
}

[data-theme="dark"] .input-group-text {
  background: #1c2128 !important;
  border-color: var(--border) !important;
  color: var(--text-muted);
}

[data-theme="dark"] .form-label {
  color: var(--text-secondary);
}

/* checkboxes & radios */
[data-theme="dark"] .form-check-input {
  background-color: #1c2128;
  border-color: var(--border);
}
[data-theme="dark"] .form-check-input:checked {
  background-color: var(--primary);
  border-color: var(--primary);
}
[data-theme="dark"] .form-check-label {
  color: var(--text-secondary);
}

/* ── Dark: modals ─────────────────────────────────────────── */
[data-theme="dark"] .modal-content {
  background: var(--surface);
  border-color: var(--border);
}

[data-theme="dark"] .modal-header {
  border-bottom-color: var(--border);
}

[data-theme="dark"] .modal-footer {
  border-top-color: var(--border);
}

[data-theme="dark"] .btn-close {
  filter: invert(1) grayscale(1) brightness(2);
}

/* ── Dark: navigation ─────────────────────────────────────── */
[data-theme="dark"] .nav-tabs {
  border-bottom-color: var(--border);
}

[data-theme="dark"] .nav-tabs .nav-link {
  color: var(--text-secondary);
}

[data-theme="dark"] .nav-tabs .nav-link:hover {
  color: var(--text-primary);
}

[data-theme="dark"] .nav-tabs .nav-link.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  background: transparent;
}

/* ── Dark: pagination ─────────────────────────────────────── */
[data-theme="dark"] .pagination .page-link {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text-secondary);
}

[data-theme="dark"] .pagination .page-link:hover {
  background: rgba(255,255,255,.06);
  color: var(--primary);
  border-color: var(--border);
}

[data-theme="dark"] .pagination .page-item.active .page-link {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

[data-theme="dark"] .pagination .page-item.disabled .page-link {
  background: var(--surface);
  color: var(--text-muted);
  border-color: var(--border);
}

/* ── Dark: list group ─────────────────────────────────────── */
[data-theme="dark"] .list-group-item {
  background: var(--surface);
  border-color: var(--border-light);
  color: var(--text-primary);
}

/* ── Dark: badges (custom status) ────────────────────────── */
[data-theme="dark"] .badge-online {
  background: rgba(16,185,129,.15);
  color: #6ee7b7;
}
[data-theme="dark"] .badge-offline {
  background: rgba(239,68,68,.15);
  color: #fca5a5;
}
[data-theme="dark"] .badge-pending {
  background: rgba(255,255,255,.07);
  color: var(--text-secondary);
  border-color: var(--border);
}
[data-theme="dark"] .badge-executing {
  background: rgba(245,158,11,.15);
  color: #fcd34d;
}
[data-theme="dark"] .badge-done {
  background: rgba(16,185,129,.15);
  color: #6ee7b7;
}
[data-theme="dark"] .badge-failed {
  background: rgba(239,68,68,.15);
  color: #fca5a5;
}
[data-theme="dark"] .badge-cancelled {
  background: rgba(255,255,255,.06);
  color: var(--text-muted);
  border-color: var(--border);
}

/* ── Dark: Bootstrap badge overrides ─────────────────────── */
[data-theme="dark"] .bg-success { background-color: rgba(16,185,129,.25)  !important; color: #6ee7b7 !important; }
[data-theme="dark"] .bg-danger  { background-color: rgba(239,68,68,.25)    !important; color: #fca5a5 !important; }
[data-theme="dark"] .bg-warning { background-color: rgba(245,158,11,.25)   !important; color: #fcd34d !important; }
[data-theme="dark"] .bg-info    { background-color: rgba(14,165,233,.25)    !important; color: #7dd3fc !important; }
[data-theme="dark"] .bg-secondary { background-color: rgba(148,163,184,.2) !important; color: #cbd5e1 !important; }
[data-theme="dark"] .bg-primary   { background-color: rgba(99,102,241,.25) !important; color: #c7d2fe !important; }
[data-theme="dark"] .bg-light     { background-color: rgba(255,255,255,.07)!important; color: var(--text-secondary) !important; }
[data-theme="dark"] .bg-dark      { background-color: rgba(255,255,255,.1) !important; color: var(--text-primary)   !important; }

/* bg-opacity-10 combos (e.g. bg-secondary bg-opacity-10 text-secondary) */
[data-theme="dark"] .bg-secondary.bg-opacity-10 {
  background-color: rgba(148,163,184,.12) !important;
}

[data-theme="dark"] .tag-badge {
  background: rgba(99,102,241,.15);
  border-color: rgba(99,102,241,.3);
  color: #c7d2fe;
}

/* ── Dark: buttons ────────────────────────────────────────── */
[data-theme="dark"] .btn-outline-secondary {
  border-color: var(--border);
  color: var(--text-secondary);
}

[data-theme="dark"] .btn-outline-secondary:hover {
  background: rgba(255,255,255,.07);
  border-color: #475569;
  color: var(--text-primary);
}

[data-theme="dark"] .btn-outline-primary {
  border-color: var(--primary);
  color: #a5b4fc;
}

[data-theme="dark"] .btn-outline-primary:hover {
  background: rgba(99,102,241,.15);
  color: #c7d2fe;
}

[data-theme="dark"] .btn-outline-danger {
  border-color: rgba(239,68,68,.4);
  color: #f87171;
}

[data-theme="dark"] .btn-outline-danger:hover {
  background: rgba(239,68,68,.12);
  border-color: var(--danger);
  color: #fca5a5;
}

/* ── Dark: alerts ─────────────────────────────────────────── */
[data-theme="dark"] .alert-danger {
  background: rgba(239,68,68,.12);
  border-color: rgba(239,68,68,.3);
  color: #fca5a5;
}
[data-theme="dark"] .alert-warning {
  background: rgba(245,158,11,.1);
  border-color: rgba(245,158,11,.3);
  color: #fcd34d;
}
[data-theme="dark"] .alert-success {
  background: rgba(16,185,129,.1);
  border-color: rgba(16,185,129,.3);
  color: #6ee7b7;
}
[data-theme="dark"] .alert-info {
  background: rgba(14,165,233,.1);
  border-color: rgba(14,165,233,.3);
  color: #7dd3fc;
}
[data-theme="dark"] .alert-primary {
  background: rgba(99,102,241,.12);
  border-color: rgba(99,102,241,.3);
  color: #c7d2fe;
}
[data-theme="dark"] .alert-secondary {
  background: rgba(148,163,184,.1);
  border-color: rgba(148,163,184,.25);
  color: #cbd5e1;
}

/* ── Dark: scrollbar ──────────────────────────────────────── */
[data-theme="dark"] ::-webkit-scrollbar-thumb {
  background: #30363d;
}

[data-theme="dark"] ::-webkit-scrollbar-thumb:hover {
  background: #484f58;
}

/* ── Dark: login card ─────────────────────────────────────── */
[data-theme="dark"] .login-card {
  background: rgba(255,255,255,.04);
  border-color: rgba(255,255,255,.1) !important;
}

/* ── Dark: stat cards ─────────────────────────────────────── */
[data-theme="dark"] .stat-card {
  background: var(--surface);
}

/* ── Dark: device header ──────────────────────────────────── */
[data-theme="dark"] .dev-header-device-icon {
  background: rgba(99,102,241,.15);
  color: #a5b4fc;
}

/* ── Dark: empty state ────────────────────────────────────── */
[data-theme="dark"] .empty-state {
  color: var(--text-muted);
}

/* ── Theme toggle button ──────────────────────────────────── */
#theme-toggle-btn {
  transition: transform .3s cubic-bezier(.4,0,.2,1), background .15s;
}

[data-theme="dark"] #theme-toggle-btn {
  color: #f59e0b;
}
[data-theme="dark"] #theme-toggle-btn:hover {
  background: rgba(245,158,11,.12);
  color: #fbbf24;
}
