:root {
  --tg-bg: #f6f8fb;
  --tg-panel: #ffffff;
  --tg-sidebar: #0b1220;
  --tg-sidebar-soft: #141d2e;
  --tg-border: #e6eaf0;
  --tg-text: #172033;
  --tg-muted: #6b778c;
  --tg-accent: #229ed9;
  --tg-accent-soft: #eaf6fc;
  --tg-success: #22a06b;
  --tg-success-soft: #eaf8f1;
  --tg-danger: #d64545;
  --tg-shadow: 0 10px 35px rgba(15, 23, 42, .06);
}

* {
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
}

body {
  background:
    radial-gradient(circle at 88% 4%, rgba(34, 158, 217, .08), transparent 24%),
    var(--tg-bg);
  color: var(--tg-text);
}

.app {
  background: transparent;
}

.sidebar {
  width: 258px;
  background:
    linear-gradient(180deg, #0b1220 0%, #101827 62%, #0b1220 100%);
  padding: 26px 18px 22px;
  border-right: 1px solid rgba(255,255,255,.05);
  box-shadow: 8px 0 30px rgba(15, 23, 42, .08);
}

.logo {
  font-size: 27px;
  letter-spacing: -.7px;
  margin: 0 8px 24px;
}

.logo span {
  color: #36c275;
}

.tg-bot-sidebar-card {
  margin: 0 0 22px;
  padding: 13px;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 14px;
  background: rgba(255,255,255,.055);
}

.tg-bot-sidebar-label {
  color: #8290a8;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .09em;
  text-transform: uppercase;
  margin-bottom: 10px;
}

.tg-bot-sidebar-main {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.tg-bot-sidebar-avatar {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 12px;
  background: linear-gradient(145deg, #2ca9e1, #1686bb);
  color: white;
  font-size: 16px;
  font-weight: 900;
  box-shadow: 0 7px 16px rgba(34, 158, 217, .22);
}

.tg-bot-sidebar-info {
  min-width: 0;
}

.tg-bot-sidebar-name {
  color: #f8fafc;
  font-size: 13px;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tg-bot-sidebar-user {
  margin-top: 3px;
  color: #8ea0b9;
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.channel-label {
  color: #66758d;
  font-size: 10px;
  letter-spacing: .12em;
  padding: 0 11px;
  margin: 17px 0 8px;
}

.menu-item {
  position: relative;
  padding: 12px 13px;
  margin-bottom: 6px;
  border-radius: 11px;
  color: #aebbd0;
  font-size: 13px;
  font-weight: 650;
  transition:
    background .16s ease,
    color .16s ease,
    transform .16s ease;
}

.menu-item:hover {
  background: rgba(255,255,255,.07);
  color: #fff;
}

.menu-item.active {
  background: linear-gradient(90deg, rgba(34,158,217,.23), rgba(34,158,217,.10));
  color: #fff;
  box-shadow: inset 3px 0 0 #38bdf8;
}

.menu-item.active::after {
  content: "";
  width: 6px;
  height: 6px;
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  border-radius: 999px;
  background: #38bdf8;
}

.main {
  background: transparent;
}

.topbar {
  height: 78px;
  padding: 0 30px;
  background: rgba(255,255,255,.93);
  border-bottom: 1px solid var(--tg-border);
  backdrop-filter: blur(14px);
}

.topbar h2 {
  color: #172033;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -.25px;
}

.status-badge {
  min-height: 32px;
  padding: 7px 12px;
  border: 1px solid #dfe5ec;
  background: #fff;
  color: #526176;
  box-shadow: 0 2px 8px rgba(15,23,42,.04);
}

.status-badge.ok {
  border-color: #ccebdd;
  background: var(--tg-success-soft);
  color: #147a50;
}

.status-badge.error {
  border-color: #f4caca;
  background: #fff1f1;
  color: #b83232;
}

.page {
  padding: 30px;
}

.page:not(.conversations) {
  max-width: 1450px;
  width: 100%;
  margin: 0 auto;
}

.page-header {
  margin-bottom: 22px;
}

.page-header h1 {
  color: #172033;
  font-size: 25px;
  letter-spacing: -.55px;
}

.page-header p {
  color: var(--tg-muted);
  line-height: 1.5;
}

.card {
  border: 1px solid var(--tg-border);
  border-radius: 15px;
  box-shadow: var(--tg-shadow);
}

.btn {
  min-height: 40px;
  padding: 10px 15px;
  border-radius: 10px;
  background: #1899d3;
  box-shadow: 0 5px 13px rgba(24,153,211,.16);
  font-size: 12px;
  letter-spacing: .01em;
  transition:
    transform .15s ease,
    box-shadow .15s ease,
    filter .15s ease;
}

.btn:hover {
  filter: none;
  transform: translateY(-1px);
  box-shadow: 0 7px 16px rgba(24,153,211,.20);
}

.btn.secondary {
  background: #f1f5f9;
  color: #445166;
  box-shadow: none;
  border: 1px solid #e2e8f0;
}

.btn.danger {
  background: #d84b4b;
  box-shadow: 0 5px 13px rgba(216,75,75,.14);
}

.page.conversations.active {
  background: #f8fafc;
}

.conversation-list {
  background: #fff;
  border-right: 1px solid var(--tg-border);
}

.conversation-search {
  padding: 17px;
  background: #fff;
  border-bottom: 1px solid #eef1f5;
}

.conversation-search input {
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid #dfe5ec;
  border-radius: 12px;
  background: #f8fafc;
  outline: none;
}

.conversation-search input:focus {
  border-color: #8ccfed;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(34,158,217,.09);
}

.conversation-row {
  margin: 5px 8px;
  border-radius: 12px;
  border-bottom: none;
  transition: background .14s ease;
}

.conversation-row:hover {
  background: #f6f9fc;
}

.conversation-row.active {
  background: var(--tg-accent-soft);
}

.avatar {
  background: linear-gradient(145deg, #38afe3, #188bc0);
  color: white;
  box-shadow: 0 4px 10px rgba(34,158,217,.18);
}

.conversation-name,
.chat-header-name {
  color: #172033;
  font-weight: 800;
}

.conversation-preview,
.chat-header-user {
  color: #7a879a;
}

.chat {
  background:
    linear-gradient(rgba(248,250,252,.91), rgba(248,250,252,.91)),
    radial-gradient(circle at 1px 1px, #dce3eb 1px, transparent 0);
  background-size: auto, 22px 22px;
}

.chat-header {
  background: rgba(255,255,255,.96);
  border-bottom: 1px solid var(--tg-border);
  box-shadow: 0 4px 16px rgba(15,23,42,.025);
}

.chat-messages {
  padding: 24px;
}

.bubble {
  border: 1px solid #e8edf2;
  border-radius: 14px 14px 14px 5px;
  box-shadow: 0 4px 12px rgba(15,23,42,.045);
  line-height: 1.45;
}

.message-row.out .bubble {
  background: #def4ff;
  border-color: #c7e9f8;
  border-radius: 14px 14px 5px 14px;
}

.bubble-time {
  color: #8b97a8;
}

.chat-compose {
  gap: 10px;
  padding: 15px 18px;
  background: rgba(255,255,255,.97);
  border-top: 1px solid var(--tg-border);
}

.chat-compose textarea {
  min-height: 45px;
  border: 1px solid #dce3eb;
  border-radius: 12px;
  padding: 11px 13px;
  background: #f8fafc;
}

.chat-compose textarea:focus {
  border-color: #8ccfed;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(34,158,217,.09);
}

table {
  border-collapse: separate;
  border-spacing: 0;
}

thead th {
  background: #f8fafc;
  color: #64748b;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .04em;
}

th,
td {
  border-bottom: 1px solid #edf0f4;
}

tbody tr:hover td {
  background: #fbfdff;
}

.pill {
  border-radius: 999px;
}

.form-card {
  border-radius: 15px;
}

.field label {
  color: #4d5a6d;
}

.field input,
.field textarea,
.field select {
  border-radius: 10px;
  border-color: #dce3eb;
  background: #fbfcfe;
}

.field input:focus,
.field textarea:focus,
.field select:focus {
  border-color: #8ccfed;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(34,158,217,.09);
}

.tg-settings-shell {
  display: grid;
  gap: 18px;
}

.tg-settings-hero {
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 24px;
  align-items: center;
  padding: 24px;
  border-radius: 18px;
  background:
    linear-gradient(135deg, #0f1a2c 0%, #12243b 58%, #12334a 100%);
  color: white;
  box-shadow: 0 14px 40px rgba(15,23,42,.13);
}

.tg-settings-hero::after {
  content: "";
  width: 220px;
  height: 220px;
  position: absolute;
  right: -80px;
  top: -95px;
  border-radius: 50%;
  background: rgba(56,189,248,.10);
}

.tg-settings-kicker {
  margin-bottom: 8px;
  color: #7dd3fc;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.tg-settings-bot-name {
  font-size: 25px;
  font-weight: 900;
  letter-spacing: -.5px;
}

.tg-settings-bot-user {
  margin-top: 5px;
  color: #a7c3d4;
  font-size: 13px;
}

.tg-settings-hero-badge {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 12px;
  border-radius: 999px;
  background: rgba(34,197,94,.13);
  border: 1px solid rgba(74,222,128,.25);
  color: #bbf7d0;
  font-size: 11px;
  font-weight: 800;
}

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

.tg-metric-card {
  min-width: 0;
  padding: 17px;
  border: 1px solid var(--tg-border);
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 6px 20px rgba(15,23,42,.04);
}

.tg-metric-label {
  color: #7a8799;
  font-size: 11px;
  font-weight: 700;
}

.tg-metric-value {
  margin-top: 6px;
  color: #172033;
  font-size: 24px;
  font-weight: 900;
  letter-spacing: -.5px;
}

.tg-info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px;
}

.tg-info-card {
  padding: 19px;
  border: 1px solid var(--tg-border);
  border-radius: 15px;
  background: #fff;
  box-shadow: 0 6px 20px rgba(15,23,42,.04);
}

.tg-info-card h3 {
  margin: 0 0 5px;
  color: #172033;
  font-size: 14px;
}

.tg-info-card > p {
  margin: 0 0 15px;
  color: #7a8799;
  font-size: 12px;
  line-height: 1.45;
}

.tg-info-row {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding: 10px 0;
  border-top: 1px solid #edf1f5;
  font-size: 12px;
}

.tg-info-row span:first-child {
  color: #7a8799;
}

.tg-info-row strong {
  color: #2a3547;
  text-align: right;
  overflow-wrap: anywhere;
}

.tg-lock-box {
  padding: 13px;
  border-radius: 11px;
  border: 1px dashed #d6dee8;
  background: #f8fafc;
  color: #657286;
  font-size: 11px;
  line-height: 1.5;
}

.tg-bots-list {
  display: grid;
  gap: 9px;
}

.tg-bot-list-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px;
  border: 1px solid #e7ebf0;
  border-radius: 11px;
  background: #fbfdff;
}

.tg-bot-list-icon {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 10px;
  background: var(--tg-accent-soft);
  color: #1388bd;
  font-weight: 900;
}

.tg-bot-list-text {
  min-width: 0;
}

.tg-bot-list-name {
  color: #263246;
  font-size: 12px;
  font-weight: 800;
}

.tg-bot-list-user {
  margin-top: 2px;
  color: #8490a2;
  font-size: 11px;
}

.tg-status-original {
  display: none !important;
}

#telegramFlowEditorV3 .nf-flow-canvas,
#telegramBroadcastBuilder .tb-card {
  border-color: var(--tg-border) !important;
  box-shadow: var(--tg-shadow);
}

#telegramFlowEditorV3 .nf-flow-node {
  border-color: #e3e8ee !important;
  box-shadow: 0 8px 24px rgba(15,23,42,.055) !important;
}

#telegramFlowEditorV3 .nf-flow-start {
  background: #172033 !important;
}

#telegramBroadcastBuilder .tb-mode {
  border-radius: 12px !important;
}

#telegramBroadcastBuilder .tb-mode.active {
  border-color: #67bfe8 !important;
  background: #eff9fe !important;
  box-shadow: 0 0 0 2px rgba(34,158,217,.09) !important;
}

#telegramBroadcastBuilder .tb-preview-shell {
  background: linear-gradient(180deg, #d9edf7, #eaf4f9) !important;
}

@media (max-width: 1100px) {
  .tg-metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

@media (max-width: 900px) {
  .sidebar {
    width: 210px;
  }

  .page {
    padding: 22px;
  }
}

@media (max-width: 680px) {
  .sidebar {
    width: 100%;
    padding: 18px 14px;
  }

  .tg-bot-sidebar-card {
    margin-bottom: 14px;
  }

  .topbar {
    height: auto;
    min-height: 68px;
    padding: 14px 18px;
    flex-wrap: wrap;
  }

  .page {
    padding: 18px;
  }

  .tg-settings-hero {
    grid-template-columns: 1fr;
    gap: 14px;
  }

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

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