:root {
  --ink: #14151a;
  --muted: #6b7280;
  --paper: #f3f4f8;
  --card: #ffffff;
  --line: #e6e8ef;
  --accent: #5b46f5;
  --accent-ink: #ffffff;
  --accent-soft: #efeaff;
  --teal: #1f6f64;
  --good: #1f7a4d;
  --bad: #a3262c;
  --warn: #9a6700;
  --shadow: 0 10px 30px rgba(20, 22, 40, 0.06);
  font-family: "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(900px 420px at 0% 0%, #e7e4ff 0%, transparent 55%),
    radial-gradient(700px 380px at 100% 0%, #ffe9df 0%, transparent 50%),
    var(--paper);
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

.auth-body {
  min-height: 100vh;
  background:
    radial-gradient(ellipse at 50% 38%, #3c2d86 0%, #16122e 42%, #070b16 78%);
}
.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
}
.auth-card {
  margin: 0;
  width: min(380px, 92vw);
  background: #fff;
  border: 0;
  border-radius: 22px;
  padding: 36px 32px 28px;
  box-shadow: 0 24px 60px rgba(20, 10, 50, 0.45);
}
.auth-card h1 {
  margin: 0;
  text-align: center;
  color: #5b46f5;
  font-size: 28px;
  font-weight: 700;
}
.auth-sub {
  margin: 8px 0 26px;
  text-align: center;
  color: #9aa1b2;
  font-size: 14px;
}
.auth-card label { color: #2f3542; font-size: 14px; margin-bottom: 16px; }
.auth-card input {
  border: 1px solid #d7dbe6;
  border-radius: 8px;
  padding: 11px 12px;
  background: #fff;
}
.auth-card .signin {
  width: 100%;
  margin-top: 6px;
  border: 0;
  border-radius: 12px;
  padding: 12px 16px;
  color: #fff;
  font-weight: 650;
  background: linear-gradient(90deg, #7a6bff, #b7a6ff);
  box-shadow: 0 10px 22px rgba(110, 90, 255, 0.35);
}
.eyebrow { letter-spacing: 0.14em; text-transform: uppercase; font-size: 12px; color: var(--accent); margin: 0; }
.tabs { display: flex; gap: 8px; margin-bottom: 18px; }
.tab, .btn {
  border: 1px solid var(--line);
  background: transparent;
  border-radius: 999px;
  padding: 8px 14px;
}
.tab.active, .btn.primary { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--bad); }
label { display: block; font-size: 13px; margin-bottom: 12px; color: var(--muted); }
input, select, textarea {
  width: 100%;
  margin-top: 6px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 12px;
  padding: 10px 12px;
}
textarea { min-height: 140px; resize: vertical; }
.form-error { color: var(--bad); min-height: 1.2em; }
.hint { color: var(--muted); font-size: 13px; }

.shell { display: grid; grid-template-columns: 248px 1fr; min-height: calc(100vh - 92px); gap: 16px; padding: 16px; }
.sidebar {
  background: linear-gradient(180deg, #241b45 0%, #14161f 100%);
  color: #fff;
  padding: 22px 14px;
  border: 0;
  border-radius: 24px;
  position: sticky;
  top: 16px;
  height: calc(100vh - 124px);
  box-shadow: 0 18px 40px rgba(20, 16, 40, 0.18);
}
.brand { font-size: 20px; font-weight: 700; color: #fff; padding: 8px 12px 22px; letter-spacing: -0.03em; }
.sidebar button {
  width: 100%;
  text-align: left;
  background: transparent;
  color: #d5d0e6;
  border: 0;
  border-radius: 12px;
  padding: 11px 12px;
  margin-bottom: 4px;
  font-weight: 600;
}
.sidebar button:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
.sidebar button.active { background: var(--accent); color: #fff; }
.workspace { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 16px;
  align-items: center;
  width: 100%;
  padding: 14px 28px;
  position: sticky;
  top: 0;
  z-index: 5;
  background: #fff;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  box-shadow: 0 1px 0 rgba(20, 22, 40, 0.04);
}
.top-title { grid-column: 2; text-align: center; }
.top-left { grid-column: 1; display: flex; align-items: center; gap: 12px; min-width: 0; }
.menu-toggle {
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: #f4f5f8;
  color: var(--ink);
}
.menu-toggle:hover { background: #e8eaf1; }
.welcome { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sub-activate { padding: 6px 12px; font-size: 13px; margin-left: 8px; }
.shell.menu-closed { grid-template-columns: 1fr; }
.shell.menu-closed .sidebar { display: none; }
.topbar h1 { margin: 2px 0 0; font-size: 26px; font-weight: 680; letter-spacing: -0.03em; }
.top-actions { grid-column: 3; justify-self: end; display: flex; gap: 10px; align-items: center; color: var(--muted); }
#who { background: #f4f5f8; border-radius: 999px; padding: 8px 12px; font-size: 13px; font-weight: 650; }
.return-btn { background: #fff; border: 1px solid #cfd3e0; padding: 8px 14px; }
#gmtClock { font-size: 13px; font-weight: 650; white-space: nowrap; color: var(--ink); }
.credit-pill {
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 999px;
  padding: 8px 12px;
  font-weight: 700;
}
.view { padding: 0 0 32px; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; }
.card {
  background: var(--card);
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 20px;
  padding: 18px;
  box-shadow: var(--shadow);
}
.card > .row { align-items: center; margin-bottom: 14px; }
.card > .row .btn, .card > .row .btn-compact { flex: 0 0 auto; }
#addUser {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 8px 18px;
}
.card > .row h2 { margin: 0; }
.back-btn,
.row > .back-btn,
.card > .row .back-btn {
  flex: 0 0 auto;
  border-radius: 999px;
  background: #fff;
  border: 1px solid #cfd3e0;
  padding: 8px 18px;
}
.stat { position: relative; overflow: hidden; }
.card.stat::before { content: ""; position: absolute; left: 0; top: 16px; bottom: 16px; width: 4px; border-radius: 999px; background: linear-gradient(180deg, #8b7cff, #5b46f5); }
.stat b { display: block; font-size: 28px; margin-top: 8px; letter-spacing: -0.03em; }
.stat span { color: var(--muted); font-size: 13px; font-weight: 600; }
.campaign-head {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 4px 0 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #f7f8fc;
}
.campaign-head p { margin: 0; display: flex; flex-direction: column; gap: 4px; }
.campaign-head span { color: var(--muted); font-size: 12px; font-weight: 650; letter-spacing: 0.04em; text-transform: uppercase; }
.campaign-message { grid-column: 1 / -1; }
.campaign-head table, .campaign-head .pager { grid-column: 1 / -1; background: transparent; }
.campaign-head th, .campaign-head td { background: transparent; }
.col-filter th { text-transform: none; letter-spacing: 0; font-weight: 500; padding-top: 0; }
.col-filter input { margin-top: 0; padding: 7px 8px; font-size: 13px; }
.layout { display: grid; grid-template-columns: 1fr; gap: 16px; }
#sendForm.layout { grid-template-columns: minmax(0, 1fr) 280px; align-items: start; }
.row { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; }
.row > * { flex: 1; }
.user-sheet { background: #e7e9f7; border: 0; padding: 18px; }
.user-sheet .row { align-items: center; margin-bottom: 14px; }
.user-sheet .btn-compact { flex: 0 0 auto; padding: 6px 12px; font-size: 13px; }
.user-sheet h2 { margin: 0; }
.user-grid { width: 100%; border-collapse: separate; border-spacing: 0 8px; font-size: 14px; }
.user-grid th {
  background: #3f51d6;
  color: #fff;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 600;
  font-size: 14px;
  padding: 12px 14px;
  border: 0;
}
.user-grid th:first-child { border-radius: 10px 0 0 10px; }
.user-grid th:last-child { border-radius: 0 10px 10px 0; }
.user-grid td { background: #f4f6ff; border: 0; padding: 14px; vertical-align: middle; }
.user-grid tbody tr td:first-child { border-radius: 10px 0 0 10px; }
.user-grid tbody tr td:last-child { border-radius: 0 10px 10px 0; }
.pw-cell { display: flex; align-items: center; gap: 8px; letter-spacing: 0.08em; }
.eye-btn { border: 0; background: transparent; padding: 0; line-height: 0; color: #5c6578; }
.pill.connected { background: #1f9d55; color: #fff; font-weight: 700; letter-spacing: 0.04em; }
.pill.inactive { background: #e23b3b; color: #fff; font-weight: 700; }
.pill.disconnected { background: #c9cdd8; color: #333; }
td.balance { white-space: nowrap; }
.balance-cell { display: inline-flex; align-items: center; gap: 8px; min-height: 30px; }
.balance-value { font-weight: 700; font-variant-numeric: tabular-nums; }
.balance-loading { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; }
.balance-spin {
  width: 12px;
  height: 12px;
  border: 2px solid #d9dced;
  border-top-color: #3f51d6;
  border-radius: 50%;
  display: inline-block;
  animation: balance-spin 0.7s linear infinite;
}
@keyframes balance-spin { to { transform: rotate(360deg); } }
.balance-error { color: var(--bad); font-size: 13px; font-weight: 650; cursor: help; }
.balance-btn {
  border: 0;
  border-radius: 999px;
  background: #3f51d6;
  color: #fff;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 650;
}
.balance-btn:hover { background: #3242c4; }
.balance-refresh {
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: 8px;
  background: #eef0fb;
  color: #3f51d6;
  display: inline-grid;
  place-items: center;
  padding: 0;
}
.balance-refresh:hover { background: #e0e4f8; }
td.actions { white-space: nowrap; width: 1%; text-align: right; vertical-align: middle; }
td.actions > * + * { margin-left: 8px; }
.vendor-bar { display: flex; align-items: center; gap: 16px; margin-bottom: 14px; }
.vendor-bar .inline, .search-label { display: flex; align-items: center; gap: 8px; margin: 0; color: #333; flex: 0 0 auto; }
.vendor-bar select, .vendor-bar input { width: auto; margin: 0; }
.search-label { margin-left: auto; }
.search-label input { min-width: 180px; }
.create-vendor { flex: 0 0 auto; background: #6d4dff; border-color: #6d4dff; color: #fff; border-radius: 999px; padding: 8px 16px; }
.vendor-bar .search-label { margin-left: auto; }
.endpoint-cell { display: grid; gap: 4px; font-size: 13px; }
.endpoint-cell b { color: var(--muted); font-weight: 650; margin-right: 4px; }
.url-cell { max-width: 220px; word-break: break-all; }
.vendor-expand { display: inline-flex; align-items: center; gap: 8px; }
.expand-btn {
  width: 24px;
  height: 24px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: #333;
  font-size: 16px;
  line-height: 1;
  padding: 0;
  cursor: pointer;
  flex: 0 0 auto;
}
.expand-btn:hover { background: #f7f8fc; }
.api-account-detail td { padding: 0; background: #f7f8fc; border-bottom: 1px solid var(--line); }
.api-account-detail[hidden] { display: none; }
.endpoint-panel {
  display: grid;
  gap: 10px;
  padding: 14px 16px 14px 48px;
  background: #f4f5f8;
}
.endpoint-item { display: grid; gap: 2px; }
.endpoint-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.endpoint-value { font-size: 14px; color: var(--ink); word-break: break-all; }
.api-account-modal { width: min(640px, 94vw); }
.api-account-form { display: grid; gap: 12px; margin-top: 16px; }
.api-account-form label { display: grid; gap: 6px; margin: 0; font-size: 14px; color: #222; }
.api-account-form input { margin: 0; }
.secret-field { display: flex; align-items: center; gap: 8px; }
.secret-field input { flex: 1; }
.vendor-form-card { background: #fff; border-radius: 18px; padding: 28px 28px 22px; }
.vendor-form { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 28px; }
#tplForm.vendor-form { grid-template-columns: 1fr; max-width: 640px; margin: 0 auto; }
#tplForm textarea { min-height: 140px; }
.vendor-form label { font-size: 14px; color: #222; }
.vendor-form input { border-radius: 12px; background: #fff; }
.vendor-form .check-line { grid-column: 1; display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
.vendor-form .check-line input { width: 18px; height: 18px; }
.vendor-actions { display: flex; justify-content: center; gap: 14px; margin-top: 18px; }
.pill-btn { background: #6d4dff; color: #fff; border: 1px solid #6d4dff; border-radius: 999px; padding: 10px 22px; }
.pill-btn.ghost { background: #fff; color: #6d4dff; }
.modal-back { position: fixed; inset: 0; background: rgba(20, 16, 40, 0.28); display: grid; place-items: center; z-index: 20; }
.modal-back.confirm-layer { z-index: 40; }
.price-modal { width: min(760px, 94vw); background: #fff; border-radius: 16px; padding: 22px 24px 18px; box-shadow: 0 24px 60px rgba(20, 16, 40, 0.18); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.modal-head h2 { margin: 0; font-size: 22px; }
.x-btn { border: 0; background: transparent; font-size: 28px; line-height: 1; color: #444; }
.price-map { display: grid; grid-template-columns: 1.2fr 1fr auto; gap: 14px; align-items: end; margin: 18px 0; }
.price-map label { display: flex; flex-direction: column; gap: 8px; }
.price-grid { width: 100%; border-collapse: collapse; }
.price-grid th { text-align: left; background: #f4f6fb; color: #667; font-size: 12px; letter-spacing: 0.04em; padding: 10px 12px; }
.price-grid td { padding: 12px; border-bottom: 1px solid #eee; }
.price-grid tr.price-pick { cursor: pointer; }
.modal-foot { display: flex; justify-content: flex-end; margin-top: 16px; }
.confirm-modal {
  width: min(420px, 92vw);
  background: #fff;
  border-radius: 16px;
  padding: 28px 24px 22px;
  box-shadow: 0 24px 60px rgba(20, 16, 40, 0.18);
}
.confirm-modal h2 { margin: 0; font-size: 18px; font-weight: 650; text-align: center; line-height: 1.4; }
.confirm-modal .modal-foot { justify-content: center; gap: 10px; }
.route-create h2 { margin: 0 0 4px; }
.section-bar { margin: 16px 0 12px; background: #3f51d6; color: #fff; border-radius: 8px; padding: 10px 14px; font-weight: 700; letter-spacing: 0.04em; }
.route-country { display: block; max-width: 100%; }
.trunk-head, .trunk-row { display: grid; grid-template-columns: 1.6fr 140px 90px 48px; gap: 12px; align-items: center; }
.trunk-head { color: #667; font-size: 12px; letter-spacing: 0.04em; margin-bottom: 8px; }
.trunk-row { margin-bottom: 8px; }
.trunk-row select, .trunk-row input { margin: 0; }
.trunk-hint { color: #667; }
.add-trunk { background: #fff; color: #6d4dff; border: 1px dashed #6d4dff; border-radius: 10px; padding: 8px 14px; }
.add-trunk:disabled { opacity: 0.4; cursor: default; }
.trunk-total { margin: 14px 0; }
.route-actions { display: flex; justify-content: flex-end; gap: 10px; }
.icon-btn { width: 30px; height: 30px; border: 0; border-radius: 8px; background: #3f51d6; color: #fff; display: inline-grid; place-items: center; padding: 0; }
.icon-btn.stop { background: #2f2f2f; }
.icon-btn.remove { background: #c43838; }
.icon-btn:disabled { opacity: 0.35; cursor: default; }
.run-btn { border: 0; border-radius: 999px; color: #fff; padding: 6px 12px; font-size: 13px; }
.run-btn.start { background: #1f9d55; }
.run-btn.stop { background: #2f2f2f; }
.run-btn:disabled { opacity: 0.35; cursor: default; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 12px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-weight: 650; font-size: 12px; letter-spacing: 0.04em; text-transform: uppercase; }
tbody tr:hover td { background: #fafbff; }
.pill {
  display: inline-block;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 12px;
  background: #eee7dc;
}
.pill.delivered, .pill.DELIVERED, .pill.completed, .pill.approved, .pill.active, .pill.ACTIVE, .pill.connected { background: #e5f4ea; color: var(--good); }
.pill.failed, .pill.FAILED, .pill.undelivered, .pill.rejected, .pill.cancelled, .pill.inactive, .pill.INACTIVE { background: #fde8e6; color: var(--bad); }
.pill.disconnected { background: #f4f5f8; color: #5c6570; }
.pill.queued, .pill.QUEUED, .pill.sending, .pill.SENDING, .pill.scheduled, .pill.sent, .pill.SENT, .pill.pending, .pill.PENDING, .pill.waiting, .pill.connecting { background: #fff1d6; color: var(--warn); }
.pill.waiting { text-transform: uppercase; }
.bars { display: flex; align-items: end; gap: 10px; height: 120px; }
.bar { flex: 1; background: #f0d3c4; border-radius: 8px 8px 2px 2px; min-height: 4px; position: relative; }
.bar span { position: absolute; top: -18px; left: 0; right: 0; text-align: center; font-size: 11px; color: var(--muted); }
.meta { color: var(--muted); font-size: 13px; }
.check { display: flex; gap: 8px; align-items: flex-start; color: var(--ink); }
.check input { width: auto; margin-top: 3px; }
.toast {
  position: fixed;
  bottom: 18px;
  right: 18px;
  background: var(--ink);
  color: white;
  padding: 12px 16px;
  border-radius: 12px;
}
.pager { display: flex; gap: 8px; align-items: center; margin-top: 12px; }
.pager label { display: flex; align-items: center; gap: 8px; margin: 0; flex: 0 0 auto; }
.pager select { width: auto; margin: 0; }
.campaign-toolbar {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: flex-end;
  justify-content: flex-start;
  gap: 12px;
  margin-bottom: 14px;
  width: auto;
  max-width: 100%;
}
.campaign-toolbar > * {
  flex: 0 0 auto;
  min-width: 0;
}
.campaign-toolbar .toolbar-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 140px;
  margin: 0;
  margin-bottom: 0;
}
.campaign-toolbar .toolbar-field select {
  width: 140px;
  margin: 0;
}
.campaign-toolbar .toolbar-q {
  width: 300px;
  max-width: 300px;
  margin: 0;
  flex: 0 0 300px;
}
.campaign-toolbar .toolbar-search-btn {
  width: auto;
  margin: 0;
  white-space: nowrap;
  align-self: flex-end;
}
@media (max-width: 720px) {
  .campaign-toolbar {
    flex-wrap: wrap;
  }
  .campaign-toolbar .toolbar-q {
    width: min(300px, calc(100% - 152px));
    max-width: 100%;
    flex: 1 1 200px;
  }
}
.split { display: grid; grid-template-columns: 280px 1fr; gap: 16px; }
@media (max-width: 980px) {
  .shell, .layout, .split, .vendor-form, #sendForm.layout { grid-template-columns: 1fr; }
  .shell { padding: 10px; }
  .sidebar { position: static; height: auto; display: flex; gap: 8px; overflow: auto; }
  .sidebar nav { display: flex; }
  .sidebar button { width: auto; white-space: nowrap; }
}
