:root {
    --primary: #e74c3c;
    --primary-dark: #c0392b;
    --secondary: #3498db;
    --success: #2ecc71;
    --dark: #2c3e50;
    --light: #ecf0f1;
    --card-bg: rgba(255, 255, 255, 0.95);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    min-height: 100vh;
    color: var(--dark);
    padding-bottom: 80px;
}

.hero {
    padding: 30px clamp(20px, 4vw, 60px);
    position: relative;
    overflow: hidden;
}

.hero-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    position: relative;
    z-index: 1;
}

.hero-title {
    text-align: left;
    min-width: 0;
    flex: 1 1 auto;
}

.pulse-bg {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, rgba(231, 76, 60, 0.3) 0%, transparent 70%);
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: translate(-50%, -50%) scale(1); opacity: 0.5; }
    50% { transform: translate(-50%, -50%) scale(1.5); opacity: 0.2; }
}

.hero h1 {
    color: #fff;
    font-size: 2.5rem;
    font-weight: 800;
    text-shadow: 0 4px 20px rgba(231, 76, 60, 0.5);
    position: relative;
    z-index: 1;
}

.hero .subtitle {
    color: rgba(255, 255, 255, 0.8);
    margin-top: 10px;
    font-size: 1.1rem;
}

.total-counter {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    padding: 16px 32px;
    border-radius: 20px;
    flex: 0 0 auto;
    text-align: center;
    box-shadow: 0 10px 40px rgba(231, 76, 60, 0.4);
    white-space: nowrap;
}


.total-counter #total-donations {
    display: block;
    color: #fff;
    font-size: 3rem;
    font-weight: 800;
}

.total-counter .label {
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.donation-container {
    max-width: 500px;
    margin: 0 auto;
    padding: 0 20px;
    position: relative;
}

.donation-card {
    background: var(--card-bg);
    border-radius: 24px;
    padding: 30px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.donation-card h2 {
    text-align: center;
    margin-bottom: 25px;
    color: var(--dark);
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--dark);
}

.form-group select,
.form-group input {
    width: 100%;
    padding: 15px 20px;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    font-size: 1rem;
    font-family: inherit;
    transition: all 0.3s ease;
    background: #fff;
}

.form-group select:focus,
.form-group input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(231, 76, 60, 0.1);
}

.donate-btn {
    width: 100%;
    padding: 18px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    border: none;
    border-radius: 12px;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
}

.donate-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 30px rgba(231, 76, 60, 0.4);
}

.donate-btn:active {
    transform: translateY(0);
}

.btn-glow {
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.3) 0%, transparent 60%);
    opacity: 0;
    transition: opacity 0.3s;
}

.donate-btn:hover .btn-glow {
    opacity: 1;
    animation: shine 1s infinite;
}

@keyframes shine {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.message {
    margin-top: 15px;
    padding: 12px;
    border-radius: 8px;
    text-align: center;
}

.message.error {
    background: #fee;
    color: #c00;
    border: 1px solid #fcc;
}

.message.success {
    background: #efe;
    color: #090;
    border: 1px solid #cfc;
}

.success-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.success-overlay.show {
    opacity: 1;
    visibility: visible;
}

.success-content {
    text-align: center;
    color: #fff;
    transform: scale(0.8);
    transition: transform 0.4s ease;
}

.success-overlay.show .success-content {
    transform: scale(1);
}

.heart-beat {
    font-size: 5rem;
    animation: heartbeat 1s ease-in-out infinite;
}

@keyframes heartbeat {
    0%, 100% { transform: scale(1); }
    25% { transform: scale(1.2); }
    50% { transform: scale(1); }
    75% { transform: scale(1.1); }
}

.success-content h2 {
    font-size: 2rem;
    margin: 20px 0;
    color: var(--success);
}

.success-content p {
    font-size: 1.3rem;
    margin-bottom: 30px;
    color: rgba(255, 255, 255, 0.8);
}

.next-btn {
    padding: 15px 40px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 30px;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s;
}

.next-btn:hover {
    background: var(--primary-dark);
    transform: scale(1.05);
}

.confetti {
    position: absolute;
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

@keyframes confetti-fall {
    0% { transform: translateY(-100vh) rotate(0deg); opacity: 1; }
    100% { transform: translateY(100vh) rotate(720deg); opacity: 0; }
}

.page-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: rgba(15, 20, 40, 0.97);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    padding: 12px 20px;
    gap: 12px;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.4);
    z-index: 100;
}

.footer-donate-btn {
    flex: 1;
    padding: 14px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(231, 76, 60, 0.4);
}

.footer-donate-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(231, 76, 60, 0.5);
}

.footer-admin-link,
.footer-lang-btn {
    padding: 14px 16px;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 600;
    color: #fff;
    border-radius: 12px;
    background: rgba(255,255,255,0.08);
    transition: background 0.2s;
    white-space: nowrap;
}

.footer-admin-link:hover,
.footer-lang-btn:hover {
    background: rgba(255,255,255,0.15);
}

.leaderboard-page {
    padding: 20px clamp(12px, 3vw, 40px);
    max-width: min(1400px, 95vw);
    margin: 0 auto;
}

.leaderboard-page header {
    text-align: center;
    margin-bottom: 30px;
}

.leaderboard-page h1 {
    color: #fff;
    font-size: 2rem;
}

.leaderboard-page .subtitle {
    color: rgba(255, 255, 255, 0.7);
}

.stats-summary {
    display: flex;
    gap: 20px;
    margin-bottom: 30px;
}

.stat-box {
    flex: 1;
    background: var(--card-bg);
    padding: 20px;
    border-radius: 16px;
    text-align: center;
}

.stat-number {
    display: block;
    font-size: 2rem;
    font-weight: 800;
    color: var(--primary);
}

.stat-label {
    color: #666;
    font-size: 0.9rem;
}

.chart-container {
    background: var(--card-bg);
    padding: 20px;
    border-radius: 16px;
    margin-bottom: 30px;
}

.ranking-list {
    background: var(--card-bg);
    border-radius: 16px;
    overflow: hidden;
}

.ranking-header {
    display: grid;
    grid-template-columns: 60px 1fr 80px;
    padding: 15px 20px;
    background: var(--dark);
    color: #fff;
    font-weight: 600;
}

.ranking-item {
    display: grid;
    grid-template-columns: 60px 1fr 80px;
    padding: 15px 20px;
    border-bottom: 1px solid #eee;
    align-items: center;
    transition: all 0.3s;
}

.ranking-item:hover {
    background: #f9f9f9;
    transform: translateX(10px);
}

.ranking-item:first-child {
    background: linear-gradient(90deg, #ffd700, #ffed4a);
}

.ranking-item:nth-child(2) {
    background: linear-gradient(90deg, #c0c0c0, #e8e8e8);
}

.ranking-item:nth-child(3) {
    background: linear-gradient(90deg, #cd7f32, #e8a86d);
}

.rank-medal {
    font-size: 1.5rem;
}

.org-name {
    font-weight: 600;
}

.donation-count {
    font-weight: 800;
    color: var(--primary);
    font-size: 1.2rem;
}

.admin-page {
    padding: 20px;
    max-width: 600px;
    margin: 0 auto;
}

.admin-page header {
    text-align: center;
    margin-bottom: 30px;
}

.admin-page h1 {
    color: #fff;
    font-size: 1.8rem;
}

.admin-page .subtitle {
    color: rgba(255, 255, 255, 0.7);
}

.admin-card {
    background: var(--card-bg);
    padding: 20px;
    border-radius: 16px;
    margin-bottom: 20px;
}

.admin-card h2,
.admin-card h3 {
    margin-bottom: 15px;
    color: var(--dark);
}

.form-row {
    display: flex;
    gap: 10px;
}

.color-group {
    width: 60px;
}

.color-group input {
    width: 100%;
    height: 50px;
    border: none;
    cursor: pointer;
}

.admin-btn {
    padding: 12px 24px;
    background: var(--secondary);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.admin-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(52, 152, 219, 0.4);
}

.admin-btn.primary {
    background: var(--primary);
}

.admin-btn.danger {
    background: #c00;
}

.org-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.org-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px;
    background: #f5f5f5;
    border-radius: 8px;
}

.org-color {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    margin-right: 10px;
}

.org-thumb {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    object-fit: cover;
}

.org-rank-img {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    object-fit: cover;
    margin-right: 10px;
}

.org-info {
    display: flex;
    align-items: center;
}

.org-actions {
    display: flex;
    gap: 5px;
}

.edit-org-btn {
    background: var(--secondary);
    color: #fff;
    border: none;
    padding: 5px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
}

.delete-org {
    background: #c00;
    color: #fff;
    border: none;
    padding: 5px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
}

.color-group label {
    font-size: 0.75rem;
    color: #666;
    display: block;
    margin-bottom: 4px;
}

.time-filter {
    display: flex;
    gap: 8px;
    margin-bottom: 15px;
}

.time-btn {
    padding: 6px 14px;
    background: var(--dark);
    color: #fff;
    border: none;
    border-radius: 16px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.3s;
}

.time-btn.active {
    background: var(--primary);
}

.time-btn:hover:not(.active) {
    background: #444;
}

.timeline-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.timeline-header h3 {
    color: var(--dark);
    font-size: 1.1rem;
}

.hint {
    color: #666;
    font-size: 0.85rem;
    margin-bottom: 10px;
}

/* --- Top-3 badges below bar chart --- */
#org-badges {
    display: flex;
    justify-content: center;
    align-items: flex-end;
    gap: 20px;
    margin-top: 16px;
    flex-wrap: wrap;
}

.org-badge {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 4px 0;
    transition: transform 0.2s;
}

.org-badge:hover {
    transform: translateY(-2px);
}

.badge-medal {
    font-size: 2rem;
}

.badge-name {
    font-weight: 700;
    color: #111;
    border-bottom: 3px solid currentColor;
    padding-bottom: 2px;
    text-align: center;
}

.badge-count {
    color: #444;
    font-weight: 600;
}

.badge-links {
    display: flex;
    gap: 6px;
    justify-content: center;
}

.badge-link {
    font-size: 1rem;
    text-decoration: none;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.badge-link:hover {
    opacity: 1;
}

/* rank-based sizing: 1st > 2nd > 3rd */
.org-badge[data-rank="1"] .badge-medal  { font-size: 2.4rem; }
.org-badge[data-rank="1"] .badge-name   { font-size: 1.1rem; }
.org-badge[data-rank="1"] .badge-count  { font-size: 1rem; }

.org-badge[data-rank="2"] .badge-medal  { font-size: 2rem; }
.org-badge[data-rank="2"] .badge-name   { font-size: 0.95rem; }
.org-badge[data-rank="2"] .badge-count  { font-size: 0.9rem; }

.org-badge[data-rank="3"] .badge-medal  { font-size: 1.6rem; }
.org-badge[data-rank="3"] .badge-name   { font-size: 0.85rem; }
.org-badge[data-rank="3"] .badge-count  { font-size: 0.8rem; }

/* --- Donation modal --- */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 300;
    backdrop-filter: blur(4px);
    padding: 20px;
}

.modal-card {
    background: #fff;
    border-radius: 24px;
    padding: 30px 24px 36px;
    width: 100%;
    max-width: 500px;
    position: relative;
    animation: modal-in 0.25s ease;
}

@keyframes modal-in {
    from { transform: scale(0.92); opacity: 0; }
    to   { transform: scale(1);    opacity: 1; }
}

.modal-card h2 {
    text-align: center;
    margin-bottom: 24px;
    color: var(--dark);
}

.modal-close {
    position: absolute;
    top: 16px;
    right: 20px;
    background: #eee;
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    background: #ddd;
}

/* --- Admin header --- */
.admin-header-meta {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-top: 8px;
}

.admin-user {
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.9rem;
}

.logout-btn {
    padding: 6px 14px;
    font-size: 0.85rem;
    text-decoration: none;
    display: inline-block;
}

.error-msg {
    color: #c00;
    margin-top: 10px;
    text-align: center;
}

.success-msg {
    color: #090;
    margin-top: 10px;
    text-align: center;
}

.danger-zone {
    border: 2px solid #c00;
}

.hidden {
    display: none !important;
}

.drag-handle {
    color: #aaa;
    font-size: 1.2rem;
    cursor: grab;
    user-select: none;
    padding: 0 4px;
}

.org-item.drag-over {
    border: 2px dashed var(--secondary);
    background: #eaf4ff;
}

@media (max-width: 600px) {
    .hero-row {
        flex-direction: column;
        align-items: flex-start;
    }

    .hero-title {
        text-align: left;
    }

    .hero h1 {
        font-size: 1.8rem;
    }

    .total-counter #total-donations {
        font-size: 2.5rem;
    }

    .form-row {
        flex-direction: column;
    }
}