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

:root {
    --bg: #0f1117;
    --surface: #1a1d27;
    --surface2: #222636;
    --border: #2a2d3e;
    --primary: #1877F2;
    --primary-hover: #1565d8;
    --text: #e8eaf0;
    --text-muted: #6b7280;
    --text-dim: #9ca3af;
    --success: #22c55e;
    --danger: #ef4444;
    --warning: #f59e0b;
    --purple: #a855f7;
    --orange: #f97316;
    --sidebar-w: 240px;
    --radius: 10px;
    --radius-sm: 6px;
    --shadow: 0 4px 24px rgba(0,0,0,0.3);
}

html, body { height: 100%; }

body {
    font-family: 'DM Sans', sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.6;
    display: flex;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

input, textarea, select {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: inherit;
    font-size: 14px;
    padding: 10px 14px;
    outline: none;
    transition: border-color 0.2s;
}

input:focus, textarea:focus, select:focus { border-color: var(--primary); }
textarea { resize: vertical; }
label { display: block; font-weight: 500; margin-bottom: 6px; color: var(--text-dim); font-size: 13px; }
code { font-family: monospace; background: var(--bg); padding: 2px 6px; border-radius: 4px; font-size: 12px; }

.required { color: var(--danger); }

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
    white-space: nowrap;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: var(--primary); color: var(--primary); }
.btn-danger { background: rgba(239,68,68,0.15); color: var(--danger); border: 1px solid rgba(239,68,68,0.3); }
.btn-danger:hover { background: rgba(239,68,68,0.25); }
.btn-facebook { background: #1877F2; color: #fff; }
.btn-facebook:hover { background: #1565d8; }
.btn-full { width: 100%; justify-content: center; }
.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-text { background: none; border: none; color: var(--primary); cursor: pointer; font-size: 13px; padding: 0; }
.btn-publish { padding: 14px; font-size: 15px; margin-top: 12px; }

.form-group { margin-bottom: 18px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 20px; }
.form-full { grid-column: 1 / -1; }

.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    font-size: 14px;
}
.alert-success { background: rgba(34,197,94,0.1); border: 1px solid rgba(34,197,94,0.3); color: var(--success); }
.alert-error { background: rgba(239,68,68,0.1); border: 1px solid rgba(239,68,68,0.3); color: var(--danger); }

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}
.badge-published, .badge-success { background: rgba(34,197,94,0.15); color: var(--success); }
.badge-failed { background: rgba(239,68,68,0.15); color: var(--danger); }
.badge-draft { background: rgba(107,114,128,0.2); color: var(--text-muted); }
.badge-image { background: rgba(24,119,242,0.15); color: var(--primary); }
.badge-video { background: rgba(168,85,247,0.15); color: var(--purple); }
.badge-none { background: var(--surface2); color: var(--text-muted); }

.text-success { color: var(--success); font-weight: 600; }
.text-danger { color: var(--danger); }

.sidebar {
    width: var(--sidebar-w);
    min-height: 100vh;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 24px 20px;
    font-family: 'Syne', sans-serif;
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
    border-bottom: 1px solid var(--border);
}

.brand-icon { flex-shrink: 0; }

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-weight: 500;
    transition: all 0.2s;
    text-decoration: none;
}

.nav-item:hover { background: var(--surface2); color: var(--text); text-decoration: none; }
.nav-item.active { background: rgba(24,119,242,0.15); color: var(--primary); }
.nav-item svg { flex-shrink: 0; }

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-info { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; }

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

.user-meta { min-width: 0; }
.user-name { display: block; font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-email { display: block; font-size: 11px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.logout-btn {
    color: var(--text-muted);
    display: flex;
    align-items: center;
    padding: 6px;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
    flex-shrink: 0;
}
.logout-btn:hover { color: var(--danger); background: rgba(239,68,68,0.1); text-decoration: none; }

.main-content {
    margin-left: var(--sidebar-w);
    flex: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.topbar {
    height: 60px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 50;
}

.menu-toggle { display: none; background: none; border: none; color: var(--text-muted); cursor: pointer; padding: 4px; }
.topbar-right { display: flex; align-items: center; gap: 12px; }

.page-body { padding: 32px 28px; flex: 1; }

.page-header { margin-bottom: 28px; }
.page-header h2 { font-family: 'Syne', sans-serif; font-size: 24px; font-weight: 700; margin-bottom: 4px; }
.page-header p { color: var(--text-muted); }

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
}

.stat-icon {
    width: 46px;
    height: 46px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-icon.blue { background: rgba(24,119,242,0.15); color: var(--primary); }
.stat-icon.green { background: rgba(34,197,94,0.15); color: var(--success); }
.stat-icon.orange { background: rgba(249,115,22,0.15); color: var(--orange); }
.stat-icon.purple { background: rgba(168,85,247,0.15); color: var(--purple); }

.stat-info { display: flex; flex-direction: column; }
.stat-num { font-family: 'Syne', sans-serif; font-size: 28px; font-weight: 700; line-height: 1; }
.stat-label { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

.section-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 24px;
}

.section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.section-head h3 {
    font-family: 'Syne', sans-serif;
    font-size: 16px;
    font-weight: 600;
}

.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table th { text-align: left; padding: 10px 12px; color: var(--text-muted); font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; border-bottom: 1px solid var(--border); }
.data-table td { padding: 12px; border-bottom: 1px solid var(--border); }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--surface2); }
.msg-cell { max-width: 200px; }

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 48px 24px;
    color: var(--text-muted);
    gap: 12px;
    text-align: center;
}

.pages-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }

.page-card {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
    display: flex;
    align-items: center;
    gap: 14px;
    transition: border-color 0.2s;
}

.page-card:hover { border-color: var(--primary); }

.page-avatar {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), #6d28d9);
    color: #fff;
    font-weight: 700;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.page-info { flex: 1; min-width: 0; }
.page-info h4 { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.page-category { display: block; font-size: 12px; color: var(--text-muted); }
.page-fans { display: block; font-size: 12px; color: var(--text-muted); }
.page-account small { color: var(--text-muted); font-size: 11px; }

.post-layout { display: grid; grid-template-columns: 1fr 300px; gap: 24px; align-items: start; }
.post-main { display: flex; flex-direction: column; gap: 0; }
.post-sidebar { position: sticky; top: 80px; }

.char-count { display: block; text-align: right; font-size: 12px; color: var(--text-muted); margin-top: 4px; }

.media-upload {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    position: relative;
    min-height: 140px;
    transition: border-color 0.2s;
    overflow: hidden;
}

.media-upload:hover { border-color: var(--primary); }

.media-upload input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
    z-index: 2;
    width: 100%;
    height: 100%;
    padding: 0;
    border: none;
}

.media-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 32px;
    color: var(--text-muted);
    gap: 8px;
    text-align: center;
}

.media-placeholder p { font-weight: 500; }
.media-placeholder small { font-size: 12px; }

.media-preview img, .media-preview video {
    width: 100%;
    max-height: 220px;
    object-fit: contain;
    display: block;
    background: var(--bg);
}

.pages-checklist { display: flex; flex-direction: column; gap: 4px; max-height: 360px; overflow-y: auto; }

.page-check-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.15s;
}

.page-check-item:hover { background: var(--surface2); }
.page-check-item input[type="checkbox"] { width: 16px; height: 16px; flex-shrink: 0; accent-color: var(--primary); cursor: pointer; }

.page-check-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), #6d28d9);
    color: #fff;
    font-weight: 700;
    font-size: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.page-check-info { flex: 1; min-width: 0; }
.page-check-info span { display: block; font-weight: 500; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.page-check-info small { color: var(--text-muted); font-size: 11px; }

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 100%;
    max-width: 680px;
    max-height: 80vh;
    overflow-y: auto;
}

.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}

.modal-head h3 { font-family: 'Syne', sans-serif; font-size: 16px; font-weight: 600; }
.modal-head button { background: none; border: none; color: var(--text-muted); cursor: pointer; padding: 4px; }
.modal-head button:hover { color: var(--text); }
.modal-body { padding: 24px; }

.detail-block { margin-bottom: 16px; }
.detail-block strong { display: block; font-size: 12px; text-transform: uppercase; color: var(--text-muted); letter-spacing: 0.5px; margin-bottom: 6px; }
.detail-block p { color: var(--text); line-height: 1.6; }

.auth-body {
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    width: 100%;
}

.auth-wrapper { width: 100%; max-width: 400px; padding: 24px; }

.auth-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: 'Syne', sans-serif;
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 32px;
    justify-content: center;
}

.auth-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 32px;
}

.auth-card h1 {
    font-family: 'Syne', sans-serif;
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 6px;
}

.auth-sub { color: var(--text-muted); margin-bottom: 24px; }
.auth-link { text-align: center; margin-top: 20px; color: var(--text-muted); font-size: 13px; }

@media (max-width: 1024px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .post-layout { grid-template-columns: 1fr; }
    .post-sidebar { position: static; }
}

@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); transition: transform 0.3s; }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .menu-toggle { display: flex; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .form-grid { grid-template-columns: 1fr; }
    .page-body { padding: 20px 16px; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
}
