:root {
    --bg: #f5f6f8;
    --surface: #ffffff;
    --text: #1c1e21;
    --muted: #6b7280;
    --border: #e2e5ea;
    --primary: #2554c7;
    --fact: #157347;
    --fact-bg: #e3f5ec;
    --allegation: #b45309;
    --allegation-bg: #fdf1e0;
    --danger: #c0392b;
    --radius: 10px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: 'Pretendard', 'Apple SD Gothic Neo', 'Malgun Gothic', '맑은 고딕', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
}

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

.container {
    max-width: 1080px;
    margin: 0 auto;
    padding: 0 16px;
}

.container.narrow {
    max-width: 720px;
}

/* ---- header / footer ---- */
.site-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 56px;
}

.logo {
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--text);
}

.site-nav {
    display: flex;
    align-items: center;
    gap: 14px;
}

.site-footer {
    margin-top: 48px;
    padding: 24px 0 36px;
    border-top: 1px solid var(--border);
    background: var(--surface);
    font-size: 0.85rem;
    color: var(--muted);
}

/* ---- common ---- */
.page-title {
    margin: 24px 0 4px;
    font-size: 1.5rem;
}

.page-subtitle {
    margin: 0 0 20px;
    color: var(--muted);
}

.muted {
    color: var(--muted);
    font-size: 0.9em;
}

.empty {
    color: var(--muted);
    padding: 12px 0;
}

.notice {
    margin: 16px 0;
    padding: 12px 16px;
    background: #fff8e1;
    border: 1px solid #f0dc9a;
    border-radius: var(--radius);
    font-size: 0.92rem;
}

.alert {
    margin: 16px 0;
    padding: 12px 16px;
    background: #e8f0fe;
    border: 1px solid #b6cdf5;
    border-radius: var(--radius);
}

.alert.error {
    background: #fdecea;
    border-color: #f2b8b5;
    color: var(--danger);
}

.badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 700;
    white-space: nowrap;
}

.badge-fact {
    background: var(--fact-bg);
    color: var(--fact);
}

.badge-allegation {
    background: var(--allegation-bg);
    color: var(--allegation);
}

.button {
    display: inline-block;
    padding: 9px 18px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
}

.button:hover {
    opacity: 0.9;
    text-decoration: none;
}

.button-sm {
    padding: 5px 12px;
    font-size: 0.85rem;
}

.link-button {
    background: none;
    border: none;
    padding: 0;
    color: var(--primary);
    cursor: pointer;
    font-size: inherit;
    font-family: inherit;
}

.link-button.danger {
    color: var(--danger);
}

.inline-form {
    display: inline;
}

/* ---- party jump nav ---- */
.party-jump {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 24px;
}

.party-jump a {
    padding: 5px 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 4px solid var(--border);
    border-radius: 999px;
    font-size: 0.88rem;
    color: var(--text);
}

.party-jump a.active {
    background: #34404f;
    color: #fff;
    font-weight: 700;
}

.party-jump a:hover {
    text-decoration: none;
    outline: 2px solid var(--primary);
}

/* ---- party pyramid ---- */
.party-section {
    margin-bottom: 40px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.party-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    padding: 12px 20px;
    background: #566072;
    color: #fff;
}

.party-header h2 {
    margin: 0;
    font-size: 1.2rem;
}

.party-count {
    font-size: 0.9rem;
    opacity: 0.9;
}

.pyramid {
    padding: 20px;
}

.tier {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 14px;
    margin-bottom: 18px;
}

.tier-members {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
    gap: 10px;
    margin-bottom: 0;
}

.card {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 12px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    transition: box-shadow 0.15s, transform 0.15s;
}

.card:hover {
    text-decoration: none;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.photo {
    object-fit: cover;
    border-radius: 50%;
    background: #dfe3e8;
}

.avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: #8a93a3;
}

.card-lg .photo {
    width: 96px;
    height: 96px;
    font-size: 2rem;
}

.card-md .photo {
    width: 72px;
    height: 72px;
    font-size: 1.5rem;
}

.card-sm .photo {
    width: 56px;
    height: 56px;
    font-size: 1.2rem;
}

.card-lg {
    min-width: 180px;
}

.card-md {
    min-width: 140px;
}

.card-title {
    margin-top: 6px;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--primary);
}

.card-name {
    font-weight: 700;
    margin-top: 2px;
}

.card-sm .card-name {
    font-size: 0.9rem;
}

.card-district {
    font-size: 0.75rem;
    color: var(--muted);
}

/* ---- politician detail ---- */
.profile {
    display: flex;
    gap: 24px;
    align-items: flex-start;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-top: 24px;
}

.profile-photo {
    width: 128px;
    height: 128px;
    object-fit: cover;
    border-radius: var(--radius);
    background: #dfe3e8;
    flex-shrink: 0;
}

.avatar-xl {
    font-size: 3rem;
}

.profile-info h1 {
    margin: 0 0 6px;
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.party-chip {
    padding: 3px 12px;
    border-radius: 999px;
    background: #566072;
    color: #fff;
    font-size: 0.85rem;
    font-weight: 600;
}

.titles {
    margin: 0 0 10px;
    color: var(--primary);
    font-weight: 600;
}

.facts {
    margin: 0;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 4px 20px;
}

.facts div {
    display: flex;
    gap: 10px;
}

.facts dt {
    color: var(--muted);
    min-width: 64px;
    flex-shrink: 0;
}

.facts dd {
    margin: 0;
    word-break: break-all;
}

.legend {
    margin: 20px 0;
    padding: 12px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.88rem;
    color: var(--muted);
}

.entry-section {
    margin-bottom: 28px;
}

.entry-section h2 {
    font-size: 1.1rem;
    border-bottom: 2px solid var(--border);
    padding-bottom: 6px;
}

.entry {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 20px;
    margin-bottom: 12px;
}

.entry-head {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.entry-head h3 {
    margin: 0;
    font-size: 1.02rem;
}

.entry-head time {
    color: var(--muted);
    font-size: 0.85rem;
    margin-left: auto;
}

.entry-content {
    margin: 10px 0;
    white-space: pre-line;
}

.sources {
    margin: 0;
    padding-left: 18px;
    font-size: 0.88rem;
}

.entry-admin {
    margin-top: 8px;
    font-size: 0.85rem;
}

/* ---- admin ---- */
.admin-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 16px 0;
}

.admin-nav a {
    padding: 8px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-weight: 600;
}

.stat-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin: 16px 0 24px;
}

.stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
}

.stat strong {
    font-size: 1.5rem;
}

.stat span {
    color: var(--muted);
    font-size: 0.85rem;
}

.form-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 24px;
    margin-bottom: 20px;
}

.form-card h2 {
    margin-top: 0;
    font-size: 1.05rem;
}

.form-card label {
    display: block;
    margin: 12px 0;
    font-weight: 600;
    font-size: 0.92rem;
}

.form-card input[type="text"],
.form-card input[type="password"],
.form-card input[type="url"],
.form-card input[type="date"],
.form-card input[type="number"],
.form-card select,
.form-card textarea {
    display: block;
    width: 100%;
    margin-top: 4px;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.95rem;
    font-family: inherit;
    background: #fff;
    color: var(--text);
}

.field-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 0 14px;
}

fieldset {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin: 16px 0 8px;
    padding: 12px 16px;
}

legend {
    font-weight: 700;
    font-size: 0.92rem;
    padding: 0 6px;
}

.source-row {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 2fr auto;
    gap: 8px;
    align-items: center;
    margin-bottom: 8px;
}

.source-row input {
    margin-top: 0 !important;
}

.search-form {
    display: flex;
    gap: 8px;
    margin: 16px 0;
}

.search-form input {
    flex: 1;
    max-width: 320px;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
}

.position-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.position-list li {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}

.table-wrap {
    overflow-x: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.92rem;
}

th, td {
    padding: 10px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

td:nth-child(4), td:last-child {
    white-space: normal;
}

th {
    background: #f0f2f5;
    font-size: 0.85rem;
}

.input-sm {
    width: 80px;
    padding: 6px 8px;
    border: 1px solid var(--border);
    border-radius: 8px;
}

/* ---- bills / votes ---- */
.badge-neutral {
    background: #eef1f5;
    color: #4a5568;
}

.vote-bar {
    display: flex;
    margin-top: 10px;
    border-radius: 6px;
    overflow: hidden;
    font-size: 0.78rem;
    font-weight: 700;
    color: #fff;
    min-height: 24px;
}

.vote-bar > div {
    display: flex;
    align-items: center;
    padding: 2px 8px;
    white-space: nowrap;
    flex-basis: 0;
}

.vote-yes {
    background: #2f855a;
}

.vote-no {
    background: #c0392b;
}

.vote-blank {
    background: #a0aec0;
}

.vote-members {
    line-height: 1.9;
}

details summary {
    cursor: pointer;
    color: var(--primary);
    font-size: 0.9rem;
    margin-top: 6px;
}

.bill-row h3 a {
    color: var(--text);
}

/* ---- waste map / ranking ---- */
.waste-map-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 20px;
    margin-bottom: 28px;
}

.waste-map-section h2 {
    margin-top: 0;
    font-size: 1.05rem;
}

.waste-map-wrap {
    display: flex;
    flex-wrap: wrap;
    gap: 24px;
    align-items: flex-start;
}

.waste-map {
    display: grid;
    grid-template-columns: repeat(5, minmax(76px, 96px));
    grid-auto-rows: 68px;
    gap: 6px;
}

.map-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    text-align: center;
    padding: 4px;
}

.map-tile:hover {
    text-decoration: none;
    outline: 2px solid var(--primary);
}

.map-tile.tile-dark {
    color: #fff;
    border-color: transparent;
}

.map-tile.tile-selected {
    outline: 3px solid var(--primary);
}

.tile-name {
    font-weight: 700;
    font-size: 0.85rem;
}

.tile-amount {
    font-size: 0.68rem;
    line-height: 1.2;
    word-break: keep-all;
}

.map-side {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 160px;
}

.map-tile-wide {
    padding: 10px 14px;
}

.rank {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #34404f;
    color: #fff;
    font-weight: 700;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.waste-amount {
    margin-left: auto;
    font-weight: 800;
    color: var(--danger);
    white-space: nowrap;
}

/* ---- mobile ---- */
@media (max-width: 640px) {
    .page-title {
        font-size: 1.25rem;
    }

    .pyramid {
        padding: 12px;
    }

    .tier-members {
        grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
    }

    .card-lg .photo {
        width: 72px;
        height: 72px;
    }

    .card-md .photo {
        width: 56px;
        height: 56px;
    }

    .card-sm .photo {
        width: 44px;
        height: 44px;
    }

    .card-lg {
        min-width: 140px;
    }

    .card-md {
        min-width: 110px;
    }

    .profile {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .profile-info h1 {
        justify-content: center;
    }

    .facts div {
        justify-content: center;
    }

    .source-row {
        grid-template-columns: 1fr;
    }

    .entry-head time {
        margin-left: 0;
        width: 100%;
    }

    .waste-map {
        grid-template-columns: repeat(5, 1fr);
        grid-auto-rows: 56px;
        width: 100%;
    }

    .tile-amount {
        display: none;
    }

    .waste-amount {
        margin-left: 0;
        width: 100%;
    }
}
