:root {
  --bg: #eef4ff;
  --bg-soft: #dde8ff;
  --surface: #ffffff;
  --surface-soft: #f6f9ff;
  --border: #d9e4ff;
  --text: #142543;
  --text-dim: #66789f;
  --primary: #2a67f2;
  --primary-2: #00a9d8;
  --danger: #d74a69;
  --ok: #1f9f69;
  --shadow: 0 20px 40px rgba(27, 47, 86, 0.14);
}

:root[data-theme="dark"] {
  --bg: #0b1428;
  --bg-soft: #152743;
  --surface: #101d34;
  --surface-soft: #152845;
  --border: #2a416c;
  --text: #eaf2ff;
  --text-dim: #9fb4dd;
  --primary: #4f8eff;
  --primary-2: #30cdfd;
  --danger: #ff6b88;
  --ok: #46d498;
  --shadow: 0 22px 42px rgba(0, 0, 0, 0.36);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 10% 12%, var(--bg-soft) 0, transparent 38%),
    radial-gradient(circle at 86% 84%, #c8deff4d 0, transparent 35%),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
}

.card {
  width: min(560px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 24px;
  box-shadow: var(--shadow);
}

.card-wide {
  width: min(1100px, 100%);
}

.security-card {
  width: min(980px, 100%);
}

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

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 10px;
}

h1,
h2,
h3 {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
}

h2,
h3 {
  margin-bottom: 10px;
}

.brand-tag {
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--text-dim);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 4px 10px;
  text-transform: uppercase;
}

p {
  margin: 0 0 16px;
  color: var(--text-dim);
}

label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.92rem;
  color: var(--text);
}

input,
select {
  width: 100%;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  padding: 11px 12px;
  margin-bottom: 12px;
}

input:focus,
select:focus {
  outline: none;
  border-color: #82a9ff;
  box-shadow: 0 0 0 3px #3f76f029;
}

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

button,
.btn {
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 10px 14px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: 0.18s ease;
  white-space: nowrap;
}

button:hover,
.btn:hover {
  transform: translateY(-1px);
}

button:disabled,
.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  filter: saturate(0.6);
}

button,
.btn-primary {
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
}

.btn.secondary,
button.secondary,
.theme-toggle {
  color: var(--text);
  border-color: var(--border);
  background: var(--surface-soft);
}

.btn-danger {
  color: var(--danger);
  border-color: #efbcc8;
  background: #fff2f5;
}

.btn-success {
  color: var(--ok);
  border-color: #bde8d2;
  background: #ecfbf4;
}

:root[data-theme="dark"] .btn-danger {
  border-color: #6f2940;
  background: #371a26;
}

:root[data-theme="dark"] .btn-success {
  border-color: #28654d;
  background: #133326;
}

.inline {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 6px 0 12px;
}

.inline input {
  width: auto;
  margin: 0;
}

.telegram-login-wrap {
  display: flex;
  justify-content: center;
  margin: 10px 0 4px;
}

.flash {
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 10px;
  font-size: 0.92rem;
}

.flash.error {
  background: #fff0f4;
  border: 1px solid #f3c2cf;
  color: #a83855;
}

.flash.ok {
  background: #ecfaf2;
  border: 1px solid #bfe8d1;
  color: #1b8154;
}

:root[data-theme="dark"] .flash.error {
  background: #381a25;
  border-color: #6f2940;
  color: #ffabc0;
}

:root[data-theme="dark"] .flash.ok {
  background: #143425;
  border-color: #29674d;
  color: #98f0c3;
}

.muted {
  color: var(--text-dim);
}

.block {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.block-soft {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  background: var(--surface-soft);
}

.table-wrap {
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

.table th,
.table td {
  text-align: left;
  padding: 10px 10px;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
  vertical-align: middle;
}

.table th {
  color: var(--text-dim);
  font-weight: 600;
  background: var(--surface-soft);
}

.table td form {
  margin: 0;
}

.review-edit-row {
  display: grid;
  grid-template-columns: minmax(170px, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.review-edit-row select {
  margin: 0;
  min-width: 170px;
}

.status-edit-row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  gap: 10px;
  align-items: end;
}

.status-edit-field select {
  margin: 0;
}

.status-edit-btn {
  display: flex;
  align-items: end;
}

.status-edit-btn .btn-primary {
  min-width: 130px;
}

.mini-btn {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--text);
  padding: 6px 9px;
  font-size: 0.82rem;
  font-weight: 600;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-right: 4px;
}

.icon-link-btn {
  width: 34px;
  height: 34px;
  padding: 4px;
}

.service-icon {
  width: 18px;
  height: 18px;
  object-fit: contain;
  display: block;
}

.pill {
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.74rem;
  display: inline-flex;
  align-items: center;
  line-height: 1.2;
}

.pill.ok {
  background: #e6f8ef;
  color: var(--ok);
}

.pill.muted {
  background: #eaf0fb;
  color: var(--text-dim);
}

.pill.danger {
  background: #ffe9ef;
  color: var(--danger);
}

.pill.warn {
  background: #fff3dd;
  color: #af6f00;
}

.pill.info {
  background: #e8f0ff;
  color: #2f5fca;
}

.date-pill {
  background: #e5f1ff;
  color: #1f5cb8;
}

:root[data-theme="dark"] .pill.ok {
  background: #153428;
}

:root[data-theme="dark"] .pill.muted {
  background: #223859;
}

:root[data-theme="dark"] .pill.danger {
  background: #3c1e2a;
}

:root[data-theme="dark"] .pill.warn {
  background: #3a2d11;
}

:root[data-theme="dark"] .pill.info {
  background: #1a2f54;
  color: #9fc2ff;
}

:root[data-theme="dark"] .date-pill {
  background: #183152;
  color: #97c1ff;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.8rem;
  white-space: nowrap;
}

.state-ok {
  color: var(--ok);
}

.state-off {
  color: var(--danger);
}

.code {
  padding: 9px 11px;
  border-radius: 10px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.85rem;
  word-break: break-all;
}

.qr-wrap {
  display: flex;
  justify-content: center;
  margin: 10px 0;
}

.qr-code {
  width: 200px;
  height: 200px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #fff;
  padding: 8px;
}

.topnav {
  display: flex;
  gap: 10px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.tg-account-card {
  width: min(1240px, 100%);
}

.tg-layout {
  margin-top: 10px;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 14px;
}

.tg-side {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

@media (min-width: 901px) {
  .tg-side {
    position: sticky;
    top: 16px;
    align-self: start;
  }
}

.tg-back-btn {
  width: 100%;
}

.tg-side-card {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-soft);
  padding: 14px;
}

.tg-avatar {
  width: 72px;
  height: 72px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: linear-gradient(135deg, #2f74f33a, #00a9d624);
  display: grid;
  place-items: center;
  font-family: "Space Grotesk", sans-serif;
  font-size: 1.05rem;
  font-weight: 700;
  margin: 0 auto 10px;
}

.tg-side-title {
  text-align: center;
  font-family: "Space Grotesk", sans-serif;
  font-size: 1.02rem;
  font-weight: 700;
}

.tg-side-sub {
  text-align: center;
  color: var(--text-dim);
  font-size: 0.78rem;
  margin-top: 2px;
  margin-bottom: 10px;
}

.tg-meta-list {
  display: flex;
  flex-direction: column;
}

.tg-meta-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid var(--border);
  padding: 7px 2px;
  font-size: 0.82rem;
}

.tg-meta-item:last-child {
  border-bottom: none;
}

.tg-side .tg-control-block h3 {
  margin-bottom: 8px;
}

.tg-side .status-edit-row {
  grid-template-columns: 1fr;
  gap: 8px;
}

.tg-side .status-edit-field select {
  margin: 0;
}

.tg-side .status-edit-btn .btn-primary {
  width: 100%;
  min-width: 0;
}

.tg-ban-pill {
  white-space: normal;
  overflow-wrap: anywhere;
}

.tg-main {
  min-width: 0;
}

.tg-control-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.tg-control-links {
  display: flex;
  gap: 8px;
}

.tg-main .block {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

.tg-main .block + .block {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.tg-reviews-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.tg-main .table {
  min-width: 720px;
  table-layout: fixed;
}

.tg-main .table th,
.tg-main .table td {
  font-size: 0.78rem;
  padding: 7px 6px;
}

.tg-main .table th:nth-child(1),
.tg-main .table td:nth-child(1) {
  width: 14%;
}

.tg-main .table th:nth-child(2),
.tg-main .table td:nth-child(2) {
  width: 31%;
}

.tg-main .table th:nth-child(3),
.tg-main .table td:nth-child(3) {
  width: 11%;
}

.tg-main .table th:nth-child(4),
.tg-main .table td:nth-child(4) {
  width: 10%;
}

.tg-main .table th:nth-child(5),
.tg-main .table td:nth-child(5) {
  width: 24%;
}

.tg-main .table th:nth-child(6),
.tg-main .table td:nth-child(6) {
  width: 10%;
  white-space: nowrap;
}

.tg-main .table td:nth-child(1),
.tg-main .table td:nth-child(2) {
  overflow-wrap: anywhere;
}

.tg-main .inline-status-form {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.tg-main .status-pill-btn {
  cursor: pointer;
  border: 1px solid transparent;
}

.tg-main .status-editor {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.tg-main .status-editor[hidden] {
  display: none !important;
}

.tg-main .status-editor select {
  min-width: 130px;
  width: auto;
  max-width: 170px;
  font-size: 0.74rem;
  padding: 5px 7px;
  margin: 0;
  border-radius: 8px;
}

.tg-main .status-editor-actions {
  display: inline-flex;
  align-items: center;
  gap: 0;
}

.tg-main .status-apply-btn {
  height: 28px;
  border-radius: 8px;
  padding: 0 12px;
  font-size: 0.72rem;
  line-height: 1.1;
  border: 1px solid transparent;
  cursor: pointer;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff;
  min-width: 96px;
}

.tg-main .status-apply-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.tg-main .table th.col-links {
  text-align: center;
}

.tg-main .table td.links-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  white-space: nowrap;
}

.tg-main .table td.links-cell .mini-btn {
  margin: 0;
  width: 30px;
  height: 30px;
  padding: 3px;
  flex: 0 0 30px;
}

.tg-main .table td.links-cell .service-icon {
  width: 15px;
  height: 15px;
}

.tg-main .payouts-table {
  min-width: 860px;
  table-layout: auto;
}

.tg-main .payouts-table th,
.tg-main .payouts-table td {
  font-size: 0.76rem;
}

.tg-main .payouts-table th:nth-child(1),
.tg-main .payouts-table td:nth-child(1) {
  width: 26%;
}

.tg-main .payouts-table th:nth-child(2),
.tg-main .payouts-table td:nth-child(2) {
  width: 9%;
}

.tg-main .payouts-table th:nth-child(3),
.tg-main .payouts-table td:nth-child(3) {
  width: 11%;
}

.tg-main .payouts-table th:nth-child(4),
.tg-main .payouts-table td:nth-child(4),
.tg-main .payouts-table th:nth-child(5),
.tg-main .payouts-table td:nth-child(5) {
  width: 14%;
}

.tg-main .payouts-table th:nth-child(6),
.tg-main .payouts-table td:nth-child(6) {
  width: 26%;
}

.withdraw-reason-cell {
  white-space: normal;
  overflow-wrap: anywhere;
}

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

  .tg-side {
    display: grid;
    grid-template-columns: 1fr;
  }

  .tg-back-btn {
    width: auto;
  }

  .tg-main .table th,
  .tg-main .table td {
    font-size: 0.76rem;
    padding: 7px 6px;
  }

  .tg-control-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .row {
    grid-template-columns: 1fr;
  }

  .status-edit-row {
    grid-template-columns: 1fr;
  }

  .card {
    padding: 18px;
  }

  .card-head {
    align-items: flex-start;
    flex-direction: column;
  }
}
