:root {
  color-scheme: dark;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
  --bg: #050807;
  --panel: #0b1110;
  --panel-soft: #101917;
  --text: #eaf8f0;
  --muted: #8ea69a;
  --line: #1e312b;
  --green: #020403;
  --green-2: #35d07f;
  --green-soft: #143424;
  --input: #090f0d;
  --track: #15241f;
  --sidebar-text: #f4fff8;
  --sidebar-muted: #739484;
  --brand-bg: #35d07f;
  --danger: #ff6f6f;
  --danger-soft: #2a1113;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 18px 42px rgba(0, 0, 0, 0.22);
}

body.mode-light {
  color-scheme: light;
}

body.theme-3.mode-dark {
  --bg: #050807;
  --panel: #0b1110;
  --panel-soft: #101917;
  --text: #eaf8f0;
  --muted: #8ea69a;
  --line: #1e312b;
  --green: #020403;
  --green-2: #35d07f;
  --green-soft: #143424;
  --input: #090f0d;
  --track: #15241f;
  --sidebar-text: #f4fff8;
  --sidebar-muted: #739484;
  --brand-bg: #35d07f;
  --danger: #ff6f6f;
  --danger-soft: #2a1113;
}

body.theme-3.mode-light {
  --bg: #f2f7f3;
  --panel: #ffffff;
  --panel-soft: #f6fbf7;
  --text: #111b16;
  --muted: #607167;
  --line: #d7e3da;
  --green: #07140e;
  --green-2: #0d8b52;
  --green-soft: #e4f6eb;
  --input: #ffffff;
  --track: #e8f1eb;
  --sidebar-text: #f4fff8;
  --sidebar-muted: #9dbaaa;
  --brand-bg: #bdf3ce;
}

body.theme-2.mode-dark {
  --bg: #101110;
  --panel: #181918;
  --panel-soft: #20211f;
  --text: #f6f4ef;
  --muted: #b2aea5;
  --line: #30312e;
  --green: #151512;
  --green-2: #d8d1c3;
  --green-soft: #2b2923;
  --input: #141513;
  --track: #292a27;
  --sidebar-text: #fffdf6;
  --sidebar-muted: #aaa596;
  --brand-bg: #f0e7d6;
}

body.theme-2.mode-light {
  --bg: #f6f3ec;
  --panel: #fffdfa;
  --panel-soft: #f0ece3;
  --text: #25231f;
  --muted: #746f64;
  --line: #ded8cc;
  --green: #25231f;
  --green-2: #76664a;
  --green-soft: #eee7da;
  --input: #fffdfa;
  --track: #e8e0d2;
  --sidebar-text: #fffdf7;
  --sidebar-muted: #c9c0ad;
  --brand-bg: #eee0c6;
}

body.theme-5.mode-dark {
  --bg: #15120f;
  --panel: #201b16;
  --panel-soft: #2a231c;
  --text: #fbf1e3;
  --muted: #b7a894;
  --line: #3a3026;
  --green: #24180f;
  --green-2: #d39a55;
  --green-soft: #392717;
  --input: #1b1611;
  --track: #34291f;
  --sidebar-text: #fff5e6;
  --sidebar-muted: #c4a786;
  --brand-bg: #e5b06b;
}

body.theme-5.mode-light {
  --bg: #f7f1e7;
  --panel: #fffaf2;
  --panel-soft: #f0e4d2;
  --text: #2c2118;
  --muted: #796858;
  --line: #e2d2bd;
  --green: #3b281b;
  --green-2: #a96a2e;
  --green-soft: #f1dfc8;
  --input: #fffaf2;
  --track: #eadac6;
  --sidebar-text: #fff7ec;
  --sidebar-muted: #cfb79c;
  --brand-bg: #f0c48a;
}

body.theme-8.mode-dark {
  --bg: #0d1020;
  --panel: #14182b;
  --panel-soft: #1a2038;
  --text: #f1f4ff;
  --muted: #a2acc9;
  --line: #27304e;
  --green: #10142a;
  --green-2: #8b9cff;
  --green-soft: #232b58;
  --input: #11162a;
  --track: #222a4b;
  --sidebar-text: #f4f6ff;
  --sidebar-muted: #9ca8d4;
  --brand-bg: #9ba8ff;
}

body.theme-8.mode-light {
  --bg: #f4f6ff;
  --panel: #ffffff;
  --panel-soft: #eef1ff;
  --text: #171a2f;
  --muted: #626b8c;
  --line: #dbe0f3;
  --green: #171a3a;
  --green-2: #5364dd;
  --green-soft: #e4e8ff;
  --input: #ffffff;
  --track: #e8ecff;
  --sidebar-text: #f7f8ff;
  --sidebar-muted: #a8b0dd;
  --brand-bg: #dbe1ff;
}

* {
  box-sizing: border-box;
}

body {
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  letter-spacing: 0;
  margin: 0;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a {
  color: var(--green-2);
}

.shell {
  display: grid;
  grid-template-columns: 256px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  background: var(--green);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  gap: 22px;
  left: 0;
  padding: 18px 13px;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 5;
}

.brand {
  align-items: center;
  display: flex;
  gap: 12px;
  padding: 6px 8px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
}

.brand > span {
  align-items: center;
  background: var(--brand-bg);
  border-radius: 8px;
  color: var(--green);
  display: inline-flex;
  font-weight: 800;
  height: 34px;
  justify-content: center;
  width: 34px;
}

.brand b,
.brand small {
  display: block;
}

.brand b {
  font-size: 14px;
  font-weight: 750;
}

.brand small {
  color: var(--sidebar-muted);
  font-size: 11px;
  font-weight: 500;
  margin-top: 2px;
}

.nav {
  display: grid;
  gap: 4px;
}

.nav p {
  color: var(--sidebar-muted);
  font-size: 10px;
  font-weight: 800;
  margin: 14px 10px 5px;
  text-transform: uppercase;
}

.nav a,
.logout {
  align-items: center;
  border-radius: 7px;
  color: #dcece1;
  display: flex;
  gap: 10px;
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.2;
  padding: 8px 10px;
  text-decoration: none;
}

.nav svg {
  fill: currentColor;
  height: 17px;
  width: 17px;
}

.nav a.active,
.nav a:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
}

.logout {
  margin-top: auto;
}

.content {
  min-width: 0;
  padding: 22px 24px;
}

.topbar {
  align-items: center;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.topbar p {
  color: var(--green-2);
  font-weight: 700;
  margin: 0 0 4px;
}

h1,
h2 {
  letter-spacing: 0;
  margin: 0;
}

h1 {
  font-size: 22px;
  font-weight: 800;
  line-height: 1.15;
}

h2 {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.25;
}

.top-actions,
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.kpi-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(156px, 1fr));
  margin-bottom: 16px;
}

.kpi-grid div,
.panel,
.login-box {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 7px;
  box-shadow: var(--shadow);
}

.kpi-grid div {
  position: relative;
  min-height: 82px;
  padding: 14px;
}

.kpi-grid i {
  align-items: center;
  background: var(--green-soft);
  border-radius: 6px;
  color: var(--green-2);
  display: inline-flex;
  height: 28px;
  justify-content: center;
  position: absolute;
  right: 12px;
  top: 12px;
  width: 28px;
}

.kpi-grid i svg {
  fill: currentColor;
  height: 16px;
  width: 16px;
}

.kpi-grid b {
  display: block;
  font-size: 23px;
  font-weight: 800;
  line-height: 1;
}

.kpi-grid span {
  color: var(--muted);
  display: block;
  font-size: 12px;
  line-height: 1.35;
  margin-top: 7px;
}

.kpi-grid .danger-stat {
  background: var(--danger-soft);
  border-color: #e4b3b3;
}

.kpi-grid .danger-stat b,
.kpi-grid .danger-stat span {
  color: var(--danger);
}

.kpi-grid .danger-stat i {
  background: #ffe8e8;
  color: var(--danger);
}

.panel {
  margin-bottom: 18px;
  overflow: hidden;
  padding: 16px;
}

.panel-head {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin: -2px 0 14px;
  padding-bottom: 12px;
}

.subhead {
  color: var(--muted);
  display: block;
  font-size: 12px;
  margin-top: 4px;
}

.two-col {
  display: grid;
  gap: 18px;
  grid-template-columns: repeat(2, minmax(280px, 1fr));
}

.funnel {
  display: grid;
  gap: 12px;
}

.funnel-row {
  align-items: center;
  display: grid;
  gap: 12px;
  grid-template-columns: 130px minmax(0, 1fr) 80px;
}

.funnel-row span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.funnel-row > div,
.bar {
  background: var(--track);
  border-radius: 999px;
  height: 8px;
  overflow: hidden;
}

.funnel-row b,
.bar b {
  background: var(--green-2);
  border-radius: inherit;
  display: block;
  height: 100%;
  min-width: 2px;
}

.funnel-row strong {
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.bar {
  height: 5px;
  margin-top: 7px;
  max-width: 280px;
}

.timeline-grid {
  display: grid;
  gap: 18px;
  grid-template-columns: repeat(3, minmax(220px, 1fr));
}

.timeline-grid h3 {
  font-size: 13px;
  margin: 0 0 10px;
}

.mini-chart {
  display: grid;
  gap: 8px;
}

.chart-row {
  align-items: center;
  display: grid;
  gap: 8px;
  grid-template-columns: 76px minmax(0, 1fr) 44px;
}

.chart-row span {
  color: var(--muted);
  font-size: 11px;
}

.chart-row div {
  background: var(--track);
  border-radius: 999px;
  height: 7px;
  overflow: hidden;
}

.chart-row b {
  background: var(--green-2);
  border-radius: inherit;
  display: block;
  height: 100%;
  min-width: 2px;
}

.chart-row strong {
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.operations-list {
  display: grid;
  gap: 10px;
}

.operation {
  align-items: center;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 6px;
  display: flex;
  justify-content: space-between;
  padding: 10px 12px;
}

.operation[data-status="running"] {
  border-color: var(--green-2);
}

.operation[data-status="failed"] {
  border-color: var(--danger);
}

.operation span,
.operation em {
  color: var(--muted);
  display: block;
  font-size: 12px;
  font-style: normal;
}

.operation em {
  color: var(--danger);
}

.operation strong,
.num {
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}

label {
  color: var(--muted);
  display: grid;
  font-size: 12px;
  gap: 6px;
}

input,
textarea,
select {
  background: var(--input);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  padding: 9px 10px;
  width: 100%;
}

button,
.button {
  align-items: center;
  background: var(--green-2);
  border: 0;
  border-radius: 6px;
  color: #ffffff;
  cursor: pointer;
  display: inline-flex;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  gap: 8px;
  justify-content: center;
  min-height: 38px;
  padding: 9px 12px;
  position: relative;
  text-decoration: none;
  transform: translateY(0) scale(1);
  transition: transform 120ms ease, filter 120ms ease, box-shadow 120ms ease, opacity 120ms ease;
  user-select: none;
}

button:hover,
.button:hover {
  filter: brightness(1.06);
}

button:active,
.button:active,
button.is-pressed,
.button.is-pressed {
  box-shadow: inset 0 2px 7px rgba(0, 0, 0, 0.3);
  filter: brightness(0.9);
  transform: translateY(1px) scale(0.985);
}

button.is-loading,
.button.is-loading {
  cursor: wait;
  opacity: 0.84;
  pointer-events: none;
}

button.is-loading::before,
.button.is-loading::before {
  animation: button-spin 700ms linear infinite;
  border: 2px solid rgba(255, 255, 255, 0.38);
  border-radius: 50%;
  border-top-color: #ffffff;
  content: "";
  flex: 0 0 auto;
  height: 13px;
  width: 13px;
}

.ghost.is-loading::before {
  border-color: rgba(34, 197, 94, 0.25);
  border-top-color: var(--green);
}

@keyframes button-spin {
  to { transform: rotate(360deg); }
}

.ghost {
  background: var(--green-soft);
  color: var(--green);
}

.settings-grid,
.segment-form {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  margin-bottom: 14px;
}

.composer-layout {
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(0, 1.45fr) minmax(280px, 0.65fr);
}

.composer {
  display: grid;
  gap: 13px;
}

.composer-toolbar {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(3, minmax(120px, 1fr));
}

.message-field textarea {
  min-height: 190px;
  resize: vertical;
}

.composer-meta {
  align-items: center;
  color: var(--muted);
  display: flex;
  font-size: 12px;
  justify-content: space-between;
}

small {
  color: var(--muted);
  font-size: 11px;
}

.warning {
  color: var(--danger);
  font-weight: 700;
}

.ok-text {
  color: var(--green-2);
  font-weight: 700;
}

.guidelines {
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 15px;
}

.guidelines h3 {
  font-size: 14px;
  margin: 0 0 10px;
}

.guidelines ul {
  color: var(--muted);
  display: grid;
  gap: 8px;
  line-height: 1.35;
  margin: 0;
  padding-left: 18px;
}

.preview-card {
  background: var(--input);
  border: 1px solid var(--line);
  border-radius: 8px;
  margin: 0 0 16px;
  padding: 13px;
}

.vk-preview {
  background: #0f172a;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 18px;
  padding: 14px;
}

.vk-preview > span {
  color: #9fb0cf;
  display: block;
  font-size: 11px;
  font-weight: 800;
  margin-bottom: 12px;
  text-transform: uppercase;
}

.vk-message {
  align-items: flex-start;
  display: flex;
  gap: 10px;
}

.vk-avatar {
  align-items: center;
  background: #3f8cff;
  border-radius: 50%;
  color: #fff;
  display: inline-flex;
  flex: 0 0 auto;
  font-size: 11px;
  font-weight: 800;
  height: 34px;
  justify-content: center;
  width: 34px;
}

.vk-bubble {
  background: #1f2937;
  border: 1px solid #334155;
  border-radius: 14px;
  color: #f8fafc;
  display: grid;
  gap: 9px;
  max-width: 520px;
  padding: 12px;
}

.vk-bubble b {
  color: #c7d2fe;
  font-size: 12px;
}

.vk-bubble p {
  line-height: 1.45;
  margin: 0;
  white-space: pre-wrap;
}

.vk-attachment {
  height: 96px;
  width: 96px;
}

.offer-image-card {
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.image-thumb {
  align-items: center;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: inline-flex;
  height: 96px;
  justify-content: center;
  overflow: hidden;
  width: 96px;
}

.image-thumb img {
  display: block;
  height: 100%;
  object-fit: contain;
  width: 100%;
}

.vk-message-button {
  align-self: start;
  background: var(--green-2);
  border-radius: 7px;
  color: #fff;
  display: inline-flex;
  font-size: 13px;
  font-weight: 800;
  justify-content: center;
  padding: 10px 14px;
  text-decoration: none;
  width: fit-content;
}

.vk-message-button.success {
  background: #16a34a;
}

.vk-message-button.danger {
  background: #dc2626;
}

.vk-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.button-builder {
  display: grid;
  gap: 10px;
}

.button-builder > b {
  font-size: 13px;
}

.button-row {
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(120px, 1fr) 140px minmax(160px, 1.2fr);
}

.preview-card span {
  color: var(--muted);
  display: block;
  font-size: 11px;
  font-weight: 800;
  margin-bottom: 8px;
  text-transform: uppercase;
}

.preview-card p {
  line-height: 1.45;
  margin: 0;
  white-space: pre-wrap;
}

.stats-token-box {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 14px;
  margin-top: 18px;
  padding-top: 18px;
}

.hint {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  margin: 0;
}

.settings-grid .wide {
  grid-column: 1 / -1;
}

.segment-form .check,
.settings-grid .check {
  align-items: center;
  display: flex;
  gap: 7px;
}

.segment-form .check input,
.settings-grid .check input {
  width: auto;
}


.mailing-actions {
  align-items: stretch;
}

.test-recipient-form {
  align-items: center;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 8px;
}

.test-recipient-title {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  margin-right: 2px;
  text-transform: uppercase;
}

.test-recipient-form .check {
  align-items: center;
  background: var(--input);
  border: 1px solid var(--line);
  border-radius: 7px;
  display: inline-flex;
  gap: 7px;
  min-height: 40px;
  padding: 0 12px;
}

.test-recipient-form .check input {
  width: auto;
}

.upload-inline {
  color: var(--muted);
  display: grid;
  gap: 4px;
  font-size: 12px;
}

.upload-inline span {
  color: var(--text);
  font-weight: 700;
}

table {
  border-collapse: collapse;
  font-size: 12.5px;
  min-width: 720px;
  width: 100%;
}

td,
th {
  border-top: 1px solid var(--line);
  padding: 8px 10px;
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.badge {
  background: var(--panel-soft);
  border-radius: 999px;
  color: var(--muted);
  display: inline-flex;
  font-size: 12px;
  font-weight: 800;
  padding: 4px 8px;
}

.badge.ok {
  background: var(--green-soft);
  color: var(--green-2);
}

.badge.bad {
  background: var(--danger-soft);
  color: var(--danger);
}

.login {
  display: grid;
  min-height: 100vh;
  place-items: center;
}

.login-box {
  padding: 24px;
  width: min(360px, calc(100vw - 32px));
}

.login-box h1 {
  margin-bottom: 14px;
}

@media (min-width: 1500px) {
  .content {
    padding: 28px 34px;
  }

  .kpi-grid {
    grid-template-columns: repeat(6, minmax(160px, 1fr));
  }
}

@media (max-width: 1180px) {
  .shell {
    grid-template-columns: 220px minmax(0, 1fr);
  }

  .content {
    padding: 18px;
  }

  .kpi-grid {
    grid-template-columns: repeat(auto-fit, minmax(142px, 1fr));
  }

  .composer-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 980px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    height: auto;
    gap: 14px;
    position: static;
  }

  .brand {
    padding-bottom: 12px;
  }

  .nav {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 4px;
  }

  .nav p {
    display: none;
  }

  .nav a {
    flex: 0 0 auto;
    white-space: nowrap;
  }

  .logout {
    display: none;
  }

  .topbar {
    align-items: start;
  }

  .topbar,
  .two-col {
    display: grid;
    grid-template-columns: 1fr;
  }

  .settings-grid,
  .segment-form,
  .composer-layout,
  .mailing-preview-top,
  .button-row,
  .composer-toolbar,
  .timeline-grid {
    grid-template-columns: 1fr;
  }

  .panel {
    overflow-x: auto;
  }
}

@media (max-width: 760px) {
  body {
    font-size: 12.5px;
  }

  .content {
    padding: 14px;
  }

  h1 {
    font-size: 20px;
  }

  .top-actions,
  .actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .top-actions form,
  .actions form,
  .top-actions button,
  .actions button,
  .actions .button {
    width: 100%;
  }

  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .kpi-grid div {
    min-height: 76px;
  }

  .funnel-row {
    grid-template-columns: 92px minmax(0, 1fr) 54px;
  }

  .panel-head {
    align-items: start;
    display: grid;
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .sidebar {
    padding: 14px 12px;
  }

  .brand small {
    display: none;
  }

  .content {
    padding: 10px;
  }

  .kpi-grid {
    gap: 9px;
  }

  .kpi-grid b {
    font-size: 20px;
  }

  .kpi-grid span {
    font-size: 11px;
  }

  .operation {
    align-items: start;
    display: grid;
    gap: 8px;
  }

  .composer-meta {
    align-items: start;
    display: grid;
    gap: 6px;
  }
}
