:root {
    --pink: #f8b6dc;
    --pink-soft: #fbc8d6;
    --pink-deep: #c2186b;
    --ink: #111;
    --line: #222;
    --bg: #fdf3f8;
    --card: #fff;
    --muted: #6b5a63;
    --radius: 14px;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: "Hind", "Noto Sans Devanagari", system-ui, sans-serif;
    color: var(--ink);
    background: var(--bg);
    line-height: 1.5;
}
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }

/* ---------- Top bar ---------- */
.topbar { background: #111; color: #fff; padding: 10px 0; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand img { width: 48px; height: 48px; border-radius: 50%; object-fit: cover; border: 2px solid var(--pink); }
.brand strong { display: block; font-size: 1.15rem; }
.brand span { font-size: .85rem; color: #f5c6de; }

/* ---------- Layout ---------- */
.layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 520px);
    gap: 28px;
    padding-top: 24px;
    padding-bottom: 24px;
    align-items: start;
}
.col-ballot { position: sticky; top: 16px; }
@media (max-width: 960px) {
    .layout { grid-template-columns: 1fr; }
    .col-ballot { position: static; }
}

.card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 22px;
    box-shadow: 0 2px 14px rgba(194, 24, 107, .08);
    margin-bottom: 20px;
}
.card h2 { margin: 0 0 4px; font-size: 1.45rem; }
.card h3 { margin: 0 0 12px; }

/* ---------- Search form ---------- */
.search-form { display: grid; gap: 14px; margin-top: 14px; }
.search-form label span { display: block; font-weight: 600; margin-bottom: 4px; }
.search-form em { font-style: normal; font-weight: 400; color: var(--muted); font-size: .9em; }
.search-form input, .search-form select {
    width: 100%;
    padding: 11px 12px;
    font: inherit;
    border: 1.5px solid #e3c5d4;
    border-radius: 10px;
    background: #fff;
}
.search-form input:focus, .search-form select:focus {
    outline: none; border-color: var(--pink-deep); box-shadow: 0 0 0 3px rgba(194, 24, 107, .15);
}
.form-actions { display: flex; gap: 10px; }

.btn {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 11px 22px; border-radius: 10px; border: 0; cursor: pointer;
    font: inherit; font-weight: 600; text-decoration: none;
}
.btn-primary { background: var(--pink-deep); color: #fff; }
.btn-primary:hover { background: #a01258; }
.btn-ghost { background: #f3e3eb; color: var(--ink); }
.btn-whatsapp { background: #25d366; color: #fff; }

.alert { background: #fff4e5; border-left: 4px solid #f59e0b; padding: 12px; margin: 0; border-radius: 6px; }
.alert-danger { background: #fdecec; border-left-color: #b91c1c; margin-bottom: 14px; }

/* ---------- Results ---------- */
.result-list { list-style: none; margin: 0; padding: 0; }
.result-list li + li { border-top: 1px solid #f1dde7; }
.result-list a {
    display: flex; justify-content: space-between; align-items: center; gap: 12px;
    padding: 12px 8px; color: inherit; text-decoration: none; border-radius: 8px;
}
.result-list a:hover { background: #fdeef5; }
.r-main strong { font-size: 1.1rem; }
.r-main small { color: var(--muted); margin-left: 6px; }
.r-main .muted { display: block; font-size: .92rem; }
.r-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.pill { background: var(--pink); padding: 2px 10px; border-radius: 99px; font-size: .85rem; font-weight: 600; white-space: nowrap; }
.pill-district { background: #fff; border: 1.5px solid var(--pink); }
.pill-deleted { background: #b91c1c; color: #fff; }
.r-go { color: var(--pink-deep); font-weight: 600; white-space: nowrap; }
@media (max-width: 560px) {
    .result-list a { flex-direction: column; align-items: flex-start; }
    .r-meta { justify-content: flex-start; }
}
.pager { display: flex; justify-content: space-between; align-items: center; margin-top: 14px; }
.pager a { color: var(--pink-deep); font-weight: 600; text-decoration: none; }

/* ---------- Ballot paper (matches printed sample) ---------- */
.ballot {
    background: var(--pink);
    border: 4px solid var(--ink);
    padding: 18px 14px 14px;
    font-family: "Khand", "Hind", sans-serif;
    box-shadow: 0 0 0 8px var(--pink);
    margin: 8px;
}
.ballot-title {
    margin: 0;
    text-align: center;
    font-size: clamp(1.5rem, 5vw, 2.3rem);
    font-weight: 700;
    line-height: 1.15;
}
.ballot-badge {
    display: block;
    width: fit-content;
    margin: 8px auto 18px;
    background: var(--ink);
    color: #fff;
    font-size: clamp(1.4rem, 4.6vw, 2.1rem);
    font-weight: 700;
    padding: 0 30px;
    border-radius: 999px;
    line-height: 1.5;
}
.ballot-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.ballot-table th, .ballot-table td {
    border: 2px solid var(--line);
    text-align: center;
    vertical-align: middle;
}
.ballot-table th {
    font-size: clamp(.8rem, 2.2vw, 1.05rem);
    font-weight: 700;
    line-height: 1.15;
    padding: 8px 4px;
}
.ballot-table .c-sn { width: 17%; }
.ballot-table .c-name { width: 30%; }
.ballot-table .c-photo { width: 24%; }
.ballot-table .c-mark { width: 23%; }
.ballot-table td { height: 50px; font-size: 1.1rem; }
.ballot-table td.c-sn { font-family: Arial, Helvetica, sans-serif; font-weight: 900; font-size: clamp(1.3rem, 3.6vw, 1.75rem); }
.ballot-table tr.is-candidate td { height: 112px; }
.ballot-table tr.is-candidate .c-name {
    font-size: clamp(1.05rem, 3.2vw, 1.55rem);
    font-weight: 700;
    line-height: 1.1;
    padding: 4px;
}
.ballot-table tr.is-candidate .c-photo { padding: 4px; }
.ballot-table .c-photo img { width: 100%; max-width: 110px; aspect-ratio: 1 / 1; object-fit: cover; display: block; margin: 0 auto; }
.mark-box {
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--pink-soft);
    width: 56%; max-width: 64px; aspect-ratio: 4 / 5;
    font-family: Arial, Helvetica, sans-serif;
    font-weight: 900;
    font-size: clamp(2rem, 6vw, 3rem);
    animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(194, 24, 107, .0); }
    50%      { box-shadow: 0 0 0 5px rgba(194, 24, 107, .35); }
}
.ballot-note { text-align: center; margin: 14px 8px 0; font-size: 1.05rem; }

/* ---------- Voter slip ---------- */
.slip-head { border-bottom: 2px dashed #e3c5d4; padding-bottom: 10px; margin-bottom: 14px; }
.slip-grid { display: grid; grid-template-columns: 140px 1fr; gap: 8px 14px; margin: 0; }
.slip-grid dt { font-weight: 600; color: var(--muted); }
.slip-grid dd { margin: 0; }
@media (max-width: 480px) { .slip-grid { grid-template-columns: 1fr; gap: 0; } .slip-grid dd { margin-bottom: 8px; } }
.slip-highlight { display: flex; gap: 12px; margin-top: 18px; }
.slip-highlight div { flex: 1; background: var(--pink); border-radius: 10px; padding: 10px; text-align: center; }
.slip-highlight small { display: block; font-weight: 600; }
.slip-highlight b { font-size: 1.8rem; font-family: Arial, sans-serif; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; }

/* ---------- Polling-day instructions ---------- */
.instructions {
    background: var(--card);
    border-radius: var(--radius);
    border-top: 6px solid var(--pink-deep);
    box-shadow: 0 2px 14px rgba(194, 24, 107, .08);
    padding: 20px;
    margin-bottom: 24px;
    font-size: 1.05rem;
    color: var(--ink);
}
.instructions .notice {
    background: var(--pink);
    border: 3px solid var(--ink);
    border-radius: 10px;
    color: var(--ink);
    font-weight: 700;
    font-size: clamp(1.05rem, 2.6vw, 1.3rem);
    text-align: center;
    padding: 12px 16px;
}
.instructions .notice-final { background: var(--ink); color: #fff; }
.instructions .notice-final .hl {
    display: inline-block;
    background: var(--pink);
    color: var(--ink);
    border-radius: 6px;
    padding: 0 8px;
    margin: 0 2px;
}
.instructions .divider { border: 0; border-top: 2px dashed var(--pink); margin: 22px 0 18px; }
.instructions h2 { color: var(--pink-deep); font-weight: 700; font-size: clamp(1.4rem, 3.4vw, 1.75rem); margin: 0 0 10px; }
.instructions p { margin: 0 0 10px; }
.instructions ul { margin: 0 0 18px; padding-left: 20px; }
.instructions li { margin-bottom: 8px; }
.instructions li::marker { color: var(--pink-deep); }

.foot {text-align: center; color: var(--muted); font-size: .85rem; padding-bottom: 24px; }

.pdf-status { margin: 10px 0 0; font-weight: 600; color: var(--pink-deep); }
.btn:disabled { opacity: .6; cursor: wait; }

/* ---------- PDF capture: fixed-width two columns, fits one A4 page ---------- */
.pdf-mode #pdf-area { width: 1100px; background: #fff; }
.pdf-mode .slip-grid { grid-template-columns: 140px 1fr; gap: 8px 14px; }
.pdf-mode .slip-grid dd { margin: 0; }
.pdf-mode .layout { grid-template-columns: minmax(0, 1fr) 500px; gap: 20px; padding-top: 12px; padding-bottom: 12px; }
.pdf-mode .col-ballot { position: static; }
.pdf-mode .card { box-shadow: none; border: 1px solid #e3c5d4; }
.pdf-mode .mark-box { animation: none; }
.pdf-mode .no-print { display: none !important; }
.pdf-mode .wrap { max-width: none; padding: 0 28px; }
/* fixed text sizes so a PDF made on a phone matches one made on a desktop */
.pdf-mode .ballot-title { font-size: 2.3rem; }
.pdf-mode .ballot-badge { font-size: 2.1rem; }
.pdf-mode .ballot-table th { font-size: 1.05rem; }
.pdf-mode .ballot-table td.c-sn { font-size: 1.75rem; }
.pdf-mode .ballot-table tr.is-candidate .c-name { font-size: 1.55rem; }
.pdf-mode .mark-box { font-size: 3rem; }
.pdf-mode .instructions .notice { font-size: 1.3rem; }
.pdf-mode .instructions h2 { font-size: 1.75rem; }

/* ---------- Print ---------- */
@media print {
    body { background: #fff; }
    .no-print { display: none !important; }
    .layout { display: block; padding: 0; }
    .card { box-shadow: none; border: 1px solid #ccc; }
    .ballot, .slip-highlight div, .mark-box, .pill { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .mark-box { animation: none; }
    .instructions, .instructions .notice { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .instructions { page-break-inside: avoid; }
    .col-ballot { page-break-inside: avoid; }
}
