:root {
  --bg: #020617;
  --bg-elevated: #0b1220;
  --bg-card: #020617;
  --border-subtle: rgba(148, 163, 184, 0.35);
  --text: #e5e7eb;
  --muted: #94a3b8;
  --accent: #22c55e;
  --accent-soft: rgba(34, 197, 94, 0.15);
  --danger: #ef4444;
  --danger-soft: rgba(239, 68, 68, 0.15);
  --radius-lg: 18px;
  --radius-md: 10px;
  --shadow-soft: 0 18px 40px rgba(15, 23, 42, 0.6);
  --shadow-small: 0 10px 25px rgba(15, 23, 42, 0.6);
  --transition-fast: 150ms ease-out;
  --font: system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text",
    "Segoe UI", sans-serif;
}

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

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: radial-gradient(circle at top, #0f172a 0, #020617 55%);
  color: var(--text);
  font-family: var(--font);
}

body {
  display: flex;
  align-items: stretch;
  justify-content: center;
}

/* Utilities */

.hidden {
  display: none !important;
}

.btn {
  border: none;
  border-radius: 999px;
  padding: 0.45rem 0.95rem;
  font-size: 0.85rem;
  font-weight: 500;
  background: rgba(148, 163, 184, 0.12);
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  transition: background var(--transition-fast), transform var(--transition-fast),
    box-shadow var(--transition-fast), color var(--transition-fast);
}

.btn.primary {
  background: var(--accent);
  color: #022c22;
  box-shadow: 0 8px 18px rgba(34, 197, 94, 0.4);
}

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

.btn.subtle {
  background: rgba(15, 23, 42, 0.85);
}

.btn.subtle:hover {
  background: rgba(30, 64, 175, 0.8);
}

.btn.danger {
  background: var(--danger);
  color: #fef2f2;
  box-shadow: 0 8px 18px rgba(239, 68, 68, 0.4);
}

.btn.danger:hover {
  background: #dc2626;
}

.error-text {
  margin-top: 0.4rem;
  font-size: 0.8rem;
  color: #fca5a5;
}

/* Layout */

.app-shell {
  width: 100%;
  max-width: 1100px;
  padding: 1.5rem;
}

/* AUTH */

.auth-section {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
}

.auth-card {
  width: 100%;
  max-width: 720px;
  background: radial-gradient(circle at top left, #1f2937 0, #020617 55%);
  border-radius: 26px;
  box-shadow: var(--shadow-soft);
  padding: 2.2rem 2.4rem 2rem;
  border: 1px solid rgba(148, 163, 184, 0.4);
}

.app-logo {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: linear-gradient(135deg, #22c55e, #14b8a6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  box-shadow: 0 15px 35px rgba(34, 197, 94, 0.5);
  margin-bottom: 0.6rem;
}

.app-logo.small {
  width: 32px;
  height: 32px;
  font-size: 1.1rem;
  margin-bottom: 0;
}

.app-title {
  margin: 0;
  font-size: 1.7rem;
}

.app-subtitle {
  margin: 0.2rem 0 1.6rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.auth-forms {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.8rem;
}

.auth-column h2 {
  margin: 0 0 0.6rem;
  font-size: 1rem;
}

.auth-column label {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.4rem;
}

.auth-column input {
  width: 100%;
  margin-top: 0.15rem;
  margin-bottom: 0.55rem;
  padding: 0.45rem 0.55rem;
  border-radius: 8px;
  border: 1px solid rgba(148, 163, 184, 0.5);
  background: rgba(15, 23, 42, 0.9);
  color: var(--text);
  font-size: 0.85rem;
}

.auth-column input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(34, 197, 94, 0.7);
}

/* APP */

.app-section {
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.2rem;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.topbar-title {
  font-weight: 600;
}

.topbar-subtitle {
  font-size: 0.8rem;
  color: var(--muted);
}

/* Nav */

.topbar-nav {
  display: flex;
  gap: 0.45rem;
  padding: 0.25rem;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: rgba(2, 6, 23, 0.35);
}

.nav-link {
  border: none;
  cursor: pointer;
  border-radius: 999px;
  padding: 0.45rem 0.8rem;
  font-size: 0.85rem;
  color: rgba(229, 231, 235, 0.85);
  background: transparent;
  transition: background var(--transition-fast), transform var(--transition-fast);
}

.nav-link:hover {
  background: rgba(148, 163, 184, 0.12);
}

.nav-link.active {
  background: rgba(34, 197, 94, 0.12);
  color: rgba(229, 231, 235, 0.98);
  border: 1px solid rgba(34, 197, 94, 0.25);
}

.main-content {
  background: rgba(15, 23, 42, 0.96);
  border-radius: 24px;
  padding: 1.6rem 1.8rem 1.5rem;
  box-shadow: var(--shadow-soft);
  border: 1px solid rgba(148, 163, 184, 0.4);
}

/* Controls row */

.controls-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  margin-bottom: 1rem;
}

.controls-right {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

/* Window pills */

.window-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.pill {
  border: 1px solid rgba(148, 163, 184, 0.28);
  background: rgba(148, 163, 184, 0.10);
  color: rgba(229, 231, 235, 0.88);
  padding: 0.4rem 0.7rem;
  border-radius: 999px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: background var(--transition-fast), transform var(--transition-fast),
    border-color var(--transition-fast);
}

.pill:hover {
  transform: translateY(-1px);
  background: rgba(148, 163, 184, 0.14);
}

.pill.active {
  border-color: rgba(34, 197, 94, 0.35);
  background: rgba(34, 197, 94, 0.12);
}

/* Metrics row */

.metrics-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1.3rem;
}

.metric-card {
  text-align: left;
  border: 1px solid rgba(148, 163, 184, 0.4);
  background: radial-gradient(circle at top left, #111827 0, #020617 65%);
  border-radius: var(--radius-md);
  padding: 0.9rem 1rem;
  box-shadow: var(--shadow-small);
  cursor: pointer;
  transition: transform var(--transition-fast), border-color var(--transition-fast),
  background var(--transition-fast);
  color: var(--text);
}

.metric-card:hover {
  transform: translateY(-1px);
  border-color: rgba(148, 163, 184, 0.55);
}

.metric-card.active {
  border-color: rgba(34, 197, 94, 0.45);
  box-shadow: 0 0 0 1px rgba(34, 197, 94, 0.18), var(--shadow-small);
}

.metric-label {
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.metric-value {
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--text);
}

.metric-value.up {
  color: #4ade80;
}

.metric-value.down {
  color: #fecaca;
}

/* Views */

.view-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.9rem;
}

.view-title-group h1 {
  margin: 0;
  font-size: 1.2rem;
}

.view-meta {
  margin: 0.2rem 0 0;
  font-size: 0.8rem;
  color: var(--muted);
}

/* Incidents view extras */

.incidents-filters {
  display: flex;
  align-items: center;
  gap: 0.8rem;
}

.select-label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.select {
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.45);
  background: rgba(15, 23, 42, 0.9);
  color: var(--text);
  padding: 0.45rem 0.6rem;
  font-size: 0.85rem;
}

.select:focus {
  outline: none;
  border-color: rgba(34, 197, 94, 0.6);
  box-shadow: 0 0 0 1px rgba(34, 197, 94, 0.25);
}

/* Table */

.table-card {
  border-radius: var(--radius-lg);
  background: radial-gradient(circle at top left, #020617 0, #020617 70%);
  border: 1px solid var(--border-subtle);
  overflow: hidden;
}

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

.sites-table thead {
  background: rgba(15, 23, 42, 0.98);
}

.sites-table th,
.sites-table td {
  padding: 0.6rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid rgba(15, 23, 42, 0.9);
  vertical-align: top;
}

.sites-table th {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.sites-table tbody tr:nth-child(even) {
  background: rgba(15, 23, 42, 0.75);
}

.sites-table tbody tr:hover {
  background: rgba(30, 64, 175, 0.35);
}

.col-actions {
  text-align: right;
}

/* Status pill */

.status-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.12rem 0.5rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.status-up {
  background: rgba(34, 197, 94, 0.25);
  color: #4ade80;
  border: 1px solid rgba(34, 197, 94, 0.6);
}

.status-down {
  background: rgba(239, 68, 68, 0.25);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.6);
}

.status-unknown {
  background: rgba(148, 163, 184, 0.25);
  color: #cbd5e1;
  border: 1px solid rgba(148, 163, 184, 0.4);
}

/* Website cell */

.site-main-text {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.site-url {
  font-size: 0.9rem;
}

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

/* Messages */

.app-message {
  margin-top: 0.9rem;
  font-size: 0.8rem;
  color: var(--muted);
}

/* Modals */

.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 40;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.7);
  backdrop-filter: blur(5px);
}

.modal-content {
  position: relative;
  z-index: 41;
  background: radial-gradient(circle at top left, #111827 0, #020617 60%);
  border-radius: 18px;
  border: 1px solid rgba(148, 163, 184, 0.6);
  padding: 1.4rem 1.5rem 1.1rem;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-soft);
}

.modal-content h2 {
  margin: 0 0 0.8rem;
  font-size: 1.1rem;
}

.modal-form label {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.75rem;
}

.modal-form input {
  width: 100%;
  margin-top: 0.15rem;
  padding: 0.45rem 0.6rem;
  border-radius: 8px;
  border: 1px solid rgba(148, 163, 184, 0.6);
  background: rgba(15, 23, 42, 0.9);
  color: var(--text);
  font-size: 0.85rem;
}

.modal-form input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(34, 197, 94, 0.7);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
  margin-top: 0.9rem;
}

/* Responsive */

@media (max-width: 900px) {
  .metrics-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .controls-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .topbar-nav {
    width: 100%;
    justify-content: flex-start;
  }
}

@media (max-width: 800px) {
  .auth-forms {
    grid-template-columns: 1fr;
  }

  .main-content {
    padding: 1.2rem 1.1rem 1.2rem;
  }

  .table-card {
    border-radius: 14px;
  }
}
