@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600;700&display=swap');

/* ==========================================================================
   DESIGN SYSTEM TOKENS & VARIABLES
   ========================================================================== */

:root, [data-theme="dark"] {
  --bg: #07090E;
  --bg-subtle: #0D111A;
  --sidebar-bg: #0B0E17;
  --card-bg: rgba(16, 22, 34, 0.75);
  --card-bg-solid: #101623;
  --card-hover: rgba(22, 30, 46, 0.85);
  --border: rgba(255, 255, 255, 0.08);
  --border-subtle: rgba(255, 255, 255, 0.04);
  --border-highlight: rgba(99, 102, 241, 0.35);
  
  --text-main: #F8FAFC;
  --text-muted: #94A3B8;
  --text-subtle: #64748B;
  
  --primary: #6366F1;
  --primary-hover: #4F46E5;
  --primary-glow: rgba(99, 102, 241, 0.3);
  --accent: #818CF8;
  
  --status-up-bg: rgba(16, 185, 129, 0.12);
  --status-up-text: #34D399;
  --status-up-border: rgba(16, 185, 129, 0.3);
  --status-up-glow: rgba(52, 211, 153, 0.25);
  
  --status-warn-bg: rgba(245, 158, 11, 0.12);
  --status-warn-text: #FBBF24;
  --status-warn-border: rgba(245, 158, 11, 0.3);
  
  --status-down-bg: rgba(239, 68, 68, 0.12);
  --status-down-text: #F87171;
  --status-down-border: rgba(239, 68, 68, 0.3);
  --status-down-glow: rgba(248, 113, 113, 0.25);

  --terminal-bg: #05070B;
  --terminal-header: #0C0F17;
  --terminal-text: #E2E8F0;
  --terminal-border: rgba(255, 255, 255, 0.06);

  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

  --radius-xs: 4px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 16px -2px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 12px 32px -4px rgba(0, 0, 0, 0.45);
  --shadow-glow: 0 0 20px var(--primary-glow);
}

[data-theme="light"] {
  --bg: #F4F6F9;
  --bg-subtle: #EBEEF3;
  --sidebar-bg: #FFFFFF;
  --card-bg: rgba(255, 255, 255, 0.9);
  --card-bg-solid: #FFFFFF;
  --card-hover: #F8FAFC;
  --border: #E2E8F0;
  --border-subtle: #F1F5F9;
  --border-highlight: rgba(79, 70, 229, 0.35);
  
  --text-main: #0F172A;
  --text-muted: #475569;
  --text-subtle: #94A3B8;
  
  --primary: #4F46E5;
  --primary-hover: #4338CA;
  --primary-glow: rgba(79, 70, 229, 0.2);
  --accent: #4F46E5;
  
  --status-up-bg: #ECFDF5;
  --status-up-text: #059669;
  --status-up-border: #A7F3D0;
  --status-up-glow: rgba(5, 150, 105, 0.15);
  
  --status-warn-bg: #FFFBEB;
  --status-warn-text: #D97706;
  --status-warn-border: #FDE68A;
  
  --status-down-bg: #FEF2F2;
  --status-down-text: #DC2626;
  --status-down-border: #FECACA;
  --status-down-glow: rgba(220, 38, 38, 0.15);

  --terminal-bg: #090D16;
  --terminal-header: #0F172A;
  --terminal-text: #F1F5F9;
  --terminal-border: #1E293B;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 12px -2px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 12px 28px -4px rgba(0, 0, 0, 0.12);
}

/* ==========================================================================
   BASE RESET & UTILITIES
   ========================================================================== */

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  background: var(--bg);
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: color 0.15s ease;
}

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

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
}

/* Focus Ring Accessibility Utility */
*:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* Keyframe Animations */
@keyframes pulse-dot {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 var(--status-up-glow); }
  70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

@keyframes pulse-down {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 var(--status-down-glow); }
  70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(239, 68, 68, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

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

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

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.skeleton {
  background: linear-gradient(90deg, var(--card-bg-solid) 25%, var(--border) 50%, var(--card-bg-solid) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-xs);
  display: inline-block;
}

/* ==========================================================================
   APP LAYOUT & SHELL
   ========================================================================== */

.app-container {
  display: flex;
  width: 100vw;
  min-height: 100vh;
  position: relative;
}

/* Sidebar */
.sidebar {
  width: 260px;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 24px 18px;
  flex-shrink: 0;
  z-index: 20;
}

.sidebar-header {
  margin-bottom: 28px;
  padding: 0 8px;
}

.brand-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.brand-icon-box {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, #6366F1 0%, #4F46E5 100%);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #FFFFFF;
  box-shadow: 0 4px 10px rgba(99, 102, 241, 0.35);
}

.brand-title {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text-main);
}

.user-profile-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--card-bg);
  border: 1px solid var(--border);
  padding: 10px 12px;
  border-radius: var(--radius-md);
  margin-top: 10px;
}

.user-avatar-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--primary);
  color: #FFFFFF;
  font-weight: 700;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-transform: uppercase;
}

.user-name-text {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  max-width: 120px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role-tag {
  font-size: 10px;
  color: var(--text-subtle);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Nav Menu */
.nav-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.nav-item:hover {
  background: var(--card-hover);
  color: var(--text-main);
}

.nav-item.active {
  background: var(--primary);
  color: #FFFFFF;
  box-shadow: 0 4px 12px var(--primary-glow);
}

.nav-icon {
  width: 18px;
  height: 18px;
  stroke-width: 2;
  flex-shrink: 0;
}

.btn-new-monitor {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 12px 16px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-hover) 100%);
  color: #FFFFFF;
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 14px var(--primary-glow);
  transition: all 0.2s ease;
}

.btn-new-monitor:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px var(--primary-glow);
}

.btn-new-monitor:active {
  transform: scale(0.98);
}

/* Main Workspace */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg);
}

/* Topbar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 68px;
  padding: 0 32px;
  background: var(--sidebar-bg);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 15;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.page-title {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-main);
}

.live-feed-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--status-up-bg);
  border: 1px solid var(--status-up-border);
  color: var(--status-up-text);
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.live-feed-badge .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--status-up-text);
  animation: pulse-dot 2s infinite;
}

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

.icon-btn {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  transition: all 0.15s ease;
}

.icon-btn:hover {
  background: var(--card-hover);
  color: var(--text-main);
  border-color: var(--border-highlight);
}

/* View Panels */
.view-panel {
  display: none;
  padding: 28px 32px 48px;
  flex-direction: column;
  gap: 24px;
  animation: fadeIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.view-panel.active {
  display: flex;
}

/* ==========================================================================
   STAT CARDS & METRICS
   ========================================================================== */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 18px;
}

.stat-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(8px);
  position: relative;
  overflow: hidden;
  transition: all 0.2s ease;
}

.stat-card:hover {
  border-color: var(--border-highlight);
  box-shadow: var(--shadow-md);
}

.stat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.stat-value {
  font-size: 38px;
  font-weight: 800;
  margin: 12px 0 6px;
  letter-spacing: -0.03em;
  font-family: var(--font-sans);
  color: var(--text-main);
}

.stat-breakdown {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 12px;
  font-weight: 600;
  margin-top: 10px;
}

.breakdown-item {
  display: flex;
  align-items: center;
  gap: 5px;
}
.breakdown-item.op { color: var(--status-up-text); }
.breakdown-item.deg { color: var(--status-warn-text); }
.breakdown-item.down { color: var(--status-down-text); }

.stat-subtitle {
  font-size: 12px;
  color: var(--text-subtle);
}

/* ==========================================================================
   CARDS, TABLES, & DATAGRIDS
   ========================================================================== */

.content-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(8px);
}

.card-header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--card-bg-solid);
  flex-wrap: wrap;
  gap: 12px;
}

.card-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.01em;
}

.table-filter-input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  color: var(--text-main);
  font-size: 13px;
  outline: none;
  min-width: 220px;
  transition: border 0.15s ease;
}

.table-filter-input:focus {
  border-color: var(--primary);
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.data-table th {
  padding: 14px 20px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  background: var(--card-bg-solid);
  border-bottom: 1px solid var(--border);
}

.data-table td {
  padding: 16px 20px;
  font-size: 13px;
  color: var(--text-main);
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
}

.data-table tbody tr {
  cursor: pointer;
  transition: background 0.15s ease;
}

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

.data-table tbody tr.selected {
  background: rgba(99, 102, 241, 0.12);
  border-left: 3px solid var(--primary);
}

/* Status Badges */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-family: var(--font-mono);
}

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

.status-pill.up .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--status-up-text);
  animation: pulse-dot 2s infinite;
}

.status-pill.degraded, .status-pill.warn {
  background: var(--status-warn-bg);
  color: var(--status-warn-text);
  border: 1px solid var(--status-warn-border);
}

.status-pill.degraded .dot, .status-pill.warn .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--status-warn-text);
}

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

.status-pill.down .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--status-down-text);
  animation: pulse-down 1.5s infinite;
}

/* Timeline Board Styling (Matching Modern Uptime Visual Layout) */
.monitor-timeline-item {
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.monitor-timeline-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.timeline-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.timeline-url-link {
  font-family: var(--font-sans);
  font-size: 15px;
  font-weight: 700;
  color: var(--text-main);
  text-decoration: none;
  letter-spacing: -0.01em;
  transition: color 0.15s ease;
}

.timeline-url-link:hover {
  color: var(--primary);
}

.timeline-uptime-val {
  font-family: var(--font-sans);
  font-size: 14.5px;
  font-weight: 700;
  color: var(--text-main);
}

.timeline-bar-wrapper {
  display: flex;
  gap: 4px;
  width: 100%;
  align-items: center;
}

.timeline-segment-pill {
  flex: 1;
  height: 9px;
  border-radius: 4px;
  transition: transform 0.15s ease, opacity 0.15s ease;
  position: relative;
  cursor: pointer;
}

.timeline-segment-pill.up {
  background: #22C55E;
}

.timeline-segment-pill.down {
  background: #EF4444;
}

.timeline-segment-pill.nodata {
  background: rgba(255, 255, 255, 0.12);
}

.timeline-segment-pill:hover {
  transform: scaleY(1.35);
  opacity: 0.85;
}

.timeline-footer-row {
  display: flex;
  justify-content: flex-end;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-subtle);
}

/* Sparkline visualization */
.mini-sparkline {
  display: inline-flex;
  align-items: flex-end;
  gap: 2px;
  height: 16px;
  vertical-align: middle;
}

.mini-sparkbar {
  width: 3px;
  border-radius: 1px;
  min-height: 4px;
}
.mini-sparkbar.up { background: var(--status-up-text); }
.mini-sparkbar.down { background: var(--status-down-text); }

/* ==========================================================================
   TERMINAL CONSOLE & DIAGNOSTIC BOX
   ========================================================================== */

.terminal-card {
  background: var(--terminal-bg);
  border: 1px solid var(--terminal-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-md);
}

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

.terminal-title {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  color: #94A3B8;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.terminal-body {
  padding: 20px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--terminal-text);
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 300px;
  overflow-y: auto;
}

/* ==========================================================================
   MONITOR DETAIL & CHARTS
   ========================================================================== */

.detail-header-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 26px;
  backdrop-filter: blur(8px);
}

.detail-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 12px;
}

.detail-site-title {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-main);
}

.detail-meta-pills {
  display: flex;
  align-items: center;
  gap: 16px;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-muted);
  flex-wrap: wrap;
}

.chart-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  backdrop-filter: blur(8px);
}

.chart-title {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 20px;
  color: var(--text-main);
}

.bars-container {
  display: flex;
  align-items: flex-end;
  gap: 5px;
  height: 150px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

.bar-col {
  flex: 1;
  border-radius: 4px 4px 0 0;
  transition: all 0.15s ease;
  min-height: 8px;
  cursor: pointer;
  position: relative;
}

.bar-col.up { background: var(--status-up-text); }
.bar-col.warn { background: var(--status-warn-text); }
.bar-col.down { background: var(--status-down-text); }
.bar-col:hover { opacity: 0.85; transform: scaleY(1.05); }

.chart-xaxis {
  display: flex;
  justify-content: space-between;
  margin-top: 10px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-subtle);
}

.checks-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.check-list-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
}

.check-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 13px;
}
.check-row:last-child { border-bottom: none; }

.check-label {
  font-weight: 600;
  color: var(--text-muted);
}

.check-value {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
}
.check-value.ok { color: var(--status-up-text); }
.check-value.err { color: var(--status-down-text); }

/* ==========================================================================
   FORMS & INPUTS
   ========================================================================== */

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.form-input {
  padding: 11px 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-size: 14px;
  outline: none;
  transition: all 0.15s ease;
}

.form-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.btn-primary {
  padding: 10px 20px;
  background: var(--primary);
  border: none;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 700;
  color: #FFFFFF;
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: 0 2px 8px var(--primary-glow);
}

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

.btn-secondary {
  padding: 10px 20px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-secondary:hover {
  background: var(--card-hover);
  border-color: var(--border-highlight);
}

/* ==========================================================================
   MODAL DIALOGS
   ========================================================================== */

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(7, 9, 14, 0.7);
  backdrop-filter: blur(6px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal-overlay.active {
  display: flex;
}

.modal-box {
  background: var(--card-bg-solid);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 460px;
  max-width: 100%;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: fadeIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.modal-title {
  font-size: 17px;
  font-weight: 800;
  color: var(--text-main);
}

.modal-close {
  background: transparent;
  border: none;
  font-size: 22px;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
}

.modal-body {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.modal-footer {
  padding: 18px 24px;
  background: var(--sidebar-bg);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

/* ==========================================================================
   TOAST NOTIFICATION ENGINE
   ========================================================================== */

#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  background: var(--card-bg-solid);
  border: 1px solid var(--border-highlight);
  color: var(--text-main);
  padding: 12px 18px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideInRight 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

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

/* Footer Bar */
.footer-bar {
  padding: 20px 32px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-subtle);
  margin-top: auto;
}

/* ==========================================================================
   MOBILE BOTTOM NAVIGATION & RESPONSIVE BREAKPOINTS
   ========================================================================== */

.mobile-bottom-nav {
  display: none;
}

@media (max-width: 768px) {
  .app-container {
    flex-direction: column;
    padding-bottom: 70px; /* Space for bottom nav */
  }

  .sidebar {
    display: none; /* Hidden on mobile; replaced by bottom nav */
  }

  .topbar {
    padding: 0 18px;
    height: 60px;
  }

  .page-title {
    font-size: 18px;
  }

  .view-panel {
    padding: 18px 18px 36px;
    gap: 18px;
  }

  .stats-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }

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

  .mobile-bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100vw;
    height: 64px;
    background: var(--sidebar-bg);
    border-top: 1px solid var(--border);
    backdrop-filter: blur(16px);
    z-index: 100;
    justify-content: space-around;
    align-items: center;
    padding: 0 8px;
  }

  .mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    user-select: none;
  }

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

  .mobile-nav-item svg {
    width: 20px;
    height: 20px;
  }

  .footer-bar {
    padding: 16px 18px;
    flex-direction: column;
    gap: 8px;
    text-align: center;
  }
}

@media (max-width: 480px) {
  .topbar-actions #theme-toggle-label {
    display: none;
  }

  .stat-value {
    font-size: 30px;
  }
}

/* ==========================================================================
   PRINT / PDF STYLES
   ========================================================================== */

@page {
  size: A4 portrait;
  margin: 1.2cm;
}

@media print {
  /* Hide irrelevant shell UI elements */
  .sidebar, 
  .topbar, 
  .mobile-bottom-nav, 
  .icon-btn, 
  .btn-primary, 
  .btn-secondary, 
  button, 
  #toast-container, 
  .footer-bar, 
  .terminal-card, 
  .modal-overlay,
  .table-filter-input {
    display: none !important;
  }

  /* Only display the currently active view tab */
  .view-panel {
    display: none !important;
  }

  .view-panel.active {
    display: block !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  @page {
    size: A4 portrait;
    margin: 10mm 12mm;
  }

  /* Executive Summary Card Print Optimization */
  #report-summary-card {
    background: #F8FAFC !important;
    border: 1px solid #CBD5E1 !important;
    border-left: 4px solid #22C55E !important;
    color: #0F172A !important;
    page-break-inside: avoid !important;
    break-inside: avoid !important;
  }

  #report-summary-card span,
  #report-summary-card p,
  #report-summary-card strong {
    color: #0F172A !important;
  }
  body, html, .app-container, .main-content, .view-panel, .view-panel.active {
    background: #FFFFFF !important;
    color: #0F172A !important;
    display: block !important;
    height: auto !important;
    min-height: 0 !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: visible !important;
    float: none !important;
  }

  /* Force 4-column flex row for Stat Cards in print */
  body .main-content .stats-grid,
  body .stats-grid,
  .stats-grid {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    gap: 10px !important;
    margin-bottom: 16px !important;
    width: 100% !important;
    page-break-inside: avoid !important;
    break-inside: avoid !important;
  }

  body .main-content .stats-grid .stat-card,
  body .stat-card,
  .stat-card,
  .stats-grid > * {
    flex: 1 1 0px !important;
    min-width: 0 !important;
    padding: 10px 12px !important;
    margin-bottom: 0 !important;
    border: 1px solid #CBD5E1 !important;
    box-shadow: none !important;
    background: #FFFFFF !important;
  }

  .stat-value {
    font-size: 20px !important;
    margin-top: 4px !important;
  }

  .stat-header {
    font-size: 10px !important;
    text-transform: uppercase !important;
    letter-spacing: 0.05em !important;
  }

  /* Allow container cards to break across pages so content flows naturally onto Page 1 */
  .content-card, .detail-header-card, .chart-card {
    border: 1px solid #CBD5E1 !important;
    box-shadow: none !important;
    background: #FFFFFF !important;
    color: #0F172A !important;
    padding: 14px 18px !important;
    margin-bottom: 16px !important;
    page-break-inside: auto !important;
    break-inside: auto !important;
  }

  /* Hide duplicate matrix table in print */
  .report-matrix-table-card {
    display: none !important;
  }

  .card-header-bar {
    background: #F8FAFC !important;
    border-bottom: 1px solid #E2E8F0 !important;
    padding: 10px 14px !important;
  }

  .stat-value, .card-title, .page-title, h2, h3 {
    color: #0F172A !important;
  }

  .stat-subtitle, .stat-header, .check-label {
    color: #475569 !important;
  }

  /* Status Badges */
  .status-pill {
    border: 1px solid #94A3B8 !important;
    padding: 2px 6px !important;
    font-size: 10px !important;
  }

  /* Hide raw table datagrids in print so dashboard prints cleanly without 8 pages of table rows */
  .table-card,
  .table-filter-bar,
  .action-btn,
  .modal-overlay,
  .mobile-bottom-nav,
  .sidebar,
  .topbar {
    display: none !important;
  }

  /* Compact 2-column grid for 30-day timeline items in print */
  #monitors-timeline-list {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px 14px !important;
  }

  .monitor-timeline-item {
    page-break-inside: avoid !important;
    break-inside: avoid !important;
    border: 1px solid #E2E8F0 !important;
    border-radius: 6px !important;
    padding: 8px 10px !important;
    margin-bottom: 0 !important;
    background: #FFFFFF !important;
    gap: 4px !important;
  }

  .timeline-url-link, .timeline-uptime-val {
    color: #0F172A !important;
    font-size: 11.5px !important;
  }

  .timeline-footer-row {
    font-size: 9.5px !important;
  }

  .timeline-segment-pill {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
    height: 6px !important;
  }

  .timeline-segment-pill.up {
    background: #22C55E !important;
  }

  .timeline-segment-pill.down {
    background: #EF4444 !important;
  }

  .timeline-segment-pill.nodata {
    background: #E2E8F0 !important;
  }

  #report-sort-select {
    display: none !important;
  }
}
