:root {
  color-scheme: light;
  --bg: #f3f5f7;
  --surface: #fff;
  --ink: #17202a;
  --muted: #667085;
  --line: #d9e0e8;
  --blue: #1457d9;
  --blue-soft: #eaf1ff;
  --green: #087a55;
  --green-soft: #e7f7f0;
  --red: #b42318;
  --red-soft: #fff0ee;
  --amber: #9a6700;
  --amber-soft: #fff7d6;
  --instagram: #b4267a;
  --facebook: #1877f2;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: Tahoma, Arial, sans-serif; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .65; }
.shell { width: min(1220px, calc(100% - 32px)); margin: 0 auto; padding: 26px 0 52px; }
.topbar, .section-heading, .panel-heading, .approval-meta, .review-actions, .media-row { display: flex; gap: 12px; }
.topbar, .section-heading, .panel-heading { align-items: center; justify-content: space-between; }
.topbar { margin-bottom: 18px; }
h1, h2, p { margin: 0; }
h1 { font-size: clamp(28px, 4vw, 42px); line-height: 1.15; }
h2 { font-size: 19px; }
.subtitle { margin-top: 8px; color: var(--muted); line-height: 1.6; }
.eyebrow, .kicker { margin-bottom: 5px; color: var(--blue); font-size: 12px; font-weight: 800; text-transform: uppercase; }
.quiet, small { color: var(--muted); }
.role-tabs { display: inline-flex; gap: 4px; margin-bottom: 22px; padding: 4px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.role-tab, .secondary, .icon-button { min-height: 42px; border: 0; border-radius: 6px; padding: 0 16px; background: transparent; color: var(--muted); font-weight: 800; }
.role-tab.active { background: var(--ink); color: white; }
.icon-button, .secondary { background: #e8edf3; color: var(--ink); }
.view { display: none; }
.view.active { display: block; }
.section-heading { margin-bottom: 14px; }
.panel { border: 1px solid var(--line); border-radius: 8px; background: var(--surface); padding: 18px; box-shadow: 0 10px 24px rgba(23, 32, 42, .05); }
.composer-layout { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(300px, .65fr); gap: 16px; align-items: start; }
.designer-layout { display: grid; grid-template-columns: minmax(360px, .75fr) minmax(0, 1.25fr); gap: 16px; align-items: start; }
form { display: grid; gap: 16px; }
label { display: grid; gap: 7px; color: #475467; font-size: 14px; font-weight: 800; }
input[type="text"], input[type="password"], input[type="tel"], input[type="url"], input[type="datetime-local"], input[type="file"], textarea, select { width: 100%; min-height: 44px; border: 1px solid var(--line); border-radius: 7px; padding: 10px 12px; background: white; color: var(--ink); font-weight: 500; }
.media-multiselect { min-height: 120px; }
textarea { resize: vertical; line-height: 1.6; }
input:focus, textarea:focus, select:focus { outline: 3px solid rgba(20, 87, 217, .13); border-color: var(--blue); }
.media-row > label { flex: 1; }
fieldset { margin: 0; border: 1px solid var(--line); border-radius: 8px; padding: 14px; }
legend { padding: 0 7px; color: #475467; font-size: 14px; font-weight: 800; }
.channel-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.channel-card { display: grid; grid-template-columns: auto auto 1fr; align-items: center; gap: 10px; min-height: 72px; border: 1px solid var(--line); border-radius: 8px; padding: 11px; color: var(--ink); cursor: pointer; }
.channel-card:has(input:checked) { border-color: var(--blue); background: var(--blue-soft); }
.channel-card input { width: 18px; height: 18px; }
.channel-card span:last-child { display: grid; gap: 3px; min-width: 0; }
.channel-card strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.channel-card.disabled { opacity: .5; cursor: not-allowed; }
.service-icon { display: grid; width: 32px; height: 32px; place-items: center; border-radius: 50%; color: white; font-weight: 900; }
.service-icon.facebook { background: var(--facebook); }
.service-icon.instagram { background: var(--instagram); }
.schedule-options { display: flex; flex-wrap: wrap; gap: 9px; }
.schedule-options label { display: flex; align-items: center; gap: 7px; min-height: 42px; border: 1px solid var(--line); border-radius: 7px; padding: 8px 11px; cursor: pointer; }
.schedule-options label:has(input:checked) { border-color: var(--blue); background: var(--blue-soft); color: var(--blue); }
.primary, .otp-form button, .approve { min-height: 44px; border: 0; border-radius: 7px; padding: 0 17px; background: var(--blue); color: white; font-weight: 900; }
.submit-button { width: fit-content; }
.preview-panel { position: sticky; top: 16px; }
.media-preview, .approval-media { display: grid; min-height: 280px; place-items: center; overflow: hidden; border: 1px dashed #bcc7d6; border-radius: 8px; background: #f8fafc; color: var(--muted); }
.media-preview img, .media-preview video, .approval-media img, .approval-media video { width: 100%; height: 100%; object-fit: contain; background: #f0f2f5; }
.designer-preview { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.designer-preview-item { display: grid; gap: 7px; min-width: 0; }
.designer-preview-item img, .designer-preview-item video { width: 100%; aspect-ratio: 1; object-fit: contain; border-radius: 7px; background: #f0f2f5; }
.designer-preview-item span { overflow: hidden; color: var(--muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.field-help { margin-bottom: 10px; color: var(--muted); font-size: 13px; line-height: 1.5; }
.media-bank-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.bank-item { position: relative; display: grid; gap: 6px; overflow: hidden; min-height: 150px; border: 2px solid transparent; border-radius: 8px; padding: 0 0 8px; background: #f4f6f8; color: var(--ink); text-align: right; }
.bank-item.selected { border-color: var(--blue); background: var(--blue-soft); }
.bank-item img, .bank-item video { width: 100%; aspect-ratio: 1; object-fit: cover; background: #e8ecf1; pointer-events: none; }
.bank-caption { overflow: hidden; padding: 0 8px; font-size: 12px; font-weight: 800; text-overflow: ellipsis; white-space: nowrap; }
.order-badge { position: absolute; top: 7px; right: 7px; display: grid; width: 28px; height: 28px; place-items: center; border-radius: 50%; background: var(--blue); color: white; font-weight: 900; }
.carousel-preview { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; min-height: 260px; align-content: center; border: 1px dashed #bcc7d6; border-radius: 8px; padding: 8px; background: #f8fafc; color: var(--muted); text-align: center; }
.carousel-frame { position: relative; min-width: 0; }
.carousel-frame img, .carousel-frame video { width: 100%; aspect-ratio: 1; object-fit: contain; border-radius: 6px; background: #edf0f3; }
.carousel-frame span, .submission-carousel span { position: absolute; top: 6px; right: 6px; display: grid; width: 25px; height: 25px; place-items: center; border-radius: 50%; background: rgba(23,32,42,.86); color: white; font-size: 12px; font-weight: 900; }
.preview-text { margin-top: 14px; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.7; }
.preview-channels { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 12px; }
.badge, .status-pill { display: inline-flex; width: fit-content; min-height: 26px; align-items: center; border-radius: 999px; padding: 4px 9px; background: #edf1f5; color: #344054; font-size: 12px; font-weight: 800; }
.badge.facebook { background: rgba(24,119,242,.1); color: var(--facebook); }
.badge.instagram { background: rgba(180,38,122,.1); color: var(--instagram); }
.status-pill.pending, .status-pill.processing { background: var(--amber-soft); color: var(--amber); }
.status-pill.pending_review, .status-pill.processing { background: var(--amber-soft); color: var(--amber); }
.status-pill.approved, .status-pill.approved_for_scheduling, .status-pill.published { background: var(--green-soft); color: var(--green); }
.status-pill.rejected, .status-pill.failed, .status-pill.changes_requested { background: var(--red-soft); color: var(--red); }
.brand-badge { display: inline-flex; align-items: center; min-height: 26px; border-radius: 5px; padding: 4px 9px; background: #17202a; color: white; font-size: 12px; font-weight: 900; }
.manager-login { display: grid; grid-template-columns: 1fr minmax(280px, 420px); align-items: end; gap: 24px; }
.otp-form { align-content: end; }
.otp-step { display: grid; grid-template-columns: 1fr auto; align-items: end; gap: 10px; }
.phone-hint { color: var(--muted); font-size: 13px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 14px; }
.stats > div { display: grid; gap: 4px; border: 1px solid var(--line); border-radius: 8px; background: white; padding: 14px; }
.stats strong { font-size: 26px; }
.stats span { color: var(--muted); font-size: 13px; }
.approval-grid { display: grid; gap: 14px; }
.review-section { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 18px; }
.media-review-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.media-review-card { overflow: hidden; border: 1px solid var(--line); border-radius: 8px; background: white; }
.media-review-preview { display: grid; height: 240px; place-items: center; background: #eef1f4; }
.media-review-preview img, .media-review-preview video { width: 100%; height: 100%; object-fit: contain; }
.media-review-info { display: grid; gap: 10px; padding: 13px; }
.approval-card { display: grid; grid-template-columns: 320px 1fr; overflow: hidden; border: 1px solid var(--line); border-radius: 8px; background: white; }
.approval-media { min-height: 310px; border: 0; border-radius: 0; border-left: 1px solid var(--line); }
.approval-content { display: grid; align-content: start; gap: 13px; padding: 18px; }
.approval-meta { flex-wrap: wrap; align-items: center; color: var(--muted); font-size: 13px; }
.approval-text { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.7; }
.schedule-summary { display: flex; flex-wrap: wrap; gap: 10px; color: var(--muted); }
.schedule-summary strong { color: var(--ink); }
.review-note { border-right: 3px solid var(--blue); padding-right: 10px; color: #475467; }
.review-actions { flex-wrap: wrap; }
.reject, .danger { min-height: 42px; border: 0; border-radius: 7px; padding: 0 15px; background: var(--red-soft); color: var(--red); font-weight: 900; }
.submission-errors { border-radius: 7px; padding: 10px; background: var(--red-soft); color: var(--red); line-height: 1.5; }
.no-media { color: var(--muted); }
.submission-carousel { display: grid; width: 100%; height: 100%; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 5px; padding: 5px; }
.submission-carousel > div { position: relative; min-width: 0; min-height: 140px; }
.submission-carousel img, .submission-carousel video { width: 100%; height: 100%; object-fit: contain; }
.posts-layout { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.post-list { display: grid; gap: 10px; }
.post-card { display: grid; gap: 9px; border: 1px solid var(--line); border-radius: 8px; padding: 12px; }
.post-assets { display: grid; grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)); gap: 5px; }
.post-assets img { width: 100%; max-height: 220px; object-fit: contain; border-radius: 6px; background: #f1f3f5; }
.post-card p { overflow-wrap: anywhere; line-height: 1.5; }
.status { margin-inline-start: 7px; color: var(--muted); font-size: 12px; font-weight: 800; }
.message { min-height: 26px; margin-top: 12px; color: var(--muted); font-weight: 800; }
.message.success { color: var(--green); }
.message.error { color: var(--red); }
.notice { border: 1px solid #efd489; border-radius: 7px; padding: 10px 12px; background: var(--amber-soft); color: #765000; font-size: 13px; line-height: 1.6; }
.empty-state { padding: 18px; color: var(--muted); text-align: center; }

.login-screen { display: grid; min-height: 100vh; place-items: center; padding: 24px; background: #eef2f6; }
.login-card { width: min(100%, 470px); border: 1px solid var(--line); border-radius: 8px; background: white; padding: 32px; box-shadow: 0 22px 60px rgba(23, 32, 42, .12); }
.login-brand { display: flex; align-items: center; gap: 12px; padding-bottom: 24px; border-bottom: 1px solid var(--line); }
.brand-mark, .team-avatar, #currentUserInitial { display: grid; place-items: center; flex: 0 0 auto; border-radius: 7px; background: var(--ink); color: white; font-weight: 900; }
.brand-mark { width: 44px; height: 44px; font-size: 21px; }
.login-brand div, .user-chip > span:last-child { display: grid; gap: 3px; }
.login-brand small { color: var(--muted); }
.login-copy { display: grid; gap: 10px; padding: 28px 0 20px; }
.login-copy h1 { font-size: 30px; }
.login-copy p:last-child { color: var(--muted); line-height: 1.7; }
.login-form { gap: 13px; }
.login-otp-step { display: grid; gap: 12px; margin-top: 4px; border-top: 1px solid var(--line); padding-top: 16px; }
.otp-field { display: grid; gap: 7px; }
.otp-label { color: #475467; font-size: 14px; font-weight: 800; }
.otp-input { min-height: 58px !important; border-color: var(--green) !important; padding: 0 0 0 20px !important; color: var(--ink); font-family: Arial, sans-serif; font-size: 24px !important; font-weight: 900 !important; letter-spacing: 20px; text-align: center; }
.otp-input::placeholder { color: #77818c; opacity: 1; }
.otp-input:focus { outline-color: rgba(8, 122, 85, .14) !important; }
#loginMessage:empty { display: none; }
#loginMessage.success { min-height: 0; margin: 0; border-radius: 7px; padding: 10px 12px; background: var(--green-soft); font-size: 13px; text-align: center; }
#loginMessage.error { min-height: 0; margin: 0; border-radius: 7px; padding: 10px 12px; background: var(--red-soft); font-size: 13px; text-align: center; }
.text-button { width: fit-content; border: 0; background: transparent; color: var(--blue); font-weight: 800; }
.session-note { margin-top: 12px; color: var(--muted); font-size: 12px; line-height: 1.6; text-align: center; }
.account-actions, .user-chip { display: flex; align-items: center; gap: 9px; }
.account-actions { flex-wrap: wrap; justify-content: flex-end; }
.user-chip { min-height: 44px; border: 1px solid var(--line); border-radius: 7px; background: white; padding: 5px 9px; }
#currentUserInitial { width: 32px; height: 32px; background: var(--blue); }
.user-chip small { color: var(--muted); font-size: 11px; }
.team-panel { margin-bottom: 20px; }
.team-form { display: grid; grid-template-columns: 1fr 1fr 180px minmax(230px, 1fr) auto; align-items: end; gap: 10px; margin-top: 16px; }
.brand-permissions { padding: 8px 12px; }
.check-row { display: flex; flex-wrap: wrap; gap: 12px; }
.check-row label { display: flex; align-items: center; gap: 6px; color: var(--ink); }
.brand-filter { min-width: 150px; gap: 4px; font-size: 11px; }
.brand-filter select { min-height: 38px; padding-block: 6px; }
.component-review { display: grid; gap: 10px; border-top: 1px solid var(--line); padding-top: 13px; }
.team-list { display: grid; gap: 8px; margin-top: 8px; }
.team-user { display: grid; grid-template-columns: auto 1fr auto auto; align-items: center; gap: 11px; border-top: 1px solid var(--line); padding: 10px 0; }
.team-user.inactive { opacity: .65; }
.team-avatar { width: 36px; height: 36px; background: #344054; }
.team-user-details { display: grid; gap: 4px; min-width: 0; }
.team-user-details small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@media (max-width: 860px) {
  .composer-layout, .designer-layout, .posts-layout, .manager-login, .approval-card { grid-template-columns: 1fr; }
  .team-form { grid-template-columns: 1fr 1fr; }
  .preview-panel { position: static; }
  .approval-media { min-height: 240px; border-left: 0; border-bottom: 1px solid var(--line); }
}

@media (max-width: 600px) {
  .shell { width: min(100% - 20px, 1220px); padding-top: 16px; }
  .topbar, .section-heading, .media-row { align-items: stretch; flex-direction: column; }
  .account-actions { justify-content: stretch; }
  .user-chip { flex: 1; }
  .login-screen { padding: 12px; }
  .login-card { padding: 22px 18px; }
  .team-form { grid-template-columns: 1fr; }
  .team-user { grid-template-columns: auto 1fr auto; }
  .team-user button { grid-column: 1 / -1; width: 100%; }
  .otp-step { grid-template-columns: 1fr; }
  .role-tabs { display: grid; grid-template-columns: repeat(2, 1fr); width: 100%; }
  .role-tab { padding: 0 8px; }
  .channel-grid, .stats { grid-template-columns: 1fr; }
  .submit-button, .review-actions button { width: 100%; }
}
