:root {
    --bg: #0a0d17;
    --bg-soft: #10142280;
    --card-bg: rgba(255, 255, 255, 0.045);
    --card-border: rgba(255, 255, 255, 0.09);
    --text: #f2f3fa;
    --text-dim: #9aa0b8;
    --color-a: #ffd400;
    --color-a-dark: #cfae00;
    --color-b: #ff2f92;
    --color-b-dark: #cc1f73;
    --accent-blue: #4f8cff;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
    background:
        radial-gradient(circle at 15% 0%, rgba(79, 140, 255, 0.16), transparent 45%),
        radial-gradient(circle at 85% 15%, rgba(255, 47, 146, 0.14), transparent 45%),
        var(--bg);
    color: var(--text);
    min-height: 100vh;
}

.topbar {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 16px 20px;
}
.topbar-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
@media (min-width: 860px) {
    .topbar {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        padding: 18px 32px;
    }
    .topbar-top {
        justify-content: flex-start;
        gap: 24px;
    }
    .main-nav {
        flex: 1;
        justify-content: center;
    }
}

.topbar .brand {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
    text-decoration: none;
    font-weight: 800;
    letter-spacing: 0.02em;
    font-size: 1.15rem;
    color: var(--text);
}

.brand-accent {
    background: linear-gradient(90deg, var(--accent-blue), var(--color-b));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.admin-link {
    color: var(--text-dim);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    border: 1px solid var(--card-border);
    padding: 6px 14px;
    border-radius: 999px;
}
.admin-link:hover {
    color: var(--text);
    border-color: var(--text-dim);
}

main {
    max-width: 1200px;
    margin: 12px auto 48px;
    padding: 0 20px;
}

.dashboard {
    display: grid;
    grid-template-columns: 400px 1fr;
    gap: 24px;
    align-items: start;
}

@media (max-width: 900px) {
    .dashboard { grid-template-columns: 1fr; }
}

.card,
.vote-card,
.results-panel {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    padding: 28px;
    backdrop-filter: blur(12px);
}

.card.narrow {
    max-width: 420px;
    margin: 24px auto;
}

.today-date {
    color: var(--text-dim);
    font-size: 0.85rem;
    margin: 0 0 10px;
}

.badge {
    display: inline-block;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--card-border);
    color: var(--text-dim);
    font-size: 0.78rem;
    font-weight: 600;
    padding: 4px 12px;
    border-radius: 999px;
    margin-bottom: 16px;
}

.question-heading {
    font-size: 1.8rem;
    font-weight: 800;
    line-height: 1.2;
    margin: 0 0 20px;
}
.option-a-text { color: var(--color-a); }
.option-b-text { color: var(--color-b); }
.vs-text { color: var(--text); opacity: 0.6; font-weight: 500; }

.question-image {
    width: 100%;
    border-radius: 12px;
    margin-bottom: 20px;
    display: block;
    object-fit: cover;
    max-height: 260px;
}

form label {
    display: block;
    margin-top: 16px;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-dim);
    font-size: 0.9rem;
}
form input[type="text"],
form input[type="password"],
form select {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--card-border);
    border-radius: 10px;
    font-size: 1rem;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text);
}
form input[type="file"] {
    width: 100%;
    color: var(--text-dim);
}
form select:invalid { color: var(--text-dim); }
form select option { color: #1a1a1a; }

.choices {
    display: flex;
    gap: 14px;
    margin-top: 4px;
}
.choice-btn {
    flex: 1;
    padding: 16px;
    font-size: 1rem;
    font-weight: 700;
    border: 2px solid var(--color-a);
    background: transparent;
    color: var(--color-a);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.15s ease;
}
.choice-btn.choice-b {
    border-color: var(--color-b);
    color: var(--color-b);
}
.choice-btn.choice-a.selected {
    background: var(--color-a);
    color: #1a1400;
}
.choice-btn.choice-b.selected {
    background: var(--color-b);
    color: #2a0016;
}

.cta-button,
.button {
    display: inline-block;
    width: 100%;
    margin-top: 22px;
    padding: 15px 20px;
    background: linear-gradient(90deg, var(--accent-blue), var(--color-b));
    color: white;
    border: none;
    border-radius: 999px;
    font-size: 1.05rem;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
}
.cta-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.fine-print {
    text-align: center;
    color: var(--text-dim);
    font-size: 0.8rem;
    margin-top: 12px;
}

.error {
    color: #ff6b6b;
    font-weight: 500;
    margin-top: 12px;
}
.success {
    color: #4ade80;
    font-weight: 500;
}
.hidden { display: none; }

.voted-state {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--card-border);
    border-radius: 10px;
    padding: 18px;
    color: var(--text-dim);
}

.empty-state h1 {
    font-size: 1.4rem;
    margin-bottom: 10px;
}
.empty-state p {
    color: var(--text-dim);
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 14px;
}
.results-header h2 {
    margin: 0;
    font-size: 1.4rem;
}
.total-votes {
    color: var(--text-dim);
    font-size: 0.9rem;
    margin: 0;
}

.totals-bar {
    display: flex;
    height: 36px;
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 18px;
    font-size: 0.85rem;
    font-weight: 700;
}
.totals-bar .side-a,
.totals-bar .side-b {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    padding: 0 6px;
}
.totals-bar .side-a {
    background: var(--color-a);
    color: #1a1400;
}
.totals-bar .side-b {
    background: var(--color-b);
    color: #2a0016;
}

.map-view-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}
.map-view-row label {
    color: var(--text-dim);
    font-size: 0.85rem;
}
#legend-none {
    display: none;
    align-items: center;
}
#legend-none.visible {
    display: inline-flex;
}
.dot-none {
    background: #2a2e42;
    border: 1px solid var(--card-border);
}

#map {
    height: 480px;
    width: 100%;
    border-radius: 12px;
    border: 1px solid var(--card-border);
    background: #0a0d17;
    position: relative;
}
.spain-map-inset {
    position: absolute;
    right: 10px;
    bottom: 10px;
    width: 110px;
    height: 80px;
    border: 1px solid var(--card-border);
    border-radius: 6px;
    z-index: 500;
}
.spain-map-inset.leaflet-container {
    background: #0a0d17 !important;
}
#map .leaflet-tile-pane {
    filter: invert(1) hue-rotate(180deg) brightness(0.7) contrast(0.9) saturate(0.6);
}
#map .leaflet-control-attribution {
    background: rgba(10, 13, 23, 0.7);
    color: var(--text-dim);
}
#map .leaflet-control-attribution a {
    color: var(--text-dim);
}
#map .leaflet-control-zoom a {
    background: rgba(20, 22, 34, 0.9);
    color: var(--text);
    border-color: var(--card-border) !important;
}

.legend {
    display: flex;
    gap: 20px;
    margin-top: 14px;
    color: var(--text-dim);
    font-size: 0.85rem;
}
.dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 6px;
}
.dot-a { background: var(--color-a); }
.dot-b { background: var(--color-b); }

.city-results-title {
    margin: 24px 0 12px;
    font-size: 1.05rem;
    color: var(--text);
}
.city-results-grid {
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.ca-group {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--card-border);
    border-radius: 10px;
    overflow: hidden;
    scroll-margin-top: 20px;
    transition: border-color 0.3s ease, background 0.3s ease;
}
.ca-group.highlighted {
    border-color: var(--color-b);
    background: rgba(255, 47, 146, 0.08);
}
.ca-group-header {
    position: relative;
    height: 70px;
    cursor: pointer;
    list-style: none;
}
.ca-group-header::-webkit-details-marker {
    display: none;
}
.ca-group-header::after {
    content: "\25BE";
    position: absolute;
    right: 12px;
    bottom: 8px;
    color: white;
    font-size: 1rem;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.85);
    transition: transform 0.2s ease;
}
.ca-group[open] .ca-group-header::after {
    transform: rotate(180deg);
}
.ca-group-header img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.ca-group-header span {
    position: absolute;
    left: 12px;
    bottom: 8px;
    color: white;
    font-weight: 700;
    font-size: 0.95rem;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: baseline;
    gap: 8px;
}
.ca-group-bar {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 5px;
    display: flex;
}
.ca-group-bar .part-a { background: var(--color-a); }
.ca-group-bar .part-b { background: var(--color-b); }
.ca-group-header span em {
    font-style: normal;
    font-weight: 500;
    font-size: 0.75rem;
    opacity: 0.85;
}
.ca-group-cities {
    padding: 10px 16px 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.city-row .city-name {
    font-weight: 600;
    font-size: 0.85rem;
    margin-bottom: 6px;
}
.city-row .split-bar { height: 6px; }
.split-bar {
    display: flex;
    height: 8px;
    border-radius: 999px;
    overflow: hidden;
    margin-bottom: 6px;
}
.split-bar .part-a { background: var(--color-a); }
.split-bar .part-b { background: var(--color-b); }
.split-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-dim);
}

.admin-preview {
    max-width: 100%;
    border-radius: 10px;
    margin: 12px 0;
    max-height: 200px;
    object-fit: cover;
}

.main-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 22px;
    justify-content: center;
}
.main-nav a {
    color: var(--text-dim);
    text-decoration: none;
    font-size: 0.92rem;
    font-weight: 600;
    padding-bottom: 4px;
    border-bottom: 2px solid transparent;
}
.main-nav a:hover {
    color: var(--text);
}
.main-nav a.active {
    color: var(--text);
    border-bottom-color: var(--color-b);
}

.results-header {
    flex-wrap: wrap;
    gap: 14px;
}
.results-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}
#city-search {
    padding: 10px 14px;
    border-radius: 999px;
    border: 1px solid var(--card-border);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text);
    font-size: 0.9rem;
    min-width: 180px;
}
.share-button {
    padding: 10px 18px;
    border-radius: 999px;
    border: none;
    background: linear-gradient(90deg, var(--accent-blue), var(--color-b));
    color: white;
    font-weight: 700;
    font-size: 0.85rem;
    cursor: pointer;
    white-space: nowrap;
}

.results-panel-full {
    max-width: 100%;
}
.date-select {
    padding: 10px 14px;
    border-radius: 999px;
    border: 1px solid var(--card-border);
    background: rgba(255, 255, 255, 0.06);
    color: var(--text);
    font-size: 0.9rem;
}
.date-select option { color: #1a1a1a; }

.badge-inline {
    margin-left: 10px;
    padding: 2px 10px;
    font-size: 0.7rem;
}

.carousel-section {
    margin-top: 28px;
}
.carousel {
    display: flex;
    gap: 14px;
    overflow-x: auto;
    padding-bottom: 8px;
}
.carousel-card {
    flex: 0 0 220px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 16px;
    text-decoration: none;
    color: var(--text);
}
.carousel-card:hover {
    border-color: var(--text-dim);
}
.carousel-date {
    color: var(--text-dim);
    font-size: 0.75rem;
    margin: 0 0 6px;
}
.carousel-question {
    font-weight: 700;
    font-size: 0.95rem;
    margin: 0 0 12px;
}

.historico-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-top: 20px;
}
.historico-row {
    display: grid;
    grid-template-columns: 1fr 200px auto;
    gap: 18px;
    align-items: center;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 16px 20px;
}
@media (max-width: 700px) {
    .historico-row {
        grid-template-columns: 1fr;
        text-align: left;
    }
}
.historico-date {
    color: var(--text-dim);
    font-size: 0.8rem;
    margin: 0 0 6px;
}
.historico-question {
    font-weight: 700;
    margin: 0;
}
.historico-link {
    width: auto;
    margin: 0;
    padding: 10px 18px;
    font-size: 0.85rem;
}

.ca-map-hint {
    margin: 0 0 12px;
    text-align: left;
}

#map .leaflet-interactive {
    cursor: pointer;
    transition: fill-opacity 0.15s ease;
}
#map .leaflet-tooltip {
    background: rgba(10, 13, 23, 0.92);
    border: 1px solid var(--card-border);
    color: var(--text);
    font-size: 0.8rem;
}

.ca-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-top: 24px;
}
.ca-row {
    display: flex;
    gap: 16px;
    align-items: center;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 12px 20px 12px 12px;
    scroll-margin-top: 20px;
    transition: border-color 0.3s ease, background 0.3s ease;
}
.ca-row.highlighted {
    border-color: var(--color-b);
    background: rgba(255, 47, 146, 0.08);
}
.ca-thumb {
    width: 72px;
    height: 56px;
    object-fit: cover;
    border-radius: 8px;
    flex-shrink: 0;
}
.ca-row-body {
    flex: 1;
    min-width: 0;
}
.ca-name {
    font-weight: 700;
    margin-bottom: 10px;
}
.ca-row .split-bar { height: 12px; }

.proposal-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 16px;
}
.proposal-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 14px 18px;
}
.proposal-question {
    font-weight: 600;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.vote-proposal-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 8px 16px;
    border-radius: 12px;
    border: 2px solid var(--accent-blue);
    background: transparent;
    color: var(--text);
    cursor: pointer;
    font-weight: 700;
    min-width: 70px;
}
.vote-proposal-btn .vote-count {
    font-size: 1.1rem;
}
.vote-proposal-btn .vote-label {
    font-size: 0.7rem;
    color: var(--text-dim);
    font-weight: 500;
}
.vote-proposal-btn.voted {
    border-color: var(--color-b);
    background: rgba(255, 47, 146, 0.12);
    cursor: default;
}
.vote-proposal-btn:disabled {
    opacity: 0.8;
}
.proposal-row form {
    margin: 0;
}
.proposal-row .historico-link {
    margin-top: 0;
}
