/* Grip Ads Console - Meta Ads Manager lookalike styling */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 13px; color: #1c2b33; background: #f0f2f5;
}
button { font: inherit; cursor: pointer; }

/* ---------- top bar ---------- */
#topbar {
  display: flex; align-items: center; gap: 16px;
  height: 52px; padding: 0 16px; background: #fff;
  border-bottom: 1px solid #dadde1; position: sticky; top: 0; z-index: 30;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 15px; }
.brand-mark {
  width: 28px; height: 28px; border-radius: 6px; background: #6a3fb5; color: #fff;
  display: inline-flex; align-items: center; justify-content: center; font-weight: 800;
}
.account-pill {
  background: #e7f3ff; color: #1877f2; border-radius: 15px; padding: 5px 14px; font-weight: 600;
}
.top-controls { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.readonly-chip {
  background: #fff3e0; color: #a15c00; border: 1px solid #f0ce93;
  border-radius: 4px; padding: 3px 8px; font-weight: 600; font-size: 12px;
}
.ctl { display: flex; align-items: center; gap: 6px; color: #65676b; font-size: 12px; }
.ctl select {
  font: inherit; color: #1c2b33; padding: 5px 8px; border: 1px solid #ccd0d5;
  border-radius: 6px; background: #fff;
}

/* ---------- layout ---------- */
#layout { display: flex; min-height: calc(100% - 52px); }
#sidenav {
  width: 232px; background: #fff; border-right: 1px solid #dadde1;
  padding: 12px 8px; flex-shrink: 0;
}
.nav-item {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  padding: 10px 12px; border: 0; background: none; border-radius: 8px;
  color: #1c2b33; font-weight: 600; margin-bottom: 2px;
}
.nav-item:hover { background: #f2f2f2; }
.nav-item.active { background: #e7f3ff; color: #1877f2; }
.nav-item.beacon-nav.active { background: #e6f7f5; color: #00756a; }
.nav-ico { width: 18px; text-align: center; }
#main { flex: 1; padding: 16px 20px 60px; min-width: 0; }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid #dadde1; margin-bottom: 0; }
.tab {
  padding: 10px 18px; border: 0; background: none; font-weight: 600; color: #65676b;
  border-bottom: 3px solid transparent;
}
.tab.active { color: #1877f2; border-bottom-color: #1877f2; }
.beacon .tab.active { color: #00756a; border-bottom-color: #00756a; }
.crumbs { padding: 10px 2px; color: #65676b; }
.crumbs a { color: #1877f2; cursor: pointer; text-decoration: none; }
.crumbs a:hover { text-decoration: underline; }

/* ---------- toolbar ---------- */
.toolbar {
  display: flex; align-items: center; gap: 10px; padding: 10px 0;
}
.toolbar .spacer { flex: 1; }
.btn {
  border: 1px solid #ccd0d5; background: #fff; border-radius: 6px;
  padding: 6px 12px; font-weight: 600; color: #1c2b33;
}
.btn:hover { background: #f5f6f7; }

/* ---------- table ---------- */
.table-wrap { background: #fff; border: 1px solid #dadde1; border-radius: 8px; overflow-x: auto; }
table.data { border-collapse: collapse; width: 100%; min-width: 1080px; }
table.data th, table.data td {
  padding: 9px 12px; text-align: right; border-bottom: 1px solid #ebedf0;
  white-space: nowrap; font-variant-numeric: tabular-nums;
}
table.data th {
  background: #f5f6f7; color: #65676b; font-weight: 600; font-size: 12px;
  position: sticky; top: 0; text-align: right;
}
table.data th:first-child, table.data td:first-child { text-align: left; }
table.data th.left, table.data td.left { text-align: left; }
table.data tbody tr:hover { background: #f7f9fb; }
table.data tbody tr { cursor: pointer; }
.name-cell { font-weight: 600; color: #1c2b33; max-width: 340px; overflow: hidden; text-overflow: ellipsis; }
.name-link { color: #1877f2; cursor: pointer; }
.name-link:hover { text-decoration: underline; }
.sub { color: #65676b; font-size: 11px; font-weight: 400; }
.totals td { font-weight: 700; background: #fafbfc; border-top: 2px solid #dadde1; }

/* status + delivery */
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
.dot.green { background: #31a24c; }
.dot.grey { background: #bcc0c4; }
.dot.amber { background: #e6a700; }
.delivery-learning { color: #a15c00; font-weight: 600; }
.delivery-paused { color: #65676b; }
.delivery-active { color: #31a24c; font-weight: 600; }

/* toggle switch (read-only trap) */
.switch { width: 34px; height: 18px; border-radius: 10px; background: #31a24c; position: relative; display: inline-block; vertical-align: middle; }
.switch.off { background: #bcc0c4; }
.switch::after {
  content: ""; position: absolute; top: 2px; left: 18px; width: 14px; height: 14px;
  border-radius: 50%; background: #fff; transition: left .12s;
}
.switch.off::after { left: 2px; }

/* thumbnails */
.thumb {
  width: 44px; height: 55px; border-radius: 4px; display: inline-flex; align-items: center;
  justify-content: center; color: #fff; font-size: 9px; font-weight: 800; vertical-align: middle;
  margin-right: 8px; flex-shrink: 0;
}
.ad-name-flex { display: flex; align-items: center; }

/* ---------- drawer ---------- */
#drawer {
  position: fixed; top: 0; right: 0; width: 720px; max-width: 92vw; height: 100%;
  background: #fff; box-shadow: -4px 0 24px rgba(0,0,0,.18); z-index: 50;
  overflow-y: auto; padding: 20px 24px;
}
#drawer-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.25); z-index: 40; }
.hidden { display: none !important; }
.drawer-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 14px; }
.drawer-head h2 { font-size: 16px; flex: 1; line-height: 1.35; }
.drawer-close { border: 0; background: #f0f2f5; border-radius: 50%; width: 30px; height: 30px; font-size: 15px; }
.panel { border: 1px solid #dadde1; border-radius: 8px; padding: 14px 16px; margin-bottom: 14px; }
.panel h3 { font-size: 13px; margin-bottom: 10px; color: #65676b; text-transform: uppercase; letter-spacing: .3px; }
.kv { display: grid; grid-template-columns: 170px 1fr; row-gap: 7px; }
.kv .k { color: #65676b; }
.kv .v { font-weight: 600; }
.v.warn { color: #c0392b; }
.bd-tabs { display: flex; gap: 6px; margin-bottom: 10px; }
.bd-tab { border: 1px solid #ccd0d5; background: #fff; border-radius: 15px; padding: 4px 12px; font-weight: 600; color: #65676b; }
.bd-tab.active { background: #e7f3ff; color: #1877f2; border-color: #9ec9f5; }
.mini { width: 100%; border-collapse: collapse; }
.mini th, .mini td { padding: 6px 8px; text-align: right; border-bottom: 1px solid #ebedf0; font-variant-numeric: tabular-nums; }
.mini th { color: #65676b; font-weight: 600; }
.mini th:first-child, .mini td:first-child { text-align: left; }

/* chart */
.chart-svg { width: 100%; height: 190px; display: block; }
.legend { display: flex; gap: 16px; font-size: 11px; color: #65676b; margin-top: 4px; }
.legend .sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 4px; vertical-align: -1px; }

/* ---------- beacon ---------- */
.beacon-band {
  background: linear-gradient(90deg, #04665c, #0b8f80); color: #fff;
  border-radius: 10px; padding: 16px 20px; margin-bottom: 14px;
}
.beacon-band h1 { font-size: 17px; margin-bottom: 3px; }
.beacon-band p { opacity: .85; font-size: 12px; }
.note-box {
  background: #f6f7f9; border: 1px solid #e4e6eb; border-left: 4px solid #0b8f80;
  padding: 10px 14px; border-radius: 6px; margin: 12px 0; color: #37474f;
}
.section-title { font-size: 14px; font-weight: 700; margin: 18px 0 8px; }
.pager { display: flex; gap: 8px; align-items: center; padding: 10px 0; color: #65676b; }

/* audience overlap bar */
.overlap-wrap { display: flex; align-items: center; gap: 14px; margin-top: 10px; }
.venn { position: relative; width: 150px; height: 84px; flex-shrink: 0; }
.venn .c { position: absolute; width: 84px; height: 84px; border-radius: 50%; opacity: .55; }
.venn .c1 { left: 0; background: #1877f2; }
.venn .c2 { right: 0; background: #e6a700; }

/* gate */
#gate {
  position: fixed; inset: 0; background: rgba(16, 24, 32, .72); z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.gate-card {
  background: #fff; border-radius: 12px; max-width: 620px; width: 100%;
  padding: 30px 34px; box-shadow: 0 12px 48px rgba(0,0,0,.35);
}
.gate-card h1 { font-size: 19px; margin-bottom: 14px; }
.gate-brief { margin-bottom: 12px; line-height: 1.5; color: #37474f; }
#gate-form { margin-top: 18px; }
#gate-form label { display: block; font-weight: 600; margin-bottom: 6px; }
#gate-form input {
  width: 100%; font: inherit; padding: 9px 12px; border: 1px solid #ccd0d5;
  border-radius: 6px; margin-bottom: 12px;
}
.gate-start { background: #6a3fb5 !important; color: #fff !important; border-color: #6a3fb5 !important; width: 100%; padding: 10px !important; }
.gate-err { color: #c0392b; font-weight: 600; margin-top: 8px; }

/* toast */
#toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%);
  background: #1c2b33; color: #fff; border-radius: 8px; padding: 11px 18px;
  font-weight: 600; z-index: 90; box-shadow: 0 6px 20px rgba(0,0,0,.3);
}
