/* ============================================================
   Server Console — Design System & Complete Styles
   ============================================================ */

/* --- CSS Variables (Dark Theme) --- */
:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface-hover: #222632;
  --border: #2a2e3a;
  --text: #e1e4eb;
  --text-muted: #8b90a0;
  --accent: #6c8cff;
  --accent-hover: #5a7aee;
  --green: #4ade80;
  --red: #f87171;
  --orange: #fb923c;
  --yellow: #facc15;

  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  --mono: 'SF Mono', 'Fira Code', 'Cascadia Code', 'Consolas', monospace;
  --radius: 8px;
  --radius-sm: 4px;
  --radius-lg: 12px;
  --shadow: 0 2px 8px rgba(0,0,0,0.3);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.4);
  --transition: 0.2s ease;
  --sidebar-width: 240px;
  --header-height: 56px;
}

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

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  color: var(--accent-hover);
}

/* --- Scrollbar Styling --- */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

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

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

* {
  scrollbar-width: thin;
  scrollbar-color: var(--border) var(--bg);
}

/* --- App Layout --- */
#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.app-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* --- Header --- */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-height);
  padding: 0 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 100;
}

.header h1 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 4px;
}

.header h1 span {
  color: var(--accent);
}

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

.env-badge {
  padding: 4px 12px;
  background: rgba(108, 140, 255, 0.15);
  color: var(--accent);
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.refresh-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: var(--surface-hover);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13px;
  transition: var(--transition);
}

.refresh-btn:hover {
  background: var(--border);
  color: var(--text);
}

.refresh-btn svg {
  width: 14px;
  height: 14px;
}

.refresh-btn.spinning svg {
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* --- Sidebar --- */
.sidebar {
  width: var(--sidebar-width);
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  overflow-x: hidden;
  flex-shrink: 0;
  padding: 8px 0;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
  border-left: 3px solid transparent;
  font-size: 13px;
  user-select: none;
}

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

.sidebar-item.active {
  background: rgba(108, 140, 255, 0.1);
  color: var(--accent);
  border-left-color: var(--accent);
}

.sidebar-item .icon {
  font-size: 16px;
  width: 22px;
  text-align: center;
  flex-shrink: 0;
}

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

.sidebar-item .count {
  background: var(--surface-hover);
  color: var(--text-muted);
  padding: 1px 7px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  min-width: 20px;
  text-align: center;
}

.sidebar-item.active .count {
  background: rgba(108, 140, 255, 0.2);
  color: var(--accent);
}

/* --- Detail Panel (Main Content) --- */
.detail-panel {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 24px;
  min-width: 0;
}

/* --- Loading Spinner --- */
.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 60px 20px;
  color: var(--text-muted);
  font-size: 14px;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* --- Page Title & Subtitle --- */
.page-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}

.page-subtitle {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 24px;
}

.page-header {
  margin-bottom: 24px;
}

.page-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 24px;
}

/* --- Stat Grid --- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.stat-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
}

.stat-box .stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

.stat-box .stat-value.green { color: var(--green); }
.stat-box .stat-value.red { color: var(--red); }
.stat-box .stat-value.orange { color: var(--orange); }
.stat-box .stat-value.yellow { color: var(--yellow); }
.stat-box .stat-value.accent { color: var(--accent); }

.stat-box .stat-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* --- App Grid --- */
.app-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

/* --- App Card --- */
.app-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  transition: var(--transition);
}

.app-card:hover {
  border-color: var(--accent);
  background: var(--surface-hover);
}

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

.app-card .app-name {
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.app-card .app-port {
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--mono);
  background: var(--bg);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
}

.app-card .app-details {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}

.app-card .app-detail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
}

.app-card .app-detail-row .label {
  color: var(--text-muted);
}

.app-card .app-detail-row .value {
  color: var(--text);
  font-family: var(--mono);
  font-size: 12px;
}

.app-card .actions {
  display: flex;
  gap: 6px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.app-card .actions .btn {
  flex: 1;
}

/* --- Metric Row --- */
.metric-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.metric-row:last-child {
  border-bottom: none;
}

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

.metric-row .metric-value {
  color: var(--text);
  font-weight: 600;
  font-family: var(--mono);
}

.metric-row .metric-extra {
  color: var(--text-muted);
  font-size: 12px;
  margin-left: 8px;
}

/* --- Status Dot --- */
.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-dot.green {
  background: var(--green);
  box-shadow: 0 0 6px rgba(74, 222, 128, 0.4);
}

.status-dot.red {
  background: var(--red);
  box-shadow: 0 0 6px rgba(248, 113, 113, 0.4);
}

.status-dot.yellow {
  background: var(--yellow);
  box-shadow: 0 0 6px rgba(250, 204, 21, 0.4);
}

.status-dot.orange {
  background: var(--orange);
  box-shadow: 0 0 6px rgba(251, 146, 60, 0.4);
}

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

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
  user-select: none;
}

.btn:hover {
  background: var(--surface-hover);
  border-color: var(--text-muted);
}

.btn:active {
  transform: scale(0.97);
}

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

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

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

.btn-danger {
  background: rgba(248, 113, 113, 0.15);
  color: var(--red);
  border-color: rgba(248, 113, 113, 0.3);
}

.btn-danger:hover {
  background: rgba(248, 113, 113, 0.25);
  border-color: var(--red);
}

.btn-success {
  background: rgba(74, 222, 128, 0.15);
  color: var(--green);
  border-color: rgba(74, 222, 128, 0.3);
}

.btn-success:hover {
  background: rgba(74, 222, 128, 0.25);
  border-color: var(--green);
}

.btn-warning {
  background: rgba(251, 146, 60, 0.15);
  color: var(--orange);
  border-color: rgba(251, 146, 60, 0.3);
}

.btn-warning:hover {
  background: rgba(251, 146, 60, 0.25);
  border-color: var(--orange);
}

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

.btn-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* --- Data Table --- */
.data-table-wrapper {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 24px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th {
  background: var(--surface);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  user-select: none;
  position: sticky;
  top: 0;
  z-index: 1;
}

.data-table th.sortable {
  cursor: pointer;
  transition: var(--transition);
}

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

.data-table th .sort-arrow {
  display: inline-block;
  margin-left: 4px;
  font-size: 10px;
  opacity: 0.3;
}

.data-table th.sort-asc .sort-arrow,
.data-table th.sort-desc .sort-arrow {
  opacity: 1;
  color: var(--accent);
}

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

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

.data-table tbody tr:nth-child(even) {
  background: rgba(26, 29, 39, 0.5);
}

.data-table tbody tr:hover {
  background: var(--surface-hover);
}

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

.data-table tbody tr.clickable {
  cursor: pointer;
}

/* --- Log Viewer --- */
.log-viewer {
  background: #0a0c10;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.6;
  color: var(--green);
  overflow: auto;
  max-height: 500px;
  white-space: pre-wrap;
  word-break: break-all;
}

.log-viewer .log-line {
  display: block;
  padding: 1px 0;
}

.log-viewer .log-line .timestamp {
  color: var(--text-muted);
}

.log-viewer .log-line.error {
  color: var(--red);
}

.log-viewer .log-line.warning {
  color: var(--orange);
}

/* --- Gauge --- */
.gauge-row {
  display: flex;
  gap: 24px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 24px;
}

.gauge {
  position: relative;
  width: 140px;
  height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
}

.gauge svg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.gauge .gauge-bg {
  fill: none;
  stroke: var(--border);
  stroke-width: 8;
}

.gauge .gauge-fill {
  fill: none;
  stroke-width: 8;
  stroke-linecap: round;
  transition: stroke-dasharray 0.6s ease;
}

.gauge-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
  z-index: 1;
}

.gauge-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  z-index: 1;
  margin-top: 2px;
}

/* --- Tab Bar --- */
.tab-bar {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
  overflow-x: auto;
}

.tab-btn {
  padding: 10px 18px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font);
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

.tab-btn:hover {
  color: var(--text);
  background: var(--surface-hover);
}

.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* --- Badges --- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.badge-green {
  background: rgba(74, 222, 128, 0.15);
  color: var(--green);
}

.badge-red {
  background: rgba(248, 113, 113, 0.15);
  color: var(--red);
}

.badge-yellow {
  background: rgba(250, 204, 21, 0.15);
  color: var(--yellow);
}

.badge-blue {
  background: rgba(108, 140, 255, 0.15);
  color: var(--accent);
}

.badge-orange {
  background: rgba(251, 146, 60, 0.15);
  color: var(--orange);
}

.badge-gray {
  background: rgba(139, 144, 160, 0.15);
  color: var(--text-muted);
}

/* --- Progress Bar --- */
.progress-bar {
  width: 100%;
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.4s ease;
  background: var(--accent);
}

.progress-fill.green { background: var(--green); }
.progress-fill.red { background: var(--red); }
.progress-fill.orange { background: var(--orange); }
.progress-fill.yellow { background: var(--yellow); }

/* --- Modal --- */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.15s ease;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 600px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.2s ease;
}

.modal.modal-wide {
  max-width: 900px;
}

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

.modal-header h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.modal-close {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

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

.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

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

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

/* --- Toast --- */
.toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  padding: 12px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 13px;
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.25s ease;
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 380px;
}

.toast.leaving {
  animation: toastOut 0.2s ease forwards;
}

.toast-success {
  border-left: 3px solid var(--green);
}

.toast-error {
  border-left: 3px solid var(--red);
}

.toast-warning {
  border-left: 3px solid var(--orange);
}

.toast-info {
  border-left: 3px solid var(--accent);
}

.toast .toast-icon {
  font-size: 16px;
  flex-shrink: 0;
}

@keyframes toastIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@keyframes toastOut {
  from { transform: translateX(0); opacity: 1; }
  to { transform: translateX(100%); opacity: 0; }
}

/* --- Empty State --- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
}

.empty-state .empty-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.5;
}

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

.empty-state .empty-message {
  font-size: 13px;
  color: var(--text-muted);
  max-width: 400px;
}

/* --- Search Input --- */
.search-input {
  width: 100%;
  max-width: 320px;
  padding: 8px 14px 8px 36px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 13px;
  font-family: var(--font);
  outline: none;
  transition: var(--transition);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%238b90a0' viewBox='0 0 24 24'%3E%3Cpath d='M21 21l-4.35-4.35M11 19a8 8 0 1 0 0-16 8 8 0 0 0 0 16z' stroke='%238b90a0' fill='none' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 10px center;
}

.search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(108, 140, 255, 0.15);
}

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

/* --- Code Block --- */
.code-block {
  background: #0a0c10;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.6;
  color: var(--text);
  overflow-x: auto;
  white-space: pre;
  tab-size: 4;
}

.code-block .keyword { color: var(--accent); }
.code-block .string { color: var(--green); }
.code-block .comment { color: var(--text-muted); }
.code-block .number { color: var(--orange); }

/* --- Card (generic container) --- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}

.card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-title .card-icon {
  font-size: 16px;
}

/* --- Alert Card --- */
.alert-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 8px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.alert-card.alert-critical {
  border-left: 3px solid var(--red);
}

.alert-card.alert-warning {
  border-left: 3px solid var(--orange);
}

.alert-card.alert-info {
  border-left: 3px solid var(--accent);
}

.alert-card .alert-icon {
  font-size: 18px;
  flex-shrink: 0;
  margin-top: 1px;
}

.alert-card .alert-body {
  flex: 1;
}

.alert-card .alert-title {
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 2px;
}

.alert-card .alert-message {
  font-size: 12px;
  color: var(--text-muted);
}

.alert-card .alert-time {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
}

/* --- Section --- */
.section {
  margin-bottom: 32px;
}

.section-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* --- Domain Card --- */
.domain-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.domain-card .domain-name {
  font-weight: 600;
  font-size: 14px;
  color: var(--accent);
}

.domain-card .domain-meta {
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: var(--text-muted);
}

/* --- Toggle Switch --- */
.toggle {
  position: relative;
  width: 40px;
  height: 22px;
  cursor: pointer;
}

.toggle input {
  display: none;
}

.toggle .toggle-slider {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--border);
  border-radius: 11px;
  transition: var(--transition);
}

.toggle .toggle-slider::before {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  left: 3px;
  bottom: 3px;
  background: var(--text-muted);
  border-radius: 50%;
  transition: var(--transition);
}

.toggle input:checked + .toggle-slider {
  background: var(--accent);
}

.toggle input:checked + .toggle-slider::before {
  transform: translateX(18px);
  background: #fff;
}

/* --- Form Elements --- */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-input {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 14px;
  font-family: var(--font);
  outline: none;
  transition: var(--transition);
}

.form-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(108, 140, 255, 0.15);
}

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

/* --- Login Page --- */
.login-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100%;
  padding: 20px;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px;
  width: 100%;
  max-width: 400px;
  text-align: center;
}

.login-card h2 {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 8px;
}

.login-card .login-subtitle {
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 28px;
}

.login-card .form-group {
  text-align: left;
}

.login-card .btn-primary {
  width: 100%;
  padding: 12px;
  font-size: 15px;
  margin-top: 8px;
}

.login-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0;
  color: var(--text-muted);
  font-size: 12px;
}

.login-divider::before,
.login-divider::after {
  content: '';
  flex: 1;
  border-top: 1px solid var(--border);
}

/* --- Sparkline --- */
.sparkline-container {
  display: inline-block;
  vertical-align: middle;
}

/* --- Toolbar Row --- */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.toolbar-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

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

/* --- Iframe container --- */
.iframe-container {
  width: 100%;
  height: 600px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg);
}

.iframe-container iframe {
  width: 100%;
  height: 100%;
  border: none;
}

/* --- Detail View (sub-page within a page) --- */
.detail-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
  margin-bottom: 16px;
  transition: var(--transition);
  background: none;
  border: none;
  font-family: var(--font);
  padding: 0;
}

.detail-back:hover {
  color: var(--accent);
}

/* --- Peer / Info Cards Grid --- */
.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

/* ============================================================
   Responsive Breakpoints
   ============================================================ */

/* <= 1200px */
@media (max-width: 1200px) {
  .stat-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .gauge-row {
    gap: 16px;
  }

  .gauge {
    width: 120px;
    height: 120px;
  }

  .gauge-value {
    font-size: 20px;
  }
}

/* <= 900px */
@media (max-width: 900px) {
  .sidebar {
    width: 56px;
    overflow: visible;
  }

  .sidebar-item .label,
  .sidebar-item .count {
    display: none;
  }

  .sidebar-item {
    justify-content: center;
    padding: 12px;
    border-left: none;
    border-bottom: 2px solid transparent;
  }

  .sidebar-item.active {
    border-left: none;
    border-bottom-color: var(--accent);
  }

  .sidebar-item .icon {
    margin: 0;
    font-size: 18px;
  }

  .detail-panel {
    padding: 16px;
  }

  .app-grid {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  }

  .page-header-row {
    flex-direction: column;
    align-items: stretch;
  }

  .modal {
    width: 95%;
    max-height: 90vh;
  }
}

/* <= 600px */
@media (max-width: 600px) {
  .header h1 {
    font-size: 15px;
  }

  .env-badge {
    display: none;
  }

  .stat-grid {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .stat-box .stat-value {
    font-size: 22px;
  }

  .gauge-row {
    flex-direction: column;
    align-items: center;
  }

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

  .detail-panel {
    padding: 12px;
  }

  .btn-group {
    flex-direction: column;
  }

  .btn-group .btn {
    width: 100%;
  }

  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }

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

  .data-table {
    font-size: 12px;
  }

  .data-table th,
  .data-table td {
    padding: 8px 10px;
  }
}
