/* Design tokens ---------------------------------------------------- */
:root {
  --paper: #EFEAE0;
  --paper-raised: #FBF8F1;
  --ink: #1E2A4A;
  --ink-muted: #5B6178;
  --accent: #C2871F;
  --accent-ink: #2E2000;
  --verde: #3C6E47;
  --verde-bg: #E3EDE3;
  --vermelho: #A13D2E;
  --vermelho-bg: #F3E4DF;
  --linha: #D9D0B9;
  --shadow: rgba(30, 42, 74, 0.10);
  --erro: #A13D2E;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #141B2E;
    --paper-raised: #1C2540;
    --ink: #EDEAE0;
    --ink-muted: #A9AEC4;
    --accent: #E7A83E;
    --accent-ink: #241800;
    --verde: #7BB489;
    --verde-bg: #1E3327;
    --vermelho: #E08972;
    --vermelho-bg: #3A2420;
    --linha: #33406B;
    --shadow: rgba(0, 0, 0, 0.4);
    --erro: #E08972;
  }
}

:root[data-theme="dark"] {
  --paper: #141B2E;
  --paper-raised: #1C2540;
  --ink: #EDEAE0;
  --ink-muted: #A9AEC4;
  --accent: #E7A83E;
  --accent-ink: #241800;
  --verde: #7BB489;
  --verde-bg: #1E3327;
  --vermelho: #E08972;
  --vermelho-bg: #3A2420;
  --linha: #33406B;
  --shadow: rgba(0, 0, 0, 0.4);
  --erro: #E08972;
}

/* Reset & base ------------------------------------------------------ */
* { box-sizing: border-box; }

html { color-scheme: light dark; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Public Sans", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  font-family: "Bitter", Georgia, serif;
  font-weight: 600;
  text-wrap: balance;
  margin: 0 0 4px;
}

p { line-height: 1.55; }

a { color: var(--ink); }

/* Masthead ------------------------------------------------------------ */
.masthead {
  background: var(--ink);
  border-bottom: 1px solid var(--linha);
}

.masthead-inner {
  max-width: 1180px;
  margin-inline: auto;
  padding-inline: 24px;
  min-height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: "Bitter", Georgia, serif;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--paper-raised);
  text-decoration: none;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.brand-icon { width: 30px; height: 30px; flex-shrink: 0; }

.masthead-nav {
  display: flex;
  align-items: center;
  gap: 22px;
  flex-wrap: wrap;
  margin-left: auto;
}

.masthead-nav a {
  color: var(--paper-raised);
  opacity: 0.72;
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 500;
}

.masthead-nav a:hover,
.masthead-nav a.is-active {
  opacity: 1;
}

.masthead-nav .nav-sep {
  width: 1px;
  height: 18px;
  background: var(--linha);
  opacity: 0.4;
}

.masthead-nav .nav-cta {
  opacity: 1;
  background: var(--accent);
  color: var(--accent-ink);
  padding: 7px 14px;
  border-radius: 6px;
  font-weight: 600;
}

/* Nav toggle (hamburger) - hidden on desktop, shown below the breakpoint
   where the full nav (up to 11 links when logged in) no longer fits on
   one line and would otherwise wrap into a wall of links pushing page
   content below the fold (caught live on a real phone-width screenshot,
   not assumed). */
.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 36px;
  height: 36px;
  padding: 0;
  background: none;
  border: none;
  cursor: pointer;
}

.nav-toggle span {
  display: block;
  width: 100%;
  height: 2px;
  background: var(--paper-raised);
  border-radius: 1px;
}

@media (max-width: 860px) {
  .nav-toggle { display: flex; }

  .masthead-nav {
    display: none;
    width: 100%;
    flex-direction: column;
    align-items: flex-start;
    gap: 14px;
    margin-left: 0;
    padding: 18px 0 6px;
  }

  .masthead-nav.is-open { display: flex; }

  .masthead-nav .nav-sep { display: none; }
}

.site-footer {
  border-top: 1px solid var(--linha);
  margin-top: 48px;
}

.site-footer-inner {
  max-width: 1180px;
  margin-inline: auto;
  padding: 20px 24px 40px;
  color: var(--ink-muted);
  font-size: 0.82rem;
}

/* Containers ---------------------------------------------------------- */
.shell {
  max-width: 460px;
  margin-inline: auto;
  padding-inline: 20px;
  padding-block: 48px 64px;
}

.shell--wide {
  max-width: 1180px;
  padding-inline: clamp(20px, 4vw, 24px);
}

.shell--flush {
  max-width: none;
  padding-inline: 0;
  padding-block: 0;
}

.wrap {
  max-width: 1180px;
  margin-inline: auto;
  padding-inline: clamp(20px, 4vw, 24px);
}

/* Page head ------------------------------------------------------------ */
.page-head {
  margin-bottom: 28px;
}

.page-head-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 20px;
  flex-wrap: wrap;
}

.page-head h1 {
  font-size: clamp(1.55rem, 2.6vw, 2.1rem);
}

.page-head .lead {
  color: var(--ink-muted);
  font-size: 1rem;
  max-width: 70ch;
  margin: 8px 0 0;
}

.page-head .kicker {
  color: var(--ink-muted);
  font-size: 0.88rem;
  margin-bottom: 8px;
}

.link-quiet {
  font-size: 0.92rem;
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
  white-space: nowrap;
}
.link-quiet:hover { text-decoration: underline; }

.whatsapp-share-link {
  display: inline-flex;
  align-items: center;
}
.whatsapp-icon {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

/* Step indicator ------------------------------------------------------ */
.steps {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 16px;
}
.steps .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--linha);
}
.steps .dot.done,
.steps .dot.current {
  background: var(--accent);
}
.steps .step-label {
  font-size: 0.82rem;
  color: var(--ink-muted);
  margin-left: 6px;
}

/* Status badge -------------------------------------------------------- */
.status-badge {
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  margin-bottom: 16px;
  white-space: nowrap;
}
.status-badge.pendente { background: var(--linha); color: var(--ink); }
.status-badge.aprovado { background: var(--verde-bg); color: var(--verde); }
.status-badge.rejeitado { background: var(--vermelho-bg); color: var(--vermelho); }

/* Shared data table (convites, histórico eleitoral, perfil do usuário,
   perfil de vereador) --------------------------------------------------- */
.voto-tema-table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0 1.5rem;
  font-size: 0.9rem;
}

.voto-tema-table th,
.voto-tema-table td {
  text-align: left;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--linha);
  vertical-align: middle;
}

.voto-tema-table th {
  color: var(--ink-muted);
  font-weight: 600;
}

.voto-tema-table .status-badge {
  margin-bottom: 0;
}

.alerta-atraso {
  background: var(--vermelho);
  color: var(--paper-raised);
  font-weight: 700;
  font-size: 1.05rem;
  text-align: center;
  padding: 10px 14px;
  border-radius: 8px;
  margin-bottom: 16px;
}

/* Card ------------------------------------------------------------- */
.card {
  background: var(--paper-raised);
  border: 1px solid var(--linha);
  border-radius: 10px;
  padding: 26px 24px;
  box-shadow: 0 2px 10px var(--shadow);
}

.card h1 { font-size: 1.4rem; margin-bottom: 6px; }

.voto-botoes {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 16px 0;
}

.lead {
  color: var(--ink-muted);
  font-size: 0.92rem;
  margin: 6px 0 20px;
}

.note {
  font-size: 0.8rem;
  color: var(--ink-muted);
  margin-top: 16px;
}
.note a { color: var(--accent); }

.fine-print {
  margin-top: 18px;
  font-size: 0.85rem;
  color: var(--ink-muted);
}
.fine-print a { color: var(--accent); }

hr.divider {
  border: none;
  border-top: 1px solid var(--linha);
  margin: 18px 0;
}

/* Forms -------------------------------------------------------------- */
form p {
  margin: 0 0 16px;
}

form label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--ink);
}

form input,
form select {
  width: 100%;
  font-family: inherit;
  font-size: 0.95rem;
  padding: 10px 12px;
  border: 1px solid var(--linha);
  border-radius: 6px;
  background: var(--paper);
  color: var(--ink);
}

form input:focus,
form select:focus,
button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

form .helptext {
  display: block;
  font-size: 0.76rem;
  color: var(--ink-muted);
  margin-top: 5px;
}

/* Django's password validators render as a <ul> inside .helptext (e.g. on
   password1) — reset the browser's default list spacing so it reads as a
   compact hint, not a large bulleted block. */
form .helptext ul {
  margin: 4px 0 0;
  padding-left: 16px;
  list-style: disc;
}

form .helptext li {
  margin-bottom: 2px;
}

form ul.errorlist {
  list-style: none;
  margin: 0 0 6px;
  padding: 0;
  color: var(--erro);
  font-size: 0.82rem;
}

form .field-error {
  margin: 4px 0 0;
  color: var(--erro);
  font-size: 0.82rem;
}

button, input[type="submit"] {
  width: 100%;
  background: var(--accent);
  color: var(--accent-ink);
  border: none;
  border-radius: 6px;
  padding: 12px 16px;
  font-family: inherit;
  font-size: 0.98rem;
  font-weight: 600;
  cursor: pointer;
}

button:hover, input[type="submit"]:hover {
  filter: brightness(1.05);
}

/* Auth screens (login/signup) - hero banner on top, form below. Always
   stacked (not side-by-side): a long form (signup has ~11 fields) made a
   side-by-side split look broken - the short hero text either left a
   huge empty gap or (on mobile) pushed the form off-screen below a
   full-height panel. Stacking removes that mismatch at every width. ---- */
.auth-hero {
  background: var(--ink);
  color: var(--paper-raised);
  padding: 40px clamp(20px, 5vw, 72px);
}

.auth-hero .kicker {
  color: var(--paper-raised);
  opacity: 0.65;
  font-size: 0.9rem;
  margin-bottom: 12px;
}

.auth-hero h1 {
  color: var(--paper-raised);
  font-size: clamp(1.5rem, 4vw, 2.1rem);
  line-height: 1.2;
  max-width: 48ch;
}

.auth-hero p {
  color: var(--paper-raised);
  opacity: 0.78;
  max-width: 52ch;
  margin-top: 10px;
}

.auth-form-wrap {
  padding: 32px 20px 64px;
  display: flex;
  justify-content: center;
}

.auth-form-wrap .shell {
  padding: 0;
  margin: 0;
  max-width: 420px;
  width: 100%;
}

/* Landing page --------------------------------------------------------- */
.hero {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 56px;
  align-items: center;
  padding-block: 64px 40px;
}

@media (max-width: 860px) {
  .hero { grid-template-columns: 1fr; padding-block: 40px 24px; gap: 32px; }
}

.landing .kicker {
  color: var(--ink-muted);
  font-size: 0.9rem;
  margin-bottom: 10px;
}

.landing h1 {
  font-size: clamp(2.1rem, 4.4vw, 3.4rem);
  line-height: 1.12;
  margin-bottom: 18px;
}

.landing .lead {
  font-size: 1.1rem;
  color: var(--ink-muted);
  max-width: 52ch;
  margin: 0 0 32px;
}

.landing .features {
  display: flex;
  flex-direction: column;
  gap: 22px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.landing .features li {
  padding: 18px 20px;
  background: var(--paper-raised);
  border: 1px solid var(--linha);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
}

.landing .features strong {
  display: block;
  font-size: 1rem;
  margin-bottom: 4px;
}

.landing .features span {
  color: var(--ink-muted);
  font-size: 0.92rem;
}

.cta {
  display: inline-block;
  background: var(--accent);
  color: var(--accent-ink);
  border: none;
  border-radius: 6px;
  padding: 13px 22px;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  text-decoration: none;
}

.cta:hover {
  filter: brightness(1.05);
}

/* Dashboard (home) ------------------------------------------------------ */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 20px;
}

.dashboard-card {
  display: block;
  background: var(--paper-raised);
  border: 1px solid var(--linha);
  border-top: 3px solid var(--accent);
  border-radius: 10px;
  padding: 26px 24px;
  text-decoration: none;
  color: inherit;
  box-shadow: 0 2px 10px var(--shadow);
}

.dashboard-card h2 {
  font-size: 1.2rem;
  margin-bottom: 8px;
}

.dashboard-card p {
  color: var(--ink-muted);
  font-size: 0.92rem;
  margin: 0;
}

.dashboard-card .link-quiet {
  display: inline-block;
  margin-top: 14px;
}

/* Toolbar (filters) ------------------------------------------------------ */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: end;
  padding: 18px 20px;
  background: var(--paper-raised);
  border: 1px solid var(--linha);
  border-radius: 10px;
  margin-bottom: 28px;
}
.filters > div { flex: 1 1 160px; }
.filters p { margin: 0; }
.filters button { width: auto; flex: 0 0 auto; padding-inline: 22px; }

/* Obras: card grid ------------------------------------------------------- */
.obra-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 18px;
}

.obra-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--paper-raised);
  border: 1px solid var(--linha);
  border-radius: 10px;
  padding: 20px;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s ease;
}

.obra-card:hover {
  border-color: var(--accent);
}

.obra-card .status-badge {
  margin-bottom: 0;
  align-self: flex-start;
}

.obra-card .obra-meta {
  color: var(--ink-muted);
  font-size: 0.84rem;
}

.obra-card .obra-title {
  font-weight: 600;
  font-size: 0.98rem;
  color: var(--ink);
}

.empty-state {
  padding: 40px 20px;
  text-align: center;
  color: var(--ink-muted);
  background: var(--paper-raised);
  border: 1px dashed var(--linha);
  border-radius: 10px;
}

/* Two-column detail layout ------------------------------------------------ */
.detail-layout {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 32px;
  align-items: start;
}

@media (max-width: 860px) {
  .detail-layout { grid-template-columns: 1fr; }
}

.detail-main { min-width: 0; }

.sidebar-panel {
  background: var(--paper-raised);
  border: 1px solid var(--linha);
  border-radius: 10px;
  padding: 22px;
  position: sticky;
  top: 20px;
}

.sidebar-panel h2 {
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--ink-muted);
  margin-bottom: 14px;
}

.fact-list {
  margin: 0;
}
.fact-list dt {
  font-size: 0.78rem;
  color: var(--ink-muted);
  margin-top: 14px;
}
.fact-list dt:first-child { margin-top: 0; }
.fact-list dd {
  margin: 2px 0 0;
  font-weight: 600;
  font-size: 0.95rem;
}

/* Legislativo: ledger list ------------------------------------------------ */
.ledger {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--linha);
}

.ledger-item {
  display: grid;
  grid-template-columns: 190px 1fr;
  gap: 24px;
  padding: 22px 0;
  border-bottom: 1px solid var(--linha);
}

@media (max-width: 700px) {
  .ledger-item { grid-template-columns: 1fr; gap: 6px; }
}

.ledger-meta {
  color: var(--ink-muted);
  font-size: 0.84rem;
  line-height: 1.5;
}

.ledger-body .obra-title,
.ledger-body strong { font-size: 1rem; }

.ledger-body p { margin: 6px 0 0; }

/* Vote breakdown table --------------------------------------------------- */
.table-wrap { overflow-x: auto; margin-top: 10px; }
.votos-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}
.votos-table th, .votos-table td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--linha);
}
.votos-table th {
  color: var(--ink-muted);
  font-weight: 500;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

/* Theme / type tags on a proposição card ---------------------------------- */
.ledger-body .tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 0; }
.tag {
  display: inline-block;
  font-size: 0.74rem;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 999px;
  border: 1px solid var(--linha);
  color: var(--ink-muted);
}
.tag-simbolico { background: var(--linha); color: var(--ink); }

/* Feed counters: efeito prático vs. homenagens e datas -------------------- */
.contadores {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1px;
  background: var(--linha);
  border: 1px solid var(--linha);
  border-radius: 10px;
  overflow: hidden;
  margin: 18px 0 10px;
}
.contador { background: var(--paper-raised); padding: 14px 16px; }
.contador .num {
  font-family: "Bitter", Georgia, serif;
  font-weight: 700;
  font-size: 1.55rem;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
  display: block;
}
.contador .label { color: var(--ink-muted); font-size: 0.82rem; margin-top: 4px; display: block; }
.contador .label small { font-size: 0.74rem; }
.contador-simbolico .num { color: var(--ink-muted); }

/* Back button on detail pages ---------------------------------------------- */
.back-link {
  display: inline-block;
  margin-bottom: 14px;
  padding: 7px 14px;
  border: 1px solid var(--linha);
  border-radius: 8px;
  background: var(--paper-raised);
  color: var(--ink);
  font-size: 0.86rem;
  font-weight: 600;
  text-decoration: none;
}
.back-link:hover, .back-link:focus-visible { border-color: var(--accent); color: var(--accent); }
