/* ─── Tokens ─── */
:root {
  --background: 0 0% 100%;
  --foreground: 240 10% 3.9%;
  --card: 0 0% 100%;
  --card-foreground: 240 10% 3.9%;
  --muted: 240 4.8% 95.9%;
  --muted-foreground: 240 3.8% 46.1%;
  --border: 240 5.9% 90%;
  --input: 240 5.9% 90%;
  --ring: 240 5.9% 10%;
  --primary: 240 5.9% 10%;
  --primary-foreground: 0 0% 98%;
  --secondary: 240 4.8% 95.9%;
  --secondary-foreground: 240 5.9% 10%;
  --destructive: 0 84.2% 60.2%;
  --destructive-foreground: 0 0% 98%;
  --success: 142 76% 36%;
  --success-foreground: 0 0% 98%;
  --warning: 38 92% 50%;
  --warning-foreground: 0 0% 98%;
  --radius: 0.5rem;
  --font-sans: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

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

body {
  font-family: var(--font-sans);
  background: hsl(var(--muted));
  color: hsl(var(--foreground));
  line-height: 1.6;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ─── Nav ─── */
nav {
  background: hsl(var(--card));
  border-bottom: 1px solid hsl(var(--border));
  padding: 0 1.5rem;
  height: 3.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(8px);
  background: hsla(var(--card) / 0.8);
}

.nav-brand {
  font-weight: 600;
  font-size: 0.9rem;
  color: hsl(var(--foreground));
  letter-spacing: -0.02em;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.nav-links a {
  color: hsl(var(--muted-foreground));
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.375rem 0.75rem;
  border-radius: var(--radius);
  transition: color 0.15s, background 0.15s;
}

.nav-links a:hover {
  color: hsl(var(--foreground));
  background: hsl(var(--muted));
}

.nav-user {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: 0.75rem;
  padding-left: 0.75rem;
  border-left: 1px solid hsl(var(--border));
}

.nav-user span {
  font-size: 0.875rem;
  color: hsl(var(--muted-foreground));
}

.avatar {
  width: 26px;
  height: 26px;
  border-radius: 9999px;
  border: 1px solid hsl(var(--border));
}

.btn-link {
  background: none;
  border: none;
  color: hsl(var(--muted-foreground));
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.375rem 0.75rem;
  border-radius: var(--radius);
  transition: color 0.15s, background 0.15s;
  text-decoration: none;
}

.btn-link:hover {
  color: hsl(var(--foreground));
  background: hsl(var(--muted));
}

/* ─── Main ─── */
main {
  max-width: 680px;
  margin: 2rem auto;
  padding: 0 1rem;
}

/* ─── Typography ─── */
h1 {
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.03em;
  color: hsl(var(--foreground));
  margin-bottom: 1.5rem;
}

h2 {
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: hsl(var(--foreground));
}

h3 {
  font-size: 0.875rem;
  font-weight: 600;
  color: hsl(var(--foreground));
}

p {
  font-size: 0.875rem;
  color: hsl(var(--muted-foreground));
  line-height: 1.6;
}

/* ─── Card ─── */
.card {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1rem;
}

.card h2 {
  margin-bottom: 0.75rem;
}

.card p + .btn,
.card p + .btn-secondary {
  margin-top: 0.75rem;
}

/* ─── Buttons ─── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 1rem;
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  border: none;
  border-radius: var(--radius);
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: opacity 0.15s;
  line-height: 1.25;
}

.btn:hover {
  opacity: 0.9;
}

.btn:active {
  opacity: 0.8;
}

.btn-secondary {
  background: hsl(var(--secondary));
  color: hsl(var(--secondary-foreground));
  border: 1px solid hsl(var(--border));
}

.btn-secondary:hover {
  background: hsl(var(--muted));
  opacity: 1;
}

.btn-google {
  background: hsl(var(--foreground));
  color: hsl(var(--background));
  padding: 0.625rem 1.5rem;
  font-size: 0.875rem;
}

/* ─── Flash messages ─── */
.flash {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: 0.875rem;
  border: 1px solid;
}

.flash-success {
  background: hsl(142 76% 36% / 0.08);
  color: hsl(142 76% 28%);
  border-color: hsl(142 76% 36% / 0.2);
}

.flash-error {
  background: hsl(0 84% 60% / 0.08);
  color: hsl(0 84% 40%);
  border-color: hsl(0 84% 60% / 0.2);
}

/* ─── Status ─── */
.status-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.125rem 0.625rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 500;
  border: 1px solid;
  line-height: 1.5;
}

.status-watching {
  background: hsl(142 76% 36% / 0.08);
  color: hsl(142 76% 28%);
  border-color: hsl(142 76% 36% / 0.2);
}

.status-disconnected {
  background: hsl(38 92% 50% / 0.08);
  color: hsl(38 92% 35%);
  border-color: hsl(38 92% 50% / 0.2);
}

.status-error {
  background: hsl(0 84% 60% / 0.08);
  color: hsl(0 84% 40%);
  border-color: hsl(0 84% 60% / 0.2);
}

.status-not-configured {
  background: hsl(var(--muted));
  color: hsl(var(--muted-foreground));
  border-color: hsl(var(--border));
}

.meta {
  color: hsl(var(--muted-foreground));
  font-size: 0.8rem;
}

.error-text {
  color: hsl(0 84% 40%);
}

/* ─── Table ─── */
table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.5rem;
  font-size: 0.875rem;
}

thead {
  border-bottom: 1px solid hsl(var(--border));
}

th {
  text-align: left;
  padding: 0.5rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: hsl(var(--muted-foreground));
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

td {
  padding: 0.625rem 0.75rem;
  border-bottom: 1px solid hsl(var(--border));
  color: hsl(var(--foreground));
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr {
  transition: background 0.1s;
}

tbody tr:hover {
  background: hsl(var(--muted) / 0.5);
}

/* ─── Forms ─── */
.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.375rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: hsl(var(--foreground));
}

.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="number"] {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid hsl(var(--input));
  border-radius: var(--radius);
  font-family: var(--font-sans);
  font-size: 0.875rem;
  color: hsl(var(--foreground));
  background: transparent;
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
}

.form-group input::placeholder {
  color: hsl(var(--muted-foreground));
  opacity: 0.6;
}

.form-group input:focus {
  border-color: hsl(var(--ring));
  box-shadow: 0 0 0 2px hsl(var(--ring) / 0.1);
}

.form-group input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  border-radius: 0.25rem;
  vertical-align: middle;
  margin-right: 0.375rem;
  accent-color: hsl(var(--primary));
}

.form-row {
  display: flex;
  gap: 1rem;
  align-items: flex-end;
}

.form-row .form-group {
  flex: 1;
}

/* ─── Setup checklist ─── */
.setup-checklist {
  margin-top: 1rem;
  padding: 1rem;
  background: hsl(38 92% 50% / 0.06);
  border: 1px solid hsl(38 92% 50% / 0.15);
  border-radius: var(--radius);
}

.setup-checklist h3 {
  margin-bottom: 0.25rem;
}

.setup-checklist p {
  margin-bottom: 0.5rem;
}

.setup-checklist ol {
  margin-left: 1.25rem;
  font-size: 0.875rem;
}

.setup-checklist ol li {
  padding: 0.125rem 0;
}

.setup-checklist a {
  color: hsl(var(--foreground));
  font-weight: 500;
}

.setup-checklist a:hover {
  text-decoration: none;
}

/* ─── Login ─── */
.login-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background: hsl(var(--background));
}

.login-card {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  padding: 3rem 2.5rem;
  border-radius: calc(var(--radius) * 1.5);
  text-align: center;
  max-width: 380px;
  width: 100%;
}

.login-card h1 {
  margin-bottom: 0.375rem;
  font-size: 1.375rem;
}

.login-card p {
  margin-bottom: 2rem;
}

/* ─── Responsive ─── */
@media (max-width: 640px) {
  main {
    padding: 0 0.75rem;
    margin: 1.25rem auto;
  }

  .card {
    padding: 1.25rem;
  }

  .form-row {
    flex-direction: column;
    gap: 0;
  }

  nav {
    padding: 0 1rem;
  }

  .nav-user span {
    display: none;
  }

  h1 {
    font-size: 1.25rem;
  }
}
