:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --success: #16a34a;
    --warning: #d97706;
    --danger: #dc2626;
    --bg: #f7f8fb;
    --card: #ffffff;
    --text: #1f2937;
    --muted: #6b7280;
    --border: #e5e7eb;
    --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

/* Nav */
.navbar {
    background: #fff;
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 10;
}
.nav-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 12px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}
.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
    text-decoration: none;
}
.brand-logo {
    height: 32px;
    width: auto;
    display: block;
}
.brand-text {
    color: var(--text);
    border-left: 1px solid var(--border);
    padding-left: 12px;
    font-weight: 600;
}
@media (max-width: 600px) {
    .brand-text { display: none; }
}
.nav-links {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}
.nav-links a {
    color: var(--text);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
}
.nav-links a:hover { color: var(--primary); }
.user-tag {
    color: var(--muted);
    font-size: 13px;
    padding-left: 12px;
    border-left: 1px solid var(--border);
}
.btn-link {
    color: var(--danger) !important;
    font-weight: 500;
}
.btn-link-secondary {
    color: var(--muted) !important;
    font-weight: 500;
    font-size: 13px;
}

/* Layout */
.container {
    max-width: 1200px;
    margin: 24px auto;
    padding: 0 20px;
}
h1 { font-size: 28px; margin: 0 0 20px; }
h2 { font-size: 20px; margin: 0 0 16px; }
h3 { font-size: 16px; margin: 0 0 8px; }

.card {
    background: var(--card);
    border-radius: 10px;
    padding: 20px;
    box-shadow: var(--shadow);
    margin-bottom: 20px;
    border: 1px solid var(--border);
}

.two-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}
@media (max-width: 768px) {
    .two-col { grid-template-columns: 1fr; }
}

/* Auth */
.auth-card {
    max-width: 420px;
    margin: 60px auto;
    background: var(--card);
    padding: 32px;
    border-radius: 12px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

/* Forms */
.form { display: flex; flex-direction: column; gap: 14px; }
.form label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 500; }
.form input, .form textarea, .form select {
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
}
.form input:focus, .form textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}
.form-row { display: grid; grid-template-columns: 2fr 1fr; gap: 12px; }
.form-actions { display: flex; gap: 10px; margin-top: 8px; }

/* Buttons */
.btn {
    display: inline-block;
    padding: 9px 18px;
    border-radius: 6px;
    border: none;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: opacity 0.15s;
}
.btn:hover { opacity: 0.9; }
.btn-primary { background: var(--primary); color: white; }
.btn-secondary { background: #e5e7eb; color: var(--text); }
.btn-success { background: var(--success); color: white; }
.btn-warning { background: var(--warning); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-disabled { background: #d1d5db; color: var(--muted); cursor: not-allowed; }
.btn-sm { padding: 5px 11px; font-size: 12px; }

/* Stats grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.stat-card {
    background: var(--card);
    padding: 18px;
    border-radius: 10px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}
.stat-success { border-left: 4px solid var(--success); }
.stat-warning { border-left: 4px solid var(--warning); }
.stat-label { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; }
.stat-value { font-size: 32px; font-weight: 700; margin-top: 6px; }

/* Progress bar */
.progress-bar {
    background: #e5e7eb;
    border-radius: 8px;
    height: 24px;
    overflow: hidden;
    margin: 12px 0;
}
.progress-fill {
    background: linear-gradient(90deg, var(--primary), var(--success));
    height: 100%;
    color: white;
    text-align: center;
    line-height: 24px;
    font-size: 12px;
    font-weight: 600;
    transition: width 0.3s;
    min-width: 30px;
}

/* Table */
.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}
.table th, .table td {
    text-align: left;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
}
.table th {
    background: #f9fafb;
    font-weight: 600;
    font-size: 13px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.sub-row td { background: #f9fafb; }
.sub-detail { padding: 8px 0; font-size: 13px; }

/* Goal cards grid */
.goal-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}
.goal-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 18px;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow);
}
.goal-card h3 { margin: 10px 0 8px; }
.goal-card p { font-size: 14px; color: var(--muted); flex: 1; }
.goal-header { display: flex; justify-content: space-between; }

/* Badges */
.badge {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.badge-cat { background: #dbeafe; color: #1e40af; }
.badge-admin { background: #fce7f3; color: #9d174d; }
.badge-selected { background: #e0e7ff; color: #3730a3; }
.badge-submitted { background: #fef3c7; color: #92400e; }
.badge-approved { background: #dcfce7; color: #166534; }
.badge-rejected { background: #fee2e2; color: #991b1b; }
.badge-pending { background: #fef3c7; color: #92400e; }

.points-pill {
    display: inline-block;
    background: #fef3c7;
    color: #92400e;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
}

/* Flash messages */
.flash {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 14px;
}
.flash-success { background: #dcfce7; color: #166534; border: 1px solid #86efac; }
.flash-error   { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.flash-warning { background: #fef3c7; color: #92400e; border: 1px solid #fcd34d; }
.flash-info    { background: #dbeafe; color: #1e40af; border: 1px solid #93c5fd; }
.flash-reset   { background: #fef3c7; color: #78350f; border: 2px solid #f59e0b; }

.temp-pw-box {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
    padding: 12px 14px;
    background: #fffbeb;
    border: 1px dashed #f59e0b;
    border-radius: 6px;
}
.temp-pw {
    font-family: ui-monospace, Menlo, Consolas, monospace;
    font-size: 18px;
    font-weight: 700;
    color: #78350f;
    letter-spacing: 1px;
    user-select: all;
}
.copy-btn { margin-left: auto; }

/* Tabs */
.tabs {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 20px;
}
.tab {
    padding: 10px 18px;
    color: var(--muted);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    border-bottom: 2px solid transparent;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* Submission review */
.sub-review { border-left: 4px solid var(--warning); }
.sub-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.review-form { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); }
.proof-preview {
    max-width: 400px;
    max-height: 300px;
    border-radius: 8px;
    border: 1px solid var(--border);
    margin: 10px 0;
}
.review-comment {
    background: #f3f4f6;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 13px;
    margin-top: 6px;
}

/* Action row */
.action-row { display: flex; gap: 12px; flex-wrap: wrap; }

/* Footer */
.footer {
    text-align: center;
    color: var(--muted);
    padding: 24px;
    font-size: 12px;
}

/* Leaderboard */
.leaderboard-table tbody tr { transition: background 0.15s; }
.leaderboard-table tbody tr:hover { background: #f9fafb; }
.me-row { background: #fef9c3 !important; }
.me-row:hover { background: #fef08a !important; }
.rank-medal {
    font-weight: 700;
    font-size: 16px;
}
.rank-medal.gold { color: #ca8a04; }
.rank-medal.silver { color: #6b7280; }
.rank-medal.bronze { color: #b45309; }
.rank-num { font-weight: 600; color: var(--muted); }
.points-value { color: var(--primary); font-size: 18px; }

.participation-list { display: flex; flex-direction: column; gap: 14px; }
.participation-item {
    padding: 12px;
    background: #f9fafb;
    border-radius: 8px;
    border: 1px solid var(--border);
}
.participation-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}
.participants-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.chip {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 500;
    border: 1px solid transparent;
}
.chip-selected  { background: #e0e7ff; color: #3730a3; border-color: #c7d2fe; }
.chip-submitted { background: #fef3c7; color: #92400e; border-color: #fde68a; }
.chip-approved  { background: #dcfce7; color: #166534; border-color: #86efac; }
.chip-rejected  { background: #fee2e2; color: #991b1b; border-color: #fca5a5; }

.activity-feed { list-style: none; padding: 0; margin: 0; }
.activity-feed li {
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}
.activity-feed li:last-child { border-bottom: none; }

.legend { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.actions-cell { white-space: nowrap; }
.actions-cell .btn { margin-right: 4px; }

/* Rewards */
.my-points-card {
    text-align: center;
    background: linear-gradient(135deg, #fef3c7, #fde68a);
    border: 1px solid #fcd34d;
}
.my-points-label {
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #92400e;
    font-weight: 600;
}
.my-points-value {
    font-size: 56px;
    font-weight: 800;
    color: #78350f;
    line-height: 1;
    margin: 8px 0;
}

.reward-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.reward-card {
    background: var(--card);
    border-radius: 12px;
    padding: 22px;
    border: 2px solid var(--border);
    box-shadow: var(--shadow);
    position: relative;
    transition: transform 0.15s, box-shadow 0.15s;
}
.reward-card.unlocked {
    border-color: var(--success);
    background: linear-gradient(135deg, #ffffff, #f0fdf4);
}
.reward-card.locked {
    opacity: 0.75;
}
.reward-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 14px rgba(0,0,0,0.08);
}
.reward-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}
.reward-tier-icon {
    font-size: 40px;
    line-height: 1;
}
.reward-threshold {
    text-align: right;
}
.threshold-num {
    font-size: 28px;
    font-weight: 700;
    color: var(--primary);
}
.threshold-label {
    display: block;
    font-size: 11px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}
.reward-card h3 {
    font-size: 18px;
    margin: 6px 0 8px;
}
.reward-status {
    margin-top: 14px;
    text-align: center;
}

/* Settings page */
.settings-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}
@media (max-width: 768px) {
    .settings-grid { grid-template-columns: 1fr; }
}

/* Dashboard reward preview */
.reward-preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    flex-wrap: wrap;
    gap: 8px;
}
.reward-preview-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 10px;
    margin-bottom: 14px;
}
.reward-preview-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #f9fafb;
    transition: border-color 0.15s;
}
.reward-preview-item.unlocked {
    border-color: var(--success);
    background: linear-gradient(135deg, #ffffff, #f0fdf4);
}
.reward-preview-item.locked {
    opacity: 0.75;
}
.reward-preview-icon {
    font-size: 26px;
    line-height: 1;
}
.reward-preview-info {
    flex: 1;
    min-width: 0;
}
.reward-preview-threshold {
    font-size: 12px;
    font-weight: 700;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.reward-preview-name {
    font-size: 13px;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.reward-preview-status .badge {
    font-size: 13px;
    padding: 4px 8px;
}

/* Utility */
.muted { color: var(--muted); }
.small { font-size: 12px; }
