:root {
  --bg: #f6f5f9;
  --surface: #ffffff;
  --surface-soft: #efedf5;
  --ink: #1e1633;
  --muted: #6c6482;
  --accent: #ec257c;
  --purple: #371b71;
  --green: #16a34a;
  --green-soft: rgba(22, 163, 74, 0.12);
  --amber: #b45309;
  --amber-soft: rgba(217, 119, 6, 0.13);
  --red: #dc2626;
  --red-soft: rgba(220, 38, 38, 0.1);
  --radius: 18px;
  --radius-sm: 12px;
  --shadow-soft: 0 2px 12px rgba(30, 22, 51, 0.04);
  --topbar-bg: rgba(246, 245, 249, 0.9);
  --input-focus-bg: #ffffff;
  --border-subtle: transparent;
}

/* Tema Purple (padrão): cards claros estilo Light sobre fundo roxo #371B71 */
html[data-theme="purple"] {
  --bg: #371b71;
  --shadow-soft: 0 8px 24px rgba(18, 6, 48, 0.24);
  --topbar-bg: rgba(55, 27, 113, 0.9);
}

/* Tema Dark: fundo roxo #371B71 com superfícies escuras e texto claro */
html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #371b71;
  --surface: #2a1358;
  --surface-soft: #3c2178;
  --ink: #fcfcfb;
  --muted: #cbbfe6;
  --accent: #ec257c;
  --purple: #fcfcfb;
  --green: #4ade80;
  --green-soft: rgba(74, 222, 128, 0.18);
  --amber: #fbbf24;
  --amber-soft: rgba(251, 191, 36, 0.18);
  --red: #f87171;
  --red-soft: rgba(248, 113, 113, 0.2);
  --shadow-soft: 0 8px 24px rgba(14, 5, 36, 0.28);
  --topbar-bg: rgba(55, 27, 113, 0.88);
  --input-focus-bg: #46288a;
  --border-subtle: rgba(252, 252, 251, 0.11);
}

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

html, body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  line-height: 1.45;
  min-height: 100dvh;
  transition: background-color 0.25s ease, color 0.25s ease;
}

.hidden { display: none !important; }
button, input, textarea { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }

.stack-sm { display: flex; flex-direction: column; gap: 0.65rem; }
.stack-md { display: flex; flex-direction: column; gap: 1rem; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; }
.muted { color: var(--muted); }
.small-text { font-size: 0.82rem; }

.toast {
  position: fixed;
  top: max(1rem, env(safe-area-inset-top));
  left: 50%;
  transform: translate(-50%, -140%);
  z-index: 900;
  background: var(--ink);
  color: #fff;
  padding: 0.7rem 1.15rem;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 500;
  max-width: calc(100vw - 2rem);
  transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}
.toast.show { transform: translate(-50%, 0); }
.toast.error { background: var(--red); }

.login-shell {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border-radius: 26px;
  padding: 2rem 1.5rem;
  box-shadow: var(--shadow-soft);
  text-align: center;
}
.login-avatar { width: 64px; height: 64px; border-radius: 50%; margin: 0 auto 0.75rem; display: block; object-fit: cover; }
.login-title { font-size: 1.35rem; font-weight: 800; color: var(--purple); }
.login-sub { font-size: 0.88rem; color: var(--muted); margin-bottom: 1.4rem; }

.field { display: flex; flex-direction: column; gap: 0.35rem; text-align: left; }
.field-label { font-size: 0.78rem; font-weight: 600; color: var(--muted); }

input, textarea {
  width: 100%;
  border: none;
  background: var(--surface-soft);
  border-radius: var(--radius-sm);
  padding: 0.8rem 0.95rem;
  font-size: 0.94rem;
  outline: none;
}
input:focus, textarea:focus {
  background: var(--input-focus-bg);
  box-shadow: 0 0 0 2px rgba(236, 37, 124, 0.35);
}

.form-error {
  color: var(--red);
  font-size: 0.84rem;
  background: var(--red-soft);
  padding: 0.65rem 0.85rem;
  border-radius: 12px;
}

.app-shell {
  max-width: 720px;
  margin: 0 auto;
  padding-bottom: 3rem;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: max(0.85rem, env(safe-area-inset-top)) 1rem 0.75rem;
  background: var(--topbar-bg);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  transition: background-color 0.25s ease;
}
.topbar-brand { display: flex; align-items: center; gap: 0.65rem; }
.topbar-avatar { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; }
.topbar-title { display: block; font-size: 1.05rem; font-weight: 800; color: var(--purple); }
.topbar-sub { display: block; font-size: 0.74rem; color: var(--muted); }
.topbar-actions { display: flex; align-items: center; gap: 0.45rem; margin-left: auto; }
.icon-pill { padding: 0.45rem 0.85rem; border-radius: 999px; background: var(--surface); font-size: 0.8rem; font-weight: 700; color: var(--purple); }

.content { padding: 0.5rem 1rem 1rem; }

.surface {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.15rem;
  box-shadow: var(--shadow-soft);
}
.block-title { font-size: 0.96rem; font-weight: 800; color: var(--purple); }
.link-accent { color: var(--accent); font-size: 0.84rem; font-weight: 700; white-space: nowrap; }

.btn-primary {
  border: none;
  background: var(--accent);
  color: #fff;
  padding: 0.88rem 1.2rem;
  border-radius: 14px;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
}
.btn-primary:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-subtle {
  border: none;
  background: var(--surface-soft);
  color: var(--purple);
  padding: 0.78rem 1.05rem;
  border-radius: 14px;
  font-weight: 700;
  font-size: 0.88rem;
  cursor: pointer;
}
.btn-full { width: 100%; }

.manual-box summary {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.55rem;
}

.stat-pill {
  background: var(--surface);
  border-radius: 16px;
  padding: 0.75rem 0.5rem;
  text-align: center;
  box-shadow: var(--shadow-soft);
}
.stat-pill strong { display: block; font-size: 1.25rem; font-weight: 800; line-height: 1.1; }
.stat-pill span { font-size: 0.72rem; color: var(--muted); font-weight: 600; }
.stat-new strong { color: var(--green); }
.stat-diff strong { color: var(--amber); }
.stat-only-site strong { color: var(--red); }
.stat-ok strong { color: var(--purple); }

.cmp-item {
  background: var(--surface-soft);
  border-radius: 14px;
  padding: 0.85rem 0.95rem;
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
}

.cmp-item input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin-top: 0.2rem;
  accent-color: var(--accent);
  flex-shrink: 0;
}

.cmp-body { flex: 1; min-width: 0; }
.cmp-title { font-size: 0.92rem; font-weight: 700; color: var(--ink); word-break: break-word; }
.cmp-url { font-size: 0.76rem; color: var(--muted); word-break: break-all; margin-top: 0.18rem; display: block; }
.cmp-tags { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.45rem; }
.cmp-tag {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  background: #fff;
  color: var(--purple);
}
.cmp-tag.warn { background: var(--amber-soft); color: var(--amber); }

.json-box {
  background: #1b1330;
  color: #e9e4f5;
  padding: 0.95rem;
  border-radius: 14px;
  font-size: 0.76rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  overflow-x: auto;
  max-height: 260px;
  white-space: pre;
}

.actions-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
}

/* Seletor compacto de 3 temas (Dark / Light / Purple) */
.theme-switcher {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border-radius: 999px;
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

.login-theme-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 1rem;
}

.login-theme-wrap .theme-switcher {
  background: var(--surface-soft);
  box-shadow: none;
}

.theme-opt-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  height: 28px;
  min-width: 28px;
  padding: 0 0.42rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.28rem;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}

.theme-opt-btn svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  display: block;
}

.theme-opt-label {
  display: none;
  line-height: 1;
}

@media (min-width: 560px) {
  .theme-opt-btn {
    padding: 0 0.58rem;
  }

  .theme-opt-label {
    display: inline;
  }
}

.theme-opt-btn:hover {
  color: var(--purple);
  background: var(--surface-soft);
}

.theme-opt-btn[data-theme-option="dark"][aria-pressed="true"] {
  background: #200e4a;
  color: #fcfcfb;
}

.theme-opt-btn[data-theme-option="dark"][aria-pressed="true"] svg {
  color: #fcd401;
}

.theme-opt-btn[data-theme-option="light"][aria-pressed="true"] {
  background: #fde8f2;
  color: #371b71;
}

.theme-opt-btn[data-theme-option="light"][aria-pressed="true"] svg {
  color: #f59e0b;
}

.theme-opt-btn[data-theme-option="purple"][aria-pressed="true"] {
  background: #ec257c;
  color: #ffffff;
}

.theme-opt-btn[data-theme-option="purple"][aria-pressed="true"] svg {
  color: #fcd401;
}

/* Ajustes específicos: Tema Purple (topbar sobre #371B71) */
html[data-theme="purple"] .topbar-title {
  color: #fcfcfb;
}

html[data-theme="purple"] .topbar-sub {
  color: rgba(252, 252, 251, 0.78);
}

/* Ajustes específicos: Tema Dark */
html[data-theme="dark"] .topbar {
  border-bottom: 1px solid rgba(252, 252, 251, 0.08);
}

html[data-theme="dark"] .login-card,
html[data-theme="dark"] .surface,
html[data-theme="dark"] .stat-pill,
html[data-theme="dark"] .icon-pill,
html[data-theme="dark"] .theme-switcher {
  border: 1px solid var(--border-subtle);
}

html[data-theme="dark"] .cmp-tag {
  background: rgba(252, 252, 251, 0.14);
  color: #fcfcfb;
}

html[data-theme="dark"] .cmp-tag.warn {
  background: var(--amber-soft);
  color: #fde68a;
}

html[data-theme="dark"] .toast {
  background: #180a36;
  border: 1px solid rgba(252, 252, 251, 0.14);
}

html[data-theme="dark"] .theme-opt-btn[data-theme-option="light"][aria-pressed="true"] {
  background: #ffffff;
  color: #371b71;
}
