:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --bg: #f3f4f6;
    --text: #1f2937;
    --muted: #6b7280;
    --border: #d1d5db;
    --green: #16a34a;
    --red: #dc2626;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { margin: 0; padding: 0; }
body {
    font-family: 'Poppins', system-ui, -apple-system, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
}

.page {
    flex: 1;
    width: 100%;
    max-width: 72rem;
    margin: 0 auto;
    padding: 2rem 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2rem;
}
@media (min-width: 1024px) {
    .page { flex-direction: row; justify-content: space-between; gap: 3rem; padding: 3rem 1rem; }
}

/* ---------- hero ---------- */
.hero {
    display: flex;
    flex-direction: column;
    gap: .75rem;
    width: 100%;
    max-width: 42rem;
    font-weight: 900;
    font-size: 2.25rem;
    line-height: 1.1;
    letter-spacing: -.025em;
    user-select: none;
}
@media (min-width: 768px) { .hero { font-size: 3rem; gap: 1.5rem; } }
@media (min-width: 1024px) { .hero { font-size: 3.75rem; } }

.hero span { display: inline-block; cursor: default; text-shadow: 0 1px 2px rgba(0,0,0,.08); transform-origin: left; }
.hero .indent { margin-left: 1.5rem; }
@media (min-width: 1024px) { .hero .indent { margin-left: 3rem; } }
.c-rose { color: #f43f5e; }
.c-purple { color: #9333ea; }
.c-orange { color: #f97316; }
.c-green { color: #10b981; }

@keyframes slideInLeft {
    0% { transform: translateX(-100vw); opacity: 0; }
    80% { transform: translateX(20px); opacity: 1; }
    100% { transform: translateX(0); opacity: 1; }
}
@keyframes slideInRight {
    0% { transform: translateX(100vw); opacity: 0; }
    80% { transform: translateX(-20px); opacity: 1; }
    100% { transform: translateX(0); opacity: 1; }
}
@keyframes wobble {
    0%, 100% { transform: translateX(0) rotate(0) scale(1); }
    15% { transform: translateX(-5px) rotate(-4deg) scale(1.05); }
    30% { transform: translateX(4px) rotate(4deg) scale(1.05); }
    45% { transform: translateX(-3px) rotate(-2deg) scale(1.05); }
    60% { transform: translateX(2px) rotate(2deg) scale(1.05); }
    75% { transform: translateX(-1px) rotate(-1deg) scale(1.05); }
}
@keyframes spin { to { transform: rotate(360deg); } }

.slide-left { animation: slideInLeft 1s ease-out both; }
.slide-right { animation: slideInRight 1s ease-out both; }
.wobble:hover { animation: wobble .8s ease-in-out infinite; }

@media (prefers-reduced-motion: reduce) {
    .slide-left, .slide-right, .wobble:hover { animation: none; }
}

/* ---------- card ---------- */
.card {
    width: 100%;
    max-width: 28rem;
    flex-shrink: 0;
    background: #fff;
    border-radius: 1rem;
    box-shadow: 0 20px 25px -5px rgba(0,0,0,.1), 0 8px 10px -6px rgba(0,0,0,.1);
    padding: 1.25rem;
}
@media (min-width: 768px) { .card { padding: 1.5rem; } }

.center { text-align: center; }
.muted { color: var(--muted); font-size: .875rem; margin: 0; }
.card-head { text-align: center; margin-bottom: 1.5rem; }
.card-head h1 { font-size: 1.25rem; margin: 0 0 .25rem; }

.icon-circle {
    width: 3rem; height: 3rem; border-radius: 999px;
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto .5rem;
}
.icon-circle.small { width: 2.5rem; height: 2.5rem; }
.icon-circle.blue { background: #eff6ff; color: var(--primary); }
.icon-circle.green { background: #dcfce7; color: var(--green); }
.icon-circle.red { background: #fee2e2; color: var(--red); }
.icon-circle.amber { background: #fef3c7; color: #d97706; }

label { display: block; font-size: .875rem; font-weight: 500; margin: 1rem 0 .375rem; }
label:first-of-type { margin-top: 0; }
.input-wrap { position: relative; }
.input-icon { position: absolute; left: .75rem; top: 50%; transform: translateY(-50%); color: #9ca3af; pointer-events: none; }
input[type=text], input[type=tel] {
    width: 100%;
    padding: .75rem 1rem .75rem 2.5rem;
    border: 1px solid var(--border);
    border-radius: .5rem;
    font: inherit;
    font-size: 1rem;
    letter-spacing: .1em;
    transition: box-shadow .15s, border-color .15s;
}
input:focus { outline: none; border-color: transparent; box-shadow: 0 0 0 2px var(--primary); }
input:disabled { background: #f9fafb; }
.upper { text-transform: uppercase; }
.upper::placeholder { text-transform: none; }
.hint { font-size: .7rem; color: var(--muted); margin: .25rem 0 0; }

.btn {
    border: 0; border-radius: .5rem; cursor: pointer;
    font: inherit; font-weight: 600; font-size: 1rem;
    padding: .75rem 1rem;
    display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
    transition: background-color .15s, opacity .15s;
}
.btn:disabled { opacity: .65; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
#pay-btn { width: 100%; margin-top: 1.5rem; }
.btn-sm { font-size: .875rem; padding: .55rem .75rem; flex: 1; }
.btn-light { background: #fff; color: #374151; border: 1px solid var(--border); }
.btn-light:hover:not(:disabled) { background: #f9fafb; }
.btn-retry { width: 100%; background: #ea580c; color: #fff; font-size: .95rem; }
.btn-retry:hover:not(:disabled) { background: #c2410c; }

.secure-note { display: flex; align-items: center; justify-content: center; gap: .3rem; font-size: .7rem; color: var(--muted); margin: .6rem 0 0; }

.msg { padding: .6rem .75rem; border-radius: .5rem; font-size: .8rem; line-height: 1.45; margin: .5rem 0 .75rem; text-align: left; white-space: pre-line; }
.msg-red { background: #fef2f2; border: 1px solid #fecaca; color: #b91c1c; text-align: center; margin-top: 0; }
.msg-blue { background: #eff6ff; border: 1px solid #bfdbfe; color: #1e40af; }
.msg-yellow { background: #fefce8; border: 1px solid #fde68a; color: #854d0e; }
.msg-green { background: #f0fdf4; border: 1px solid #bbf7d0; color: #166534; }

/* ---------- processing ---------- */
#view-processing { padding: 1.5rem 0; }
#view-processing h2 { font-size: 1.1rem; margin: 0 0 .25rem; }
.spinner {
    width: 2.5rem; height: 2.5rem; margin: 0 auto 1rem;
    border: 4px solid #dbeafe; border-top-color: var(--primary); border-radius: 999px;
    animation: spin 1s linear infinite;
}

/* ---------- result ---------- */
#result-title { font-size: 1.1rem; margin: 0 0 .25rem; }
.green-text { color: var(--green); }
.red-text { color: var(--red); }
.amber-text { color: #d97706; }

.actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: .75rem; }
#retry-info { margin: -.25rem 0 .75rem; }

.receipt { background: #f9fafb; border: 1px solid #e5e7eb; border-radius: .5rem; padding: .75rem; }
.receipt-head { text-align: center; border-bottom: 1px solid #d1d5db; padding-bottom: .4rem; margin-bottom: .5rem; }
.receipt-head h3 { font-size: .9rem; margin: 0; }
.receipt-head p { font-size: .6rem; color: var(--muted); margin: 0; }
.receipt dl { margin: 0; font-size: .78rem; }
.receipt dl > div { display: flex; justify-content: space-between; gap: 1rem; padding: .2rem 0; }
.receipt dt { color: #4b5563; }
.receipt dd { margin: 0; font-weight: 600; text-align: right; word-break: break-all; }
.receipt .r-status { border-top: 1px dashed #d1d5db; margin-top: .4rem; padding-top: .5rem; }
.r-note { margin-top: .4rem; padding: .4rem; border-radius: .25rem; font-size: .65rem; font-weight: 500; text-align: center; }
.r-note.ok { background: #f0fdf4; color: #15803d; border: 1px solid #bbf7d0; }
.r-note.bad { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }
.r-note.wait { background: #fefce8; color: #854d0e; border: 1px solid #fde68a; }
.r-note:empty { display: none; }

.disclaimer { text-align: center; font-size: .7rem; color: #9ca3af; padding: 0 1rem 1rem; }

/* ---------- print: receipt only, top-left ---------- */
@media print {
    html, body { background: #fff !important; display: block !important; min-height: 0 !important; }
    .page { display: block !important; padding: 0 !important; margin: 0 !important; max-width: none !important; }
    @page { margin: .5cm; }
    .no-print { display: none !important; }
    .print-container { box-shadow: none !important; border: 0 !important; padding: 0 !important; margin: 0 !important; max-width: 100% !important; }
    .print-receipt-box { border: 2px solid #000 !important; padding: 15px !important; border-radius: 8px !important; background: transparent !important; }
}

/* ---------- portal paused (voter API down) ---------- */
#view-paused { padding: 1rem 0 .5rem; }
#view-paused h2 { font-size: 1.25rem; margin: 0 0 .5rem; }
#view-paused .msg { text-align: center; font-size: .9rem; }
