:root {
  --bg-primary: #0f172a;
  --bg-card: #1e293b;
  --bg-card-hover: #24344d;
  --border-color: #334155;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --color-green: #10b981;
  --color-red: #ef4444;
  --color-orange: #f59e0b;
  --color-blue: #3b82f6;
  --color-gray: #64748b;
  --font-sans: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

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

body {
  background-color: var(--bg-primary);
  color: var(--text-main);
  font-family: var(--font-sans);
  line-height: 1.5;
  padding: 1rem;
}

.app-container {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* Header */
.header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-color);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo-icon {
  font-size: 2rem;
}

h1 {
  font-size: 1.5rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.badge-v1 {
  background: #3b82f6;
  color: #fff;
  font-size: 0.75rem;
  padding: 0.15rem 0.5rem;
  border-radius: 9999px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.pulse-indicator {
  font-size: 0.85rem;
  color: var(--color-green);
  font-weight: 500;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  background-color: #3b82f6;
  color: #fff;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 0.4rem 0.85rem;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-outline {
  background: transparent;
  border-color: var(--border-color);
  color: var(--text-main);
}

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

/* Alert Banner */
.alert-banner {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid var(--color-red);
  color: #fca5a5;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
}

/* Cards Grid */
.grid-cards {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}

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

.card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1.25rem;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.2);
}

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

.server-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.server-title h2 {
  font-size: 1.25rem;
}

.role-badge {
  background: #334155;
  color: #cbd5e1;
  font-size: 0.75rem;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
}

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

.dot-online { background-color: var(--color-green); box-shadow: 0 0 8px var(--color-green); }
.dot-disconnected { background-color: var(--color-red); box-shadow: 0 0 8px var(--color-red); }
.dot-recovered { background-color: var(--color-orange); box-shadow: 0 0 8px var(--color-orange); }
.dot-stale { background-color: var(--color-orange); box-shadow: 0 0 8px var(--color-orange); }
.dot-unknown { background-color: var(--color-gray); }

.status-pill {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.25rem 0.65rem;
  border-radius: 9999px;
  text-transform: uppercase;
}

.status-online { background: rgba(16, 185, 129, 0.2); color: #34d399; }
.status-disconnected { background: rgba(239, 68, 68, 0.2); color: #f87171; }
.status-recovered { background: rgba(245, 158, 11, 0.2); color: #fbbf24; }
.status-stale { background: rgba(245, 158, 11, 0.25); color: #fbbf24; border: 1px solid rgba(245, 158, 11, 0.5); }
.status-unknown { background: rgba(100, 116, 139, 0.2); color: #94a3b8; }

/* Metrics */
.metric-row {
  margin-bottom: 1rem;
}

.metric-info {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  margin-bottom: 0.25rem;
}

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

.metric-info .value {
  font-weight: 600;
}

.progress-bar {
  background-color: #0f172a;
  height: 8px;
  border-radius: 9999px;
  overflow: hidden;
}

.progress-fill {
  background-color: var(--color-blue);
  height: 100%;
  border-radius: 9999px;
  transition: width 0.3s ease;
}

.progress-warn { background-color: var(--color-orange); }
.progress-danger { background-color: var(--color-red); }
.progress-stale { background-color: var(--color-gray); opacity: 0.7; }

/* Transparent provenance for Vibe's two independent application containers. */
.container-breakdown {
  margin: .25rem 0 .75rem;
  padding: .65rem .8rem;
  background: #0f172a;
  border: 1px solid var(--border-color);
  border-radius: 7px;
  font-size: .78rem;
}
.container-breakdown-title { font-weight: 600; color: #cbd5e1; }
.container-breakdown-subtitle { margin-top: .25rem; color: var(--text-muted); font-size: .72rem; }
.container-breakdown-item {
  margin-top: .45rem; display: flex; justify-content: space-between;
  gap: .75rem; color: #cbd5e1;
}
.container-breakdown-item span:last-child { text-align: right; font-variant-numeric: tabular-nums; }

/* Stats Mini Grid */
.stats-mini-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px dashed var(--border-color);
}

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

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

.mini-value {
  font-size: 0.85rem;
  font-weight: 600;
}

/* Expiry Box */
.expiry-box {
  margin-top: 1rem;
  padding: 0.65rem 0.85rem;
  background: #0f172a;
  border-radius: 6px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
}

.days-remaining {
  font-weight: 700;
  color: #38bdf8;
}

.days-warn { color: var(--color-orange); }
.days-danger { color: var(--color-red); }

/* Charts */
.chart-section {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

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

.section-header h3 {
  font-size: 1.1rem;
}

.chart-selector {
  display: flex;
  gap: 0.5rem;
}

.tab-btn {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 0.25rem 0.75rem;
  border-radius: 4px;
  font-size: 0.8rem;
  cursor: pointer;
}

.tab-btn.active {
  background: #3b82f6;
  color: #fff;
  border-color: #3b82f6;
}

.chart-container {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

@media (min-width: 768px) {
  .chart-container {
    grid-template-columns: 1fr 1fr;
  }
}

.chart-wrapper {
  background: #0f172a;
  border-radius: 8px;
  padding: 0.75rem;
}

.chart-wrapper h4 {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.trend-chart {
  width: 100%;
  height: 120px;
  overflow: visible;
}

/* Events Table */
.table-responsive {
  overflow-x: auto;
  max-height: 350px;
}

.events-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  text-align: left;
}

.events-table th, .events-table td {
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--border-color);
}

.events-table th {
  color: var(--text-muted);
  font-weight: 600;
  position: sticky;
  top: 0;
  background: var(--bg-card);
}

.badge-info { background: rgba(59, 130, 246, 0.2); color: #60a5fa; padding: 2px 6px; border-radius: 4px; font-size: 0.75rem; }
.badge-warning { background: rgba(245, 158, 11, 0.2); color: #fbbf24; padding: 2px 6px; border-radius: 4px; font-size: 0.75rem; }
.badge-critical { background: rgba(239, 68, 68, 0.2); color: #f87171; padding: 2px 6px; border-radius: 4px; font-size: 0.75rem; }

.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 2rem !important;
}

.footer {
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
  padding: 1rem 0;
}
