:root {
  --ink: #0f141b;
  --navy: #1b2330;
  --navy-2: #243042;
  --blue: #1e4e79;
  --blue-2: #2c6aa3;
  --steel: #8a96a3;
  --line: #dfe4ea;
  --bg: #f3f5f8;
  --card: #ffffff;
  --text: #1b2330;
  --muted: #5d6b7a;
  --ok: #1f7a4d;
  --warn: #a86a00;
  --bad: #b3261e;
  --radius: 10px;
  font-family: "Heebo", system-ui, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 15px; }
.hidden { display: none !important; }
a { color: var(--blue); }

.brand { font-weight: 800; font-size: 20px; letter-spacing: -0.5px; }
.brand span { font-weight: 400; color: var(--steel); margin-inline-start: 4px; }

.login { min-height: 100vh; display: grid; place-items: center; background: var(--navy); }
.login-card { background: var(--card); padding: 32px; border-radius: 14px; width: min(360px, 92vw); display: grid; gap: 16px; }

.shell { display: grid; grid-template-columns: 230px 1fr; min-height: 100vh; }
.sidebar { background: var(--navy); color: #fff; padding: 24px 16px; display: flex; flex-direction: column; gap: 24px; position: sticky; top: 0; height: 100vh; }
.sidebar .brand span { color: #9fb3c8; }
.sidebar nav { display: grid; gap: 4px; }
.sidebar nav a { color: #c9d3de; text-decoration: none; padding: 10px 12px; border-radius: 8px; font-weight: 500; }
.sidebar nav a:hover { background: var(--navy-2); color: #fff; }
.sidebar nav a.active { background: var(--blue); color: #fff; }
.ai-badge { margin-top: auto; font-size: 12px; color: #9fb3c8; }

.page { padding: 28px 32px; max-width: 1200px; width: 100%; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: 24px; }
.page-head p { margin: 4px 0 0; color: var(--muted); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.grid { display: grid; gap: 16px; }
.grid.stats { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.stat .num { font-size: 30px; font-weight: 800; }
.stat .label { color: var(--muted); }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: right; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 500; font-size: 13px; }
tr:last-child td { border-bottom: 0; }
.table-wrap { overflow-x: auto; }

.btn { border: 1px solid var(--line); background: #fff; color: var(--text); padding: 8px 14px; border-radius: 8px; font: inherit; font-weight: 500; cursor: pointer; }
.btn:hover { border-color: var(--steel); }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.primary:hover { background: var(--blue-2); }
.btn.danger { color: var(--bad); }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn:disabled { opacity: .55; cursor: wait; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

label { display: grid; gap: 6px; font-weight: 500; font-size: 14px; }
input, select, textarea { font: inherit; padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--text); width: 100%; }
textarea { min-height: 120px; resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--blue-2); outline-offset: -1px; }
.form { display: grid; gap: 14px; }
.form .cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.check { display: flex; gap: 8px; align-items: center; font-weight: 400; }
.check input { width: auto; }
.hint { color: var(--muted); font-size: 13px; margin: 0; }
.error { color: var(--bad); margin: 0; min-height: 1em; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 12px; font-weight: 500; background: #eef1f5; color: var(--muted); white-space: nowrap; }
a.badge { text-decoration: none; padding: 4px 10px; font-size: 13px; }
a.badge.active { background: var(--blue); color: #fff; }
.badge.pending { background: #eaf1f8; color: var(--blue); }
.badge.in_progress { background: #fff3dc; color: var(--warn); }
.badge.posted, .badge.active, .badge.done { background: #e4f4ec; color: var(--ok); }
.badge.failed { background: #fbe9e7; color: var(--bad); }
.badge.cancelled, .badge.paused, .badge.draft, .badge.skipped { background: #eef1f5; color: var(--muted); }

.thumbs { display: flex; gap: 6px; flex-wrap: wrap; }
.thumbs img { width: 64px; height: 48px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); }
.thumb-item { position: relative; }
.thumb-item button { position: absolute; top: -6px; left: -6px; border: 0; background: var(--bad); color: #fff; border-radius: 50%; width: 18px; height: 18px; font-size: 11px; cursor: pointer; line-height: 18px; padding: 0; }

.group-picker { max-height: 280px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; }
.group-picker .check { padding: 4px 0; }
.variant { white-space: pre-wrap; background: #f7f9fb; border: 1px solid var(--line); border-radius: 8px; padding: 10px; font-size: 14px; }
.pre { white-space: pre-wrap; }
.token { font-family: ui-monospace, monospace; font-size: 12px; direction: ltr; background: #f3f5f8; padding: 3px 6px; border-radius: 6px; word-break: break-all; }
.empty { color: var(--muted); text-align: center; padding: 28px 8px; }

.modal { position: fixed; inset: 0; background: rgba(15, 20, 27, .55); display: grid; place-items: center; z-index: 10; padding: 16px; }
.modal-card { background: #fff; border-radius: 14px; padding: 22px; width: min(760px, 100%); max-height: 90vh; overflow: auto; }
.modal-card h2 { margin-top: 0; }
.toast { position: fixed; bottom: 20px; left: 20px; background: var(--ink); color: #fff; padding: 12px 16px; border-radius: 10px; z-index: 20; max-width: 420px; }
.toast.bad { background: var(--bad); }

@media (max-width: 800px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; padding: 14px 16px; gap: 12px; }
  .shell > * { min-width: 0; }
  .sidebar nav { grid-auto-flow: column; overflow-x: auto; max-width: 100%; }
  .sidebar nav a { white-space: nowrap; }
  .ai-badge { display: none; }
  .page { padding: 18px 16px; }
}

/* ---- wide modal + campaign layout ---- */
.modal-card.wide { width: min(1180px, 100%); }
.cmp-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 24px; align-items: start; }
.cmp-preview { position: sticky; top: 0; }
@media (max-width: 900px) { .cmp-layout { grid-template-columns: 1fr; } .cmp-preview { position: static; } }

/* segmented buttons & chips */
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button, .seg a { border: 0; background: #fff; padding: 7px 14px; font: inherit; cursor: pointer; color: var(--text); text-decoration: none; }
.seg button + button, .seg a + a { border-inline-start: 1px solid var(--line); }
.seg .on { background: var(--blue); color: #fff; }
.chip { display: inline-flex; align-items: center; gap: 4px; border: 1px solid var(--line); border-radius: 99px; padding: 4px 10px; font-weight: 400; cursor: pointer; }
.chip input { width: auto; }
fieldset.sched { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; display: grid; gap: 10px; margin: 0; }
fieldset.sched legend { font-weight: 700; padding: 0 6px; }
.logo-box { width: 120px; height: 80px; border: 1px dashed var(--line); border-radius: 8px; display: grid; place-items: center; background: repeating-conic-gradient(#f3f5f8 0 25%, #fff 0 50%) 0 0 / 16px 16px; }
.logo-box img { max-width: 100%; max-height: 100%; }

/* phone preview */
.phone { border: 10px solid #111; border-radius: 34px; background: #fff; box-shadow: 0 8px 30px rgba(0,0,0,.15); overflow: hidden; }
.phone-screen { height: 560px; overflow: auto; background: #f0f2f5; }
.pv-top { background: #fff; padding: 10px 12px; color: #1877f2; font-size: 20px; letter-spacing: -0.5px; }
.pv-post { background: #fff; margin-top: 8px; font-size: 14px; }
.pv-head { display: flex; gap: 8px; padding: 10px 12px; align-items: center; }
.pv-avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--blue); color: #fff; display: grid; place-items: center; font-weight: 700; flex: none; }
.pv-name { font-weight: 600; }
.pv-text { padding: 0 12px 10px; white-space: pre-wrap; line-height: 1.45; }
.pv-images { display: grid; gap: 2px; }
.pv-images.n2 { grid-template-columns: 1fr 1fr; }
.pv-images.n3 { grid-template-columns: 1fr 1fr; }
.pv-images.n3 .pv-img:first-child { grid-column: 1 / -1; }
.pv-img { position: relative; }
.pv-img > img:first-child { width: 100%; display: block; aspect-ratio: 4 / 3; object-fit: cover; }
.pv-logo { position: absolute; }
.pv-logo.top-right { top: 3%; right: 3%; } .pv-logo.top-left { top: 3%; left: 3%; }
.pv-logo.bottom-right { bottom: 3%; right: 3%; } .pv-logo.bottom-left { bottom: 3%; left: 3%; }
.pv-more { position: absolute; inset: 0; background: rgba(0,0,0,.45); color: #fff; font-size: 26px; font-weight: 700; display: grid; place-items: center; }
.pv-actions { display: flex; justify-content: space-around; border-top: 1px solid #e4e6eb; padding: 8px 0; color: #65676b; font-size: 13px; }

/* weekly schedule board */
.week { display: grid; grid-template-columns: repeat(7, minmax(130px, 1fr)); gap: 10px; overflow-x: auto; }
.day { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; display: grid; gap: 8px; align-content: start; min-height: 320px; }
.day.today { border-color: var(--blue); box-shadow: 0 0 0 1px var(--blue); }
.day-head { display: flex; justify-content: space-between; align-items: baseline; }
.day-total { background: #fff6dc; color: #8a5a00; border-radius: 6px; text-align: center; font-weight: 700; padding: 4px; font-size: 13px; }
.slot { border: 1px solid var(--line); border-radius: 8px; padding: 8px; font-size: 13px; }
.slot-time { color: var(--blue); font-weight: 700; direction: ltr; text-align: right; }
.slot-name { font-weight: 600; margin: 2px 0; }

/* bar charts (single series, one hue) */
.bars { display: flex; gap: 10px; align-items: flex-end; height: 200px; padding-top: 24px; border-bottom: 1px solid var(--line); }
.bar-col { flex: 1; display: grid; grid-template-rows: 1fr auto; height: 100%; outline: none; }
.bar-track { position: relative; display: flex; align-items: flex-end; justify-content: center; }
.bar { width: min(40px, 70%); background: var(--blue); border-radius: 4px 4px 0 0; min-height: 2px; }
.bar-tip { position: absolute; bottom: calc(100% + 4px); background: var(--ink); color: #fff; padding: 3px 8px; border-radius: 6px; font-size: 12px; white-space: nowrap; opacity: 0; pointer-events: none; transition: opacity .1s; }
.bar-col:hover .bar-tip, .bar-col:focus .bar-tip { opacity: 1; }
.bar-col:hover .bar { background: var(--blue-2); }
.bar-label { text-align: center; font-size: 12px; color: var(--muted); padding-top: 6px; }
.hbar { margin: 10px 0; }
.hbar-track { height: 8px; background: #eef1f5; border-radius: 99px; margin-top: 4px; }
.hbar-fill { height: 100%; background: var(--blue); border-radius: 99px; }

.cmp-preview .phone { max-width: 340px; margin: 0 auto; }

/* drop zone */
.dropzone { margin-top: 8px; border: 2px dashed var(--line); border-radius: 10px; padding: 18px; text-align: center; color: var(--muted); cursor: pointer; transition: background .1s, border-color .1s; }
.dropzone:hover, .dropzone.over { border-color: var(--blue-2); background: #eaf1f8; color: var(--blue); }
.dropzone.busy { opacity: .6; pointer-events: none; }
.dropzone.busy .dz-text::after { content: " · מעלה..."; }
.thumbs video { width: 64px; height: 48px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); background: #000; }
.pv-img > :first-child { width: 100%; display: block; aspect-ratio: 4 / 3; object-fit: cover; background: #000; }

/* pace + whatsapp hints, extension status */
.pace { background: #f3f7fb; border: 1px solid #dbe6f1; border-radius: 8px; padding: 8px 10px; font-size: 13px; color: var(--text); display: grid; gap: 2px; }
.ext-status { margin-bottom: 12px; padding: 12px 16px; }
.ext-status.ok { border-color: #bfe3cf; background: #f2faf5; }
.ext-status.warn { border-color: #f1d9a6; background: #fffaf0; }
.ext-status.bad { border-color: #f2b8b5; background: #fdf1f0; }

.stats-line { font-size: 12px; color: var(--muted); margin-top: 2px; white-space: nowrap; }
