/* ==========================================================================
   Como Voto - Styles
   ========================================================================== */

:root {
    /* Colors */
    --color-bg: #e9ecef;
    --color-surface: #ffffff;
    --color-text: #1a1a2e;
    --color-text-secondary: #6b7280;
    --color-border: #e5e7eb;
    --color-primary: #3b82f6;
    --color-primary-hover: #2563eb;

    /* Party colors */
    --color-pj: #1e88e5;
    --color-ucr: #ef4444;
    --color-pro: #fdd835;
    --color-lla: #7b1fa2;
    --color-other: #78909c;

    /* Vote colors */
    --color-afirmativo: #22c55e;
    --color-negativo: #ef4444;
    --color-abstencion: #f59e0b;
    --color-ausente: #94a3b8;
    --color-presidente: #8b5cf6;

    /* Layout */
    --max-width: 1200px;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -4px rgba(0,0,0,0.1);
    --transition: 0.2s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 1.5rem;
}

.hidden {
    display: none !important;
}

/* ====== HEADER ====== */
.header {
    background: url('header_mainpage.png') center/cover no-repeat;
    color: white;
    padding: 2rem 0;
    text-align: center;
}

.header-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.logo {
    font-size: 2.75rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.logo-icon {
    font-size: 2.5rem;
}

.subtitle {
    color: #ffffff;
    font-size: 1rem;
    font-weight: 700;
}

/* ====== SEARCH ====== */
.search-section {
    padding: 1.5rem 0 1rem;
}

.search-section.card-outline,
.law-search-section.card-outline {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 2rem 1.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.search-section.card-outline .container,
.law-search-section.card-outline .container {
    background: transparent;
    border: none;
    border-radius: 0;
    padding: 0;
    box-shadow: none;
}

.search-box {
    position: relative;
    max-width: 600px;
    margin: 0 auto 1.5rem;
}

.ranking-section:not(:has(.ranking-card)) .container {
    margin-top: 1rem;
}

.search-label {
    display: block;
    font-weight: 700;
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    text-align: center;
}

.search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    left: 1rem;
    width: 20px;
    height: 20px;
    color: var(--color-text-secondary);
    pointer-events: none;
}

#search-input {
    width: 100%;
    padding: 0.875rem 2.5rem 0.875rem 3rem;
    font-size: 1rem;
    font-family: inherit;
    border: 2px solid var(--color-border);
    border-radius: 50px;
    background: var(--color-surface);
    transition: border-color var(--transition), box-shadow var(--transition);
    outline: none;
}

#search-input:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.clear-btn {
    position: absolute;
    right: 0.75rem;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--color-text-secondary);
    cursor: pointer;
    padding: 0.25rem;
    line-height: 1;
    display: none;
}

#search-input:not(:placeholder-shown) + .clear-btn {
    display: block;
}

.search-results {
    position: absolute;
    top: calc(100%);
    left: 0;
    right: 0;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    max-height: 400px;
    overflow-y: auto;
    z-index: 100;
}

.search-result-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid var(--color-border);
    transition: background var(--transition);
    gap: 0.75rem;
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item:hover {
    background: #f0f7ff;
}

.search-result-name {
    font-weight: 500;
    flex: 1;
}

.search-result-meta {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
}

.search-result-meta .badge {
    font-size: 0.7rem;
}

/* ====== FILTERS ====== */
.filters {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.filter-group label {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--color-text-secondary);
}

.filter-group select {
    padding: 0.5rem 0.75rem;
    font-size: 0.9rem;
    font-family: inherit;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-surface);
    cursor: pointer;
    outline: none;
}

.filter-group select:focus {
    border-color: var(--color-primary);
}

/* ====== BADGES ====== */
.badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 50px;
    font-size: 0.75rem;
    font-weight: 500;
    white-space: nowrap;
}

.badge-pj {
    background: rgba(30, 136, 229, 0.12);
    color: var(--color-pj);
}

.badge-pro {
    background: rgba(249, 168, 37, 0.12);
    color: #f9a825;
}

.badge-ucr {
    background: rgba(239, 68, 68, 0.08);
    color: var(--color-ucr);
}

.badge-lla {
    background: rgba(123, 31, 162, 0.12);
    color: var(--color-lla);
}

.badge-otros {
    background: rgba(120, 144, 156, 0.12);
    color: var(--color-other);
}

.badge-diputados {
    background: rgba(59, 130, 246, 0.1);
    color: var(--color-primary);
}

.badge-senadores {
    background: rgba(239, 68, 68, 0.1);
    color: #dc2626;
}

.badge-both {
    background: linear-gradient(90deg, rgba(59, 130, 246, 0.1), rgba(239, 68, 68, 0.1));
    color: #7c3aed;
}

/* ====== STATS BAR ====== */
.stats-bar {
    padding: 1rem 0;
    background: var(--color-background);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
}

.stat-card {
    background: var(--color-surface);
    padding: 1.25rem;
    border-radius: var(--radius);
    border: 1px solid var(--color-border);
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.stat-number {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-primary);
}

.stat-label {
    font-size: 0.8rem;
    color: var(--color-text-secondary);
    font-weight: 500;
}

/* ====== RANKING SECTION ====== */
.ranking-section {
    padding: 1rem 0 2rem;
}

.ranking-section:not(:has(.ranking-card)) .container {
    margin-top: 1rem;
}

/* Card outline style for sections */
.card-outline,
.ranking-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 2rem 1.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    margin-bottom: 1.5rem;
}

/* Remove container styling when card-outline is used on section */
.search-section.card-outline .container,
.law-search-section.card-outline .container,
.ranking-card .container {
    background: transparent;
    border: none;
    border-radius: 0;
    padding: 0;
    box-shadow: none;
}

.ranking-card {
    margin-top: 1rem;
}

.ranking-controls {
    max-width: 900px;
    margin: 0 auto 1.5rem;
}

.ranking-controls-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: center;
}

.ranking-table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.ranking-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.ranking-table th {
    background: var(--color-surface);
    padding: 0.6rem 0.5rem;
    text-align: left;
    font-weight: 600;
    border-bottom: 2px solid var(--color-border);
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 1;
}

.ranking-table td {
    padding: 0.5rem 0.5rem;
    border-bottom: 1px solid var(--color-border);
    vertical-align: middle;
}

.ranking-table td.ranking-cell-bloc {
    max-width: 180px;
    white-space: normal;
    word-wrap: break-word;
    font-size: 0.8rem;
}

.ranking-table tr:hover {
    background: rgba(99, 102, 241, 0.04);
}

.ranking-table .ranking-sortable {
    cursor: pointer;
    user-select: none;
    text-align: right;
}

.ranking-table .ranking-sortable:hover {
    color: var(--color-primary);
}

.ranking-table .ranking-sortable.sort-active {
    color: var(--color-primary);
    font-weight: 700;
}

.ranking-name-link {
    color: var(--color-primary);
    text-decoration: none;
    font-weight: 500;
    cursor: pointer;
}

.ranking-name-link:hover {
    text-decoration: underline;
}

.ranking-cell-num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.ranking-sortable {
    text-align: right;
}

.ranking-medal {
    font-size: 1rem;
    vertical-align: middle;
}

.ranking-title-row {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 0.5rem;
}
.ranking-title-row .section-title { margin-bottom: 0; }
.ranking-title-row .section-desc { margin-bottom: 0; }

.ranking-export-row {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    justify-content: flex-end;
    width: 100%;
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--color-border);
}

/* ====== LEGISLATOR DETAIL ====== */
.legislator-detail {
    padding: 1rem 0 3rem;
}

.back-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.5rem 1rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all var(--transition);
    margin-bottom: 1.5rem;
    color: var(--color-text);
}

.back-btn:hover {
    background: var(--color-bg);
    border-color: var(--color-primary);
    color: var(--color-primary);
}

/* Legislator Header */
.leg-header {
    background: var(--color-surface);
    padding: 2rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 1.5rem;
}



.leg-header-left {
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.leg-photo {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--color-border);
    flex-shrink: 0;
}

.leg-name {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.leg-meta {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.leg-alignment-summary {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
    justify-content: center;
}

.alignment-card {
    text-align: center;
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius-sm);
    background: var(--color-bg);
    min-width: 120px;
}

.alignment-card .alignment-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.25rem;
}

.alignment-card .alignment-value {
    font-size: 1.75rem;
    font-weight: 700;
}

.alignment-pj .alignment-label { color: var(--color-pj); }
.alignment-pj .alignment-value { color: var(--color-pj); }
.alignment-ucr .alignment-label { color: var(--color-negativo); }
.alignment-ucr .alignment-value { color: var(--color-negativo); }
.alignment-pro .alignment-label { color: #f9a825; }
.alignment-pro .alignment-value { color: #f9a825; }
.alignment-lla .alignment-label { color: var(--color-lla); }
.alignment-lla .alignment-value { color: var(--color-lla); }

/* 3-column era breakdown grid */
.alignment-grid-3col {
    display: flex;
    gap: 0.75rem;
}

.alignment-era-col {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    align-items: center;
    min-width: 96px;
}

.alignment-era-label {
    font-size: 0.62rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-secondary);
    white-space: nowrap;
}

.alignment-grid-3col .alignment-card {
    min-width: 0;
    width: 100%;
    padding: 0.45rem 0.55rem;
    box-sizing: border-box;
}

.alignment-grid-3col .alignment-card .alignment-value {
    font-size: 1.3rem;
}

.alignment-grid-3col .alignment-card .alignment-label {
    font-size: 0.62rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ====== LEG-HEADER OFF-SCREEN EXPORT CARD ====== */
.lhe-alignment-title {
    font-size: 0.6rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--color-text-secondary);
    margin: 0.6rem 0 0.4rem;
}

.lhe-alignment-grid {
    /* layout is now handled by .alignment-grid-3col */
}

#leg-header-export-card .alignment-era-col {
    min-width: 0;
    flex: 1;
}

#leg-header-export-card .alignment-era-label {
    font-size: 0.55rem;
}

#leg-header-export-card .alignment-card {
    min-width: 0;
    padding: 0.35rem 0.45rem;
}

#leg-header-export-card .alignment-card .alignment-label { font-size: 0.5rem; }
#leg-header-export-card .alignment-card .alignment-value { font-size: 1.0rem; }

/* Stats row inside the export card header */
.lhe-stats {
    display: flex;
    gap: 0.75rem;
    margin-top: 0.35rem;
    flex-wrap: wrap;
}
.lhe-stat {
    display: flex;
    align-items: baseline;
    gap: 0.2rem;
}
.lhe-stat-value {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--color-text);
}
.lhe-stat-label {
    font-size: 0.5rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--color-text-secondary);
}

/* Stats row inside the live header */
.leg-stats-inline {
    display: flex;
    gap: 1.25rem;
    margin-top: 0.6rem;
    flex-wrap: wrap;
}
.leg-stat-inline {
    display: flex;
    align-items: baseline;
    gap: 0.3rem;
}
.leg-stat-inline-value {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--color-text);
}
.leg-stat-inline-label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--color-text-secondary);
}

/* ====== LEGISLATOR INFO / TERMS CARD ====== */
.leg-info-stats-row {
    display: flex;
    gap: 2.5rem;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
}

.leg-info-stat {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.leg-info-stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1;
    color: var(--color-text);
}

.leg-info-stat-label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--color-text-secondary);
}

.leg-terms-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

.leg-terms-table th {
    text-align: left;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--color-text-secondary);
    padding: 0 0.75rem 0.5rem 0;
    border-bottom: 1px solid var(--color-border);
}

.leg-terms-table td {
    padding: 0.5rem 0.75rem 0.5rem 0;
    border-bottom: 1px solid var(--color-border);
    vertical-align: middle;
}

.leg-terms-table tr:last-child td {
    border-bottom: none;
}

/* Scale down fonts inside the off-screen info export card (html2canvas scale:3 */
/* makes everything appear 3× — this 0.7 factor brings text down ~30%)          */
#info-export-card .leg-info-stat-value  { font-size: 1.15rem; }
#info-export-card .leg-info-stat-label  { font-size: 0.40rem; }
#info-export-card .leg-terms-table      { font-size: 0.55rem; }
#info-export-card .leg-terms-table th   { font-size: 0.40rem; }
#info-export-card .aec-chart-title      { font-size: 0.55rem; }

/* ====== WAFFLE VISUALIZATION ====== */
.waffle-section {
    background: var(--color-surface);
    padding: 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
}

.waffle-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1rem;
}

.waffle-toolbar h3 {
    font-size: 1.1rem;
}

.waffle-controls {
    display: flex;
    gap: 0.75rem;
    align-items: flex-end;
    flex-wrap: wrap;
}

.waffle-filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.waffle-filter-group label {
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--color-text-secondary);
}

.waffle-filter-group select,
.waffle-filter-group input {
    padding: 0.35rem 0.6rem;
    font-size: 0.85rem;
    font-family: inherit;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-surface);
    outline: none;
}

.waffle-filter-group input {
    width: 180px;
}

.waffle-filter-group select:focus,
.waffle-filter-group input:focus {
    border-color: var(--color-primary);
}

.waffle-actions {
    display: flex;
    gap: 0.5rem;
}

.btn-share {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.4rem 0.75rem;
    font-size: 0.8rem;
    font-family: inherit;
    font-weight: 500;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-surface);
    cursor: pointer;
    transition: all var(--transition);
    color: var(--color-text);
    white-space: nowrap;
}

.btn-share:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
    background: #f0f7ff;
}

.btn-share:disabled {
    opacity: 0.6;
    cursor: wait;
}

.btn-share-tw:hover {
    border-color: #1d9bf0;
    color: #1d9bf0;
    background: rgba(29, 155, 240, 0.05);
}

/* Waffle Card (the exportable part) */
.waffle-card {
    background: #ffffff;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1.25rem;
    overflow: hidden;
}

.waffle-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid #e5e7eb;
}

.waffle-card-name {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--color-text);
}

.waffle-card-meta {
    display: flex;
    gap: 0.5rem;
}

/* Small portrait in waffle header (Leyes destacadas) */
.waffle-header-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.waffle-header-photo {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--color-border);
    flex-shrink: 0;
}
.waffle-header-photo.no-photo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #e5e7eb;
    color: var(--color-text-secondary);
}
.waffle-card-name-text {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--color-text);
}

/* Waffle law rows */
.waffle-law-row {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid #f1f5f9;
}

.waffle-law-row:last-child {
    border-bottom: none;
}

.waffle-law-label {
    min-width: 200px;
    max-width: 280px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

.waffle-law-name {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--color-text);
    line-height: 1.3;
    word-break: break-word;
}

.waffle-law-year {
    font-size: 0.7rem;
    color: var(--color-text-secondary);
    font-weight: 400;
}

.waffle-tiles {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    flex: 1;
}

.waffle-tile {
    width: 28px;
    height: 28px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    cursor: default;
    transition: transform 0.1s ease;
}

.waffle-tile:hover {
    transform: scale(1.15);
    z-index: 2;
}

.waffle-tile.tile-clickable {
    cursor: pointer;
}

/* "En General" votes stand out with a larger box and a colored border.
   border is used (not box-shadow) because html2canvas does not render box-shadow. */
.waffle-tile.tile-general {
    width: 28px;
    height: 28px;
    border-radius: 4px;
    font-size: 0.75rem;
}
.tile-AFIRMATIVO.tile-general  { border: 2.5px solid #16a34a; }
.tile-NEGATIVO.tile-general    { border: 2.5px solid #dc2626; }
.tile-ABSTENCION.tile-general  { border: 2.5px solid #d97706; }
.tile-AUSENTE.tile-general     { border: 2.5px solid #94a3b8; }
.tile-PRESIDENTE.tile-general  { border: 2.5px solid #7c3aed; }

/* Legend swatch for "Voto en general" — white fill with darker border */
.waffle-tile-legend.tile-general-legend {
    background: #ffffff;
    border: 2px solid #6b7280;
}

/* Applied temporarily during image export so the law label doesn't crowd the tiles */
.waffle-card.exporting {
    padding: 0.6rem;
}

.exporting .waffle-law-row {
    gap: 0.60rem;
}

.exporting .waffle-law-label {
    min-width: 80px;
    max-width: 110px;
    font-size: 0.75rem;
}

.tile-AFIRMATIVO {
    background: #dcfce7;
    color: #16a34a;
}

.tile-NEGATIVO {
    background: #fee2e2;
    color: #dc2626;
}

.tile-ABSTENCION {
    background: #fef3c7;
    color: #d97706;
}

.tile-AUSENTE {
    background: #f1f5f9;
    color: #94a3b8;
}

.tile-PRESIDENTE {
    background: #ede9fe;
    color: #7c3aed;
}

/* Waffle legend */
.waffle-legend {
    display: flex;
    gap: 1rem;
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid #f1f5f9;
    flex-wrap: wrap;
}

.waffle-legend-item {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.75rem;
    color: var(--color-text-secondary);
}

.waffle-tile-legend {
    width: 14px;
    height: 14px;
    border-radius: 3px;
    display: inline-block;
}

.waffle-card-footer {
    text-align: right;
    font-size: 0.65rem;
    color: #d1d5db;
    margin-top: 0.5rem;
    font-weight: 500;
}

.export-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.export-footer-date {
    color: #d1d5db;
    font-size: 0.65rem;
    font-weight: 500;
}

/* ── Presentismo tooltip ── */
.has-tooltip {
    position: relative;
    cursor: help;
}

.has-tooltip .stat-tooltip {
    display: none;
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    width: 220px;
    background: #1f2937;
    color: #f9fafb;
    font-size: 0.75rem;
    font-weight: 400;
    line-height: 1.4;
    padding: 0.5rem 0.65rem;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.25);
    pointer-events: none;
    z-index: 100;
    text-transform: none;
    letter-spacing: 0;
}

.has-tooltip .stat-tooltip::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: #1f2937;
}

.has-tooltip:hover .stat-tooltip {
    display: block;
}

/* ── Alignment export card (off-screen render target) ── */
.aec-header-inner {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--color-border);
    margin-bottom: 0.75rem;
}

.aec-photo {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.aec-photo-placeholder {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: #e5e7eb;
    flex-shrink: 0;
}

.aec-name {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--color-text);
}

.aec-meta {
    font-size: 0.75rem;
    color: var(--color-text-secondary);
    margin-top: 0.15rem;
}

.aec-chart-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 0.5rem;
}



.aec-chart-img {
    width: 100%;
    display: block;
    border-radius: 4px;
}

.waffle-empty {
    text-align: center;
    padding: 2rem;
    color: var(--color-text-secondary);
    font-size: 0.9rem;
}

/* ====== CHARTS ====== */
.charts-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.chart-card {
    background: var(--color-surface);
    padding: 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.chart-card-title-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.75rem;
    margin-bottom: 0;
    flex-wrap: wrap;
}

.chart-card-actions {
    display: flex;
    gap: 0.4rem;
    flex-shrink: 0;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.exporting .chart-card-actions {
    display: none !important;
}

.chart-card h3 {
    font-size: 1.1rem;
    margin-bottom: 0.25rem;
}

.chart-desc {
    font-size: 0.8rem;
    color: var(--color-text-secondary);
    margin-bottom: 1rem;
}

.chart-container {
    position: relative;
    height: 300px;
}

/* ====== VOTES TABLE ====== */
.votes-section {
    background: var(--color-surface);
    padding: 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.votes-section h3 {
    font-size: 1.1rem;
    margin-bottom: 1rem;
}

.votes-filters {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.votes-filters select,
.votes-law-input {
    padding: 0.4rem 0.75rem;
    font-size: 0.85rem;
    font-family: inherit;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-surface);
    cursor: pointer;
    outline: none;
}

.votes-law-input {
    min-width: 180px;
    cursor: text;
}

.votes-law-input:focus,
.votes-filters select:focus {
    border-color: var(--color-primary);
}

.votes-table-wrapper {
    overflow-x: auto;
}

.votes-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.votes-table th {
    text-align: left;
    padding: 0.75rem;
    border-bottom: 2px solid var(--color-border);
    font-weight: 600;
    color: var(--color-text-secondary);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
}

.votes-table td {
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid var(--color-border);
    vertical-align: top;
}

.votes-table tr:hover {
    background: #f9fafb;
}

.vote-title {
    font-size: 0.85rem;
    line-height: 1.35;
}

.vote-article {
    font-size: 0.7rem;
    color: var(--color-text-secondary);
    margin-top: 0.15rem;
}

.vote-chip {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}

.vote-AFIRMATIVO { background: rgba(34, 197, 94, 0.12); color: #16a34a; }
.vote-NEGATIVO { background: rgba(239, 68, 68, 0.12); color: #dc2626; }
.vote-ABSTENCION { background: rgba(245, 158, 11, 0.12); color: #d97706; }
.vote-AUSENTE { background: rgba(148, 163, 184, 0.12); color: #64748b; }
.vote-PRESIDENTE { background: rgba(139, 92, 246, 0.12); color: #7c3aed; }
.vote-NA { background: rgba(148, 163, 184, 0.08); color: #94a3b8; }

/* Pagination */
.votes-pagination {
    display: flex;
    justify-content: center;
    gap: 0.25rem;
    margin-top: 1rem;
    flex-wrap: wrap;
}

.votes-pagination button {
    padding: 0.4rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-surface);
    font-family: inherit;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all var(--transition);
}

.votes-pagination button:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
}

.votes-pagination button.active {
    background: var(--color-primary);
    color: white;
    border-color: var(--color-primary);
}

/* ====== LAW SEARCH SECTION ====== */
.law-search-section {
    padding: 1rem 0 2rem;
}

.law-search-section:not(.card-outline) .container {
    margin-top: 1rem;
}

.section-title {
    font-size: 1.5rem;
    font-weight: 700;
    text-align: center;
    margin-bottom: 0.25rem;
}

.section-desc {
    text-align: center;
    color: var(--color-text-secondary);
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
}

.law-search-controls {
    max-width: 640px;
    margin: 0 auto 1.5rem;
}

.law-search-row {
    position: relative;
    margin-bottom: 0.75rem;
}

.law-search-row input {
    width: 100%;
    padding: 0.75rem 1.25rem;
    font-size: 1rem;
    font-family: inherit;
    border: 2px solid var(--color-border);
    border-radius: 50px;
    background: var(--color-surface);
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.law-search-row input:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.law-filter-row {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

/* ====== MULTI-SELECT DROPDOWN WIDGET ====== */
.ms-wrap {
    position: relative;
    display: inline-block;
}

.ms-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.4rem;
    padding: 0.35rem 0.6rem;
    font-size: 0.85rem;
    font-family: inherit;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-surface);
    color: var(--color-text);
    cursor: pointer;
    outline: none;
    min-width: 5.5rem;
    white-space: nowrap;
    text-align: left;
    line-height: 1.4;
}

.ms-btn::after {
    content: "\25BE";
    font-size: 0.65rem;
    color: var(--color-text-secondary);
    flex-shrink: 0;
    margin-left: 0.2rem;
}

.ms-btn:hover {
    border-color: #94a3b8;
}

.ms-btn.ms-active {
    border-color: var(--color-primary);
    color: var(--color-primary);
}

.ms-panel {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    z-index: 300;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    min-width: 100%;
    max-height: 240px;
    overflow-y: auto;
    padding: 0.25rem 0;
}

.ms-option {
    display: flex;
    align-items: center;
    gap: 0;
    padding: 0.3rem 0.75rem;
    cursor: pointer;
    font-size: 0.85rem;
    font-family: inherit;
    white-space: nowrap;
    user-select: none;
    color: var(--color-text);
}

.ms-option:hover {
    background: #f0f7ff;
}

.ms-option input[type="checkbox"] {
    accent-color: var(--color-primary);
    cursor: pointer;
    flex-shrink: 0;
    margin-right: 0.45rem;
}

/* Law dropdown */
.law-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    max-height: 360px;
    overflow-y: auto;
    z-index: 100;
}

.law-dropdown-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.65rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid var(--color-border);
    transition: background var(--transition);
    font-size: 0.9rem;
    gap: 0.75rem;
}

.law-dropdown-item:last-child { border-bottom: none; }
.law-dropdown-item:hover { background: #f0f7ff; }

.law-dropdown-name {
    flex: 1;
    font-weight: 500;
    line-height: 1.3;
}

.law-dropdown-notable {
    margin-right: 0.3rem;
    font-size: 0.8rem;
}

.law-dropdown-meta {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-shrink: 0;
}

.law-dropdown-year {
    font-size: 0.75rem;
    color: var(--color-text-secondary);
    font-weight: 500;
}

/* Law detail card */
.law-detail-wrapper {
    max-width: 720px;
    margin: 0 auto;
}

.law-detail-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
    margin-bottom: 0.75rem;
}

.law-detail-card {
    background: #ffffff;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1.5rem;
    overflow: hidden;
}

.law-detail-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid #e5e7eb;
}

.law-detail-title {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--color-text);
    flex: 1;
    line-height: 1.3;
}

.law-detail-meta {
    display: flex;
    gap: 0.4rem;
    flex-shrink: 0;
    align-items: center;
}

.law-detail-body {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.law-detail-empty {
    text-align: center;
    padding: 2rem;
    color: var(--color-text-secondary);
    font-size: 0.9rem;
    font-style: italic;
}

.law-detail-legend {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid #f1f5f9;
    flex-wrap: wrap;
}

.law-detail-footer {
    text-align: right;
    font-size: 0.65rem;
    color: #d1d5db;
    margin-top: 0.5rem;
    font-weight: 500;
}

/* Per-votación block */
.law-votacion-block {
    padding: 0.75rem 0;
    border-bottom: 1px solid #f1f5f9;
}

.law-votacion-block:last-child {
    border-bottom: none;
}

.law-votacion-single {
    padding-top: 0;
}

.law-votacion-header {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    margin-bottom: 0.6rem;
}

.law-votacion-topline {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.law-votacion-header-single {
    margin-bottom: 0.6rem;
}

.law-votacion-type {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--color-text);
}

.law-votacion-fullname {
    font-size: 0.78rem;
    color: var(--color-text-secondary);
    line-height: 1.3;
}

.law-votacion-date {
    font-size: 0.8rem;
    color: var(--color-text-secondary);
}

.law-votacion-link {
    font-size: 0.85rem;
    text-decoration: none;
    margin-left: auto;
}

.law-result {
    display: inline-block;
    padding: 0.1rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

.law-result-afirm {
    background: rgba(34, 197, 94, 0.12);
    color: #16a34a;
}

.law-result-neg {
    background: rgba(239, 68, 68, 0.12);
    color: #dc2626;
}

/* Coalition breakdown bars */
.law-bars-container {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.law-bar-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.law-bar-total {
    margin-top: 0.25rem;
    padding-top: 0.35rem;
    border-top: 1px solid #e5e7eb;
}

.law-bar-total .law-bar-label {
    font-weight: 700;
}

.law-bar-label {
    min-width: 75px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--color-text);
    flex-shrink: 0;
}

.law-bar-track {
    flex: 1;
    display: flex;
    height: 22px;
    border-radius: 4px;
    overflow: hidden;
    background: #f1f5f9;
}

.law-bar-seg {
    transition: width 0.3s ease;
    min-width: 0;
    cursor: pointer;
}

.law-bar-seg:hover {
    filter: brightness(1.12);
}

.law-bar-seg.bar-afirm { background: var(--color-afirmativo); }
.law-bar-seg.bar-neg   { background: var(--color-negativo); }
.law-bar-seg.bar-abst  { background: var(--color-abstencion); }
.law-bar-seg.bar-aus   { background: #cbd5e1; }

/* Party-colored left accent on bar labels */
.law-bar-row[data-party="pj"]  .law-bar-label { color: var(--color-pj); }
.law-bar-row[data-party="ucr"] .law-bar-label { color: var(--color-ucr); }
.law-bar-row[data-party="pro"] .law-bar-label { color: #f9a825; }
.law-bar-row[data-party="lla"] .law-bar-label { color: var(--color-lla); }
.law-bar-row[data-party="cc"]  .law-bar-label { color: #0d9488; }
.law-bar-row[data-party="oth"] .law-bar-label { color: var(--color-other); }

/* ====== VOTER DETAIL LIST (bar click drill-down) ====== */
.law-voter-list {
    margin-top: 0.5rem;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    overflow: hidden;
    font-size: 0.82rem;
}

.voter-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.6rem;
    font-weight: 600;
    border-bottom: 1px solid var(--color-border);
}

.voter-header.voter-afirm { background: rgba(34, 197, 94, 0.10); color: #16a34a; }
.voter-header.voter-neg   { background: rgba(239, 68, 68, 0.10); color: #dc2626; }
.voter-header.voter-abst  { background: rgba(234, 179, 8, 0.10);  color: #b45309; }
.voter-header.voter-aus   { background: rgba(148, 163, 184, 0.15); color: #64748b; }

.voter-header-label { flex: 1; }
.voter-header-count {
    background: rgba(0,0,0,0.08);
    padding: 0.1rem 0.45rem;
    border-radius: 10px;
    font-size: 0.75rem;
}
.voter-close {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.85rem;
    color: inherit;
    opacity: 0.6;
    padding: 0 0.2rem;
}
.voter-close:hover { opacity: 1; }

.voter-body {
    max-height: 260px;
    overflow-y: auto;
    padding: 0.3rem 0;
}

.voter-group-header {
    padding: 0.3rem 0.6rem 0.15rem;
    font-weight: 600;
    font-size: 0.78rem;
    color: var(--color-text-secondary);
    border-top: 1px solid var(--color-border);
}
.voter-group-header:first-child { border-top: none; }
.voter-group-header[data-party="pj"]  { color: var(--color-pj); }
.voter-group-header[data-party="ucr"] { color: var(--color-ucr); }
.voter-group-header[data-party="pro"] { color: #f9a825; }
.voter-group-header[data-party="lla"] { color: var(--color-lla); }
.voter-group-header[data-party="cc"]  { color: #0d9488; }
.voter-group-header[data-party="oth"] { color: var(--color-other); }

.voter-group-count {
    font-weight: 400;
    opacity: 0.7;
}

.voter-item {
    padding: 0.15rem 0.6rem 0.15rem 1rem;
    line-height: 1.4;
}
.voter-item.voter-afirm { color: #16a34a; }
.voter-item.voter-neg   { color: #dc2626; }
.voter-item.voter-abst  { color: #b45309; }
.voter-item.voter-aus   { color: #94a3b8; }

.voter-link {
    color: inherit;
    text-decoration: none;
    border-bottom: 1px dotted currentColor;
    cursor: pointer;
}
.voter-link:hover {
    text-decoration: underline;
    opacity: 0.8;
}

.voter-loading {
    padding: 0.6rem;
    text-align: center;
    color: var(--color-text-secondary);
    font-style: italic;
}

.law-bar-counts {
    min-width: 110px;
    font-size: 0.72rem;
    color: var(--color-text-secondary);
    white-space: nowrap;
    flex-shrink: 0;
}

/* ====== VOTE INFO POPUP ====== */
.vote-popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.vote-popup-overlay.hidden {
    display: none !important;
}

.vote-popup {
    background: var(--color-surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 1.75rem 2rem;
    max-width: 520px;
    width: 100%;
    position: relative;
    animation: popupFadeIn 0.15s ease;
}

@keyframes popupFadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.vote-popup-close {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--color-text-secondary);
    cursor: pointer;
    line-height: 1;
    padding: 0.25rem;
    transition: color var(--transition);
}

.vote-popup-close:hover {
    color: var(--color-text);
}

.vote-popup-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 1rem;
    padding-right: 1.5rem;
    color: var(--color-text);
}

.vote-popup-body {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.vote-popup-row {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.vote-popup-label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-text-secondary);
}

.vote-popup-value {
    font-size: 0.9rem;
    color: var(--color-text);
    line-height: 1.4;
}

.vote-popup-link {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    margin-top: 0.5rem;
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--color-primary);
    background: rgba(59, 130, 246, 0.08);
    border: 1px solid rgba(59, 130, 246, 0.2);
    border-radius: var(--radius-sm);
    text-decoration: none;
    transition: all var(--transition);
}

.vote-popup-link:hover {
    background: rgba(59, 130, 246, 0.15);
    border-color: var(--color-primary);
}

/* ====== FOOTER ====== */
.footer {
    background: url('header_mainpage.png') center/cover no-repeat;
    color: #ffffff;
    padding: 2rem 0;
    text-align: center;
    font-size: 0.85rem;
}

.footer a {
    color: #ffffff;
}

.footer p + p {
    margin-top: 0.5rem;
}

/* ====== RESPONSIVE ====== */
@media (max-width: 768px) {
    .header {
        padding: 1.25rem 0;
    }

    .logo {
        font-size: 1.5rem;
    }

    .logo-icon {
        font-size: 1.75rem;
    }

    .ranking-controls-row {
        flex-direction: column;
    }

    .ranking-table {
        font-size: 0.75rem;
    }

    .ranking-table th,
    .ranking-table td {
        padding: 0.4rem 0.3rem;
    }

    .charts-row {
        grid-template-columns: 1fr;
    }

    .chart-container {
        height: 220px;
    }

    .leg-header {
        flex-direction: column;
        padding: 1.25rem;
    }

    /* Keep photo + name side-by-side on tablets */
    .leg-header-left {
        flex-direction: row;
        align-items: center;
    }

    .leg-photo {
        width: 56px;
        height: 56px;
    }

    .leg-name {
        font-size: 1.3rem;
    }

    .leg-alignment-summary {
        width: 100%;
        justify-content: flex-start;
    }

    .waffle-section,
    .votes-section,
    .chart-card {
        padding: 1rem;
    }

    .waffle-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .waffle-law-label {
        min-width: 130px;
        max-width: 160px;
    }

    .waffle-tile {
        width: 24px;
        height: 24px;
        font-size: 0.65rem;
    }

    .waffle-tile.tile-general {
        width: 24px;
        height: 24px;
        font-size: 0.65rem;
        border-radius: 2px;
    }
    .tile-AFIRMATIVO.tile-general  { border: 1.5px solid #16a34a; }
    .tile-NEGATIVO.tile-general    { border: 1.5px solid #dc2626; }
    .tile-ABSTENCION.tile-general  { border: 1.5px solid #d97706; }
    .tile-AUSENTE.tile-general     { border: 1.5px solid #94a3b8; }
    .tile-PRESIDENTE.tile-general  { border: 1.5px solid #7c3aed; }

    .waffle-card-name {
        font-size: 1rem;
    }

    .votes-table {
        font-size: 0.8rem;
    }

    .votes-table th,
    .votes-table td {
        padding: 0.4rem;
    }

    .stat-card {
        padding: 1rem;
    }

    .stat-number {
        font-size: 1.25rem;
    }
}

/* ─── Phone layout: card-based votes table + stacked notable card ─── */
@media (max-width: 600px) {
    /* Votes table → per-row cards */
    .votes-table-wrapper {
        overflow-x: unset;
    }

    .votes-table,
    .votes-table tbody {
        display: block;
    }

    .votes-table thead {
        display: none;
    }

    .votes-table tr {
        display: grid;
        grid-template-columns: 1fr auto;
        background: var(--color-surface);
        border: 1px solid var(--color-border);
        border-radius: var(--radius-sm);
        margin-bottom: 0.5rem;
        padding: 0.5rem 0.75rem;
    }

    .votes-table tr:hover {
        background: #f9fafb;
    }

    /* td 1 – date: top-left */
    .votes-table td:nth-child(1) {
        grid-column: 1;
        grid-row: 1;
        border: none;
        padding: 0 0 0.1rem;
        font-size: 0.72rem;
        color: var(--color-text-secondary);
        white-space: nowrap;
    }

    /* td 2 – law name: full-width second row */
    .votes-table td:nth-child(2) {
        grid-column: 1 / -1;
        grid-row: 2;
        border: none;
        padding: 0.1rem 0;
    }

    /* td 3 – source link: top-right, next to date */
    .votes-table td:nth-child(3) {
        grid-column: 2;
        grid-row: 1;
        border: none;
        padding: 0 0 0.1rem;
        text-align: right;
    }

    /* td 4 – vote chip: third row */
    .votes-table td:nth-child(4) {
        grid-column: 1 / -1;
        grid-row: 3;
        border: none;
        padding: 0.1rem 0 0;
    }

    /* Hide the four coalition columns — not enough room on phones */
    .votes-table td:nth-child(5),
    .votes-table td:nth-child(6),
    .votes-table td:nth-child(7),
    .votes-table td:nth-child(8) {
        display: none;
    }

    /* Law detail: shrink bar labels on phones */
    .law-bar-label {
        min-width: 65px;
        font-size: 0.72rem;
    }

    .law-bar-counts {
        min-width: 80px;
        font-size: 0.65rem;
    }

    .law-filter-row {
        flex-direction: column;
        gap: 0.5rem;
    }

    .law-filter-row .filter-group select {
        width: 100%;
    }

    /* Votes filters: stack vertically, full-width, touch-friendly */
    .votes-filters {
        flex-direction: column;
        gap: 0.5rem;
    }

    .votes-filters select,
    .votes-law-input {
        width: 100%;
        min-width: unset;
        min-height: 42px;
    }

    /* Back button: full-width for easy tap */
    .back-btn {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 0.875rem;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }

    /* Search filters: label + select inline */
    .filters {
        flex-direction: column;
        gap: 0.5rem;
    }

    .filter-group {
        flex-direction: row;
        align-items: center;
        gap: 0.5rem;
    }

    .filter-group label {
        flex-shrink: 0;
        min-width: 70px;
    }

    .filter-group select {
        flex: 1;
    }

    .alignment-card {
        min-width: 80px;
        padding: 0.5rem 0.75rem;
    }

    .alignment-card .alignment-value {
        font-size: 1.2rem;
    }

    .waffle-law-row {
        flex-direction: column;
        gap: 0.25rem;
    }

    .waffle-law-label {
        min-width: unset;
        max-width: unset;
    }

    .waffle-controls {
        flex-direction: column;
        width: 100%;
    }

    .waffle-filter-group {
        width: 100%;
    }

    .waffle-filter-group select,
    .waffle-filter-group input {
        width: 100%;
    }

    .waffle-actions {
        width: 100%;
    }

    .waffle-actions .btn-share {
        flex: 1;
        justify-content: center;
    }

    .chart-card-actions {
        flex-direction: row;
        flex-wrap: wrap;
        width: 100%;
    }

    .chart-card-actions .btn-share {
        flex: 1;
        justify-content: center;
    }

    /* Notable share buttons → now law detail actions: full-width row */
    .law-detail-actions .btn-share {
        flex: 1;
        justify-content: center;
    }

    /* Tighten legend spacing */
    .waffle-legend,
    .law-detail-legend {
        gap: 0.5rem;
        font-size: 0.7rem;
    }
}

/* ====== SCROLLBAR ====== */
.search-results::-webkit-scrollbar {
    width: 6px;
}

.search-results::-webkit-scrollbar-track {
    background: transparent;
}

.search-results::-webkit-scrollbar-thumb {
    background: var(--color-border);
    border-radius: 3px;
}

.search-results::-webkit-scrollbar-thumb:hover {
    background: #adb5bd;
}
