/* =========================================================
   Eleitorando Dashboard — Visual SaaS Premium
   ========================================================= */
:root{
  --bg: #f5f6fa;
  --surface: #ffffff;
  --surface-2: #fafafa;
  --border: #e6e8ee;
  --border-strong: #d1d5db;
  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #64748b;
  --muted-2: #94a3b8;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --party: #CC0000;        /* sobreescrito por JS */
  --party-light: rgba(204,0,0,.08);
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --eleitorando: #1E40AF;
  --shadow-sm: 0 1px 2px rgba(15,23,42,.04);
  --shadow: 0 4px 12px rgba(15,23,42,.06);
  --shadow-lg: 0 12px 32px rgba(15,23,42,.08);
}

*{ box-sizing: border-box; margin: 0; padding: 0; }
html, body{ height: 100%; }
body{
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  font-size: 14px;
}
button{ font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
a{ color: inherit; text-decoration: none; }

.screen{ display: none; min-height: 100vh; }
.screen.active{ display: block; }

/* ============================================================
   LOGIN
   ============================================================ */
.screen--login{
  display: none;
  background: var(--eleitorando);
  position: relative;
  min-height: 100vh;
  padding: 24px;
}
.screen--login.active{ display: flex; align-items: center; justify-content: center; }

.login-bg{
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 20% 30%, rgba(255,255,255,.06), transparent 40%),
    radial-gradient(circle at 80% 70%, rgba(255,255,255,.04), transparent 40%);
}

.login-card{
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 440px;
  background: #fff;
  border-radius: 16px;
  padding: 36px;
  box-shadow: 0 24px 60px rgba(0,0,0,.25);
}

.login-card__brand{
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}
.login-card__logo{
  height: 32px;
  width: auto;
}
.login-card__tagline{
  font-size: 11px;
  color: var(--muted);
  font-weight: 500;
}

.login-card__title{
  font-size: 22px;
  font-weight: 700;
  text-align: center;
  margin-bottom: 4px;
}
.login-card__subtitle{
  font-size: 13px;
  color: var(--muted);
  text-align: center;
  margin-bottom: 28px;
}

.login-form{
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.form-field{
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.form-field label{
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-2);
  letter-spacing: .2px;
}
.form-field input, .form-field select{
  background: #fff;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 14px;
  font-family: inherit;
  transition: border-color .15s;
}
.form-field input:focus, .form-field select:focus{
  outline: none;
  border-color: var(--primary);
}

.btn-login{
  background: var(--ink);
  color: #fff;
  border-radius: 10px;
  padding: 14px;
  font-weight: 700;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 8px;
  transition: all .15s;
}
.btn-login:hover{ background: #1e293b; }
.btn-login:active{ transform: scale(.98); }

.login-card__demo{
  margin-top: 16px;
  background: #fef3c7;
  border-left: 3px solid #f59e0b;
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 12px;
  color: #78350f;
}

.login-card__footer{
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--muted);
  text-align: center;
  line-height: 1.5;
}

/* ============================================================
   ESCOLHER PARTIDO
   ============================================================ */
.screen--choose-party.active{
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}
.choose-wrap{
  width: 100%;
  max-width: 520px;
  padding: 32px;
}
.choose-header{
  text-align: center;
  margin-bottom: 24px;
}
.choose-logo{
  height: 28px;
  margin-bottom: 16px;
}
.choose-title{
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 4px;
}
.choose-sub{
  font-size: 13px;
  color: var(--muted);
}
.party-list{
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.party-option{
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 20px;
  background: #fff;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: all .15s;
}
.party-option:hover{
  border-color: var(--ink-2);
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}
.party-option__badge{
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 800;
  font-size: 18px;
  flex-shrink: 0;
}
.party-option__info{ flex: 1; }
.party-option__name{
  font-weight: 700;
  font-size: 15px;
}
.party-option__role{
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}
.party-option__arrow{
  color: var(--muted-2);
}
.choose-logout{
  display: block;
  text-align: center;
  margin-top: 24px;
  font-size: 13px;
  color: var(--muted);
  text-decoration: underline;
  cursor: pointer;
}

/* ============================================================
   DASHBOARD LAYOUT
   ============================================================ */
.screen--dashboard{
  display: none;
  min-height: 100vh;
}
.screen--dashboard.active{
  display: grid;
  grid-template-columns: 264px 1fr;
}

/* ============== SIDEBAR ============== */
.sidebar{
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 24px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar__brand{
  padding: 0 8px 20px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.sidebar__logo{
  height: 24px;
  width: auto;
}

.sidebar__party{
  background: var(--party-light);
  border-radius: 10px;
  padding: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
}
.sidebar__party-badge{
  width: 36px;
  height: 36px;
  background: var(--party);
  color: #fff;
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 13px;
  flex-shrink: 0;
}
.sidebar__party-info{ flex: 1; min-width: 0; }
.sidebar__party-name{
  font-size: 12px;
  font-weight: 700;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar__party-meta{
  font-size: 10px;
  color: var(--muted);
  margin-top: 2px;
}

.sidebar__nav{
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.nav-item{
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--ink-2);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all .12s;
}
.nav-item svg{
  width: 18px;
  height: 18px;
  color: var(--muted);
  flex-shrink: 0;
}
.nav-item:hover{
  background: var(--surface-2);
  color: var(--ink);
}
.nav-item:hover svg{ color: var(--ink-2); }
.nav-item.active{
  background: var(--party-light);
  color: var(--party);
  font-weight: 600;
}
.nav-item.active svg{ color: var(--party); }
.nav-item__badge{
  margin-left: auto;
  background: var(--party);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
}

.sidebar__user{
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-top: 1px solid var(--border);
  margin-top: 12px;
  padding-top: 16px;
}
.sidebar__user-avatar{
  width: 36px;
  height: 36px;
  background: var(--ink);
  color: #fff;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}
.sidebar__user-info{ flex: 1; min-width: 0; }
.sidebar__user-name{
  font-size: 13px;
  font-weight: 700;
}
.sidebar__user-email{
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar__user-logout{
  width: 28px;
  height: 28px;
  border-radius: 6px;
  color: var(--muted);
  display: grid;
  place-items: center;
}
.sidebar__user-logout:hover{ background: var(--surface-2); color: var(--danger); }

/* ============== MAIN ============== */
.main{
  padding: 28px 36px;
  overflow-x: auto;
}

.page{ display: none; }
.page.active{ display: block; animation: pageIn .25s ease-out; }
@keyframes pageIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

.page-header{
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.page-header__breadcrumb{
  font-size: 11px;
  font-weight: 600;
  color: var(--party);
  letter-spacing: 1.5px;
  text-transform: uppercase;
  margin-bottom: 4px;
}
.page-header__title{
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -.5px;
}
.page-header__sub{
  font-size: 14px;
  color: var(--muted);
  margin-top: 6px;
}
.page-header__actions{
  display: flex;
  align-items: center;
  gap: 8px;
}

.period-selector{
  display: flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 3px;
}
.period-btn{
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  border-radius: 6px;
}
.period-btn.active{
  background: var(--ink);
  color: #fff;
}

.btn-export, .btn-primary, .btn-secondary{
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  transition: all .15s;
  cursor: pointer;
}
.btn-export{
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--ink-2);
}
.btn-export:hover{ border-color: var(--ink-2); }
.btn-primary{
  background: var(--party);
  color: #fff;
}
.btn-primary:hover{ filter: brightness(1.1); }
.btn-secondary{
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--ink-2);
}

/* ============== METRICS CARDS ============== */
.metrics-grid{
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 24px;
}
@media (max-width: 1024px){ .metrics-grid{ grid-template-columns: repeat(2, 1fr); } }

.metric-card{
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 20px;
  transition: all .15s;
}
.metric-card:hover{ box-shadow: var(--shadow); }
.metric-card--highlight{
  background: linear-gradient(135deg, var(--party), color-mix(in srgb, var(--party) 80%, black));
  color: #fff;
  border: none;
}
.metric-card--highlight .metric-card__label,
.metric-card--highlight .metric-card__delta{
  color: rgba(255,255,255,.85) !important;
}

.metric-card__label{
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 8px;
}
.metric-card__value{
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -.5px;
  line-height: 1;
  margin-bottom: 8px;
}
.metric-card__delta{
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
}
.metric-card__delta--up{ color: var(--success); }

/* ============== CHARTS ============== */
.charts-grid{
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.chart-card{
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  display: flex;
  flex-direction: column;
}
.chart-card--big{ grid-column: 1 / -1; }
.chart-card__head{
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}
.chart-card canvas{
  max-height: 240px !important;
  width: 100% !important;
}
.chart-card--big canvas{ max-height: 280px !important; }
.chart-card__title{
  font-size: 14px;
  font-weight: 700;
}
.chart-card__sub{
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 2px;
}

/* ============== STATE LIST ============== */
.state-list{ display: flex; flex-direction: column; gap: 10px; }
.state-row{
  display: grid;
  grid-template-columns: 60px 1fr 80px;
  gap: 14px;
  align-items: center;
  font-size: 13px;
}
.state-row__uf{
  font-weight: 700;
  font-size: 14px;
}
.state-row__bar{
  background: var(--surface-2);
  border-radius: 999px;
  height: 8px;
  overflow: hidden;
}
.state-row__fill{
  background: var(--party);
  height: 100%;
  border-radius: 999px;
}
.state-row__count{
  text-align: right;
  font-weight: 600;
  color: var(--ink-2);
}

/* ============== TABLES ============== */
.table-card{
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
.table-filters{
  display: flex;
  gap: 10px;
  padding: 16px;
  border-bottom: 1px solid var(--border);
}
.table-search{
  flex: 1;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 14px;
  font-size: 13px;
  font-family: inherit;
}
.table-search:focus{ outline: none; border-color: var(--primary); background: #fff; }
.table-select{
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
}

.data-table{
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table thead{
  background: var(--surface-2);
}
.data-table th{
  text-align: left;
  padding: 12px 16px;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .5px;
  border-bottom: 1px solid var(--border);
}
.data-table td{
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--ink-2);
}
.data-table tr:last-child td{ border-bottom: none; }
.data-table tr:hover td{ background: var(--surface-2); }

.lead-name{
  display: flex;
  align-items: center;
  gap: 10px;
}
.lead-name__avatar{
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--party-light);
  color: var(--party);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 12px;
}
.lead-name__text{ font-weight: 600; color: var(--ink); }

.status-badge{
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}
.status-badge--pendente{ background: #fef3c7; color: #92400e; }
.status-badge--contatado{ background: #dbeafe; color: #1e40af; }
.status-badge--filiado{ background: #d1fae5; color: #065f46; }
.status-badge--descartado{ background: #f1f5f9; color: var(--muted); }

.row-action{
  background: transparent;
  color: var(--primary);
  font-weight: 600;
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 6px;
}
.row-action:hover{ background: var(--party-light); }

/* ============== CAMPAIGNS ============== */
.campaign-grid{
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 24px;
}
.campaign-card{
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  text-align: center;
}
.campaign-card__icon{ font-size: 36px; margin-bottom: 12px; }
.campaign-card__title{
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 6px;
}
.campaign-card__desc{
  font-size: 12.5px;
  color: var(--muted);
  margin-bottom: 16px;
  line-height: 1.4;
}

.empty-state{
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: 12px;
  padding: 56px 24px;
  text-align: center;
}
.empty-state__icon{ font-size: 48px; margin-bottom: 12px; opacity: .5; }
.empty-state__title{
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 4px;
}
.empty-state__sub{
  font-size: 13px;
  color: var(--muted);
}

/* ============== CONFIG ============== */
.config-grid{
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.config-section{
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
}
.config-section__title{
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 14px;
}

.config-plan__badge{
  display: inline-block;
  background: var(--party-light);
  color: var(--party);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  margin-bottom: 8px;
}
.config-plan__price{
  font-size: 32px;
  font-weight: 800;
  margin-bottom: 4px;
}
.config-plan__price span{ font-size: 14px; color: var(--muted); font-weight: 500; }
.config-plan__features{
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 14px;
  font-size: 13px;
  color: var(--ink-2);
}

.team-list{ display: flex; flex-direction: column; gap: 8px; }
.team-member{
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  background: var(--surface-2);
  border-radius: 8px;
}
.team-member__avatar{
  width: 32px;
  height: 32px;
  background: var(--ink);
  color: #fff;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 13px;
}
.team-member__info{ flex: 1; }
.team-member__name{ font-size: 13px; font-weight: 600; }
.team-member__role{ font-size: 11px; color: var(--muted); }

/* ============== TOAST ============== */
.toast{
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--ink);
  color: #fff;
  padding: 12px 18px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  opacity: 0;
  transform: translateY(10px);
  transition: all .25s;
  pointer-events: none;
  z-index: 9999;
  box-shadow: var(--shadow-lg);
}
.toast.show{ opacity: 1; transform: translateY(0); }

/* Responsivo */
@media (max-width: 900px){
  .screen--dashboard.active{ grid-template-columns: 1fr; }
  .sidebar{ display: none; }
  .main{ padding: 20px; }
  .charts-grid{ grid-template-columns: 1fr; }
  .campaign-grid{ grid-template-columns: 1fr; }
  .config-grid{ grid-template-columns: 1fr; }
}
