@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  --bg: #0b0c0e;          /* black-ish page background */
  --on-bg: #e8eaef;       /* text on the page */
  --on-bg-muted: #8b919c;
  --surface: #15171c;     /* dark cards + header */
  --surface-2: #1c1f26;
  --border: #292d34;
  --border-strong: #3a3f49;
  --text: #e8eaef;        /* text on dark surfaces */
  --muted: #9aa1ad;
  --faint: #6a7079;
  --accent: #3b82f6;      /* blue */
  --accent-weak: #14233f;
  --green: #35c48a;
  --green-dot: #34c88a;
  --amber: #e6b655;
  --amber-bg: #231d0f;
  --amber-border: #463a1c;
  --red: #f0807f;
  --red-bg: #241416;
  --red-border: #4a2a2c;
  --track: #23272e;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 1px 3px rgba(0, 0, 0, 0.35);
  --radius: 10px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 13px;
  color: var(--on-bg);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; cursor: pointer; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* ---------- login ---------- */
.login-body { display: grid; place-items: center; min-height: 100vh; }
.login-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  box-shadow: var(--shadow); padding: 28px; width: 340px; display: flex; flex-direction: column; gap: 14px;
}
.login-card h1 { margin: 0; font-size: 18px; font-weight: 600; letter-spacing: -0.01em; }
.login-card .muted { margin: -8px 0 4px; }
.login-card input[type='password'] {
  padding: 10px 12px; border-radius: 8px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); outline: none;
}
.login-card input[type='password']:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-weak); }
.login-card .remember { display: flex; gap: 8px; align-items: center; font-size: 12px; color: var(--muted); }
.login-card button { padding: 10px; border: 0; border-radius: 8px; background: var(--accent); color: #fff; font-weight: 600; }
.error { color: var(--red); font-size: 12px; margin: 0; }

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 15px 24px; background: var(--surface); color: var(--text); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20; flex-wrap: wrap;
}
.brand { font-weight: 700; letter-spacing: -0.01em; font-size: 14px; }
.controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.controls select {
  background: var(--surface); color: var(--text); border: 1px solid var(--border-strong);
  border-radius: 8px; padding: 8px 34px 8px 14px; outline: none; cursor: pointer;
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239aa1ad' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 11px;
}
.controls select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-weak); }

/* custom client dropdown (so the menu always opens BELOW the button) */
.dd { position: relative; }
.dd-btn { display: inline-flex; align-items: center; gap: 12px; min-width: 150px; background: var(--surface); color: var(--text); border: 1px solid var(--border-strong); border-radius: 8px; padding: 8px 12px 8px 14px; cursor: pointer; font: inherit; }
.dd-btn:hover { background: var(--surface-2); }
.dd-btn:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-weak); }
.dd-caret { margin-left: auto; width: 0; height: 0; border-left: 4px solid transparent; border-right: 4px solid transparent; border-top: 5px solid var(--muted); }
.dd-menu { position: absolute; top: calc(100% + 6px); left: 0; min-width: 100%; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 10px; box-shadow: 0 12px 34px rgba(0,0,0,.45); padding: 5px; z-index: 60; }
.dd-item { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 7px; cursor: pointer; white-space: nowrap; color: var(--text); font-size: 13px; }
.dd-item:hover { background: var(--surface-2); }
.dd-item.on { background: var(--accent); color: #fff; }
.dd-check { width: 13px; flex: none; }

.interval { color: var(--muted); font-size: 12px; display: inline-flex; align-items: center; gap: 6px; }

/* little "i" info icons with a hover tooltip */
.info { display: inline-flex; align-items: center; justify-content: center; width: 15px; height: 15px; border-radius: 50%; border: 1px solid var(--faint); color: var(--faint); font-size: 10px; font-weight: 700; font-style: normal; text-transform: none; letter-spacing: 0; line-height: 1; cursor: help; position: relative; flex: none; vertical-align: middle; }
.info:hover { color: var(--text); border-color: var(--muted); }
.info::after { content: attr(data-tip); position: absolute; top: calc(100% + 8px); left: 50%; transform: translateX(-50%); width: 230px; background: var(--surface); color: var(--text); border: 1px solid var(--border-strong); border-radius: 9px; padding: 9px 11px; font-size: 11px; font-weight: 400; line-height: 1.45; text-transform: none; letter-spacing: 0; box-shadow: 0 12px 34px rgba(0,0,0,.45); opacity: 0; pointer-events: none; transition: opacity .12s; z-index: 90; }
.info:hover::after { opacity: 1; }
.controls .info:last-of-type::after { left: auto; right: 0; transform: none; }

/* custom number stepper (replaces the ugly native spinners) */
.stepper { display: inline-flex; align-items: stretch; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--surface); overflow: hidden; height: 32px; }
.stepper input { border: 0; background: transparent; color: var(--text); width: 34px; padding: 0 2px 0 10px; outline: none; font: inherit; -moz-appearance: textfield; appearance: textfield; }
.stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.stepper:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-weak); }
.sp-btns { display: flex; flex-direction: column; border-left: 1px solid var(--border); }
.sp-btns button { width: 20px; flex: 1; background: var(--surface); border: 0; display: grid; place-items: center; cursor: pointer; padding: 0; }
.sp-btns button:hover { background: var(--surface-2); }
.sp-down { border-top: 1px solid var(--border); }
.sp-up::before { content: ''; border-left: 4px solid transparent; border-right: 4px solid transparent; border-bottom: 5px solid var(--muted); }
.sp-down::before { content: ''; border-left: 4px solid transparent; border-right: 4px solid transparent; border-top: 5px solid var(--muted); }
.sp-btns button:hover::before { border-bottom-color: var(--text); border-top-color: var(--text); }
.btn {
  background: var(--surface); color: var(--text); border: 1px solid var(--border-strong);
  border-radius: 8px; padding: 7px 14px; font-weight: 500;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #4f4fc9; }
.btn.subtle { color: var(--muted); border-color: transparent; }

/* toggle switch */
.switch { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; cursor: pointer; user-select: none; }
.switch input { display: none; }
.switch .track { width: 34px; height: 20px; border-radius: 999px; background: var(--border-strong); position: relative; transition: background .15s; }
.switch .track::after { content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: var(--shadow); transition: transform .15s; }
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(14px); }

/* ---------- banner ---------- */
.banner { margin: 14px 24px 0; padding: 9px 14px; border-radius: 8px; font-size: 12px; background: var(--amber-bg); color: var(--amber); border: 1px solid var(--amber-border); }

/* ---------- layout: board (left) + sidebar (right) ---------- */
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; padding: 18px 24px; align-items: start; }
.board { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 1100px) { .layout { grid-template-columns: 1fr; } }
@media (max-width: 760px) { .board { grid-template-columns: 1fr; } }
.tabs { display: flex; align-items: center; gap: 6px; height: 32px; margin-bottom: 0; }
.tab { font-size: 12px; font-weight: 500; padding: 5px 12px; border-radius: 8px; border: 1px solid transparent; background: transparent; color: var(--on-bg-muted); cursor: pointer; }
.tab:hover { color: var(--on-bg); }
.tab.on { background: var(--surface); color: var(--text); border-color: var(--border); }
.tabs .chip { margin-left: auto; }
.tab-hidden { display: none !important; }

/* Active / Paused group headers inside a column */
.group-header { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; font-weight: 700; color: var(--on-bg-muted); margin: 12px 2px 4px; }
.group-header:first-child { margin-top: 0; }
.group-header span { color: var(--faint); font-weight: 600; }

/* loading skeleton (shown while a client's data loads) */
.sk { position: relative; overflow: hidden; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.sk::after { content: ''; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, rgba(255,255,255,0.05), transparent); animation: shimmer 1.2s infinite; }
.sk-card { height: 76px; margin-bottom: 10px; }
.sk-line { height: 44px; margin-bottom: 8px; }
@keyframes shimmer { 100% { transform: translateX(100%); } }
.col-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 2px; }
.col-head h2 { margin: 0; font-size: 13px; font-weight: 600; }
.chip { font-size: 11px; font-weight: 600; color: var(--on-bg-muted); background: rgba(255,255,255,0.07); border: 1px solid rgba(255,255,255,0.12); border-radius: 999px; padding: 1px 8px; }
.col .hint { color: var(--on-bg-muted); font-size: 11px; margin: 0 0 10px; }
/* Active / Paused / Exclude as distinct boxes. Each box is exactly as tall as its campaigns. */
.include-col, .exclude-col { display: flex; flex-direction: column; gap: 12px; }
/* line up the Exclude box with the Active box (which sits below the tabs row) */
.exclude-col { margin-top: 44px; }
.zone { display: flex; flex-direction: column; flex: 0 0 auto; border: 1px solid var(--border); border-radius: var(--radius); background: rgba(255,255,255,0.015); overflow: hidden; }
.zone-head { display: flex; align-items: center; gap: 7px; padding: 10px 14px; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; font-weight: 700; color: var(--on-bg); border-bottom: 1px solid var(--border); flex: none; }
.zone-head .zc { color: var(--faint); margin-left: auto; }
.zone-sub { margin-left: auto; text-transform: none; letter-spacing: 0; font-weight: 400; color: var(--faint); font-size: 11px; }
.exclude-col .zc { margin-left: 6px; }
.zone-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.zone-dot.running { background: var(--green-dot); }
.zone-dot.amber { background: var(--amber); }
.zone-dot.red { background: var(--red); }
/* Box height = its content; only a very long list scrolls (so it never gets absurdly tall). */
.zone-list { min-height: 0; max-height: 62vh; overflow-y: auto; padding: 10px; display: flex; flex-direction: column; gap: 10px; }
.zone-list.empty { min-height: 68px; align-items: center; justify-content: center; }
.zone-list.empty::after { content: 'None'; color: var(--faint); font-size: 12px; }
#exclude.empty::after { content: 'Drag campaigns here to exclude'; }

/* custom scrollbar fitting the theme */
.zone-list { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
.zone-list::-webkit-scrollbar { width: 10px; }
.zone-list::-webkit-scrollbar-track { background: transparent; }
.zone-list::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 10px; border: 3px solid transparent; background-clip: padding-box; }
.zone-list::-webkit-scrollbar-thumb:hover { background: var(--faint); background-clip: padding-box; }

/* ---------- card (simple: big rank · name · one line · toggles) ---------- */
.card {
  display: flex; align-items: center; gap: 14px;
  background: var(--surface); color: var(--text); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 16px; min-height: 76px;
  transition: border-color .12s, box-shadow .12s; cursor: grab;
}
.card:active { cursor: grabbing; }
.card button { cursor: pointer; }
.card:hover { border-color: var(--border-strong); }
.card.red { border-color: var(--red-border); background: var(--red-bg); }

.rank { flex: none; width: 48px; display: grid; place-items: center; }
.rank .num { width: 48px; height: 48px; border-radius: 12px; background: var(--accent); color: #fff; font-size: 27px; font-weight: 800; display: grid; place-items: center; line-height: 1; }
.rank .dot { width: 10px; height: 10px; border-radius: 50%; }
.dot.running { background: var(--green-dot); }
.dot.paused, .dot.amber { background: var(--amber); }
.dot.red { background: var(--red); }

.main { flex: 1; min-width: 0; }
.main .name { font-weight: 600; font-size: 14px; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.main .line { font-size: 12px; color: var(--muted); margin-top: 9px; }
.main .line .run { color: var(--green); font-weight: 600; }
.main .line .pause { color: var(--faint); font-weight: 600; }
.main .line .danger { color: var(--red); font-weight: 600; }
.main .act { margin-top: 9px; }
.main .act button { background: var(--surface); color: var(--red); border: 1px solid var(--red-border); border-radius: 7px; padding: 5px 11px; font-size: 12px; font-weight: 500; }
.main .act button:hover { background: var(--surface-2); border-color: var(--red); }

.ctl { flex: none; display: flex; gap: 6px; }
.ctl button { font-size: 12px; font-weight: 500; padding: 7px 12px; border-radius: 8px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--muted); }
.ctl button:hover { background: var(--surface-2); }
.ctl button.on { background: var(--accent); border-color: var(--accent); color: #fff; }

.sortable-ghost { opacity: .35; }
.sortable-chosen { box-shadow: 0 8px 24px rgba(0,0,0,.25); }

/* ---------- sidebar (right) ---------- */
.sidebar { display: flex; flex-direction: column; gap: 14px; position: sticky; top: 74px; margin-top: 44px; }
.panel { background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; }
.panel h3 { margin: 0 0 4px; font-size: 13px; font-weight: 600; }
.panel-hint { margin: 0 0 12px; font-size: 11px; color: var(--muted); line-height: 1.4; }

/* focus card */
.focus-opts { display: flex; flex-direction: column; gap: 8px; }
.focus-opt { text-align: left; display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); color: var(--text); }
.focus-opt:hover { border-color: var(--border-strong); }
.focus-opt b { font-size: 13px; font-weight: 600; }
.focus-opt span { font-size: 11px; color: var(--muted); }
.focus-opt.on { border-color: var(--accent); background: var(--accent-weak); }
.focus-opt.on b { color: var(--accent); }

/* inbox pools */
.pool { padding: 10px 0; border-top: 1px solid var(--border); }
.pool:first-child { border-top: 0; padding-top: 0; }
.pool-top { display: flex; justify-content: space-between; font-size: 12px; margin-bottom: 6px; }
.pool-top span { color: var(--muted); }
.pool-bar { height: 8px; background: var(--track); border-radius: 5px; overflow: hidden; }
.pool-bar > span { display: block; height: 100%; background: var(--accent); }
.pool-cap { font-size: 11px; color: var(--muted); margin-top: 5px; }

.audit { overflow: hidden; margin: -4px -4px 0; }
.audit div { font-size: 12px; color: var(--muted); padding: 8px 12px; border-bottom: 1px solid var(--border); }
.audit div:last-child { border-bottom: 0; }
.audit b { color: var(--text); font-weight: 600; }
.audit .t { color: var(--faint); font-size: 11px; }
