:root {
  color-scheme: dark;
  --bg: #0b0b0f;
  --topbar: rgba(11, 11, 15, 0.84);
  --surface: #141419;
  --surface-2: #1a1a21;
  --surface-3: #202029;
  --text: #f5f3ee;
  --muted: #9996a3;
  --faint: #6f6c78;
  --line: rgba(255, 255, 255, 0.09);
  --line-strong: rgba(255, 255, 255, 0.15);
  --accent: #8b7cff;
  --accent-strong: #7565f5;
  --accent-soft: rgba(139, 124, 255, 0.13);
  --success: #52d6aa;
  --success-soft: rgba(82, 214, 170, 0.12);
  --danger: #ff738d;
  --danger-soft: rgba(255, 115, 141, 0.12);
  --warning: #f6bd68;
  --shadow: 0 28px 80px rgba(0, 0, 0, 0.28);
  --radius: 22px;
  --radius-sm: 14px;
  --content: 1080px;
  --nav-height: 76px;
}

html[data-theme="light"] {
  color-scheme: light;
  --bg: #f7f6f2;
  --topbar: rgba(247, 246, 242, 0.88);
  --surface: #ffffff;
  --surface-2: #f0efeb;
  --surface-3: #e8e6e0;
  --text: #17161b;
  --muted: #716e78;
  --faint: #96929c;
  --line: rgba(24, 22, 29, 0.09);
  --line-strong: rgba(24, 22, 29, 0.15);
  --accent: #6758df;
  --accent-strong: #594bc9;
  --accent-soft: rgba(103, 88, 223, 0.1);
  --success: #188c6c;
  --success-soft: rgba(24, 140, 108, 0.1);
  --danger: #d94e69;
  --danger-soft: rgba(217, 78, 105, 0.1);
  --warning: #a56b18;
  --shadow: 0 24px 70px rgba(35, 30, 48, 0.1);
}

* {
  box-sizing: border-box;
}

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

html {
  height: 100%;
  overflow: hidden;
}

body {
  height: 100%;
  min-height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  color: var(--text);
  background:
    radial-gradient(circle at 52% -14rem, color-mix(in srgb, var(--accent) 11%, transparent), transparent 38rem),
    var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  letter-spacing: -0.006em;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button,
input {
  min-width: 0;
  border: 0;
  color: inherit;
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: wait;
  opacity: 0.55;
}

svg {
  display: block;
  width: 20px;
  height: 20px;
  stroke-width: 1.8;
}

 .app {
  min-height: 100%;
}

/* Desktop navigation is a calm top toolbar, not a second dashboard column. */
.side-rail {
  position: sticky;
  inset: 0 0 auto;
  z-index: 30;
  width: 100%;
  height: var(--nav-height);
  display: flex;
  align-items: center;
  gap: 24px;
  padding:
    max(10px, var(--tg-content-safe-area-inset-top, 0px))
    max(24px, var(--tg-content-safe-area-inset-right, 0px))
    10px
    max(24px, var(--tg-content-safe-area-inset-left, 0px));
  border-bottom: 1px solid var(--line);
  background: var(--topbar);
  backdrop-filter: blur(24px) saturate(135%);
}

.brand,
.mobile-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand {
  flex: 0 0 auto;
  color: var(--text);
  text-decoration: none;
}

.brand-mark {
  width: 34px;
  height: 34px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 34px;
  overflow: visible;
  border-radius: 0;
  color: inherit;
  background: transparent;
  box-shadow: none;
}

.brand-mark > img,
.brand-avatar > img {
  width: 100%;
  height: 100%;
  display: block !important;
  object-fit: contain;
  object-position: center;
  background: transparent;
}

.brand-mark-lg {
  width: 58px;
  height: 58px;
  border-radius: 18px;
}

.brand-mark-lg > span {
  font-size: 25px;
}

.brand > span:last-child {
  display: grid;
  line-height: 1.05;
}

.brand b,
.mobile-brand b {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.brand small {
  margin-top: 4px;
  color: var(--faint);
  font-size: 9px;
  letter-spacing: 0.15em;
}

 .maintenance-screen > img {
  display: none !important;
}

.rail-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
}

.nav-item {
  position: relative;
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 14px;
  border-radius: 999px;
  color: var(--muted);
  background: transparent;
  font-size: 13px;
  font-weight: 600;
  transition: color 160ms ease, background 160ms ease, transform 160ms ease;
}

.nav-item:hover {
  color: var(--text);
  background: var(--surface-2);
}

.nav-item.active {
  color: var(--text);
  background: var(--surface-2);
}

.nav-item.active svg {
  color: var(--accent);
}

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

.presence {
  display: none;
}

.avatar,
.icon-btn {
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 40px;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--text);
  background: var(--surface-2);
}

.avatar {
  border: 0;
  color: #fff;
  background: linear-gradient(145deg, #9d90ff, #7060eb);
  font-size: 13px;
  font-weight: 700;
}

.brand-avatar {
  padding: 5px;
  overflow: hidden;
  background: transparent;
}

.workspace {
  width: 100%;
  min-width: 0;
  margin: 0;
  padding: 0 max(24px, var(--tg-content-safe-area-inset-right, 0px)) 64px max(24px, var(--tg-content-safe-area-inset-left, 0px));
}

.app-bar,
.screen {
  width: min(100%, var(--content));
  margin-inline: auto;
}

.app-bar {
  min-height: 116px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  padding: 34px 0 22px;
}

.page-heading h1 {
  margin: 0;
  font-size: clamp(28px, 3vw, 38px);
  font-weight: 600;
  line-height: 1.12;
  letter-spacing: -0.045em;
}

.page-heading p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.app-bar > .avatar {
  display: none;
}

.mobile-brand {
  display: none;
}

.screen {
  padding-top: 6px;
}

.screen-stack {
  display: grid;
  gap: 34px;
}

.columns,
.dashboard-grid,
.partner-main-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 36px;
}

.section {
  min-width: 0;
  padding: 0 0 28px;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.section:last-child {
  border-bottom-color: transparent;
}

.section.plain {
  padding: 0;
  border: 0;
}

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

.section-head h2,
.sheet-head h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.025em;
}

.section-head p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.overline {
  margin: 0 0 9px;
  color: var(--accent);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

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

/* Only the main action receives a surface. Secondary information flows below. */
.connection-panel {
  position: relative;
  min-height: 260px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 36px;
  overflow: hidden;
  padding: clamp(28px, 5vw, 56px);
  border: 0;
  border-radius: 32px;
  background:
    linear-gradient(110deg, rgba(139, 124, 255, 0.13), transparent 48%),
    linear-gradient(135deg, #191820, #131319 68%);
  box-shadow: var(--shadow);
}

html[data-theme="light"] .connection-panel {
  background:
    linear-gradient(110deg, rgba(116, 96, 235, 0.1), transparent 48%),
    linear-gradient(135deg, #ffffff, #f1eff6 78%);
}

.connection-copy {
  position: relative;
  z-index: 1;
  max-width: 720px;
}

.connection-copy h2 {
  max-width: 680px;
  margin: 0 0 14px;
  font-size: clamp(30px, 4vw, 44px);
  font-weight: 600;
  line-height: 1.06;
  letter-spacing: -0.055em;
}

.connection-copy > p {
  max-width: 540px;
  margin: 0 0 28px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.65;
}

.state-label {
  width: max-content;
  max-width: 100%;
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 16px;
  color: var(--success);
  font-size: 12px;
  font-weight: 700;
}

.status-dot,
.presence i {
  width: 7px;
  height: 7px;
  flex: 0 0 7px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 5px var(--success-soft);
}

.state-label.expired {
  color: var(--danger);
}

.state-label.expired .status-dot {
  background: var(--danger);
  box-shadow: 0 0 0 5px var(--danger-soft);
}

.button-row,
.hero-actions,
.hero-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.hero-actions {
  max-width: 520px;
}

.hero-tools {
  flex: 1 1 auto;
}

.primary-btn,
.secondary-btn,
.danger-btn,
.icon-action,
.text-btn,
.small-btn {
  min-height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 0 18px;
  border-radius: 14px;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  transition: transform 150ms ease, background 150ms ease, color 150ms ease;
}

.primary-btn {
  color: #fff;
  background: var(--accent-strong);
  box-shadow: 0 12px 30px rgba(117, 101, 245, 0.2);
}

.primary-btn:hover {
  background: var(--accent);
  transform: translateY(-1px);
}

.primary-btn-lg {
  min-height: 54px;
  padding-inline: 24px;
  font-size: 14px;
}

.secondary-btn,
.icon-action {
  border: 1px solid var(--line-strong);
  color: var(--text);
  background: transparent;
}

.secondary-btn:hover,
.icon-action:hover {
  background: var(--surface-2);
}

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

.text-btn {
  min-height: 36px;
  margin-top: 14px;
  padding: 0;
  color: var(--accent);
  background: transparent;
}

.small-btn {
  width: 40px;
  height: 40px;
  min-height: 40px;
  padding: 0;
  border-radius: 50%;
  color: var(--danger);
  background: var(--danger-soft);
}

.wide {
  width: 100%;
}

/* Summary values live in a single strip instead of isolated boxes. */
.compact-metrics,
.partner-kpis,
.stats-row,
.metric-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  overflow: hidden;
  border-radius: 20px;
  background: var(--surface);
}

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

.compact-metric,
.partner-kpi,
.stat,
.metric-tile {
  min-width: 0;
  min-height: 94px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 20px;
  border-right: 1px solid var(--line);
  background: transparent;
}

.compact-metric:last-child,
.partner-kpi:last-child,
.stat:last-child,
.metric-tile:last-child {
  border-right: 0;
}

.compact-metric-icon,
.partner-kpi > span,
.metric-icon,
.row-icon,
.device-card-icon,
.team-level,
.expiry-notice-icon {
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 38px;
  border-radius: 50%;
  color: var(--accent);
  background: var(--accent-soft);
}

.compact-metric-icon svg,
.partner-kpi > span svg,
.metric-icon svg,
.row-icon svg,
.device-card-icon svg {
  width: 18px;
  height: 18px;
}

.compact-metric > div,
.partner-kpi > div,
.metric-tile > div {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.compact-metric span:not(.compact-metric-icon),
.partner-kpi small,
.partner-kpi em,
.metric-tile span,
.metric-tile small,
.stat span {
  overflow: hidden;
  color: var(--muted);
  font-size: 10px;
  font-style: normal;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.compact-metric strong,
.partner-kpi strong,
.metric-tile strong,
.stat strong {
  overflow: hidden;
  font-size: 17px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dashboard-grid {
  gap: 46px;
}

.lte-card,
.renewal-card {
  min-height: 220px;
  display: flex;
  flex-direction: column;
}

.lte-card .progress-wrap,
.renewal-card .wide {
  margin-top: auto;
}

.progress-wrap {
  display: grid;
  gap: 10px;
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 11px;
}

.progress {
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-3);
}

.progress i {
  height: 100%;
  display: block;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent-strong), #b79eff);
}

.expiry-notice,
.withdraw-note,
.bonus-nudge {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 14px 16px;
  border-radius: 16px;
  color: var(--muted);
  background: var(--surface);
}

.expiry-notice > div,
.withdraw-note span,
.bonus-nudge > span:nth-child(2) {
  min-width: 0;
  flex: 1;
}

.expiry-notice h3,
.expiry-notice p,
.bonus-nudge strong,
.bonus-nudge small {
  margin: 0;
}

.expiry-notice p,
.bonus-nudge small {
  color: var(--muted);
  font-size: 12px;
}

.bonus-nudge {
  width: 100%;
  color: var(--text);
  text-align: left;
}

.bonus-nudge .chevron,
.list-row .chevron {
  color: var(--faint);
}

/* Lists use rhythm and separators. No nested tile wall. */
.list,
.device-list,
.history-list,
.detail-list,
.level-breakdown,
.partner-team-list {
  display: grid;
}

.list-row,
.device-row,
.device-card,
.history-row,
.detail-row,
.level-breakdown-row,
.partner-team-row {
  min-width: 0;
  min-height: 64px;
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
}

.list-row:last-child,
.device-row:last-child,
.device-card:last-child,
.history-row:last-child,
.detail-row:last-child,
.level-breakdown-row:last-child,
.partner-team-row:last-child {
  border-bottom: 0;
}

button.list-row {
  width: 100%;
  color: inherit;
  text-align: left;
}

.list-row > div,
.device-info,
.device-card-copy,
.history-row > div,
.partner-team-row > span:nth-child(2) {
  min-width: 0;
  flex: 1;
}

.list-row h3,
.list-row p,
.device-info h3,
.device-info p,
.device-card h3,
.device-card p,
.history-row p {
  margin: 0;
}

.list-row h3,
.device-info h3,
.device-card h3 {
  font-size: 13px;
  font-weight: 600;
}

.list-row p,
.device-info p,
.device-card p,
.history-row p,
.device-card small,
.partner-team-row small,
.level-breakdown-row small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

.device-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
}

.device-card-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.device-card-title h3 {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.device-card-title span {
  color: var(--faint);
  font-size: 10px;
}

.steps-list {
  display: grid;
  gap: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}

.steps-list li {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.steps-list li:last-child {
  border-bottom: 0;
}

.steps-list li > span {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  flex: 0 0 30px;
  border-radius: 50%;
  color: var(--accent);
  background: var(--accent-soft);
  font-size: 11px;
  font-weight: 700;
}

.steps-list p {
  margin: 0;
  color: var(--muted);
}

.empty-state {
  min-height: 260px;
  display: grid;
  place-items: center;
  text-align: center;
}

.empty-state > div {
  max-width: 440px;
}

.empty-state > div > svg {
  width: 42px;
  height: 42px;
  margin: 0 auto 14px;
  color: var(--accent);
}

.empty-state h2,
.empty-state p {
  margin: 0;
}

.empty-state p {
  margin-top: 8px;
  color: var(--muted);
}

/* Partner analytics: editorial hierarchy with one data canvas. */
.partner-dashboard {
  gap: 30px;
}

.partner-hero {
  min-height: 270px;
}

.partner-balance {
  position: relative;
  z-index: 1;
  min-width: 230px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  padding-left: 34px;
  border-left: 1px solid var(--line-strong);
}

.partner-balance span,
.partner-balance small {
  color: var(--muted);
  font-size: 11px;
}

.partner-balance strong {
  margin: 8px 0 5px;
  font-size: clamp(30px, 4vw, 44px);
  font-weight: 600;
  letter-spacing: -0.05em;
}

.period-switch,
.metric-switch {
  width: max-content;
  max-width: 100%;
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: 999px;
  background: var(--surface);
}

.period-switch button,
.metric-switch button {
  min-height: 38px;
  padding: 0 16px;
  border-radius: 999px;
  color: var(--muted);
  background: transparent;
  font-size: 11px;
  font-weight: 600;
}

.period-switch button.active,
.metric-switch button.active {
  color: #fff;
  background: var(--accent-strong);
}

.partner-main-grid {
  grid-template-columns: minmax(0, 1fr) 270px;
  align-items: start;
  gap: 42px;
}

.partner-analytics,
.partner-rates {
  padding-bottom: 0;
  border-bottom: 0;
}

.analytics-heading {
  margin-bottom: 15px;
}

.partner-line-chart {
  width: 100%;
  overflow: hidden;
}

.partner-line-chart svg {
  width: 100%;
  height: auto;
  aspect-ratio: 820 / 300;
}

.chart-grid-line {
  stroke: var(--line);
  stroke-width: 1;
}

.chart-axis-label,
.chart-date-label {
  fill: var(--faint);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 10px;
}

.chart-series-line {
  fill: none;
  stroke: var(--series-color);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chart-point {
  fill: var(--bg);
  stroke: var(--series-color);
  stroke-width: 2.5;
}

.chart-legend {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 22px;
  margin-top: 8px;
  border-top: 1px solid var(--line);
}

.chart-legend-item {
  min-width: 0;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.chart-legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--series-color);
}

.chart-legend-item > span:nth-child(2) {
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.chart-legend-item b,
.chart-legend-item strong {
  font-size: 11px;
  font-weight: 600;
}

.chart-legend-item small {
  color: var(--faint);
  font-size: 9px;
}

.level-rate-grid {
  display: grid;
}

.level-rate-grid > div {
  min-height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.level-rate-grid span {
  color: var(--muted);
  font-size: 11px;
}

.level-rate-grid strong {
  font-size: 17px;
  font-weight: 600;
}

.level-rate-grid > div.enabled strong,
.level-rate-grid > div:first-child strong {
  color: var(--accent);
}

.partner-rule-note {
  margin: 16px 0 0;
  font-size: 10px;
  line-height: 1.6;
}

.level-breakdown-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
}

.level-breakdown-row > span {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.level-breakdown-row > span:last-child {
  text-align: right;
}

.level-breakdown-row b,
.partner-team-row b,
.partner-team-row > strong {
  font-size: 13px;
  font-weight: 600;
}

.partner-team-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
}

.team-level {
  color: var(--accent);
  font-size: 10px;
  font-weight: 700;
}

.rev-share-value {
  width: max-content;
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 0 0 20px;
  color: var(--muted);
}

.rev-share-value strong {
  color: var(--accent);
  font-size: 24px;
}

.referral-link {
  display: flex;
  align-items: center;
  gap: 12px;
}

.referral-link code {
  min-width: 0;
  flex: 1;
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.withdraw-note.ready {
  color: var(--success);
  background: var(--success-soft);
}

/* Profile, checkout and sheets. */
.theme-options {
  display: flex;
  gap: 8px;
}

.theme-option {
  min-height: 42px;
  padding: 0 16px;
  border-radius: 999px;
  color: var(--muted);
  background: var(--surface);
}

.theme-option.active {
  color: #fff;
  background: var(--accent-strong);
}

.field-row {
  display: flex;
  gap: 8px;
}

.field-row input {
  min-height: 46px;
  flex: 1;
  padding: 0 15px;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  outline: none;
  background: var(--surface);
}

.field-row input:focus {
  border-color: var(--accent);
}

.sheet-layer {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: end center;
  padding: 20px;
}

.sheet-layer[hidden] {
  display: none;
}

.sheet-backdrop {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.58);
  backdrop-filter: blur(8px);
}

.sheet {
  position: relative;
  z-index: 1;
  width: min(100%, 620px);
  max-height: min(82dvh, 760px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 26px;
  background: var(--surface);
  box-shadow: 0 30px 100px rgba(0, 0, 0, 0.45);
}

.sheet-handle {
  display: none;
}

 .sheet-head {
  flex: 0 0 auto;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
}

.sheet-head p {
  margin-bottom: 5px;
}

 .sheet-body {
  min-width: 0;
  min-height: 0;
  flex: 1 1 auto;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}

.tariff-scroll {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}

.tariff-option,
.payment-option,
.selected-plan,
.checkout-summary {
  min-width: 0;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface-2);
}

.tariff-option {
  min-height: 112px;
  display: grid;
  gap: 4px;
  color: var(--muted);
  text-align: left;
}

.tariff-option b {
  color: var(--text);
  font-size: 16px;
}

.tariff-option em {
  width: max-content;
  color: var(--accent);
  font-size: 9px;
  font-style: normal;
  font-weight: 700;
  text-transform: uppercase;
}

.tariff-option.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.selected-plan,
.checkout-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin: 14px 0;
}

.selected-plan h3,
.selected-plan p,
.checkout-summary h3,
.checkout-summary p {
  margin: 0;
}

.plan-price {
  font-size: 21px;
  font-weight: 600;
}

.payment-list {
  display: grid;
  gap: 0;
}

.payment-option {
  width: 100%;
  min-height: 60px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  text-align: left;
}

.payment-option:last-child {
  border-bottom: 0;
}

.qr-wrap {
  display: grid;
  place-items: center;
  gap: 15px;
  text-align: center;
}

.qr-wrap img,
.qr-wrap canvas {
  max-width: min(100%, 320px);
  border-radius: 18px;
}

.danger-confirm {
  text-align: center;
}

.danger-confirm-icon {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  margin: 0 auto;
  border-radius: 50%;
  color: var(--danger);
  background: var(--danger-soft);
}

.danger-confirm h3 {
  margin: 16px 0 6px;
}

.danger-confirm p {
  margin: 0 0 18px;
  color: var(--muted);
}

.toast {
  position: fixed;
  z-index: 100;
  left: 50%;
  bottom: 24px;
  min-height: 46px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 16px;
  border-radius: 999px;
  color: #fff;
  background: #25242b;
  box-shadow: var(--shadow);
  transform: translateX(-50%);
}

.toast[hidden] {
  display: none;
}

.maintenance-screen {
  min-height: 60dvh;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 12px;
  text-align: center;
}

.maintenance-screen h1,
.maintenance-screen p {
  max-width: 520px;
  margin: 0;
}

.maintenance-screen > p:not(.overline) {
  color: var(--muted);
}

.skeleton {
  position: relative;
  overflow: hidden;
  border-radius: 18px;
  background: var(--surface);
}

.skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.05), transparent);
  animation: shimmer 1.2s infinite;
}

.hero-skeleton {
  height: 300px;
}

.line-skeleton {
  width: 70%;
  height: 18px;
}

@keyframes shimmer {
  to { transform: translateX(100%); }
}

.bottom-nav {
  display: none;
}

@media (max-width: 900px) {
  .side-rail {
    gap: 14px;
  }

  .brand span:last-child {
    display: none;
  }

  .nav-item {
    padding-inline: 11px;
  }

  .partner-main-grid {
    grid-template-columns: 1fr;
  }

  .partner-rates .level-rate-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 16px;
  }

  .partner-rates .level-rate-grid > div {
    display: grid;
    align-content: center;
  }
}

@media (max-width: 700px) {
  :root {
    --radius: 18px;
    --radius-sm: 13px;
  }

  body {
    font-size: 14px;
  }

  .side-rail {
    display: none;
  }

  .workspace {
    padding:
      0
      max(16px, var(--tg-content-safe-area-inset-right, 0px))
      calc(86px + max(env(safe-area-inset-bottom), var(--tg-content-safe-area-inset-bottom, 0px)))
      max(16px, var(--tg-content-safe-area-inset-left, 0px));
  }

  .app-bar {
    position: sticky;
    top: 0;
    z-index: 25;
    min-height: 62px;
    align-items: center;
    padding: max(8px, var(--tg-content-safe-area-inset-top, 0px)) 0 8px;
    background: var(--topbar);
    backdrop-filter: blur(24px) saturate(135%);
  }

  .mobile-brand {
    display: flex;
  }

  .mobile-brand .brand-mark {
    width: 30px;
    height: 30px;
    flex-basis: 30px;
    border-radius: 10px;
  }

  .mobile-brand .brand-mark > span {
    font-size: 14px;
  }

  .page-heading {
    display: none;
  }

  .app-bar > .avatar {
    width: 36px;
    height: 36px;
    display: inline-flex;
    flex-basis: 36px;
  }

  .screen {
    padding-top: 10px;
  }

  .screen-stack,
  .partner-dashboard {
    gap: 24px;
  }

  .columns,
  .dashboard-grid,
  .partner-main-grid {
    grid-template-columns: 1fr;
    gap: 24px;
  }

  .section {
    padding-bottom: 22px;
  }

  .section-head {
    margin-bottom: 14px;
  }

  .section-head h2,
  .sheet-head h2 {
    font-size: 19px;
  }

  .connection-panel,
  .partner-hero {
    min-height: 0;
    display: block;
    padding: 28px 22px;
    border-radius: 24px;
  }

  .connection-copy h2 {
    max-width: 320px;
    margin-bottom: 11px;
    font-size: clamp(29px, 9vw, 38px);
    line-height: 1.08;
  }

  .connection-copy > p {
    margin-bottom: 22px;
    font-size: 13px;
    line-height: 1.6;
  }

  .button-row,
  .hero-actions {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr;
  }

  .hero-tools {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .primary-btn,
  .secondary-btn,
  .danger-btn,
  .icon-action {
    width: 100%;
  }

  .compact-metrics,
  .stats-row {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    border-radius: 17px;
  }

  .compact-metric,
  .stat {
    min-height: 82px;
    display: grid;
    align-content: center;
    gap: 6px;
    padding: 13px 10px;
  }

  .compact-metric-icon {
    width: 30px;
    height: 30px;
    flex-basis: 30px;
  }

  .compact-metric strong,
  .stat strong {
    font-size: 14px;
  }

  .dashboard-grid {
    gap: 22px;
  }

  .lte-card,
  .renewal-card {
    min-height: 190px;
  }

  .partner-balance {
    min-width: 0;
    margin-top: 24px;
    padding: 20px 0 0;
    border-top: 1px solid var(--line-strong);
    border-left: 0;
  }

  .partner-balance strong {
    font-size: 34px;
  }

  .period-switch,
  .metric-switch {
    width: 100%;
    display: grid;
  }

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

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

  .period-switch button,
  .metric-switch button {
    min-width: 0;
    padding-inline: 5px;
    font-size: 10px;
  }

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

  .partner-kpi,
  .metric-tile {
    min-height: 78px;
    padding: 13px;
  }

  .partner-kpi:nth-child(2),
  .metric-tile:nth-child(2) {
    border-right: 0;
  }

  .partner-kpi:nth-child(-n + 2),
  .metric-tile:nth-child(-n + 2) {
    border-bottom: 1px solid var(--line);
  }

  .partner-kpi > span,
  .metric-icon {
    width: 32px;
    height: 32px;
    flex-basis: 32px;
  }

  .partner-kpi strong,
  .metric-tile strong {
    font-size: 15px;
  }

  .partner-analytics,
  .partner-rates {
    padding-bottom: 22px;
    border-bottom: 1px solid var(--line);
  }

  .partner-line-chart svg {
    aspect-ratio: 360 / 245;
  }

  .chart-legend {
    grid-template-columns: 1fr;
  }

  .partner-rates .level-rate-grid,
  .level-rate-grid {
    grid-template-columns: 1fr;
  }

  .level-breakdown-row {
    gap: 10px;
  }

  .level-breakdown-row small {
    font-size: 10px;
  }

  .referral-link,
  .field-row {
    align-items: stretch;
    flex-direction: column;
  }

  .bottom-nav {
    position: fixed;
    inset: auto 0 0;
    z-index: 40;
    min-height: 68px;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    padding: 6px max(8px, var(--tg-safe-area-inset-right, 0px)) max(6px, var(--tg-safe-area-inset-bottom, 0px)) max(8px, var(--tg-safe-area-inset-left, 0px));
    border-top: 1px solid var(--line);
    background: var(--topbar);
    backdrop-filter: blur(24px) saturate(140%);
  }

  .bottom-nav .nav-item {
    min-height: 54px;
    display: grid;
    place-items: center;
    align-content: center;
    gap: 2px;
    padding: 0 2px;
    border-radius: 12px;
    font-size: 9px;
  }

  .bottom-nav .nav-item.active {
    background: transparent;
  }

  .bottom-nav .nav-item.active::after {
    content: "";
    position: absolute;
    bottom: 2px;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--accent);
  }

  .sheet-layer {
    padding: 0;
  }

  .sheet {
    width: 100%;
    max-height: 88dvh;
    padding: 20px 18px calc(20px + env(safe-area-inset-bottom));
    border-width: 1px 0 0;
    border-radius: 26px 26px 0 0;
  }

  .sheet-handle {
    width: 38px;
    height: 4px;
    display: block;
    margin: -8px auto 16px;
    border-radius: 99px;
    background: var(--line-strong);
  }

  .tariff-scroll {
    display: flex;
    gap: 9px;
    overflow-x: auto;
    padding-bottom: 5px;
    scroll-snap-type: x mandatory;
  }

  .tariff-option {
    min-width: 156px;
    flex: 0 0 156px;
    scroll-snap-align: start;
  }

  .toast {
    bottom: calc(78px + env(safe-area-inset-bottom));
  }
}

@media (max-width: 370px) {
  .workspace {
    padding-inline: 11px;
  }

  .connection-panel,
  .partner-hero {
    padding: 24px 18px;
  }

  .connection-copy h2 {
    font-size: 28px;
  }

  .compact-metric-icon,
  .partner-kpi > span {
    display: none;
  }

  .partner-kpi {
    display: grid;
    align-content: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}



/* Small interaction polish: feedback without changing layout or navigation behavior. */
.primary-btn:active,
.secondary-btn:active,
.danger-btn:active,
.icon-action:active,
.icon-btn:active,
.text-btn:active,
.small-btn:active,
.nav-item:active,
.bottom-nav .nav-item:active {
  transform: scale(0.985);
}

.sheet-layer:not([hidden]) .sheet-backdrop {
  animation: miniappFadeIn 120ms ease-out both;
}

.sheet-layer:not([hidden]) .sheet {
  animation: miniappSheetIn 150ms cubic-bezier(.2,.8,.2,1) both;
}

.toast:not([hidden]) {
  animation: miniappToastIn 140ms ease-out both;
}

@keyframes miniappFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes miniappSheetIn {
  from {
    opacity: .88;
    transform: translateY(8px) scale(.995);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes miniappToastIn {
  from {
    opacity: 0;
    transform: translate(-50%, 5px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}
