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

:root {
    --bg: #0c0f1a;
    --bg-card: rgba(255,255,255,0.03);
    --bg-card-hover: rgba(255,255,255,0.05);
    --bg-input: rgba(255,255,255,0.05);
    --border: rgba(255,255,255,0.06);
    --border-hover: rgba(255,255,255,0.12);
    --text: #e2e8f0;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --text-faint: #475569;
    --primary: #6366f1;
    --primary-light: #818cf8;
    --primary-bg: rgba(99,102,241,0.1);
    --primary-border: rgba(99,102,241,0.2);
    --green: #22c55e;
    --green-bg: rgba(34,197,94,0.08);
    --green-border: rgba(34,197,94,0.25);
    --amber: #f59e0b;
    --amber-bg: rgba(245,158,11,0.08);
    --amber-border: rgba(245,158,11,0.25);
    --red: #ef4444;
    --red-bg: rgba(239,68,68,0.08);
    --red-border: rgba(239,68,68,0.25);
    --sidebar-width: 240px;
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;
}

body {
    font-family: 'DM Sans', -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
}

/* Layout */
.app-layout { display: flex; min-height: 100vh; }

.sidebar {
    position: fixed; left: 0; top: 0; bottom: 0;
    width: var(--sidebar-width);
    background: linear-gradient(180deg, #111528 0%, #0c0f1a 100%);
    border-right: 1px solid var(--border);
    display: flex; flex-direction: column;
    padding: 24px 0;
    z-index: 100;
}

.sidebar-brand {
    display: flex; align-items: center; gap: 12px;
    padding: 0 24px; margin-bottom: 32px;
    color: var(--primary-light); font-weight: 800; font-size: 16px;
}

.sidebar-nav { flex: 1; display: flex; flex-direction: column; gap: 2px; }

.nav-item {
    display: flex; align-items: center; gap: 12px;
    padding: 11px 24px; color: var(--text-muted);
    text-decoration: none; font-size: 14px; font-weight: 400;
    border-left: 3px solid transparent;
    transition: all 0.15s;
}
.nav-item:hover { color: var(--text); background: rgba(255,255,255,0.03); }
.nav-item.active {
    color: var(--text); background: var(--primary-bg);
    border-left-color: var(--primary); font-weight: 600;
}

.nav-divider { height: 1px; background: var(--border); margin: 12px 24px; }
.nav-label { padding: 4px 24px; font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; }

.sidebar-user {
    display: flex; align-items: center; gap: 10px;
    margin: 0 16px; padding: 12px;
    background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
}

.user-avatar {
    width: 34px; height: 34px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: 700; color: #fff; flex-shrink: 0;
}

.user-info { flex: 1; min-width: 0; }
.user-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; color: var(--text-muted); }
.logout-btn { color: var(--text-muted); transition: color 0.15s; display: flex; }
.logout-btn:hover { color: var(--red); }

.main-content { margin-left: var(--sidebar-width); padding: 32px 40px; flex: 1; max-width: 100%; }

/* Mobile nav */
.mobile-nav {
    display: none; position: fixed; bottom: 0; left: 0; right: 0;
    background: #111528; border-top: 1px solid var(--border);
    padding: 8px 0; z-index: 100;
    justify-content: space-around;
}
.mobile-nav-item {
    display: flex; align-items: center; justify-content: center;
    width: 44px; height: 44px; border-radius: var(--radius);
    color: var(--text-muted); text-decoration: none; transition: all 0.15s;
}
.mobile-nav-item.active { color: var(--primary-light); background: var(--primary-bg); }

/* Cards */
.card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-lg); padding: 24px; margin-bottom: 16px;
}
.card-highlight { background: var(--primary-bg); border-color: var(--primary-border); }
.card-success { background: var(--green-bg); border-color: var(--green-border); }
.card-warning { background: var(--amber-bg); border-color: var(--amber-border); }

/* Window indicator */
.window-status { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.window-dot {
    width: 10px; height: 10px; border-radius: 50%;
    flex-shrink: 0;
}
.window-dot.active { background: var(--green); box-shadow: 0 0 8px rgba(34,197,94,0.5); animation: pulse 2s infinite; }
.window-dot.inactive { background: var(--text-muted); }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.5; } }

.window-pills { display: flex; gap: 8px; flex-wrap: wrap; }
.window-pill {
    padding: 6px 14px; border-radius: var(--radius-sm);
    font-size: 12px; font-weight: 600;
    background: var(--bg-card); border: 1px solid var(--border);
    color: var(--text-muted);
}
.window-pill.active { background: var(--primary-bg); border-color: var(--primary-border); color: var(--primary-light); }

/* Page header */
.page-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 24px; gap: 16px; flex-wrap: wrap; }
.page-title { font-size: 22px; font-weight: 800; margin: 0; }
.page-subtitle { color: var(--text-muted); font-size: 13px; margin-top: 4px; }

/* Buttons */
.btn {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 10px 20px; border-radius: 10px;
    font-family: inherit; font-size: 14px; font-weight: 600;
    border: none; cursor: pointer; transition: all 0.2s;
    text-decoration: none; white-space: nowrap;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: #5558e6; }
.btn-secondary { background: var(--bg-card); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: var(--border-hover); }
.btn-danger { background: var(--red-bg); color: var(--red); border: 1px solid var(--red-border); }
.btn-danger:hover { background: rgba(239,68,68,0.15); }
.btn-success { background: var(--green-bg); color: var(--green); border: 1px solid var(--green-border); }
.btn-sm { padding: 6px 12px; font-size: 12px; border-radius: var(--radius-sm); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* Forms */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 12px; color: var(--text-secondary); margin-bottom: 6px; font-weight: 500; }
.form-input, .form-select {
    width: 100%; padding: 10px 14px;
    background: var(--bg-input); border: 1px solid var(--border);
    border-radius: 10px; color: var(--text); font-family: inherit; font-size: 14px;
    outline: none; transition: border-color 0.15s;
}
.form-input:focus, .form-select:focus { border-color: var(--primary); }
.form-select { appearance: auto; }
.form-select option { background: #161a2e; color: var(--text); }

/* Post cards */
.post-card { transition: all 0.2s; }
.post-meta { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.post-meta-item { font-size: 12px; color: var(--text-muted); }
.post-meta-dot { color: var(--text-faint); }
.post-title { font-size: 16px; font-weight: 700; margin: 0 0 4px; line-height: 1.4; }
.post-link { font-size: 12px; color: var(--primary-light); text-decoration: none; word-break: break-all; }
.post-link:hover { text-decoration: underline; }

.post-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.post-score {
    text-align: center; padding: 8px 16px;
    border-radius: 10px; background: var(--bg-card); flex-shrink: 0;
}
.post-score-value { font-size: 24px; font-weight: 800; }
.post-score-label { font-size: 10px; color: var(--text-muted); text-transform: uppercase; }

/* Distribution grid */
.dist-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 8px; }

.dist-item {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 16px; border-radius: 10px; cursor: pointer;
    border: 1px solid var(--border); background: var(--bg-card);
    transition: all 0.2s; width: 100%; text-align: left;
    font-family: inherit; color: var(--text);
}
.dist-item:hover:not(:disabled):not(.dist-done) { border-color: var(--border-hover); }
.dist-item.dist-done.on-time { border-color: var(--green-border); background: var(--green-bg); }
.dist-item.dist-done.late { border-color: var(--amber-border); background: var(--amber-bg); }
.dist-item:disabled { opacity: 0.5; cursor: not-allowed; }

.dist-checkbox {
    width: 22px; height: 22px; border-radius: 6px;
    border: 2px solid rgba(255,255,255,0.2);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; transition: all 0.2s;
}
.dist-done .dist-checkbox { border: none; }
.dist-done.on-time .dist-checkbox { background: var(--green); color: #fff; }
.dist-done.late .dist-checkbox { background: var(--amber); color: #fff; }

.dist-icon { flex-shrink: 0; }
.dist-info { flex: 1; min-width: 0; }
.dist-platform { font-size: 13px; font-weight: 600; }
.dist-time { font-size: 11px; margin-top: 2px; }
.dist-done.on-time .dist-time { color: var(--green); }
.dist-done.late .dist-time { color: var(--amber); }

.dist-points { font-size: 13px; font-weight: 700; }

/* Post score summary */
.post-summary {
    margin-top: 12px; padding: 8px 12px;
    border-radius: var(--radius-sm); background: rgba(255,255,255,0.02);
    font-size: 12px; color: var(--text-muted);
}

/* WhatsApp reminder */
.whatsapp-reminder {
    margin-top: 12px; padding: 12px 16px;
    border-radius: var(--radius-sm);
    background: rgba(37,211,102,0.06); border: 1px solid rgba(37,211,102,0.15);
    font-size: 13px; color: #25d366;
    display: flex; align-items: center; gap: 10px;
}

/* Badge */
.badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 10px; border-radius: 20px;
    font-size: 11px; font-weight: 600;
}
.badge-window { background: var(--primary-bg); color: var(--primary-light); border: 1px solid var(--primary-border); }
.badge-active { background: var(--green-bg); color: var(--green); border: 1px solid var(--green-border); }
.badge-inactive { background: rgba(255,255,255,0.03); color: var(--text-muted); border: 1px solid var(--border); }

/* Leaderboard */
.lb-card { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.lb-rank { font-size: 28px; width: 40px; text-align: center; flex-shrink: 0; }
.lb-user { flex: 1; min-width: 120px; }
.lb-user-name { font-size: 16px; font-weight: 700; }
.lb-user-sub { font-size: 12px; color: var(--text-secondary); }
.lb-stats { display: flex; gap: 24px; flex-wrap: wrap; }
.lb-stat { text-align: center; }
.lb-stat-value { font-size: 22px; font-weight: 800; }
.lb-stat-label { font-size: 10px; color: var(--text-muted); text-transform: uppercase; }
.lb-bonus {
    padding: 6px 14px; border-radius: 20px;
    font-size: 11px; font-weight: 700;
    background: linear-gradient(135deg, var(--primary), #8b5cf6);
    color: #fff; white-space: nowrap;
}

/* Modal */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.7); backdrop-filter: blur(8px);
    display: flex; align-items: center; justify-content: center;
    z-index: 999; padding: 16px;
}
.modal {
    background: #161a2e; border: 1px solid var(--border);
    border-radius: 20px; padding: 32px;
    width: 100%; max-width: 480px;
}
.modal-title { font-size: 20px; font-weight: 700; margin-bottom: 24px; }
.modal-actions { display: flex; gap: 12px; margin-top: 24px; }
.modal-actions .btn { flex: 1; justify-content: center; }

/* Social link input modal */
.social-link-prompt { margin-top: 8px; }

/* Table */
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th {
    padding: 12px 16px; text-align: left;
    font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px;
    color: var(--text-muted); border-bottom: 1px solid var(--border);
}
.data-table td {
    padding: 12px 16px; border-bottom: 1px solid rgba(255,255,255,0.03);
    vertical-align: middle;
}
.data-table tr:hover td { background: rgba(255,255,255,0.02); }

/* Empty state */
.empty-state {
    text-align: center; padding: 48px 24px;
}
.empty-icon { font-size: 48px; margin-bottom: 16px; color: var(--text-muted); opacity: 0.5; }
.empty-text { color: var(--text-muted); font-size: 14px; }

/* Window selector */
.window-selector { display: flex; gap: 8px; margin-bottom: 20px; flex-wrap: wrap; }
.window-btn {
    padding: 8px 16px; border-radius: var(--radius-sm);
    background: var(--bg-card); border: 1px solid var(--border);
    color: var(--text-muted); font-family: inherit; font-size: 13px;
    font-weight: 500; cursor: pointer; transition: all 0.15s;
}
.window-btn:hover { border-color: var(--border-hover); }
.window-btn.active { background: var(--primary-bg); border-color: var(--primary-border); color: var(--primary-light); font-weight: 600; }

/* Date nav */
.date-nav { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.date-nav-btn {
    width: 36px; height: 36px; border-radius: var(--radius-sm);
    background: var(--bg-card); border: 1px solid var(--border);
    color: var(--text); cursor: pointer; display: flex;
    align-items: center; justify-content: center;
    font-size: 16px; transition: all 0.15s;
}
.date-nav-btn:hover { border-color: var(--border-hover); }
.date-current { font-size: 15px; font-weight: 600; }

/* Alert */
.alert {
    padding: 12px 16px; border-radius: var(--radius);
    margin-bottom: 16px; font-size: 13px;
    display: flex; align-items: center; gap: 10px;
}
.alert-success { background: var(--green-bg); border: 1px solid var(--green-border); color: var(--green); }
.alert-error { background: var(--red-bg); border: 1px solid var(--red-border); color: var(--red); }
.alert-info { background: var(--primary-bg); border: 1px solid var(--primary-border); color: var(--primary-light); }

/* Login page */
.login-page {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, #0c0f1a 0%, #1a1040 50%, #0c0f1a 100%);
    padding: 16px;
}
.login-card { text-align: center; width: 100%; max-width: 360px; }
.login-logo {
    width: 72px; height: 72px; border-radius: 20px;
    margin: 0 auto 24px; display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, var(--primary), #8b5cf6);
    box-shadow: 0 8px 32px rgba(99,102,241,0.3);
    color: #fff;
}
.login-title { font-size: 28px; font-weight: 800; margin-bottom: 8px; }
.login-subtitle { color: var(--text-muted); font-size: 14px; margin-bottom: 32px; }
.login-form { text-align: left; }
.login-error { color: var(--red); font-size: 13px; margin-bottom: 12px; text-align: center; }

/* Month selector */
.month-selector { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 20px; }
.month-btn {
    padding: 8px 16px; border-radius: var(--radius-sm);
    background: var(--bg-card); border: 1px solid var(--border);
    color: var(--text-muted); font-family: inherit; font-size: 13px;
    cursor: pointer; transition: all 0.15s; text-decoration: none;
}
.month-btn:hover { border-color: var(--border-hover); color: var(--text); }
.month-btn.active { background: var(--primary-bg); border-color: var(--primary-border); color: var(--primary-light); font-weight: 600; }

/* Utility */
.text-green { color: var(--green); }
.text-amber { color: var(--amber); }
.text-red { color: var(--red); }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 12px; }
.text-center { text-align: center; }
.fw-700 { font-weight: 700; }
.fw-800 { font-weight: 800; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.flex { display: flex; }
.flex-center { display: flex; align-items: center; }
.gap-8 { gap: 8px; }
.gap-16 { gap: 16px; }
.flex-1 { flex: 1; }

/* Responsive */
@media (max-width: 768px) {
    .sidebar { display: none; }
    .mobile-nav { display: flex; }
    .main-content { margin-left: 0; padding: 16px 16px 80px; }
    .page-header { flex-direction: column; }
    .lb-stats { gap: 16px; }
    .dist-grid { grid-template-columns: 1fr; }
    .modal { padding: 24px; margin: 16px; }
    .data-table { font-size: 12px; }
    .data-table th, .data-table td { padding: 10px 8px; }
}

@media (max-width: 480px) {
    .lb-card { gap: 10px; }
    .lb-rank { font-size: 22px; width: 30px; }
    .lb-stat-value { font-size: 18px; }
    .post-header { flex-direction: column; }
}
