@import url('https://fonts.googleapis.com/css2?family=Barlow+Condensed:wght@600&display=swap');

:root {
  --ink:   #1C1C1E;
  --paper: #E8E2D0;
  --teal:  #2A6B6E;
  --ochre: #C88B2F;
  --dim:   #6B6860;
  --rule:  #D2CCB8;
  --mono:  ui-monospace, 'JetBrains Mono', 'Cascadia Code', monospace;
}

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

body {
  font-family: ui-sans-serif, system-ui, -apple-system, sans-serif;
  background: var(--paper);
  color: var(--ink);
  line-height: 1.55;
  font-size: 0.9375rem;
}

a { color: var(--teal); }
a:hover { text-decoration: underline; }

/* ── NAV ───────────────────────────────────────────────────────── */

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  padding: 0.875rem 1.5rem;
  background: var(--ink);
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-logo {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 1.0625rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #fff;
  text-decoration: none;
}

.nav-hamburger {
  display: none;
  background: none;
  border: none;
  color: #b0aba2;
  font-size: 1.25rem;
  cursor: pointer;
  padding: 0.25rem 0.375rem;
  line-height: 1;
  border-radius: 2px;
}
.nav-hamburger:focus-visible { outline: 2px solid var(--teal); }

.nav-links {
  display: flex;
  gap: 0.125rem;
  list-style: none;
}

.nav-links a {
  color: #b0aba2;
  text-decoration: none;
  font-size: 0.8125rem;
  letter-spacing: 0.02em;
  padding: 0.375rem 0.625rem;
  border-radius: 2px;
  transition: color 0.15s, background 0.15s;
}

.nav-links a:hover,
.nav-links a[aria-current="page"] {
  color: #fff;
  background: rgba(255, 255, 255, 0.09);
}

@media (max-width: 640px) {
  .nav-hamburger { display: block; }

  .nav-links {
    display: none;
    flex-direction: column;
    gap: 0;
    width: 100%;
    margin-top: 0.625rem;
    border-top: 1px solid #2e2e30;
    padding-top: 0.375rem;
  }

  .nav-links.open { display: flex; }

  .nav-links a {
    display: block;
    padding: 0.75rem 0.25rem;
    border-bottom: 1px solid #2e2e30;
    border-radius: 0;
  }

  .nav-links li:last-child a { border-bottom: none; }
}

/* ── LAYOUT ─────────────────────────────────────────────────────── */

.main {
  max-width: 860px;
  margin: 2.5rem auto;
  padding: 0 1.25rem;
}

.site-footer {
  max-width: 860px;
  margin: 0 auto 3rem;
  padding: 2rem 1rem 0;
  border-top: 1px solid var(--rule);
  font-size: 0.8rem;
  color: var(--dim);
  text-align: center;
  line-height: 1.6;
}
.site-footer p { margin-bottom: 1rem; }

.venmo-btn {
  display: inline-block;
  padding: 0.6rem 1.5rem;
  background: #3D95CE;
  color: #fff;
  border-radius: 4px;
  font-size: 0.8rem;
  text-decoration: none;
}
.venmo-btn:hover { background: #2f7fb0; text-decoration: none; }

.page-title {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 1.375rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ink);
  margin-bottom: 1.75rem;
}

.rule { border: none; border-top: 1px solid var(--rule); margin: 1.75rem 0; }

/* ── STATUS WORDS / META ────────────────────────────────────────── */

.status-word { color: var(--ink); }
.status-word.running      { color: var(--teal); }
.status-word.paused       { color: var(--ochre); }
.status-word.degraded     { color: var(--ochre); }
.status-word.token-expired{ color: var(--ochre); }
.status-word.poll-error   { color: var(--ochre); }
.status-word.valid        { color: var(--teal); }
.status-word.expired      { color: var(--ochre); }
.status-word.unknown      { color: var(--dim); }

.status-meta {
  font-family: var(--mono);
  font-size: 0.8125rem;
  font-weight: 400;
  color: var(--dim);
  text-transform: none;
  letter-spacing: 0;
}

.status-meta.stale { color: var(--ochre); }

/* ── CONNECTION ITEMS (status page clickable rows) ─────────────── */

.connections {
  margin-bottom: 1.75rem;
}

.connection-item {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  padding: 0.625rem 0;
  border-bottom: 1px solid var(--rule);
  text-decoration: none;
  color: inherit;
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 1.1875rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.connection-item:last-child { border-bottom: none; }
.connection-item:hover { text-decoration: none; }

.connection-label {
  font-family: var(--mono);
  font-size: 0.8125rem;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: var(--dim);
  flex-shrink: 0;
  min-width: 6.5rem;
}

.connection-arrow {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 0.8125rem;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: var(--dim);
  opacity: 0.3;
  transition: opacity 0.12s;
}

.connection-item--alert .connection-arrow {
  color: var(--ochre);
  opacity: 1;
}

.connection-item:hover .connection-arrow { opacity: 1; }

.status-poll-meta { margin-bottom: 2rem; }

/* ── ALERT BANNER ───────────────────────────────────────────────── */

.alert-banner {
  border: 2px solid var(--ochre);
  background: rgba(200, 139, 47, 0.07);
  padding: 0.875rem 1.125rem;
  margin-bottom: 1.75rem;
  font-size: 0.9rem;
  line-height: 1.5;
}

.alert-banner strong { color: var(--ochre); }

/* ── ACTIVITY LIST ──────────────────────────────────────────────── */

.section-label {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--dim);
  margin-bottom: 1.125rem;
}

.activity-list { list-style: none; }

.activity-entry {
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--rule);
}
.activity-entry:last-child { border-bottom: none; }

.activity-ts {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--dim);
  display: block;
  margin-bottom: 0.2rem;
}

.activity-body {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
}

.activity-desc { font-size: 0.875rem; }

.activity-outcome {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--dim);
  white-space: nowrap;
  flex-shrink: 0;
}
.activity-outcome.submitted { color: var(--teal); }
.activity-outcome.failed    { color: var(--ochre); }

.activity-empty { color: var(--dim); font-size: 0.875rem; padding: 0.5rem 0; }

.view-all-link { font-size: 0.8rem; color: var(--dim); }

/* ── EVENTS TABLE ───────────────────────────────────────────────── */

.events-table-wrap { overflow-x: auto; }

.events-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.events-table th {
  text-align: left;
  padding: 0.5rem 0.75rem;
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--dim);
  border-bottom: 2px solid var(--rule);
  white-space: nowrap;
}

.events-table td {
  padding: 0.75rem;
  border-bottom: 1px solid var(--rule);
  vertical-align: top;
}

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

.event-name { font-weight: 500; }

.event-msg-preview {
  font-size: 0.75rem;
  color: var(--dim);
  font-style: italic;
  margin-top: 0.2rem;
  max-width: 220px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.events-empty { color: var(--dim); font-size: 0.875rem; padding: 1rem 0; }

@media (max-width: 600px) {
  .events-table .col-ga,
  .events-table .col-price { display: none; }
}

/* ── TOGGLE + REMOVE ────────────────────────────────────────────── */

.toggle-btn {
  font-family: var(--mono);
  font-size: 0.72rem;
  padding: 0.25rem 0.625rem;
  border: 1px solid var(--rule);
  background: none;
  color: var(--dim);
  cursor: pointer;
  border-radius: 2px;
  white-space: nowrap;
}

.toggle-btn.on { border-color: var(--teal); color: var(--teal); }
.toggle-btn:focus-visible { outline: 2px solid var(--teal); }

.remove-btn {
  background: none;
  border: none;
  color: var(--dim);
  cursor: pointer;
  font-size: 0.875rem;
  line-height: 1;
  padding: 0.25rem 0.375rem;
  border-radius: 2px;
}
.remove-btn:hover { color: var(--ochre); }
.remove-btn:focus-visible { outline: 2px solid var(--teal); }

/* ── FORMS ──────────────────────────────────────────────────────── */

.form-section { margin-top: 2.25rem; }

.form-section-title {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--dim);
  margin-bottom: 1.25rem;
}

.field { margin-bottom: 1.125rem; }

.field label {
  display: block;
  font-size: 0.8125rem;
  color: var(--dim);
  margin-bottom: 0.375rem;
}

.field input[type="text"],
.field input[type="number"],
.field input[type="password"],
.field textarea {
  display: block;
  width: 100%;
  padding: 0.5rem 0.625rem;
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid var(--rule);
  color: var(--ink);
  font-size: 0.9rem;
  font-family: inherit;
  border-radius: 2px;
  outline: none;
  transition: border-color 0.15s, background 0.15s;
  -webkit-appearance: none;
}

.field input:focus,
.field textarea:focus {
  border-color: var(--teal);
  background: rgba(255, 255, 255, 0.8);
}

.field input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  margin-right: 0.375rem;
  accent-color: var(--teal);
  cursor: pointer;
}

.field-checkbox { display: flex; align-items: center; }
.field-checkbox label { margin: 0; font-size: 0.875rem; color: var(--ink); cursor: pointer; }

.field-hint {
  font-size: 0.75rem;
  color: var(--dim);
  margin-top: 0.3rem;
}

.field-warn {
  font-size: 0.8125rem;
  color: var(--ochre);
  margin-top: 0.375rem;
  padding: 0.625rem 0.75rem;
  border: 1px solid var(--ochre);
  background: rgba(200, 139, 47, 0.07);
  display: none;
}

textarea { resize: vertical; min-height: 3.5rem; }

.form-actions { margin-top: 1.5rem; display: flex; gap: 0.75rem; align-items: center; }

/* ── BUTTONS ────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.5rem 1.125rem;
  font-size: 0.875rem;
  font-family: inherit;
  border-radius: 2px;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  white-space: nowrap;
}

.btn:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }

.btn-primary { background: var(--teal); color: #fff; }
.btn-primary:hover { background: #235b5e; color: #fff; }

.btn-secondary {
  background: transparent;
  border: 1px solid var(--rule);
  color: var(--ink);
}
.btn-secondary:hover { border-color: var(--dim); }

/* ── AUTH PAGE ──────────────────────────────────────────────────── */

.auth-steps { list-style: none; }

.auth-step {
  display: flex;
  gap: 1.125rem;
  padding: 1rem 0;
  border-bottom: 1px solid var(--rule);
}
.auth-step:last-child { border-bottom: none; }

.auth-step-num {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--dim);
  flex-shrink: 0;
  width: 1.625rem;
  padding-top: 0.05rem;
}

.auth-step-body { flex: 1; min-width: 0; }
.auth-step-body p { font-size: 0.9rem; }
.auth-step-body p + p { margin-top: 0.35rem; }

.auth-step-note {
  font-size: 0.8rem;
  color: var(--dim);
  margin-top: 0.375rem;
}

.auth-screenshot-placeholder {
  border: 1px dashed var(--rule);
  background: rgba(255, 255, 255, 0.35);
  padding: 1.5rem;
  text-align: center;
  font-size: 0.8rem;
  color: var(--dim);
  margin-top: 0.75rem;
}

.auth-screenshot {
  margin-top: 0.75rem;
  border: 1px solid var(--rule);
  max-width: 100%;
  display: block;
  border-radius: 2px;
}

.auth-token-zone {
  margin-top: 2rem;
  padding-top: 1.75rem;
  border-top: 2px solid var(--rule);
}

.auth-token-zone .zone-label {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--dim);
  margin-bottom: 0.875rem;
}

.token-preview {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--dim);
  margin-bottom: 0.75rem;
}

.token-input {
  font-family: var(--mono) !important;
  font-size: 0.8rem !important;
  letter-spacing: 0.02em;
}

.auth-actions { display: flex; gap: 0.75rem; margin-top: 0.875rem; align-items: center; }

.auth-last-verified {
  font-size: 0.78rem;
  color: var(--dim);
  margin-top: 0.875rem;
  font-family: var(--mono);
}

@media (max-width: 640px) {
  .auth-token-zone {
    position: sticky;
    bottom: 0;
    background: var(--paper);
    padding: 1.25rem;
    border-top: 2px solid var(--rule);
    box-shadow: 0 -6px 20px rgba(28, 28, 30, 0.1);
    margin: 1.5rem -1.25rem 0;
  }
}

/* ── GMAIL PAGE ─────────────────────────────────────────────────── */

.connection-status { margin-bottom: 1.5rem; }

.connection-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  margin-bottom: 0.375rem;
}

.connection-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--dim);
  flex-shrink: 0;
  align-self: center;
}
.connection-dot.connected { background: var(--teal); }
.connection-dot.alert     { background: var(--ochre); }

.connection-meta {
  font-size: 0.78rem;
  color: var(--dim);
  font-family: var(--mono);
  margin-bottom: 1rem;
}

.gmail-explainer {
  margin-top: 2rem;
  padding: 1.125rem;
  border: 1px solid var(--rule);
  background: rgba(255, 255, 255, 0.35);
  font-size: 0.875rem;
}

.gmail-explainer p + p { margin-top: 0.625rem; }

/* ── LOGS ───────────────────────────────────────────────────────── */

.log-list { list-style: none; }

.log-entry {
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--rule);
}
.log-entry:last-child { border-bottom: none; }

.log-ts {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--dim);
  display: block;
  margin-bottom: 0.2rem;
}

.log-body { display: flex; gap: 0.625rem; align-items: baseline; }

.log-level {
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--dim);
  text-transform: uppercase;
  flex-shrink: 0;
}
.log-level.error { color: var(--ochre); }

.log-msg { font-size: 0.875rem; flex: 1; }

.log-empty { color: var(--dim); font-size: 0.875rem; padding: 0.5rem 0; }

.pagination {
  margin-top: 1.5rem;
  display: flex;
  gap: 1rem;
  align-items: center;
  font-size: 0.8125rem;
  color: var(--dim);
}

/* ── SETUP PAGE ─────────────────────────────────────────────────── */

.setup-intro {
  color: var(--dim);
  font-size: 0.9rem;
  margin-bottom: 2rem;
  max-width: 480px;
}

/* ── INLINE FEEDBACK ────────────────────────────────────────────── */

.feedback-ok    { font-size: 0.875rem; color: var(--teal); }
.feedback-error { font-size: 0.875rem; color: var(--ochre); }

/* ── LOGIN PAGE ─────────────────────────────────────────────────── */
/* Standalone page (does not extend base.html — avoids the double-nav bug),
   so it needs its own scoped rules instead of inheriting .main/.page-title. */

.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1.5rem;
}

.login-main {
  width: 100%;
  max-width: 360px;
  padding: 2rem 1.75rem;
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid var(--rule);
  border-radius: 2px;
}

.login-heading {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink);
  margin-bottom: 1.5rem;
}

.login-error {
  font-size: 0.875rem;
  color: var(--ochre);
  margin-bottom: 1.125rem;
}

/* ── SCREEN READER ONLY ─────────────────────────────────────────── */

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ── UTILITY ────────────────────────────────────────────────────── */

code {
  font-family: var(--mono);
  background: rgba(0, 0, 0, 0.06);
  padding: 0.1em 0.35em;
  border-radius: 2px;
  font-size: 0.85em;
}

/* ── FOCUS + REDUCED MOTION ─────────────────────────────────────── */

:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
