/* ============================================================
   Politibook Web — main stylesheet
   Theme: Brazilian flag colors (green/yellow) + gold favorites
   ============================================================ */

:root {
  --green:        #009C3B;
  --green-dark:   #006B29;
  --yellow:       #FFDF00;
  --yellow-soft:  #FFF1A8;
  --gold:         #D4A017;
  --gold-light:   #FCEFC3;
  --red:          #D9342B;
  --blue:         #0F2A5C;

  --bg:           #FAFAF7;
  --surface:      #FFFFFF;
  --surface-alt:  #F4F4EE;
  --border:       #E5E2D7;
  --text:         #1B1B1B;
  --text-soft:    #5A5A5A;
  --text-muted:   #8A8A8A;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow:    0 2px 8px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.10);

  --radius-sm: 6px;
  --radius:    10px;
  --radius-lg: 16px;
}

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

html, body {
  margin: 0; padding: 0;
  font-family: 'Inter', system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--green-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; display: block; }

/* ── Layout ──────────────────────────────────────────────────────────────── */
.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
}

.main {
  min-height: calc(100vh - 220px);
  padding: 32px 0 64px;
}

/* ── Topbar ──────────────────────────────────────────────────────────────── */
.topbar {
  background: linear-gradient(135deg, var(--green) 0%, var(--green-dark) 100%);
  color: #fff;
  box-shadow: var(--shadow);
  position: sticky; top: 0; z-index: 100;
}
.topbar-inner {
  max-width: 1200px; margin: 0 auto; padding: 12px 24px;
  display: flex; align-items: center; gap: 24px;
}
.brand {
  display: flex; align-items: center; gap: 8px;
  color: #fff; font-weight: 800; font-size: 1.2rem;
  text-decoration: none;
}
.brand-flag { font-size: 1.4rem; }
.brand-name { letter-spacing: -0.5px; }

.topnav {
  display: flex; gap: 4px; flex: 1;
  margin-left: 24px;
}
.topnav-link {
  color: rgba(255, 255, 255, 0.85);
  padding: 8px 14px; border-radius: var(--radius-sm);
  font-weight: 500; font-size: 0.95rem;
  transition: background 0.15s, color 0.15s;
}
.topnav-link:hover { background: rgba(255, 255, 255, 0.12); color: #fff; text-decoration: none; }
.topnav-link.is-active {
  background: var(--yellow);
  color: var(--green-dark);
}

.topbar-actions { display: flex; align-items: center; gap: 8px; }
.user-pill {
  background: rgba(255, 255, 255, 0.18);
  padding: 6px 12px; border-radius: 999px;
  font-size: 0.85rem; font-weight: 500;
}

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-block;
  font-family: inherit; font-size: 0.95rem; font-weight: 600;
  padding: 10px 18px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none; text-align: center;
  transition: transform 0.05s, box-shadow 0.15s, background 0.15s;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn-sm { font-size: 0.85rem; padding: 6px 12px; }
.btn-block { display: block; width: 100%; }

.btn-primary {
  background: var(--yellow); color: var(--green-dark);
  border-color: var(--yellow);
}
.btn-primary:hover { background: var(--yellow-soft); box-shadow: var(--shadow); }

.btn-ghost {
  background: transparent; color: inherit;
  border-color: rgba(255, 255, 255, 0.30);
}
.topbar .btn-ghost { color: #fff; }
.btn-ghost:hover { background: rgba(0, 0, 0, 0.06); }
.topbar .btn-ghost:hover { background: rgba(255, 255, 255, 0.16); }

.btn-gold {
  background: var(--gold); color: #fff;
  border-color: var(--gold);
}
.btn-gold:hover { background: #B0860F; }

.btn-danger {
  background: var(--red); color: #fff;
  border-color: var(--red);
}
.btn-danger:hover { background: #B92822; }

.inline-form { display: inline-block; margin: 0; }

/* ── Hero ────────────────────────────────────────────────────────────────── */
.hero {
  text-align: center;
  padding: 32px 0 24px;
}
.hero-title {
  font-size: 2.4rem; font-weight: 800;
  margin: 0 0 8px;
  letter-spacing: -1px;
}
.hero-sub {
  color: var(--text-soft);
  font-size: 1.1rem;
  margin: 0 auto 24px; max-width: 580px;
}
.hero-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

/* ── Sections ────────────────────────────────────────────────────────────── */
.feed-section { margin: 32px 0; }
.section-head { margin-bottom: 16px; }
.section-head-row {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px;
}
.section-link {
  font-size: 0.9rem; font-weight: 600;
  color: var(--green-dark);
  white-space: nowrap;
}

/* ── Presidential candidates strip (home hero) ─────────────────────────── */
.feed-section-cands {
  /* Visually anchor the most important content above the news feed.
     Subtle elevated surface to set the "main event" apart. */
  background: linear-gradient(180deg, #FFFDF5 0%, var(--bg) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 24px 24px;
  margin-top: 8px;
  margin-bottom: 32px;
}

.hero-cands-strip {
  list-style: none;
  margin: 0; padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}
.hero-cands-strip > li { margin: 0; }

.hero-cand {
  position: relative;
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 14px 14px;
  text-decoration: none;
  color: inherit;
  text-align: center;
  transition: transform 0.12s, box-shadow 0.15s, border-color 0.15s;
  overflow: hidden;
  /* Top stripe color reserved for political-position grouping (set per-class). */
}
.hero-cand::before {
  /* 4px coloured top stripe — pre-attentive cue for political grouping
     without dominating the card. */
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: var(--text-muted);
}
.hero-cand:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  border-color: #d2cdbb;
  text-decoration: none;
}
.hero-cand:focus-visible {
  outline: 3px solid var(--green);
  outline-offset: 2px;
}
.hero-cand-photo {
  display: flex; justify-content: center;
  margin-bottom: 10px;
}
/* Force avatar size in this strip even when the avatar templatetag uses defaults. */
.hero-cand-photo .avatar {
  width: 96px !important; height: 96px !important;
  line-height: 96px !important;
  font-size: 1.6rem;
  border-width: 3px;
}
.hero-cand-name {
  font-size: 1rem; font-weight: 700;
  margin: 0 0 6px;
  line-height: 1.25;
}
.hero-cand-meta {
  display: flex; justify-content: center; gap: 4px;
  margin: 0 0 6px;
}
.hero-cand-pos {
  display: inline-block;
  font-size: 0.72rem; font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.4px;
}

/* Political-position colour coding — used only as a 4px stripe at the top
   so the visual cue is informative but not editorialising. */
.hero-cand.pos-esquerda::before        { background: #C0392B; }
.hero-cand.pos-centro-esquerda::before { background: #E67E22; }
.hero-cand.pos-centro::before          { background: #7F8C8D; }
.hero-cand.pos-centro-direita::before  { background: #5DADE2; }
.hero-cand.pos-direita::before         { background: #2874A6; }

@media (max-width: 480px) {
  .hero-cands-strip { grid-template-columns: repeat(2, 1fr); }
  .feed-section-cands { padding: 16px 14px 18px; }
  .section-head-row { flex-direction: column; align-items: flex-start; }
}

.section-title {
  font-size: 1.4rem; font-weight: 700;
  margin: 0 0 4px;
}
.section-title-gold { color: var(--gold); }
.section-sub { color: var(--text-soft); font-size: 0.95rem; margin: 0; }

.page-head { margin-bottom: 24px; }
.page-title {
  font-size: 1.8rem; font-weight: 800;
  margin: 0 0 4px; letter-spacing: -0.5px;
}
.page-sub { color: var(--text-soft); margin: 0; }

/* ── Tabs ────────────────────────────────────────────────────────────────── */
.tabs {
  display: flex; gap: 4px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 16px;
}
.tab {
  padding: 10px 18px;
  font-weight: 600; color: var(--text-soft);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
}
.tab:hover { text-decoration: none; color: var(--text); }
.tab.is-active { color: var(--green-dark); border-bottom-color: var(--green); }

/* ── Filter bar ──────────────────────────────────────────────────────────── */
.filter-bar {
  display: grid; grid-template-columns: 2fr 1fr 1fr auto; gap: 8px;
  background: var(--surface); padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 20px;
}
.filter-input {
  font-family: inherit; font-size: 0.95rem;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
}
.filter-input:focus {
  outline: 2px solid var(--green);
  outline-offset: -1px;
}
.results-count { color: var(--text-soft); font-size: 0.9rem; margin: 0 0 16px; }

@media (max-width: 720px) {
  .filter-bar { grid-template-columns: 1fr 1fr; }
  .filter-bar .btn { grid-column: 1 / -1; }
}

/* ── News cards ──────────────────────────────────────────────────────────── */
.news-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.news-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: transform 0.12s, box-shadow 0.15s;
}
.news-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}
.news-card-link {
  display: flex; flex-direction: column; height: 100%;
  color: inherit; text-decoration: none;
}
.news-card-link:hover { text-decoration: none; }
.news-img {
  width: 100%; height: 160px; object-fit: cover;
  background: var(--surface-alt);
}
.news-img-placeholder {
  display: flex; align-items: center; justify-content: center;
  font-size: 2.5rem; color: var(--text-muted);
}
.news-body { padding: 14px 16px 16px; flex: 1; display: flex; flex-direction: column; }
.news-tag {
  display: inline-block;
  background: var(--gold-light); color: var(--gold);
  padding: 2px 10px; border-radius: 999px;
  font-size: 0.75rem; font-weight: 700;
  margin-bottom: 8px; align-self: flex-start;
  text-transform: uppercase; letter-spacing: 0.4px;
}
.news-title {
  font-size: 1.05rem; font-weight: 700; line-height: 1.35;
  margin: 0 0 6px;
}
.news-desc { color: var(--text-soft); font-size: 0.9rem; margin: 0 0 10px; flex: 1; }
.news-meta { color: var(--text-muted); font-size: 0.8rem; margin: 0; }

/* ── Politician cards ────────────────────────────────────────────────────── */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 12px;
}
.pol-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: flex; align-items: center; gap: 12px;
  transition: box-shadow 0.15s, border-color 0.15s;
}
.pol-card:hover {
  box-shadow: var(--shadow);
  border-color: #d2cdbb;
}
.pol-card-link {
  flex: 1;
  display: flex; align-items: center; gap: 12px;
  color: inherit; text-decoration: none;
  min-width: 0;
}
.pol-card-link:hover { text-decoration: none; }
.pol-card-info { min-width: 0; flex: 1; }
.pol-card-name {
  font-size: 1rem; font-weight: 700;
  margin: 0 0 4px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pol-card-meta {
  display: flex; align-items: center; gap: 6px;
  margin: 0; font-size: 0.85rem; color: var(--text-soft);
  flex-wrap: wrap;
}
.pol-card-sub {
  font-size: 0.8rem; color: var(--text-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pol-card-actions {
  display: flex; gap: 4px;
  flex-shrink: 0;
}

/* ── Avatars ─────────────────────────────────────────────────────────────── */
.avatar {
  border-radius: 50%;
  background: var(--surface-alt);
  flex-shrink: 0;
  object-fit: cover;
  border: 2px solid #fff;
  box-shadow: var(--shadow-sm);
}
.avatar-fallback {
  display: inline-flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--green) 0%, var(--green-dark) 100%);
  color: #fff; font-weight: 700;
}

/* ── Badges ──────────────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 0.75rem; font-weight: 700;
  background: var(--surface-alt);
  color: var(--text-soft);
  letter-spacing: 0.3px;
}
.badge-party { background: #E8F4EC; color: var(--green-dark); }
.badge-state { background: #FFF7CC; color: #8C6B00; }

/* ── Icon buttons (favorite / reject) ────────────────────────────────────── */
.iconbtn {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 999px;
  width: 36px; height: 36px;
  font-size: 1.1rem; line-height: 1;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.12s;
}
.iconbtn:hover { border-color: var(--text-soft); color: var(--text); }
.iconbtn-fav.is-on {
  /* Filled gold heart on a soft gold background — symmetric with the
     reject button, so users read both states the same way. */
  background: var(--gold-light);
  border-color: var(--gold);
  color: var(--gold);
  font-weight: 900;
  font-size: 1.3rem;
  line-height: 1;
}
.iconbtn-rej.is-on {
  /* Red X on a soft red background — clearly reads as "rejected"
     across themes, with the X itself drawn in vivid red instead of
     the previous white-on-red which was easy to misread as a check. */
  background: #FFE6E4;
  border-color: var(--red);
  color: var(--red);
  font-weight: 900;
  font-size: 1.35rem;
  line-height: 1;
}

/* ── Auth ─────────────────────────────────────────────────────────────────── */
.auth-page {
  display: flex; justify-content: center;
  padding: 48px 24px;
}
.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 36px 32px;
  width: 100%; max-width: 420px;
  box-shadow: var(--shadow);
}
.auth-title {
  margin: 0 0 4px;
  font-size: 1.6rem; font-weight: 800;
}
.auth-sub { color: var(--text-soft); margin: 0 0 24px; }
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-foot { text-align: center; margin: 20px 0 0; color: var(--text-soft); font-size: 0.9rem; }

.field { display: flex; flex-direction: column; gap: 4px; }
.field-label { font-size: 0.85rem; font-weight: 600; color: var(--text-soft); }
.field input {
  font-family: inherit; font-size: 1rem;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
}
.field input:focus { outline: 2px solid var(--green); outline-offset: -1px; }
.field-error {
  color: var(--red); font-size: 0.8rem;
}
.form-errors {
  background: #FDEDEB; color: var(--red);
  border: 1px solid #F4C7C3;
  padding: 10px 14px; border-radius: var(--radius-sm);
  font-size: 0.9rem;
}

/* ── Detail page ─────────────────────────────────────────────────────────── */
.detail-hero {
  display: flex; gap: 24px; align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
}
.detail-hero-info { flex: 1; min-width: 0; }
.detail-name {
  font-size: 1.8rem; font-weight: 800;
  margin: 0 0 4px; letter-spacing: -0.5px;
}
.detail-sub { color: var(--text-soft); margin: 0 0 8px; }
.detail-meta {
  display: flex; gap: 6px; flex-wrap: wrap;
  margin: 0 0 8px;
}
.detail-contact { color: var(--text-soft); margin: 0 0 8px; font-size: 0.9rem; }
.detail-slogan {
  font-style: italic; color: var(--text-soft);
  margin: 8px 0 0;
}
.detail-actions { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; }

.detail-section { margin: 28px 0; }

/* ── Scores ──────────────────────────────────────────────────────────────── */
.scores-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  margin-bottom: 24px;
}
.scores-grid {
  display: grid; grid-template-columns: 180px 1fr; gap: 24px;
  align-items: center;
}
.score-card { text-align: center; }
.score-overall {
  font-size: 3.5rem; font-weight: 800;
  width: 140px; height: 140px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 8px;
  color: #fff;
}
.score-label {
  font-size: 0.95rem; font-weight: 600;
  color: var(--text-soft); margin: 0;
}
.score-quad {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
}
.score-cell {
  background: var(--surface-alt);
  padding: 14px;
  border-radius: var(--radius);
  display: flex; flex-direction: column; gap: 2px;
}
.score-num { font-size: 1.6rem; font-weight: 800; }
.score-name { font-size: 0.85rem; font-weight: 600; color: var(--text-soft); }
.score-hint { font-size: 0.75rem; color: var(--text-muted); }

.score-excellent { color: #1B7F35; background-color: #1B7F35; }
.score-good      { color: #4F8E1B; background-color: #4F8E1B; }
.score-fair      { color: #C58E00; background-color: #C58E00; }
.score-poor      { color: #B92822; background-color: #B92822; }
/* When applied to plain numbers, only the foreground should color. */
.score-num.score-excellent, .score-num.score-good,
.score-num.score-fair, .score-num.score-poor { background: transparent; }
.score-overall.score-neutral { background: var(--text-muted); }
.score-num.score-neutral { color: var(--text-muted); }

@media (max-width: 720px) {
  .scores-grid { grid-template-columns: 1fr; }
  .score-overall { width: 100px; height: 100px; font-size: 2.5rem; }
  .detail-hero { flex-direction: column; text-align: center; }
}

/* ── Data table & lists ──────────────────────────────────────────────────── */
.data-table {
  width: 100%; border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  font-size: 0.9rem;
}
.data-table th, .data-table td {
  padding: 10px 14px; text-align: left;
  border-bottom: 1px solid var(--border);
}
.data-table th {
  background: var(--surface-alt);
  font-weight: 600; color: var(--text-soft);
  font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.5px;
}
.data-table tr:last-child td { border-bottom: none; }
.t-right { text-align: right !important; }

.prop-list, .speech-list, .kv-list {
  list-style: none; padding: 0;
  display: flex; flex-direction: column; gap: 8px;
}
.prop-item, .speech-item, .kv-list li {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  font-size: 0.95rem;
}
.speech-date { color: var(--text-muted); font-size: 0.85rem; margin-right: 8px; }
.prose { line-height: 1.6; color: var(--text); }

/* ── Empty messages, alerts ──────────────────────────────────────────────── */
.empty-msg {
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 24px;
  color: var(--text-soft);
  text-align: center;
}

.messages { padding-top: 16px; }
.alert {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  font-size: 0.9rem;
}
.alert-success { background: #E8F5EC; color: #1B7F35; border: 1px solid #C7E5D2; }
.alert-error   { background: #FDEDEB; color: #B92822; border: 1px solid #F4C7C3; }
.alert-info    { background: #E8F0FB; color: #1A4DB3; border: 1px solid #C7D9F0; }

/* ── Footer ──────────────────────────────────────────────────────────────── */
.footer {
  padding: 32px 0;
  border-top: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 0.85rem;
  text-align: center;
}
.footer a { color: var(--green-dark); }

/* ──────────────────────────────────────────────────────────────────────────
   MOBILE OPTIMIZATIONS
   Design principles:
   - Touch targets ≥ 44×44 CSS px (Apple HIG, WCAG 2.5.5)
   - Form inputs ≥ 16px font-size (prevents iOS Safari auto-zoom on focus)
   - Bottom tab bar > top nav for thumb reach (Lei de Fitts: thumb zone)
   - Reduce cognitive load: hero is shorter, less competing CTAs
   - No horizontal scroll on any viewport (overflow-x: hidden on body)
   - Tables become card-stack on narrow viewports
   - Sticky filter bar so user does not lose search controls when scrolling
   ────────────────────────────────────────────────────────────────────────── */

/* Always: prevent horizontal overflow caused by long words (links, titles) */
body { overflow-x: hidden; }
.detail-name, .news-title, .pol-card-name, .hero-cand-name { overflow-wrap: anywhere; }

/* Tap highlight: subtle, branded — no default blue blob on iOS */
a, button { -webkit-tap-highlight-color: rgba(0, 156, 59, 0.15); }

/* All form inputs: 16px font min on mobile (avoid iOS focus-zoom) and bigger
   tap area, regardless of viewport. */
.field input, .filter-input, button.btn {
  font-size: max(16px, 0.95rem);   /* never smaller than 16px */
}

/* Inputs: minimum 44×44 touch target */
.field input, .filter-input { min-height: 44px; }

/* All .btn meet 44px tap target. */
.btn { min-height: 44px; padding: 12px 20px; }
.btn-sm { min-height: 36px; padding: 8px 14px; }

/* Icon buttons (favorite/reject): bump from 36 → 44 to satisfy Fitts */
.iconbtn { width: 44px; height: 44px; font-size: 1.2rem; }

/* Section "see all" link: bigger tap area */
.section-link { padding: 8px 0; min-height: 44px; display: inline-flex; align-items: center; }

/* Tablet & smaller (≤ 900 px) ────────────────────────────────────────────── */
@media (max-width: 900px) {
  .container { padding: 0 16px; }
  .main { padding: 24px 0 96px; /* extra bottom space for the mobile tab bar */ }
}

/* Phone landscape & smaller (≤ 720 px) ──────────────────────────────────── */
@media (max-width: 720px) {
  .filter-bar {
    /* Sticky filter bar so the user does not lose search controls. */
    position: sticky; top: 56px; z-index: 50;
    background: var(--surface);
    box-shadow: var(--shadow-sm);
  }
}

/* Phone portrait (≤ 640 px) ─────────────────────────────────────────────── */
@media (max-width: 640px) {
  /* ── Topbar: keep brand only; nav moves to bottom tab bar ───────────── */
  .topbar-inner { flex-wrap: nowrap; gap: 12px; padding: 10px 16px; }
  .brand-name { font-size: 1.1rem; }
  .topnav { display: none; }   /* replaced by .mobile-tabbar */
  .topbar-actions { gap: 6px; }
  .topbar-actions .btn-sm { padding: 8px 10px; font-size: 0.85rem; }
  .user-pill { display: none; }   /* room is tight; user can see name in /admin/ */

  /* ── Hero ──────────────────────────────────────────────────────────── */
  .hero-title { font-size: 1.7rem; line-height: 1.15; }
  .hero-sub { font-size: 1rem; }
  .hero-actions .btn { width: 100%; }
  .hero-actions { flex-direction: column; gap: 8px; }

  /* ── News + cards stack to single column ──────────────────────────── */
  .news-grid, .card-grid { grid-template-columns: 1fr; }

  /* ── Candidates strip on home: 2 columns, smaller photo ────────────── */
  .feed-section-cands { padding: 14px 12px 16px; margin-bottom: 24px; }
  .hero-cands-strip { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .hero-cand { padding: 12px 8px 12px; }
  .hero-cand-photo .avatar {
    width: 72px !important; height: 72px !important; line-height: 72px !important;
    font-size: 1.2rem;
  }
  .hero-cand-name { font-size: 0.95rem; }
  .hero-cand-pos { display: none; }   /* hide redundant tag on small */

  /* ── Section heads: stack ──────────────────────────────────────────── */
  .section-head-row { flex-direction: column; align-items: flex-start; gap: 8px; }
  .section-title { font-size: 1.2rem; }

  /* ── Detail page: stack hero, center text ──────────────────────────── */
  .detail-hero {
    flex-direction: column; align-items: center; text-align: center;
    padding: 20px 14px; gap: 12px;
  }
  .detail-name { font-size: 1.4rem; }
  .detail-meta { justify-content: center; }
  .detail-actions { width: 100%; flex-direction: column; gap: 8px; }
  .detail-actions .btn { width: 100%; }

  /* ── Scores: single column, smaller orb ────────────────────────────── */
  .scores-section { padding: 16px 14px; }
  .scores-grid { grid-template-columns: 1fr; gap: 16px; }
  .score-overall { width: 96px; height: 96px; font-size: 2.2rem; }
  .score-quad { gap: 8px; }
  .score-cell { padding: 12px 10px; }

  /* ── Data table: card-stack pattern ────────────────────────────────── */
  .data-table thead { display: none; }
  .data-table, .data-table tbody, .data-table tr, .data-table td { display: block; width: 100%; }
  .data-table tr {
    border: 1px solid var(--border); border-radius: var(--radius);
    background: var(--surface); margin-bottom: 8px; padding: 10px 12px;
  }
  .data-table td { border: none; padding: 4px 0; text-align: left !important; }
  .data-table td:first-child { font-weight: 600; color: var(--text); }
  .data-table td:nth-child(2) { color: var(--text-soft); font-size: 0.85rem; }
  .data-table td:last-child { color: var(--green-dark); font-weight: 700; }

  /* ── Auth: less padding, bigger inputs ─────────────────────────────── */
  .auth-page { padding: 24px 12px; }
  .auth-card { padding: 24px 18px; }

  /* ── Filter bar: 1 col + side-padding match ────────────────────────── */
  .filter-bar { grid-template-columns: 1fr; gap: 6px; padding: 10px; top: 52px; }
  .filter-bar .btn { width: 100%; }

  /* ── Page heads: tighter ───────────────────────────────────────────── */
  .page-title { font-size: 1.5rem; }

  /* ── Tabs: full-width pills ───────────────────────────────────────── */
  .tabs { gap: 0; }
  .tab { flex: 1; text-align: center; padding: 12px 6px; }
}

/* Bottom mobile tab bar (only visible ≤ 640 px) ─────────────────────────── */
.mobile-tabbar {
  display: none;
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 200;
  background: var(--surface);
  border-top: 1px solid var(--border);
  box-shadow: 0 -2px 8px rgba(0,0,0,0.06);
  padding-bottom: env(safe-area-inset-bottom);   /* iOS notch */
}
.mobile-tabbar-inner {
  display: grid; grid-template-columns: repeat(4, 1fr);
}
.mobile-tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px;
  padding: 10px 4px 8px;
  color: var(--text-soft); text-decoration: none;
  font-size: 0.72rem; font-weight: 600;
  min-height: 56px;     /* > 44 to allow vertical icon+label */
}
.mobile-tab:hover { text-decoration: none; }
.mobile-tab-ico { font-size: 1.4rem; line-height: 1; }
.mobile-tab.is-active { color: var(--green-dark); }
.mobile-tab.is-active .mobile-tab-ico { transform: scale(1.05); }

@media (max-width: 640px) {
  .mobile-tabbar { display: block; }
  /* hide footer on small screens since the tab bar already grounds the page */
  .footer { display: none; }
}

/* Very small phones (≤ 360 px — old Androids, iPhone SE 1st gen) ────────── */
@media (max-width: 360px) {
  .hero-cands-strip { grid-template-columns: 1fr; }
  .hero-cand-photo .avatar {
    width: 80px !important; height: 80px !important; line-height: 80px !important;
  }
  .topbar-actions .btn-ghost { display: none; }   /* keep only "Criar conta" */
  .container { padding: 0 12px; }
}
