* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: #f4f6f9;
    color: #2b2b2b;
}
.topbar {
    background: #fff;
    border-bottom: 1px solid #e5e7eb;
    padding: 14px 24px;
}
.logo { font-weight: 700; font-size: 20px; color: #ff6a2b; }
.logo span { color: #5b3df5; }

.page-wrap { max-width: 1200px; margin: 24px auto; padding: 0 20px; }

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

.section-title { color: #2f6fed; font-weight: 600; font-size: 20px; }
.fb-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px; height: 20px;
    background: #1877f2;
    color: #fff;
    border-radius: 4px;
    font-weight: 700;
    font-size: 13px;
    margin-right: 6px;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 18px;
    border-radius: 6px;
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
    border: none;
    cursor: pointer;
}
.btn-fb { background: #1877f2; color: #fff; }
.btn-fb.small { padding: 8px 14px; font-size: 13px; }
.btn-outline-red {
    background: #fff; color: #e53e3e; border: 1px solid #e53e3e;
    padding: 6px 12px; border-radius: 6px; font-size: 13px; font-weight: 600;
}
.btn-outline-blue {
    background: #fff; color: #2f6fed; border: 1px solid #2f6fed;
}
.btn-outline-gray {
    background: #fff; color: #555; border: 1px solid #ccc;
}
.btn-sm { padding: 6px 10px; font-size: 12px; border-radius: 20px; }

.connect-card {
    background: #fff;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    padding: 18px 24px;
    margin-bottom: 20px;
}
.center-card { text-align: center; }

.user-row { display: flex; align-items: center; gap: 16px; }
.avatar { width: 60px; height: 60px; border-radius: 8px; object-fit: cover; }
.user-meta { flex: 1; }
.page-count { color: #666; font-size: 13px; }
.user-name { font-weight: 600; font-size: 16px; }

.search-box {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    width: 220px;
}

.page-list-label { color: #666; font-size: 13px; margin-bottom: 10px; }

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

.page-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 16px;
}
.page-card-top { display: flex; gap: 12px; margin-bottom: 14px; }
.page-avatar { width: 48px; height: 48px; border-radius: 50%; object-fit: cover; }
.page-name { color: #2f6fed; font-weight: 600; }
.page-id { color: #888; font-size: 12px; }
.page-status { font-size: 12px; color: #444; display: flex; align-items: center; gap: 5px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #34c759; display: inline-block; }

.page-card-actions { display: flex; gap: 8px; }

/* Modal */
.modal-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.4);
    align-items: center; justify-content: center;
    z-index: 100;
}
.modal {
    background: #fff;
    border-radius: 8px;
    padding: 24px;
    width: 420px;
    max-width: 90vw;
}
.modal h3 { margin-top: 0; }
.modal textarea, .modal input[type="url"] {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    margin-bottom: 10px;
    font-family: inherit;
}
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; }
.post-status { min-height: 20px; font-size: 13px; margin-bottom: 8px; }
.post-status.success { color: #22a35a; }
.post-status.error { color: #e53e3e; }

/* ===== App layout with sidebar (facebook_poster.php, multimedia_post.php) ===== */
.app-layout { display: flex; max-width: 1400px; margin: 0 auto; }
.sidebar {
    width: 220px;
    flex-shrink: 0;
    background: #fff;
    border-right: 1px solid #e5e7eb;
    min-height: calc(100vh - 60px);
    padding: 16px 0;
}
.side-label {
    font-size: 11px;
    text-transform: uppercase;
    color: #999;
    padding: 14px 20px 6px;
    letter-spacing: .04em;
}
.side-item {
    display: block;
    padding: 9px 20px;
    color: #444;
    text-decoration: none;
    font-size: 14px;
}
.side-item:hover { background: #f4f6f9; }
.side-item.active { color: #2f6fed; font-weight: 600; background: #eef3ff; }

.app-main { flex: 1; padding: 24px 28px; min-width: 0; }
.breadcrumb { font-size: 13px; color: #888; }
.breadcrumb a { color: #2f6fed; text-decoration: none; }

.cloud-icon { display: inline-block; }

/* ===== Poster hub cards ===== */
.poster-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 18px;
}
.poster-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 30px 20px;
    text-align: center;
    text-decoration: none;
    color: inherit;
    transition: box-shadow .15s, transform .15s;
}
.poster-card:not(.no-hover):hover { box-shadow: 0 6px 18px rgba(0,0,0,.08); transform: translateY(-2px); }
.poster-icon { font-size: 34px; margin-bottom: 10px; }
.poster-icon.blue { color: #2f6fed; }
.poster-icon.pink { color: #e83e8c; }
.poster-icon.green { color: #22a35a; }
.poster-icon.red { color: #e53e3e; }
.poster-title { color: #2f6fed; font-weight: 600; margin-bottom: 6px; }
.poster-desc { color: #888; font-size: 13px; }
.social-icon { color: #2f6fed; }

/* ===== Multimedia composer (multimedia_post.php) ===== */
.composer-layout {
    display: grid;
    grid-template-columns: 280px 1fr 320px;
    gap: 20px;
    align-items: start;
}
.composer-pages, .composer-form, .composer-preview {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 16px;
}
.composer-pages-head { font-weight: 600; color: #2f6fed; margin-bottom: 10px; }
.search-box.full { width: 100%; margin-bottom: 10px; }
.page-select-all {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    color: #555;
    margin-bottom: 8px;
}
.mini-select { font-size: 12px; padding: 3px 6px; border-radius: 4px; border: 1px solid #ddd; max-width: 140px; }
.page-checklist { max-height: 480px; overflow-y: auto; }
.page-check-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 4px;
    border-bottom: 1px solid #f2f2f2;
    cursor: pointer;
}
.page-check-avatar { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; }
.page-check-name { font-size: 13px; font-weight: 600; }
.page-check-handle { font-size: 11px; color: #999; }

.composer-tabs {
    display: flex;
    align-items: center;
    gap: 6px;
    border-bottom: 1px solid #eee;
    margin-bottom: 16px;
    padding-bottom: 10px;
    flex-wrap: wrap;
}
.tab-btn {
    background: none;
    border: none;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    color: #555;
}
.tab-btn.active { background: #eef3ff; color: #2f6fed; font-weight: 600; }
.ig-toggle { margin-left: auto; font-size: 13px; color: #555; display: flex; align-items: center; gap: 6px; }

.field-label { display: block; font-size: 13px; font-weight: 600; color: #444; margin: 12px 0 6px; }
.info-dot { color: #aaa; font-size: 11px; cursor: help; }
.composer-form input[type="text"],
.composer-form input[type="url"],
.composer-form input[type="datetime-local"],
.composer-form textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-family: inherit;
    font-size: 14px;
    margin-bottom: 8px;
}
.reels-toggle { display: block; font-size: 13px; color: #555; margin-top: 6px; }

.posting-time-row { display: flex; align-items: center; gap: 10px; margin-top: 4px; }
.switch { position: relative; display: inline-block; width: 40px; height: 22px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider-track {
    position: absolute; cursor: pointer; inset: 0;
    background: #ccc; border-radius: 22px; transition: .2s;
}
.slider-track::before {
    content: ""; position: absolute; height: 16px; width: 16px;
    left: 3px; bottom: 3px; background: #fff; border-radius: 50%; transition: .2s;
}
.switch input:checked + .slider-track { background: #1877f2; }
.switch input:checked + .slider-track::before { transform: translateX(18px); }

/* ===== Live preview panel ===== */
.fb-preview-card { border: 1px solid #eee; border-radius: 8px; padding: 12px; }
.fb-preview-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.fb-preview-avatar { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; background: #ddd; }
.fb-preview-name { font-weight: 600; font-size: 14px; }
.fb-preview-meta { font-size: 11px; color: #999; }
.fb-preview-text { font-size: 14px; white-space: pre-wrap; margin-bottom: 10px; min-height: 20px; }
.fb-preview-media img.preview-img,
.fb-preview-media video.preview-img { width: 100%; border-radius: 6px; max-height: 240px; object-fit: cover; }
.preview-link { background: #f4f6f9; border-radius: 6px; padding: 10px; font-size: 13px; color: #444; word-break: break-all; }
.fb-preview-actions {
    display: flex; justify-content: space-between;
    border-top: 1px solid #eee; margin-top: 12px; padding-top: 10px;
    font-size: 13px; color: #666;
}

@media (max-width: 1100px) {
    .composer-layout { grid-template-columns: 1fr; }
}
