:root {
    color-scheme: dark;
    --site-header-height: 84px;
    --ink-950: #111111;
    --ink-900: #1e1e1e;
    --ink-700: #3c3b37;
    --stone-500: #888780;
    --stone-300: #b4b2a9;
    --brand-500: #97c459;
    --brand-600: #6fa832;
    --bg: #141414;
    --surface: rgba(34, 34, 34, 0.86);
    --surface-strong: rgba(28, 28, 28, 0.96);
    --border: rgba(180, 178, 169, 0.28);
    --text: #ece9df;
    --muted: #b7b3a8;
    --accent: var(--brand-500);
    --accent-strong: var(--brand-600);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: "Avenir Next", "Segoe UI", sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at top right, rgba(151, 196, 89, 0.16), transparent 36%),
        radial-gradient(circle at 10% 82%, rgba(180, 178, 169, 0.12), transparent 28%),
        linear-gradient(180deg, #1a1a1a 0%, var(--bg) 100%);
}

/* =========================================================================
   App shell: shared header / main / footer layout for every page.
   Header and footer are fixed rows; the central area (.app-body) is the only
   thing that scrolls, so the footer nav pill sits at the exact same spot on
   every screen.
   ========================================================================= */

body.app-shell {
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
}

.app-body {
    min-height: 0;
    overflow: auto;
    display: flex;
    flex-direction: column;
}

.app-body > main {
    flex: 1 1 auto;
    min-height: 0;
}

.app-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 5.5rem;
}

/* Pages without a nav pill (landing, admin) leave the footer empty. */
.app-footer:empty {
    display: none;
}

/* Home page: solid dark background, no gradient. */
body.home-page {
    background: var(--bg);
}

.site-header {
    position: sticky;
    top: 0;
    z-index: 20;
    border-bottom: 1px solid rgba(180, 178, 169, 0.22);
    background: rgba(20, 20, 20, 0.82);
    backdrop-filter: blur(8px);
}

.site-header__inner {
    width: min(1320px, calc(100vw - 2rem));
    margin: 0 auto;
    min-height: calc(var(--site-header-height) - 20px);
    padding-top: 10px;
    padding-bottom: 10px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
}

.site-nav {
    display: flex;
    gap: 0.9rem;
}

.site-nav a {
    color: var(--muted);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.94rem;
}

.site-nav a:hover {
    color: var(--brand-500);
}

.page-shell {
    width: min(1080px, calc(100vw - 2rem));
    margin: 0 auto;
    padding: 4rem 0 5rem;
}

.hero {
    padding: 2rem;
}

.hero.compact {
    padding-bottom: 1rem;
}

.eyebrow {
    margin: 0 0 0.75rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--stone-300);
    font-size: 0.78rem;
}

h1 {
    margin: 0;
    font-size: clamp(2.5rem, 6.5vw, 5rem);
    line-height: 0.98;
}

.lede {
    max-width: 42rem;
    font-size: 1.1rem;
    line-height: 1.6;
    color: var(--muted);
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-top: 0.75rem;
    padding: 0.62rem 1rem;
    border-radius: 0.65rem;
    border: 1px solid rgba(111, 168, 50, 0.45);
    background: linear-gradient(180deg, var(--brand-500) 0%, var(--brand-600) 100%);
    color: #14200d;
    text-decoration: none;
    font-weight: 700;
}

.category-actions {
    display: flex;
    gap: 0.6rem;
}

.category-actions .button {
    margin-top: 0;
    min-width: 180px;
}

.hidden {
    display: none;
}

.danger-button {
    border-color: rgba(209, 92, 89, 0.55);
    background: rgba(178, 62, 58, 0.16);
    color: #f3d8d8;
}

.danger-button:hover {
    background: rgba(178, 62, 58, 0.26);
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    padding: 0 2rem;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 1.25rem;
    padding: 1.25rem;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
}

.card h2 {
    margin-top: 0;
}

.card p,
.card li {
    color: var(--muted);
    line-height: 1.6;
}

.admin-shell {
    width: min(1320px, calc(100vw - 2rem));
}

.admin-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
    padding: 0 2rem;
}

.admin-card {
    background: var(--surface-strong);
    border: 1px solid var(--border);
    border-radius: 1rem;
    padding: 1rem;
    box-shadow: 0 18px 36px rgba(0, 0, 0, 0.35);
}

.admin-card h2,
.admin-card h3 {
    margin-top: 0;
}

.stacked-form {
    display: grid;
    gap: 0.55rem;
    margin-bottom: 0.9rem;
}

.stacked-form label,
.check {
    display: grid;
    gap: 0.28rem;
    color: var(--stone-300);
    font-size: 0.92rem;
}

input,
select,
textarea,
button {
    font: inherit;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid rgba(180, 178, 169, 0.35);
    background: rgba(17, 17, 17, 0.95);
    color: var(--text);
    border-radius: 0.55rem;
    padding: 0.48rem 0.6rem;
}

input:focus,
select:focus,
textarea:focus {
    outline: 2px solid rgba(151, 196, 89, 0.38);
    border-color: var(--brand-600);
}

button {
    border-radius: 0.55rem;
    border: 1px solid rgba(180, 178, 169, 0.32);
    background: rgba(42, 42, 42, 0.96);
    color: var(--text);
    padding: 0.44rem 0.72rem;
    cursor: pointer;
}

button:hover {
    background: rgba(55, 55, 55, 0.96);
}

.inline-form {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    align-items: center;
    margin-bottom: 0.35rem;
}

.inline-form.wide input[type="text"]:first-child {
    min-width: 260px;
    flex: 1;
}

.danger-inline button {
    border-color: rgba(209, 92, 89, 0.45);
    background: rgba(178, 62, 58, 0.18);
}

.danger-inline button:hover {
    background: rgba(178, 62, 58, 0.28);
}

.table-wrap {
    overflow-x: auto;
}

.category-tree {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 0.45rem;
}

.category-tree li {
    display: block;
    padding-left: calc(var(--depth) * 1.1rem);
}

.category-tree li.is-collapsed>ul {
    display: none;
}

.tree-item {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    width: 100%;
    padding: 0.35rem 0.4rem;
    border-radius: 0.4rem;
    border: none;
    background: transparent;
    cursor: pointer;
    transition: color 120ms ease, background-color 120ms ease;
}

.tree-item:hover {
    color: #f5f2e7;
    background: rgba(255, 255, 255, 0.04);
}

.tree-item:focus-visible {
    outline: none;
    color: #f5f2e7;
    background: rgba(255, 255, 255, 0.04);
}

.tree-item.is-selected {
    color: #d9efb6;
    background: rgba(111, 168, 50, 0.16);
}

.tree-item__label {
    color: inherit;
    font-size: 0.95rem;
    font-weight: 600;
}

.tree-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 1.4rem;
    width: 1.4rem;
    height: 1.4rem;
    padding: 0;
    border: none;
    background: transparent;
    cursor: pointer;
    color: inherit;
    transition: transform 120ms ease;
    flex-shrink: 0;
}

.tree-toggle.is-hidden {
    visibility: hidden;
}

.tree-toggle[aria-expanded="false"] {
    transform: rotate(-90deg);
}

.tree-toggle__icon {
    display: block;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    border-top: 1px solid rgba(180, 178, 169, 0.24);
    padding: 0.45rem 0.2rem;
    text-align: left;
    vertical-align: top;
}

th {
    color: var(--stone-300);
    font-size: 0.86rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.muted {
    color: var(--stone-500);
    display: block;
    margin-bottom: 0.35rem;
}

@media (max-width: 700px) {
    .page-shell {
        padding-top: 2rem;
    }

    .hero,
    .card-grid,
    .admin-grid,
    .admin-tabs,
    .admin-panel,
    .admin-two-pane {
        padding-left: 1rem;
        padding-right: 1rem;
    }
}

/* =========================================================================
   Admin: tabs + two-pane (Temas / Localidades)
   ========================================================================= */

.admin-tabs {
    display: flex;
    gap: 0.4rem;
    padding: 0 2rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.admin-tab {
    border: none;
    border-bottom: 2px solid transparent;
    border-radius: 0.5rem 0.5rem 0 0;
    background: transparent;
    color: var(--stone-300);
    font-weight: 600;
    padding: 0.55rem 0.9rem;
}

.admin-tab:hover {
    background: rgba(255, 255, 255, 0.04);
    color: var(--text);
}

.admin-tab.is-active {
    color: var(--text);
    border-bottom-color: var(--brand-500);
    background: rgba(111, 168, 50, 0.1);
}

.admin-panel {
    padding: 0 2rem;
}

.admin-two-pane {
    display: grid;
    grid-template-columns: minmax(260px, 340px) 1fr;
    gap: 1rem;
    align-items: start;
}

.tp-left,
.tp-right {
    background: var(--surface-strong);
    border: 1px solid var(--border);
    border-radius: 1rem;
    padding: 1rem;
    box-shadow: 0 18px 36px rgba(0, 0, 0, 0.35);
}

.tp-left__head,
.tp-right__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem;
    margin-bottom: 0.7rem;
}

.tp-left__head h2,
.tp-right__head h2 {
    margin: 0;
    font-size: 1.15rem;
}

.theme-editor {
    margin-top: 0.9rem;
    padding-top: 0.9rem;
    border-top: 1px solid var(--border);
}

.theme-editor h3 {
    margin: 0 0 0.6rem;
    font-size: 0.98rem;
}

.tp-empty {
    color: var(--stone-500);
    padding: 1.4rem 0.4rem;
    text-align: center;
}

/* ---- Question cards ---- */

.question-create {
    border: 1px solid var(--border);
    border-radius: 0.8rem;
    padding: 0.9rem;
    margin-bottom: 1rem;
    background: rgba(255, 255, 255, 0.02);
    display: grid;
    gap: 0.55rem;
}

.question-create h3 {
    margin: 0;
    font-size: 0.98rem;
}

.question-list {
    display: grid;
    gap: 0.8rem;
}

.question-card {
    border: 1px solid var(--border);
    border-radius: 0.8rem;
    padding: 0.8rem 0.9rem;
    background: rgba(255, 255, 255, 0.02);
}

.qc-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.6rem;
}

.qc-prompt {
    margin: 0;
    font-weight: 600;
    line-height: 1.4;
}

.qc-actions {
    display: flex;
    gap: 0.3rem;
    flex-shrink: 0;
}

.qc-actions form {
    display: inline-flex;
}

.qc-badge {
    display: inline-block;
    margin-left: 0.4rem;
    padding: 0.05rem 0.4rem;
    border-radius: 0.4rem;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #e6c07a;
    background: rgba(230, 192, 122, 0.14);
    vertical-align: middle;
}

.alt-list {
    list-style: none;
    margin: 0.6rem 0 0;
    padding: 0;
    display: grid;
    gap: 0.3rem;
}

.alt-list li {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--muted);
    font-size: 0.92rem;
}

.alt-pos {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.5rem;
    height: 1.5rem;
    padding: 0 0.35rem;
    border-radius: 0.4rem;
    background: rgba(111, 168, 50, 0.16);
    color: #d9efb6;
    font-size: 0.8rem;
    font-weight: 700;
    flex-shrink: 0;
}

.alt-label {
    color: var(--text);
}

.alt-empty {
    color: var(--stone-500);
    font-style: italic;
}

.alt-hint {
    margin: 0 0 0.5rem;
    font-size: 0.82rem;
    color: var(--stone-500);
    line-height: 1.45;
}

/* ---- Small icon buttons ---- */

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.9rem;
    height: 1.9rem;
    padding: 0;
    border-radius: 0.45rem;
    line-height: 1;
    flex-shrink: 0;
}

.icon-btn.danger {
    border-color: rgba(209, 92, 89, 0.45);
    background: rgba(178, 62, 58, 0.16);
    color: #e79b98;
}

.icon-btn.danger:hover {
    background: rgba(178, 62, 58, 0.3);
}

/* ---- In-place question editor ---- */

.qc-edit {
    margin-top: 0.6rem;
    padding-top: 0.8rem;
    border-top: 1px dashed var(--border);
    display: grid;
    gap: 0.7rem;
}

.qc-edit h4 {
    margin: 0;
    font-size: 0.9rem;
    color: var(--stone-300);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.qc-edit-form {
    display: grid;
    gap: 0.5rem;
}

.qc-edit-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.7rem;
}

.qc-edit-row label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--stone-300);
    font-size: 0.9rem;
}

.qc-edit-row input[type="number"] {
    width: 5rem;
}

.alt-edit-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 0.4rem;
}

.alt-edit {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.alt-edit-form,
.alt-add-form {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem;
    flex: 1;
}

.alt-edit-form input,
.alt-add-form input {
    width: auto;
}

.alt-edit-form input[name="label"],
.alt-add-form input[name="label"] {
    flex: 1 1 160px;
    min-width: 130px;
}

.alt-edit-form input.num,
.alt-add-form input.num {
    width: 4.5rem;
    flex: 0 0 auto;
}

.alt-edit-form input[type="checkbox"],
.alt-add-form input[type="checkbox"],
.qc-edit-row input[type="checkbox"] {
    width: auto;
}

.alt-add-form {
    padding-top: 0.4rem;
    border-top: 1px solid var(--border);
}

.qc-edit-foot {
    display: flex;
    justify-content: flex-end;
}

.button.ghost {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
}

.button.ghost:hover {
    background: rgba(255, 255, 255, 0.05);
}

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

/* =========================================================================
   Guided voter-flow footer (Local / Temas)
   ========================================================================= */

.flow-footer {
    /* The navigation pill. A fixed-size box centered by .app-footer, so it has
       the same size and position on every page — only the label text changes. */
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    /* Fixed width => the box is identical regardless of label length. */
    width: 22rem;
    max-width: calc(100vw - 2rem);
    height: 3.4rem;
    padding: 0 1.1rem;
    border: 1px solid var(--border);
    border-radius: 0.9rem;
    background: rgba(20, 20, 20, 0.6);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
}

.flow-footer__label {
    /* Fixed width keeps the two chevrons at the same spacing regardless of the
       label text, so their size and position don't shift between screens. */
    width: 11rem;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: var(--text);
}

.flow-footer__chevron {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: rgba(42, 42, 42, 0.9);
    color: var(--text);
    text-decoration: none;
    transition: background-color 120ms ease;
}

.flow-footer__chevron:hover {
    background: rgba(55, 55, 55, 0.95);
}

.flow-footer__chevron.is-disabled {
    opacity: 0.28;
    pointer-events: none;
}
