/* ============================================
   GTS Connect Portal — Admin Panel Wireframe
   Bootstrap 5 Custom Styles
   Brand: #6f0f10 (dark red), #231f20 (charcoal)
   ============================================ */

:root {
  --gts-red: #6f0f10;
  --gts-red-light: #8b1a1b;
  --gts-red-dark: #5a0c0d;
  --gts-charcoal: #231f20;
  --gts-charcoal-light: #3a3536;
  --sidebar-width: 260px;
  --sidebar-collapsed: 70px;
  --topbar-height: 60px;
}

/* ---- Global ---- */
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: #f4f6f9;
  color: #333;
  overflow-x: hidden;
}

a { color: var(--gts-red); }
a:hover { color: var(--gts-red-dark); }

.btn-gts {
  background-color: var(--gts-red);
  border-color: var(--gts-red);
  color: #fff;
}
.btn-gts:hover, .btn-gts:focus {
  background-color: var(--gts-red-dark);
  border-color: var(--gts-red-dark);
  color: #fff;
}

.btn-outline-gts {
  border-color: var(--gts-red);
  color: var(--gts-red);
}
.btn-outline-gts:hover {
  background-color: var(--gts-red);
  color: #fff;
}

.text-gts { color: var(--gts-red) !important; }
.bg-gts { background-color: var(--gts-red) !important; }
.bg-gts-charcoal { background-color: var(--gts-charcoal) !important; }

/* ---- Login Page ---- */
.login-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--gts-charcoal) 0%, #1a1617 100%);
}

.login-card {
  width: 100%;
  max-width: 420px;
  border: none;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.login-card .card-body { padding: 2.5rem; }

.login-logo {
  max-width: 220px;
  margin: 0 auto 1.5rem;
  display: block;
}

/* ---- Sidebar ---- */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--gts-charcoal);
  z-index: 1040;
  transition: width 0.3s ease, transform 0.3s ease;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  border-right: 1px solid #000;
}

.sidebar-brand {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  min-height: var(--topbar-height);
  background: #fff;
}

.sidebar-brand img {
  max-width: 160px;
  height: auto;
}

.sidebar-nav {
  list-style: none;
  padding: 0.75rem 0;
  margin: 0;
  flex: 1;
}

.sidebar-nav .nav-label {
  padding: 0.75rem 1.25rem 0.35rem;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #fff;
}

.sidebar-nav .nav-item { margin: 1px 0; }

.sidebar-nav .nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 1.25rem;
  color: rgba(255,255,255,0.7);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  border-left: 3px solid transparent;
  transition: all 0.2s;
}

.sidebar-nav .nav-link:hover {
  color: #fff;
  background: rgba(255,255,255,0.05);
}

.sidebar-nav .nav-link.active {
  color: #fff;
  background: rgba(111, 15, 16, 0.3);
  border-left-color: var(--gts-red);
}

.sidebar-nav .nav-link i {
  font-size: 1.1rem;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid rgba(255,255,255,0.08);
}

.sidebar-project {
  border-top: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.03);
  padding: 0.5rem 0 0.25rem;
}

.sidebar-project .nav-label {
  padding: 0.5rem 1.25rem 0.25rem;
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(255,255,255,0.4);
}

.sidebar-project .nav-item {
  margin: 0;
}

.sidebar-project .nav-link {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.4rem 1.25rem;
  color: rgba(255,255,255,0.5);
  text-decoration: none;
  font-size: 0.8rem;
  font-weight: 500;
  border-left: 3px solid transparent;
  transition: all 0.2s;
}

.sidebar-project .nav-link:hover {
  color: rgba(255,255,255,0.8);
  background: rgba(255,255,255,0.03);
}

.sidebar-project .nav-link.active {
  color: rgba(255,255,255,0.8);
  border-left-color: rgba(255,255,255,0.3);
}

.sidebar-project .nav-link i {
  font-size: 0.9rem;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.sidebar-version {
  padding: 0 1.25rem 0.25rem 1.55rem;
  font-size: 0.55rem;
  color: rgba(255,255,255,0.7);
  letter-spacing: 0.05em;
}

/* ---- Main Content ---- */
.main-content {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  transition: margin-left 0.3s ease;
}

/* ---- Top Bar ---- */
.topbar {
  height: var(--topbar-height);
  background: #fff;
  border-bottom: 1px solid #e2e6ea;
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 1030;
}

.topbar .sidebar-toggle {
  background: none;
  border: none;
  font-size: 1.25rem;
  color: #555;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  margin-right: 1rem;
}

.topbar .global-search {
  flex: 1;
  max-width: 480px;
}

.topbar .global-search .form-control {
  border-radius: 20px;
  padding-left: 2.5rem;
  background-color: #f4f6f9;
  border-color: #e2e6ea;
  font-size: 0.875rem;
}

.topbar .global-search .form-control:focus {
  background-color: #fff;
  border-color: var(--gts-red);
  box-shadow: 0 0 0 0.2rem rgba(111, 15, 16, 0.15);
}

.topbar .search-icon {
  position: absolute;
  left: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  color: #999;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-left: auto;
}

.topbar-right .btn-icon {
  background: none;
  border: none;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #555;
  position: relative;
  transition: background 0.2s;
}

.topbar-right .btn-icon:hover {
  background: #f4f6f9;
}

.notification-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 8px;
  height: 8px;
  background: var(--gts-red);
  border-radius: 50%;
  border: 2px solid #fff;
}

.org-selector {
  font-size: 0.8rem;
  border-radius: 6px;
  border-color: #e2e6ea;
  padding: 0.3rem 2rem 0.3rem 0.6rem;
  background-color: #f8f9fa;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--gts-red);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
}

/* ---- Page Content ---- */
.page-content { padding: 1.5rem; }

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.page-header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--gts-charcoal);
  margin: 0;
}

.breadcrumb {
  font-size: 0.8rem;
  margin-bottom: 0;
}

/* ---- KPI Cards ---- */
.kpi-card {
  border: none;
  border-radius: 10px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  transition: transform 0.2s, box-shadow 0.2s;
}

.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.kpi-card .card-body {
  padding: 1.25rem;
}

.kpi-icon {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
}

.kpi-value {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.2;
  color: var(--gts-charcoal);
}

.kpi-label {
  font-size: 0.8rem;
  color: #777;
  font-weight: 500;
}

.kpi-change {
  font-size: 0.75rem;
  font-weight: 600;
}

/* ---- Cards ---- */
.card {
  border: none;
  border-radius: 10px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.card-header {
  background: #fff;
  border-bottom: 1px solid #eee;
  font-weight: 600;
  padding: 1rem 1.25rem;
  border-radius: 10px 10px 0 0 !important;
}

/* ---- Tables ---- */
.table-card .table {
  margin-bottom: 0;
  font-size: 0.875rem;
}

.table-card .table thead th {
  background: #f8f9fa;
  border-bottom: 2px solid #e2e6ea;
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #555;
  white-space: nowrap;
  padding: 0.75rem 1rem;
}

.table-card .table tbody td {
  padding: 0.75rem 1rem;
  vertical-align: middle;
  border-bottom: 1px solid #f0f0f0;
}

.table-card .table tbody tr:hover {
  background-color: #fafbfd;
}

.table-card .table tbody tr { cursor: pointer; }

/* ---- Status Badges ---- */
.badge-status {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.35em 0.7em;
  border-radius: 20px;
  letter-spacing: 0.02em;
}

.badge-active { background: #d4edda; color: #155724; }
.badge-suspended { background: #fff3cd; color: #856404; }
.badge-inactive, .badge-deactivated { background: #f8d7da; color: #721c24; }
.badge-stock { background: #d1ecf1; color: #0c5460; }
.badge-online { background: #d4edda; color: #155724; }
.badge-offline { background: #e2e3e5; color: #383d41; }

/* ---- SIM Detail ---- */
.sim-detail-header {
  background: #fff;
  border-radius: 10px;
  padding: 1.5rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  margin-bottom: 1.5rem;
}

.sim-actions .btn {
  font-size: 0.8rem;
  padding: 0.4rem 1rem;
}

.detail-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #888;
  margin-bottom: 0.15rem;
}

.detail-value {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--gts-charcoal);
  margin-bottom: 1rem;
}

.detail-value .copy-btn {
  border: none;
  background: none;
  color: #aaa;
  cursor: pointer;
  font-size: 0.75rem;
  padding: 0;
  margin-left: 0.35rem;
}

.detail-value .copy-btn:hover { color: var(--gts-red); }

/* ---- Organization Tree ---- */
.org-tree {
  padding: 0;
}

.org-tree ul {
  list-style: none;
  padding-left: 1.5rem;
  margin: 0;
}

.org-tree > ul { padding-left: 0; }

.org-tree li {
  position: relative;
  padding: 0.35rem 0;
}

.org-tree li::before {
  content: '';
  position: absolute;
  left: -1rem;
  top: 0;
  height: 100%;
  border-left: 1px dashed #ccc;
}

.org-tree li::after {
  content: '';
  position: absolute;
  left: -1rem;
  top: 1.1rem;
  width: 0.75rem;
  border-bottom: 1px dashed #ccc;
}

.org-tree > ul > li::before,
.org-tree > ul > li::after { display: none; }

.org-node {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: #fff;
  border: 1px solid #e2e6ea;
  border-radius: 8px;
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.2s;
}

.org-node:hover {
  border-color: var(--gts-red);
  box-shadow: 0 2px 8px rgba(111, 15, 16, 0.1);
}

.org-node.level-0 {
  background: var(--gts-charcoal);
  color: #fff;
  border-color: var(--gts-charcoal);
  font-weight: 600;
}

.org-node.level-1 {
  background: var(--gts-red);
  color: #fff;
  border-color: var(--gts-red);
}

.org-node .org-sim-count {
  font-size: 0.7rem;
  background: rgba(0,0,0,0.15);
  padding: 0.15rem 0.5rem;
  border-radius: 10px;
}

.org-node.level-0 .org-sim-count,
.org-node.level-1 .org-sim-count {
  background: rgba(255,255,255,0.2);
}

/* ---- Notes Log ---- */
.notes-log .note-entry {
  padding: 0.75rem 0;
  border-bottom: 1px solid #f0f0f0;
}

.notes-log .note-entry:last-child { border-bottom: none; }

.note-meta {
  font-size: 0.75rem;
  color: #888;
}

.note-text {
  font-size: 0.875rem;
  margin-top: 0.25rem;
}

/* ---- Audit Log ---- */
.audit-action {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.3em 0.6em;
  border-radius: 4px;
}

.audit-activate { background: #d4edda; color: #155724; }
.audit-suspend { background: #fff3cd; color: #856404; }
.audit-deactivate { background: #f8d7da; color: #721c24; }
.audit-assign { background: #cce5ff; color: #004085; }
.audit-create { background: #d1ecf1; color: #0c5460; }

/* ---- Provider Status ---- */
.provider-card {
  border: none;
  border-radius: 10px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.provider-status-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
}

.provider-status-dot.healthy { background: #28a745; }
.provider-status-dot.degraded { background: #ffc107; }
.provider-status-dot.down { background: #dc3545; }

/* ---- Filter Bar ---- */
.filter-bar {
  background: #fff;
  border-radius: 10px;
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.filter-bar .form-control,
.filter-bar .form-select {
  font-size: 0.85rem;
  border-radius: 6px;
}

/* ---- Charts ---- */
.chart-container {
  position: relative;
  height: 280px;
  width: 100%;
}

.chart-container-sm {
  height: 200px;
}

/* ---- Confirmation Modal ---- */
.modal-confirm .modal-header {
  border-bottom: none;
  padding-bottom: 0;
}

.modal-confirm .modal-body {
  text-align: center;
  padding: 1.5rem 2rem;
}

.modal-confirm .confirm-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.75rem;
  margin: 0 auto 1rem;
}

/* ---- Responsive ---- */
@media (max-width: 991.98px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.show {
    transform: translateX(0);
  }
  .main-content {
    margin-left: 0;
  }
  .sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1035;
  }
  .sidebar-overlay.show { display: block; }
}

@media (max-width: 767.98px) {
  .page-content { padding: 1rem; }
  .kpi-value { font-size: 1.35rem; }
  .topbar { padding: 0 1rem; }
}

/* ---- Utilities ---- */
.text-mono {
  font-family: 'SF Mono', 'Fira Code', 'Fira Mono', monospace;
  font-size: 0.85rem;
}

.cursor-pointer { cursor: pointer; }

.transition-all {
  transition: all 0.2s ease;
}

/* Scrollbar styling */
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 4px; }

/* DataTables overrides */
.dataTables_wrapper .dataTables_length select,
.dataTables_wrapper .dataTables_filter input {
  font-size: 0.85rem;
  border-radius: 6px;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current {
  background: var(--gts-red) !important;
  border-color: var(--gts-red) !important;
  color: #fff !important;
}

/* Help button */
.help-toggle {
  position: fixed;
  bottom: 1rem;
  left: calc(var(--sidebar-width) + 1rem);
  z-index: 9998;
  background: #0d6efd;
  color: #fff;
  padding: 0.4rem 1rem;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  box-shadow: 0 2px 10px rgba(13, 110, 253, 0.3);
  border: none;
  cursor: pointer;
  transition: all 0.2s;
}

.help-toggle:hover {
  background: #0b5ed7;
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(13, 110, 253, 0.4);
}

@media (max-width: 991.98px) {
  .help-toggle { left: 1rem; }
}

/* Future feature placeholder */
.nav-link .badge-future {
  font-size: 0.5rem;
  padding: 0.15em 0.35em;
  background: rgba(255,255,255,0.15);
  color: rgba(255,255,255,0.5);
  border-radius: 3px;
  margin-left: auto;
}

/* Field tooltip styles */
[data-field-help] {
  position: relative;
  cursor: help;
  border-bottom: 1px dashed #ccc;
}

/* Feedback toggle */
.feedback-toggle {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  z-index: 9998;
  background: var(--gts-red);
  color: #fff;
  padding: 0.4rem 1rem;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  box-shadow: 0 2px 10px rgba(111, 15, 16, 0.3);
  border: none;
  cursor: pointer;
  transition: all 0.2s;
}

.feedback-toggle:hover {
  background: var(--gts-red-dark);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(111, 15, 16, 0.4);
}

/* Feedback panel */
.feedback-panel {
  position: fixed;
  bottom: 0;
  right: 0;
  width: 380px;
  max-height: 80vh;
  background: #fff;
  border-radius: 12px 0 0 0;
  box-shadow: -4px -4px 20px rgba(0,0,0,0.15);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  transition: transform 0.3s ease;
}

.feedback-panel.open {
  transform: translateY(0);
}

.feedback-panel-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid #eee;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

.feedback-panel-header h6 {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--gts-charcoal);
}

.feedback-panel-close {
  background: none;
  border: none;
  font-size: 1.25rem;
  color: #999;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.feedback-panel-close:hover { color: #333; }

.feedback-panel-body {
  padding: 1rem 1.25rem;
  overflow-y: auto;
  flex: 1;
}

.feedback-entries {
  margin-bottom: 1rem;
}

.feedback-entry {
  padding: 0.65rem 0;
  border-bottom: 1px solid #f0f0f0;
  font-size: 0.85rem;
  position: relative;
}

.feedback-entry:last-child { border-bottom: none; }

.feedback-entry-time {
  font-size: 0.7rem;
  color: #999;
  margin-bottom: 0.2rem;
}

.feedback-entry-text {
  color: #333;
  white-space: pre-wrap;
}

.feedback-entry-delete {
  position: absolute;
  top: 0.65rem;
  right: 0;
  background: none;
  border: none;
  color: #ccc;
  cursor: pointer;
  font-size: 0.75rem;
  padding: 0;
}

.feedback-entry-delete:hover { color: var(--gts-red); }

.feedback-entry-actions {
  position: absolute;
  top: 0.65rem;
  right: 0;
  display: flex;
  gap: 0.5rem;
}

.feedback-entry-action {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.75rem;
  padding: 0;
}

.feedback-entry-action[title="Archive"] { color: #0d6efd; }
.feedback-entry-action[title="Archive"]:hover { color: #0a58ca; }

.feedback-entry-action[title="Delete"] { color: #dc3545; }
.feedback-entry-action[title="Delete"]:hover { color: #a71d2a; }

.feedback-empty {
  text-align: center;
  color: #aaa;
  font-size: 0.85rem;
  padding: 1.5rem 0;
}

.feedback-input-area {
  padding: 1rem 1.25rem;
  border-top: 1px solid #eee;
  flex-shrink: 0;
}

.feedback-input-area textarea {
  font-size: 0.85rem;
  border-radius: 8px;
  resize: none;
}

.feedback-input-area .btn {
  font-size: 0.8rem;
}

.feedback-page-label {
  font-size: 0.65rem;
  color: #aaa;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.feedback-save-status {
  font-size: 0.75rem;
  font-weight: 500;
  transition: opacity 0.3s;
}

@media (max-width: 480px) {
  .feedback-panel { width: 100%; border-radius: 12px 12px 0 0; }
}

/* ============================================================
   Device View — Phase 1 components

   Status enum (must mirror mock-devices.js HEALTH_STATUSES):
     healthy / warning / failed / unknown / not_monitored

   Colors are intentionally semantic and not Bootstrap aliases so
   they survive a Bootstrap version bump.
   ============================================================ */

:root {
  --dv-status-healthy:       #1a7a2e;
  --dv-status-healthy-bg:    #e8f5ec;
  --dv-status-warning:       #b56b00;
  --dv-status-warning-bg:    #fdf2dc;
  --dv-status-failed:        #b91c1c;
  --dv-status-failed-bg:     #fde8e8;
  --dv-status-unknown:       #6b7280;
  --dv-status-unknown-bg:    #f1f3f5;
  --dv-status-not-monitored: #94a3b8;
  --dv-status-not-monitored-bg: #f1f5f9;
}

/* --- Chain pill row (compact 9-stage strip per device row) --- */

.chain-strip {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

.chain-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 4px;
  font-size: 0.65rem;
  font-weight: 700;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  text-decoration: none;
  cursor: help;
  border: 1px solid transparent;
  transition: transform 0.08s ease;
}

.chain-pill:hover { transform: translateY(-1px); }

.chain-pill--healthy        { background: var(--dv-status-healthy);          color: #fff; }
.chain-pill--warning        { background: var(--dv-status-warning);          color: #fff; }
.chain-pill--failed         { background: var(--dv-status-failed);           color: #fff; }
.chain-pill--unknown        { background: var(--dv-status-unknown);          color: #fff; opacity: 0.55; }
.chain-pill--not_monitored  { background: var(--dv-status-not-monitored-bg); color: var(--dv-status-not-monitored); border-color: var(--dv-status-not-monitored); }

/* --- Status pill (overall device health badge) --- */

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.status-pill--healthy        { background: var(--dv-status-healthy-bg);        color: var(--dv-status-healthy); }
.status-pill--warning        { background: var(--dv-status-warning-bg);        color: var(--dv-status-warning); }
.status-pill--failed         { background: var(--dv-status-failed-bg);         color: var(--dv-status-failed); }
.status-pill--unknown        { background: var(--dv-status-unknown-bg);        color: var(--dv-status-unknown); }
.status-pill--not_monitored  { background: var(--dv-status-not-monitored-bg);  color: var(--dv-status-not-monitored); }

.status-pill .bi { font-size: 0.7rem; }

/* --- Status source chip (Manual / API / Webhook / Calculated / Not Monitored) --- */

.source-chip {
  display: inline-block;
  padding: 0.05rem 0.4rem;
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  border-radius: 3px;
  background: #f1f3f5;
  color: #495057;
  border: 1px solid #dee2e6;
  text-transform: uppercase;
}

.source-chip--api           { background: #e7f1ff; color: #0b5394; border-color: #b6d4fe; }
.source-chip--webhook       { background: #f3e8ff; color: #6b21a8; border-color: #e9d5ff; }
.source-chip--calculated    { background: #fef3c7; color: #92400e; border-color: #fde68a; }
.source-chip--not_monitored { background: #f1f5f9; color: #94a3b8; border-color: #cbd5e1; }

/* --- Rollup card (per-stage counts at top of Device Health) --- */

.rollup-card {
  background: #fff;
  border: 1px solid #e9ecef;
  border-radius: 8px;
  padding: 1rem 1.25rem;
}

.rollup-card-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  font-weight: 700;
  color: #6c757d;
  letter-spacing: 0.06em;
  margin-bottom: 0.65rem;
}

.rollup-stages {
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  gap: 0.5rem;
}

@media (max-width: 1100px) {
  .rollup-stages { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 600px) {
  .rollup-stages { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.rollup-stage {
  border: 1px solid #e9ecef;
  border-radius: 6px;
  padding: 0.5rem 0.6rem;
  background: #fff;
  cursor: pointer;
  transition: border-color 0.1s ease, box-shadow 0.1s ease;
  text-decoration: none;
  color: inherit;
  display: block;
}

.rollup-stage:hover {
  border-color: #adb5bd;
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}

.rollup-stage-label {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  color: #6c757d;
  letter-spacing: 0.04em;
  margin-bottom: 0.2rem;
}

.rollup-stage-count {
  font-size: 0.95rem;
  font-weight: 700;
  color: #212529;
  line-height: 1.2;
}

.rollup-stage-sub {
  font-size: 0.7rem;
  color: #6c757d;
  margin-top: 0.1rem;
}

.rollup-stage--warning { border-left: 3px solid var(--dv-status-warning); }
.rollup-stage--failed  { border-left: 3px solid var(--dv-status-failed); }
.rollup-stage--healthy { border-left: 3px solid var(--dv-status-healthy); }

/* --- Device Health table --- */

.device-table { font-size: 0.85rem; }

.device-table tbody tr { cursor: pointer; }

.device-table tbody tr:hover { background: #f8f9fa; }

.device-table .device-name { font-weight: 600; color: #212529; }

.device-table .device-meta { font-size: 0.7rem; color: #6c757d; }

.device-table thead .sort-link {
  color: inherit;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.device-table thead .sort-link:hover { color: #0d6efd; }

.device-table thead .sort-indicator {
  font-size: 0.65rem;
  opacity: 0.65;
}

/* --- Scenario banner (shown when ?scenario= is active) --- */

.scenario-banner {
  background: #fff8e1;
  border: 1px solid #f7d77a;
  border-radius: 6px;
  padding: 0.55rem 0.85rem;
  font-size: 0.8rem;
  color: #5c4503;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.scenario-banner .scenario-name { font-weight: 700; }

.scenario-banner select {
  font-size: 0.8rem;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  border: 1px solid #d4b75a;
  background: #fff;
}

/* --- View action buttons on customers hierarchy nodes --- */

.org-view-actions {
  display: inline-flex;
  gap: 0.3rem;
  margin-left: 0.5rem;
}

.org-view-actions .btn {
  font-size: 0.7rem;
  padding: 0.1rem 0.5rem;
  line-height: 1.3;
}

/* --- Device Detail — expanded chain --- */

.chain-expanded {
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  gap: 0.4rem;
}

@media (max-width: 1100px) {
  .chain-expanded { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

.chain-stage-block {
  border: 1px solid #e9ecef;
  border-radius: 6px;
  padding: 0.5rem 0.4rem;
  background: #fff;
  cursor: pointer;
  position: relative;
  transition: border-color 0.1s ease, box-shadow 0.1s ease;
  display: block;
  text-decoration: none;
  color: inherit;
}

.chain-stage-block:hover {
  border-color: #adb5bd;
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}

.chain-stage-block.selected {
  border-color: #0d6efd;
  box-shadow: 0 0 0 2px rgba(13, 110, 253, 0.18);
}

.chain-stage-block .stage-band {
  height: 4px;
  border-radius: 2px;
  margin-bottom: 0.45rem;
}

.chain-stage-block .stage-band--healthy        { background: var(--dv-status-healthy); }
.chain-stage-block .stage-band--warning        { background: var(--dv-status-warning); }
.chain-stage-block .stage-band--failed         { background: var(--dv-status-failed); }
.chain-stage-block .stage-band--unknown        { background: var(--dv-status-unknown); opacity: 0.55; }
.chain-stage-block .stage-band--not_monitored  { background: var(--dv-status-not-monitored); }

.chain-stage-block .stage-name {
  font-size: 0.7rem;
  font-weight: 600;
  color: #212529;
  line-height: 1.2;
  margin-bottom: 0.2rem;
}

.chain-stage-block .stage-mini-status {
  font-size: 0.65rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #6c757d;
}

.chain-stage-block .stage-mini-status .bi {
  font-size: 0.65rem;
  margin-right: 0.15rem;
}

.chain-stage-block .stage-mini-status--healthy { color: var(--dv-status-healthy); }
.chain-stage-block .stage-mini-status--warning { color: var(--dv-status-warning); }
.chain-stage-block .stage-mini-status--failed  { color: var(--dv-status-failed); }
.chain-stage-block .stage-mini-status--unknown { color: var(--dv-status-unknown); }
.chain-stage-block .stage-mini-status--not_monitored { color: var(--dv-status-not-monitored); }

/* --- Stage diagnostics panel (inline detail for selected chain stage) --- */

.stage-diagnostics {
  background: #fff;
  border: 1px solid #e9ecef;
  border-radius: 8px;
  padding: 1.25rem 1.5rem;
}

.stage-diagnostics .stage-diagnostics-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 0.85rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid #f1f3f5;
}

.stage-diagnostics .stage-diagnostics-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0;
}

.stage-diagnostics .stage-diagnostics-sub {
  font-size: 0.8rem;
  color: #6c757d;
  margin-top: 0.15rem;
}

.stage-diagnostics .diagnostic-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.7rem 1.5rem;
  font-size: 0.85rem;
}

@media (max-width: 720px) {
  .stage-diagnostics .diagnostic-grid { grid-template-columns: 1fr; }
}

.stage-diagnostics .diagnostic-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #6c757d;
  margin-bottom: 0.15rem;
}

.stage-diagnostics .diagnostic-value {
  color: #212529;
  word-break: break-word;
}

.stage-diagnostics .diagnostic-value--muted {
  color: #adb5bd;
  font-style: italic;
}

.stage-diagnostics-actions {
  margin-top: 1rem;
  padding-top: 0.85rem;
  border-top: 1px solid #f1f3f5;
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* --- Device metadata grid (full device record on detail page) --- */

.device-meta-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem 2rem;
  font-size: 0.85rem;
}

@media (max-width: 720px) {
  .device-meta-grid { grid-template-columns: 1fr; }
}

.device-meta-grid .meta-row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  border-bottom: 1px solid #f1f3f5;
  padding: 0.4rem 0;
}

.device-meta-grid .meta-row .meta-key {
  color: #6c757d;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-weight: 600;
  white-space: nowrap;
}

.device-meta-grid .meta-row .meta-val {
  color: #212529;
  text-align: right;
  word-break: break-word;
}

.device-meta-grid .meta-row .meta-val--muted {
  color: #adb5bd;
  font-style: italic;
}

/* --- Outage timeline (mocked) --- */

.outage-timeline {
  position: relative;
  padding-left: 1.25rem;
}

.outage-timeline::before {
  content: '';
  position: absolute;
  left: 0.35rem;
  top: 0;
  bottom: 0;
  width: 2px;
  background: #e9ecef;
}

.outage-event {
  position: relative;
  padding-bottom: 0.85rem;
  font-size: 0.85rem;
}

.outage-event::before {
  content: '';
  position: absolute;
  left: -1.05rem;
  top: 0.35rem;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #adb5bd;
  border: 2px solid #fff;
}

.outage-event--resolved::before { background: var(--dv-status-healthy); }
.outage-event--failed::before   { background: var(--dv-status-failed); }
.outage-event--warning::before  { background: var(--dv-status-warning); }

.outage-event .outage-time {
  font-size: 0.7rem;
  color: #6c757d;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.outage-event .outage-summary {
  color: #212529;
  font-weight: 500;
}
