:root {
  --navy: #0d2c41;
  --navy-2: #163b55;
  --teal: #239c98;
  --teal-dark: #1b7d7a;
  --slate: #6f6a67;
  --gold: #ffc665;
  --tan: #b58f64;
  --sky: #739cd1;
  --cream: #f6f3ee;
  --light: #e7e9ec;
  --line: #dfe2e6;
  --white: #ffffff;
  --ink: #142231;
  --muted: #5d6670;
  --ok: #1f8a5b;
  --ok-bg: #e5f4ec;
  --warn: #9a6200;
  --warn-bg: #fff4dc;
  --err: #b3261e;
  --err-bg: #fdeceb;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(13, 44, 65, 0.06), 0 4px 16px rgba(13, 44, 65, 0.06);
  --display: 'Poppins', 'Century Gothic', system-ui, sans-serif;
  --body: 'Open Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--body);
  color: var(--ink);
  background: var(--cream);
  font-size: 15px;
  line-height: 1.5;
}
h1, h2, h3 { font-family: var(--display); color: var(--navy); margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 24px; }
h2 { font-size: 19px; }
h3 { font-size: 16px; }
a { color: var(--teal-dark); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.hidden { display: none !important; }

/* ---------- header ---------- */
.topbar {
  background: var(--navy);
  color: var(--white);
  position: sticky; top: 0; z-index: 20;
}
.topbar-inner {
  max-width: 1180px; margin: 0 auto; padding: 10px 16px;
  display: flex; align-items: center; gap: 24px; flex-wrap: wrap;
}
.topbar-logo { height: 42px; width: auto; display: block; }
.login-logo { width: 230px; display: block; margin: 0 auto 8px; }
.brand-name { font-family: var(--display); font-size: 13px; letter-spacing: 0.18em; text-transform: uppercase; color: #b9d7e0; }
.tabs { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.tab {
  background: none; border: 0; color: #cfe0e8; font: 600 14px var(--display);
  padding: 8px 14px; border-radius: 999px; cursor: pointer;
}
.tab:hover { color: var(--white); background: rgba(255, 255, 255, 0.08); }
.tab.active { background: var(--teal); color: var(--white); }
.topbar .link-btn { color: #cfe0e8; background: none; border: 0; cursor: pointer; font: 14px var(--body); }

main { max-width: 1180px; margin: 0 auto; padding: 24px 16px 80px; }

/* ---------- common ---------- */
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.stack > * + * { margin-top: 12px; }
.card {
  background: var(--white); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px;
}
.section-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }

.btn {
  display: inline-flex; align-items: center; gap: 6px; justify-content: center;
  border: 1px solid var(--line); background: var(--white); color: var(--navy);
  font: 600 14px var(--display); padding: 8px 14px; border-radius: 8px; cursor: pointer;
  text-decoration: none; white-space: nowrap;
}
.btn:hover { border-color: var(--navy); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn.primary { background: var(--teal); border-color: var(--teal); color: var(--white); }
.btn.primary:hover { background: var(--teal-dark); border-color: var(--teal-dark); }
.btn.navy { background: var(--navy); border-color: var(--navy); color: var(--white); }
.btn.danger { color: var(--err); }
.btn.danger:hover { border-color: var(--err); }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--light); }

label { display: block; font-weight: 600; font-size: 13px; color: var(--navy); margin-bottom: 4px; }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=time], input[type=datetime-local], select, textarea {
  width: 100%; font: 15px var(--body); color: var(--ink);
  padding: 9px 11px; border: 1px solid #cdd3d9; border-radius: 8px; background: var(--white);
}
textarea { resize: vertical; min-height: 90px; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(35, 156, 152, 0.35); border-color: var(--teal); }
.field { margin-bottom: 14px; }
.hint { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (max-width: 640px) { .grid2, .grid3 { grid-template-columns: 1fr; } }

.pill {
  display: inline-flex; align-items: center; gap: 5px; font: 600 12px var(--display);
  padding: 3px 9px; border-radius: 999px; background: var(--light); color: var(--navy); white-space: nowrap;
}
.pill.draft { background: var(--light); color: var(--slate); }
.pill.scheduled { background: #e3f2f1; color: var(--teal-dark); }
.pill.publishing { background: #e8effa; color: #2f5d9c; }
.pill.published { background: var(--ok-bg); color: var(--ok); }
.pill.partial { background: var(--warn-bg); color: var(--warn); }
.pill.failed { background: var(--err-bg); color: var(--err); }
.pill.skipped { background: var(--light); color: var(--slate); }
.pill.pending { background: #eef1f4; color: var(--muted); }
.pill.ai { background: #fff4dc; color: #7a5200; }

.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--white); font-size: 13px; cursor: pointer; user-select: none;
}
.chip.on { background: var(--navy); color: var(--white); border-color: var(--navy); }
.platform-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.p-facebook { background: #1877f2; }
.p-instagram { background: #d62976; }
.p-youtube { background: #ff0000; }
.p-tiktok { background: #111111; }

.banner { padding: 12px 14px; border-radius: 10px; font-size: 14px; margin-bottom: 16px; border: 1px solid; }
.banner.info { background: #eaf4f4; border-color: #bfe0de; color: #154e4c; }
.banner.warn { background: var(--warn-bg); border-color: #f2d496; color: #6d4a00; }
.banner.err { background: var(--err-bg); border-color: #f2c2bf; color: #7d1c16; }
.banner.ok { background: var(--ok-bg); border-color: #b9e0c9; color: #175d3f; }
.banner ul { margin: 6px 0 0; padding-left: 18px; }

.empty { text-align: center; padding: 48px 16px; color: var(--muted); }
.empty h3 { margin-bottom: 6px; }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: var(--navy); }
.login-card { width: 100%; max-width: 380px; background: var(--white); border-radius: 16px; padding: 28px; box-shadow: 0 20px 50px rgba(0,0,0,0.25); }

.login-card .tag { text-align: center; font: 600 11px var(--display); letter-spacing: 0.3em; color: var(--slate); margin-bottom: 22px; }

/* ---------- clients ---------- */
.clients { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 16px; }
@media (max-width: 400px) { .clients { grid-template-columns: 1fr; } }
.client-card h3 { font-size: 17px; }
.linkbox { display: flex; gap: 6px; margin: 10px 0; }
.linkbox input { font-size: 12.5px; background: #f7f8f9; }
.acct { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--light); font-size: 14px; }
.acct .name { flex: 1; min-width: 0; overflow-wrap: anywhere; line-height: 1.35; }
.acct .name .warn-line { font-size: 12.5px; margin-top: 2px; }
.switch { position: relative; width: 36px; height: 20px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: #c9ced4; border-radius: 999px; transition: 0.15s; cursor: pointer; }
.switch span::before { content: ''; position: absolute; width: 16px; height: 16px; left: 2px; top: 2px; background: white; border-radius: 50%; transition: 0.15s; }
.switch input:checked + span { background: var(--teal); }
.switch input:checked + span::before { transform: translateX(16px); }

/* ---------- modal ---------- */
.modal-bg {
  position: fixed; inset: 0; background: rgba(13, 44, 65, 0.55); z-index: 50;
  display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow-y: auto;
}
.modal { background: var(--white); border-radius: 16px; width: 100%; max-width: 680px; padding: 22px; box-shadow: 0 20px 60px rgba(0,0,0,0.3); }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; flex-wrap: wrap; }
.close-x { background: none; border: 0; font-size: 24px; line-height: 1; cursor: pointer; color: var(--slate); }
.counter { font-size: 12px; color: var(--muted); text-align: right; margin-top: 3px; }
.img-preview { display: flex; gap: 12px; align-items: center; margin-top: 8px; }
.img-preview img { width: 84px; height: 84px; object-fit: cover; border-radius: 8px; }

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 100;
  background: var(--navy); color: white; padding: 10px 18px; border-radius: 999px; font-size: 14px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.25); max-width: calc(100% - 32px);
}
.toast.err { background: var(--err); }

.activity { font-size: 13.5px; }
.activity div { padding: 8px 0; border-bottom: 1px solid var(--light); display: grid; grid-template-columns: 150px 90px 1fr; gap: 10px; }
@media (max-width: 640px) { .activity div { grid-template-columns: 1fr; gap: 2px; } }
.spinner { width: 16px; height: 16px; border: 2px solid rgba(255,255,255,0.4); border-top-color: white; border-radius: 50%; animation: spin 0.8s linear infinite; display: inline-block; }
.btn:not(.primary):not(.navy) .spinner { border-color: rgba(13,44,65,0.2); border-top-color: var(--navy); }
@keyframes spin { to { transform: rotate(360deg); } }

.color-field { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.color-field input[type=color] { width: 44px; height: 32px; padding: 0; border: 1px solid var(--line); border-radius: 6px; background: none; cursor: pointer; }

.flag { overflow-wrap: anywhere; background: var(--warn-bg); color: #6d4a00; border-radius: 8px; padding: 7px 10px; font-size: 13px; }
.flag.err { background: var(--err-bg); color: #7d1c16; }

/* ---------- setup checklist ---------- */
.setup { display: flex; gap: 8px; flex-wrap: wrap; }
.setup .pill.ok { background: var(--ok-bg); color: var(--ok); }
.setup .pill.no { background: var(--warn-bg); color: var(--warn); }

/* ---------- video cards ---------- */
.vlist { display: grid; gap: 16px; }
.vcard {
  display: grid; grid-template-columns: 300px 1fr; gap: 20px;
  background: var(--white); border: 1px solid var(--line); border-left: 4px solid #c9ced4;
  border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow);
}
.vcard.f-long { grid-template-columns: 440px 1fr; }
.vcard.s-scheduled { border-left-color: var(--teal); }
.vcard.s-published { border-left-color: var(--ok); }
.vcard.s-failed { border-left-color: var(--err); }
.vcard.s-partial { border-left-color: var(--gold); }
.vcard.s-rejected { opacity: 0.7; }
@media (max-width: 900px) { .vcard, .vcard.f-long { grid-template-columns: 1fr; } }
.player { width: 100%; border-radius: 10px; background: #0b1d2b; display: block; }
.f-short .player { aspect-ratio: 9 / 16; max-height: 560px; }
.f-long .player { aspect-ratio: 16 / 9; }
.thumb-row { display: flex; gap: 10px; align-items: center; margin-top: 10px; }
.thumb-row img { width: 160px; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); }
.vmeta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; font-size: 13px; }
.vmeta strong { font-family: var(--display); color: var(--navy); font-size: 15px; }
.pill.f-short { background: #fde8f1; color: #9b1c56; }
.pill.f-long { background: #fde6e6; color: #a11414; }
.summary { font-size: 14px; color: var(--ink); background: #f4f6f8; border-radius: 8px; padding: 8px 10px; margin-bottom: 12px; }
.vfields .field { margin-bottom: 10px; }
.vfields textarea { min-height: 120px; font-size: 14px; }
.dests { display: flex; gap: 6px; flex-wrap: wrap; }
.dests .chip input { display: none; }
.vactions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--light); }
.vactions .grow { flex: 1; }
.targets { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.target { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; padding: 3px 9px; border-radius: 999px; background: #f2f4f6; text-decoration: none; color: inherit; }
.target.t-published { background: var(--ok-bg); }
.target.t-failed { background: var(--err-bg); }
.target.t-skipped { background: var(--light); color: var(--muted); }
.target-err { font-size: 12.5px; color: var(--err); margin-top: 6px; }
.readonly { white-space: pre-wrap; font-size: 14px; background: #f7f8f9; border-radius: 8px; padding: 10px; max-height: 220px; overflow: auto; }
.counts { display: inline-flex; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--gold); color: var(--navy); font-size: 12px; align-items: center; justify-content: center; margin-left: 4px; }

/* ---------- jobs ---------- */
.jobs { display: grid; gap: 10px; }
.job { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: center; background: var(--white); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.job .note { font-size: 13px; color: var(--muted); white-space: pre-wrap; }
.pill.collecting { background: #eef1f4; color: var(--muted); }
.pill.processing { background: #e8effa; color: #2f5d9c; }
.pill.done { background: var(--ok-bg); color: var(--ok); }
.pill.cancelled { background: var(--light); color: var(--slate); }
.pill.rejected { background: var(--light); color: var(--slate); }

.endcards { display: flex; gap: 12px; align-items: flex-start; flex-wrap: wrap; }
.endcards img { border-radius: 8px; border: 1px solid var(--line); display: block; }
.music-row { display: flex; gap: 10px; align-items: center; padding: 8px 0; border-top: 1px solid var(--light); font-size: 14px; }
.music-row audio { height: 32px; }
.days { display: flex; gap: 4px; flex-wrap: wrap; }

/* Phones: logo and sign-out on one line, tabs in a scrolling row below. */
@media (max-width: 720px) {
  .topbar-inner { gap: 8px 12px; padding: 8px 12px; justify-content: space-between; }
  .topbar-logo { height: 34px; }
  .brand-name { display: none; }
  .tabs { order: 3; flex: 1 0 100%; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -12px; padding: 0 12px 4px; }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { flex: none; padding: 7px 12px; }
  main { padding-top: 16px; }
  .vcard { padding: 14px; gap: 14px; }
  .f-short .player { max-height: 70vh; width: auto; margin: 0 auto; }
}
#bf h3 { margin: 26px 0 10px; }
#bf h3:first-child { margin-top: 0; }
.client-card > .row.spread { flex-wrap: nowrap; align-items: flex-start; }
