:root {
  color-scheme: light;
  --bg: #eef3f7;
  --panel: #ffffff;
  --ink: #1d2733;
  --muted: #697789;
  --line: #d6dee8;
  --nav: #0d252b;
  --nav-soft: #153a42;
  --nav-muted: #a7bac2;
  --teal: #19a7a6;
  --blue: #2563eb;
  --green: #0f8f70;
  --amber: #b26a00;
  --red: #c93636;
  --shadow: 0 16px 40px rgba(31, 49, 68, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.hidden {
  display: none !important;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(135deg, #e9f1f4 0%, #f8fbfd 100%);
}

.login-panel {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 28px;
}

.login-brand,
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.login-brand {
  margin-bottom: 26px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: var(--teal);
  color: #fff;
  font-weight: 700;
}

.login-brand strong,
.brand strong {
  display: block;
  font-size: 18px;
}

.login-brand small,
.brand small {
  display: block;
  color: var(--muted);
  margin-top: 4px;
}

.login-panel h1 {
  margin: 0 0 22px;
  font-size: 26px;
}

.login-panel label {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
  color: var(--muted);
  font-size: 14px;
}

.login-panel input {
  width: 100%;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  color: var(--ink);
  outline: 0;
}

.login-panel input:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(25, 167, 166, 0.12);
}

.login-error {
  margin: 0 0 14px;
  color: var(--red);
  font-size: 14px;
}

.app-shell {
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 240px;
  background: var(--nav);
  color: #eff8fa;
  padding: 12px 12px 18px;
}

.brand {
  height: 54px;
  padding: 0 2px 16px;
  margin-bottom: 16px;
}

.brand small {
  color: var(--nav-muted);
}

nav {
  display: grid;
  gap: 6px;
}

.nav-item,
.nav-group-button {
  width: 100%;
  min-height: 44px;
  border: 0;
  border-radius: 7px;
  padding: 0 14px;
  background: transparent;
  color: var(--nav-muted);
  text-align: left;
  cursor: pointer;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav-group-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-group-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav-caret {
  color: #8aa0a8;
}

.nav-item:hover,
.nav-group-button:hover,
.nav-item.active {
  background: var(--nav-soft);
  color: #fff;
}

.nav-children {
  display: grid;
  gap: 4px;
  margin: 4px 0 8px;
}

.nav-children .nav-item {
  padding-left: 48px;
  min-height: 38px;
  font-size: 14px;
}

.nav-icon {
  width: 18px;
  color: inherit;
  text-align: center;
}

.main {
  margin-left: 240px;
  min-height: 100vh;
  padding: 14px 22px 28px;
}

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

h1 {
  margin: 0;
  font-size: 24px;
}

p {
  margin: 5px 0 0;
  color: var(--muted);
}

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

.primary-button,
.ghost-button,
.danger-button,
.table-button,
.soft-button {
  border: 1px solid var(--line);
  border-radius: 6px;
  min-height: 36px;
  padding: 0 12px;
  cursor: pointer;
}

.primary-button {
  border-color: var(--teal);
  background: var(--teal);
  color: #fff;
}

.login-panel .primary-button {
  width: 100%;
}

.ghost-button,
.table-button {
  background: #fff;
  color: var(--ink);
}

.danger-button {
  border-color: #f2c4c4;
  background: #fff;
  color: var(--red);
}

.user-menu {
  position: relative;
}

.user-menu-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  border: 1px solid #b9d8ff;
  border-radius: 4px;
  background: #edf6ff;
  color: #62758a;
  padding: 0 14px;
  cursor: pointer;
}

.user-menu-caret {
  color: #7890a6;
  font-size: 13px;
}

.user-menu-panel {
  position: absolute;
  top: 46px;
  right: 0;
  width: 90px;
  background: #fff;
  border-radius: 3px;
  box-shadow: 0 10px 28px rgba(30, 48, 64, 0.18);
  padding: 8px 0;
  z-index: 15;
}

.user-menu-panel::before {
  content: "";
  position: absolute;
  top: -8px;
  right: 38px;
  width: 0;
  height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-bottom: 8px solid #fff;
}

.user-menu-panel button {
  width: 100%;
  min-height: 36px;
  border: 0;
  background: transparent;
  color: #5e6c7b;
  cursor: pointer;
  text-align: center;
}

.user-menu-panel button:hover {
  background: #f3f7fa;
  color: var(--ink);
}

.soft-button {
  background: #eefafa;
  color: #397072;
  border-color: #bfe4e4;
}

.alert {
  position: fixed;
  top: 18px;
  left: calc(240px + (100vw - 240px) / 2);
  z-index: 1000;
  width: max-content;
  max-width: min(640px, calc(100vw - 280px));
  transform: translateX(-50%);
  border: 1px solid #f0c36d;
  background: #fff8e7;
  color: #694900;
  border-radius: 6px;
  box-shadow: 0 12px 28px rgba(45, 59, 77, 0.16);
  padding: 11px 18px;
  text-align: center;
  pointer-events: none;
  animation: toastIn 0.16s ease-out;
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translate(-50%, -8px);
  }

  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.metric {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.metric span {
  color: var(--muted);
  font-size: 13px;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 28px;
}

.ops-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}

.right-toolbar {
  justify-content: flex-end;
}

.list-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 10px;
  margin-bottom: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

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

.list-toolbar input,
.list-toolbar select {
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 0 10px;
  outline: 0;
}

.list-toolbar input:focus,
.list-toolbar select:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(25, 167, 166, 0.12);
}

.search-field {
  min-width: 240px;
}

.filter-actions {
  display: flex;
  gap: 8px;
}

.list-total {
  margin-left: auto;
  min-height: 36px;
  display: flex;
  align-items: center;
  color: var(--muted);
  font-size: 13px;
}

.pagination {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
}

.pagination-summary {
  color: var(--muted);
  font-size: 13px;
}

.ops-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.ops-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 4px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.ops-card.ok {
  border-left-color: var(--green);
}

.ops-card.warn {
  border-left-color: var(--amber);
}

.ops-card.bad {
  border-left-color: var(--red);
}

.ops-card span,
.kv-grid span,
.wallet-grid span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 6px;
}

.ops-card strong {
  display: block;
  font-size: 20px;
}

.template-metrics {
  margin-bottom: 14px;
}

.template-preview-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1fr;
  gap: 14px;
  padding: 16px;
}

.telegram-preview {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbfd;
  padding: 12px;
}

.telegram-preview-header {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 8px;
}

.telegram-message {
  margin: 0;
  word-break: break-word;
  line-height: 1.45;
  color: var(--ink);
}

.keyboard-preview {
  display: grid;
  gap: 6px;
}

.keyboard-row {
  display: grid;
  gap: 6px;
}

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

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

.keyboard-row.cols-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.keyboard-button {
  display: grid;
  place-items: center;
  min-height: 34px;
  border-radius: 6px;
  background: #dfe7ef;
  color: #162633;
  font-size: 13px;
  padding: 6px 8px;
  text-align: center;
}

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

.button-config-row {
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 12px;
  align-items: end;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px;
  background: #fbfcfe;
}

.keyboard-config-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 18px;
  padding: 16px;
  align-items: start;
}

.keyboard-config-main,
.keyboard-config-side {
  min-width: 0;
}

.keyboard-config-controls {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 180px 160px;
  gap: 14px;
  align-items: end;
  margin-bottom: 16px;
}

.keyboard-field {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}

.keyboard-field input {
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  outline: 0;
  background: #fff;
}

.keyboard-field input:focus,
.keyboard-table-input:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(25, 167, 166, 0.12);
}

.segmented-control {
  display: inline-flex;
  width: fit-content;
  border: 1px solid var(--line);
  border-radius: 7px;
  overflow: hidden;
  background: #f3f7fa;
}

.segmented-control button {
  min-height: 32px;
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  padding: 0 12px;
  cursor: pointer;
}

.segmented-control button:last-child {
  border-right: 0;
}

.segmented-control button.active {
  background: var(--teal);
  color: #fff;
}

.toggle-field {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  color: var(--ink);
  cursor: pointer;
}

.toggle-field input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.toggle-field b {
  font-size: 13px;
  color: var(--blue);
}

.toggle-field.compact {
  min-height: 24px;
}

.keyboard-list-heading {
  margin: 4px 0 10px;
  font-weight: 700;
}

.keyboard-list-heading.with-action {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.compact-button {
  min-height: 32px;
  padding: 0 10px;
}

button.danger-link {
  color: #dc2626;
}

.keyboard-table-wrap {
  border: 1px solid var(--line);
  border-radius: 8px;
}

.keyboard-config-table th:first-child,
.keyboard-config-table td:first-child {
  width: 42px;
  text-align: center;
}

.keyboard-config-table th:nth-child(5),
.keyboard-config-table td:nth-child(5) {
  width: 72px;
}

.keyboard-config-table th:nth-child(6),
.keyboard-config-table td:nth-child(6) {
  width: 88px;
}

.keyboard-table-input {
  width: 100%;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  outline: 0;
  background: #fff;
}

.keyboard-row-actions {
  display: grid;
  gap: 6px;
}

button.inline-link {
  border: 0;
  background: transparent;
  padding: 0;
  text-align: left;
  cursor: pointer;
}

.keyboard-phone {
  padding: 14px;
}

.keyboard-message {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
  border-radius: 7px;
  background: #fff;
  padding: 12px;
}

.keyboard-message strong {
  font-size: 16px;
}

.wide-button {
  width: 100%;
  margin-top: 12px;
}

.form-label {
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 7px;
}

.kv-grid,
.wallet-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  padding: 16px;
}

.kv-grid > div,
.wallet-grid > div {
  min-height: 72px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 12px;
  background: #fbfcfe;
}

.kv-grid strong,
.wallet-grid strong {
  display: block;
  word-break: break-all;
}

.kv-grid > .kv-action-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.kv-action-card > div {
  min-width: 0;
}

.kv-action-card .soft-button {
  flex: 0 0 auto;
}

.copy-value {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.copy-value strong {
  min-width: 0;
}

.copy-icon-button {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--muted);
  cursor: pointer;
  padding: 0;
}

.copy-icon-button:hover {
  color: var(--teal);
  border-color: #bfe4e4;
  background: #eefafa;
}

.copy-icon-button svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.bot-list-table-scroll {
  overflow-x: auto;
}

.bot-list-table {
  min-width: 1500px;
  table-layout: fixed;
}

.bot-list-table th,
.bot-list-table td {
  white-space: nowrap;
}

.bot-list-table th:nth-child(1),
.bot-list-table td:nth-child(1) {
  width: 48px;
}

.bot-list-table th:nth-child(2),
.bot-list-table td:nth-child(2) {
  width: 92px;
}

.bot-list-table th:nth-child(3),
.bot-list-table td:nth-child(3),
.bot-list-table th:nth-child(4),
.bot-list-table td:nth-child(4) {
  width: 145px;
}

.bot-list-table th:nth-child(5),
.bot-list-table td:nth-child(5) {
  width: 78px;
}

.bot-list-table th:nth-child(6),
.bot-list-table td:nth-child(6),
.bot-list-table th:nth-child(7),
.bot-list-table td:nth-child(7) {
  width: 92px;
}

.bot-list-table th:nth-child(8),
.bot-list-table td:nth-child(8),
.bot-list-table th:nth-child(9),
.bot-list-table td:nth-child(9),
.bot-list-table th:nth-child(10),
.bot-list-table td:nth-child(10),
.bot-list-table th:nth-child(11),
.bot-list-table td:nth-child(11) {
  width: 92px;
}

.bot-list-table th:nth-child(12),
.bot-list-table td:nth-child(12),
.bot-list-table th:nth-child(13),
.bot-list-table td:nth-child(13) {
  width: 155px;
}

.bot-list-table th:nth-child(14),
.bot-list-table td:nth-child(14) {
  width: 76px;
}

.bot-list-table th:nth-child(15),
.bot-list-table td:nth-child(15) {
  width: 74px;
}

.bot-energy-address-cell {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.bot-energy-address-row {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.bot-energy-address-row strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bot-energy-address-row .copy-icon-button {
  width: 26px;
  height: 26px;
}

.section {
  margin-top: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.section-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.section-header h2 {
  margin: 0;
  font-size: 16px;
}

.skeleton-line {
  display: block;
  width: var(--w, 100%);
  max-width: 100%;
  height: 13px;
  border-radius: 999px;
  background: linear-gradient(90deg, #eef3f7 0%, #f7fafc 45%, #eef3f7 100%);
  background-size: 220% 100%;
  animation: skeleton-pulse 1.2s ease-in-out infinite;
}

.loading-card {
  display: grid;
  align-content: start;
  gap: 12px;
}

.metric.loading-card .skeleton-line:last-child {
  height: 24px;
}

.loading-table .skeleton-line {
  height: 12px;
}

@keyframes skeleton-pulse {
  0% {
    background-position: 100% 0;
  }

  100% {
    background-position: -100% 0;
  }
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.table-scroll {
  overflow-x: auto;
}

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

th {
  color: var(--muted);
  font-weight: 600;
  background: #fbfcfe;
}

tr:last-child td {
  border-bottom: 0;
}

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

.muted-line {
  color: var(--muted);
  font-size: 12px;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

.inline-link {
  color: var(--blue);
  text-decoration: none;
}

.inline-link:hover {
  text-decoration: underline;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 300px;
}

.action-row .table-button,
.action-row .danger-button {
  min-height: 30px;
  padding: 0 9px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  border-radius: 999px;
  padding: 0 8px;
  font-size: 12px;
  background: #eef2f6;
}

.badge.active,
.badge.completed,
.badge.paid,
.badge.succeeded {
  background: #e7f6f1;
  color: var(--green);
}

.badge.queued,
.badge.retry,
.badge.pending {
  background: #fff4db;
  color: var(--amber);
}

.badge.failed,
.badge.disabled,
.badge.invalid {
  background: #ffe9e9;
  color: var(--red);
}

.empty {
  padding: 30px;
  text-align: center;
  color: var(--muted);
}

.empty.compact {
  padding: 16px;
}

.security-wrap {
  max-width: 520px;
  margin: 30px auto 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 18px;
}

.security-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 62px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 12px 14px;
  margin-bottom: 12px;
}

.security-row:last-child {
  margin-bottom: 0;
}

.security-row strong {
  display: block;
  margin-bottom: 4px;
}

.security-row-actions {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.switch-button {
  width: 40px;
  height: 20px;
  border: 0;
  border-radius: 999px;
  background: #d9dee6;
  position: relative;
  cursor: pointer;
  padding: 0;
  transition: background-color 0.16s ease;
}

.switch-button::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.18);
  transition: transform 0.16s ease;
}

.switch-button.on {
  background: #8dbbff;
}

.switch-button.on::after {
  transform: translateX(20px);
}

.switch-button:focus-visible {
  outline: 3px solid rgba(141, 187, 255, 0.35);
  outline-offset: 2px;
}

.toggle {
  width: 42px;
  height: 22px;
  border-radius: 999px;
  background: #d9dee6;
  position: relative;
}

.toggle::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
}

.toggle.on {
  background: #8dbbff;
}

.toggle.on::after {
  left: 23px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(9, 28, 34, 0.42);
  z-index: 20;
}

.modal {
  width: min(560px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
  background: #fff;
  border-radius: 8px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.modal-header,
.modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}

.modal-footer {
  border-top: 1px solid var(--line);
  border-bottom: 0;
  justify-content: flex-end;
}

.modal-header h2 {
  margin: 0;
  font-size: 18px;
}

.modal-body {
  padding: 18px;
}

.modal-message {
  margin: 0;
  color: var(--ink);
  line-height: 1.6;
}

.json-preview {
  margin: 16px 0 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
  color: var(--ink);
  font: 12px/1.5 ui-monospace, SFMono-Regular, Consolas, monospace;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 360px;
  overflow: auto;
}

.modal-error {
  margin: 0;
  color: var(--red);
  font-size: 13px;
}

.modal-close {
  border: 0;
  background: transparent;
  font-size: 22px;
  cursor: pointer;
  color: var(--muted);
}

.form-grid {
  display: grid;
  gap: 14px;
}

.form-grid label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 14px;
}

.form-grid input,
.form-grid textarea,
.form-grid select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  outline: 0;
  background: #fff;
}

.form-grid textarea {
  min-height: 120px;
  resize: vertical;
}

.telegram-format-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 4px 0 8px;
}

.format-button {
  border: 1px solid #cfe0f0;
  border-radius: 6px;
  background: #f8fbfd;
  color: #496176;
  padding: 5px 9px;
  cursor: pointer;
  font-size: 13px;
  line-height: 1.2;
}

.format-button:hover {
  border-color: var(--teal);
  color: #0f8f70;
  background: #eefdfb;
}

.form-grid input:focus,
.form-grid textarea:focus,
.form-grid select:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(25, 167, 166, 0.12);
}

.danger-text {
  color: var(--red);
}

.table-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.announcement-modal {
  width: min(1100px, calc(100vw - 36px));
  max-height: calc(100vh - 28px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.announcement-modal .modal-body {
  padding: 0;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

.announcement-modal .modal-footer {
  flex: 0 0 auto;
  background: #fff;
  z-index: 1;
}

.announcement-editor {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(390px, 0.95fr);
  height: min(620px, calc(100vh - 150px));
  min-height: 0;
}

.announcement-form {
  padding: 18px 20px 28px;
  overflow: auto;
  border-right: 1px solid var(--line);
  min-height: 0;
}

.announcement-preview-panel {
  padding: 18px 14px;
  overflow: auto;
  background: #fff;
  min-height: 0;
}

.announcement-top-grid {
  grid-template-columns: 1fr 1fr;
  margin-bottom: 14px;
}

.announcement-field {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 13px;
}

.announcement-field.required > span::before {
  content: "* ";
  color: var(--red);
}

.announcement-field input,
.announcement-field textarea,
.announcement-top-grid select,
.announcement-image-input input,
.announcement-inline-row input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  outline: 0;
  background: #fff;
}

.announcement-field textarea {
  min-height: 158px;
  resize: vertical;
}

.announcement-field input:focus,
.announcement-field textarea:focus,
.announcement-top-grid select:focus,
.announcement-image-input input:focus,
.announcement-inline-row input:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(25, 167, 166, 0.12);
}

.announcement-emoji-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbfd;
  color: var(--muted);
}

.announcement-emoji-row > div {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.emoji-button {
  width: 34px;
  height: 34px;
  border: 1px solid #cfe0f0;
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  font-size: 18px;
}

.announcement-image-row {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 12px 14px;
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 13px;
}

.announcement-image-row > strong {
  grid-column: 1 / -1;
}

.announcement-image-box {
  width: 110px;
  height: 110px;
  display: grid;
  place-items: center;
  border: 1px dashed #bdd0e5;
  border-radius: 8px;
  background: #f8fbfd;
  color: #778899;
  font-size: 34px;
  cursor: pointer;
}

.announcement-image-input {
  display: grid;
  align-content: start;
  gap: 8px;
}

.announcement-image-input p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.announcement-inline-box {
  margin-bottom: 14px;
}

.announcement-inline-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  color: var(--muted);
}

.link-button {
  border: 0;
  background: transparent;
  color: #1677ff;
  cursor: pointer;
  font-weight: 700;
}

.announcement-inline-row {
  display: grid;
  grid-template-columns: 1fr 1.35fr auto;
  gap: 8px;
  margin-top: 8px;
}

.announcement-radio-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  margin: 14px 0;
  color: var(--muted);
  font-size: 13px;
}

.announcement-radio-row label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--ink);
}

.announcement-radio-row input {
  width: 14px;
  height: 14px;
}

.announcement-preview-title {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
  color: #1677ff;
  font-weight: 700;
}

.announcement-phone {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #101b28;
  box-shadow: 0 14px 34px rgba(15, 23, 42, 0.12);
}

.announcement-phone-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: #172534;
  color: #fff;
}

.announcement-phone-head span:not(.announcement-avatar) {
  display: block;
  margin-top: 2px;
  color: #9fb0c3;
  font-size: 12px;
}

.announcement-avatar {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #3b8bdc;
  font-size: 20px;
}

.announcement-phone-body {
  min-height: 350px;
  padding: 22px 26px;
  color: #dce7f5;
  background-color: #101b28;
  background-image: radial-gradient(rgba(105, 145, 190, 0.16) 1px, transparent 1px);
  background-size: 18px 18px;
}

.announcement-preview-message {
  line-height: 1.6;
  word-break: break-word;
}

.announcement-preview-message strong {
  color: #fff;
}

.announcement-preview-text {
  margin-top: 10px;
}

.announcement-preview-text pre,
.announcement-preview-text code {
  color: #fff;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
}

.muted-preview {
  color: #9fb0c3;
  font-style: italic;
}

.announcement-preview-image img {
  display: block;
  max-width: 100%;
  max-height: 180px;
  object-fit: cover;
  margin-bottom: 12px;
  border-radius: 8px;
}

.announcement-preview-buttons {
  display: grid;
  gap: 7px;
  margin-top: 14px;
}

.announcement-preview-buttons button {
  min-height: 34px;
  border: 0;
  border-radius: 6px;
  background: #2d8cff;
  color: #fff;
  font-weight: 700;
}

.checkbox-row {
  display: flex !important;
  grid-template-columns: none !important;
  align-items: center;
  gap: 9px !important;
  color: var(--ink) !important;
}

.checkbox-row input {
  width: 16px;
  height: 16px;
}

.totp-setup {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 16px;
  align-items: start;
}

.totp-setup img {
  width: 180px;
  height: 180px;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.secret-box {
  word-break: break-all;
  padding: 10px;
  border-radius: 6px;
  background: #f4f8fb;
  border: 1px solid var(--line);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  color: #1f3a4a;
}

@media (max-width: 900px) {
  .sidebar {
    position: static;
    width: auto;
  }

  .main {
    margin-left: 0;
    padding: 16px;
  }

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

  .ops-grid,
  .kv-grid,
  .wallet-grid,
  .template-preview-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .list-toolbar {
    align-items: stretch;
  }

  .list-toolbar label,
  .search-field,
  .filter-actions,
  .list-total {
    width: 100%;
    min-width: 0;
  }

  .filter-actions {
    justify-content: flex-start;
  }

  .list-total {
    margin-left: 0;
  }

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

  .alert {
    left: 50%;
    max-width: calc(100vw - 32px);
    top: 12px;
  }

  .totp-setup {
    grid-template-columns: 1fr;
  }

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

  .keyboard-config-layout,
  .keyboard-config-controls {
    grid-template-columns: 1fr;
  }

  .keyboard-config-side {
    order: -1;
  }

  .segmented-control {
    width: 100%;
  }

  .segmented-control button {
    flex: 1;
  }
}

.badge.credit,
.badge.recharge,
.badge.refund,
.badge.approved,
.badge.confirmed {
  background: #e7f6f1;
  color: var(--green);
}

.badge.debit,
.badge.withdrawal,
.badge.purchase {
  background: #eef2ff;
  color: #315fca;
}

.badge.commission,
.badge.pending,
.badge.queued,
.badge.retry {
  background: #fff4db;
  color: var(--amber);
}

.badge.rejected,
.badge.cancelled,
.badge.expired,
.badge.failed,
.badge.disabled,
.badge.invalid {
  background: #ffe9e9;
  color: var(--red);
}

.badge.adjustment,
.badge.freeze,
.badge.unfreeze {
  background: #f0ecff;
  color: #6c45c7;
}

.emoji-library-tabs {
  margin-bottom: 2px;
}

.emoji-filter-bar,
.emoji-manual-form,
.emoji-dynamic-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 10px;
  padding: 14px 16px;
}

.emoji-dynamic-toolbar {
  justify-content: space-between;
  padding-bottom: 0;
}

.emoji-dynamic-toolbar .emoji-filter-bar {
  padding: 0;
}

.emoji-filter-bar label,
.emoji-manual-form label {
  display: grid;
  gap: 6px;
  min-width: 210px;
  color: var(--muted);
  font-size: 12px;
}

.emoji-filter-bar input,
.emoji-filter-bar select,
.emoji-manual-form input {
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 0 10px;
  outline: 0;
}

.emoji-filter-bar input:focus,
.emoji-filter-bar select:focus,
.emoji-manual-form input:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(25, 167, 166, 0.12);
}

.emoji-library-note {
  margin: 0 16px 14px;
  padding: 10px 12px;
  border-left: 3px solid #3b82f6;
  background: #f4f8fd;
  color: #516579;
  font-size: 13px;
  line-height: 1.6;
}

.emoji-grid {
  display: grid;
  gap: 10px;
  padding: 0 16px 16px;
}

.emoji-static-grid {
  grid-template-columns: repeat(auto-fill, minmax(126px, 1fr));
}

.emoji-dynamic-grid {
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
}

.emoji-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

.emoji-static-card {
  display: grid;
  grid-template-rows: 54px auto auto;
  align-items: center;
  gap: 4px;
  min-height: 116px;
  padding: 10px;
  cursor: pointer;
  text-align: center;
}

.emoji-static-card:hover {
  border-color: var(--teal);
  background: #f5fbfb;
}

.emoji-static-symbol {
  font-size: 38px;
  line-height: 1;
}

.emoji-static-card strong,
.emoji-static-card small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.emoji-static-card strong {
  font-size: 12px;
}

.emoji-static-card small,
.emoji-dynamic-card small {
  color: var(--muted);
  font-size: 11px;
}

.emoji-dynamic-card {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  min-height: 142px;
  overflow: hidden;
}

.emoji-preview {
  display: grid;
  place-items: center;
  width: 72px;
  min-height: 94px;
  background: #f3f7fa;
  overflow: hidden;
}

.emoji-preview > span {
  font-size: 38px;
}

.emoji-preview svg,
.emoji-preview img,
.emoji-preview video {
  display: block;
  width: 60px !important;
  height: 60px !important;
  object-fit: contain;
}

.emoji-preview.preview-failed::after {
  content: "预览失败";
  color: var(--muted);
  font-size: 11px;
}

.emoji-card-body {
  display: grid;
  align-content: center;
  gap: 7px;
  min-width: 0;
  padding: 12px;
}

.emoji-card-body strong,
.emoji-card-body code,
.emoji-card-body small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.emoji-card-body code {
  color: #516579;
  font-size: 11px;
}

.emoji-card-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.emoji-card-actions {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 1fr 34px 34px;
  gap: 6px;
  padding: 8px;
  border-top: 1px solid var(--line);
}

.icon-button {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: #516579;
  cursor: pointer;
}

.icon-button.danger {
  border-color: #f2c4c4;
  color: var(--red);
}

.emoji-pagination {
  padding: 0 16px 16px;
}

.emoji-total {
  padding: 0 16px 16px;
  color: var(--muted);
  font-size: 13px;
  text-align: right;
}

@media (max-width: 900px) {
  .emoji-filter-bar,
  .emoji-manual-form,
  .emoji-dynamic-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .emoji-filter-bar label,
  .emoji-manual-form label {
    min-width: 0;
    width: 100%;
  }

  .emoji-static-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .emoji-static-card strong,
  .emoji-static-card small {
    display: none;
  }

  .emoji-static-card {
    grid-template-rows: 54px;
    min-height: 72px;
  }
}
