:root {
  --bg-primary: #f8fafc;
  --bg-card: #ffffff;
  --bg-code: #f1f5f9;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --border-color: #e2e8f0;
  --accent-color: #f6821f; /* Cloudflare Orange */
  --accent-hover: #e07116;
  --accent-subtle: #fff7ed;
  --success-color: #10b981;
  --success-bg: #ecfdf5;
  --success-border: #a7f3d0;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --transition: all 0.2s ease-in-out;
  color-scheme: light dark;
}

[data-theme="dark"] {
  --bg-primary: #0b0f19;
  --bg-card: #151c2e;
  --bg-code: #1c2438;
  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --border-color: #26334d;
  --accent-color: #fb923c;
  --accent-hover: #f97316;
  --accent-subtle: rgba(251, 146, 60, 0.12);
  --success-color: #34d399;
  --success-bg: rgba(16, 185, 129, 0.12);
  --success-border: rgba(16, 185, 129, 0.3);
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.3);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.4);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  transition: background-color 0.25s ease, color 0.25s ease;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.page-container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 2rem 1.25rem 3rem;
  width: 100%;
}

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

.logo-group {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.logo-badge {
  font-size: 1.8rem;
  background: var(--accent-subtle);
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  border: 1px solid var(--accent-color);
}

h1 {
  font-size: clamp(1.25rem, 2vw + 0.8rem, 1.75rem);
  font-weight: 700;
  letter-spacing: -0.02em;
}

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

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.875rem;
  font-weight: 600;
  padding: 0.5rem 0.95rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: var(--transition);
}

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

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

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

.btn-secondary:hover {
  background-color: var(--bg-code);
}

.btn-sm {
  font-size: 0.8rem;
  padding: 0.35rem 0.65rem;
}

/* Alert Banner */
.banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.85rem 1.25rem;
  border-radius: var(--radius-md);
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
}

.banner-success {
  background-color: var(--success-bg);
  border: 1px solid var(--success-border);
  color: var(--text-primary);
}

.banner-close {
  background: none;
  border: none;
  font-size: 1.25rem;
  cursor: pointer;
  color: var(--text-secondary);
  line-height: 1;
  padding: 0 0.25rem;
}

.hidden {
  display: none !important;
}

/* Cards */
.card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}

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

.hero-card {
  margin-bottom: 1.75rem;
  background: linear-gradient(135deg, var(--bg-card) 0%, var(--accent-subtle) 100%);
  border-left: 4px solid var(--accent-color);
}

.status-indicator-wrapper {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.5rem;
}

.pulse-dot {
  width: 12px;
  height: 12px;
  background-color: var(--success-color);
  border-radius: 50%;
  position: relative;
  display: inline-block;
  box-shadow: 0 0 0 rgba(16, 185, 129, 0.4);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
  }
  70% {
    box-shadow: 0 0 0 10px rgba(16, 185, 129, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
  }
}

.status-title {
  font-size: 1.15rem;
  font-weight: 600;
}

.hero-desc {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-bottom: 1rem;
}

.meta-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.tag {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.25rem 0.6rem;
  border-radius: 9999px;
  background-color: var(--bg-code);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}

.tag-accent {
  background-color: var(--accent-subtle);
  color: var(--accent-color);
  border-color: var(--accent-color);
}

/* Grid layout */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1.5rem;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

h2 {
  font-size: 1.1rem;
  font-weight: 600;
}

.card-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

/* Diagnostics & Details */
.diagnostics-box {
  background-color: var(--bg-code);
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--text-secondary);
  margin-bottom: 1rem;
}

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

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

.details-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.85rem;
}

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

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

.detail-value {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-weight: 500;
  color: var(--text-primary);
}

.detail-value.highlight {
  color: var(--accent-color);
  font-weight: 700;
}

/* Routing Tests */
.test-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.test-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem;
  background-color: var(--bg-code);
  border-radius: var(--radius-md);
}

.test-info {
  display: flex;
  flex-direction: column;
  font-size: 0.825rem;
}

.test-info strong {
  font-size: 0.875rem;
  color: var(--text-primary);
}

.test-info span {
  color: var(--text-muted);
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  background: var(--bg-card);
  padding: 0.15rem 0.35rem;
  border-radius: 4px;
  border: 1px solid var(--border-color);
  font-size: 0.8em;
}

/* Headers output */
.headers-output {
  margin-top: 1rem;
  background: var(--bg-code);
  padding: 0.75rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  max-height: 200px;
  overflow-y: auto;
}

.headers-output pre {
  font-size: 0.775rem;
  color: var(--text-secondary);
  white-space: pre-wrap;
  word-break: break-all;
}

/* Settings table */
.settings-table-wrapper {
  overflow-x: auto;
  margin-bottom: 0.85rem;
}

.settings-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.settings-table td {
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid var(--border-color);
}

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

.hint-text {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.4;
}

/* Footer */
.footer {
  text-align: center;
  padding-top: 2.5rem;
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-top: auto;
}

/* Responsive adjustments */
@media (max-width: 600px) {
  .header {
    flex-direction: column;
    align-items: flex-start;
  }
  .test-item {
    flex-direction: column;
    align-items: flex-start;
  }
  .test-item .btn {
    align-self: flex-start;
    margin-top: 0.25rem;
  }
}
