:root {
  --ink: #0b1328;
  --muted: #657087;
  --canvas: #f4f5f7;
  --surface: #ffffff;
  --surface-soft: #fafafa;
  --line: #e5e7eb;
  --yellow: #ffca12;
  --yellow-dark: #a66c00;
  --teal: #078787;
  --green: #157347;
  --green-soft: #eaf8f0;
  --red: #d92d20;
  --red-soft: #fff0ee;
  --orange: #b54708;
  --orange-soft: #fff5e8;
  --blue: #175cd3;
  --blue-soft: #eff5ff;
  --shadow-sm: 0 1px 2px rgba(11, 19, 40, 0.05);
  --shadow-lg: 0 20px 48px rgba(11, 19, 40, 0.14);
  --radius: 18px;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--canvas); }
body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: var(--canvas);
  font: 15px/1.5 Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
.hidden { display: none !important; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 264px minmax(0, 1fr); }
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column; padding: 24px 18px;
  color: #fff; background: var(--ink);
}
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 28px; }
.brand-mark {
  width: 42px; height: 42px; display: grid; place-items: center;
  border-radius: 13px; color: var(--ink); background: var(--yellow);
  overflow: hidden;
}
.brand-mark img { width: 27px; height: 27px; display: block; object-fit: contain; }
.brand strong { display: block; font-size: 17px; font-weight: 650; }
.brand small { display: block; color: #aeb7cb; font-size: 12px; }
.nav-label { padding: 0 12px 8px; color: #7f8aa3; font-size: 11px; font-weight: 650; letter-spacing: .12em; text-transform: uppercase; }
.nav { display: grid; gap: 6px; }
.nav-button {
  width: 100%; display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  border: 0; border-radius: 12px; color: #c8cede; background: transparent;
  font-weight: 550; text-align: left; cursor: pointer;
}
.nav-button:hover { color: #fff; background: rgba(255,255,255,.07); }
.nav-button.active { color: var(--ink); background: var(--yellow); }
.nav-icon { width: 22px; height: 22px; display: grid; place-items: center; flex: 0 0 auto; text-align: center; }
.nav-icon .lucide { width: 18px; height: 18px; stroke-width: 1.8; }
.nav-icon.naira { font-size: 15px; font-weight: 650; }
.nav-count { margin-left: auto; min-width: 24px; padding: 2px 7px; border-radius: 999px; background: rgba(255,255,255,.12); font-size: 11px; text-align: center; }
.nav-button.active .nav-count { background: rgba(11,19,40,.1); }
.sidebar-spacer { flex: 1; min-height: 30px; }
.connection-mini { padding: 16px; border: 1px solid rgba(255,255,255,.11); border-radius: 14px; background: rgba(255,255,255,.04); }
.connection-state { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: #98a2b3; }
.status-dot.connected { background: #39d98a; box-shadow: 0 0 0 4px rgba(57,217,138,.12); }
.connection-mini p { margin: 7px 0 14px; color: #9da7bc; font-size: 12px; }
.connection-mini .button { font-weight: 600; }

.main { min-width: 0; padding: 32px clamp(20px, 4vw, 56px) 56px; }
.topbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin: 0 0 28px; }
.eyebrow { margin: 0 0 5px; color: var(--yellow-dark); font-size: 12px; font-weight: 850; letter-spacing: .08em; text-transform: uppercase; }
.topbar h1 { margin: 0; font-size: clamp(28px, 3vw, 38px); line-height: 1.15; letter-spacing: -.035em; }
.topbar p { max-width: 700px; margin: 8px 0 0; color: var(--muted); }
.top-actions { display: flex; gap: 10px; }

.button {
  min-height: 42px; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px; border: 1px solid transparent; border-radius: 11px;
  color: var(--ink); background: var(--yellow); font-weight: 800; cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease, opacity .12s ease;
}
.button:hover:not(:disabled) { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.button:disabled { opacity: .5; cursor: not-allowed; }
.button.secondary { border-color: var(--line); background: var(--surface); }
.button.ghost { border-color: transparent; background: transparent; }
.button.danger { color: #fff; background: var(--red); }
.button.danger-outline { color: var(--red); border-color: #f5b7b2; background: var(--surface); }
.button.success { color: #fff; background: var(--green); }
.button.small { min-height: 34px; padding: 7px 11px; border-radius: 9px; font-size: 13px; }
.icon-button { width: 40px; height: 40px; padding: 0; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); cursor: pointer; }
.button .lucide { width: 17px; height: 17px; stroke-width: 2; }
.icon-button .lucide { width: 18px; height: 18px; vertical-align: middle; }

.panel { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm); }
.panel + .panel { margin-top: 18px; }
.panel-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 20px 22px; border-bottom: 1px solid var(--line); }
.panel-header h2 { margin: 0; font-size: 18px; }
.panel-header p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.panel-body { padding: 22px; }

.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat-card { position: relative; min-height: 140px; padding: 20px; overflow: hidden; border: 1px solid var(--line); border-radius: 17px; background: var(--surface); box-shadow: var(--shadow-sm); }
.stat-card.highlight { border-color: #f2c017; background: linear-gradient(135deg, #ffdb53, var(--yellow)); }
.stat-card::after { content: ""; position: absolute; right: -28px; bottom: -36px; width: 105px; height: 105px; border-radius: 50%; background: rgba(11,19,40,.035); }
.stat-label { color: var(--muted); font-size: 12px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; }
.highlight .stat-label { color: #594600; }
.stat-value { margin-top: 15px; font-size: 32px; font-weight: 900; line-height: 1; letter-spacing: -.04em; }
.stat-meta { margin-top: 9px; color: var(--muted); font-size: 12px; }
.highlight .stat-meta { color: #665000; }
.overview-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(280px, .8fr); gap: 18px; }
.queue-list { display: grid; gap: 10px; }
.queue-item { display: flex; align-items: center; gap: 13px; padding: 14px; border: 1px solid var(--line); border-radius: 13px; }
.queue-symbol { width: 40px; height: 40px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 11px; background: var(--orange-soft); }
.queue-copy { min-width: 0; flex: 1; }
.queue-copy strong, .queue-copy span { display: block; }
.queue-copy span { color: var(--muted); font-size: 12px; }
.scope-list { display: grid; gap: 12px; margin: 0; padding: 0; list-style: none; }
.scope-list li { display: flex; align-items: flex-start; gap: 10px; }
.scope-check { color: var(--green); font-weight: 900; }
.scope-check .lucide { width: 18px; height: 18px; stroke-width: 2.25; }

.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 17px 20px; border-bottom: 1px solid var(--line); }
.filters { display: flex; flex-wrap: wrap; gap: 7px; }
.filter {
  padding: 8px 13px; border: 1px solid var(--line); border-radius: 999px;
  color: var(--muted); background: var(--surface); font-size: 13px; font-weight: 750; cursor: pointer;
}
.filter.active { color: var(--ink); border-color: var(--yellow); background: #fff7d6; }
.search { position: relative; min-width: 250px; }
.search input { width: 100%; padding-left: 38px; }
.search > .lucide { position: absolute; z-index: 1; left: 13px; top: 12px; width: 17px; height: 17px; color: var(--muted); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { padding: 12px 16px; color: var(--muted); background: var(--surface-soft); font-size: 11px; font-weight: 850; letter-spacing: .06em; text-align: left; text-transform: uppercase; white-space: nowrap; }
td { padding: 16px; border-top: 1px solid var(--line); vertical-align: middle; }
tbody tr:hover { background: #fffdf5; }
.primary-cell { font-weight: 800; }
.secondary-cell { display: block; max-width: 230px; margin-top: 2px; overflow: hidden; color: var(--muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.money { font-size: 16px; font-weight: 900; white-space: nowrap; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 9px; border-radius: 999px; font-size: 11px; font-weight: 850; text-transform: capitalize; white-space: nowrap; }
.chip.pending, .chip.processing, .chip.scheduled { color: var(--orange); background: var(--orange-soft); }
.chip.processed, .chip.active { color: var(--green); background: var(--green-soft); }
.chip.suspended { color: var(--red); background: var(--red-soft); }
.chip.failed, .chip.expired { color: var(--red); background: var(--red-soft); }
.chip.inactive { color: var(--muted); background: #f0f1f3; }
.chip.risk { color: var(--red); background: var(--red-soft); }
.row-actions { display: flex; justify-content: flex-end; gap: 7px; white-space: nowrap; }

.ads-layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 18px; align-items: start; }
.ad-grid { display: grid; gap: 13px; }
.ad-card { display: grid; grid-template-columns: 72px minmax(0, 1fr) auto; gap: 15px; align-items: center; padding: 15px; border: 1px solid var(--line); border-radius: 15px; }
.ad-art { width: 72px; height: 72px; display: grid; place-items: center; overflow: hidden; border-radius: 14px; font-size: 22px; font-weight: 900; }
.ad-art img { width: 100%; height: 100%; object-fit: cover; }
.ad-copy { min-width: 0; }
.ad-copy h3 { margin: 0 0 3px; font-size: 15px; }
.ad-copy p { margin: 0 0 7px; overflow: hidden; color: var(--muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.ad-meta { display: flex; flex-wrap: wrap; gap: 6px; }
.ad-actions { display: flex; gap: 6px; }
.preview-sticky { position: sticky; top: 24px; }
.preview-label { margin: 0 0 10px; color: var(--muted); font-size: 11px; font-weight: 850; letter-spacing: .07em; text-transform: uppercase; }
.phone-preview { padding: 18px; border: 8px solid var(--ink); border-radius: 28px; background: #f5f4f1; }
.promo-preview { position: relative; min-height: 122px; display: flex; flex-direction: column; justify-content: center; padding: 18px 76px 24px 18px; border-radius: 18px; overflow: hidden; }
.promo-preview strong { font-size: 17px; line-height: 1.25; }
.promo-preview span { margin-top: 4px; font-size: 13px; }
.promo-preview .preview-accent { position: absolute; right: 13px; top: 16px; width: 46px; height: 72px; border: 4px solid rgba(255,255,255,.7); border-radius: 24px; }
.preview-dots { position: absolute; bottom: 9px; left: 50%; display: flex; gap: 5px; transform: translateX(-50%); }
.preview-dots i { width: 5px; height: 5px; border-radius: 50%; background: rgba(11,19,40,.3); }
.preview-dots i:first-child { background: rgba(11,19,40,.65); }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; }
.field { display: grid; gap: 7px; }
.field.full { grid-column: 1 / -1; }
.field label { color: #344054; font-size: 12px; font-weight: 800; }
.field-hint { color: var(--muted); font-size: 11px; }
input, select, textarea {
  width: 100%; min-height: 43px; padding: 10px 12px; border: 1px solid #d9dde5; border-radius: 10px;
  outline: 0; color: var(--ink); background: var(--surface);
}
textarea { min-height: 92px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: #d5a500; box-shadow: 0 0 0 3px rgba(255,202,18,.18); }
.color-row { display: grid; grid-template-columns: 42px 1fr; gap: 8px; }
input[type="color"] { min-height: 43px; padding: 4px; }
.switch-row { min-height: 43px; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; }
.switch { position: relative; width: 42px; height: 24px; flex: 0 0 auto; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: #d0d5dd; cursor: pointer; }
.switch span::after { content: ""; position: absolute; left: 3px; top: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch input:checked + span { background: var(--green); }
.switch input:checked + span::after { transform: translateX(18px); }
.form-actions { display: flex; justify-content: flex-end; gap: 9px; padding-top: 7px; }
.compact-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); max-width: 620px; }
.verification-box { padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-soft); }
.check-row { min-height: 38px; display: flex; align-items: center; gap: 9px; font-size: 13px !important; font-weight: 600 !important; }
.check-row input { width: 18px; min-height: 18px; flex: 0 0 18px; }

.empty-state { padding: 54px 24px; color: var(--muted); text-align: center; }
.empty-symbol { width: 52px; height: 52px; display: grid; place-items: center; margin: 0 auto 12px; border-radius: 15px; background: #f3f4f6; font-size: 22px; }
.empty-symbol .lucide { width: 24px; height: 24px; stroke-width: 1.7; }
.empty-state strong { display: block; margin-bottom: 4px; color: var(--ink); }
.loading { padding: 52px; color: var(--muted); text-align: center; }
.spinner { width: 22px; height: 22px; display: inline-block; margin-right: 9px; border: 3px solid #eceff3; border-top-color: var(--yellow-dark); border-radius: 50%; vertical-align: middle; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.alert { display: flex; gap: 10px; margin: 0 0 18px; padding: 13px 15px; border: 1px solid #f1b3ad; border-radius: 12px; color: #912018; background: var(--red-soft); }
.alert.info { color: #1849a9; border-color: #bfd4ff; background: var(--blue-soft); }
.alert > .lucide { width: 18px; height: 18px; flex: 0 0 auto; margin-top: 2px; }
.toast-stack { position: fixed; z-index: 80; right: 24px; bottom: 24px; display: grid; gap: 10px; }
.toast { min-width: 280px; max-width: 420px; padding: 13px 15px; border-radius: 12px; color: #fff; background: var(--ink); box-shadow: var(--shadow-lg); animation: toast-in .18s ease-out; }
.toast.error { background: #912018; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

.modal-backdrop { position: fixed; z-index: 60; inset: 0; display: grid; place-items: center; padding: 20px; background: rgba(11,19,40,.58); backdrop-filter: blur(3px); }
.modal { width: min(680px, 100%); max-height: calc(100vh - 40px); overflow: auto; border-radius: 20px; background: var(--surface); box-shadow: var(--shadow-lg); }
.modal.small { width: min(470px, 100%); }
.modal-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; padding: 21px 22px; border-bottom: 1px solid var(--line); }
.modal-header h2 { margin: 0; font-size: 20px; }
.modal-header p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.modal-body { padding: 22px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 9px; padding: 16px 22px; border-top: 1px solid var(--line); }
.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.detail { padding: 12px; border-radius: 11px; background: var(--surface-soft); }
.detail.wide { grid-column: 1 / -1; }
.detail label { display: block; margin-bottom: 3px; color: var(--muted); font-size: 10px; font-weight: 850; letter-spacing: .06em; text-transform: uppercase; }
.detail strong { overflow-wrap: anywhere; }
.sensitive { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .08em; }

@media (max-width: 1100px) {
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ads-layout { grid-template-columns: 1fr; }
  .preview-sticky { position: static; }
  .phone-preview { max-width: 420px; }
}
@media (max-width: 820px) {
  .app-shell { display: block; }
  .sidebar { position: static; width: 100%; height: auto; padding: 14px 16px; overflow: visible; }
  .brand { padding-bottom: 13px; }
  .nav-label, .sidebar-spacer, .connection-mini { display: none; }
  .nav { grid-template-columns: repeat(6, 1fr); }
  .nav-button { justify-content: center; padding: 10px 8px; }
  .nav-icon { display: none; }
  .nav-count { margin-left: 2px; }
  .main { padding: 24px 16px 44px; }
  .overview-grid { grid-template-columns: 1fr; }
  .topbar { align-items: center; }
  .topbar p { display: none; }
  .toolbar { align-items: stretch; flex-direction: column; }
  .search { min-width: 0; }
}
@media (max-width: 560px) {
  .stat-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-card { min-height: 125px; padding: 16px; }
  .stat-value { font-size: 26px; }
  .top-actions .button span { display: none; }
  .panel-header, .panel-body { padding: 17px; }
  .ad-card { grid-template-columns: 56px minmax(0, 1fr); }
  .ad-art { width: 56px; height: 56px; }
  .ad-actions { grid-column: 1 / -1; justify-content: flex-end; }
  .form-grid, .detail-grid { grid-template-columns: 1fr; }
  .detail.wide, .field.full { grid-column: auto; }
  .modal-footer { flex-direction: column-reverse; }
  .modal-footer .button { width: 100%; }
  .toast-stack { right: 14px; bottom: 14px; left: 14px; }
  .toast { min-width: 0; }
}
