/* ===================================================
   LILLYDOO Pulse - Dark Professional Monitoring Theme
   =================================================== */

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

:root {
  --bg-body: #1a1d23;
  --bg-sidebar: #141720;
  --bg-card: #242830;
  --bg-card-hover: #2a2f38;
  --bg-input: #1e2128;
  --bg-topbar: #1e2128;

  --border-color: #2e3340;
  --border-light: #363c4a;

  --text-primary: #e4e6eb;
  --text-secondary: #8b92a5;
  --text-muted: #5c6378;

  --accent-green: #00d68f;
  --accent-green-dim: rgba(0, 214, 143, 0.12);
  --accent-red: #ff3d71;
  --accent-red-dim: rgba(255, 61, 113, 0.12);
  --accent-orange: #ffaa00;
  --accent-orange-dim: rgba(255, 170, 0, 0.12);
  --accent-blue: #3366ff;
  --accent-blue-dim: rgba(51, 102, 255, 0.12);
  --accent-gray: #6b7280;
  --accent-gray-dim: rgba(107, 114, 128, 0.12);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;

  --shadow-card: 0 2px 8px rgba(0, 0, 0, 0.25);
  --shadow-card-hover: 0 4px 16px rgba(0, 0, 0, 0.35);
  --shadow-modal: 0 12px 40px rgba(0, 0, 0, 0.5);

  --sidebar-width: 240px;
  --topbar-height: 56px;

  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s ease;
}

html {
  font-size: 14px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg-body);
  color: var(--text-primary);
  line-height: 1.5;
  overflow-x: hidden;
  min-height: 100vh;
}

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

a:hover {
  text-decoration: underline;
}

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

::-webkit-scrollbar-track {
  background: transparent;
}

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

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

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

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 20px;
  height: var(--topbar-height);
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 0.3px;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.sidebar-brand i {
  color: var(--accent-green);
  font-size: 1.3rem;
}

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

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.93rem;
  font-weight: 500;
  transition: all var(--transition-fast);
  text-decoration: none;
  position: relative;
}

.nav-link:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-primary);
  text-decoration: none;
}

.nav-link.active {
  background: var(--accent-green-dim);
  color: var(--accent-green);
}

.nav-link.active i {
  color: var(--accent-green);
}

.nav-link i {
  width: 20px;
  text-align: center;
  font-size: 1rem;
  color: var(--text-muted);
  transition: color var(--transition-fast);
}

.nav-link:hover i {
  color: var(--text-secondary);
}

.sidebar-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border-color);
  flex-shrink: 0;
}

.version-tag {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ===================================================
   Topbar
   =================================================== */
.main-wrapper {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  transition: margin-left var(--transition-normal);
}

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

.sidebar-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 6px;
}

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

.topbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-clock {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* ===================================================
   Content Area
   =================================================== */
.content {
  padding: 24px;
  min-height: calc(100vh - var(--topbar-height));
}

/* ===================================================
   Buttons
   =================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 18px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
  white-space: nowrap;
  line-height: 1.4;
}

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

.btn:active {
  transform: translateY(0);
}

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

.btn-primary {
  background: var(--accent-green);
  color: #0d1117;
}

.btn-primary:hover {
  background: #00f0a0;
  box-shadow: 0 4px 14px rgba(0, 214, 143, 0.3);
}

.btn-danger {
  background: var(--accent-red);
  color: #fff;
}

.btn-danger:hover {
  background: #ff5a8a;
  box-shadow: 0 4px 14px rgba(255, 61, 113, 0.3);
}

.btn-secondary {
  background: var(--border-color);
  color: var(--text-primary);
}

.btn-secondary:hover {
  background: var(--border-light);
}

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

.btn-icon {
  background: none;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
  padding: 0;
  font-size: 0.9rem;
}

.btn-icon:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
  border-color: var(--border-light);
}

.btn-icon.spinning i {
  animation: spin 0.8s linear infinite;
}

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

/* ===================================================
   Cards
   =================================================== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  transition: box-shadow var(--transition-normal);
}

.card:hover {
  box-shadow: var(--shadow-card-hover);
}

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

.card-header h2 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.card-body {
  padding: 20px;
}

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

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-card);
  transition: all var(--transition-normal);
}

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

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

.stat-icon.blue {
  background: var(--accent-blue-dim);
  color: var(--accent-blue);
}

.stat-icon.green {
  background: var(--accent-green-dim);
  color: var(--accent-green);
}

.stat-icon.red {
  background: var(--accent-red-dim);
  color: var(--accent-red);
}

.stat-icon.orange {
  background: var(--accent-orange-dim);
  color: var(--accent-orange);
}

.stat-info {
  display: flex;
  flex-direction: column;
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.1;
  color: var(--text-primary);
}

.stat-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 2px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ===================================================
   Status Badges
   =================================================== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.badge-up,
.badge-valid {
  background: var(--accent-green-dim);
  color: var(--accent-green);
}

.badge-down,
.badge-expired,
.badge-critical {
  background: var(--accent-red-dim);
  color: var(--accent-red);
}

.badge-warning,
.badge-expiring {
  background: var(--accent-orange-dim);
  color: var(--accent-orange);
}

.badge-unknown,
.badge-pending {
  background: var(--accent-gray-dim);
  color: var(--accent-gray);
}

.badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
  background: currentColor;
}

/* ===================================================
   Tables
   =================================================== */
.table-wrapper {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

thead th {
  text-align: left;
  padding: 14px 16px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

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

tbody tr:hover {
  background: rgba(255, 255, 255, 0.02);
}

tbody td {
  padding: 16px 16px;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.875rem;
  color: var(--text-secondary);
  vertical-align: middle;
  line-height: 1.6;
}

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

.table-empty {
  text-align: center;
  padding: 40px 16px;
  color: var(--text-muted);
}

.table-empty i {
  font-size: 2rem;
  margin-bottom: 10px;
  display: block;
}

/* ===================================================
   Monitor Type Icons
   =================================================== */
.type-icon {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.type-icon i {
  font-size: 0.9rem;
}

.type-icon.ping i { color: var(--accent-blue); }
.type-icon.ssl i { color: var(--accent-orange); }

/* ===================================================
   Modal
   =================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-normal);
}

.modal-overlay.open {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-modal);
  width: 90%;
  max-width: 520px;
  max-height: 85vh;
  overflow-y: auto;
  transform: translateY(20px) scale(0.97);
  transition: transform var(--transition-normal);
}

.modal-overlay.open .modal {
  transform: translateY(0) scale(1);
}

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

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

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

.modal-close:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.05);
}

.modal-body {
  padding: 24px;
}

/* ===================================================
   Forms
   =================================================== */
.form-group {
  margin-bottom: 20px;
}

.form-group.condensed {
  margin-bottom: 12px;
}

.form-group.spaced {
  margin-bottom: 24px;
}

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

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

.form-control:focus {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(51, 102, 255, 0.15);
}

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

select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235c6378' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
  cursor: pointer;
}

textarea.form-control {
  resize: vertical;
  min-height: 80px;
}

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

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

.loading-spinner.hidden {
  display: none;
}

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

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

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
  pointer-events: auto;
  animation: toastIn 0.3s ease forwards;
  min-width: 260px;
  max-width: 400px;
}

.toast.removing {
  animation: toastOut 0.25s ease forwards;
}

.toast-success {
  background: #14352d;
  border: 1px solid var(--accent-green);
  color: var(--accent-green);
}

.toast-error {
  background: #351a24;
  border: 1px solid var(--accent-red);
  color: var(--accent-red);
}

.toast-warning {
  background: #352d14;
  border: 1px solid var(--accent-orange);
  color: var(--accent-orange);
}

.toast-info {
  background: #1a2435;
  border: 1px solid var(--accent-blue);
  color: var(--accent-blue);
}

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

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

/* ===================================================
   Section Header
   =================================================== */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.section-header h1 {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text-primary);
}

/* Page Header (alias) */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.page-header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
}

/* ===================================================
   Response Time Display
   =================================================== */
.response-time {
  font-variant-numeric: tabular-nums;
  color: var(--text-secondary);
}

.response-time.fast { color: var(--accent-green); }
.response-time.medium { color: var(--accent-orange); }
.response-time.slow { color: var(--accent-red); }

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

.empty-state i {
  font-size: 3rem;
  margin-bottom: 16px;
  display: block;
  opacity: 0.5;
}

.empty-state h3 {
  font-size: 1.1rem;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.empty-state p {
  font-size: 0.875rem;
  margin-bottom: 20px;
}

/* ===================================================
   Action Buttons Group
   =================================================== */
.action-btns {
  display: flex;
  gap: 6px;
}

/* ===================================================
   Uptime Bar
   =================================================== */
.uptime-bar {
  display: flex;
  gap: 3px;
  margin-top: 12px;
}

.uptime-block {
  flex: 1;
  height: 28px;
  border-radius: 3px;
  min-width: 8px;
  position: relative;
  cursor: pointer;
  transition: transform var(--transition-fast);
}

.uptime-block:hover {
  transform: scaleY(1.2);
}

.uptime-block.up { background: var(--accent-green); }
.uptime-block.down { background: var(--accent-red); }
.uptime-block.warning { background: var(--accent-orange); }
.uptime-block.empty { background: var(--bg-card); }

.uptime-block .tooltip {
  display: none;
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-body);
  border: 1px solid var(--border-color);
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 0.7rem;
  white-space: nowrap;
  margin-bottom: 4px;
  color: var(--text-primary);
  pointer-events: none;
  z-index: 10;
}

.uptime-block:hover .tooltip { display: block; }

/* ===================================================
   Detail View
   =================================================== */
.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px 24px;
  margin-bottom: 8px;
  padding: 4px 0;
}

.detail-item {
  padding: 4px 0;
}

.detail-item label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  display: block;
  margin-bottom: 6px;
}

.detail-item span {
  font-size: 0.95rem;
  color: var(--text-primary);
  word-break: break-all;
  line-height: 1.6;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 20px;
  cursor: pointer;
}

.back-link:hover {
  color: var(--accent-blue);
  text-decoration: none;
}

/* ===================================================
   Progress Bar
   =================================================== */
.progress-bar-wrapper {
  background: var(--bg-input);
  border-radius: 8px;
  height: 12px;
  overflow: hidden;
  margin-top: 8px;
}

.progress-bar-fill {
  height: 100%;
  border-radius: 8px;
  transition: width 0.4s ease;
}

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

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.4);
  }

  .main-wrapper {
    margin-left: 0;
  }

  .sidebar-toggle {
    display: block;
  }

  .content {
    padding: 16px;
  }

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

  .section-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
}

@media (max-width: 480px) {
  .stat-grid {
    grid-template-columns: 1fr;
  }

  .stat-card {
    padding: 16px;
  }
}

/* ===================================================
   Monitor Grid & Tiles
   =================================================== */
.monitor-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
  margin-bottom: 24px;
}

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

@media (max-width: 768px) {
  .monitor-grid {
    grid-template-columns: 1fr;
  }
}

.monitor-tile {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-left: 3px solid var(--accent-gray);
  border-radius: var(--radius-md);
  padding: 20px;
  box-shadow: var(--shadow-card);
  transition: transform var(--transition-normal), box-shadow var(--transition-normal), border-color var(--transition-normal);
}

.monitor-tile:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-card-hover);
  border-left-color: currentColor;
}

.monitor-tile.up {
  border-left-color: var(--accent-green);
}

.monitor-tile.up:hover {
  border-left-color: #00f0a0;
}

.monitor-tile.down {
  border-left-color: var(--accent-red);
}

.monitor-tile.down:hover {
  border-left-color: #ff5a8a;
}

.monitor-tile.warning {
  border-left-color: var(--accent-orange);
}

.monitor-tile.warning:hover {
  border-left-color: #ffc040;
}

.monitor-tile .tile-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.monitor-tile .tile-header .tile-name {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-right: 10px;
}

.monitor-tile .tile-target {
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
  font-size: 0.78rem;
  color: var(--text-muted);
  background: var(--bg-input);
  padding: 3px 8px;
  border-radius: 4px;
  display: inline-block;
  margin-bottom: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.monitor-tile .tile-metric {
  margin-bottom: 12px;
}

.monitor-tile .tile-metric .metric-value {
  font-size: 1.8rem;
  font-weight: 700;
  line-height: 1.1;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.monitor-tile .tile-metric .metric-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 2px;
}

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

.monitor-tile .tile-footer .last-checked {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.monitor-tile .tile-footer .btn {
  padding: 4px 10px;
  font-size: 0.75rem;
}

/* ===================================================
   Sparkline Card
   =================================================== */
.sparkline-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  padding: 20px;
  transition: box-shadow var(--transition-normal);
}

.sparkline-card:hover {
  box-shadow: var(--shadow-card-hover);
}

/* ===================================================
   Stat Number Status Colors
   =================================================== */
.stat-number.up {
  color: var(--accent-green);
}

.stat-number.down {
  color: var(--accent-red);
}

.stat-number.warning {
  color: var(--accent-orange);
}

/* ===================================================
   Status Badge Transitions & Pulse Animation
   =================================================== */
.badge {
  transition: background var(--transition-normal), color var(--transition-normal), box-shadow var(--transition-normal);
}

.badge-down,
.badge-expired,
.badge-critical {
  animation: badge-pulse 2s ease-in-out infinite;
}

@keyframes badge-pulse {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(255, 61, 113, 0.45);
  }
  50% {
    box-shadow: 0 0 0 6px rgba(255, 61, 113, 0);
  }
}

/* ── Category Tags ─────────────────────────────────────────── */
.category-tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.3px;
  white-space: nowrap;
  transition: all 0.2s ease;
}

.category-tag:hover {
  filter: brightness(1.2);
  transform: scale(1.05);
}

.category-tags-wrapper {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}

/* Category multi-select in forms */
.category-select {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 0;
}

.category-checkbox {
  cursor: pointer;
  user-select: none;
}

.category-checkbox input {
  display: none;
}

.category-chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: 16px;
  font-size: 0.75rem;
  font-weight: 600;
  transition: all 0.2s ease;
  opacity: 0.5;
}

.category-checkbox input:checked + .category-chip {
  opacity: 1;
  box-shadow: 0 0 0 1px var(--cat-color, #6b7280);
  filter: brightness(1.1);
}

.category-checkbox:hover .category-chip {
  opacity: 0.8;
}

/* Category filter bar */
.category-filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 12px 0;
  margin-bottom: 8px;
}

.category-filter-chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 14px;
  border-radius: 16px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.2s ease;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
}

.category-filter-chip:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.category-filter-chip.active {
  color: var(--chip-color, var(--text-primary));
  background: var(--chip-bg, var(--bg-tertiary));
  border-color: var(--chip-color, var(--text-muted));
}

.category-filter-chip .chip-count {
  margin-left: 6px;
  font-size: 0.65rem;
  opacity: 0.7;
}

/* ── Uptime Bars ───────────────────────────────────────────── */
.uptime-bars {
  display: flex;
  gap: 24px;
  padding: 16px 0;
}
.uptime-bars-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.uptime-bars-item label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  font-weight: 600;
}
@media (max-width: 768px) {
  .uptime-bars { flex-direction: column; gap: 12px; }
}

/* ── Method Badge ──────────────────────────────────────────── */
.method-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  font-family: monospace;
}
.method-badge.get { background: #00d68f20; color: #00d68f; }
.method-badge.head { background: #0080ff20; color: #0080ff; }
.method-badge.post { background: #ffaa0020; color: #ffaa00; }

/* ── Port State ────────────────────────────────────────────── */
.port-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 700;
}
.port-badge.open { background: #00d68f20; color: #00d68f; }
.port-badge.closed { background: #ff3d7120; color: #ff3d71; }
.port-badge.filtered { background: #ffaa0020; color: #ffaa00; }

/* ── Maintenance Cards ─────────────────────────────────────── */
.maintenance-section { margin-bottom: 24px; }
.maintenance-section h2 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.maintenance-section h2 .count-badge {
  background: var(--bg-tertiary);
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.75rem;
}

.maintenance-card {
  background: var(--bg-secondary, #242830);
  border-radius: 8px;
  padding: 16px 20px;
  margin-bottom: 10px;
  border-left: 3px solid var(--border-color, #2d3340);
  transition: all 0.2s ease;
}
.maintenance-card:hover {
  background: var(--bg-hover, #2a2f3a);
}
.maintenance-card.active {
  border-left-color: #ffaa00;
  background: rgba(255, 170, 0, 0.04);
}
.maintenance-card.upcoming {
  border-left-color: #0080ff;
}
.maintenance-card.past {
  border-left-color: var(--border-color, #2d3340);
  opacity: 0.6;
}
.maintenance-card .maint-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
}
.maintenance-card .maint-name {
  font-weight: 600;
  font-size: 1rem;
  color: var(--text-primary);
}
.maintenance-card .maint-time {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.maintenance-card .maint-monitors {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 6px;
}
.maintenance-card .maint-notes {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-style: italic;
  margin-top: 6px;
}

.maintenance-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  background: #ffaa0020;
  color: #ffaa00;
}

.recurring-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  background: #7b61ff20;
  color: #7b61ff;
}

/* ── All Monitors Toggle ───────────────────────────────────── */
.all-monitors-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bg-tertiary, #1e2230);
  border-radius: 6px;
  margin-bottom: 8px;
}
.all-monitors-toggle label {
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
}
.monitor-checklist {
  max-height: 200px;
  overflow-y: auto;
  padding: 8px;
  background: var(--bg-tertiary, #1e2230);
  border-radius: 6px;
}
.monitor-checklist label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  font-size: 0.85rem;
  cursor: pointer;
}
.monitor-checklist .type-group {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  padding: 8px 0 4px;
  font-weight: 600;
}

/* ── Past Section Toggle ───────────────────────────────────── */
.toggle-past-btn {
  background: none;
  border: 1px solid var(--border-color, #2d3340);
  color: var(--text-muted);
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s;
}
.toggle-past-btn:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

/* ── Body Match Icon ───────────────────────────────────────── */
.body-match-ok { color: #00d68f; }
.body-match-fail { color: #ff3d71; }

/* ===================================================
   Sidebar Documentation Links
   =================================================== */
.sidebar-docs {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 0 10px 12px;
}

.doc-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 500;
  transition: all var(--transition-fast);
  text-decoration: none;
}

.doc-link:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-secondary);
  text-decoration: none;
}

.doc-link i {
  width: 16px;
  text-align: center;
  font-size: 0.85rem;
}

/* Settings */
.settings-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border-color, #2d3340);
  padding-bottom: 0;
}
.settings-tab {
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 10px 18px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 6px;
}
.settings-tab:hover { color: var(--text-primary); }
.settings-tab.active {
  color: var(--accent-green, #00d68f);
  border-bottom-color: var(--accent-green, #00d68f);
}

.language-selector {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}
.lang-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 28px;
  min-width: 160px;
  border-radius: 8px;
  border: 2px solid var(--border-color, #2d3340);
  background: var(--bg-card, #242830);
  color: var(--text-primary);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}
.lang-btn:hover {
  border-color: var(--text-muted);
  background: var(--bg-card-hover, #2a2f3a);
}
.lang-btn.active {
  border-color: var(--accent-green, #00d68f);
  background: rgba(0, 214, 143, 0.08);
}
.lang-flag { font-size: 1.4rem; }

.token-field {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-input, #1e2230);
  border: 1px solid var(--border-color, #2d3340);
  border-radius: 8px;
  padding: 12px 16px;
}
.token-value {
  flex: 1;
  font-size: 0.9rem;
  font-family: monospace;
  word-break: break-all;
  color: var(--text-primary);
  letter-spacing: 1px;
}
.token-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.token-type-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
}
.token-type-badge.admin { background: #ff3d7120; color: #ff3d71; }
.token-type-badge.agent { background: #0080ff20; color: #0080ff; }
.token-type-badge.poller { background: #ffaa0020; color: #ffaa00; }

/* ===================================================
   Settings Page Spacing Improvements
   =================================================== */
.settings-section {
  padding: 18px 20px 20px;
  margin-bottom: 0;
}

.settings-section:last-child {
  margin-bottom: 0;
}

/* Cards inside settings panels need outer spacing */
.settings-panel .card {
  margin-bottom: 16px;
}
.settings-panel .card:last-child {
  margin-bottom: 0;
}

.settings-tabs {
  margin-bottom: 16px;
}

.card-body.condensed {
  padding: 12px;
}

.language-selector {
  gap: 14px;
  margin-top: 10px;
}
.language-selector .lang-btn { padding: 12px 22px; }

.token-display {
  margin: 12px 0;
  padding: 12px 14px;
  background: var(--bg-input);
  border-radius: var(--radius-md);
  font-family: monospace;
  font-size: 0.88rem;
  line-height: 1.4;
}

.token-field {
  gap: 8px;
  padding: 10px 14px;
}

/* Sidebar user display */
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  margin: 8px 12px;
  background: var(--bg-card, #242830);
  border-radius: 8px;
  border: 1px solid var(--border-color, #2d3340);
  font-size: 0.8rem;
  color: var(--text-secondary);
}
.sidebar-user i.fa-user-circle {
  font-size: 1.2rem;
  color: var(--accent-green, #00d68f);
}
.sidebar-user span {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-logout {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: all 0.2s;
}
.sidebar-logout:hover {
  color: var(--accent-red, #ff3d71);
  background: rgba(255, 61, 113, 0.1);
}

/* Login page */
.login-bg {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at top, #1a1d23 0%, #0d0f13 100%);
  padding: 20px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}
.login-card {
  background: #1e2230;
  border: 1px solid #2d3340;
  border-radius: 16px;
  padding: 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}
.login-brand {
  text-align: center;
  margin-bottom: 32px;
}
.login-brand i {
  font-size: 2.4rem;
  color: #00d68f;
  margin-bottom: 12px;
  display: block;
}
.login-brand h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: #f0f3f8;
  margin-bottom: 4px;
}
.login-brand p {
  font-size: 0.85rem;
  color: #8a92a3;
}
.login-form .form-group {
  margin-bottom: 18px;
}
.login-form label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: #a8b0c0;
  margin-bottom: 6px;
}
.login-form input {
  width: 100%;
  padding: 12px 14px;
  background: #15181f;
  border: 1px solid #2d3340;
  border-radius: 8px;
  color: #f0f3f8;
  font-size: 0.95rem;
  transition: border 0.2s;
  box-sizing: border-box;
}
.login-form input:focus {
  outline: none;
  border-color: #00d68f;
}
.login-btn {
  width: 100%;
  padding: 14px;
  background: #00d68f;
  color: #0d0f13;
  border: none;
  border-radius: 8px;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.2s;
}
.login-btn:hover { background: #00c280; }
.login-btn:disabled { opacity: 0.6; cursor: not-allowed; }
.login-error {
  background: rgba(255, 61, 113, 0.1);
  border: 1px solid rgba(255, 61, 113, 0.3);
  color: #ff3d71;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 0.85rem;
  margin-bottom: 16px;
  display: none;
}
.login-error.visible { display: block; }
.login-langs {
  text-align: center;
  margin-top: 24px;
  font-size: 0.75rem;
  color: #6b7280;
}
.login-langs a {
  color: #6b7280;
  text-decoration: none;
  margin: 0 6px;
  cursor: pointer;
}
.login-langs a.active { color: #00d68f; font-weight: 600; }
.login-langs a:hover { color: #f0f3f8; }

.token-type-badge.viewer { background: #6b728020; color: #6b7280; }
.token-type-badge.editor { background: #0080ff20; color: #0080ff; }

/* ===================================================
   Audit fixes (appended) - responsive & consistency
   =================================================== */

/* Ensure table-wrapper scrolls on narrow screens and tables can exceed viewport */
.table-wrapper {
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
}
@media (max-width: 768px) {
  .table-wrapper { overflow-x: auto; }
  .table-wrapper table { min-width: 560px; }
  thead th, tbody td { padding: 10px 12px; }
}

/* Action buttons stay on one row; wrap gracefully if truly needed */
.action-btns {
  flex-wrap: wrap;
  justify-content: flex-end;
}
@media (max-width: 480px) {
  .action-btns { gap: 4px; }
  .action-btns .btn,
  .action-btns .btn-icon { padding: 4px 8px; font-size: 0.75rem; }
}

/* Modal: responsive width with margins, scrollable body on small screens */
@media (max-width: 600px) {
  .modal-overlay { padding: 16px; align-items: flex-start; }
  .modal {
    width: 100%;
    max-width: 100%;
    max-height: calc(100vh - 32px);
    margin: 0;
  }
  .modal-header { padding: 14px 18px; }
  .modal-body { padding: 18px; }
  .form-actions { flex-direction: column-reverse; }
  .form-actions .btn { width: 100%; }
}

/* Form inputs: guarantee consistent box-sizing inside modals */
.modal .form-control,
.modal input,
.modal select,
.modal textarea {
  box-sizing: border-box;
  max-width: 100%;
}

/* Settings tabs: horizontal scroll instead of wrapping on mobile */
.settings-tabs {
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
}
.settings-tabs::-webkit-scrollbar { display: none; }
.settings-tab {
  white-space: nowrap;
  flex-shrink: 0;
}

/* Consistent card spacing inside settings tabs/panels */
.settings-panel > .card + .card,
.settings-panel > .settings-section + .settings-section {
  margin-top: 16px;
}

/* Toast container responsive - don't overflow or overlap on mobile */
@media (max-width: 480px) {
  .toast-container {
    top: 12px;
    right: 12px;
    left: 12px;
  }
  .toast {
    min-width: 0;
    max-width: 100%;
    width: 100%;
  }
}

/* Empty state centering guarantee */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

/* Disabled state for all button variants (icon buttons weren't covered) */
.btn-icon:disabled,
button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn-icon:disabled:hover {
  background: none;
  color: var(--text-secondary);
  border-color: var(--border-color);
}

/* Topbar on mobile: tighter padding so clock/title fit */
@media (max-width: 600px) {
  .topbar { padding: 0 14px; gap: 10px; }
  .topbar-title { font-size: 1rem; }
  .topbar-clock { display: none; }
}

/* Token field wrapping on narrow widths */
@media (max-width: 600px) {
  .token-field { flex-wrap: wrap; }
  .token-value { min-width: 0; word-break: break-all; }
}

/* Language selector full-width buttons on mobile */
@media (max-width: 480px) {
  .language-selector { flex-direction: column; }
  .lang-btn { width: 100%; min-width: 0; }
}

/* Page header stacks on mobile so Add buttons don't overflow */
@media (max-width: 600px) {
  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  .page-header h1 { font-size: 1.25rem; }
}

/* Multi-Source Picker */
.source-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 0;
}
.source-checkbox {
  cursor: pointer;
  user-select: none;
}
.source-checkbox-fixed {
  cursor: not-allowed;
}
.source-checkbox input {
  display: none;
}
.source-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 16px;
  font-size: 0.8rem;
  font-weight: 600;
  background: var(--bg-tertiary, #1e2230);
  border: 1px solid var(--border-color, #2d3340);
  color: var(--text-secondary);
  transition: all 0.2s ease;
  opacity: 0.55;
}
.source-checkbox input:checked + .source-chip {
  opacity: 1;
  background: rgba(0, 214, 143, 0.12);
  color: #00d68f;
  border-color: rgba(0, 214, 143, 0.5);
}
.source-checkbox-fixed .source-chip-public {
  opacity: 1;
  background: rgba(0, 214, 143, 0.12);
  color: #00d68f;
  border-color: rgba(0, 214, 143, 0.5);
}
.source-chip i.fa-globe { color: #00d68f; }
.source-chip i.fa-broadcast-tower { color: #ffaa00; }
.source-chip-hint {
  font-size: 0.7rem;
  font-weight: 400;
  opacity: 0.7;
  margin-left: 2px;
}

.source-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.7rem;
  font-weight: 600;
  vertical-align: middle;
  margin-right: 3px;
}
.source-badge-public {
  background: rgba(0, 214, 143, 0.12);
  color: #00d68f;
}
.source-badge-poller {
  background: rgba(255, 170, 0, 0.12);
  color: #ffaa00;
}
.source-badge i { font-size: 0.65rem; }

/* ===================================================
   Spacing Improvements — Cards, Sections, Detail Views
   =================================================== */

/* Consistent card spacing in content area */
.content .card + .card,
.content .card + .table-wrapper,
.content .table-wrapper + .card {
  margin-top: 24px;
}

/* Card body generous padding */
.card-body {
  padding: 20px 24px;
}

/* Card header breathing room */
.card-header {
  padding: 18px 24px;
}

/* Detail view sections need vertical breathing room */
.content h2,
.content h3 {
  margin-top: 28px;
  margin-bottom: 16px;
}

.content h2:first-child,
.content h3:first-child {
  margin-top: 0;
}

/* Monitor detail: space between info cards and history */
.detail-grid + .card,
.detail-grid + .table-wrapper,
.detail-grid + h3,
.detail-grid + h2 {
  margin-top: 24px;
}

/* Dashboard monitor grid: more gap */
.monitor-grid {
  gap: 20px;
  margin-bottom: 28px;
}

/* Dashboard stat grid: more gap */
.stat-grid {
  gap: 20px;
  margin-bottom: 28px;
}

/* Uptime bars inside tiles: breathing room */
.uptime-bars {
  margin-top: 8px;
  margin-bottom: 4px;
}

/* Source result cards in detail views */
.source-result-card {
  margin-bottom: 20px;
}

/* Category tags: slightly more spacing */
.category-tag {
  margin-bottom: 4px;
}

/* Form groups in modals: more vertical space */
.form-group + .form-group {
  margin-top: 18px;
}
