:root {
  --bg: #070911;
  --sidebar: #0b0f1d;
  --panel: #101423;
  --panel-2: #0d111f;
  --panel-3: #151a2c;
  --ink: #f4f6ff;
  --muted: #8a91a6;
  --soft: #b9bfd2;
  --line: #22283b;
  --line-soft: rgba(255, 255, 255, 0.055);
  --purple: #705cff;
  --purple-2: #8b7cff;
  --green: #62d6ae;
  --green-dark: #1f7c66;
  --blue: #5a8bff;
  --amber: #d59b3d;
  --red: #e06666;
  --shadow: 0 22px 55px rgba(0, 0, 0, 0.34);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", Tahoma, sans-serif;
}

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

button {
  min-height: 38px;
  border: 1px solid rgba(112, 92, 255, 0.28);
  border-radius: 8px;
  background: rgba(112, 92, 255, 0.18);
  color: var(--ink);
  padding: 0 13px;
  cursor: pointer;
  white-space: nowrap;
}

.button-link {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(112, 92, 255, 0.28);
  border-radius: 8px;
  background: rgba(112, 92, 255, 0.18);
  color: var(--ink);
  padding: 0 13px;
  text-decoration: none;
  white-space: nowrap;
}

.button-link:hover {
  border-color: rgba(112, 92, 255, 0.58);
  background: rgba(112, 92, 255, 0.28);
}

button:hover:not(:disabled) {
  border-color: rgba(112, 92, 255, 0.58);
  background: rgba(112, 92, 255, 0.28);
}

.danger-button {
  border-color: rgba(224, 102, 102, 0.28);
  background: rgba(224, 102, 102, 0.12);
}

.danger-button:hover:not(:disabled) {
  border-color: rgba(224, 102, 102, 0.58);
  background: rgba(224, 102, 102, 0.22);
}

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

input,
select,
textarea {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0d1120;
  color: var(--ink);
  outline: none;
}

input,
select {
  min-height: 40px;
  padding: 0 12px;
}

textarea {
  min-height: 92px;
  padding: 10px 12px;
  resize: vertical;
}

input::placeholder,
textarea::placeholder {
  color: #646b80;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(112, 92, 255, 0.74);
  box-shadow: 0 0 0 3px rgba(112, 92, 255, 0.14);
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin: 0;
  font-size: 1.35rem;
  line-height: 1.1;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 0.98rem;
  line-height: 1.2;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  border-right: 1px solid var(--line);
  background: var(--sidebar);
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding: 20px 14px 12px;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 0 5px 24px;
}

.brand-mark {
  width: 39px;
  height: 39px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(145deg, #5d6bff, #8b55ff);
  box-shadow: 0 12px 28px rgba(112, 92, 255, 0.36);
}

.brand strong,
.sidebar-user strong {
  display: block;
  color: #fff;
  font-size: 0.98rem;
}

.brand span,
.sidebar-user span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  margin-top: 2px;
}

.side-nav {
  overflow: auto;
  padding-right: 2px;
}

.nav-label {
  margin: 14px 7px 10px;
  color: #767d91;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.tab-button {
  width: 100%;
  min-height: 39px;
  margin: 2px 0;
  border: 1px solid transparent;
  background: transparent;
  color: var(--soft);
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  padding: 0 10px;
  font-weight: 700;
  text-align: left;
}

.tab-button:hover:not(:disabled) {
  border-color: rgba(112, 92, 255, 0.18);
  background: rgba(112, 92, 255, 0.09);
}

.tab-button.active {
  border-color: rgba(112, 92, 255, 0.26);
  background: rgba(112, 92, 255, 0.18);
  color: #fff;
  box-shadow: inset 3px 0 0 var(--purple);
}

.nav-icon {
  width: 22px;
  color: #a6acc0;
  text-align: center;
}

.sidebar-user {
  border-top: 1px solid var(--line);
  padding: 16px 4px 0;
  display: grid;
  grid-template-columns: 34px 1fr 34px;
  gap: 10px;
  align-items: center;
}

.avatar,
.icon-button {
  width: 34px;
  height: 34px;
  min-height: 34px;
  border-radius: 8px;
  display: grid;
  place-items: center;
}

.avatar {
  background: #202647;
  color: #c8c5ff;
  font-weight: 900;
}

.icon-button {
  padding: 0;
  border-color: var(--line);
  background: #101526;
  color: var(--muted);
}

.main-shell {
  min-width: 0;
  background:
    radial-gradient(circle at 78% 0%, rgba(112, 92, 255, 0.08), transparent 28%),
    var(--bg);
}

.topbar {
  min-height: 66px;
  border-bottom: 1px solid var(--line);
  background: rgba(8, 11, 20, 0.92);
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(260px, 422px) auto;
  gap: 20px;
  align-items: center;
  padding: 0 24px;
}

.global-search {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #101423;
  display: grid;
  grid-template-columns: 34px 1fr;
  align-items: center;
  color: #697086;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.global-search input {
  min-height: 40px;
  border: 0;
  background: transparent;
  box-shadow: none;
  padding-left: 0;
}

.global-search span {
  text-align: center;
}

.local-pill {
  min-height: 34px;
  border: 1px solid rgba(98, 214, 174, 0.2);
  border-radius: 999px;
  background: rgba(35, 150, 122, 0.16);
  color: var(--green);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  font-size: 0.82rem;
  font-weight: 800;
}

.local-pill span {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(98, 214, 174, 0.12);
}

.stats-strip {
  display: none;
}

.content {
  width: min(1054px, calc(100% - 48px));
  margin: 24px auto 0;
}

.content.wide-content {
  width: calc(100% - 32px);
  max-width: none;
  margin: 24px 16px 0;
}

.token-panel {
  width: min(1054px, calc(100% - 48px));
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 12px;
  margin: 14px auto 0;
}

.hidden {
  display: none !important;
}

.view-panel {
  display: none;
}

.view-panel.active {
  display: grid;
  gap: 30px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel-head,
.message-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 18px 12px;
  border-bottom: 1px solid var(--line-soft);
}

.panel-head.compact {
  padding-bottom: 10px;
}

.panel-head.compact > div:first-child {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}

.panel-note {
  color: #6f768a;
  font-size: 0.78rem;
}

.eyebrow {
  margin: 0 0 5px;
  color: #6f768a;
  font-size: 0.7rem;
  font-weight: 900;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.head-actions,
.table-filters,
.row-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

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

.metric-card {
  min-height: 112px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, #121728, #0f1322);
  padding: 15px;
}

.metric-card span,
.metric-card em {
  color: var(--muted);
  font-style: normal;
}

.metric-card strong {
  display: block;
  margin: 9px 0 4px;
  color: #fff;
  font-size: 1.75rem;
  line-height: 1;
}

#dashboardView {
  gap: 18px;
}

#dashboardView .metric-grid {
  grid-template-columns: repeat(4, minmax(170px, 1fr));
}

.dashboard-command .panel-head {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) auto;
  align-items: start;
}

.dashboard-filter-bar {
  display: grid;
  grid-template-columns: auto 172px auto;
  gap: 10px;
  align-items: center;
}

.segmented-control {
  min-height: 40px;
  display: inline-grid;
  grid-template-columns: repeat(3, minmax(68px, 1fr));
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0c1020;
}

.segmented-control button {
  min-height: 38px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}

.segmented-control button.active {
  background: rgba(98, 214, 174, 0.16);
  color: var(--green);
  box-shadow: inset 0 0 0 1px rgba(98, 214, 174, 0.24);
}

.dashboard-period-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 12px;
  padding: 14px 18px 18px;
  border-top: 1px solid var(--line-soft);
  background: rgba(255, 255, 255, 0.012);
}

.dashboard-period-summary article,
.revenue-comparison-list article {
  min-height: 78px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: #0d1221;
  padding: 12px;
}

.dashboard-period-summary span,
.revenue-comparison-list span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.dashboard-period-summary strong,
.revenue-comparison-list strong {
  display: block;
  margin-top: 6px;
  color: #fff;
  font-size: 1.1rem;
}

.dashboard-period-summary em {
  display: block;
  margin-top: 4px;
  color: var(--soft);
  font-size: 0.82rem;
  font-style: normal;
}

.dashboard-insight-grid {
  display: grid;
  grid-template-columns: minmax(360px, 0.92fr) minmax(420px, 1.08fr);
  gap: 18px;
}

.revenue-body {
  display: grid;
  grid-template-columns: minmax(210px, 0.85fr) minmax(260px, 1fr);
  gap: 18px;
  align-items: center;
  padding: 18px;
}

.donut-wrap {
  min-height: 260px;
  display: grid;
  place-items: center;
}

.revenue-donut {
  --ratio: 0;
  --tone: var(--green);
  width: min(230px, 100%);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background:
    conic-gradient(var(--tone) calc(var(--ratio) * 1%), rgba(255, 255, 255, 0.08) 0),
    #0d1221;
  box-shadow: inset 0 0 0 1px var(--line), 0 18px 34px rgba(0, 0, 0, 0.24);
}

.revenue-donut > div {
  width: 68%;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  align-content: center;
  border-radius: 999px;
  background: #101423;
  text-align: center;
  padding: 12px;
}

.revenue-donut strong {
  color: #fff;
  font-size: 2rem;
  line-height: 1;
}

.revenue-donut span {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
}

.revenue-comparison-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(120px, 1fr));
  gap: 10px;
}

.trend-value {
  font-weight: 900;
}

.trend-up {
  color: var(--green) !important;
}

.trend-down {
  color: var(--red) !important;
}

.trend-flat {
  color: var(--amber) !important;
}

.revenue-bars {
  min-height: 300px;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(66px, 1fr);
  gap: 10px;
  align-items: end;
  overflow-x: auto;
  padding: 18px;
}

.revenue-bar-item {
  min-width: 66px;
  display: grid;
  grid-template-rows: 1fr auto auto;
  gap: 8px;
  align-items: end;
  text-align: center;
}

.revenue-bar-track {
  height: 190px;
  display: flex;
  align-items: end;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: #0d1221;
  overflow: hidden;
}

.revenue-bar-track span {
  width: 100%;
  min-height: 6px;
  display: block;
  border-radius: 8px 8px 0 0;
  background: linear-gradient(180deg, var(--green), var(--blue));
}

.revenue-bar-item strong {
  color: #fff;
  font-size: 0.78rem;
  line-height: 1.2;
}

.revenue-bar-item em {
  color: var(--muted);
  font-size: 0.76rem;
  font-style: normal;
}

.visit-analytics {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.visit-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 10px;
}

.visit-summary-grid article {
  min-height: 86px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: #0d1221;
  padding: 12px;
}

.visit-summary-grid span,
.visit-list span {
  display: block;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
}

.visit-summary-grid strong {
  display: block;
  margin-top: 7px;
  color: #fff;
  font-size: 1.32rem;
  line-height: 1;
}

.visit-summary-grid em {
  display: block;
  margin-top: 7px;
  color: var(--soft);
  font-size: 0.78rem;
  font-style: normal;
}

.visit-timeline-chart {
  min-height: 220px;
  display: grid;
  grid-template-columns: repeat(24, minmax(20px, 1fr));
  gap: 6px;
  align-items: end;
  overflow: hidden;
  padding: 12px 4px 4px;
}

.visit-bar-item {
  display: grid;
  grid-template-rows: 1fr auto auto;
  gap: 6px;
  align-items: end;
  text-align: center;
}

.visit-bar-track {
  height: 132px;
  display: flex;
  align-items: end;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: #0d1221;
  overflow: hidden;
}

.visit-bar-track span {
  width: 100%;
  min-height: 4px;
  display: block;
  border-radius: 8px 8px 0 0;
  background: linear-gradient(180deg, var(--green), var(--blue));
}

.visit-bar-item.is-peak .visit-bar-track {
  border-color: rgba(213, 155, 61, 0.48);
  box-shadow: 0 0 0 2px rgba(213, 155, 61, 0.1);
}

.visit-bar-item.is-peak .visit-bar-track span {
  background: linear-gradient(180deg, var(--amber), var(--green));
}

.visit-bar-item strong {
  color: #fff;
  font-size: 0.78rem;
  line-height: 1;
}

.visit-bar-item em {
  color: var(--muted);
  font-size: 0.72rem;
  font-style: normal;
  min-height: 14px;
}

.visit-detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  align-items: start;
  min-height: 0;
}

.visit-detail-grid > section {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.visit-detail-grid h3 {
  margin: 0 0 10px;
  color: #dfe4f7;
  font-size: 0.9rem;
}

.visit-list {
  display: grid;
  align-content: start;
  gap: 8px;
  max-height: 230px;
  min-height: 120px;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 4px;
  overscroll-behavior: contain;
  scrollbar-color: rgba(98, 214, 174, 0.44) rgba(255, 255, 255, 0.04);
  scrollbar-width: thin;
}

#visitLocationsList,
#visitLatestList {
  max-height: 230px;
  min-height: 120px;
  overflow-y: auto;
  overflow-x: hidden;
}

.visit-list article {
  min-height: 58px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: rgba(13, 18, 33, 0.78);
  padding: 10px;
}

.visit-list strong {
  display: block;
  color: #fff;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.visit-list span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.visit-list::-webkit-scrollbar {
  width: 8px;
}

.visit-list::-webkit-scrollbar-track {
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
}

.visit-list::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(98, 214, 174, 0.48);
}

.visit-list::-webkit-scrollbar-thumb:hover {
  background: rgba(98, 214, 174, 0.72);
}

.visit-list b {
  color: var(--green);
  font-size: 0.86rem;
}

.split-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 22px;
}

.crm-grid {
  display: grid;
  grid-template-columns: minmax(305px, 370px) 1fr;
  gap: 22px;
  align-items: start;
}

.conversation-pane {
  min-height: calc(100vh - 118px);
}

.search-input,
.phone-filter {
  width: calc(100% - 32px);
  margin: 14px 16px 0;
}

.phone-filter {
  margin-bottom: 14px;
}

.conversation-list {
  height: calc(100vh - 362px);
  overflow: auto;
  padding: 0 10px 12px;
}

.conversation-item {
  width: 100%;
  min-height: 78px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.025);
  color: var(--ink);
  display: block;
  text-align: left;
  margin-bottom: 8px;
  padding: 10px;
}

.conversation-item:hover {
  background: rgba(112, 92, 255, 0.08);
}

.conversation-item.active {
  border-color: rgba(112, 92, 255, 0.55);
  box-shadow: inset 3px 0 0 var(--purple);
}

.conversation-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-weight: 800;
}

.conversation-preview {
  margin-top: 6px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.badge {
  min-width: 24px;
  height: 24px;
  border-radius: 999px;
  background: var(--purple);
  color: #fff;
  display: inline-grid;
  place-items: center;
  font-size: 0.78rem;
}

.muted {
  color: var(--muted);
  font-size: 0.88rem;
}

.message-pane {
  min-height: calc(100vh - 118px);
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.message-list {
  height: calc(100vh - 246px);
  overflow: auto;
  padding: 16px;
}

.message-bubble {
  max-width: min(720px, 88%);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 10px;
  background: rgba(255, 255, 255, 0.035);
}

.message-bubble.outgoing {
  margin-left: auto;
  border-color: rgba(90, 139, 255, 0.32);
  background: rgba(90, 139, 255, 0.1);
}

.message-bubble.incoming {
  border-color: rgba(98, 214, 174, 0.3);
  background: rgba(98, 214, 174, 0.08);
}

.message-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
}

.message-body {
  margin: 0;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.reply-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 14px;
  border-top: 1px solid var(--line-soft);
}

.table-wrap {
  width: 100%;
  max-width: 100%;
  max-height: clamp(260px, calc(100vh - 280px), 620px);
  min-height: 220px;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-color: rgba(98, 214, 174, 0.42) rgba(255, 255, 255, 0.04);
  scrollbar-width: thin;
}

.table-wrap::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

.table-wrap::-webkit-scrollbar-track {
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.035);
}

.table-wrap::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(98, 214, 174, 0.68), rgba(90, 139, 255, 0.62));
}

.table-wrap::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, rgba(98, 214, 174, 0.9), rgba(90, 139, 255, 0.82));
}

.table-wrap thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #101423;
  box-shadow: 0 1px 0 var(--line-soft);
}

#webhookEventsTable {
  max-height: 300px;
  min-height: 190px;
}

#ordersTable,
#sessionsTable {
  max-height: calc(100vh - 220px);
  min-height: 380px;
}

#usersTable {
  max-height: calc(100vh - 360px);
  min-height: clamp(430px, calc(100vh - 364px), 563px);
}

#usersView table {
  min-width: 1180px;
}

#productsView.active {
  gap: 18px;
}

#productsView .split-grid {
  grid-template-columns: minmax(380px, 0.82fr) minmax(460px, 1.18fr);
}

#productsTable table {
  min-width: 1080px;
}

#categoriesTable table {
  min-width: 720px;
}

#productsView .table-filters {
  flex-wrap: wrap;
  justify-content: flex-end;
}

#productCategoryFilter,
#productStatusFilter {
  min-width: 178px;
}

#categoriesTable {
  max-height: 360px;
  min-height: 260px;
}

#productsTable {
  max-height: calc(100vh - 390px);
  min-height: clamp(430px, calc(100vh - 390px), 563px);
}

#stockTable {
  max-height: calc(100vh - 430px);
  min-height: 320px;
}

#transactionsTable {
  max-height: 320px;
  min-height: 220px;
}

#transactionsView .panel:not(:first-child) .table-wrap {
  max-height: 260px;
  min-height: 190px;
}

#phonesView .table-wrap {
  max-height: calc(100vh - 380px);
  min-height: 430px;
  overflow: auto;
}

#phonesView table {
  min-width: 1360px;
}

#phonesView thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #101423;
}

.inline-form {
  display: grid;
  grid-template-columns: repeat(7, minmax(120px, 1fr)) auto;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line-soft);
  background: rgba(255, 255, 255, 0.018);
}

.import-form {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto minmax(180px, 1fr);
  gap: 10px;
  align-items: center;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line-soft);
  background: rgba(255, 255, 255, 0.012);
}

.bulk-actions {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto auto;
  gap: 10px;
  align-items: center;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line-soft);
  background: rgba(224, 102, 102, 0.035);
}

.phone-tools,
.user-tools {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto auto;
  gap: 10px;
  align-items: center;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line-soft);
  background: rgba(255, 255, 255, 0.012);
}

.user-tools {
  grid-template-columns: minmax(180px, 1fr) auto;
}

.pagination-bar {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px 18px;
  border-top: 1px solid var(--line-soft);
  background: rgba(255, 255, 255, 0.012);
}

.pagination-pages {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

.pagination-pages button {
  min-width: 36px;
  min-height: 34px;
  padding: 0 10px;
  border-color: var(--line);
  background: #0d1120;
}

.pagination-pages button.active {
  border-color: rgba(112, 92, 255, 0.7);
  background: rgba(112, 92, 255, 0.32);
  color: #fff;
}

.pagination-ellipsis {
  display: inline-flex;
  min-width: 22px;
  justify-content: center;
  color: var(--muted);
  font-weight: 900;
}

.select-cell {
  width: 42px;
  text-align: center;
}

.select-cell input {
  min-height: auto;
}

.stack-form,
.stock-form {
  display: grid;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line-soft);
  background: rgba(255, 255, 255, 0.018);
}

.stock-form {
  grid-template-columns: minmax(220px, 0.45fr) minmax(320px, 1fr) auto;
  align-items: start;
}

.checkbox-line {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--soft);
  font-weight: 800;
}

.checkbox-line input {
  min-height: auto;
  width: 16px;
  height: 16px;
}

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

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

th {
  color: #6f768a;
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

td {
  color: #d8dcef;
  font-size: 0.88rem;
  overflow-wrap: anywhere;
}

td strong,
td span {
  display: block;
  overflow-wrap: anywhere;
}

td span {
  color: var(--muted);
  font-size: 0.82rem;
}

.empty-row {
  height: 76px;
  color: #747b8f;
  text-align: center;
  vertical-align: middle;
}

.row-actions {
  justify-content: flex-end;
}

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

.status {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  border-radius: 999px;
  padding: 0 10px;
  font-size: 0.78rem;
  font-weight: 900;
  color: #07110f;
  background: var(--muted);
}

.status.active,
.status.completed,
.status.available,
.status.topup,
.status.refund {
  background: var(--green);
}

.status.waiting,
.status.charge,
.status.order_charge,
.status.admin_adjust {
  color: #fff;
  background: var(--blue);
}

.status.blocked,
.status.hidden,
.status.disabled,
.status.cancelled {
  color: #fff;
  background: var(--red);
}

.status.sold {
  background: var(--amber);
}

.status.expired {
  background: var(--amber);
}

.money-plus {
  color: var(--green);
  font-weight: 900;
}

.money-minus {
  color: var(--red);
  font-weight: 900;
}

.settings-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 14px;
  padding: 18px;
}

.settings-form label,
.system-field {
  display: grid;
  gap: 7px;
  color: var(--soft);
  font-weight: 800;
}

.settings-form .wide {
  grid-column: 1 / -1;
}

.system-config-form {
  padding: 18px;
}

.system-config-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 14px;
}

.system-group {
  grid-column: 1 / -1;
  margin: 6px 0 -2px;
  color: #6f768a;
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.system-field small {
  min-height: 18px;
  color: #747b8f;
  font-weight: 700;
}

.system-field.changed small {
  color: var(--green);
}

.restart-note {
  color: var(--amber);
}

.telegram-token-form {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto minmax(190px, 0.9fr);
  gap: 12px;
  align-items: end;
  padding: 16px 18px 0;
}

.telegram-token-form label {
  display: grid;
  gap: 7px;
  color: var(--soft);
  font-weight: 800;
}

.telegram-token-form .panel-note {
  align-self: center;
  min-width: 0;
  overflow-wrap: anywhere;
}

.telegram-status-grid {
  display: grid;
  grid-template-columns: 0.9fr 0.65fr 1.45fr;
  gap: 12px;
  padding: 18px;
}

.webhook-status-grid {
  display: grid;
  grid-template-columns: 0.75fr 0.75fr 1.5fr;
  gap: 12px;
  padding: 18px;
  border-bottom: 1px solid var(--line-soft);
}

.telegram-status-item {
  min-height: 82px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.026);
  padding: 13px;
}

.telegram-status-item span {
  display: block;
  color: #747b8f;
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.telegram-status-item strong {
  display: block;
  margin-top: 8px;
  color: #eef1ff;
  font-size: 0.95rem;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.telegram-status-item small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.76rem;
}

.telegram-status-summary.ok {
  color: var(--green);
}

.telegram-status-summary.warn {
  color: var(--amber);
}

.telegram-status-summary.error {
  color: var(--red);
}

.telegram-menu-builder {
  display: grid;
  gap: 0;
}

.telegram-menu-form {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) 120px auto;
  gap: 12px;
  align-items: end;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line-soft);
  background: rgba(255, 255, 255, 0.014);
}

.telegram-menu-item-form {
  grid-template-columns: minmax(180px, 0.8fr) minmax(200px, 1fr) minmax(170px, 0.8fr) 130px 100px minmax(150px, 0.7fr) 90px auto;
  background: rgba(98, 214, 174, 0.025);
}

.telegram-menu-form label {
  display: grid;
  gap: 7px;
  min-width: 0;
  color: var(--soft);
  font-weight: 800;
}

.telegram-menu-form label small {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.35;
}

.telegram-menu-form input,
.telegram-menu-form select {
  width: 100%;
  min-width: 0;
}

.telegram-menu-form .wide {
  grid-column: 1 / -2;
}

.telegram-flow-note {
  padding: 11px 18px;
  border-bottom: 1px solid var(--line-soft);
  background: rgba(98, 214, 174, 0.045);
  color: #9ea9c4;
  font-size: 0.82rem;
  font-weight: 700;
}

.telegram-menu-list {
  display: grid;
  gap: 0;
  max-height: clamp(320px, calc(100vh - 380px), 620px);
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  scrollbar-color: rgba(98, 214, 174, 0.42) rgba(255, 255, 255, 0.04);
  scrollbar-width: thin;
}

.telegram-menu-list::-webkit-scrollbar {
  width: 10px;
}

.telegram-menu-list::-webkit-scrollbar-track {
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.035);
}

.telegram-menu-list::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(98, 214, 174, 0.68), rgba(90, 139, 255, 0.62));
}

.telegram-menu-group {
  border-bottom: 1px solid var(--line-soft);
}

.telegram-menu-group:last-child {
  border-bottom: 0;
}

.telegram-menu-main-row,
.telegram-menu-item-row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto minmax(230px, auto);
  gap: 12px;
  align-items: center;
}

.telegram-menu-main-row {
  padding: 14px 18px;
  background: rgba(112, 92, 255, 0.075);
}

.telegram-menu-title strong,
.telegram-menu-item-row strong {
  display: block;
  color: #f3f5ff;
  font-size: 0.96rem;
}

.telegram-menu-title span,
.telegram-menu-item-row span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.8rem;
}

.telegram-route-warning {
  display: block;
  margin-top: 6px;
  color: var(--amber);
  font-size: 0.78rem;
  font-style: normal;
  font-weight: 800;
}

.telegram-menu-items {
  display: grid;
}

.telegram-preview {
  display: grid;
  gap: 6px;
  padding: 12px 18px;
  border-top: 1px solid var(--line-soft);
  background: rgba(98, 214, 174, 0.035);
}

.telegram-preview-label {
  color: #7a8298;
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.telegram-preview-row {
  display: grid;
  grid-auto-columns: minmax(0, 1fr);
  grid-auto-flow: column;
  gap: 6px;
}

.telegram-preview-button {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(185, 191, 210, 0.16);
  border-radius: 8px;
  background: rgba(128, 154, 112, 0.28);
  color: #f2f6ea;
  padding: 0 10px;
  font-size: 0.86rem;
  font-weight: 800;
  text-align: center;
}

.telegram-menu-item-row {
  padding: 12px 18px 12px 34px;
  border-top: 1px solid var(--line-soft);
  background: rgba(255, 255, 255, 0.012);
}

.telegram-menu-empty {
  padding: 14px 18px 16px 34px;
  color: var(--muted);
  font-size: 0.86rem;
}

.telegram-menu-group.is-disabled,
.telegram-menu-item-row.is-disabled {
  opacity: 0.68;
}

.empty-state {
  min-height: 190px;
  display: grid;
  place-items: center;
  text-align: center;
  color: #747b8f;
  padding: 18px;
}

.empty-state h3 {
  color: #dfe3f5;
  margin-bottom: 8px;
}

.balance-popover {
  position: fixed;
  z-index: 50;
  width: min(340px, calc(100vw - 24px));
  border: 1px solid rgba(112, 92, 255, 0.38);
  border-radius: 8px;
  background: #101423;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.56);
  padding: 14px;
  display: grid;
  gap: 12px;
}

.balance-popover-head {
  display: grid;
  gap: 4px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line-soft);
}

.balance-popover-head strong {
  color: #fff;
  font-size: 0.98rem;
}

.balance-popover-head span {
  color: var(--muted);
  font-size: 0.78rem;
  overflow-wrap: anywhere;
}

.balance-popover label {
  display: grid;
  gap: 7px;
  color: var(--soft);
  font-size: 0.82rem;
  font-weight: 800;
}

.balance-popover input {
  width: 100%;
}

.balance-popover-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.footer-line {
  width: min(1054px, calc(100% - 48px));
  margin: 30px auto 42px;
  color: #6f768a;
  font-size: 0.78rem;
  text-align: center;
}

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

  #dashboardView .metric-grid {
    grid-template-columns: repeat(2, minmax(150px, 1fr));
  }

  .dashboard-insight-grid,
  .revenue-body {
    grid-template-columns: 1fr;
  }

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

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

@media (max-width: 1500px) and (min-width: 981px) {
  .telegram-menu-item-form {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .telegram-menu-item-form .wide {
    grid-column: 1 / -2;
  }
}

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

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

  .side-nav {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 5px;
  }

  .nav-label,
  .sidebar-user {
    display: none;
  }

  .tab-button {
    width: auto;
    min-width: max-content;
  }

  .topbar {
    grid-template-columns: 1fr;
    padding: 14px;
  }

  .content,
  .token-panel,
  .footer-line {
    width: min(100% - 28px, 1054px);
  }

  .dashboard-command .panel-head {
    grid-template-columns: 1fr;
  }

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

  .conversation-list,
  .message-list {
    height: 420px;
  }

  .conversation-pane,
  .message-pane {
    min-height: auto;
  }

  .settings-form,
  .system-config-grid,
  .dashboard-filter-bar,
  .dashboard-period-summary,
  .telegram-token-form,
  .telegram-menu-form,
  .telegram-menu-item-form,
  .webhook-status-grid,
  .telegram-status-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .token-panel,
  .reply-form,
  .stock-form,
  .inline-form,
  .import-form,
  .bulk-actions,
  .user-tools,
  .phone-tools,
  .panel-head,
  .message-head,
  .telegram-menu-main-row,
  .telegram-menu-item-row {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .panel-head,
  .message-head {
    display: grid;
  }

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

  #dashboardView .metric-grid,
  .revenue-comparison-list,
  .visit-summary-grid,
  .visit-detail-grid {
    grid-template-columns: 1fr;
  }

  .revenue-donut {
    width: min(210px, 100%);
  }

  .revenue-bars,
  .visit-timeline-chart {
    grid-template-columns: none;
    grid-auto-flow: column;
    grid-auto-columns: minmax(72px, 88px);
    overflow-x: auto;
  }

  .table-filters,
  .head-actions {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
  }

  .telegram-menu-item-row {
    padding-left: 18px;
  }
}
