/* EnAds - mobile first: bottom tab bar on phones, side rail on wide screens (same design as EnCRM, orange). */
:root {
  --bg: #f5f6fa; --card: #fff; --ink: #1d2030; --muted: #6b7083; --line: #e6e8ef; --accent: #ea580c; --accent-soft: #fff1e6;
  --good: #15803d; --good-soft: #e7f6ec; --warn: #b45309; --warn-soft: #fff4e0; --bad: #b91c1c; --bad-soft: #fdecec;
  --radius: 14px; --nav-h: 62px; --safe-b: env(safe-area-inset-bottom, 0px);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-size: 15px; -webkit-tap-highlight-color: transparent; }
a { color: var(--accent); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
h1 { font-size: 20px; margin: 0; } h2 { font-size: 16px; margin: 0 0 10px; } h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 18px 0 8px; }
.muted { color: var(--muted); } .small { font-size: 13px; } .mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; }
.num { text-align: right; font-variant-numeric: tabular-nums; } .nowrap { white-space: nowrap; }
.hidden { display: none !important; }

/* layout */
.shell { min-height: 100vh; padding-bottom: calc(var(--nav-h) + var(--safe-b) + 12px); }
.top { position: sticky; top: 0; z-index: 20; background: var(--bg); padding: 12px 16px 8px; display: flex; align-items: center; gap: 10px; }
.top .title { flex: 1; min-width: 0; } .top .title .sub { font-size: 12px; color: var(--muted); }
.page { padding: 0 16px 16px; max-width: 980px; }
.nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; height: calc(var(--nav-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  background: #fff; border-top: 1px solid var(--line); display: flex; }
.nav a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--muted); font-size: 11px; font-weight: 600; position: relative; }
.nav a svg { width: 24px; height: 24px; }
.nav a.on { color: var(--accent); }
.nav a .dot { position: absolute; top: 8px; left: 50%; margin-left: 6px; min-width: 16px; height: 16px; border-radius: 8px; background: var(--bad); color: #fff; font-size: 10px; line-height: 16px; text-align: center; padding: 0 4px; }
@media (min-width: 900px) {
  .shell { padding-bottom: 20px; padding-left: 92px; }
  .nav { top: 0; bottom: 0; right: auto; width: 84px; height: auto; flex-direction: column; justify-content: flex-start; padding-top: 14px; border-top: 0; border-right: 1px solid var(--line); }
  .nav a { flex: 0 0 72px; }
  .page, .top { padding-left: 20px; padding-right: 20px; }
}

/* pieces */
.card { background: var(--card); border-radius: var(--radius); padding: 14px; box-shadow: 0 1px 2px rgba(20,24,40,.05); margin-bottom: 12px; }
.card.flush { padding: 0; overflow: hidden; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid4 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 700px) { .grid4 { grid-template-columns: repeat(4, 1fr); } }
.stat { background: var(--card); border-radius: var(--radius); padding: 12px 14px; box-shadow: 0 1px 2px rgba(20,24,40,.05); }
.stat .lbl { font-size: 12px; color: var(--muted); font-weight: 600; } .stat .val { font-size: 21px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; } .stat .hint { font-size: 12px; color: var(--muted); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 9px 14px; font-weight: 600; cursor: pointer; min-height: 40px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.good { background: var(--good); border-color: var(--good); color: #fff; } .btn.bad { background: #fff; border-color: #f2c4c4; color: var(--bad); }
.btn.sm { min-height: 32px; padding: 5px 10px; font-size: 13px; border-radius: 8px; }
.btn.block { width: 100%; }
/* Icons inside buttons (Call, WhatsApp…) stay icon-sized; button links are not underlined. */
.btn svg { width: 18px; height: 18px; flex: none; }
.btn.sm svg { width: 16px; height: 16px; }
a.btn { text-decoration: none; color: inherit; } a.btn.primary, a.btn.good { color: #fff; }
.btn:disabled { opacity: .55; }
.icon-btn { width: 40px; height: 40px; border-radius: 12px; border: 0; background: #fff; display: inline-flex; align-items: center; justify-content: center; position: relative; box-shadow: 0 1px 2px rgba(20,24,40,.06); cursor: pointer; }
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn .dot { position: absolute; top: 4px; right: 4px; min-width: 16px; height: 16px; border-radius: 8px; background: var(--bad); color: #fff; font-size: 10px; line-height: 16px; padding: 0 4px; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: #eef0f5; color: #4b5064; white-space: nowrap; }
.b-good { background: var(--good-soft); color: var(--good); } .b-warn { background: var(--warn-soft); color: var(--warn); } .b-bad { background: var(--bad-soft); color: var(--bad); } .b-acc { background: var(--accent-soft); color: var(--accent); }
.alert { padding: 10px 12px; border-radius: 10px; margin-bottom: 12px; font-size: 14px; }
.alert.warn { background: var(--warn-soft); color: #7a3e06; } .alert.bad { background: var(--bad-soft); color: var(--bad); } .alert.info { background: var(--accent-soft); color: #9a3412; }
.empty { padding: 28px 16px; text-align: center; color: var(--muted); }

/* forms */
.f { display: block; margin-bottom: 12px; }
.f > span { display: block; font-size: 13px; font-weight: 600; color: #464a5c; margin-bottom: 5px; }
.f input, .f select, .f textarea, .search { width: 100%; border: 1px solid #d7dae4; border-radius: 10px; padding: 10px 12px; background: #fff; min-height: 44px; outline: none; }
.f textarea { min-height: 80px; resize: vertical; }
.f input:focus, .f select:focus, .f textarea:focus, .search:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.hint-text { font-size: 12px; color: var(--muted); margin-top: 4px; }
.check { display: flex; align-items: center; gap: 8px; margin: 6px 0 12px; font-weight: 600; font-size: 14px; }
.check input { width: 20px; height: 20px; }
.seg { display: flex; background: #e9ebf2; border-radius: 10px; padding: 3px; gap: 3px; }
.seg button { flex: 1; border: 0; background: transparent; border-radius: 8px; padding: 7px 6px; font-weight: 600; font-size: 13px; color: var(--muted); cursor: pointer; }
.seg button.on { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(20,24,40,.1); }
.req { color: var(--bad); }

/* chips */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 10px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: 0 0 auto; border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 6px 12px; font-size: 13px; font-weight: 600; color: #464a5c; cursor: pointer; white-space: nowrap; }
.chip.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.chip .n { opacity: .65; margin-left: 4px; font-weight: 500; }

/* lists */
.item { display: flex; gap: 12px; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--line); background: #fff; cursor: pointer; }
.item:last-child { border-bottom: 0; }
.item .main { flex: 1; min-width: 0; }
.item .t1 { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .t2 { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.item .side { text-align: right; flex: 0 0 auto; }
.item .amt { font-weight: 700; font-variant-numeric: tabular-nums; }
.item.off { opacity: .5; } .item.off .amt { text-decoration: line-through; }
.qa { display: flex; gap: 6px; }
.qa a { width: 38px; height: 38px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; }
.qa a svg { width: 20px; height: 20px; }
.qa .call { background: var(--accent-soft); color: var(--accent); } .qa .wa { background: #e5f8ec; color: #128c4a; }
.avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: flex; align-items: center; justify-content: center; font-weight: 700; flex: 0 0 auto; }

/* status colours */
.st-New { background: #e0ecff; color: #1d4ed8; } .st-Contact-Attempted { background: #fff4e0; color: #b45309; } .st-Contacted { background: #e6f4ff; color: #0369a1; }
.st-Qualified { background: #f0e8ff; color: #6d28d9; } .st-Follow-Up { background: #fff1d6; color: #a16207; } .st-Converted { background: var(--good-soft); color: var(--good); }
.st-Bad-Fit, .st-Not-Interested { background: #eef0f5; color: #6b7083; }

/* timeline */
.tl { list-style: none; margin: 0; padding: 0; }
.tl li { position: relative; padding: 0 0 14px 18px; border-left: 2px solid var(--line); margin-left: 6px; }
.tl li::before { content: ""; position: absolute; left: -6px; top: 4px; width: 10px; height: 10px; border-radius: 50%; background: #c7cbe0; }
.tl li.status::before { background: var(--accent); } .tl li.whatsapp_in::before, .tl li.whatsapp::before { background: #25d366; }
.tl .when { font-size: 12px; color: var(--muted); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 8px 14px; margin: 0; font-size: 14px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; word-break: break-word; }

/* floating + action bars */
.fab { position: fixed; right: 18px; bottom: calc(var(--nav-h) + var(--safe-b) + 16px); z-index: 25; width: 56px; height: 56px; border-radius: 18px; border: 0; background: var(--accent); color: #fff;
  box-shadow: 0 6px 18px rgba(234,88,12,.35); display: flex; align-items: center; justify-content: center; cursor: pointer; }
.fab svg { width: 28px; height: 28px; }
.actionbar { position: fixed; left: 0; right: 0; bottom: calc(var(--nav-h) + var(--safe-b)); z-index: 25; display: flex; gap: 8px; padding: 10px 12px; background: rgba(245,246,250,.96); border-top: 1px solid var(--line); }
.actionbar .btn { flex: 1; }
.has-actionbar { padding-bottom: 70px; }
@media (min-width: 900px) { .fab { bottom: 24px; } .actionbar { left: 84px; bottom: 0; } }

/* sheets (full-screen on phones, centred panel on wide screens) */
.sheet-bg { position: fixed; inset: 0; z-index: 50; background: rgba(15,18,30,.45); display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--bg); width: 100%; max-width: 640px; max-height: 94vh; border-radius: 18px 18px 0 0; display: flex; flex-direction: column; animation: up .18s ease-out; }
.sheet-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); background: #fff; border-radius: 18px 18px 0 0; }
.sheet-head h2 { flex: 1; margin: 0; }
.sheet-body { overflow-y: auto; padding: 16px; padding-bottom: calc(16px + var(--safe-b)); }
@media (min-width: 700px) { .sheet-bg { align-items: center; } .sheet { border-radius: 18px; } }
@keyframes up { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }

/* duty switch */
.duty { display: inline-flex; align-items: center; gap: 8px; border: 0; border-radius: 999px; padding: 6px 12px 6px 6px; font-weight: 700; font-size: 13px; cursor: pointer; background: #e9ebf2; color: #555b70; }
.duty .knob { width: 26px; height: 26px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.duty.on { background: var(--good); color: #fff; }

/* auth */
.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.auth .card { width: 100%; max-width: 380px; padding: 24px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 18px; margin-bottom: 18px; }
.brand img { width: 36px; height: 36px; }

#toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav-h) + var(--safe-b) + 80px); z-index: 80; display: flex; flex-direction: column; gap: 8px; width: min(92vw, 420px); pointer-events: none; }
#toast div { background: var(--ink); color: #fff; padding: 11px 14px; border-radius: 12px; font-size: 14px; box-shadow: 0 6px 18px rgba(0,0,0,.2); pointer-events: auto; }
#toast div.err { background: var(--bad); }
table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
table.t th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.t td { padding: 9px 10px; border-bottom: 1px solid var(--line); }
.tbl-wrap { overflow-x: auto; }
.shot { max-width: 100%; border-radius: 10px; border: 1px solid var(--line); }
.sug { border: 1px solid var(--line); border-radius: 10px; background: #fff; margin-top: -8px; margin-bottom: 12px; max-height: 220px; overflow-y: auto; }
.sug div { padding: 10px 12px; border-bottom: 1px solid var(--line); cursor: pointer; } .sug div:last-child { border-bottom: 0; }
.picked { display: flex; align-items: center; justify-content: space-between; gap: 8px; background: var(--accent-soft); border-radius: 10px; padding: 10px 12px; margin-bottom: 12px; }
/* Plans: one row, left to right, scrolled sideways (swipe on phones). */
.plans { display: flex; gap: 8px; overflow-x: auto; scroll-snap-type: x proximity; padding: 2px 2px 8px; margin: 0 -2px; -webkit-overflow-scrolling: touch; }
.plan { flex: 0 0 152px; scroll-snap-align: start; border: 1.5px solid var(--line); background: #fff; border-radius: 12px; padding: 10px 12px; text-align: left; cursor: pointer; display: flex; flex-direction: column; gap: 3px; min-height: 64px; }
.plan b { font-size: 15px; } .plan span { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.plan small { font-size: 12px; color: #4b5064; line-height: 1.35; margin-top: 2px; white-space: pre-line; }
.plan.on { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 2px var(--accent-soft); } .plan.on span { color: var(--accent); }
pre.code { background: #f0f1f6; padding: 10px; border-radius: 8px; white-space: pre-wrap; word-break: break-all; font-size: 13px; }


/* ---------- EnAds ---------- */
.stats4 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 12px; }
@media (min-width: 700px) { .stats4 { grid-template-columns: repeat(4, 1fr); } }
.stat.link { cursor: pointer; } .stat.link:hover { box-shadow: 0 0 0 2px var(--accent-soft); }
.stat .val.warn { color: var(--warn); } .stat .val.acc { color: var(--accent); }
/* Breakdown boxes (by ad account / salesperson / plan): side by side, scrolled sideways on phones. */
.bk { display: flex; gap: 10px; overflow-x: auto; padding: 2px 2px 10px; margin: 0 -2px 4px; scrollbar-width: thin; }
.bk .box { flex: 1 0 170px; background: var(--card); border-radius: var(--radius); box-shadow: 0 1px 2px rgba(20,24,40,.05); padding: 10px 12px; max-height: 210px; overflow-y: auto; }
.bk .box h4 { margin: 0 0 6px; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.bk .box button { display: flex; width: 100%; justify-content: space-between; gap: 8px; border: 0; background: none; padding: 5px 0; border-bottom: 1px solid var(--line); font-size: 14px; cursor: pointer; text-align: left; }
.bk .box button:last-child { border-bottom: 0; } .bk .box button b { font-variant-numeric: tabular-nums; }
.bk .box button.on { color: var(--accent); font-weight: 700; }
/* Request queue */
.queue { display: flex; gap: 10px; overflow-x: auto; padding: 2px 2px 10px; margin: 0 -2px 4px; }
.qcard { flex: 0 0 220px; background: #fff; border-radius: var(--radius); padding: 10px 12px; box-shadow: 0 1px 2px rgba(20,24,40,.06); border-top: 4px solid var(--warn); cursor: pointer; color: inherit; }
.qcard.working { border-top-color: #2563eb; }
.qcard .who { display: flex; justify-content: space-between; gap: 6px; font-size: 12px; font-weight: 700; color: var(--muted); }
.qcard .nm { font-weight: 700; margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qcard .sm { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.spin { display: inline-block; width: 10px; height: 10px; border: 2px solid #93c5fd; border-top-color: #2563eb; border-radius: 50%; animation: rot 1s linear infinite; vertical-align: -1px; margin-right: 4px; }
@keyframes rot { to { transform: rotate(360deg); } }
/* Ad cards */
.ads { display: grid; grid-template-columns: 1fr; gap: 10px; }
@media (min-width: 700px) { .ads { grid-template-columns: 1fr 1fr; } }
@media (min-width: 1200px) { .ads { grid-template-columns: 1fr 1fr 1fr; } }
.ad { background: #fff; border-radius: var(--radius); box-shadow: 0 1px 2px rgba(20,24,40,.06); padding: 12px 14px; cursor: pointer; color: inherit; display: block; border-left: 5px solid var(--good); position: relative; }
.ad.scheduled { border-left-color: #2563eb; } .ad.ending { border-left-color: var(--warn); } .ad.ended, .ad.stopped { border-left-color: #c3c7d4; }
.ad .top1 { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.ad .cn { font-weight: 750; font-size: 16px; line-height: 1.25; }
.ad .an { font-size: 13px; color: var(--muted); margin-top: 1px; }
.ad .tag { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; padding: 3px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); white-space: nowrap; }
.ad .dates { font-size: 13px; color: #4b5064; margin: 8px 0; display: flex; flex-wrap: wrap; gap: 2px 14px; }
.ad .dates span { color: var(--muted); }
.ad .bot { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; }
.ad .meta { font-size: 12px; color: var(--muted); text-align: right; line-height: 1.5; }
.ad .meta b { color: #4b5064; font-weight: 650; }
.ad .res { font-size: 12px; margin-top: 8px; color: #4b5064; display: flex; gap: 12px; flex-wrap: wrap; }
.ad .res b { font-variant-numeric: tabular-nums; }
.cd { display: flex; gap: 5px; }
.cd div { background: #f2f3f7; border-radius: 8px; padding: 4px 7px; text-align: center; min-width: 44px; }
.cd b { display: block; font-size: 17px; font-variant-numeric: tabular-nums; line-height: 1.2; }
.cd small { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.cd.ending div { background: var(--warn-soft); } .cd.ending b { color: var(--warn); }
.cd.late div { background: #eef0f5; } .cd.late b { color: var(--muted); font-size: 14px; }
.filters { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 10px; }
@media (min-width: 900px) { .filters { grid-template-columns: repeat(5, 1fr); } }
.filters select, .filters input { width: 100%; border: 1px solid #d7dae4; border-radius: 10px; padding: 8px 10px; background: #fff; min-height: 40px; font-size: 14px; }
/* Results */
.rgrid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 8px; }
@media (min-width: 700px) { .rgrid { grid-template-columns: repeat(3, 1fr); } }
/* Media */
.mgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; }
.mg { position: relative; aspect-ratio: 1 / 1; border-radius: 10px; overflow: hidden; background: #e9ebf2; border: 2px solid transparent; cursor: pointer; padding: 0; }
.mg img, .mg video { width: 100%; height: 100%; object-fit: cover; display: block; }
.mg .ic { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); padding: 6px; text-align: center; word-break: break-all; }
.mg .play { position: absolute; left: 6px; bottom: 6px; background: rgba(0,0,0,.6); color: #fff; border-radius: 6px; font-size: 11px; padding: 1px 6px; }
.mg.sel { border-color: var(--accent); }
.mg.sel::after { content: "✓"; position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; border-radius: 50%; background: var(--accent); color: #fff; font-size: 13px; line-height: 22px; text-align: center; font-weight: 800; }
.viewer { max-width: 100%; max-height: 70vh; display: block; margin: 0 auto 12px; border-radius: 10px; }
.drop { border: 2px dashed #d7dae4; border-radius: 12px; padding: 16px; text-align: center; color: var(--muted); margin-bottom: 12px; cursor: pointer; background: #fff; }
.drop.over { border-color: var(--accent); background: var(--accent-soft); }
.upl { font-size: 13px; margin: -4px 0 10px; }
.upl div { display: flex; justify-content: space-between; gap: 8px; padding: 3px 0; }
.pre { white-space: pre-wrap; word-break: break-word; background: #fff; border-radius: 10px; padding: 12px; border: 1px solid var(--line); font-size: 14px; max-height: 340px; overflow: auto; }
.st-pending { background: var(--warn-soft); color: var(--warn); } .st-working { background: #e0ecff; color: #1d4ed8; } .st-done { background: var(--good-soft); color: var(--good); }
.st-rejected { background: var(--bad-soft); color: var(--bad); } .st-cancelled { background: #eef0f5; color: #6b7083; }
.st-running { background: var(--good-soft); color: var(--good); } .st-scheduled { background: #e0ecff; color: #1d4ed8; } .st-ended, .st-stopped { background: #eef0f5; color: #6b7083; }
.hist { list-style: none; padding: 0; margin: 0; font-size: 13px; }
.hist li { padding: 6px 0; border-bottom: 1px solid var(--line); } .hist li:last-child { border-bottom: 0; }
.cpick { max-height: 50vh; overflow-y: auto; }
.ad.paused { border-left-color: #64748b; } .cd.paused div { background: #eef2f7; } .cd.paused b { color: #475569; }
.st-paused { background: #eef2f7; color: #475569; }
