:root {
  --bg: #eff3f8;
  --bg-strong: #dfe7f1;
  --card: rgba(255, 255, 255, 0.82);
  --card-solid: #ffffff;
  --panel: rgba(255, 255, 255, 0.7);
  --text: #152031;
  --muted: #627188;
  --line: rgba(14, 27, 53, 0.1);
  --line-strong: rgba(14, 27, 53, 0.16);
  --brand: #2fda76;
  --brand-dark: #22b85f;
  --brand-ink: #06364f;
  --sidebar: #08344b;
  --sidebar-deep: #05263a;
  --sidebar-line: rgba(255, 255, 255, 0.12);
  --success-bg: rgba(47, 218, 118, 0.15);
  --success-text: #138348;
  --warning-bg: rgba(255, 194, 102, 0.18);
  --warning-text: #9a5f05;
  --danger-bg: rgba(220, 83, 83, 0.12);
  --danger-text: #b33131;
  --shadow: 0 24px 80px rgba(7, 28, 43, 0.12);
  --font: "Geologica", Inter, system-ui, sans-serif;
}

html[data-theme="dark"] {
  --bg: #0f131a;
  --bg-strong: #1a2230;
  --card: rgba(31, 37, 49, 0.84);
  --card-solid: #202736;
  --panel: rgba(26, 32, 45, 0.86);
  --text: #edf2fb;
  --muted: #95a4ba;
  --line: rgba(224, 232, 247, 0.08);
  --line-strong: rgba(224, 232, 247, 0.14);
  --brand: #34e082;
  --brand-dark: #20c86b;
  --brand-ink: #05293d;
  --sidebar: #061925;
  --sidebar-deep: #04131d;
  --sidebar-line: rgba(255, 255, 255, 0.08);
  --success-bg: rgba(52, 224, 130, 0.16);
  --success-text: #79f0af;
  --warning-bg: rgba(255, 194, 102, 0.14);
  --warning-text: #ffcf82;
  --danger-bg: rgba(220, 83, 83, 0.14);
  --danger-text: #ff9a9a;
  --shadow: 0 30px 90px rgba(0, 0, 0, 0.34);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(47, 218, 118, 0.18), transparent 26%),
    radial-gradient(circle at top right, rgba(8, 52, 75, 0.12), transparent 24%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-strong) 100%);
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.hidden,
[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

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

.eyebrow {
  margin: 0 0 6px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.auth-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px;
}

.auth-card {
  width: min(100%, 520px);
  padding: 36px;
  border-radius: 30px;
  border: 1px solid var(--line);
  background: var(--card);
  backdrop-filter: blur(20px);
  box-shadow: var(--shadow);
}

.auth-brand {
  display: grid;
  grid-template-columns: 80px 1fr;
  gap: 20px;
  align-items: center;
  margin-bottom: 28px;
}

.auth-brand-mark,
.sidebar-mark {
  color: var(--brand);
}

.auth-brand-mark svg,
.sidebar-mark svg {
  width: 100%;
  height: auto;
  display: block;
}

.auth-brand h1 {
  margin: 0;
  font-size: clamp(30px, 5vw, 40px);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.04em;
}

.brand-copy {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.auth-switch {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  padding: 8px;
  border-radius: 18px;
  background: rgba(6, 54, 79, 0.06);
  margin-bottom: 18px;
}

.auth-switch-btn {
  border: 0;
  border-radius: 14px;
  padding: 12px 14px;
  background: transparent;
  color: var(--muted);
  font-weight: 500;
}

.auth-switch-btn.active {
  background: var(--card-solid);
  color: var(--text);
  box-shadow: 0 10px 24px rgba(7, 28, 43, 0.08);
}

.auth-form {
  display: none;
  gap: 16px;
}

.auth-form.active {
  display: grid;
}

.auth-message,
.app-notice {
  margin: 0 0 18px;
  padding: 12px 14px;
  border-radius: 14px;
  line-height: 1.45;
}

.auth-message,
.app-notice.notice-danger {
  background: var(--danger-bg);
  color: var(--danger-text);
}

.app-notice.notice-success {
  background: var(--success-bg);
  color: var(--success-text);
}

.app-notice.notice-warning {
  background: var(--warning-bg);
  color: var(--warning-text);
}

.field {
  display: grid;
  gap: 8px;
}

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

.field input,
.field select,
.field textarea,
.search-field input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.76);
  color: var(--text);
  padding: 14px 16px;
  outline: none;
  transition:
    border-color 0.16s ease,
    box-shadow 0.16s ease,
    background 0.16s ease;
}

html[data-theme="dark"] .field input,
html[data-theme="dark"] .field select,
html[data-theme="dark"] .field textarea,
html[data-theme="dark"] .search-field input {
  background: rgba(9, 13, 21, 0.44);
}

.field input:focus,
.field select:focus,
.field textarea:focus,
.search-field input:focus {
  border-color: rgba(47, 218, 118, 0.72);
  box-shadow: 0 0 0 4px rgba(47, 218, 118, 0.14);
}

.field textarea {
  resize: vertical;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 16px;
  min-height: 44px;
  padding: 0 16px;
  transition:
    transform 0.16s ease,
    background 0.16s ease,
    border-color 0.16s ease,
    color 0.16s ease;
}

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

.button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.button-primary {
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%);
  color: var(--brand-ink);
  font-weight: 600;
  box-shadow: 0 16px 32px rgba(47, 218, 118, 0.22);
}

.button-ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--text);
}

.button-full {
  width: 100%;
}

.button-lg {
  min-height: 50px;
}

.button-sm {
  min-height: 36px;
  border-radius: 12px;
  padding: 0 12px;
  font-size: 13px;
}

.auth-foot {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 20px;
}

.stat-chip {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.42);
}

html[data-theme="dark"] .stat-chip {
  background: rgba(255, 255, 255, 0.03);
}

.stat-chip strong,
.stat-chip span {
  display: block;
}

.stat-chip strong {
  font-size: 13px;
  font-weight: 600;
}

.stat-chip span {
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.45;
}

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

.sidebar {
  padding: 28px 22px;
  background:
    radial-gradient(circle at top right, rgba(47, 218, 118, 0.18), transparent 34%),
    linear-gradient(180deg, var(--sidebar) 0%, var(--sidebar-deep) 100%);
  color: #edf6ff;
  border-right: 1px solid var(--sidebar-line);
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.sidebar-brand {
  display: grid;
  grid-template-columns: 54px 1fr;
  gap: 14px;
  align-items: center;
}

.sidebar-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.04em;
}

.sidebar-subtitle {
  margin-top: 4px;
  color: rgba(237, 246, 255, 0.66);
  font-size: 13px;
}

.sidebar-nav {
  display: grid;
  gap: 6px;
}

.nav-item {
  min-height: 46px;
  text-align: left;
  border: 0;
  padding: 0 14px;
  border-radius: 14px;
  background: transparent;
  color: rgba(237, 246, 255, 0.72);
  font-weight: 500;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.06);
}

.nav-item.active {
  background: rgba(47, 218, 118, 0.18);
  color: #ffffff;
}

.sidebar-foot {
  margin-top: auto;
  display: grid;
  gap: 14px;
}

.account-card {
  display: grid;
  grid-template-columns: 46px 1fr;
  gap: 12px;
  align-items: center;
  padding: 14px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.account-avatar {
  width: 46px;
  height: 46px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  font-weight: 700;
  color: var(--brand-ink);
  background: linear-gradient(135deg, var(--brand) 0%, #8ef7ba 100%);
}

.account-name {
  font-weight: 600;
}

.account-plan {
  margin-top: 4px;
  color: rgba(237, 246, 255, 0.66);
  font-size: 13px;
}

.sidebar-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.workspace {
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-width: 0;
}

.workspace-topbar {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 18px;
}

.workspace-title {
  margin: 0;
  font-size: clamp(28px, 4vw, 38px);
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1.02;
}

.workspace-tools {
  display: flex;
  align-items: center;
  gap: 12px;
}

.search-field {
  display: block;
  width: min(100%, 320px);
}

.realtime-pill,
.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.status-success {
  background: var(--success-bg);
  color: var(--success-text);
  border-color: transparent;
}

.status-warning {
  background: var(--warning-bg);
  color: var(--warning-text);
  border-color: transparent;
}

.view {
  display: none;
}

.view-active {
  display: block;
}

.inbox-grid {
  display: grid;
  grid-template-columns: 360px minmax(0, 1.2fr) 320px;
  gap: 16px;
  min-height: calc(100vh - 164px);
}

.channels-layout,
.placeholder-grid {
  display: grid;
  gap: 16px;
}

.channel-card-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 26px;
  background: var(--card);
  backdrop-filter: blur(18px);
  box-shadow: 0 20px 60px rgba(7, 28, 43, 0.08);
  overflow: hidden;
}

.panel-list,
.panel-thread,
.panel-aside {
  display: flex;
  flex-direction: column;
}

.panel-head,
.thread-head {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 12px;
  padding: 20px 20px 0;
}

.panel-head-tight {
  padding-bottom: 8px;
}

.panel-head h3,
.thread-head h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.panel-head p,
.thread-head p,
.channel-copy {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.conversation-list,
.channel-summary,
.detail-list,
.check-list {
  padding: 18px 20px 20px;
}

.conversation-list {
  display: grid;
  gap: 10px;
  overflow: auto;
}

.queue-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 14px 20px 0;
}

.filter-chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  min-height: 34px;
  padding: 0 12px;
  background: var(--panel);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.filter-chip.active {
  border-color: rgba(47, 218, 118, 0.32);
  background: rgba(47, 218, 118, 0.14);
  color: var(--text);
}

.conversation-item {
  width: 100%;
  border: 1px solid transparent;
  border-radius: 20px;
  background: var(--panel);
  padding: 14px;
  text-align: left;
  color: var(--text);
  display: grid;
  gap: 12px;
}

.conversation-item:hover {
  border-color: var(--line);
}

.conversation-item.active {
  border-color: rgba(47, 218, 118, 0.44);
  background: rgba(47, 218, 118, 0.12);
}

.conversation-main {
  width: 100%;
  border: 0;
  padding: 0;
  background: transparent;
  color: inherit;
  text-align: left;
}

.conversation-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.conversation-name {
  font-weight: 600;
}

.conversation-snippet,
.conversation-meta {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.conversation-owner {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.conversation-tags {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.conversation-tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  background: rgba(47, 218, 118, 0.12);
  color: var(--text);
  font-size: 12px;
  font-weight: 500;
}

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

.conversation-badge {
  min-width: 24px;
  height: 24px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: var(--brand);
  color: var(--brand-ink);
  font-size: 12px;
  font-weight: 700;
}

.message-feed {
  flex: 1;
  padding: 20px;
  overflow: auto;
  display: grid;
  gap: 12px;
  align-content: start;
}

.empty-state {
  min-height: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
  display: grid;
  place-items: center;
  padding: 32px;
  text-align: center;
  background: transparent;
}

html[data-theme="dark"] .empty-state {
  background: transparent;
}

.empty-state h4 {
  margin: 0 0 8px;
  font-size: 20px;
  font-weight: 600;
}

.empty-state p {
  margin: 0;
  max-width: 320px;
  color: var(--muted);
  line-height: 1.6;
}

.message {
  display: grid;
  gap: 8px;
  max-width: min(78%, 640px);
}

.message-in {
  justify-self: start;
}

.message-out {
  justify-self: end;
}

.message-bubble {
  border-radius: 20px;
  padding: 14px 16px;
  line-height: 1.55;
  background: rgba(18, 32, 53, 0.06);
}

.message-out .message-bubble {
  background: linear-gradient(135deg, rgba(47, 218, 118, 0.94), rgba(104, 238, 160, 0.96));
  color: var(--brand-ink);
}

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

.composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  padding: 18px 20px 20px;
  border-top: 1px solid var(--line);
}

.composer-main {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.composer-toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.composer-helper {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.composer textarea {
  min-height: 52px;
  max-height: 180px;
}

.template-picker {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.76);
  box-shadow: 0 16px 34px rgba(7, 28, 43, 0.08);
}

html[data-theme="dark"] .template-picker {
  background: rgba(9, 13, 21, 0.78);
}

.template-picker-head strong,
.template-picker-head span {
  display: block;
}

.template-picker-head strong {
  font-size: 14px;
  font-weight: 600;
}

.template-picker-head span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.template-picker-list {
  display: grid;
  gap: 8px;
  max-height: 280px;
  overflow: auto;
}

.template-picker-item {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px 14px;
  background: var(--panel);
  color: var(--text);
  text-align: left;
  display: grid;
  gap: 4px;
}

.template-picker-item:hover {
  border-color: rgba(47, 218, 118, 0.32);
}

.template-picker-title {
  font-weight: 600;
}

.template-picker-meta,
.template-picker-body {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.template-picker-empty {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  text-align: center;
}

.detail-list {
  display: grid;
  gap: 14px;
}

.detail-list div {
  display: grid;
  gap: 4px;
}

.detail-list dt {
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.detail-list dd {
  margin: 0;
  font-size: 15px;
  line-height: 1.5;
}

.inline-code {
  display: inline-block;
  max-width: 100%;
  padding: 4px 8px;
  border-radius: 12px;
  background: rgba(8, 52, 75, 0.08);
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 13px;
  line-height: 1.45;
  word-break: break-all;
}

html[data-theme="dark"] .inline-code {
  background: rgba(255, 255, 255, 0.08);
}

.detail-actions {
  padding: 0 20px 20px;
}

.detail-form {
  padding: 0 20px 20px;
}

.channel-summary {
  display: grid;
  gap: 10px;
}

.channel-summary-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px 16px;
  background: var(--panel);
}

.channel-summary-name {
  font-weight: 600;
}

.channel-summary-meta {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.channel-card {
  padding: 22px;
  display: grid;
  gap: 16px;
}

.channel-card-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
}

.channel-kicker {
  margin: 0 0 6px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.channel-card h3 {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
}

.stack-form {
  display: grid;
  gap: 12px;
}

.qr-box {
  display: grid;
  justify-items: center;
  gap: 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  padding: 16px;
  background: transparent;
}

.qr-box img {
  width: min(100%, 220px);
  border-radius: 18px;
  background: #ffffff;
  padding: 10px;
}

.qr-box p {
  margin: 0;
  text-align: center;
  color: var(--muted);
}

.check-list {
  margin: 0;
  padding-left: 20px;
  color: var(--text);
  line-height: 1.7;
}

.check-list li + li {
  margin-top: 10px;
}

.settings-panel {
  max-width: 740px;
}

.templates-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(340px, 0.9fr);
  gap: 16px;
  align-items: start;
}

.analytics-grid {
  display: grid;
  gap: 16px;
}

.analytics-toolbar {
  display: flex;
  align-items: end;
  gap: 12px;
  flex-wrap: wrap;
}

.analytics-field {
  min-width: 130px;
}

.analytics-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  padding: 18px 20px 20px;
}

.analytics-list {
  display: grid;
  gap: 12px;
  padding: 18px 20px 20px;
}

.analytics-item {
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--panel);
}

.analytics-item-head {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 12px;
}

.analytics-item-title {
  font-weight: 600;
}

.analytics-item-meta {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

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

.analytics-item-grid div {
  display: grid;
  gap: 4px;
}

.analytics-item-grid strong {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.analytics-item-grid span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.template-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  padding: 18px 20px 0;
}

.template-list {
  display: grid;
  gap: 12px;
  padding: 18px 20px 20px;
}

.template-card {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--panel);
}

.template-card.active {
  border-color: rgba(47, 218, 118, 0.44);
  background: rgba(47, 218, 118, 0.12);
}

.template-card-top {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 12px;
}

.template-card-name {
  font-weight: 600;
}

.template-card-meta {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.template-card-body {
  margin: 0;
  color: var(--text);
  line-height: 1.6;
}

.template-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

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

.template-form-body,
.template-variable-box,
.template-manager-note,
.template-actions {
  grid-column: 1 / -1;
}

.template-form-body textarea {
  min-height: 220px;
}

.template-variable-box {
  display: grid;
  gap: 10px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
}

.template-variable-box strong {
  font-size: 14px;
  font-weight: 600;
}

.template-variable-box p {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.template-manager-note {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.template-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.operators-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.9fr);
  gap: 16px;
}

.operator-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  padding: 18px 20px 0;
}

.operator-stat {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
}

.operator-stat strong,
.operator-stat span {
  display: block;
}

.operator-stat strong {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.operator-stat span {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.operator-list {
  display: grid;
  gap: 10px;
  padding: 18px 20px 20px;
}

.operator-item {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
}

.operator-avatar {
  width: 46px;
  height: 46px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  font-weight: 700;
  color: var(--brand-ink);
  background: linear-gradient(135deg, var(--brand) 0%, #8ef7ba 100%);
}

.operator-name {
  font-weight: 600;
}

.operator-meta {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

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

.operator-form .field:last-of-type,
.operator-form button {
  grid-column: span 2;
}

.amo-grid {
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
  align-items: start;
}

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

.amo-form .field,
.amo-form .checkbox-field,
.amo-form .amo-actions {
  margin: 0;
}

.amo-form .checkbox-field,
.amo-form .amo-actions {
  grid-column: 1 / -1;
}

.checkbox-field {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  color: var(--text);
  line-height: 1.5;
}

.checkbox-field input {
  width: 18px;
  height: 18px;
  margin-top: 2px;
  accent-color: var(--brand-dark);
}

.amo-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.nav-group {
  display: grid;
  gap: 6px;
}

.nav-group-label {
  margin: 0 0 6px;
  padding: 0 14px;
  color: rgba(237, 246, 255, 0.48);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.sidebar-support {
  display: grid;
  gap: 10px;
}

.support-card {
  display: grid;
  gap: 6px;
  padding: 14px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.support-card strong {
  font-size: 13px;
  font-weight: 600;
}

.support-card span {
  color: rgba(237, 246, 255, 0.68);
  font-size: 12px;
  line-height: 1.5;
}

.support-card-alert {
  background: rgba(47, 218, 118, 0.08);
  border-color: rgba(47, 218, 118, 0.18);
}

.workspace-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 18px 20px;
  border: 1px solid rgba(47, 218, 118, 0.16);
  border-radius: 24px;
  background:
    radial-gradient(circle at top right, rgba(47, 218, 118, 0.16), transparent 34%),
    linear-gradient(135deg, rgba(255, 255, 255, 0.78), rgba(255, 255, 255, 0.58));
  box-shadow: 0 20px 50px rgba(7, 28, 43, 0.06);
}

html[data-theme="dark"] .workspace-banner {
  background:
    radial-gradient(circle at top right, rgba(47, 218, 118, 0.2), transparent 34%),
    linear-gradient(135deg, rgba(31, 37, 49, 0.88), rgba(17, 24, 36, 0.86));
}

.workspace-banner-copy {
  display: grid;
  gap: 6px;
}

.workspace-banner-copy strong {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.workspace-banner-copy span {
  color: var(--muted);
  line-height: 1.55;
}

.panel-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.section-search {
  width: min(100%, 280px);
}

.channel-alert-panel {
  padding: 22px;
}

.channel-alert-copy {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 18px;
}

.channel-alert-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.crm-page,
.bonuses-grid {
  display: grid;
  gap: 16px;
}

.crm-summary,
.bonuses-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  padding: 18px 20px 0;
}

.integration-card-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  padding: 18px 20px 20px;
}

.integration-card {
  width: 100%;
  min-height: 190px;
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 18px;
  background: var(--panel);
  display: grid;
  align-content: start;
  gap: 10px;
  text-align: left;
  color: var(--text);
}

.integration-card strong {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.integration-card span {
  color: var(--muted);
  line-height: 1.6;
}

.integration-card-active {
  border-color: rgba(47, 218, 118, 0.32);
  background: linear-gradient(135deg, rgba(47, 218, 118, 0.12), rgba(255, 255, 255, 0.72));
}

html[data-theme="dark"] .integration-card-active {
  background: linear-gradient(135deg, rgba(47, 218, 118, 0.16), rgba(20, 29, 42, 0.92));
}

.payments-layout,
.settings-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.9fr);
  gap: 16px;
  align-items: start;
}

.payment-order-panel {
  position: sticky;
  top: 28px;
}

.billing-periods {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  padding: 0 20px 20px;
}

.billing-period {
  min-height: 56px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  color: var(--muted);
  font-weight: 600;
  padding: 0 14px;
}

.billing-period.active {
  background: linear-gradient(135deg, rgba(255, 223, 126, 0.92), rgba(255, 241, 196, 0.92));
  border-color: transparent;
  color: #5f4900;
}

.pricing-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 0 20px 20px;
}

.pricing-card {
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 18px;
  background: var(--panel);
  display: grid;
  gap: 14px;
}

.pricing-card.active {
  border-color: rgba(47, 218, 118, 0.3);
  background: rgba(47, 218, 118, 0.08);
}

.pricing-card-head {
  display: grid;
  gap: 12px;
}

.pricing-card-head h4 {
  margin: 6px 0 0;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.pricing-price {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.pricing-copy {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.pricing-card-foot {
  display: grid;
  gap: 10px;
}

.pricing-card-foot strong {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.5;
}

.payment-order {
  display: grid;
  gap: 16px;
  padding: 18px 20px 20px;
}

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

.payment-order-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
  padding: 14px 16px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: var(--panel);
}

.payment-order-item strong,
.payment-order-item span,
.payment-order-item b {
  display: block;
}

.payment-order-item span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.payment-total-card {
  display: grid;
  gap: 12px;
  padding: 18px;
  border-radius: 22px;
  background: linear-gradient(180deg, rgba(8, 52, 75, 0.08), rgba(47, 218, 118, 0.08));
  border: 1px solid rgba(47, 218, 118, 0.16);
}

html[data-theme="dark"] .payment-total-card {
  background: linear-gradient(180deg, rgba(8, 52, 75, 0.26), rgba(47, 218, 118, 0.12));
}

.payment-total-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.payment-total-row span {
  color: var(--muted);
}

.payment-total-row strong {
  font-size: 18px;
  font-weight: 700;
}

.payment-total-row-accent strong {
  color: var(--success-text);
}

.payment-total-note {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.payment-empty {
  min-height: 220px;
}

.referral-bar {
  margin: 18px 20px 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--panel);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
}

.referral-copy {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.referral-copy span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

.referral-copy strong {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.02em;
  overflow-wrap: anywhere;
}

.bonus-history {
  padding: 18px 20px 20px;
}

.bonus-empty {
  min-height: 340px;
}

.settings-stack,
.settings-tips {
  display: grid;
  gap: 16px;
  padding: 18px 20px 20px;
}

.settings-group {
  display: grid;
  gap: 10px;
}

.settings-group h4 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.setting-row {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 16px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
}

.setting-row strong,
.setting-row span {
  display: block;
}

.setting-row span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.setting-value {
  font-weight: 600;
  text-align: right;
  line-height: 1.5;
}

.tip-card {
  display: grid;
  gap: 6px;
  padding: 16px 18px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: var(--panel);
}

.tip-card strong {
  font-size: 14px;
  font-weight: 700;
}

.tip-card span {
  color: var(--muted);
  line-height: 1.55;
}

@media (max-width: 1360px) {
  .inbox-grid {
    grid-template-columns: 320px minmax(0, 1fr);
  }

  .panel-aside {
    grid-column: 1 / -1;
  }

  .channel-card-grid {
    grid-template-columns: 1fr;
  }

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

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

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

  .payments-layout,
  .settings-grid {
    grid-template-columns: 1fr;
  }

  .payment-order-panel {
    position: static;
  }

  .crm-summary,
  .bonuses-summary,
  .integration-card-grid,
  .pricing-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

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

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

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--sidebar-line);
  }

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

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

  .workspace-tools {
    justify-content: space-between;
  }

  .search-field {
    width: 100%;
  }

  .amo-form {
    grid-template-columns: 1fr;
  }

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

  .operator-form {
    grid-template-columns: 1fr;
  }

  .operator-form .field:last-of-type,
  .operator-form button {
    grid-column: auto;
  }

  .billing-periods,
  .pricing-grid,
  .integration-card-grid,
  .crm-summary,
  .bonuses-summary {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 860px) {
  .auth-screen,
  .workspace {
    padding: 18px;
  }

  .auth-card,
  .panel {
    border-radius: 24px;
  }

  .auth-brand {
    grid-template-columns: 1fr;
  }

  .auth-brand-mark {
    width: 72px;
  }

  .auth-foot,
  .sidebar-actions,
  .sidebar-nav,
  .inbox-grid,
  .composer {
    grid-template-columns: 1fr;
  }

  .workspace-banner,
  .channel-alert-copy,
  .referral-bar,
  .setting-row {
    flex-direction: column;
    align-items: stretch;
  }

  .template-summary,
  .operator-summary,
  .crm-summary,
  .bonuses-summary {
    grid-template-columns: 1fr;
  }

  .composer-helper {
    text-align: left;
  }

  .conversation-list {
    max-height: 360px;
  }

  .workspace-title {
    font-size: 30px;
  }

  .analytics-summary,
  .analytics-item-grid {
    grid-template-columns: 1fr;
  }
}

/* ============================================================
   V2 — New icon-sidebar shell + component library
   ============================================================ */

/* ── btn system ─────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px; border: 1px solid transparent; border-radius: 12px;
  min-height: 40px; padding: 0 16px; font-size: 14px; font-weight: 500;
  transition: background .15s, border-color .15s, opacity .15s, transform .12s;
  white-space: nowrap; cursor: pointer; font-family: inherit;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn-primary {
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%);
  color: var(--brand-ink); font-weight: 600;
  box-shadow: 0 8px 24px rgba(47,218,118,.22);
}
.btn-primary:hover { box-shadow: 0 12px 32px rgba(47,218,118,.28); }
.btn-ghost { background: var(--panel); border-color: var(--line); color: var(--text); }
.btn-ghost:hover { border-color: var(--line-strong); background: var(--card-solid); }
.btn-sm { min-height: 34px; border-radius: 10px; padding: 0 12px; font-size: 13px; }
.btn-lg { min-height: 50px; border-radius: 14px; font-size: 16px; }
.btn-full { width: 100%; }
.btn-icon { padding: 0; width: 40px; }
.btn-icon.btn-sm { width: 34px; }
.btn-danger-ghost { background: transparent; border-color: var(--danger-text); color: var(--danger-text); }
.btn-danger-ghost:hover { background: var(--danger-bg); }

/* ── Auth v2 updates ────────────────────────────────────── */
.auth-logo-mark { color: var(--brand); }
.auth-logo-mark svg { width: 80px; height: auto; display: block; }
.auth-eyebrow { margin: 0; font-size: 11px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.auth-brand-text h1 { margin: 6px 0 0; font-size: 32px; font-weight: 700; letter-spacing: -.04em; line-height: 1; }
.auth-sub { margin: 8px 0 0; color: var(--muted); line-height: 1.5; font-size: 14px; }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 6px; background: rgba(6,54,79,.06); border-radius: 14px; margin-bottom: 20px; }
.auth-tab { border: 0; border-radius: 10px; padding: 10px 14px; background: transparent; color: var(--muted); font-weight: 500; font-family: inherit; cursor: pointer; }
.auth-tab.active { background: var(--card-solid); color: var(--text); box-shadow: 0 4px 16px rgba(7,28,43,.1); }
.auth-msg { margin: 0 0 14px; padding: 10px 14px; border-radius: 12px; font-size: 14px; line-height: 1.45; background: var(--danger-bg); color: var(--danger-text); }
.auth-chips { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 24px; }
.auth-chip { display: grid; gap: 2px; padding: 12px 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); }
.auth-chip strong { font-size: 14px; font-weight: 700; }
.auth-chip span { font-size: 12px; color: var(--muted); }

/* ── App shell v2 layout ────────────────────────────────── */
.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.app-body { display: flex; flex: 1; overflow: hidden; }

/* ── Trial banner ───────────────────────────────────────── */
.trial-banner {
  display: flex; justify-content: space-between; align-items: center;
  gap: 16px; padding: 11px 20px; flex-shrink: 0;
  background: linear-gradient(90deg, rgba(255,194,102,.16), rgba(255,220,140,.1));
  border-bottom: 1px solid rgba(255,194,102,.28);
  color: var(--warning-text);
}
.trial-banner-left { display: flex; align-items: center; gap: 12px; font-size: 14px; }
.trial-banner-left strong { font-weight: 600; }
.trial-banner-left span { margin-left: 4px; }

/* ── Sidebar v2 (icon-only, 72px) ──────────────────────── */
.sidebar {
  width: 72px; flex-shrink: 0;
  display: flex; flex-direction: column; align-items: center;
  padding: 14px 0;
  background:
    radial-gradient(circle at top right, rgba(47,218,118,.16), transparent 40%),
    linear-gradient(180deg, var(--sidebar) 0%, var(--sidebar-deep) 100%);
  border-right: 1px solid var(--sidebar-line);
  gap: 0;
  /* reset old padding */
}
.sidebar-top {
  display: flex; flex-direction: column; align-items: center;
  gap: 2px; flex: 1;
}
.sidebar-bottom {
  display: flex; flex-direction: column; align-items: center;
  gap: 2px; padding-bottom: 4px;
}
.sidebar-logo {
  width: 38px; height: 38px; color: var(--brand);
  margin-bottom: 14px; margin-top: 4px;
}
.sidebar-logo svg { width: 100%; height: auto; display: block; }
.sidebar-nav { display: contents; }

.nav-icon {
  position: relative; display: flex; flex-direction: column;
  align-items: center; gap: 4px;
  width: 58px; min-height: 54px; padding: 9px 4px 7px;
  border: 0; border-radius: 14px; background: transparent;
  color: rgba(237,246,255,.52); font-size: 10px; font-weight: 500;
  letter-spacing: .02em; cursor: pointer; font-family: inherit;
  transition: background .14s, color .14s;
}
.nav-icon span { line-height: 1.2; text-align: center; }
.nav-icon svg { flex-shrink: 0; }
.nav-icon:hover { background: rgba(255,255,255,.07); color: rgba(237,246,255,.88); }
.nav-icon.active {
  background: rgba(47,218,118,.2); color: #fff;
  box-shadow: 0 4px 16px rgba(47,218,118,.18);
}
.nav-badge {
  position: absolute; top: 6px; right: 5px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--brand); border: 1.5px solid var(--sidebar);
}
.nav-icon-sm {
  position: relative; display: flex; flex-direction: column;
  align-items: center; gap: 4px;
  width: 58px; min-height: 44px; padding: 7px 4px;
  border: 0; border-radius: 12px; background: transparent;
  color: rgba(237,246,255,.44); font-size: 10px; font-weight: 500;
  cursor: pointer; font-family: inherit;
  transition: background .14s, color .14s;
}
.nav-icon-sm:hover { background: rgba(255,255,255,.07); color: rgba(237,246,255,.78); }
.nav-badge-sm {
  position: absolute; top: 4px; right: 6px;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--brand); border: 1.5px solid var(--sidebar);
}
.sidebar-account-btn {
  width: 44px; height: 44px; border: 0; border-radius: 14px;
  background: rgba(255,255,255,.07); padding: 0; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  margin-top: 6px; transition: background .14s;
}
.sidebar-account-btn:hover { background: rgba(255,255,255,.13); }
.account-ava {
  width: 34px; height: 34px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px;
  color: var(--brand-ink);
  background: linear-gradient(135deg, var(--brand) 0%, #8ef7ba 100%);
}

/* ── Workspace v2 ───────────────────────────────────────── */
.workspace {
  flex: 1; min-width: 0; overflow: hidden;
  display: flex; flex-direction: column;
  padding: 0;
  gap: 0;
}
.view { display: none; flex: 1; flex-direction: column; }
.view-active { display: flex; overflow-y: auto; }
#view-chats { overflow-y: hidden; }

/* ── Page layout (non-chat views) ───────────────────────── */
.page-content {
  padding: 28px; width: 100%;
  display: flex; flex-direction: column; gap: 20px;
}
.page-hd {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.page-hd h1 {
  margin: 0; font-size: clamp(20px, 2.5vw, 28px);
  font-weight: 700; letter-spacing: -.04em;
}
.page-hd-tools {
  display: flex; align-items: center; gap: 10px;
  flex-wrap: wrap; margin-left: auto;
}
.section-block {
  border: 1px solid var(--line); border-radius: 20px;
  background: var(--card); overflow: hidden;
}
.section-block-head {
  padding: 14px 18px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 12px;
}
.section-block-head h3 {
  margin: 0; font-size: 15px; font-weight: 600; letter-spacing: -.02em;
}

/* ── Inbox 3-col layout ─────────────────────────────────── */
.inbox-layout {
  display: grid;
  grid-template-columns: 300px 1fr 276px;
  flex: 1; overflow: hidden;
}
.inbox-list-col {
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--card);
}
.inbox-list-head {
  padding: 12px 12px 8px; border-bottom: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 8px; flex-shrink: 0;
}
.inbox-filters {
  display: flex; flex-wrap: nowrap; gap: 6px;
  overflow-x: auto; padding-bottom: 2px;
}
.inbox-filters::-webkit-scrollbar { display: none; }
.inbox-list-tools { display: flex; gap: 8px; align-items: center; }
.inbox-list-body {
  flex: 1; overflow-y: auto; padding: 8px;
  display: flex; flex-direction: column; gap: 4px;
}

.filter-pill {
  flex-shrink: 0; border: 1px solid var(--line); border-radius: 999px;
  min-height: 28px; padding: 0 11px;
  background: transparent; color: var(--muted); font-size: 12px; font-weight: 600;
  cursor: pointer; font-family: inherit;
  transition: background .13s, border-color .13s, color .13s;
}
.filter-pill.active {
  background: rgba(47,218,118,.14); border-color: rgba(47,218,118,.3);
  color: var(--text);
}
.filter-pill:hover:not(.active) { background: rgba(0,0,0,.04); }
html[data-theme="dark"] .filter-pill:hover:not(.active) { background: rgba(255,255,255,.04); }

.inbox-thread-col {
  display: flex; flex-direction: column; overflow: hidden;
  border-right: 1px solid var(--line);
}
.inbox-aside-col {
  overflow-y: auto; padding: 16px;
  background: rgba(255,255,255,.35);
  display: flex; flex-direction: column; gap: 16px;
}
html[data-theme="dark"] .inbox-aside-col { background: rgba(255,255,255,.02); }

/* Thread head */
.thread-head {
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px; padding: 13px 16px; flex-shrink: 0;
  border-bottom: 1px solid var(--line); background: var(--card);
}
.thread-contact { display: flex; align-items: center; gap: 10px; }
.thread-ava {
  width: 38px; height: 38px; border-radius: 12px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px;
  background: linear-gradient(135deg, var(--brand) 0%, #8ef7ba 100%);
  color: var(--brand-ink);
}
.thread-name { font-weight: 600; font-size: 15px; line-height: 1.2; }
.thread-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.thread-actions { display: flex; gap: 6px; align-items: center; flex-shrink: 0; }

/* Contact aside */
.contact-card { display: flex; flex-direction: column; gap: 14px; }
.contact-card-head { display: flex; align-items: center; gap: 12px; }
.contact-ava-lg {
  width: 46px; height: 46px; border-radius: 16px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 17px;
  background: linear-gradient(135deg, var(--brand) 0%, #8ef7ba 100%);
  color: var(--brand-ink);
}
.contact-name { font-weight: 600; font-size: 15px; }
.contact-channel { font-size: 12px; color: var(--muted); margin-top: 2px; }
.contact-fields { display: grid; gap: 0; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; background: var(--card); }
.contact-field-row {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 9px 12px; border-bottom: 1px solid var(--line); font-size: 13px;
}
.contact-field-row:last-child { border-bottom: 0; }
.contact-field-row dt { color: var(--muted); flex-shrink: 0; }
.contact-field-row dd { margin: 0; text-align: right; word-break: break-word; }
.contact-form-section { display: flex; flex-direction: column; gap: 10px; }

/* WS status pill */
.ws-pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px;
  border: 1px solid var(--line); font-size: 11px; font-weight: 600;
  color: var(--muted); letter-spacing: .04em; text-transform: uppercase;
}
.ws-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); flex-shrink: 0; }
.ws-pill.connected { color: var(--success-text); border-color: rgba(47,218,118,.28); }
.ws-pill.connected .ws-dot { background: var(--brand); }

/* Composer v2 */
.composer-inner { display: flex; flex-direction: column; gap: 8px; width: 100%; }
.composer-inner textarea { min-height: 52px; max-height: 180px; border-radius: 12px; }
.composer-send { height: 100%; min-height: 60px; border-radius: 14px; padding: 0 20px; }

/* ── Data table ─────────────────────────────────────────── */
.data-table-wrap {
  overflow-x: auto; border: 1px solid var(--line);
  border-radius: 20px; background: var(--card);
}
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table th {
  padding: 11px 16px; text-align: left;
  font-size: 11px; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--muted);
  border-bottom: 1px solid var(--line); white-space: nowrap;
  background: rgba(0,0,0,.015);
}
html[data-theme="dark"] .data-table th { background: rgba(255,255,255,.02); }
.data-table td {
  padding: 12px 16px; border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover td { background: rgba(47,218,118,.035); }
.data-table .op-ava {
  width: 34px; height: 34px; border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; color: var(--brand-ink);
  background: linear-gradient(135deg, var(--brand) 0%, #8ef7ba 100%);
}
.data-table .role-badge {
  display: inline-flex; padding: 3px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600;
  background: rgba(8,52,75,.08); color: var(--muted);
}
.data-table .role-badge.admin { background: rgba(47,218,118,.16); color: var(--success-text); }

/* ── Drawer ─────────────────────────────────────────────── */
.drawer {
  position: fixed; right: 0; top: 0; bottom: 0;
  width: min(100%, 420px); z-index: 300;
  background: var(--card-solid);
  border-left: 1px solid var(--line);
  box-shadow: -20px 0 60px rgba(7,28,43,.14);
  display: flex; flex-direction: column; overflow: hidden;
  animation: drawerIn .2s ease;
}
html[data-theme="dark"] .drawer { box-shadow: -24px 0 80px rgba(0,0,0,.4); }
@keyframes drawerIn { from { transform: translateX(40px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
.drawer-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 18px 24px; border-bottom: 1px solid var(--line); flex-shrink: 0;
}
.drawer-head h3 { margin: 0; font-size: 18px; font-weight: 700; letter-spacing: -.02em; }
.drawer .stack-form { padding: 24px; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 12px; }
.drawer-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; }

/* ── CRM logo grid ──────────────────────────────────────── */
.crm-logo-grid {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px;
}
.crm-logo-card {
  position: relative; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 8px;
  min-height: 110px; padding: 20px 14px;
  border: 1px solid var(--line); border-radius: 20px;
  background: var(--card); cursor: pointer; color: var(--text);
  transition: border-color .14s, box-shadow .14s;
  font-family: inherit;
}
.crm-logo-card:hover:not(.crm-coming) {
  border-color: var(--line-strong); box-shadow: 0 8px 28px rgba(7,28,43,.07);
}
.crm-logo-text { font-size: 22px; font-weight: 800; letter-spacing: -.04em; line-height: 1; }
.crm-logo-text.crm-amo { color: #c65095; }
.crm-logo-text.crm-bitrix { color: #e84c4c; }
.crm-logo-text.crm-kommo { color: #0063f7; }
.crm-logo-icon { color: var(--muted); }
.crm-coming { opacity: .55; cursor: default; }
.crm-coming-label {
  position: absolute; top: 10px; right: 10px;
  padding: 3px 8px; border-radius: 999px;
  background: rgba(6,54,79,.07); color: var(--muted);
  font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
}
.crm-status-dot {
  width: 10px; height: 10px; border-radius: 50%;
  position: absolute; bottom: 10px; right: 10px;
}
.crm-status-dot.connected { background: var(--brand); }
.crm-status-dot.disconnected { background: var(--muted); }
.crm-status-panel {
  padding: 12px 14px; border-radius: 14px;
  background: var(--success-bg); color: var(--success-text);
  font-size: 13px; line-height: 1.5;
}

/* ── Modal ──────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 500;
  background: rgba(7,28,43,.5); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center; padding: 24px;
  animation: fadeIn .16s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal-box {
  width: min(100%, 520px); max-height: calc(100dvh - 48px);
  background: var(--card-solid); border-radius: 26px;
  border: 1px solid var(--line);
  box-shadow: 0 40px 80px rgba(7,28,43,.22);
  overflow-y: auto; padding: 28px;
  display: flex; flex-direction: column; gap: 16px;
  animation: modalUp .18s ease;
}
@keyframes modalUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal-head {
  display: flex; justify-content: space-between; align-items: center;
}
.modal-head h3 { margin: 0; font-size: 20px; font-weight: 700; letter-spacing: -.03em; }
.modal-desc { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.55; }
.modal-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.modal-links {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  font-size: 13px; color: var(--muted);
  padding-top: 12px; border-top: 1px solid var(--line);
}
.modal-links a { color: var(--brand-dark); text-decoration: none; }
.modal-links a:hover { text-decoration: underline; }

/* ── Channel available grid ─────────────────────────────── */
.channel-avail-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(188px, 1fr)); gap: 12px;
}
.channel-avail-card {
  border: 1px solid var(--line); border-radius: 20px;
  background: var(--card); padding: 18px 14px;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  transition: border-color .14s;
}
.channel-avail-icon {
  width: 54px; height: 54px; border-radius: 16px;
  display: flex; align-items: center; justify-content: center; color: #fff;
}
.ch-tg { background: #2aabee; }
.ch-wa { background: #25d366; }
.ch-waba { background: linear-gradient(135deg, #25d366, #128c7e); }
.ch-vk { background: #4a76a8; }
.ch-max { background: linear-gradient(135deg, #6a4fdb, #a06ef2); }
.channel-avail-name { font-weight: 600; font-size: 14px; text-align: center; }
.channel-avail-btn { width: 100%; }
.channel-connect-form {
  width: 100%; display: flex; flex-direction: column; gap: 10px;
}
.channel-connect-form[hidden] { display: none; }
.channels-empty-hint { padding: 16px 20px; color: var(--muted); font-size: 14px; }

/* ── Info banner ────────────────────────────────────────── */
.info-banner {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 14px 16px; border-radius: 16px; font-size: 14px; line-height: 1.55;
  background: var(--warning-bg); color: var(--warning-text);
}
.info-banner-blue {
  background: rgba(59,130,246,.08); color: #1e40af;
  border: 1px solid rgba(59,130,246,.18);
}
html[data-theme="dark"] .info-banner-blue { color: #93c5fd; background: rgba(59,130,246,.1); border-color: rgba(59,130,246,.2); }
.info-banner > svg { flex-shrink: 0; margin-top: 1px; }
.info-banner strong { font-weight: 600; }

/* ── Badge tag ──────────────────────────────────────────── */
.badge-tag {
  display: inline-flex; align-items: center;
  padding: 3px 10px; border-radius: 999px;
  background: rgba(47,218,118,.16); color: var(--success-text);
  font-size: 12px; font-weight: 600; letter-spacing: .04em;
  vertical-align: middle;
}

/* ── Settings v2 ────────────────────────────────────────── */
.settings-tabs { display: flex; gap: 4px; margin-bottom: 4px; }
.settings-tab {
  border: 0; background: transparent; padding: 8px 16px;
  border-radius: 10px; font-weight: 500; color: var(--muted); font-size: 14px;
  cursor: pointer; font-family: inherit;
  transition: background .13s, color .13s;
}
.settings-tab.active { background: rgba(47,218,118,.14); color: var(--text); }
.settings-tab:hover:not(.active) { background: rgba(0,0,0,.04); }
html[data-theme="dark"] .settings-tab:hover:not(.active) { background: rgba(255,255,255,.04); }
.settings-profile-card {
  display: flex; align-items: center; gap: 16px;
  padding: 18px 20px; border: 1px solid var(--line); border-radius: 20px;
  background: var(--card);
}
.settings-profile-ava {
  width: 54px; height: 54px; border-radius: 18px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 21px;
  color: var(--brand-ink);
  background: linear-gradient(135deg, var(--brand) 0%, #8ef7ba 100%);
}
.settings-profile-info { flex: 1; min-width: 0; }
.settings-profile-name { font-weight: 700; font-size: 16px; }
.settings-profile-role { color: var(--muted); font-size: 13px; margin-top: 3px; }
.settings-logout-btn { flex-shrink: 0; }
.settings-field-group {
  border: 1px solid var(--line); border-radius: 18px;
  background: var(--card); overflow: hidden;
}
.settings-field-group-label {
  font-size: 11px; font-weight: 700; letter-spacing: .1em;
  text-transform: uppercase; color: var(--muted);
}
.settings-field-row {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 16px; border-bottom: 1px solid var(--line);
}
.settings-field-row:last-child { border-bottom: 0; }
.settings-field-row > svg { flex-shrink: 0; color: var(--muted); }
.settings-field-label { flex: 1; font-size: 14px; color: var(--muted); }
.settings-field-value { font-size: 14px; font-weight: 500; }

/* ── Payments v2 ────────────────────────────────────────── */
.payments-layout {
  display: flex; flex: 1; overflow: hidden;
}
.payments-main {
  flex: 1; min-width: 0; overflow-y: auto; padding: 28px;
  display: flex; flex-direction: column; gap: 16px;
}
.payments-sidebar {
  width: 296px; flex-shrink: 0; border-left: 1px solid var(--line);
  padding: 24px; background: var(--card); overflow-y: auto;
}
.payment-tabs { display: flex; gap: 4px; }
.pay-tab {
  border: 0; background: transparent; padding: 8px 14px;
  border-radius: 10px; font-weight: 500; color: var(--muted); font-size: 14px;
  cursor: pointer; font-family: inherit; transition: background .13s, color .13s;
}
.pay-tab.active { background: rgba(47,218,118,.14); color: var(--text); }
.billing-periods { display: flex; flex-wrap: wrap; gap: 8px; padding: 0; }
.billing-period {
  min-height: 40px; border: 1px solid var(--line); border-radius: 12px;
  padding: 0 14px; background: var(--panel); color: var(--muted);
  font-weight: 600; font-size: 13px; cursor: pointer; font-family: inherit;
  display: inline-flex; align-items: center; gap: 8px;
  transition: background .13s, border-color .13s, color .13s;
}
.billing-period.active {
  background: linear-gradient(135deg, rgba(255,223,126,.94), rgba(255,241,196,.92));
  border-color: transparent; color: #5f4900;
}
.discount-badge {
  display: inline-flex; align-items: center; padding: 2px 7px;
  border-radius: 999px; background: rgba(47,218,118,.2);
  color: var(--success-text); font-size: 11px; font-weight: 700;
}
.pricing-catalog {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px;
}
.order-panel { display: flex; flex-direction: column; gap: 14px; }
.order-panel-head h3 { margin: 0; font-size: 17px; font-weight: 700; letter-spacing: -.02em; }
.order-panel-head p { margin: 4px 0 0; font-size: 13px; color: var(--muted); }
.order-items { display: flex; flex-direction: column; gap: 8px; }
.order-total {
  padding: 13px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
  display: flex; justify-content: space-between; align-items: center;
  font-weight: 700; font-size: 15px;
}
.order-note { margin: 0; font-size: 12px; color: var(--muted); line-height: 1.5; text-align: center; }

/* ── Bonuses v2 ─────────────────────────────────────────── */
.bonuses-hd { flex-wrap: wrap; row-gap: 10px; }
.referral-inline {
  display: flex; align-items: center; gap: 8px; margin-left: auto;
  padding: 7px 10px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--card);
}
.referral-link-val {
  font-size: 12px; color: var(--muted); font-family: ui-monospace, monospace;
  max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.bonuses-tabs { display: flex; gap: 4px; }
.bonus-tab {
  border: 0; background: transparent; padding: 8px 14px;
  border-radius: 10px; font-weight: 500; color: var(--muted); font-size: 14px;
  cursor: pointer; font-family: inherit; transition: background .13s, color .13s;
}
.bonus-tab.active { background: rgba(47,218,118,.14); color: var(--text); }
.bonus-cards {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px;
}

/* ── Analytics v2 ───────────────────────────────────────── */
.analytics-cards {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(155px, 1fr)); gap: 12px;
}
.analytics-two-col {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px;
}

/* ── Form helpers ───────────────────────────────────────── */
.toggle-row {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 13px; border: 1px solid var(--line); border-radius: 14px;
  background: var(--panel); cursor: pointer; font-size: 14px; font-family: inherit;
}
.toggle-row input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--brand-dark); flex-shrink: 0; }
.select-sm {
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--panel); color: var(--text);
  padding: 8px 12px; font: inherit; font-size: 13px; outline: none;
}
.select-sm:focus { border-color: rgba(47,218,118,.6); }
.form-hint { margin: 0; font-size: 12px; color: var(--muted); line-height: 1.5; }
.vars-box { padding: 12px 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); }
.vars-label { margin: 0 0 8px; font-size: 11px; font-weight: 700; color: var(--muted); letter-spacing: .08em; text-transform: uppercase; }
.vars-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.vars-chips code {
  padding: 3px 8px; border-radius: 8px;
  background: rgba(8,52,75,.08); color: var(--text);
  font-size: 12px; font-family: ui-monospace, monospace; cursor: pointer;
}
html[data-theme="dark"] .vars-chips code { background: rgba(255,255,255,.08); }
.op-stats { display: flex; gap: 16px; color: var(--muted); font-size: 13px; align-items: center; }
.empty-state-lg { min-height: 260px; gap: 12px; flex-direction: column; display: flex; align-items: center; justify-content: center; border: 0; border-radius: 0; padding: 40px 24px; text-align: center; }
.empty-state-lg h4 { margin: 0 0 6px; font-size: 18px; font-weight: 600; }
.empty-state-lg p { margin: 0; color: var(--muted); max-width: 280px; line-height: 1.6; }
.field-sm { gap: 5px; }
.field-sm label { font-size: 13px; font-weight: 500; }
.field-sm input,.field-sm select,.field-sm textarea { padding: 9px 12px; border-radius: 12px; font-size: 13px; }

/* ── Search field v2 ────────────────────────────────────── */
.search-field {
  display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--panel); padding: 0 12px; color: var(--muted);
}
.search-field input {
  border: 0; background: transparent; outline: none;
  padding: 8px 0; color: var(--text); font: inherit; font-size: 13px; width: 100%;
  box-shadow: none;
}
.search-field svg { flex-shrink: 0; }

/* ── Responsive v2 ──────────────────────────────────────── */
@media (max-width: 1280px) {
  .inbox-layout { grid-template-columns: 280px 1fr 260px; }
  .crm-logo-grid { grid-template-columns: repeat(2, 1fr); }
  .analytics-two-col { grid-template-columns: 1fr; }
}
@media (max-width: 1060px) {
  .inbox-layout { grid-template-columns: 260px 1fr; }
  .inbox-aside-col { display: none; }
}
@media (max-width: 800px) {
  .inbox-layout { grid-template-columns: 1fr; }
  .inbox-list-col { border-right: 0; }
  .payments-layout { flex-direction: column; }
  .payments-sidebar { width: 100%; border-left: 0; border-top: 1px solid var(--line); }
  .page-content { padding: 16px; }
  .crm-logo-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ═══════════════════════════════════════════════════════════
   V2 DESIGN POLISH — text overflow, forms, icons, active states
   ═══════════════════════════════════════════════════════════ */

/* ── Text truncation ───────────────────────────────────────── */
.nav-icon span {
  max-width: 60px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.conversation-name,
.thread-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.conversation-snippet {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: block;
}
.channel-avail-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.data-table td {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 200px;
}
.data-table th {
  white-space: nowrap;
}
.page-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Active nav state (stronger, correct specificity) ─────── */
.nav-icon.active,
.nav-icon[data-view].active {
  background: rgba(47, 218, 118, 0.18) !important;
  color: #2fda76 !important;
  box-shadow: none;
}
.nav-icon.active svg,
.nav-icon[data-view].active svg {
  color: #2fda76;
}

/* ── Auth tabs active ─────────────────────────────────────── */
.auth-tab.active {
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 1px 4px rgba(0,0,0,.08);
}

/* ── Form cleanup — simpler, more breathing room ──────────── */
.settings-field-row {
  padding: 14px 0;
  align-items: flex-start;
}
.settings-field-row label {
  padding-top: 2px;
  color: var(--muted);
  font-size: 13px;
  min-width: 140px;
  flex-shrink: 0;
}
.field-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}
.field-group .hint {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
}
input, select, textarea {
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--brand) !important;
  box-shadow: 0 0 0 3px rgba(47,218,118,.12) !important;
  outline: none;
}

/* ── Channel icons cleanup ─────────────────────────────────── */
.ch-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  flex-shrink: 0;
}
.ch-icon svg {
  width: 22px;
  height: 22px;
  fill: #fff;
  color: #fff;
}
.channel-avail-card {
  transition: box-shadow 0.15s, transform 0.12s;
}
.channel-avail-card:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,.1);
  transform: translateY(-1px);
}

/* ── CRM logo cards ────────────────────────────────────────── */
.crm-logo-card {
  transition: box-shadow 0.15s, transform 0.12s;
  cursor: pointer;
}
.crm-logo-card:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,.1);
  transform: translateY(-1px);
}

/* ── Drawer cleanup (matches HTML class .drawer-head) ──────── */
.drawer-head {
  padding: 20px 24px;
}
.drawer-head h3 {
  font-size: 17px;
}
.drawer .stack-form {
  gap: 14px;
}

/* ── Modal cleanup (matches HTML class .modal-head) ────────── */
.modal-head {
  padding: 18px 24px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-head h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}
.modal-desc {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.55;
  padding: 14px 24px 0;
}
.modal-box .stack-form {
  padding: 16px 24px 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.modal-actions {
  display: flex;
  gap: 10px;
  padding-top: 4px;
}
.modal-links {
  padding: 12px 24px 20px;
  border-top: 1px solid var(--line);
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 12px;
  color: var(--muted);
}

/* ── Table row hover ───────────────────────────────────────── */
.data-table tbody tr {
  transition: background 0.1s;
}
.data-table tbody tr:hover {
  background: var(--hover);
}

/* ── Page content max-width for readability ────────────────── */
.settings-form-wrap {
  max-width: 640px;
}

/* ── Operator avatar ───────────────────────────────────────── */
.op-ava {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  text-transform: uppercase;
}

/* ── Status badge ──────────────────────────────────────────── */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
}
.status-badge.active { background: rgba(47,218,118,.12); color: #1aaa5c; }
.status-badge.inactive { background: rgba(109,121,141,.1); color: var(--muted); }
.status-badge.pending { background: rgba(245,158,11,.12); color: #c27c00; }

/* ── Icon button reset ─────────────────────────────────────── */
.btn-icon-only {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--muted);
  transition: background 0.15s, color 0.15s;
  padding: 0;
}
.btn-icon-only:hover {
  background: var(--hover);
  color: var(--text);
}

/* ── Scrollbar style (webkit) ──────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* ═══════════════════════════════════════════════════════════
   ANALYTICS — unified design
   ═══════════════════════════════════════════════════════════ */

/* Summary stat cards (top row) */
.analytics-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.operator-stat {
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--card);
  box-shadow: none;
}
.operator-stat strong {
  display: block;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.04em;
  color: var(--text);
  line-height: 1.1;
}
.operator-stat span {
  display: block;
  margin-top: 6px;
  font-size: 13px;
  color: var(--muted);
  font-weight: 400;
}

/* Two-column section layout */
.analytics-two-col {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

/* Section block — single card container */
.section-block {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--card);
  overflow: hidden;
}
.section-block-head {
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 12px;
}
.section-block-head h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}

/* Items inside section-block — no own card frame */
.analytics-item {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px 20px;
  border: none;
  border-radius: 0;
  background: transparent;
  border-top: 1px solid var(--line);
}
.analytics-item:first-child {
  border-top: none;
}
.analytics-item:last-child {
  padding-bottom: 18px;
}

/* Item header */
.analytics-item-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}
.analytics-item-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}
.analytics-item-meta {
  margin-top: 3px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
}

/* Stat row inside item */
.analytics-item-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0;
}
.analytics-item-grid div {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-right: 12px;
  border-right: 1px solid var(--line);
}
.analytics-item-grid div:last-child {
  border-right: none;
  padding-right: 0;
  padding-left: 12px;
}
.analytics-item-grid div:not(:first-child):not(:last-child) {
  padding-left: 12px;
}
.analytics-item-grid strong {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text);
  line-height: 1.1;
}
.analytics-item-grid span {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.4;
  white-space: nowrap;
}

@media (max-width: 1280px) {
  .analytics-two-col { grid-template-columns: 1fr; }
}
@media (max-width: 800px) {
  .analytics-item-grid { grid-template-columns: repeat(3, 1fr); }
  .analytics-item-grid div { border-right: none; padding: 0; }
  .analytics-cards { grid-template-columns: repeat(3, 1fr); }
}

/* ═══════════════════════════════════════════════════════════
   UNIFIED DESIGN SYSTEM — border-radius, spacing, tabs
   ═══════════════════════════════════════════════════════════ */

/* ── Standardize card border-radius → 16px everywhere ─────── */
.section-block,
.data-table-wrap,
.settings-profile-card,
.settings-field-group,
.crm-logo-card,
.channel-avail-card,
.operator-stat,
.contact-fields,
.pricing-card,
.empty-state-lg {
  border-radius: 16px !important;
}
/* Smaller inner radius: inputs, toggles, misc */
.contact-fields { border-radius: 12px !important; }
.vars-box,
.toggle-row,
.referral-inline { border-radius: 12px !important; }
.info-banner { border-radius: 12px !important; }

/* ── Section block head — unified padding & font ───────────── */
.section-block-head {
  padding: 14px 20px !important;
}
.section-block-head h3 {
  font-size: 14px !important;
  font-weight: 600;
  letter-spacing: -.01em;
  color: var(--text);
}

/* ── Empty state inside section-block ─────────────────────── */
.section-block .empty-state,
#analyticsChannels .empty-state,
#analyticsOperators .empty-state,
#channelSummary .channels-empty-hint {
  padding: 32px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}

/* ── Tab components — unified across settings/pay/bonuses ──── */
.settings-tab,
.pay-tab,
.bonus-tab {
  border: 0;
  background: transparent;
  padding: 7px 14px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  font-family: inherit;
  transition: background .13s, color .13s;
  white-space: nowrap;
}
.settings-tab.active,
.pay-tab.active,
.bonus-tab.active {
  background: rgba(47, 218, 118, .14);
  color: var(--text);
  font-weight: 600;
}
.settings-tab:hover:not(.active),
.pay-tab:hover:not(.active),
.bonus-tab:hover:not(.active) {
  background: rgba(0, 0, 0, .04);
}
html[data-theme="dark"] .settings-tab:hover:not(.active),
html[data-theme="dark"] .pay-tab:hover:not(.active),
html[data-theme="dark"] .bonus-tab:hover:not(.active) {
  background: rgba(255, 255, 255, .04);
}

/* ── Tab row containers — unified gap ─────────────────────── */
.settings-tabs,
.payment-tabs,
.bonuses-tabs {
  display: flex;
  gap: 2px;
  flex-wrap: wrap;
}

/* ── Page header h1 — consistent size ─────────────────────── */
.page-hd h1 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -.04em;
}

/* ── Consistent page-content gap ──────────────────────────── */
.page-content {
  gap: 18px;
}
.payments-main {
  gap: 14px;
}

/* ── Bonuses history standalone heading ────────────────────── */
.section-block-head.standalone {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
}

/* ── channel-avail-grid inside section-block ───────────────── */
.section-block .channel-avail-grid {
  padding: 16px;
}

/* ── data-table border-radius fix (inner corners) ─────────── */
.data-table thead tr:first-child th:first-child { border-radius: 0; }

/* ── Op-stats in operators page header ────────────────────── */
.op-stats strong { color: var(--text); font-weight: 600; }

/* ── Billing period controls ───────────────────────────────── */
.billing-periods { margin: 0; }
.billing-period { border-radius: 10px !important; font-size: 13px; }

/* ── Order panel heading ───────────────────────────────────── */
.order-panel-head h3 {
  font-size: 16px;
}

/* ── Settings field rows — consistent height ───────────────── */
.settings-field-row {
  min-height: 48px;
}

/* ── Consistent info banner border ────────────────────────── */
.info-banner {
  border: 1px solid rgba(245, 158, 11, .2);
}
.info-banner-blue {
  border: 1px solid rgba(59, 130, 246, .18) !important;
}

/* ── CRM logo card min-height ──────────────────────────────── */
.crm-logo-card {
  min-height: 100px;
  padding: 18px 14px;
}

/* ── Channel avail card padding ────────────────────────────── */
.channel-avail-card {
  padding: 20px 16px;
  gap: 10px;
}
.channel-avail-icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
}

/* ── QR box (overrides old dashed version) ─────────────────── */
.qr-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 16px;
  margin-top: 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  width: 100%;
  background: transparent;
}
.qr-box img {
  max-width: 160px;
  border-radius: 8px;
}
.qr-box p {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
}

/* ── Empty state inside tables — no box, just centered text ── */
td .empty-state,
.data-table-wrap .empty-state {
  border: none !important;
  background: none !important;
  border-radius: 0 !important;
  min-height: auto;
  padding: 36px 20px;
}

/* ── Empty state inside section-block — no double border ────── */
.section-block .empty-state {
  border: none !important;
  background: none !important;
  border-radius: 0 !important;
  min-height: auto;
  padding: 36px 20px;
}

/* ── Empty state in message feed — keep subtle frame ────────── */
.message-feed .empty-state {
  border: 1px solid var(--line) !important;
  border-radius: 16px !important;
  background: transparent !important;
  margin: 20px;
  min-height: 200px;
}

/* ── empty-state-lg inside section-block ───────────────────── */
.section-block .empty-state-lg {
  border: none !important;
  border-radius: 0 !important;
}

/* ── empty-state h4/p font sizes ──────────────────────────── */
.empty-state h4 {
  font-size: 16px !important;
  font-weight: 600;
  margin: 0 0 6px;
  color: var(--text);
}
.empty-state p {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.55;
  max-width: 280px;
  margin: 0;
}
