:root {
  --bg: #121212;
  --bg-elev: #1a1a1a;
  --panel: #242424;
  --card: #1f1f1f;
  --line: rgba(255, 255, 255, 0.1);
  --fg: #ececec;
  --muted: #9aa0a6;
  --accent: #3d8b66;
  --accent-2: #2a4a6e;
  --ok: #8ec07c;
  --warn: #e9c46a;
  --err: #e07a7a;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --pad: 16px;
  --nav-w: 280px;
  --top: 96px;
}
* { box-sizing: border-box; }
* {
  scrollbar-width: thin;
  scrollbar-color: #9a9a9a #e4e4e4;
}
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: #e4e4e4; border-radius: 999px; }
*::-webkit-scrollbar-thumb {
  background: #9a9a9a;
  border-radius: 999px;
  border: 2px solid #e4e4e4;
}
html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.45 "Segoe UI", system-ui, sans-serif;
}
button, input, select, textarea { font: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--err); min-height: 1.2em; }
.eyebrow { margin: 0; color: var(--muted); letter-spacing: 0.12em; text-transform: uppercase; font-size: 11px; }

.auth {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
  padding-bottom: max(24px, env(safe-area-inset-bottom));
}
.auth-card {
  width: min(100%, 400px);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 28px 24px;
  box-shadow: var(--shadow);
}
.auth-card h1 { margin: 6px 0 4px; font-size: 32px; }
.auth-card label, .field { display: block; margin: 14px 0; }
.auth-card input, input, select, textarea {
  width: 100%;
  margin-top: 6px;
  padding: 12px 14px;
  color: var(--fg);
  background: #111;
  border: 1px solid var(--line);
  border-radius: 10px;
}
textarea { min-height: 88px; resize: vertical; }
textarea.donor-pack { min-height: 320px; }
textarea.caption-area {
  min-height: min(52vh, 420px);
  height: min(52vh, 420px);
  font-size: 16px;
  line-height: 1.5;
}
.promo-photo-frame {
  margin: 14px 0 8px;
  background: #0a0a0a;
  border: 1px solid var(--line);
  border-radius: 12px;
  min-height: 240px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
}
.promo-photo-frame.empty {
  min-height: 88px;
}
.promo-photo-frame img {
  display: block;
  max-width: 100%;
  max-height: min(78vh, 820px);
  width: auto;
  height: auto;
  object-fit: contain;
}
.promo-now {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
  margin: 12px 0 4px;
}
.promo-now-item {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  margin: 0;
  padding: 8px;
  min-height: 0;
  background: #0a0a0a;
  text-align: left;
}
.promo-now-item img {
  width: 100%;
  max-height: 240px;
  object-fit: contain;
  background: #000;
  border-radius: 8px;
}
.promo-now-item span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

button {
  border: 0;
  border-radius: 12px;
  padding: 12px 16px;
  min-height: 44px;
  cursor: pointer;
  font-weight: 650;
  color: var(--fg);
  background: #2a2a2a;
  border: 1px solid var(--line);
}
button.primary { background: var(--accent); border-color: transparent; color: #fff; }
button.ghost { background: transparent; }
button.danger { background: #5a2424; border-color: #7a3333; }
button.sm { min-height: 36px; padding: 8px 12px; width: auto; }
button.filter-plus {
  width: 44px;
  min-height: 44px;
  padding: 0;
  margin-top: 8px;
  font-size: 26px;
  line-height: 1;
}
button:disabled { opacity: 0.5; cursor: default; }
button.is-busy {
  opacity: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: wait;
}
button.is-busy::before {
  content: "";
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.btn-row, .row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-row > button, .row > button { flex: 1 1 140px; }
.icon-btn {
  width: 42px;
  min-width: 42px;
  padding: 0;
  background: transparent;
}

.shell { min-height: 100dvh; display: flex; flex-direction: column; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: var(--top);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  padding-top: max(8px, env(safe-area-inset-top));
  background: rgba(18, 18, 18, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}
.brand { font-weight: 800; letter-spacing: 0.04em; font-size: 22px; }
.who { color: var(--muted); font-size: 13px; margin-left: auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 30vw; }
.pills { display: none; gap: 6px; flex-wrap: wrap; align-items: center; }
.pill {
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
}
.pill.on { color: var(--ok); border-color: #3d5a3d; }

.shell-body {
  display: flex;
  flex: 1;
  min-height: 0;
  align-items: stretch;
  position: relative;
}
.sidenav {
  position: fixed;
  top: var(--top);
  left: 0;
  bottom: 0;
  width: min(86vw, var(--nav-w));
  background: var(--bg-elev);
  border-right: 1px solid var(--line);
  padding: 12px;
  transform: translateX(-110%);
  transition: transform 0.2s ease;
  z-index: 30;
  overflow: auto;
  pointer-events: none;
}
.sidenav.open {
  transform: none;
  pointer-events: auto;
}
.sidenav button {
  width: 100%;
  text-align: left;
  margin: 6px 0;
  min-height: 52px;
  padding: 14px 16px;
  font-size: 17px;
  background: transparent;
}
.sidenav button.active { background: var(--panel); border-color: var(--accent); }
.sidenav .nav-group {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.sidenav .nav-group .chev {
  display: inline-block;
  transform: rotate(-90deg);
  transition: transform 0.15s ease;
}
.sidenav .nav-group.open .chev { transform: none; }
.nav-group-list[hidden] { display: none; }
.nav-group-list button { margin: 4px 0 4px 10px; width: calc(100% - 10px); }
.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 25;
  pointer-events: none;
}
.backdrop:not(.hidden) { pointer-events: auto; }

.content {
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
  max-width: none;
  padding: 20px 28px;
  padding-bottom: max(28px, env(safe-area-inset-bottom));
}
.page-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
.page-head h2 { margin: 0; font-size: 22px; flex: 1; }
.spin {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  border: 2px solid var(--line);
  border-top-color: var(--fg);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--pad);
  margin-bottom: 14px;
}
.card h3 { margin: 0 0 10px; font-size: 15px; }
.status { color: var(--ok); white-space: pre-wrap; }
.log {
  background: #0e0e0e;
  border: 1px solid var(--line);
  color: #cfcfcf;
  font: 13px/1.45 ui-monospace, Consolas, monospace;
  height: min(56vh, 640px);
  overflow: auto;
  padding: 12px;
  border-radius: 10px;
  white-space: pre-wrap;
}
.hint { color: var(--muted); font-size: 13px; margin: 0; }
#subs-total {
  margin: 10px 0 12px;
  padding: 10px 12px;
  background: #111;
  border: 1px solid var(--line);
  border-radius: 10px;
}
.goip-cookie-ok { padding: 12px 16px; }
.qr-box {
  display: flex;
  justify-content: center;
  margin: 16px 0;
}
.qr-box svg {
  width: 220px;
  height: 220px;
  background: #fff;
  padding: 10px;
  border-radius: 12px;
}
.list {
  max-height: 240px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #111;
}
.list.filter-donors {
  max-height: min(58vh, 680px);
}
.list.filter-donors .file-item {
  min-height: 58px;
  padding: 16px 18px;
  font-size: 16px;
  gap: 14px;
}
.svc, .file-item {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.file-item {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: space-between;
}
.file-item span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.file-item .file-del {
  flex: 0 0 auto;
  color: #c98a8a;
}
.svc:last-child, .file-item:last-child { border-bottom: 0; }
.svc.active, .file-item.active { background: #1e3a2a; outline: 1px solid var(--accent); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.chips button { flex: 0 0 auto; min-height: 36px; padding: 6px 12px; }
.chips button.active { background: var(--accent); border-color: transparent; color: #fff; }
.grid-2 {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}
.check { display: flex; align-items: center; gap: 10px; margin: 8px 0; }
.check input { width: auto; margin: 0; }
.user-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.user-row:last-child { border-bottom: 0; }
.user-row .danger { flex: 0 0 auto; width: auto; }
.route-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-bottom: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
}
.route-row label { margin: 0; }
.route-head {
  display: none;
  font-size: 12px;
  color: var(--muted);
  padding: 0 12px 6px;
  gap: 8px;
}
.err-banner {
  color: var(--err);
  background: #2a1515;
  border: 1px solid #7a3333;
  border-radius: 10px;
  padding: 10px 12px;
  margin: 0 0 12px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: max(28px, env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(12px);
  z-index: 60;
  min-width: min(92vw, 360px);
  max-width: min(92vw, 420px);
  padding: 16px 18px;
  border-radius: 16px;
  background: #1c2a22;
  border: 1px solid #3d8b66;
  color: #e8f5ee;
  box-shadow: var(--shadow);
  font-weight: 650;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}
.toast.err {
  background: #2a1515;
  border-color: #7a3333;
  color: #f3d6d6;
}

button.danger {
  background: #6b2b2b;
  border-color: #8a4040;
  color: #ffd6d6;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(6, 8, 7, 0.72);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
  z-index: 50;
}
.modal-card {
  width: min(100%, 520px);
  max-height: min(92dvh, 860px);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  background: linear-gradient(180deg, #262a28 0%, #1c1f1e 100%);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 22px 22px 18px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}
.modal-card[data-tone="danger"] {
  background: linear-gradient(180deg, #322222 0%, #1f1616 100%);
  border-color: #7a3333;
}
.modal-card[data-tone="warn"] {
  background: linear-gradient(180deg, #2e2a1c 0%, #1d1b14 100%);
  border-color: #7a6a33;
}
.modal-card .eyebrow {
  margin-bottom: 6px;
}
.modal-card h2 {
  margin: 0 0 10px;
  font-size: 22px;
  letter-spacing: -0.02em;
}
.ref-copy-menu {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}
.ref-copy-menu[hidden] { display: none; }
#modal-body button.ref-link {
  display: inline;
  width: auto;
  min-height: 0;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--accent);
  font-weight: 550;
  text-align: left;
  text-decoration: underline;
  word-break: break-all;
  cursor: pointer;
}
#modal-body {
  white-space: pre-wrap;
  color: var(--muted);
  margin: 0 0 14px;
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}
.modal-stats {
  display: grid;
  gap: 8px;
  margin: 0 0 18px;
  padding: 12px;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid var(--line);
  flex: 0 1 auto;
  max-height: 28vh;
  overflow: auto;
}
.modal-stats div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 14px;
}
.modal-stats span { color: var(--muted); }
.modal-stats strong { font-weight: 700; text-align: right; }
.modal-actions {
  margin-top: 4px;
  flex: 0 0 auto;
  padding-top: 8px;
}
.modal-actions button { flex: 1; }

#boost-panes button {
  min-height: 52px;
  padding: 14px 22px;
  font-size: 16px;
}
.boost-layout {
  display: grid;
  gap: 14px;
  align-items: start;
}
.boost-right .log {
  height: min(32vh, 320px);
}
.boost-left #svcs {
  max-height: min(52vh, 560px);
}
#pane-subs #subs {
  max-height: min(42vh, 440px);
}
@media (min-width: 1200px) {
  .boost-layout {
    grid-template-columns: minmax(300px, 0.92fr) minmax(420px, 1.2fr);
  }
  .boost-left {
    position: sticky;
    top: calc(var(--top) + 10px);
  }
}

.gb-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 14px;
}
.gb-stats div {
  background: #111;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px 16px;
  min-height: 92px;
}
.gb-stats span { display: block; color: var(--muted); font-size: 13px; }
.gb-stats strong { font-size: 28px; }
.gb-price { position: relative; }
.gb-price-current {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: auto;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  min-height: 0;
  font-size: 28px;
  font-weight: 700;
  line-height: 1.2;
  cursor: pointer;
}
.gb-price-current::after {
  content: "";
  width: 8px;
  height: 8px;
  margin-top: -4px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
}
.gb-price-menu[hidden] { display: none; }
.gb-price-menu {
  position: absolute;
  z-index: 4;
  left: 8px;
  right: 8px;
  top: calc(100% - 8px);
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px;
  background: #1a1a1a;
  border: 1px solid var(--line);
  border-radius: 10px;
}
.gb-price-menu button {
  width: 100%;
  min-height: 36px;
  text-align: left;
}
.gb-price-menu button.on { border-color: var(--accent); }
.list.gb-offers,
.list.gb-accounts {
  max-height: min(58vh, 680px);
}
.modal-pick {
  max-height: min(42vh, 420px);
  margin-bottom: 8px;
}
.gb-offers-hidden { margin-top: 10px; }
.gb-offer-row .gb-offer-main { cursor: pointer; flex: 1; min-width: 0; }
.gb-offer-row > span.gb-worked {
  flex: 0 0 auto;
  min-width: max-content;
  color: var(--ok);
  font-size: 12px;
  font-weight: 650;
  white-space: nowrap;
  overflow: visible;
  text-overflow: clip;
}
.gb-work {
  flex: 0 0 auto;
  white-space: nowrap;
}
.gb-acc-switch {
  width: auto;
  min-width: 160px;
  max-width: 260px;
  margin-top: 0;
  flex: 0 0 auto;
}
.gb-dates {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 10px;
  align-items: end;
  margin: 0 0 12px;
}
.gb-dates .field { margin: 0; }
.gb-offers-tools {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin: 12px 0;
}
.gb-offers-tools button { width: auto; flex: 0 0 auto; }
.gb-accounts-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 12px;
}
.gb-accounts-head h3 { margin: 0; }
.gb-available-line { margin: 0; color: var(--muted); text-align: right; white-space: nowrap; }
.gb-available-total {
  color: var(--fg);
  font-size: 22px;
  font-weight: 700;
  margin-left: 8px;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
}
.gb-available-total:hover { text-decoration: underline; }
.gb-available-total:disabled { cursor: progress; text-decoration: none; }
.liknot-accounts-head { align-items: flex-start; }
.liknot-totals { display: flex; gap: 28px; }
.liknot-total { margin: 0; text-align: right; color: var(--muted); }
.liknot-total span { display: block; font-size: 13px; line-height: 1.2; }
.liknot-total-value {
  display: block;
  margin: 4px 0 0 auto;
  padding: 0;
  border: 0;
  background: none;
  color: var(--fg);
  font-size: 22px;
  font-weight: 700;
  cursor: pointer;
}
.liknot-total-value:hover { text-decoration: underline; }
.liknot-total-value:disabled { cursor: progress; text-decoration: none; }
.file-item[data-liknot-offer] { cursor: pointer; }
.gb-search { margin: 0 0 10px; }
.list .file-item[hidden] { display: none; }
.tg-slot h3 { margin-bottom: 4px; }
.list .file-item[hidden] { display: none; }
.log.gb-log {
  height: 68px;
  min-height: 68px;
  padding: 8px 10px;
  font-size: 12px;
}
.gb-log-card { padding: 10px 14px; }
.gb-log-card h3 { margin-bottom: 6px; font-size: 13px; color: var(--muted); }
.gb-offer-card { min-height: 280px; }
@media (max-width: 720px) {
  .gb-dates { grid-template-columns: 1fr 1fr; }
  .gb-dates button { grid-column: 1 / -1; }
}

.goip-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.goip-tabs button { flex: 1 1 120px; }
.goip-tabs button.on { border-color: var(--accent); }
.goip-accounts { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.goip-accounts button { flex: 0 1 auto; min-width: 72px; }
.goip-accounts button.on { border-color: var(--accent); }
.goip-accounts button.is-dead { border-color: #a44; color: #e7b4b4; }
#goip-add-fields, #gb-add-fields { margin-top: 10px; }
.goip-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.goip-table th, .goip-table td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.goip-table th { color: var(--muted); font-weight: 600; }
.pick-list { max-height: 280px; overflow: auto; border: 1px solid var(--line); border-radius: 10px; background: #111; padding: 6px; }
.pick-list label { display: flex; gap: 8px; align-items: center; margin: 0; padding: 6px 8px; }
.pick-list label[hidden] { display: none; }
.pick-list input { width: auto; margin: 0; }
.list.goip-folder-list {
  max-height: min(58vh, 680px);
}
.pick-list.goip-round-folders {
  max-height: min(52vh, 560px);
}
.log.goip-log {
  height: 72px;
  min-height: 72px;
  padding: 8px 10px;
  font-size: 12px;
}
.goip-log-card { padding: 10px 14px; }
.goip-log-card h3 { margin-bottom: 6px; font-size: 13px; color: var(--muted); }

.gate {
  min-height: min(70dvh, 640px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px 0 24px;
}
.gate-card {
  width: min(100%, 480px);
  background: linear-gradient(180deg, #262a28 0%, #1c1f1e 100%);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 28px 24px 22px;
  box-shadow: var(--shadow);
  text-align: left;
}
.gate-card h2 {
  margin: 0 0 12px;
  font-size: 22px;
  letter-spacing: -0.02em;
}
.gate-card p {
  margin: 0 0 20px;
  color: var(--muted);
  white-space: pre-wrap;
}
.gate-actions {
  flex-wrap: wrap;
}
.gate-actions button {
  flex: 1 1 140px;
}
.gate-soft {
  display: grid;
  gap: 12px;
  border-color: #5a6a3a;
  background: linear-gradient(180deg, #24281e 0%, #1a1d16 100%);
}
.gate-soft p { margin: 0; color: var(--muted); }

@media (min-width: 880px) {
  #menu-btn { display: none; }
  .sidenav {
    position: relative;
    top: auto;
    left: auto;
    bottom: auto;
    height: auto;
    width: var(--nav-w);
    flex: 0 0 var(--nav-w);
    transform: none;
    pointer-events: auto;
    z-index: 1;
  }
  .pills { display: flex; }
  .grid-2 { grid-template-columns: 1fr 1fr; }
  .route-row, .route-head { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1.2fr) minmax(0, 1.2fr) 76px auto; align-items: end; }
  .route-head { display: grid; }
  .who { max-width: none; }
}
