:root {
  color-scheme: dark;
  --bg-gradient-start: #0f172a;
  --bg-gradient-end: #1e293b;
  --card-bg: rgba(15, 23, 42, 0.92);
  --card-border: rgba(148, 163, 184, 0.18);
  --overlay: rgba(30, 41, 59, 0.75);
  --text-primary: #e2e8f0;
  --text-secondary: #cbd5f5;
  --text-muted: #94a3b8;
  --accent: #38bdf8;
  --accent-strong: #0ea5e9;
  --success: #34d399;
  --error: #f87171;

  font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top, rgba(56, 189, 248, 0.14), transparent),
    linear-gradient(135deg, var(--bg-gradient-start), var(--bg-gradient-end));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  color: var(--text-secondary);
  padding: 1.5rem 1rem 2rem;
}

.signed-in {
  justify-content: flex-start;
}

.signed-out {
  justify-content: center;
}

.signed-out .top-bar,
.signed-out #debug-panel,
.signed-out footer {
  display: none;
}

.signed-out .page {
  width: 100%;
  max-width: 520px;
  gap: 2rem;
}

.signed-out .auth-card {
  padding: 3rem 2.75rem;
  text-align: center;
}

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

.signed-out .google-signin {
  margin: 2rem auto 1.25rem;
}

.signed-out .note {
  color: var(--text-muted);
}

.top-bar {
  width: min(980px, 100%);
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(15, 23, 42, 0.88);
  border: 1px solid var(--card-border);
  border-radius: 1.1rem;
  padding: 0.9rem 1.4rem;
  box-shadow:
    0 32px 80px -42px rgba(15, 23, 42, 0.9),
    0 20px 50px -28px rgba(56, 189, 248, 0.35);
  position: relative;
  z-index: 50;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.top-bar:hover {
  transform: translateY(-2px);
  box-shadow:
    0 42px 110px -50px rgba(14, 165, 233, 0.55),
    0 24px 55px -30px rgba(8, 47, 73, 0.95);
}

.brand {
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  color: var(--text-primary);
}

.avatar-button {
  width: 2.6rem;
  height: 2.6rem;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #f8fafc;
  font-weight: 700;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 24px 52px -28px rgba(56, 189, 248, 0.8);
  position: relative;
}

.user-menu {
  position: absolute;
  right: 0.5rem;
  top: calc(100% + 0.75rem);
  background: rgba(15, 23, 42, 0.96);
  border: 1px solid var(--card-border);
  border-radius: 1rem;
  padding: 1.1rem 1.25rem;
  box-shadow:
    0 38px 85px -40px rgba(15, 23, 42, 0.85),
    0 22px 50px -30px rgba(56, 189, 248, 0.4);
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  min-width: 230px;
  z-index: 200;
}

.user-menu[hidden] {
  display: none !important;
  opacity: 0;
  pointer-events: none;
}

.user-menu-header span:first-child {
  color: var(--text-primary);
  font-weight: 600;
}

.user-menu-header span:last-child {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.page {
  width: 100%;
  max-width: 980px;
  display: flex;
  flex-direction: column;
  gap: 1.6rem;
  align-items: stretch;
  text-align: center;
}

.card {
  background: var(--card-bg);
  border-radius: 1.2rem;
  padding: 2.5rem 2.25rem;
  border: 1px solid var(--card-border);
  box-shadow:
    0 40px 110px -48px rgba(15, 23, 42, 0.85),
    0 26px 60px -38px rgba(14, 165, 233, 0.35);
  backdrop-filter: blur(14px);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow:
    0 54px 135px -50px rgba(14, 165, 233, 0.55),
    0 28px 65px -35px rgba(8, 47, 73, 0.9);
}

.card h1 {
  margin: 0 0 0.75rem;
  font-size: clamp(2.25rem, 6vw, 3rem);
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.card h2 {
  margin: 0 0 0.75rem;
  font-size: clamp(1.75rem, 5vw, 2.25rem);
  color: var(--text-primary);
}

.subtitle {
  margin: 0;
  font-size: 1.1rem;
}

.auth-card {
  position: relative;
}

.debug-card {
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 1.6rem;
}

.note {
  margin: 0.75rem 0 0;
  font-size: 0.95rem;
  color: var(--text-secondary);
}

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

.google-signin {
  display: flex;
  justify-content: center;
  margin: 1.5rem auto 1rem;
}

.google-signin > div {
  border-radius: 999px !important;
  padding: 0.3rem;
  background: linear-gradient(135deg, rgba(30, 41, 59, 0.82), rgba(15, 23, 42, 0.92));
  box-shadow:
    0 18px 36px -24px rgba(14, 165, 233, 0.45),
    0 8px 20px -18px rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(148, 163, 184, 0.25);
  overflow: hidden;
}

.auth-error {
  margin-top: 1.25rem;
  padding: 0.85rem 1rem;
  border-radius: 0.75rem;
  background: rgba(248, 113, 113, 0.12);
  color: var(--error);
  font-weight: 500;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}

.controls select,
.controls input {
  padding: 0.62rem 0.75rem;
  border-radius: 0.9rem;
  border: 1px solid rgba(148, 163, 184, 0.25);
  background: rgba(15, 23, 42, 0.78);
  color: var(--text-primary);
  font-size: 0.95rem;
}

.controls select:focus,
.controls input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.22);
}

.button {
  cursor: pointer;
  border: none;
  border-radius: 999px;
  padding: 0.75rem 1.75rem;
  font-size: 1.1rem;
  font-weight: 600;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.2s ease;
}

.button.light {
  background: rgba(241, 245, 249, 0.12);
  color: var(--text-primary);
  box-shadow: 0 18px 48px -30px rgba(14, 165, 233, 0.45);
}

.button.light.small {
  padding: 0.55rem 1.1rem;
  font-size: 0.9rem;
}

.button.light:hover {
  transform: translateY(-1px);
  background: rgba(56, 189, 248, 0.16);
  box-shadow: 0 26px 60px -34px rgba(14, 165, 233, 0.6);
}

.table-wrapper {
  overflow-x: auto;
  border-radius: 1rem;
  background: rgba(15, 23, 42, 0.78);
  padding: 1rem;
  border: 1px solid var(--card-border);
  box-shadow: 0 32px 70px -50px rgba(14, 165, 233, 0.35);
}

#status-table,
#log-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

#status-table th,
#status-table td,
#log-table th,
#log-table td {
  padding: 0.6rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid rgba(148, 163, 184, 0.14);
}

#status-table tbody tr:last-child td,
#log-table tbody tr:last-child td {
  border-bottom: none;
}

#status-table .offline {
  color: var(--error);
}

.log-table-wrapper {
  margin-top: 0.5rem;
}

#log-table tbody tr:hover {
  background: rgba(30, 41, 59, 0.62);
}

#log-table .optional {
  color: var(--text-muted);
  font-size: 0.88rem;
}

#log-table .result {
  font-weight: 600;
  color: var(--text-primary);
  text-transform: capitalize;
}

#log-table .result.error {
  color: var(--error);
}

footer {
  margin-top: 2.5rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.5rem;
  padding: 0.75rem 1.25rem;
  border-radius: 999px;
  background: rgba(52, 211, 153, 0.12);
  color: var(--text-primary);
  font-weight: 500;
}

.status .indicator {
  display: inline-block;
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 999px;
  background: var(--success);
  position: relative;
}

.status .indicator::after {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: inherit;
  border: 2px solid rgba(52, 211, 153, 0.45);
  animation: pulse 2s infinite;
}

.status-text {
  font-size: 1.1rem;
}

.top-bar,
.card {
  backdrop-filter: blur(14px);
}

@keyframes pulse {
  0% {
    transform: scale(0.8);
    opacity: 0.75;
  }
  50% {
    transform: scale(1.1);
    opacity: 0.35;
  }
  100% {
    transform: scale(0.8);
    opacity: 0.75;
  }
}

@media (max-width: 720px) {
  .top-bar {
    padding: 0.75rem 1rem;
    gap: 0.75rem;
  }

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

  .button.light.small {
    width: 100%;
  }

  .card {
    padding: 2.25rem 1.8rem;
  }
}
