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

/* ==========================================================================
   Design System: Refined Minimalist Palette (Dark Slate, Charcoal & Clean Grays)
   Reduced Typography Scale, Calm Saturation, Elegant Hover Transitions
   ========================================================================== */

:root {
  /* Core Dark Palette */
  --dark-black: #090d16;
  --dark-slate: #0f172a;
  --dark-charcoal: #1e293b;
  --dark-gray: #334155;
  --gray-border: #cbd5e1;
  --gray-subtle: #e2e8f0;
  --gray-light: #f1f5f9;
  --gray-bg: #f8fafc;
  --pure-white: #ffffff;

  /* Semantic Typography Colors */
  --text-main: #0f172a;
  --text-sub: #334155;
  --text-muted: #64748b;
  --text-dim: #94a3b8;

  /* Calm Muted Status Tones (Toned Down, Non-Flashy) */
  --status-connected-bg: #f1f5f9;
  --status-connected-text: #0f172a;
  --status-connected-border: #cbd5e1;
  
  --status-waiting-bg: #fefce8;
  --status-waiting-text: #854d0e;
  --status-waiting-border: #fef08a;

  --status-danger-bg: #fef2f2;
  --status-danger-text: #991b1b;
  --status-danger-border: #fecaca;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 12px -2px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 12px 28px -6px rgba(15, 23, 42, 0.1);
  --shadow-hover: 0 8px 20px -4px rgba(15, 23, 42, 0.08);

  /* Transitions */
  --transition-fast: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  --transition-normal: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Base Document & Typography Scaling */
html {
  font-size: 14px; /* Scaled down base from 16px */
}

body {
  font-family: 'Cairo', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 0.875rem;
  line-height: 1.5;
  background-color: var(--gray-bg);
  color: var(--text-main);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Headings Scaled Down & Elegant */
h1, .h1 {
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--dark-slate);
  letter-spacing: -0.3px;
}

h2, .h2 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--dark-slate);
  letter-spacing: -0.2px;
}

h3, .h3 {
  font-size: 1.08rem;
  font-weight: 700;
  color: var(--dark-slate);
}

h4, .h4 {
  font-size: 0.98rem;
  font-weight: 600;
  color: var(--dark-slate);
}

h5, .h5 {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--dark-slate);
}

h6, .h6 {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--dark-gray);
}

p, span, label {
  font-size: 0.875rem;
}

small, .small {
  font-size: 0.78rem !important;
}

/* Navbar & Top Bar Exact Alignment */
.navbar {
  height: 56px;
  min-height: 56px;
  max-height: 56px;
  background-color: var(--pure-white) !important;
  border-bottom: 1px solid var(--gray-subtle) !important;
  box-shadow: none !important;
  padding: 0 20px !important;
  display: flex;
  align-items: center;
  box-sizing: border-box;
}

.brand-logo {
  font-weight: 800;
  font-size: 1.15rem;
  color: var(--dark-slate) !important;
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  transition: var(--transition-fast);
}

.brand-logo i {
  color: var(--dark-charcoal);
  font-size: 1.3rem;
  transition: var(--transition-fast);
}

.brand-logo:hover i {
  color: var(--dark-black);
  transform: scale(1.05);
}

/* Stat Cards */
.stat-card {
  background: var(--pure-white);
  border: 1px solid var(--gray-subtle);
  border-radius: 12px;
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  transition: var(--transition-fast);
  position: relative;
  overflow: hidden;
}

.stat-card:hover {
  border-color: var(--gray-border);
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
}

.stat-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  background: var(--gray-light);
  color: var(--dark-slate);
  border: 1px solid var(--gray-subtle);
  transition: var(--transition-fast);
}

.stat-card:hover .stat-icon {
  background: var(--dark-slate);
  color: var(--pure-white);
  border-color: var(--dark-slate);
}

.stat-icon.primary, .stat-icon.success, .stat-icon.info, .stat-icon.warning, .stat-icon.danger {
  background: var(--gray-light);
  color: var(--dark-slate);
}

.stat-card h2 {
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--dark-slate);
  margin-bottom: 2px;
}

.stat-card span.text-muted {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted) !important;
}

/* Main Table Container Card */
.main-card {
  background: var(--pure-white);
  border: 1px solid var(--gray-subtle);
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
}

/* Tables */
.table {
  color: var(--text-main);
  margin-bottom: 0;
  background-color: transparent;
  font-size: 0.82rem;
}

.table th {
  background-color: var(--gray-bg);
  border-bottom: 1px solid var(--gray-subtle);
  color: var(--text-sub);
  font-weight: 700;
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  padding: 11px 14px;
  vertical-align: middle;
}

.table td {
  border-bottom: 1px solid var(--gray-light);
  padding: 11px 14px;
  vertical-align: middle;
  font-size: 0.82rem;
}

.table-hover tbody tr {
  transition: background-color 0.15s ease;
}

.table-hover tbody tr:hover td {
  background-color: var(--gray-light);
}

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

/* Status Badges (Calm & High-End) */
.badge-status {
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.74rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.badge-connected {
  background: var(--status-connected-bg);
  color: var(--status-connected-text);
  border: 1px solid var(--status-connected-border);
}

.badge-connected::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: #059669;
}

.badge-waiting {
  background: var(--status-waiting-bg);
  color: var(--status-waiting-text);
  border: 1px solid var(--status-waiting-border);
}

.badge-waiting::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: #d97706;
}

.badge-disconnected {
  background: var(--status-danger-bg);
  color: var(--status-danger-text);
  border: 1px solid var(--status-danger-border);
}

.badge-disconnected::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: #dc2626;
}

.badge-banned {
  background: #450a0a;
  color: #ffffff;
  border: 1px solid #7f1d1d;
  box-shadow: var(--shadow-sm);
}

.badge-banned::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: #f87171;
}

.badge-logged-out {
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #cbd5e1;
}

/* ==========================================================================
   Buttons System: Monochrome Luxury (Dark Slate / Charcoal with Hover State)
   ========================================================================== */

.btn {
  font-size: 0.82rem;
  font-weight: 600;
  border-radius: 8px;
  padding: 6px 14px;
  transition: var(--transition-fast);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
}

.btn-sm {
  font-size: 0.76rem;
  padding: 4px 10px;
  border-radius: 6px;
}

.btn-lg {
  font-size: 0.9rem;
  padding: 8px 18px;
  border-radius: 10px;
}

/* Primary & Success Buttons -> 12-15% Soft Dark Slate Tint */
.btn-primary, .btn-success {
  background-color: rgba(15, 23, 42, 0.12) !important;
  border: 1px solid rgba(15, 23, 42, 0.22) !important;
  color: #0f172a !important;
  font-weight: 700 !important;
  box-shadow: none !important;
}

/* Hover: Deepens smoothly to 20-22% tint */
.btn-primary:hover, .btn-success:hover, .btn-primary:focus, .btn-success:focus {
  background-color: rgba(15, 23, 42, 0.22) !important;
  border-color: rgba(15, 23, 42, 0.35) !important;
  color: #0f172a !important;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.08) !important;
}

/* Outline Buttons -> Crisp Transparent to 15% Tint on Hover */
.btn-outline-primary, .btn-outline-success {
  background-color: transparent !important;
  border: 1px solid rgba(15, 23, 42, 0.22) !important;
  color: #0f172a !important;
  font-weight: 600 !important;
}

.btn-outline-primary:hover, .btn-outline-success:hover {
  background-color: rgba(15, 23, 42, 0.14) !important;
  border-color: rgba(15, 23, 42, 0.3) !important;
  color: #0f172a !important;
  transform: translateY(-1px);
}

/* Secondary, Light & Info Buttons -> Soft 5-8% Neutral Tint */
.btn-outline-secondary, .btn-secondary, .btn-light, .btn-outline-info, .btn-info {
  background-color: rgba(15, 23, 42, 0.04) !important;
  border: 1px solid rgba(15, 23, 42, 0.14) !important;
  color: #334155 !important;
  font-weight: 600 !important;
}

.btn-outline-secondary:hover, .btn-secondary:hover, .btn-light:hover, .btn-outline-info:hover, .btn-info:hover {
  background-color: rgba(15, 23, 42, 0.12) !important;
  border-color: rgba(15, 23, 42, 0.25) !important;
  color: #0f172a !important;
  transform: translateY(-1px);
}

/* Warning Buttons (e.g. logs.txt in top bar) -> Soft 8-12% Warm Slate Tint */
.btn-outline-warning, .btn-warning {
  background-color: rgba(15, 23, 42, 0.05) !important;
  border: 1px solid rgba(15, 23, 42, 0.18) !important;
  color: #0f172a !important;
  font-weight: 600 !important;
}

.btn-outline-warning:hover, .btn-warning:hover {
  background-color: rgba(15, 23, 42, 0.14) !important;
  border-color: rgba(15, 23, 42, 0.3) !important;
  color: #0f172a !important;
  transform: translateY(-1px);
}

/* Danger Buttons -> Soft 10-12% Calm Red Tint */
.btn-outline-danger, .btn-danger {
  background-color: rgba(220, 38, 38, 0.08) !important;
  border: 1px solid rgba(220, 38, 38, 0.22) !important;
  color: #991b1b !important;
  font-weight: 600 !important;
}

.btn-outline-danger:hover, .btn-danger:hover {
  background-color: rgba(220, 38, 38, 0.16) !important;
  border-color: rgba(220, 38, 38, 0.35) !important;
  color: #7f1d1d !important;
  transform: translateY(-1px);
}

/* Key Badge */
.key-badge {
  background: var(--gray-light);
  border: 1px solid var(--gray-border);
  padding: 4px 10px;
  border-radius: 6px;
  font-family: Consolas, monospace;
  font-size: 0.78rem;
  color: var(--dark-slate);
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
}

.key-badge i {
  cursor: pointer;
  color: var(--dark-gray);
  font-size: 0.88rem;
  transition: var(--transition-fast);
}

.key-badge i:hover {
  color: var(--dark-slate);
  transform: scale(1.15);
}

.key-badge .code-snippet {
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  direction: ltr;
}

@media (max-width: 575.98px) {
  .key-badge .code-snippet {
    max-width: 130px;
  }
}

/* Modals */
.modal {
  z-index: 1070;
}
.modal-backdrop {
  z-index: 1065;
}

.modal-content {
  background-color: var(--pure-white);
  border: 1px solid var(--gray-subtle);
  border-radius: 14px;
  color: var(--text-main);
  box-shadow: var(--shadow-lg);
}

#subscriptionModal .modal-dialog {
  max-width: 95vw;
}
@media (min-width: 992px) {
  #subscriptionModal .modal-dialog {
    max-width: 1120px;
  }
}
@media (min-width: 1400px) {
  #subscriptionModal .modal-dialog {
    max-width: 1220px;
  }
}

.btn-xs {
  padding: 0.22rem 0.55rem;
  font-size: 0.75rem;
  border-radius: 6px;
}

.modal-header {
  border-bottom: 1px solid var(--gray-subtle);
  background-color: var(--pure-white);
  padding: 14px 18px;
}

.modal-header .modal-title {
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--dark-slate);
}

.modal-body {
  padding: 16px 18px;
}

.modal-footer {
  border-top: 1px solid var(--gray-subtle);
  background-color: var(--gray-bg);
  padding: 12px 18px;
}

/* Form Inputs & Selects */
.form-control, .form-select {
  background-color: var(--pure-white);
  border: 1px solid var(--gray-border);
  color: var(--dark-slate);
  border-radius: 8px;
  padding: 7px 12px;
  font-size: 0.84rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-control:focus, .form-select:focus {
  background-color: var(--pure-white);
  border-color: var(--dark-slate);
  color: var(--dark-slate);
  box-shadow: 0 0 0 0.2rem rgba(15, 23, 42, 0.08);
}

.form-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--dark-slate);
  margin-bottom: 4px;
}

/* QR Code Box */
.qr-box {
  background: var(--pure-white);
  padding: 16px;
  border-radius: 12px;
  display: inline-block;
  border: 2px dashed var(--gray-border);
  box-shadow: var(--shadow-sm);
}

.qr-box img {
  width: 220px;
  height: 220px;
  object-fit: contain;
}

/* System Logs & Code Previews */
pre.api-code-block {
  background-color: var(--gray-bg) !important;
  color: var(--dark-slate) !important;
  border: 1px solid var(--gray-subtle) !important;
  border-radius: 8px;
  font-size: 0.82rem !important;
}

/* Universal Badge Styling */
.badge.bg-dark {
  background-color: var(--dark-slate) !important;
  border: 1px solid var(--dark-charcoal) !important;
  color: var(--pure-white) !important;
  font-size: 0.74rem;
}

.badge.bg-success, .badge.text-bg-success {
  background-color: var(--dark-charcoal) !important;
  border: 1px solid var(--dark-gray) !important;
  color: var(--pure-white) !important;
}

.badge.bg-secondary, .badge.text-bg-secondary {
  background-color: var(--gray-light) !important;
  border: 1px solid var(--gray-border) !important;
  color: var(--dark-slate) !important;
}

/* ==========================================================================
   Instance View Mode Switcher (List vs Grid)
   ========================================================================== */
.view-mode-switcher {
  display: inline-flex;
  align-items: center;
  background-color: rgba(15, 23, 42, 0.05);
  border: 1px solid rgba(15, 23, 42, 0.14);
  border-radius: 8px;
  padding: 2px;
  gap: 2px;
}

.view-mode-btn {
  border: none;
  background: transparent;
  color: #64748b;
  padding: 4px 10px;
  font-size: 0.78rem;
  font-weight: 600;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  transition: all 0.15s ease-in-out;
  line-height: 1.2;
  user-select: none;
}

.view-mode-btn:hover {
  color: #0f172a;
}

.view-mode-btn.active {
  background-color: #ffffff;
  color: #0f172a;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.12);
  font-weight: 700;
}

/* ==========================================================================
   Hierarchical Instance & Device Cards (List / Rows)
   ========================================================================== */
.instance-card {
  background: var(--pure-white);
  border: 1px solid var(--gray-subtle);
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 18px;
  overflow: hidden;
  transition: var(--transition-fast);
}

.instance-card:hover {
  border-color: var(--gray-border);
  box-shadow: var(--shadow-hover);
}

.instance-card.instance-deactivated {
  border-color: #fecaca;
  background-color: #fffafb;
  opacity: 0.9;
}

.instance-header {
  padding: 14px 18px;
  background: var(--pure-white);
  border-bottom: 1px solid var(--gray-light);
}

.instance-title-wrapper {
  cursor: pointer;
  border-radius: 6px;
  padding: 3px 6px;
  margin-right: -6px;
  transition: var(--transition-fast);
  user-select: none;
}

.instance-title-wrapper:hover {
  background-color: var(--gray-light);
}

.instance-title-wrapper:hover .instance-title-link {
  color: var(--dark-black) !important;
}

.instance-title-wrapper:hover i {
  color: var(--dark-black) !important;
  transform: translateX(-3px);
}

.instance-title-wrapper i {
  transition: transform 0.2s ease, color 0.2s ease;
}

.instance-card.instance-deactivated .instance-header {
  background: #fff1f2;
}

/* ==========================================================================
   Instance Grid Cards (مربعات)
   ========================================================================== */
.instance-grid-card {
  background: var(--pure-white);
  border: 1px solid var(--gray-subtle);
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
  transition: var(--transition-fast);
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.instance-grid-card:hover {
  border-color: var(--gray-border);
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
}

.instance-grid-card.instance-deactivated {
  border-color: #fecaca;
  background-color: #fffafb;
  opacity: 0.92;
}

.instance-grid-header {
  padding: 14px 16px;
  background: var(--pure-white);
  border-bottom: 1px solid var(--gray-light);
}

.instance-grid-card.instance-deactivated .instance-grid-header {
  background: #fff1f2;
}

.instance-grid-body {
  padding: 14px 16px;
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.instance-grid-footer {
  padding: 10px 14px;
  background: #f8fafc;
  border-top: 1px solid var(--gray-light);
}

.device-subtable {
  background-color: var(--gray-bg);
  margin-bottom: 0;
}

.device-subtable th {
  background-color: #edf2f7;
  color: var(--text-sub);
  font-size: 0.74rem;
  font-weight: 700;
  padding: 9px 14px;
}

.device-subtable td {
  padding: 10px 14px;
  background-color: var(--pure-white);
  border-bottom: 1px solid var(--gray-light);
  font-size: 0.8rem;
}

.device-subtable tr:hover td {
  background-color: var(--gray-light);
}

.device-deactivated td {
  background-color: #fff5f5 !important;
}

/* Active / Inactive Status Badges & Buttons */
.badge-active {
  background: var(--gray-light);
  color: var(--dark-slate);
  border: 1px solid var(--gray-border);
  font-weight: 700;
  border-radius: 20px;
  padding: 3px 10px;
  font-size: 0.74rem;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.badge-active::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: #059669;
}

.badge-inactive {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
  font-weight: 700;
  border-radius: 20px;
  padding: 3px 10px;
  font-size: 0.74rem;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.badge-inactive::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: #dc2626;
}

.btn-toggle-badge {
  cursor: pointer;
  transition: all 0.2s ease-in-out;
  line-height: 1.2;
}

.btn-toggle-badge:hover {
  filter: brightness(0.94);
  box-shadow: 0 1px 4px rgba(0,0,0,0.12);
  transform: translateY(-1px);
}

.btn-toggle-status {
  padding: 3px 8px;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 6px;
  transition: var(--transition-fast);
}

.btn-toggle-status.active-state {
  background-color: var(--gray-light);
  color: var(--dark-slate);
  border: 1px solid var(--gray-border);
}

.btn-toggle-status.active-state:hover {
  background-color: var(--dark-charcoal);
  color: var(--pure-white);
  border-color: var(--dark-charcoal);
}

.btn-toggle-status.inactive-state {
  background-color: #fef2f2;
  color: #dc2626;
  border: 1px solid #fca5a5;
}

.btn-toggle-status.inactive-state:hover {
  background-color: #991b1b;
  color: var(--pure-white);
  border-color: #991b1b;
}

/* ==========================================================================
   Modern Sidebar Layout (RTL & Sophisticated Charcoal Black)
   ========================================================================== */
.app-layout {
  display: flex;
  min-height: 100vh;
  position: relative;
  background-color: var(--gray-bg);
}

.app-sidebar {
  width: 245px;
  background: var(--gray-bg); /* Identical to main area (#f8fafc) */
  color: var(--text-main);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 1040;
  box-shadow: -1px 0 10px rgba(15, 23, 42, 0.04);
  border-left: 1px solid var(--gray-subtle);
  transition: right 0.25s ease;
}

.sidebar-header {
  height: 56px;
  min-height: 56px;
  max-height: 56px;
  padding: 0 18px;
  background: var(--pure-white);
  border-bottom: 1px solid var(--gray-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  box-sizing: border-box;
}

.sidebar-brand {
  font-weight: 800;
  font-size: 1.05rem;
  color: var(--dark-slate);
  text-decoration: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 0 auto;
}

.sidebar-brand i {
  color: var(--dark-slate);
  font-size: 1.25rem;
}

.sidebar-brand span {
  letter-spacing: -0.2px;
}

.sidebar-menu {
  flex-grow: 1;
  padding: 12px 10px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-heading {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  padding: 10px 10px 4px 10px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--text-sub);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.84rem;
  transition: var(--transition-fast);
  border: 1px solid transparent;
}

.sidebar-link i {
  font-size: 1.05rem;
  color: var(--text-muted);
  transition: var(--transition-fast);
}

/* Hover: Distinct Gray Transition with dark text */
.sidebar-link:hover {
  background: var(--gray-subtle);
  color: var(--dark-slate);
  transform: translateX(-2px);
}

.sidebar-link:hover i {
  color: var(--dark-slate);
}

/* Active State: Soft 12-15% Tint (Calm & Non-Intrusive) */
.sidebar-link.active {
  background: rgba(15, 23, 42, 0.12) !important;
  color: var(--dark-slate) !important;
  border-right: 3px solid var(--dark-slate);
  font-weight: 700;
  box-shadow: none;
}

.sidebar-link.active i {
  color: var(--dark-slate) !important;
}

.sidebar-link .badge-counter {
  margin-right: auto;
  background: var(--gray-subtle);
  color: var(--dark-slate);
  font-size: 0.72rem;
  padding: 2px 6px;
  border-radius: 12px;
}

.sidebar-link.active .badge-counter {
  background: rgba(15, 23, 42, 0.18);
  color: var(--dark-slate);
}

.sidebar-footer {
  padding: 14px 12px;
  border-top: 1px solid var(--gray-subtle);
  background: var(--gray-light);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Main Content Area */
.app-main {
  flex-grow: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

@media (min-width: 992px) {
  .app-main {
    margin-right: 245px;
  }
}

@media (max-width: 991.98px) {
  .app-sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    right: 0 !important;
    width: 260px;
    max-width: 82vw;
    z-index: 1060;
    transform: translateX(105%);
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  }
  .app-sidebar.show {
    transform: translateX(0);
    box-shadow: -8px 0 25px rgba(0, 0, 0, 0.35);
  }
  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    background-color: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(2px);
    z-index: 1055;
    opacity: 0;
    visibility: hidden;
    transition: all 0.25s ease;
  }
  .sidebar-backdrop.show {
    opacity: 1;
    visibility: visible;
  }
}

/* Device Mobile Card (< 768px screens) */
.device-mobile-card {
  background: var(--pure-white);
  border: 1px solid var(--gray-subtle);
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
}

.device-mobile-card.device-deactivated {
  background: #fff8f8;
  border-color: #fecaca;
}

/* Views & Animation */
.view-pane {
  display: none;
}

.view-pane.active {
  display: block;
  animation: fadeInPane 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes fadeInPane {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Filter Pills */
.filter-pills-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.filter-pill {
  border: 1px solid var(--gray-subtle);
  background-color: var(--pure-white);
  color: var(--text-muted);
  border-radius: 20px;
  padding: 5px 12px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  user-select: none;
}

.filter-pill i {
  color: inherit !important;
  font-size: 0.84rem;
}

/* Filter Pill Hover: Crisp Dark Border */
.filter-pill:hover {
  border-color: var(--dark-slate);
  color: var(--dark-slate);
  background-color: var(--gray-light);
}

/* Filter Pill Active: Subtle 12-15% Tint */
.filter-pill.active {
  background-color: rgba(15, 23, 42, 0.12);
  border-color: rgba(15, 23, 42, 0.25);
  color: var(--dark-slate) !important;
  font-weight: 700;
  box-shadow: none;
}

.filter-pill.active .badge-count {
  background-color: rgba(15, 23, 42, 0.18);
  color: var(--dark-slate);
}

.filter-pill .badge-count {
  background-color: var(--gray-light);
  color: var(--dark-gray);
  font-size: 0.72rem;
  padding: 2px 6px;
  border-radius: 10px;
}

/* Nav Pills (Documentation & Settings Views / Modals) */
.nav-pills .nav-link {
  font-size: 0.8rem;
  font-weight: 600;
  padding: 6px 14px;
  color: var(--text-sub);
  border-radius: 8px;
  border: 1px solid transparent;
  transition: var(--transition-fast);
}

.nav-pills .nav-link:hover {
  background-color: var(--gray-light);
  color: var(--dark-slate);
}

/* Active Nav Pill: Soft 12-15% Tint (Calm & Non-Intrusive) */
.nav-pills .nav-link.active {
  background-color: rgba(15, 23, 42, 0.12) !important;
  color: var(--dark-slate) !important;
  border-color: rgba(15, 23, 42, 0.22) !important;
  font-weight: 700;
  box-shadow: none;
}

/* Overview Stat Boxes (Instance Details) */
.overview-stat-box {
  background: var(--gray-bg);
  border: 1px solid var(--gray-subtle);
  border-radius: 10px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: var(--transition-fast);
  height: 100%;
}

.overview-stat-box:hover {
  background: var(--pure-white);
  border-color: var(--gray-border);
  box-shadow: var(--shadow-sm);
}

.overview-stat-box .stat-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  font-size: 1.1rem;
}

.overview-stat-box .stat-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}

.overview-stat-box .stat-value {
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.2;
  color: var(--dark-slate);
}

/* Backup Hero Card */
.backup-hero-card {
  background: var(--pure-white);
  border: 1px solid var(--gray-border);
  border-radius: 14px;
  padding: 24px;
  box-shadow: var(--shadow-sm);
}

.backup-feature-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.backup-feature-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--gray-light);
  color: var(--dark-slate);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
  border: 1px solid var(--gray-subtle);
}

/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: var(--gray-light);
}
::-webkit-scrollbar-thumb {
  background: var(--gray-border);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--dark-gray);
}

/* ==========================================================================
   Cohesive Utility Overrides (Tone Down Neon/Bright Colors)
   ========================================================================== */

.text-success {
  color: #065f46 !important;
}

.text-primary {
  color: var(--dark-slate) !important;
}

.text-info {
  color: var(--dark-gray) !important;
}

.text-warning {
  color: #92400e !important;
}

.bg-success-subtle {
  background-color: var(--gray-light) !important;
}

.border-success-subtle {
  border-color: var(--gray-border) !important;
}

.bg-primary-subtle {
  background-color: var(--gray-light) !important;
}

.border-primary-subtle {
  border-color: var(--gray-border) !important;
}

/* Calm Minimalist Alerts */
.alert {
  border-radius: 10px;
  font-size: 0.82rem;
  padding: 12px 16px;
  border-width: 1px;
}

.alert-primary, .alert-info, .alert-secondary {
  background-color: var(--gray-light);
  border-color: var(--gray-border);
  color: var(--dark-slate);
}

.alert-success {
  background-color: #f0fdf4;
  border-color: #bbf7d0;
  color: #065f46;
}

.alert-warning {
  background-color: #fffbeb;
  border-color: #fef08a;
  color: #854d0e;
}

.alert-danger {
  background-color: #fef2f2;
  border-color: #fecaca;
  color: #991b1b;
}

/* Card Hover Enhancements */
.card {
  border-color: var(--gray-subtle);
  border-radius: 12px;
  transition: var(--transition-fast);
}

.card:hover {
  border-color: var(--gray-border);
}

