/* Material Design 3 tokens (light + dark) */
:root {
  --md3-primary: #4BA3C3;
  --md3-on-primary: #FFFFFF;
  --md3-primary-container: #CFEAF4;
  --md3-on-primary-container: #072F3B;
  --md3-surface: #FAFCFF;
  --md3-surface-container: #F2F6FA;
  --md3-surface-variant: #E6EFF5;
  --md3-on-surface: #0F172A;
  --md3-outline: #C7D0D9;
  --md3-hover: #2563EB;
  --md3-shadow: 0 1px 2px rgba(0,0,0,.06), 0 2px 8px rgba(0,0,0,.06);
}
@media (prefers-color-scheme: dark) {
  :root {
    --md3-primary: #7FD0E7;
    --md3-on-primary: #003242;
    --md3-primary-container: #1A3B47;
    --md3-on-primary-container: #BFE7F3;
    --md3-surface: #0B1220;
    --md3-surface-container: #101827;
    --md3-surface-variant: #1A2535;
    --md3-on-surface: #E2E8F0;
    --md3-outline: #324155;
    --md3-hover: #3b82f6;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: system-ui, -apple-system, Segoe UI, Roboto, Inter, Poppins, Arial, sans-serif; color: var(--md3-on-surface); background: var(--md3-surface); line-height: 1.5; }

.container { max-width: 1080px; margin: 0 auto; padding: 0 16px; }
.section { padding: 32px 0; }
.muted { background: var(--md3-surface-container); }
.muted-text { color: color-mix(in oklab, var(--md3-on-surface) 70%, transparent); }
.center { display: flex; align-items: center; justify-content: center; }
.right { text-align: right; }
.shadow { box-shadow: 0 6px 18px rgba(0, 0, 0, .07); }
.rounded { border-radius: 12px; }
.card { background: var(--md3-surface); padding: 16px; border-radius: 16px; box-shadow: var(--md3-shadow); border: 1px solid var(--md3-outline); }

/* Header & Nav */
.site-header { position: sticky; top: 0; background: var(--md3-surface); box-shadow: var(--md3-shadow); z-index: 20; backdrop-filter: saturate(180%) blur(6px); }
.nav { display: flex; align-items: center; gap: 12px; height: 56px; }
.brand { font-weight: 700; color: var(--md3-primary); text-decoration: none; white-space: nowrap; font-size: 18px; }
.nav-menu { display: flex; gap: 8px; align-items: center; margin-left: auto; }
.nav-menu a { text-decoration: none; color: var(--md3-on-surface); padding: 6px 8px; border-radius: 8px; }
.nav-menu a:hover { background: var(--md3-surface-variant); }
.nav-toggle { margin-left: auto; font-size: 22px; background: transparent; border: none; padding: 8px; cursor: pointer; }
@media (min-width: 768px) { .nav-toggle { display: none; } }

/* Subnav (mobile) */
.subnav { position: sticky; top: 56px; z-index: 19; display: flex; gap: 8px; padding: 8px 16px; overflow-x: auto; background: var(--md3-surface); border-bottom: 1px solid var(--md3-outline); }
.subnav a { flex: 0 0 auto; padding: 8px 12px; border-radius: 20px; background: var(--md3-surface-variant); color: var(--md3-on-surface); text-decoration: none; }
.subnav .chip-primary { background: var(--md3-primary); color: var(--md3-on-primary); }
@media (min-width: 768px) { .subnav { display: none; } }

.button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid transparent; background: color-mix(in oklab, var(--md3-primary) 16%, var(--md3-surface)); color: var(--md3-on-surface); padding: 10px 16px; border-radius: 20px; cursor: pointer; text-decoration: none; box-shadow: 0 1px 2px rgba(0,0,0,.04); position: relative; overflow: hidden; }
.button:hover { background: color-mix(in oklab, var(--md3-primary) 22%, var(--md3-surface)); }
.button:focus { outline: 3px solid color-mix(in oklab, var(--md3-primary) 35%, transparent); outline-offset: 2px; }
.button-primary { background: var(--md3-primary); color: var(--md3-on-primary); border-color: transparent; }
.button-primary:hover { background: var(--md3-hover); }
.button-xl { font-size: 1.25rem; padding: 16px 22px; }
.small { padding: 6px 10px; font-size: .875rem; }
.danger { background: #ef4444; color: #fff; border-color: #ef4444; }

/* Ripple layer */
.button::after, .tab::after, .option::after { content: ''; position: absolute; inset: 0; background: currentColor; opacity: 0; transition: opacity .2s; border-radius: inherit; mix-blend-mode: multiply; }
.button:active::after, .tab:active::after, .option:active::after { opacity: .06; }

/* Hero & Carousel */
.hero { background: linear-gradient(180deg, var(--md3-surface-container), rgba(255,255,255,0)); padding-bottom: 16px; }
.hero-cta { text-align: center; margin-top: 6px; }
.hero-cta h1 { margin-bottom: 8px; }
.hero-actions { display: flex; gap: 10px; justify-content: center; }
.carousel { position: relative; overflow: hidden; max-width: 100%; background: #000; }
.carousel-track { display: flex; transition: transform .4s ease; }
.carousel-slide { min-width: 100%; }
.carousel-slide img { display: block; width: 100%; height: 560px; object-fit: cover; }
@media (min-width: 768px) { .carousel-slide img { height: 520px; } }
.carousel-prev,.carousel-next { position: absolute; top: 50%; transform: translateY(-50%); background: rgba(0,0,0,.4); color: #fff; border: none; width: 36px; height: 36px; border-radius: 50%; cursor: pointer; }
.carousel-prev { left: 8px; }
.carousel-next { right: 8px; }
.carousel-dots { position: absolute; bottom: 10px; left: 0; right: 0; display: flex; gap: 6px; justify-content: center; }
.carousel-dots button { width: 8px; height: 8px; border-radius: 50%; border: none; background: rgba(255,255,255,.6); cursor: pointer; }
.carousel-dots button.active { background: var(--md3-primary); }

/* Grids */
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: 1fr; }
.grid-3 { grid-template-columns: 1fr; }
.grid-4 { grid-template-columns: 1fr; }
@media (min-width: 768px) { .grid-2 { grid-template-columns: 1fr 1fr; } .grid-3 { grid-template-columns: repeat(3,1fr); } .grid-4 { grid-template-columns: repeat(4,1fr); } }

/* Lists */
.bullets { padding-left: 18px; }
.bullets li { margin: 6px 0; }
.list-plain { list-style: none; padding: 0; margin: 0; }

/* Footer */
.site-footer { background: var(--md3-surface); padding: 16px 0; border-top: 1px solid var(--md3-outline); margin-top: 24px; }
.copyright { padding-top: 10px; font-size: .9rem; color: color-mix(in oklab, var(--md3-on-surface) 70%, transparent); }

/* Form */
label { display: block; margin: 8px 0 6px; font-weight: 600; }
input, textarea, select { width: 100%; padding: 12px 12px; border: 1px solid var(--md3-outline); border-radius: 12px; background: var(--md3-surface); color: var(--md3-on-surface); transition: border-color .15s, box-shadow .15s; }
input::placeholder, textarea::placeholder { color: color-mix(in oklab, var(--md3-on-surface) 50%, transparent); }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--md3-primary); box-shadow: 0 0 0 3px color-mix(in oklab, var(--md3-primary) 25%, transparent); }
.error-text { color: #b91c1c; }

/* Table */
.table-responsive { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px; border-bottom: 1px solid #e5e7eb; text-align: left; vertical-align: top; }
thead th { position: sticky; top: 0; background: var(--md3-surface-container); z-index: 1; }
table.simple th, table.simple td { border-bottom: 1px solid #e5e7eb; }

/* Modals */
.modal { position: fixed; inset: 0; display: none; align-items: center; justify-content: center; background: color-mix(in oklab, black 40%, transparent); padding: 10px; z-index: 50; }
.modal.open { display: flex; }
.modal-content { width: 100%; max-width: 680px; background: var(--md3-surface); border-radius: 28px; padding: 16px; box-shadow: 0 40px 80px rgba(0,0,0,.25); max-height: 90vh; overflow: auto; border: 1px solid var(--md3-outline); }
.modal-close { float: right; border: none; background: transparent; font-size: 24px; cursor: pointer; }

.muted-box { background: var(--md3-surface-variant); padding: 10px; border-radius: 16px; border: 1px solid var(--md3-outline); }
#padronFrame { width: 100%; height: 300px; border: 0; display: block; }
.fallback { padding: 8px; background: var(--md3-surface); border: 1px dashed var(--md3-outline); border-radius: 12px; }

.radio-list label { display: block; padding: 8px; border: 1px solid var(--md3-outline); border-radius: 16px; margin-bottom: 8px; cursor: pointer; position: relative; overflow: hidden; }
.radio-list input[type="radio"] { margin-right: 8px; }

/* Candidate options with escudo */
.radio-list .option { display: flex; align-items: center; gap: 10px; padding: 10px; }
.radio-list .option .escudo { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; }
.radio-list .option .option-text { line-height: 1.2; }

/* Tabs */
.tabs { display: flex; gap: 8px; margin-bottom: 10px; }
.tab { border: 1px solid var(--md3-outline); background: var(--md3-surface); padding: 8px 12px; border-radius: 999px; cursor: pointer; position: relative; overflow: hidden; }
.tab.active { background: var(--md3-primary); color: var(--md3-on-primary); border-color: var(--md3-primary); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* Toast */
.toast { position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); background: var(--md3-primary); color: var(--md3-on-primary); padding: 10px 14px; border-radius: 999px; box-shadow: 0 10px 30px rgba(0,0,0,.2); opacity: 0; pointer-events: none; transition: opacity .2s ease, transform .2s ease; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(-4px); }

/* Key-Value preview grid */
.kv { display: grid; grid-template-columns: 1fr 2fr; gap: 6px 12px; }
.kv .k { font-weight: 600; }
.kv .v { word-break: break-word; }

/* Records cards layout */
.cards { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .cards { grid-template-columns: repeat(2, minmax(0,1fr)); } }
@media (min-width: 1024px) { .cards { grid-template-columns: repeat(3, minmax(0,1fr)); } }
@media (min-width: 1280px) { .cards { grid-template-columns: repeat(4, minmax(0,1fr)); } }
.record-card { display: grid; gap: 6px; }
.record-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.record-title { font-weight: 700; }
.record-sub { color: color-mix(in oklab, var(--md3-on-surface) 65%, transparent); font-size: .9rem; }
.record-body .row { display: grid; grid-template-columns: 90px 1fr; gap: 8px; }
.record-body .k { color: color-mix(in oklab, var(--md3-on-surface) 75%, transparent); font-weight: 600; }
.record-body .v { word-break: break-word; }
.record-foot { color: color-mix(in oklab, var(--md3-on-surface) 60%, transparent); font-size: .85rem; text-align: right; }

/* Media card (radio) */
.media-card .thumb { position: relative; border-radius: 16px; overflow: hidden; aspect-ratio: 16/9; background: var(--md3-surface-variant); display: grid; place-items: center; }
.media-card .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.media-card .play-badge { position: absolute; left: 12px; bottom: 12px; background: var(--md3-primary); color: var(--md3-on-primary); padding: 8px 12px; border-radius: 999px; box-shadow: var(--md3-shadow); font-weight: 600; }
