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

:root {
  --color-bg: #ffffff;
  --color-bg-secondary: #f8f9fa;
  --color-bg-tertiary: #f1f3f4;
  --color-border: #dadce0;
  --color-border-light: #e8eaed;
  --color-text: #202124;
  --color-text-secondary: #5f6368;
  --color-text-muted: #80868b;
  --color-operational: #1e8e3e;
  --color-operational-bg: rgba(30, 142, 62, 0.1);
  --color-degraded: #f9ab00;
  --color-degraded-bg: rgba(249, 171, 0, 0.1);
  --color-down: #d93025;
  --color-down-bg: rgba(217, 48, 37, 0.1);
  --color-unknown: #80868b;
  --color-blue: #1a73e8;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "SF Mono", Monaco, "Cascadia Code", "Roboto Mono", Consolas, monospace;
}

html {
  font-size: 14px;
}

body {
  font-family: var(--font-sans);
  background: var(--color-bg-secondary);
  color: var(--color-text);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
}

/* Header */
.header {
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 64px;
}

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

.brand-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--color-text);
}

.brand-divider {
  width: 1px;
  height: 20px;
  background: var(--color-border);
}

.brand-section {
  font-size: 16px;
  font-weight: 400;
  color: var(--color-text-secondary);
}

.connection-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--color-text-muted);
}

.indicator-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-unknown);
  transition: background 0.3s;
}

.connection-indicator.connected .indicator-dot {
  background: var(--color-operational);
  animation: pulse-dot 2s infinite;
}

.connection-indicator.disconnected .indicator-dot {
  background: var(--color-down);
}

/* Main */
.main {
  flex: 1;
  padding: 32px 0;
}

/* Status Summary */
.status-summary {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 24px;
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 24px;
}

.summary-indicator {
  position: relative;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pulse-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--color-operational);
  z-index: 1;
}

.pulse-ring {
  position: absolute;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--color-operational-bg);
  animation: pulse-ring 2s ease-out infinite;
}

.status-summary.degraded .pulse-dot { background: var(--color-degraded); }
.status-summary.degraded .pulse-ring { background: var(--color-degraded-bg); }
.status-summary.down .pulse-dot { background: var(--color-down); }
.status-summary.down .pulse-ring { background: var(--color-down-bg); }

@keyframes pulse-ring {
  0% { transform: scale(0.5); opacity: 1; }
  100% { transform: scale(1); opacity: 0; }
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

.summary-title {
  font-size: 22px;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 2px;
}

.summary-subtitle {
  font-size: 13px;
  color: var(--color-text-muted);
}

/* System Section */
.system-section {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 24px;
}

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

.server-uptime {
  font-size: 13px;
  color: var(--color-text-secondary);
  font-family: var(--font-mono);
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--color-border-light);
}

.metric-card {
  background: var(--color-bg);
  padding: 20px 24px;
}

.metric-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 12px;
}

.metric-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text-secondary);
}

.metric-card .metric-value {
  font-size: 24px;
  font-weight: 600;
  font-family: var(--font-mono);
  color: var(--color-text);
}

.metric-sub {
  font-size: 12px;
  color: var(--color-text-muted);
  margin-top: 8px;
}

/* Progress Bar */
.progress-bar {
  height: 6px;
  background: var(--color-bg-tertiary);
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.5s ease, background 0.3s;
}

.cpu-fill { background: var(--color-blue); }
.memory-fill { background: #8e44ad; }
.disk-fill { background: #e67e22; }

.progress-fill.warning { background: var(--color-degraded); }
.progress-fill.critical { background: var(--color-down); }

/* Load Values */
.load-values {
  display: flex;
  gap: 16px;
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--color-text-secondary);
}

/* Section Common */
.section-header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--color-border-light);
}

.section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Services Section */
.services-section {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 24px;
}

.services-table {
  width: 100%;
}

.table-header {
  display: grid;
  grid-template-columns: 100px 1fr 100px 100px 80px 100px 80px 100px;
  padding: 12px 24px;
  background: var(--color-bg-tertiary);
  border-bottom: 1px solid var(--color-border-light);
  font-size: 11px;
  font-weight: 600;
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.table-row {
  display: grid;
  grid-template-columns: 100px 1fr 100px 100px 80px 100px 80px 100px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--color-border-light);
  align-items: center;
  transition: background 0.15s;
}

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

.table-row:hover {
  background: var(--color-bg-secondary);
}

.table-loading {
  padding: 48px 24px;
  text-align: center;
  color: var(--color-text-muted);
}

/* Status Badge */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 500;
}

.status-badge::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-unknown);
}

.status-badge.online::before {
  background: var(--color-operational);
  box-shadow: 0 0 0 3px var(--color-operational-bg);
}

.status-badge.online {
  color: var(--color-operational);
}

.status-badge.stopped::before,
.status-badge.errored::before {
  background: var(--color-down);
  box-shadow: 0 0 0 3px var(--color-down-bg);
}

.status-badge.stopped,
.status-badge.errored {
  color: var(--color-down);
}

/* Response Time */
.response-time {
  font-family: var(--font-mono);
  font-size: 13px;
}

.response-time.fast { color: var(--color-operational); }
.response-time.medium { color: var(--color-degraded); }
.response-time.slow { color: var(--color-down); }

/* Service Name */
.service-name {
  font-weight: 500;
  color: var(--color-text);
}

/* Metric Values in table */
.table-row .metric-value {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--color-text-secondary);
}

/* Actions */
.btn-link {
  background: none;
  border: none;
  color: var(--color-blue);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  padding: 0;
}

.btn-link:hover {
  text-decoration: underline;
}

/* Infrastructure Row */
.infra-row {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 24px;
  margin-bottom: 24px;
}

/* Database Section */
.database-section {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  overflow: hidden;
}

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

.db-status, .redis-status {
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.db-status.online, .redis-status.online {
  background: var(--color-operational-bg);
  color: var(--color-operational);
}

.db-status.offline, .redis-status.offline {
  background: var(--color-down-bg);
  color: var(--color-down);
}

.db-overview {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--color-border-light);
  border-bottom: 1px solid var(--color-border-light);
}

.db-stat {
  background: var(--color-bg);
  padding: 16px;
  text-align: center;
}

.db-stat-label {
  display: block;
  font-size: 10px;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.db-stat-value {
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 500;
  color: var(--color-text);
}

.db-table-header {
  display: grid;
  grid-template-columns: 1fr 80px 60px;
  padding: 10px 16px;
  background: var(--color-bg-tertiary);
  font-size: 10px;
  font-weight: 600;
  color: var(--color-text-secondary);
  text-transform: uppercase;
}

.db-table-row {
  display: grid;
  grid-template-columns: 1fr 80px 60px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-border-light);
  align-items: center;
}

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

.db-name {
  font-weight: 500;
  font-size: 13px;
  color: var(--color-text);
}

.db-value {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--color-text-secondary);
}

/* Redis Section */
.redis-section {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  overflow: hidden;
}

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

.redis-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--color-border-light);
}

.redis-stat {
  background: var(--color-bg);
  padding: 24px 16px;
  text-align: center;
}

.redis-stat-value {
  display: block;
  font-family: var(--font-mono);
  font-size: 28px;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 4px;
}

.redis-stat-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* SSL Section */
.ssl-section {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 24px;
}

.ssl-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--color-border-light);
}

.ssl-card {
  background: var(--color-bg);
  padding: 20px;
}

.ssl-domain {
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text);
  margin-bottom: 8px;
  word-break: break-all;
}

.ssl-expiry {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ssl-days {
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: 600;
}

.ssl-days.good { color: var(--color-operational); }
.ssl-days.warning { color: var(--color-degraded); }
.ssl-days.critical { color: var(--color-down); }

.ssl-label {
  font-size: 12px;
  color: var(--color-text-muted);
}

/* Logs Panel */
.logs-panel {
  display: none;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 24px;
}

.logs-panel.active {
  display: block;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  border-bottom: 1px solid var(--color-border-light);
  background: var(--color-bg-tertiary);
}

.panel-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text);
}

.panel-close {
  background: none;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  padding: 6px 12px;
  font-size: 12px;
  color: var(--color-text-secondary);
  cursor: pointer;
}

.panel-close:hover {
  background: var(--color-bg-secondary);
}

.panel-body {
  max-height: 400px;
  overflow-y: auto;
}

.logs-output {
  padding: 16px 24px;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.7;
  color: var(--color-text-secondary);
  white-space: pre-wrap;
  word-break: break-all;
  margin: 0;
}

/* Footer */
.footer {
  padding: 24px 0;
  border-top: 1px solid var(--color-border-light);
  background: var(--color-bg);
}

.footer-text {
  font-size: 12px;
  color: var(--color-text-muted);
  text-align: center;
}

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

  .infra-row {
    grid-template-columns: 1fr;
  }

  .ssl-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .table-header {
    display: none;
  }

  .table-row {
    display: block;
    padding: 16px 24px;
  }

  .table-row > div {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
  }

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

  .db-overview {
    grid-template-columns: repeat(2, 1fr);
  }

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

  .redis-stats {
    grid-template-columns: 1fr;
  }
}
