:root {
  color-scheme: dark;
  --bg: #111b24;
  --panel: #172635;
  --panel-2: #1d3042;
  --text: #f4f7fb;
  --muted: #94a8b8;
  --line: #2b4154;
  --accent: #39d98a;
  --danger: #ff6b6b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: #05080d;
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.shell {
  width: min(720px, 100%);
  margin: 0 auto;
  padding: 18px;
}

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

.eyebrow {
  margin: 0 0 4px;
  color: #ff4fa3;
  font-size: 13px;
  font-weight: 700;
}

h1,
h2 {
  margin: 0;
}

h1 {
  font-size: 24px;
}

h2 {
  font-size: 17px;
}

.status {
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 13px;
  padding: 7px 10px;
  white-space: nowrap;
}

.status[data-mode="ok"] {
  color: var(--accent);
}

.status[data-mode="error"] {
  color: var(--danger);
}

.panel {
  background: color-mix(in srgb, var(--panel) 84%, transparent);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 12px;
  backdrop-filter: blur(10px);
}

.section-title {
  margin-bottom: 12px;
}

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 10px;
}

.field {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 10px;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
  padding: 10px 11px;
  outline: none;
}

.toggle-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.model-toggle-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.toggle {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
  font-weight: 800;
  text-align: left;
  padding: 10px 11px;
}

.model-toggle {
  text-align: center;
  padding-inline: 8px;
}

.toggle.active {
  border-color: var(--accent);
  background: #123525;
}

input:focus,
select:focus {
  border-color: var(--accent);
}

.integration {
  border-top: 1px solid var(--line);
  padding-top: 12px;
  margin-top: 12px;
}

.integration:first-child {
  border-top: 0;
  margin-top: 0;
  padding-top: 0;
}

.integration-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.integration-head span,
.muted {
  color: var(--muted);
  font-size: 12px;
}

.empty {
  color: var(--muted);
  margin: 0;
}

.secondary {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
  font-weight: 800;
  margin-top: 14px;
}

.secondary:hover {
  border-color: var(--accent);
}

.save {
  width: 100%;
  min-height: 48px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #062012;
  font-size: 16px;
  font-weight: 800;
}

.save:disabled {
  opacity: 0.6;
}

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

body.aff-card-page {
  --figma-bg: #03070c;
  --figma-panel: rgba(17, 24, 39, 0.52);
  --figma-panel-solid: #111827;
  --figma-input: rgba(12, 18, 30, 0.54);
  --figma-line: #1f2937;
  --figma-line-soft: rgba(31, 41, 55, 0.82);
  --figma-text: #ffffff;
  --figma-muted: #6b7280;
  --figma-accent: #00b8ff;
  --figma-accent-hover: #16c4ff;
  --figma-orange: #ff8020;
  background: var(--figma-bg);
  color: var(--figma-text);
  overflow: hidden;
}

body.aff-card-page::before {
  opacity: 0.42;
}

body.aff-card-page .shell {
  width: min(390px, 100%);
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 24px 24px 0;
}

body.aff-card-page .header {
  position: relative;
  z-index: 10;
  flex: 0 0 auto;
  display: block;
  margin-bottom: 6px;
}

body.aff-card-page .header::before {
  content: "";
  position: absolute;
  inset: -10px -8px -8px;
  z-index: -1;
  pointer-events: none;
  background: radial-gradient(ellipse at left center, rgba(3, 7, 12, 0.88), rgba(3, 7, 12, 0.46) 62%, rgba(3, 7, 12, 0));
  filter: blur(2px);
}

body.aff-card-page .card-scroll {
  position: relative;
  z-index: 3;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 34px 12px 24px 0;
  scrollbar-color: rgba(0, 184, 255, 0.72) rgba(12, 18, 30, 0.42);
  scrollbar-width: thin;
}

body.aff-card-page .card-scroll.is-scrolled {
  -webkit-mask-image: linear-gradient(180deg, transparent 0, #000 32px, #000 100%);
  mask-image: linear-gradient(180deg, transparent 0, #000 32px, #000 100%);
}

body.aff-card-page .card-scroll::-webkit-scrollbar {
  width: 7px;
}

body.aff-card-page .card-scroll::-webkit-scrollbar-track {
  border-radius: 999px;
  background: rgba(12, 18, 30, 0.42);
}

body.aff-card-page .card-scroll::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(0, 184, 255, 0.95), rgba(0, 112, 170, 0.72));
  box-shadow: 0 0 8px rgba(0, 184, 255, 0.32);
}

body.aff-card-page .card-scroll::before {
  display: none;
}

body.aff-card-page .eyebrow {
  color: var(--figma-orange);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.1;
  margin-bottom: 9px;
}

body.aff-card-page h1 {
  color: var(--figma-text);
  font-size: 26px;
  font-weight: 500;
  line-height: 1.08;
  white-space: nowrap;
}

body.aff-card-page h2 {
  font-size: 16px;
  font-weight: 800;
  line-height: 1.25;
}

body.aff-card-page .status {
  min-width: 84px;
  min-height: 37px;
  position: absolute;
  top: -4px;
  right: 0;
  display: inline-grid;
  place-items: center;
  border: 0;
  border-radius: 12px;
  background: var(--figma-accent);
  color: #ffffff;
  font-size: 12px;
  font-weight: 800;
  padding: 0 14px;
}

body.aff-card-page .status[data-mode="ok"],
body.aff-card-page .status[data-mode="error"] {
  color: #ffffff;
}

body.aff-card-page .panel {
  position: relative;
  z-index: 1;
  background: var(--figma-panel);
  border: 1px solid var(--figma-line);
  border-radius: 16px;
  padding: 13px 14px 14px;
  margin-bottom: 15px;
  backdrop-filter: blur(12px);
  box-shadow: none;
}

body.aff-card-page .panel:has(.custom-select) {
  z-index: 20;
}

body.aff-card-page .section-title {
  margin: 3px 4px 16px;
}

body.aff-card-page label,
body.aff-card-page .field {
  color: #ffffff;
  gap: 6px;
  font-size: 13px;
  font-weight: 800;
  margin-bottom: 12px;
}

body.aff-card-page input,
body.aff-card-page select {
  min-height: 31px;
  border: 1px solid var(--figma-line);
  border-radius: 9px;
  background: var(--figma-input);
  color: var(--figma-text);
  font-size: 13px;
  font-weight: 600;
  padding: 6px 10px;
}

body.aff-card-page input::placeholder {
  color: var(--figma-muted);
}

body.aff-card-page input:focus,
body.aff-card-page select:focus {
  border-color: rgba(0, 184, 255, 0.68);
  box-shadow: 0 0 0 2px rgba(0, 184, 255, 0.08);
}

body.aff-card-page select {
  appearance: auto;
}

body.aff-card-page select option {
  background: #0c121e;
  color: #ffffff;
}

body.aff-card-page .native-select-hidden {
  display: none;
}

body.aff-card-page .custom-select {
  position: relative;
  width: 94px;
}

body.aff-card-page .custom-select-button {
  width: 100%;
  min-height: 31px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: 1px solid var(--figma-line);
  border-radius: 10px;
  background: var(--figma-input);
  color: var(--figma-text);
  font-size: 13px;
  font-weight: 800;
  padding: 6px 13px;
}

body.aff-card-page .custom-select-arrow {
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 6px solid var(--figma-accent);
}

body.aff-card-page .custom-select-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 30;
  width: 100%;
  display: none;
  overflow: hidden;
  border: 1px solid var(--figma-line);
  border-radius: 10px;
  background: rgba(12, 18, 30, 0.98);
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.28);
}

body.aff-card-page .custom-select.open .custom-select-menu {
  display: block;
}

body.aff-card-page .custom-select.open .custom-select-button {
  border-color: var(--figma-accent);
  box-shadow: 0 0 0 2px rgba(0, 184, 255, 0.08);
}

body.aff-card-page .custom-select-option {
  width: 100%;
  min-height: 31px;
  border: 0;
  background: transparent;
  color: #ffffff;
  font-size: 13px;
  font-weight: 700;
  text-align: left;
  padding: 7px 14px;
}

body.aff-card-page .custom-select-option:hover,
body.aff-card-page .custom-select-option:focus-visible {
  background: rgba(0, 184, 255, 0.34);
}

body.aff-card-page .custom-select-option.active {
  color: #ffffff;
  font-weight: 900;
}

body.aff-card-page select option:checked {
  background: #111827;
  color: #ffffff;
}

body.aff-card-page .grid {
  grid-template-columns: minmax(0, 1fr) 94px;
  gap: 12px;
  align-items: end;
}

body.aff-card-page .broker-role-layout {
  display: block;
  margin-bottom: 12px;
}

body.aff-card-page .broker-link-language-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 88px;
  gap: 24px;
  align-items: end;
}

body.aff-card-page .broker-chat-link,
body.aff-card-page .broker-language-field {
  margin-bottom: 0;
}

body.aff-card-page .broker-language-field .custom-select,
body.aff-card-page .broker-language-field select {
  width: 88px;
}

body.aff-card-page #roleButtons.toggle-row {
  grid-template-columns: 76px 68px;
  gap: 10px;
}

body.aff-card-page .toggle {
  min-height: 31px;
  border: 1px solid var(--figma-line);
  border-radius: 10px;
  background: var(--figma-input);
  color: var(--figma-muted);
  font-size: 12px;
  font-weight: 800;
  text-align: center;
  padding: 6px 9px;
  transition:
    transform 0.12s ease,
    background-color 0.12s ease,
    border-color 0.12s ease,
    color 0.12s ease;
}

body.aff-card-page .toggle:active,
body.aff-card-page .secondary:active,
body.aff-card-page .save:active {
  transform: translateY(1px) scale(0.99);
}

body.aff-card-page .toggle.active {
  background: var(--figma-accent);
  border-color: var(--figma-accent);
  color: #ffffff;
}

body.aff-card-page .integration {
  border-top: 1px solid var(--figma-line-soft);
  padding: 12px 4px 0;
  margin-top: 12px;
}

body.aff-card-page .integration:first-child {
  border-top: 0;
  padding-top: 0;
  margin-top: 0;
}

body.aff-card-page .integration-head {
  margin-bottom: 12px;
}

body.aff-card-page .integration-head strong {
  color: #ffffff;
  font-size: 15px;
  font-weight: 800;
}

body.aff-card-page .integration-head span,
body.aff-card-page .muted {
  color: var(--figma-muted);
  font-size: 12px;
  font-weight: 500;
}

body.aff-card-page .integration-grid {
  grid-template-columns: minmax(0, 1fr) 58px;
  gap: 12px;
}

body.aff-card-page .model-toggle-row {
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

body.aff-card-page .broker-role-row {
  grid-template-columns: 78px 94px 82px;
  justify-content: start;
}

body.aff-card-page .model-toggle {
  min-height: 31px;
  padding-inline: 6px;
}

body.aff-card-page .aff-id {
  text-align: center;
}

body.aff-card-page .secondary {
  min-height: 51px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  border: 1px solid var(--figma-line);
  border-radius: 13px;
  background: rgba(17, 24, 39, 0.76);
  color: #ffffff;
  font-size: 17px;
  font-weight: 800;
  margin-top: 14px;
  line-height: 1;
  white-space: nowrap;
}

body.aff-card-page .broker-add-integration {
  gap: 13px;
  padding-inline: 16px;
}

body.aff-card-page .broker-add-integration span:last-child {
  display: inline-block;
  min-width: 0;
}

body.aff-card-page .plus-icon {
  position: relative;
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  filter: drop-shadow(0 2px 0 rgba(0, 96, 150, 0.8)) drop-shadow(0 0 8px rgba(0, 184, 255, 0.34));
}

body.aff-card-page .plus-icon::before,
body.aff-card-page .plus-icon::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  border-radius: 999px;
  background: var(--figma-accent);
  transform: translate(-50%, -50%);
}

body.aff-card-page .plus-icon::before {
  width: 28px;
  height: 5px;
}

body.aff-card-page .plus-icon::after {
  width: 5px;
  height: 28px;
}

body.aff-card-page .secondary:hover {
  border-color: rgba(0, 184, 255, 0.5);
}

body.aff-card-page .save {
  min-height: 41px;
  border-radius: 12px;
  background: var(--figma-accent);
  color: #ffffff;
  font-size: 14px;
  font-weight: 800;
  margin-top: 2px;
}

body.aff-card-page .save:hover {
  background: var(--figma-accent-hover);
}

body.aff-card-page .empty {
  color: var(--figma-muted);
  font-size: 13px;
  margin: 0 4px;
}

@media (max-width: 420px) {
  body.aff-card-page .shell {
    padding-inline: 19px;
  }

  body.aff-card-page .grid {
    grid-template-columns: minmax(0, 1fr) 94px;
  }
}
