@import url("https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;500;600;700&family=Manrope:wght@600;700;800&display=swap");

:root {
  color-scheme: light;
  --font-body: "IBM Plex Sans", "Segoe UI", sans-serif;
  --font-display: "Manrope", "Avenir Next", sans-serif;

  --bg-canvas: #ece9e1;
  --bg-noise: rgba(255, 255, 255, 0.52);
  --bg-shell: #f7f4ee;
  --bg-surface: rgba(255, 252, 247, 0.92);
  --bg-elevated: rgba(255, 255, 255, 0.92);
  --bg-contrast: #151921;
  --bg-muted: rgba(220, 214, 202, 0.56);

  --text-strong: #171c22;
  --text-body: #313844;
  --text-muted: #6b7280;
  --text-soft: #8f98a4;
  --text-inverse: #f8f5ef;

  --line-soft: rgba(24, 31, 40, 0.08);
  --line-strong: rgba(24, 31, 40, 0.12);

  --accent-ink: #213a5a;
  --accent-ink-strong: #162842;
  --accent-teal: #2f6e78;
  --accent-gold: #9e7b2f;
  --accent-warn: #ad6f15;
  --accent-danger: #8c3b39;
  --accent-success: #2f6648;

  --shadow-soft: 0 10px 30px rgba(17, 23, 32, 0.08);
  --shadow-card: 0 20px 48px rgba(17, 23, 32, 0.08);
  --shadow-shell: 0 30px 90px rgba(17, 23, 32, 0.12);

  --radius-xs: 10px;
  --radius-sm: 14px;
  --radius-md: 18px;
  --radius-lg: 24px;
  --radius-xl: 32px;

  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 28px;
  --space-8: 32px;

  --header-h: 56px;
  --bottom-nav-h: 72px;
  --safe-top: 12px;
  --safe-bottom: 20px;
  --content-max: 560px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

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

body {
  font-family: var(--font-body);
  color: var(--tg-text, var(--text-body));
  background:
    radial-gradient(circle at top left, rgba(33, 58, 90, 0.16), transparent 32%),
    radial-gradient(circle at bottom right, rgba(158, 123, 47, 0.18), transparent 30%),
    linear-gradient(180deg, #efece5 0%, #e8e4db 100%);
}

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

button {
  cursor: pointer;
  border: 0;
  background: none;
  padding: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

#app {
  min-height: 100vh;
}

.workspace {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(280px, 340px) minmax(390px, var(--content-max));
  justify-content: center;
  gap: 24px;
  padding: 24px;
}

.rail {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.rail-card {
  position: sticky;
  top: 24px;
  background: rgba(250, 248, 243, 0.74);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.75);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-card);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.rail-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.rail-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.eyebrow {
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 11px;
  font-weight: 700;
}

.rail-title,
.hero-title,
.screen-title,
.summary-title,
.sheet-title {
  margin: 0;
  font-family: var(--font-display);
  color: var(--text-strong);
}

.rail-title {
  font-size: 30px;
  line-height: 1.05;
}

.rail-subtitle {
  margin: 6px 0 0;
  color: var(--text-muted);
  line-height: 1.5;
}

.tone-pill,
.badge,
.impact-badge,
.chip,
.kpi-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 12px;
  font-weight: 700;
}

.tone-pill,
.chip {
  background: rgba(33, 58, 90, 0.08);
  color: var(--accent-ink);
}

.chip.active {
  background: var(--accent-ink);
  color: var(--text-inverse);
}

.badge {
  background: rgba(17, 23, 32, 0.06);
  color: var(--text-body);
}

.impact-badge.high {
  background: rgba(140, 59, 57, 0.12);
  color: var(--accent-danger);
}

.impact-badge.medium {
  background: rgba(173, 111, 21, 0.12);
  color: var(--accent-warn);
}

.kpi-pill {
  background: rgba(47, 110, 120, 0.1);
  color: var(--accent-teal);
}

.flow-list,
.mini-list,
.insight-list,
.settings-list,
.sheet-rows {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.flow-link,
.setting-row,
.list-row,
.event-row,
.trade-row,
.broker-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
  text-align: left;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.54);
  border: 1px solid var(--line-soft);
  color: var(--text-body);
}

.flow-link.active,
.setting-row:focus-visible,
.list-row:focus-visible,
.event-row:focus-visible,
.trade-row:focus-visible,
.broker-row:focus-visible {
  outline: none;
  border-color: rgba(33, 58, 90, 0.25);
  box-shadow: 0 0 0 3px rgba(33, 58, 90, 0.12);
}

.flow-link.active {
  background: rgba(33, 58, 90, 0.14);
  color: var(--accent-ink);
}

.flow-copy {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.flow-title {
  font-weight: 700;
  color: var(--text-strong);
}

.flow-meta,
.meta,
.helper,
.muted,
.subtle {
  color: var(--text-muted);
}

.shell-wrap {
  display: flex;
  justify-content: center;
}

.app-shell {
  position: relative;
  min-height: calc(100vh - 48px);
  width: min(100%, var(--content-max));
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.7) 0%, rgba(247, 244, 238, 0.9) 100%),
    var(--tg-secondary-bg, var(--bg-shell));
  border-radius: 38px;
  border: 1px solid rgba(255, 255, 255, 0.78);
  box-shadow: var(--shadow-shell);
  overflow: hidden;
}

.shell-chrome {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(150deg, rgba(255, 255, 255, 0.32), transparent 38%),
    radial-gradient(circle at top right, rgba(47, 110, 120, 0.08), transparent 24%);
}

.app-frame {
  position: relative;
  min-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
}

.screen {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 48px);
}

.screen-scroll {
  flex: 1;
  padding: var(--safe-top) 16px 0;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.screen-shell {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.screen-header,
.screen-header-compact,
.wizard-header {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: var(--header-h);
}

.screen-header {
  justify-content: space-between;
}

.screen-header-left {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.greeting {
  margin: 0;
  font-family: var(--font-display);
  font-size: 24px;
  line-height: 1.1;
  color: var(--text-strong);
}

.screen-title {
  font-size: 28px;
  line-height: 1.08;
}

.screen-subtitle {
  margin: 0;
  color: var(--text-muted);
}

.progress-bar {
  height: 8px;
  width: 100%;
  border-radius: 999px;
  background: rgba(17, 23, 32, 0.08);
  overflow: hidden;
}

.progress-bar > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent-ink) 0%, #405f8d 100%);
}

.section-stack,
.card-stack,
.field-stack,
.button-stack,
.button-row,
.tool-grid,
.summary-grid,
.kpi-grid,
.watchlist,
.trade-list,
.choice-list,
.chip-list,
.check-list,
.feature-list,
.scenario-list,
.bot-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.tool-grid,
.summary-grid {
  display: grid;
  gap: 12px;
}

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

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

.card,
.bot-card,
.metric-card,
.summary-card,
.tool-card,
.sheet,
.inline-state {
  background: var(--bg-surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
}

.card,
.metric-card,
.summary-card,
.tool-card,
.inline-state {
  padding: 18px;
}

.hero-card {
  padding: 22px;
  background:
    linear-gradient(180deg, rgba(33, 58, 90, 0.94) 0%, rgba(22, 40, 66, 0.98) 100%);
  color: var(--text-inverse);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-xl);
  box-shadow: 0 24px 48px rgba(22, 40, 66, 0.22);
}

.hero-card.warning {
  background:
    linear-gradient(180deg, rgba(140, 59, 57, 0.92) 0%, rgba(113, 41, 40, 0.98) 100%);
}

.hero-card.stop {
  background:
    linear-gradient(180deg, rgba(110, 67, 22, 0.92) 0%, rgba(88, 55, 20, 0.98) 100%);
}

.hero-card h2,
.hero-card p,
.hero-card li,
.hero-card .meta,
.hero-card .mini-note {
  color: var(--text-inverse);
}

.hero-card ul,
.plain-list {
  margin: 0;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.card-title,
.section-title,
.summary-title {
  margin: 0;
  color: var(--text-strong);
  font-family: var(--font-display);
}

.card-title {
  font-size: 20px;
}

.section-title,
.summary-title {
  font-size: 18px;
}

.body-copy,
.mini-note,
.helper,
.card-copy {
  margin: 0;
  line-height: 1.55;
}

.metric-row,
.summary-row,
.detail-grid,
.two-line,
.split {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.detail-grid {
  flex-wrap: wrap;
}

.detail-grid .metric {
  flex: 1 1 140px;
}

.metric-label,
.summary-label,
.field-label {
  display: block;
  margin-bottom: 6px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.metric-value,
.summary-value,
.result-number {
  color: var(--text-strong);
  font-family: var(--font-display);
  font-size: 22px;
  line-height: 1.1;
}

.metric-value.small,
.summary-value.small {
  font-size: 18px;
}

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

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

.kpi-card {
  padding: 16px;
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.68);
  border: 1px solid var(--line-soft);
}

.button {
  width: 100%;
  border-radius: 18px;
  padding: 15px 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-weight: 700;
  transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease;
}

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

.button.primary {
  background: linear-gradient(
    180deg,
    color-mix(in srgb, var(--tg-button, #244162) 96%, #ffffff 4%) 0%,
    color-mix(in srgb, var(--tg-button, #162842) 88%, #000000 12%) 100%
  );
  color: var(--tg-button-text, var(--text-inverse));
  box-shadow: 0 14px 24px rgba(22, 40, 66, 0.22);
}

.button.secondary {
  background: rgba(33, 58, 90, 0.08);
  color: var(--accent-ink);
}

.button.ghost {
  background: transparent;
  color: var(--accent-ink);
  border: 1px solid rgba(33, 58, 90, 0.14);
}

.button.destructive {
  background: rgba(140, 59, 57, 0.12);
  color: var(--accent-danger);
}

.button.inline {
  width: auto;
  padding: 0;
  border: 0;
  border-radius: 0;
  font-weight: 700;
  color: var(--tg-link, var(--accent-ink));
  justify-content: flex-start;
}

.icon-button,
.back-button {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--line-soft);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-strong);
}

.segmented,
.pricing-toggle {
  display: flex;
  gap: 8px;
  padding: 6px;
  border-radius: var(--radius-md);
  background: rgba(17, 23, 32, 0.06);
}

.segment,
.pricing-option {
  flex: 1;
  padding: 12px 14px;
  border-radius: 14px;
  color: var(--text-muted);
  font-weight: 700;
  text-align: center;
}

.segment.active,
.pricing-option.active {
  background: var(--bg-elevated);
  color: var(--accent-ink);
  box-shadow: var(--shadow-soft);
}

.choice-card,
.field-card,
.result-card {
  border-radius: var(--radius-lg);
  border: 1px solid var(--line-soft);
  background: rgba(255, 255, 255, 0.62);
  padding: 16px 18px;
}

.choice-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  width: 100%;
  text-align: left;
}

.choice-card.selected {
  background: rgba(33, 58, 90, 0.12);
  border-color: rgba(33, 58, 90, 0.22);
}

.choice-copy {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.choice-indicator {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid rgba(33, 58, 90, 0.22);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.choice-card.selected .choice-indicator {
  border-color: var(--accent-ink);
}

.choice-card.selected .choice-indicator::after {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent-ink);
}

.field-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.field-value,
.textarea {
  width: 100%;
  border-radius: 14px;
  border: 1px solid rgba(24, 31, 40, 0.08);
  background: rgba(255, 255, 255, 0.72);
  padding: 14px 16px;
  color: var(--text-strong);
}

.textarea {
  min-height: 104px;
  resize: vertical;
}

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

.switch {
  width: 50px;
  height: 30px;
  border-radius: 999px;
  background: rgba(17, 23, 32, 0.12);
  position: relative;
}

.switch::after {
  content: "";
  position: absolute;
  top: 4px;
  left: 4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: var(--shadow-soft);
  transition: transform 120ms ease;
}

.switch.on {
  background: rgba(33, 58, 90, 0.28);
}

.switch.on::after {
  transform: translateX(20px);
}

.chip-list {
  flex-direction: row;
  flex-wrap: wrap;
}

.chip-button {
  border-radius: 999px;
  padding: 10px 14px;
  background: rgba(33, 58, 90, 0.08);
  color: var(--accent-ink);
  font-weight: 700;
}

.chip-button.active {
  background: var(--accent-ink);
  color: var(--text-inverse);
}

.check-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid var(--line-soft);
}

.check-icon {
  width: 22px;
  height: 22px;
  border-radius: 8px;
  border: 2px solid rgba(33, 58, 90, 0.18);
  flex: 0 0 auto;
}

.check-item.checked .check-icon {
  background: var(--accent-ink);
  border-color: var(--accent-ink);
  position: relative;
}

.check-item.checked .check-icon::after {
  content: "";
  position: absolute;
  left: 6px;
  top: 2px;
  width: 5px;
  height: 10px;
  border: solid #ffffff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.bottom-actions,
.sticky-actions {
  position: sticky;
  bottom: 0;
  z-index: 10;
  padding: 16px 0 calc(16px + var(--safe-bottom));
  background:
    linear-gradient(180deg, rgba(247, 244, 238, 0) 0%, rgba(247, 244, 238, 0.92) 20%, rgba(247, 244, 238, 0.98) 100%);
  backdrop-filter: blur(12px);
}

.bottom-nav {
  position: sticky;
  bottom: 0;
  z-index: 12;
  padding: 8px 12px calc(8px + var(--safe-bottom));
  background:
    linear-gradient(180deg, rgba(247, 244, 238, 0) 0%, rgba(247, 244, 238, 0.94) 22%, rgba(247, 244, 238, 0.98) 100%);
  backdrop-filter: blur(16px);
}

.bottom-nav-inner {
  height: var(--bottom-nav-h);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(24, 31, 40, 0.08);
  box-shadow: var(--shadow-soft);
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  overflow: hidden;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--text-soft);
  font-size: 11px;
  font-weight: 700;
}

.nav-item.active {
  color: var(--accent-ink);
  background: rgba(33, 58, 90, 0.08);
}

.nav-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.85;
}

.bot-card {
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(17, 23, 32, 0.34);
  display: flex;
  align-items: flex-end;
  justify-content: stretch;
  padding: 12px;
  z-index: 30;
}

.sheet {
  width: 100%;
  border-radius: 28px 28px 20px 20px;
  padding: 16px 16px calc(16px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: rgba(249, 247, 242, 0.98);
}

.sheet-handle {
  width: 52px;
  height: 5px;
  border-radius: 999px;
  background: rgba(17, 23, 32, 0.14);
  margin: 0 auto;
}

.toast {
  position: absolute;
  right: 16px;
  left: 16px;
  bottom: calc(92px + var(--safe-bottom));
  z-index: 40;
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(21, 25, 33, 0.92);
  color: var(--text-inverse);
  box-shadow: var(--shadow-card);
}

.inline-state {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.state-warning {
  border-left: 4px solid var(--accent-warn);
}

.state-danger {
  border-left: 4px solid var(--accent-danger);
}

.state-offline {
  border-left: 4px solid var(--accent-teal);
}

.support-card {
  background: rgba(33, 58, 90, 0.08);
  border-radius: var(--radius-lg);
  padding: 16px;
}

.feature-item,
.broker-point {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.feature-item::before,
.broker-point::before {
  content: "";
  margin-top: 7px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent-ink);
  flex: 0 0 auto;
}

.hero-meta,
.session-strip,
.summary-strip-card {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.session-strip {
  align-items: center;
}

.stat-highlight {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
}

.stat-highlight strong {
  font-family: var(--font-display);
  font-size: 22px;
  color: var(--text-strong);
}

.list-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--text-muted);
  font-size: 13px;
}

.broker-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px;
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--line-soft);
}

.pricing-note,
.footnote {
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.5;
}

.brand-mark {
  width: 58px;
  height: 58px;
  border-radius: 18px;
  background:
    linear-gradient(160deg, rgba(33, 58, 90, 1) 0%, rgba(47, 110, 120, 1) 100%);
  box-shadow: 0 18px 30px rgba(33, 58, 90, 0.22);
  position: relative;
}

.brand-mark::before,
.brand-mark::after {
  content: "";
  position: absolute;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 999px;
}

.brand-mark::before {
  width: 10px;
  height: 26px;
  left: 17px;
  top: 15px;
}

.brand-mark::after {
  width: 20px;
  height: 10px;
  left: 17px;
  top: 31px;
}

.splash {
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: calc(100vh - 48px);
  padding: 32px 24px;
}

.splash .hero-title {
  font-size: 42px;
  line-height: 0.96;
}

.splash-copy {
  max-width: 280px;
  margin: 0 auto;
}

.legal-line {
  font-size: 12px;
  color: var(--text-soft);
  text-align: center;
}

html[data-telegram="true"] body {
  background:
    radial-gradient(circle at top left, rgba(33, 58, 90, 0.1), transparent 32%),
    radial-gradient(circle at bottom right, rgba(158, 123, 47, 0.1), transparent 30%),
    var(--tg-bg, linear-gradient(180deg, #efece5 0%, #e8e4db 100%));
}

.screen-intro {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.divider {
  width: 100%;
  height: 1px;
  background: var(--line-soft);
}

.hidden {
  display: none !important;
}

@media (max-width: 980px) {
  .workspace {
    display: block;
    padding: 0;
  }

  .rail {
    display: none;
  }

  .app-shell {
    width: 100%;
    min-height: 100vh;
    border-radius: 0;
    border: 0;
  }

  .app-frame,
  .screen,
  .splash {
    min-height: 100vh;
  }
}

@media (max-width: 420px) {
  .tool-grid,
  .summary-grid,
  .summary-strip,
  .kpi-strip {
    grid-template-columns: 1fr;
  }

  .screen-title {
    font-size: 24px;
  }

  .greeting {
    font-size: 22px;
  }
}
