:root {
  --bg: #F8FAFC;
  --panel: #FFFFFF;
  --text: #172033;
  --muted: #5b6476;
  --line: #d9e2ef;
  --primary: #229ED9;
  --primary-hover: #1a8fc3;
  --success: #16A34A;
  --success-bg: #dcfce7;
  --warning: #F59E0B;
  --warning-bg: #fef3c7;
  --danger: #EF4444;
  --danger-bg: #fee2e2;
  --sidebar: #eff6ff;
  --sidebar-active: #d8ebff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", sans-serif;
  font-size: 14px;
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

button,
input,
select,
textarea {
  font: inherit;
}

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

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: auto;
  padding: 18px 14px;
  background: var(--sidebar);
  border-right: 1px solid var(--line);
}

.brand {
  display: block;
  margin: 0 10px 18px;
  font-size: 19px;
  font-weight: 700;
  color: var(--text);
}

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

.sidebar-bottom {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  min-height: 38px;
  padding: 8px 12px;
  border-radius: 8px;
  color: #213148;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
  color: #123f60;
  background: var(--sidebar-active);
}

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(248, 250, 252, 0.96);
  backdrop-filter: blur(2px);
}

.topbar strong {
  display: block;
  font-size: 18px;
}

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

.logout {
  color: var(--text);
  background: #edf2f7;
  padding: 8px 12px;
  border-radius: 8px;
}

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

.admin-chip {
  max-width: 180px;
  overflow: hidden;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: #24445f;
  background: #fff;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.timezone-chip {
  color: #17658c;
  border-color: #b9ddf1;
  background: #eef8ff;
}

.container {
  width: min(1320px, calc(100vw - 250px));
  margin: 20px auto 48px;
  padding: 0 16px;
}

.login-wrap {
  width: min(1120px, calc(100vw - 32px));
  margin: 48px auto;
}

.login-shell {
  display: grid;
  grid-template-columns: minmax(0, 1.18fr) minmax(360px, 0.82fr);
  gap: 22px;
  align-items: stretch;
}

.login-brand-card,
.login-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.08);
}

.login-brand-card {
  min-height: 470px;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: #eef8ff;
}

.login-logo-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.login-panel {
  align-self: center;
  padding: 30px;
}

.login-mark {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
}

.login-mark span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  border-radius: 12px;
  color: #fff;
  background: var(--primary);
  font-size: 22px;
  font-weight: 800;
}

.login-mark strong {
  display: block;
  color: var(--text);
  font-size: 19px;
}

.login-mark small {
  color: var(--muted);
}

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

.login-helper {
  margin: 8px 0 20px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.login-form {
  gap: 14px;
}

.login-form input {
  min-height: 44px;
}

.login-form button {
  min-height: 44px;
  margin-top: 4px;
  font-weight: 700;
}

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

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

.alert {
  margin-bottom: 16px;
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid transparent;
}

.alert.success {
  border-color: #c6ecd6;
  color: #105e2e;
  background: var(--success-bg);
}

.alert.error {
  border-color: #f6c0c0;
  color: #8a1515;
  background: var(--danger-bg);
}

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

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

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.stat-card {
  background: var(--panel);
  border-radius: 8px;
  border: 1px solid var(--line);
  padding: 16px;
  box-shadow: 0 1px 0 rgba(31, 41, 55, 0.04);
}

.stat-card h3 {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 13px;
}

.stat-card strong {
  font-size: 28px;
  color: var(--text);
}

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

.panel h2,
.panel h3 {
  margin: 0 0 12px;
}

.panel p {
  margin: 0;
}

.split-grid,
.card-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  align-items: start;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.compact-table {
  table-layout: fixed;
}

.compact-table td,
.compact-table th,
table td,
table th {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  font-size: 13px;
}

.compact-table th,
table th {
  color: var(--muted);
  background: #f8fbff;
  font-weight: 700;
  font-size: 12px;
}

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

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

.sortable-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 118px;
}

.sort-buttons {
  display: inline-flex;
  flex: 0 0 auto;
  gap: 4px;
}

.sort-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  min-height: 24px;
  padding: 2px 6px;
  border: 1px solid #cfe0f4;
  border-radius: 6px;
  color: #17658c;
  background: #eef8ff;
  font-size: 12px;
  font-weight: 700;
}

.sort-button:hover,
.sort-button.active {
  color: #fff;
  background: var(--primary);
  border-color: var(--primary);
  text-decoration: none;
}

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

.filter-grid .span-2 {
  grid-column: span 2;
}

.filter-card {
  padding-bottom: 12px;
}

.filter-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 4px;
}

.broadcast-layout {
  display: grid;
  gap: 16px;
  grid-template-columns: 2fr 1.8fr 1fr;
  margin-bottom: 16px;
}

.broadcast-form,
.broadcast-preview {
  display: grid;
  gap: 10px;
}

.broadcast-quick-groups {
  display: grid;
  gap: 12px;
}

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

.broadcast-template-group .helper {
  margin: 0 0 6px;
}

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

.broadcast-checkbox-inline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
}

.broadcast-preview-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.broadcast-preview-count {
  margin: 10px 0;
  color: var(--text);
}

.broadcast-preview-sample {
  min-height: 96px;
  font-size: 12px;
  white-space: pre-wrap;
}

.broadcast-actions {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.broadcast-actions-item {
  display: grid;
  gap: 6px;
}

.group-add-form {
  margin: 14px 0 16px;
}

.log-content {
  max-width: 280px;
  white-space: pre-wrap;
  word-break: break-word;
}

.broadcast-chip-group .helper {
  color: var(--muted);
}

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

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

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

input,
select,
textarea {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--text);
  background: #fff;
}

textarea {
  min-height: 90px;
  resize: vertical;
}

.empty-label {
  visibility: hidden;
}

button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 8px 14px;
  border: 0;
  border-radius: 8px;
  color: #fff;
  background: var(--primary);
  cursor: pointer;
  font: inherit;
  text-decoration: none;
}

button:hover,
.button:hover {
  opacity: 0.92;
  text-decoration: none;
}

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

button.secondary,
.button.secondary {
  color: #10233a;
  background: #e8eef9;
}

button.success,
.button.success {
  color: #fff;
  background: var(--success);
}

button.danger,
.button.danger {
  color: #fff;
  background: var(--danger);
}

button.primary,
.button.primary {
  background: var(--primary);
}

.inline-form,
.action-row {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.inline-form select,
.action-row select {
  min-width: 130px;
}

.action-row form,
.inline-form form {
  margin: 0;
}

.status {
  display: inline-flex;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
}

.status-ok {
  color: #166534;
  background: var(--success-bg);
}

.status-warning {
  color: #92400e;
  background: var(--warning-bg);
}

.status-danger {
  color: #991b1b;
  background: var(--danger-bg);
}

.status-gray {
  color: #475569;
  background: #eef2ff;
}

.message-feed {
  display: grid;
  gap: 8px;
}

.message-card,
.chat-bubble {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fcfdff;
}

.message-meta {
  color: #6b7280;
  font-size: 12px;
  margin-bottom: 6px;
}

.message-content,
.message-time {
  font-size: 13px;
}

.message-time {
  margin-top: 6px;
  color: #6b7280;
}

.chat-stream {
  display: grid;
  gap: 10px;
}

.chat-bubble {
  max-width: 76%;
}

.bubble-right {
  justify-self: end;
  background: #e8f6ec;
  border-color: #cde9d8;
}

.bubble-left {
  justify-self: start;
  background: #f2f8ff;
  border-color: #d9ebff;
}

.chat-bubble header {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: #4b5563;
  font-size: 12px;
  margin-bottom: 6px;
}

.chat-bubble p {
  margin: 0;
}

.chat-bubble small {
  display: block;
  margin-top: 6px;
  color: #9ca3af;
}

.data-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(150px, 1fr));
  gap: 8px 14px;
}

.data-list > div {
  background: #f8fbff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
}

.data-list dt {
  color: var(--muted);
  margin-bottom: 4px;
  font-size: 12px;
}

.data-list dd {
  margin: 0;
  color: #111827;
  word-break: break-all;
}

.conversation-meta {
  align-items: center;
}

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

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0;
}

.chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #eef5ff;
  color: #1e3a8a;
  padding: 5px 12px;
  font-size: 12px;
  cursor: pointer;
}

.chip:hover {
  background: #dcecff;
}

.code-box {
  white-space: pre-wrap;
  margin: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fcfdff;
  font-size: 13px;
}

.log-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 6px;
}

.log-list li {
  background: #f8fbff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  color: #222c3a;
}

.mini-list {
  margin: 8px 0 0;
  padding-left: 16px;
}

.mini-list li {
  margin: 6px 0;
}

.mini-list code {
  color: #1e40af;
}

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

/* ===== Dashboard command center ===== */

.dashboard-page {
  display: grid;
  gap: 16px;
}

.dashboard-command {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(320px, 0.75fr);
  gap: 18px;
  overflow: hidden;
  padding: 24px;
  border: 1px solid rgba(34, 158, 217, 0.34);
  border-radius: 8px;
  color: #f8fbff;
  background:
    linear-gradient(135deg, #122033 0%, #14364c 45%, #176f9a 100%),
    #122033;
  box-shadow: 0 22px 50px rgba(15, 23, 42, 0.16);
}

.dashboard-command::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(rgba(255, 255, 255, 0.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.07) 1px, transparent 1px);
  background-size: 38px 38px;
  opacity: 0.18;
  pointer-events: none;
}

.command-copy,
.command-radar {
  position: relative;
  z-index: 1;
}

.command-eyebrow {
  display: inline-flex;
  margin-bottom: 12px;
  padding: 6px 10px;
  border: 1px solid rgba(186, 230, 253, 0.36);
  border-radius: 999px;
  color: #bae6fd;
  background: rgba(15, 23, 42, 0.18);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
}

.command-copy h1 {
  margin: 0;
  font-size: 34px;
  line-height: 1.18;
}

.command-copy p {
  max-width: 760px;
  margin: 12px 0 0;
  color: rgba(248, 251, 255, 0.78);
  line-height: 1.8;
}

.command-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.command-chips span {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 7px 11px;
  border: 1px solid rgba(186, 230, 253, 0.28);
  border-radius: 999px;
  color: #eef8ff;
  background: rgba(15, 23, 42, 0.28);
  font-size: 12px;
  white-space: nowrap;
}

.command-actions {
  display: grid;
  grid-template-columns: repeat(4, minmax(110px, 1fr));
  gap: 10px;
  margin-top: 18px;
}

.command-actions a {
  min-width: 0;
  padding: 12px;
  border: 1px solid rgba(186, 230, 253, 0.28);
  border-radius: 8px;
  color: #f8fbff;
  background: rgba(15, 23, 42, 0.28);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.command-actions a:hover {
  transform: translateY(-1px);
  border-color: rgba(94, 234, 212, 0.48);
  text-decoration: none;
}

.command-actions span,
.command-status-card span {
  display: block;
  color: rgba(248, 251, 255, 0.68);
  font-size: 12px;
}

.command-actions strong {
  display: block;
  margin-top: 6px;
  overflow: hidden;
  color: #ffffff;
  font-size: 20px;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pulse-chip i {
  width: 8px;
  height: 8px;
  margin-right: 7px;
  border-radius: 999px;
  background: #22c55e;
  box-shadow: 0 0 0 5px rgba(34, 197, 94, 0.16);
}

.pulse-chip.pulse-warning i {
  background: #f59e0b;
  box-shadow: 0 0 0 5px rgba(245, 158, 11, 0.18);
}

.pulse-chip.pulse-danger i {
  background: #ef4444;
  box-shadow: 0 0 0 5px rgba(239, 68, 68, 0.18);
}

.command-radar {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr);
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.radar-ring {
  display: grid;
  place-items: center;
  width: 180px;
  aspect-ratio: 1;
  border-radius: 50%;
  background:
    conic-gradient(#5eead4 calc(var(--pct) * 1%), rgba(255, 255, 255, 0.14) 0),
    rgba(15, 23, 42, 0.28);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.16);
}

.radar-ring > div {
  display: grid;
  place-items: center;
  width: 122px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.82);
}

.radar-ring strong {
  font-size: 27px;
}

.radar-ring span,
.radar-side span {
  color: rgba(248, 251, 255, 0.68);
  font-size: 12px;
}

.radar-side {
  display: grid;
  gap: 10px;
}

.radar-side div {
  min-width: 0;
  padding: 12px;
  border: 1px solid rgba(186, 230, 253, 0.22);
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.24);
}

.radar-side strong {
  display: block;
  margin-top: 4px;
  font-size: 22px;
}

.command-status-card {
  grid-column: 1 / -1;
  padding: 14px;
  border: 1px solid rgba(94, 234, 212, 0.26);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(94, 234, 212, 0.16), rgba(59, 130, 246, 0.12)),
    rgba(15, 23, 42, 0.24);
}

.command-status-card strong {
  display: block;
  margin: 5px 0;
  color: #ffffff;
  font-size: 34px;
  line-height: 1;
}

.command-status-card small {
  color: rgba(248, 251, 255, 0.72);
}

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

.dash-action {
  position: relative;
  overflow: hidden;
  min-height: 116px;
  padding: 15px;
  border: 1px solid #dbeafe;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 14px 30px rgba(15, 23, 42, 0.06);
}

.dash-action::after {
  content: "";
  position: absolute;
  right: 12px;
  bottom: -36px;
  width: 96px;
  aspect-ratio: 1;
  border-radius: 50%;
  opacity: 0.12;
  background: var(--action-color, #229ED9);
}

.dash-action:hover {
  transform: translateY(-1px);
  border-color: var(--action-border, #93c5fd);
  text-decoration: none;
}

.dash-action span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 28px;
  border-radius: 8px;
  color: var(--action-color, #17658c);
  background: var(--action-bg, #e0f2fe);
  font-size: 12px;
  font-weight: 800;
}

.dash-action strong {
  display: block;
  margin-top: 14px;
  color: #0f172a;
  font-size: 17px;
}

.dash-action small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  line-height: 1.55;
}

.action-blue { --action-color: #0284c7; --action-bg: #e0f2fe; --action-border: #7dd3fc; }
.action-green { --action-color: #16a34a; --action-bg: #dcfce7; --action-border: #86efac; }
.action-amber { --action-color: #d97706; --action-bg: #fef3c7; --action-border: #fcd34d; }
.action-rose { --action-color: #e11d48; --action-bg: #ffe4e6; --action-border: #fda4af; }

.neo-kpi-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(150px, 1fr));
  gap: 12px;
}

.neo-stat {
  --stat-color: #229ED9;
  --stat-soft: #7dd3fc;
  --stat-border: #b9ddf1;
  min-width: 0;
  overflow: hidden;
  padding: 15px;
  border: 1px solid var(--stat-border);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 14px 28px rgba(15, 23, 42, 0.06);
}

.stat-cyan { --stat-color: #0891b2; --stat-soft: #67e8f9; --stat-border: #a5f3fc; }
.stat-green { --stat-color: #16a34a; --stat-soft: #86efac; --stat-border: #bbf7d0; }
.stat-violet { --stat-color: #7c3aed; --stat-soft: #c4b5fd; --stat-border: #ddd6fe; }
.stat-amber { --stat-color: #f59e0b; --stat-soft: #fde68a; --stat-border: #fde68a; }
.stat-rose { --stat-color: #e11d48; --stat-soft: #fda4af; --stat-border: #fecdd3; }
.stat-blue { --stat-color: #229ED9; --stat-soft: #93c5fd; --stat-border: #bfdbfe; }

.neo-stat-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.neo-stat-top b {
  color: var(--stat-color);
  font-size: 12px;
}

.neo-stat strong {
  display: block;
  margin: 11px 0;
  color: #101827;
  font-size: 28px;
  line-height: 1.1;
}

.neo-stat small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
}

.neo-bar,
.load-track {
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: #e7edf6;
}

.neo-bar i,
.load-track i {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--stat-color), var(--stat-soft));
}

.neo-spark {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  align-items: end;
  gap: 4px;
  height: 28px;
}

.neo-spark i {
  display: block;
  min-width: 0;
  border-radius: 999px 999px 3px 3px;
  background: var(--stat-color);
}

.neo-spark i:nth-child(1) { height: 32%; opacity: 0.42; }
.neo-spark i:nth-child(2) { height: 56%; opacity: 0.58; }
.neo-spark i:nth-child(3) { height: 42%; opacity: 0.5; }
.neo-spark i:nth-child(4) { height: 78%; opacity: 0.78; }
.neo-spark i:nth-child(5) { height: 100%; }
.spark-alt i:nth-child(1) { height: 70%; }
.spark-alt i:nth-child(2) { height: 44%; }
.spark-alt i:nth-child(3) { height: 92%; }
.spark-alt i:nth-child(4) { height: 64%; }
.spark-alt i:nth-child(5) { height: 82%; }

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

.command-panel {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 12px 26px rgba(15, 23, 42, 0.05);
}

.command-panel > header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.command-panel h2 {
  margin: 0 0 4px;
  font-size: 18px;
}

.command-panel p {
  margin: 0;
  color: var(--muted);
}

.panel-link {
  flex: 0 0 auto;
  padding: 7px 10px;
  border: 1px solid #cde7f5;
  border-radius: 8px;
  color: #17658c;
  background: #eef8ff;
  font-size: 12px;
  font-weight: 700;
}

.agent-stack,
.signal-feed {
  display: grid;
  gap: 10px;
}

.agent-row {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #fbfdff;
}

.agent-avatar {
  display: grid;
  place-items: center;
  width: 42px;
  aspect-ratio: 1;
  border-radius: 8px;
  color: #fff;
  background: #229ED9;
  font-weight: 800;
}

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

.agent-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}

.agent-line strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.agent-sub {
  overflow: hidden;
  margin: 3px 0 7px;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-dot {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: #64748b;
  font-size: 12px;
  white-space: nowrap;
}

.status-dot::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #94a3b8;
}

.status-dot.online {
  color: #166534;
}

.status-dot.online::before {
  background: #16a34a;
  box-shadow: 0 0 0 4px rgba(22, 163, 74, 0.14);
}

.status-dot.danger {
  color: #991b1b;
}

.status-dot.danger::before {
  background: #ef4444;
}

.agent-count {
  text-align: right;
  white-space: nowrap;
}

.agent-count strong {
  display: block;
  color: #101827;
  font-size: 18px;
}

.agent-count span {
  color: var(--muted);
  font-size: 12px;
}

.signal-row {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 10px;
  padding: 10px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #fbfdff;
}

.signal-index {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  color: #17658c;
  background: #e0f2fe;
  font-weight: 800;
}

.signal-meta {
  color: #17658c;
  font-size: 12px;
  font-weight: 700;
}

.signal-row p {
  display: -webkit-box;
  overflow: hidden;
  margin: 4px 0;
  color: #172033;
  line-height: 1.55;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.signal-row time {
  color: var(--muted);
  font-size: 12px;
}

.customer-strip table {
  border: 0;
}

.panel-desc {
  margin: 0 0 12px;
}

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

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

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

.security-form {
  margin-top: 14px;
}

.security-form label {
  min-width: 0;
}

.form-hint {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 12px;
}

.checkbox-line {
  display: flex !important;
  align-items: center;
  gap: 8px !important;
  min-height: 40px;
}

.checkbox-line input {
  width: auto;
}

.reset-password-form input {
  width: 128px;
}

/* ===== Bot UI styles (kept for /admin/bot-ui) ===== */
.bot-ui-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.bot-ui-head p {
  margin: 6px 0 0;
  color: var(--muted);
}

.bot-ui-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.bot-media-spotlight {
  border-color: #93c5fd;
  background: linear-gradient(180deg, #eff6ff, #f8fbff);
}

.bot-media-spotlight h2 {
  margin-bottom: 4px;
}

.bot-ui-page {
  display: grid;
  gap: 16px;
}

.bot-file-field {
  display: grid;
  gap: 8px;
}

.bot-checkbox-inline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}

.bot-preview-media {
  max-width: min(100%, 320px);
  border-radius: 8px;
  border: 1px solid var(--line);
}

.bot-preview-media-empty {
  margin: 0;
  color: var(--muted);
  background: #f8fbff;
  border: 1px dashed #d4deeb;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12px;
  max-width: 320px;
}

.bot-preview-inline {
  padding-bottom: 8px;
}

.bot-preview-inline .panel-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
}

.bot-preview-inline .panel-head h2 {
  margin: 0 0 4px;
}

.tg-mini-viewport {
  border: 1px solid #dbe2ea;
  border-radius: 10px;
  padding: 10px;
  background: #eff6ff;
}

.tg-mini-shell {
  max-width: 420px;
  margin: 0 auto;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid #dbe6f2;
  background: #f9fbff;
}

.tg-mini-header {
  min-height: 38px;
  padding: 0 10px;
  display: flex;
  align-items: center;
  color: #0f2e4f;
  font-weight: 600;
  border-bottom: 1px solid #dbe6f2;
  background: linear-gradient(180deg, #f5f9ff, #ecf3ff);
}

.tg-mini-body {
  padding: 10px;
}

.tg-mini-msgs {
  display: grid;
  gap: 8px;
  min-height: 112px;
  margin-bottom: 10px;
}

.tg-mini-bubble {
  max-width: 100%;
  padding: 8px 10px;
  border-radius: 10px;
  line-height: 1.45;
  font-size: 12px;
  white-space: pre-wrap;
}

.tg-bot-mini-bubble {
  justify-self: start;
  background: #ffffff;
}

.tg-user-mini-bubble {
  justify-self: end;
  background: #d5f7c8;
}

.tg-mini-media {
  width: 100%;
  border-radius: 8px;
  margin-bottom: 6px;
}

.tg-mini-media-empty {
  display: none;
}

.tg-keyboard {
  margin-top: 6px;
  display: grid;
  gap: 6px;
  background: #e9f1fb;
  border-top: 1px solid #d8e5f6;
  padding: 8px;
}

.tg-keyboard-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.tg-keyboard-row span {
  border: 1px solid #d0dbea;
  border-radius: 999px;
  background: #fff;
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 8px;
  font-size: 12px;
  text-align: center;
}

.tg-keyboard-row:only-child,
.tg-keyboard-row:last-child {
  margin-bottom: 0;
}

.bot-config-layout,
.bot-template-grid,
.bot-button-editor {
  display: grid;
  gap: 10px;
}

.bot-config-layout {
  grid-template-columns: 1fr;
}

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

.bot-template-field,
.button-slot {
  display: grid;
  gap: 6px;
}

.bot-template-field small,
.bot-template-field span {
  color: var(--muted);
}

@media (max-width: 1200px) {
  .container {
    width: min(100% - 24px, 100%);
  }

  .split-grid,
  .settings-grid,
  .dashboard-command,
  .dashboard-main-grid,
  .bot-config-layout {
    grid-template-columns: 1fr;
  }

  .neo-kpi-grid {
    grid-template-columns: repeat(3, minmax(160px, 1fr));
  }

  .dashboard-action-grid,
  .command-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .command-radar {
    max-width: 560px;
  }
}

@media (max-width: 960px) {
  .login-wrap {
    width: min(100vw - 24px, 720px);
    margin: 18px auto 32px;
  }

  .login-shell {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .login-brand-card {
    min-height: 260px;
  }

  .login-panel {
    padding: 22px;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

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

  .topbar {
    position: static;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

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

  table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }

  .data-list {
    grid-template-columns: 1fr;
  }

  .neo-kpi-grid {
    grid-template-columns: repeat(2, minmax(140px, 1fr));
  }

  .dashboard-action-grid,
  .command-actions {
    grid-template-columns: 1fr;
  }

  .dashboard-command {
    padding: 18px;
  }

  .command-copy h1 {
    font-size: 28px;
  }

  .command-radar {
    grid-template-columns: 1fr;
  }

  .radar-ring {
    width: min(180px, 100%);
  }

  .agent-row {
    grid-template-columns: 38px minmax(0, 1fr);
  }

  .agent-count {
    grid-column: 2;
    text-align: left;
  }
}

/* ===== Lanzibot unified admin polish ===== */

/* 统一页面骨架 */
.app-shell {
  min-height: 100vh;
  grid-template-columns: 240px minmax(0, 1fr);
}

.sidebar {
  width: 240px;
  background: linear-gradient(180deg, #f3f8ff, #eff6ff);
  padding: 18px 14px;
}

.sidebar-nav a {
  border: 1px solid transparent;
  min-height: 40px;
}

.sidebar-nav a:hover {
  background: #deedff;
}

.sidebar-nav a.active {
  background: var(--primary);
  color: #fff;
}

.topbar {
  gap: 12px;
  background: #ffffff;
  backdrop-filter: none;
}

.container {
  width: min(1400px, calc(100vw - 260px));
  margin: 18px auto 48px;
  padding: 0 18px;
}

.page-head {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  align-items: end;
  column-gap: 16px;
  row-gap: 8px;
  margin-bottom: 14px;
}

.page-head h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.25;
}

.page-head .status {
  justify-self: end;
}

.panel {
  border-radius: 10px;
  box-shadow: 0 2px 10px rgba(30, 64, 175, 0.04);
  padding: 16px;
}

.panel h2,
.panel h3 {
  margin: 0 0 12px;
  color: #0f2035;
}

.panel h2 {
  font-size: 16px;
}

.panel p {
  color: var(--text);
}

.panel .panel-note,
.panel .muted {
  color: var(--muted);
  margin-top: 0;
}

.split-grid,
.card-grid,
.bot-config-layout {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.stats-grid {
  grid-template-columns: repeat(4, minmax(130px, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}

.stat-card {
  border-radius: 10px;
  box-shadow: 0 1px 0 rgba(2, 6, 23, 0.05);
}

.stat-card h3 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 0 10px;
  color: #334155;
  font-size: 13px;
}

.stat-card strong {
  line-height: 1.2;
  font-size: 30px;
}

.settings-grid,
.broadcast-layout {
  grid-template-columns: repeat(2, minmax(280px, 1fr));
  gap: 16px;
}

/* 表单统一 */
.filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
}

.filter-grid .span-2 {
  grid-column: span 2;
}

.filter-card {
  padding: 14px;
}

label {
  font-size: 13px;
}

input,
select,
textarea,
.button,
button {
  font-size: 14px;
}

button,
.button {
  min-height: 36px;
  border-radius: 9px;
  font-weight: 500;
}

.button.secondary {
  background: #e5edf8;
}

.section-subtitle {
  margin: 16px 0 8px;
}

.filter-actions {
  grid-column: 1 / -1;
  justify-content: flex-start;
  margin-top: 2px;
}

button.button-small,
.button.button-small,
button.secondary.button-small {
  min-height: 30px;
  padding: 5px 10px;
  border-radius: 7px;
}

/* 表格统一 */
table {
  border-radius: 10px;
  border: 1px solid #e5edf7;
  background: #fff;
}

table thead th {
  white-space: nowrap;
  font-size: 12px;
}

table tbody td {
  color: #0f172a;
  line-height: 1.35;
  vertical-align: middle;
}

tbody tr {
  transition: background-color 0.12s ease;
}
tbody tr:hover {
  background: #f7fbff;
}

.table-wrapper {
  border-radius: 10px;
  overflow-x: auto;
}

table.compact-table {
  table-layout: fixed;
}

td .action-row,
td .inline-form {
  justify-content: flex-start;
  align-items: flex-start;
  width: 100%;
}

.action-row,
.inline-form {
  flex-wrap: wrap;
  gap: 8px;
}

.action-row form,
.inline-form form {
  width: auto;
}

td .action-row {
  justify-content: flex-start;
  flex-wrap: wrap;
}

td form input,
td form select,
td form button,
td .button {
  font-size: 13px;
}

td .action-cell {
  min-width: 240px;
}

td select {
  min-width: 120px;
}

.action-inline {
  width: 100%;
  display: grid;
  gap: 8px;
}

/* 详情布局 */
.data-list {
  gap: 10px 14px;
}

.data-list > div {
  min-width: 0;
}

.data-list dt {
  font-size: 12px;
}

a.button {
  line-height: 1;
}

.panel-form {
  margin-top: 8px;
  display: grid;
  gap: 10px;
}

.mini-list {
  color: #475569;
}

.alert {
  border-left: 4px solid transparent;
}

.alert.success {
  border-left-color: #22c55e;
}

.alert.error {
  border-left-color: #ef4444;
}

/* Bot UI 顶部工具 */
.bot-ui-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.bot-ui-note {
  display: inline-flex;
  margin: 6px 0 0;
}

.bot-ui-note .bot-ui-note-em {
  margin-left: 4px;
}

.bot-ui-actions .button,
.bot-ui-actions button {
  white-space: nowrap;
}

.bot-ui-actions label.button {
  cursor: pointer;
}

.bot-section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.bot-section-title h2 {
  margin: 0;
}

.bot-preview-inline {
  padding: 14px;
}

.tg-mini-viewport {
  border-radius: 12px;
}

.tg-keyboard-row {
  gap: 8px;
}

.tg-mini-bubble {
  line-height: 1.45;
}

@media (max-width: 1400px) {
  .container {
    width: calc(100vw - 260px);
    margin: 16px 0 42px;
    padding: 0 16px;
  }
}

@media (max-width: 1180px) {
  .stats-grid {
    grid-template-columns: repeat(2, minmax(150px, 1fr));
  }
}

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

  .sidebar {
    position: static;
    width: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    height: auto;
  }

  .topbar {
    position: static;
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 12px 14px;
  }

  .container {
    width: calc(100vw - 32px);
    margin: 14px auto 36px;
    padding: 0;
  }

  .page-head,
  .split-grid,
  .settings-grid,
  .card-grid,
  .broadcast-layout,
  .bot-config-layout {
    grid-template-columns: 1fr;
  }

  table {
    min-width: 760px;
  }

  .broadcast-layout {
    gap: 12px;
  }
}

/* ===== CRM layout refinement v3 ===== */

:root {
  --shadow-soft: 0 8px 24px rgba(15, 23, 42, 0.05);
  --shadow-card: 0 1px 2px rgba(15, 23, 42, 0.04);
}

body {
  line-height: 1.45;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 8px 18px;
  text-decoration: none;
}

.brand:hover {
  text-decoration: none;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: var(--primary);
  font-weight: 800;
  box-shadow: 0 8px 18px rgba(34, 158, 217, 0.22);
}

.brand small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
}

.sidebar-nav a {
  gap: 8px;
  font-weight: 600;
  text-decoration: none;
}

.sidebar-nav a.active {
  box-shadow: 0 8px 18px rgba(34, 158, 217, 0.2);
}

.topbar {
  min-height: 62px;
  padding: 12px 24px;
}

.container {
  width: 100%;
  max-width: 1480px;
  margin: 18px auto 48px;
  padding: 0 22px;
}

.page-head {
  min-height: 48px;
  padding: 2px 0 4px;
  align-items: center;
}

.page-head p {
  max-width: 760px;
  margin: 6px 0 0;
}

.page-head > .button,
.page-head > .status {
  justify-self: end;
}

.panel {
  border-color: #e3ebf5;
  box-shadow: var(--shadow-card);
}

.panel > header {
  margin-bottom: 10px;
}

.panel > header p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

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

.stat-card {
  min-height: 104px;
  display: grid;
  align-content: space-between;
  border-color: #e3ebf5;
  box-shadow: var(--shadow-card);
}

.stat-card h3::after {
  content: "";
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--primary);
  opacity: 0.55;
}

.table-wrapper {
  border: 1px solid #e3ebf5;
  border-radius: 10px;
  background: #fff;
}

.table-wrapper table {
  min-width: 980px;
  border: 0;
  border-radius: 0;
}

table.compact-table {
  table-layout: auto;
}

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

.compact-table td {
  height: 48px;
}

.compact-table td:nth-child(4),
.compact-table td:nth-child(5) {
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
}

td.action-cell,
.action-cell {
  min-width: 250px;
}

.action-stack {
  min-width: 270px;
  display: grid;
  gap: 8px;
}

.action-row-nowrap {
  flex-wrap: nowrap;
}

.action-stack .inline-form {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(120px, 0.85fr) minmax(150px, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.action-stack .inline-form select,
.action-stack .inline-form input[type="text"] {
  min-width: 0;
}

.action-stack .inline-form button {
  white-space: nowrap;
}

.filter-grid {
  align-items: end;
}

.filter-actions.inline-submit {
  grid-column: auto;
  align-self: end;
}

.form-panel .filter-grid {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.status {
  align-items: center;
  min-height: 24px;
  font-weight: 600;
}

.message-feed {
  max-height: 520px;
  overflow: auto;
  padding-right: 2px;
}

.message-card {
  background: #ffffff;
}

.chat-stream {
  max-width: 980px;
  margin: 0 auto;
}

.chat-bubble {
  border-radius: 12px;
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.04);
}

.data-list {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.settings-grid {
  align-items: start;
}

.broadcast-layout {
  grid-template-columns: minmax(340px, 1.05fr) minmax(340px, 1fr) minmax(280px, 0.82fr);
  align-items: start;
}

.broadcast-form,
.broadcast-preview {
  align-content: start;
}

.broadcast-preview-panel {
  position: sticky;
  top: 82px;
}

.broadcast-preview-count {
  padding: 12px;
  border: 1px solid #dbeafe;
  border-radius: 10px;
  background: #eff6ff;
}

.broadcast-preview-count strong {
  font-size: 24px;
  color: var(--primary);
}

.broadcast-preview-metrics {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 10px 0;
}

.broadcast-preview-metrics span {
  border: 1px solid #e5edf7;
  border-radius: 8px;
  background: #ffffff;
  padding: 8px 10px;
  color: #334155;
  font-size: 12px;
}

.broadcast-warning-list {
  display: grid;
  gap: 6px;
}

.broadcast-warning-list div {
  border: 1px solid #fde68a;
  border-radius: 8px;
  background: #fffbeb;
  color: #92400e;
  padding: 8px 10px;
  font-size: 12px;
}

.broadcast-preview-sample {
  max-height: 220px;
  overflow: auto;
}

.broadcast-content-box {
  max-height: 260px;
  overflow: auto;
}

.broadcast-error-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}

.broadcast-error-item {
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: 10px;
  align-items: center;
  border: 1px solid #fee2e2;
  border-radius: 10px;
  background: #fff7f7;
  padding: 10px;
}

.broadcast-error-item strong {
  color: var(--danger);
  font-size: 24px;
  text-align: center;
}

.broadcast-error-item span {
  color: #7f1d1d;
  word-break: break-word;
}

.table-header-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.broadcast-detail-filter {
  display: grid;
  grid-template-columns: 130px minmax(220px, 1fr) auto auto;
  gap: 8px;
  align-items: center;
  min-width: min(100%, 620px);
}

.broadcast-log-table th:nth-child(9),
.broadcast-log-table td:nth-child(9) {
  width: 260px;
}

.error-cell {
  color: #991b1b;
  word-break: break-word;
}

.chip-row {
  max-height: 184px;
  overflow: auto;
  padding: 2px 0;
}

.chip {
  border-color: #cfe0f4;
  background: #f4f8ff;
}

.bot-ui-head {
  align-items: center;
}

.bot-ui-page {
  grid-template-columns: minmax(520px, 1fr) minmax(360px, 430px);
  align-items: start;
}

.bot-media-spotlight {
  grid-column: 1;
  border-color: #bfdbfe;
  box-shadow: 0 8px 24px rgba(34, 158, 217, 0.08);
}

.bot-preview-inline {
  grid-column: 2;
  grid-row: 1 / span 2;
  position: sticky;
  top: 82px;
}

.bot-config-layout {
  grid-column: 1;
  grid-template-columns: 1fr;
}

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

.bot-button-edit-row {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.tg-mini-viewport {
  background: #eaf3ff;
}

.tg-mini-shell {
  max-width: 390px;
  box-shadow: var(--shadow-soft);
}

.tg-mini-header {
  min-height: 42px;
}

.tg-keyboard {
  background: #e3eaf3;
}

.tg-keyboard-row span {
  min-height: 34px;
  border-radius: 8px;
  background: #ffffff;
  color: #111827;
  font-weight: 600;
}

.bot-preview-media {
  max-height: 220px;
  object-fit: contain;
  background: #f8fafc;
}

@media (max-width: 1280px) {
  .broadcast-layout,
  .bot-ui-page {
    grid-template-columns: 1fr;
  }

  .broadcast-preview-panel,
  .bot-preview-inline {
    position: static;
    grid-column: auto;
    grid-row: auto;
  }

  .bot-config-layout {
    grid-column: auto;
  }
}

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

@media (max-width: 960px) {
  .container {
    width: 100%;
    margin: 14px auto 36px;
    padding: 0 14px;
  }

  .page-head {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .page-head > .button,
  .page-head > .status {
    justify-self: start;
  }

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

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

  .bot-button-editor,
  .bot-button-edit-row,
  .action-stack .inline-form {
    grid-template-columns: 1fr;
  }
}

/* ===== CRM workspace refresh: non-dashboard pages ===== */

.page-head {
  position: relative;
  align-items: center;
  min-height: 92px;
  padding: 18px 20px;
  border: 1px solid #dbeafe;
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(34, 158, 217, 0.12), rgba(255, 255, 255, 0.88)),
    #ffffff;
  box-shadow: 0 14px 30px rgba(15, 23, 42, 0.06);
}

.page-head h1 {
  font-size: 25px;
  line-height: 1.22;
}

.page-head .muted,
.page-head p {
  max-width: 780px;
  margin: 7px 0 0;
  color: #64748b;
  line-height: 1.65;
}

.page-head > .button,
.page-head > .status,
.page-head > .action-row,
.bot-ui-actions {
  flex: 0 0 auto;
}

.panel {
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.05);
}

.panel.card {
  overflow: hidden;
}

.panel > header,
.table-header-row,
.panel-head {
  min-height: 38px;
  padding-bottom: 12px;
  border-bottom: 1px solid #eef2f7;
}

.panel > header h2,
.panel-head h2,
.table-header-row h2,
.panel h2 {
  color: #0f172a;
  font-size: 18px;
  line-height: 1.25;
}

.panel-desc {
  margin-bottom: 14px;
  padding: 11px 12px;
  border: 1px solid #dbeafe;
  border-radius: 8px;
  color: #31536b;
  background: #f0f8ff;
  line-height: 1.6;
}

.filter-card {
  padding: 16px;
  border-color: #dbeafe;
  background: #fbfdff;
}

.filter-grid {
  grid-template-columns: repeat(auto-fit, minmax(172px, 1fr));
  align-items: end;
}

.filter-grid label,
.grid-form label,
.stack-form label,
.panel-form label {
  min-width: 0;
  color: #475569;
  font-weight: 700;
}

.filter-actions,
.inline-submit {
  min-height: 38px;
}

input,
select,
textarea {
  min-height: 40px;
  border-color: #d6e1ef;
  background: #ffffff;
  transition: border-color 0.14s ease, box-shadow 0.14s ease, background 0.14s ease;
}

input[type="checkbox"],
input[type="radio"] {
  width: 16px;
  min-height: 16px;
  padding: 0;
  box-shadow: none;
}

input:focus,
select:focus,
textarea:focus {
  outline: 0;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(34, 158, 217, 0.14);
}

textarea {
  line-height: 1.55;
}

button,
.button {
  gap: 6px;
  min-height: 40px;
  border-radius: 8px;
  font-weight: 700;
  box-shadow: 0 8px 16px rgba(34, 158, 217, 0.10);
}

button.secondary,
.button.secondary {
  box-shadow: none;
}

.button-small,
button.button-small,
.button.button-small,
select.button-small,
input.button-small {
  min-height: 32px;
  padding: 6px 10px;
  border-radius: 7px;
  font-size: 12px;
  line-height: 1.2;
}

.table-wrapper {
  margin: 0 -2px -2px;
  border: 1px solid #e3ebf6;
  border-radius: 8px;
  background: #ffffff;
}

.table-wrapper table {
  border: 0;
  border-radius: 0;
}

.compact-table {
  min-width: 980px;
  table-layout: auto;
}

.compact-table th,
table th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: #516174;
  background: #f3f7fc;
  text-transform: none;
  white-space: nowrap;
}

.compact-table td,
table td {
  color: #1f2937;
  line-height: 1.45;
}

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

.action-cell {
  min-width: 170px;
}

.action-stack {
  display: grid;
  gap: 8px;
  min-width: 190px;
}

.action-row {
  align-items: center;
}

.action-row-nowrap {
  flex-wrap: nowrap;
}

.action-row .button,
.action-row button,
.inline-form .button,
.inline-form button {
  white-space: nowrap;
}

.inline-form {
  margin: 0;
}

.inline-form select,
.inline-form input,
.action-row select,
.action-row input {
  width: auto;
  max-width: 260px;
}

.status {
  min-height: 24px;
  align-items: center;
  font-weight: 800;
  white-space: nowrap;
}

.stats-grid {
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}

.stat-card {
  position: relative;
  overflow: hidden;
  border-color: #dbeafe;
  box-shadow: 0 14px 28px rgba(15, 23, 42, 0.06);
}

.stat-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--primary);
}

.stat-card strong {
  font-size: 30px;
  line-height: 1;
}

.split-grid {
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

.data-list {
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}

.data-list > div {
  min-height: 68px;
  background: #fbfdff;
}

.message-feed,
.chat-stream {
  max-width: 980px;
}

.chat-stream {
  margin: 0 auto;
  padding: 8px;
  border: 1px solid #e5edf7;
  border-radius: 8px;
  background: #f8fbff;
}

.chat-bubble {
  border-radius: 8px;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.04);
}

.broadcast-layout {
  grid-template-columns: minmax(360px, 1.05fr) minmax(340px, 0.95fr) minmax(300px, 0.8fr);
}

.broadcast-form label,
.broadcast-preview label {
  font-weight: 700;
}

.broadcast-checkbox-inline,
.bot-checkbox-inline,
.checkbox-line {
  display: inline-flex !important;
  align-items: center;
  gap: 8px !important;
}

.broadcast-actions {
  padding-top: 12px;
  border-top: 1px solid #eef2f7;
}

.broadcast-detail-filter {
  grid-template-columns: 140px minmax(240px, 1fr) auto auto;
}

.settings-grid,
.bot-ui-page,
.bot-config-layout {
  display: grid;
  gap: 16px;
}

.settings-grid {
  grid-template-columns: repeat(2, minmax(320px, 1fr));
}

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

.security-form {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  align-items: end;
}

.reset-password-form {
  padding: 8px;
  border: 1px solid #fee2e2;
  border-radius: 8px;
  background: #fff7f7;
}

.reset-password-form input {
  width: 128px;
}

.bot-ui-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}

.bot-template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
}

.bot-template-field,
.button-slot {
  min-width: 0;
}

.bot-template-field textarea {
  min-height: 128px;
}

.bot-file-field {
  display: grid;
  gap: 8px;
}

.bot-preview-inline .tg-mini-viewport {
  border: 1px solid #dbeafe;
  border-radius: 8px;
  padding: 12px;
}

.bot-preview-media,
.tg-mini-media {
  width: 100%;
  border-radius: 8px;
}

.log-content {
  max-width: 360px;
}

.empty-state,
.empty {
  color: #64748b;
  font-size: 13px;
}

@media (max-width: 1280px) {
  .broadcast-layout,
  .settings-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .page-head {
    min-height: auto;
    padding: 15px;
  }

  .page-head h1 {
    font-size: 22px;
  }

  .filter-grid,
  .security-form,
  .broadcast-detail-filter {
    grid-template-columns: 1fr;
  }

  .action-row-nowrap {
    flex-wrap: wrap;
  }

  .inline-form select,
  .inline-form input,
  .action-row select,
  .action-row input {
    width: 100%;
    max-width: none;
  }
}
