:root {
  --paper: #f7f4ec;
  --surface: #ffffff;
  --ink: #17221f;
  --muted: #71807a;
  --line: #dedfd7;
  --forest: #0d4d3c;
  --forest-dark: #07382c;
  --mint: #bce8d2;
  --lime: #d8ee72;
  --amber: #f6b84b;
  --blue: #5da7d8;
  --danger: #d85b50;
  --shadow: 0 18px 50px rgba(24, 44, 37, 0.12);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html {
  background: #d9ddd7;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    linear-gradient(rgba(13, 77, 60, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(13, 77, 60, 0.045) 1px, transparent 1px),
    var(--paper);
  background-size: 28px 28px;
  font-family: "DM Sans", sans-serif;
  letter-spacing: 0;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button { font: inherit; letter-spacing: 0; }
button, .order-row { touch-action: manipulation; }

.app-shell {
  width: min(100%, 520px);
  min-height: 100dvh;
  margin: 0 auto;
  padding: calc(var(--safe-top) + 14px) 18px calc(104px + var(--safe-bottom));
  background: rgba(247, 244, 236, 0.96);
  position: relative;
  overflow: hidden;
}

.topbar, .summary-heading, .summary-meta, .section-heading, .order-line, .sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.topbar { min-height: 58px; }

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 0;
  background: transparent;
  color: var(--ink);
  padding: 4px 0;
  text-align: left;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  color: var(--lime);
  background: var(--forest);
  font-family: "Manrope", sans-serif;
  font-size: 21px;
  font-weight: 800;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.16);
}

.brand small, .brand strong { display: block; }
.brand small { color: var(--muted); font-size: 11px; margin-bottom: 1px; }
.brand strong { font-family: "Manrope", sans-serif; font-size: 15px; }
.brand > svg { width: 16px; color: var(--muted); }

.icon-button {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  color: var(--ink);
}

.icon-button svg { width: 20px; }
.notification-button { position: relative; }
.notification-dot {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #e86655;
  border: 2px solid white;
}

.summary { padding: 31px 2px 22px; }
.eyebrow {
  margin: 0 0 5px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
}

.balance {
  margin: 0;
  font-family: "Manrope", sans-serif;
  font-size: 38px;
  font-weight: 800;
  line-height: 1.12;
  letter-spacing: 0;
}

.period, .summary-trend {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.period {
  padding: 8px 10px;
  border-radius: 8px;
  background: #ebe8de;
  color: #59645f;
  font-size: 11px;
  font-weight: 700;
}

.period svg, .summary-trend svg { width: 14px; height: 14px; }
.summary-meta { margin-top: 13px; color: var(--muted); font-size: 13px; }
.summary-meta b { color: var(--ink); }
.summary-trend { color: var(--forest); font-weight: 600; }

.quick-actions {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 9px;
  margin-bottom: 20px;
}

.quick-action {
  min-width: 0;
  height: 82px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(255,255,255,.78);
  color: var(--ink);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.quick-action span {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  color: var(--forest);
  background: var(--mint);
}

.quick-action svg { width: 17px; }
.quick-action b { overflow-wrap: anywhere; font-size: 11px; font-weight: 700; }

.spotlight {
  min-height: 160px;
  display: grid;
  grid-template-columns: 1.15fr .85fr;
  overflow: hidden;
  border-radius: 8px;
  background: var(--forest);
  color: white;
  box-shadow: var(--shadow);
}

.spotlight-copy { padding: 21px 0 20px 21px; position: relative; z-index: 1; }
.spotlight-label { color: var(--lime); font-size: 10px; font-weight: 800; letter-spacing: .1em; }
.spotlight h2 {
  margin: 8px 0 15px;
  font-family: "Manrope", sans-serif;
  font-size: 22px;
  line-height: 1.16;
  letter-spacing: 0;
}

.spotlight button {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0;
  border: 0;
  background: transparent;
  color: white;
  font-size: 11px;
  font-weight: 700;
}
.spotlight button svg { width: 14px; }
.spotlight img { width: 100%; height: 100%; min-height: 160px; object-fit: cover; mix-blend-mode: luminosity; opacity: .82; }

.pulse-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 18px 0 30px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.pulse-item {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 15px 7px;
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  text-align: left;
}
.pulse-item:last-child { border-right: 0; }
.pulse-item > span:last-child { min-width: 0; }
.pulse-item b, .pulse-item small { display: block; }
.pulse-item b { font: 800 18px "Manrope", sans-serif; }
.pulse-item small { margin-top: 1px; color: var(--muted); font-size: 9px; overflow-wrap: anywhere; }
.pulse-icon { display: grid; place-items: center; width: 31px; height: 31px; flex: 0 0 31px; border-radius: 50%; }
.pulse-icon svg { width: 15px; }
.pulse-icon.amber { background: #fbe1af; color: #8f5b06; }
.pulse-icon.blue { background: #cde6f5; color: #17618f; }
.pulse-icon.green { background: var(--mint); color: var(--forest); }

.section-heading h2, .sheet-header h2 { margin: 0; font: 800 24px "Manrope", sans-serif; }
.text-button { border: 0; padding: 8px 0; background: transparent; color: var(--forest); font-size: 12px; font-weight: 800; }

.filter-row {
  display: flex;
  gap: 8px;
  margin: 17px -18px 10px;
  padding: 0 18px 8px;
  overflow-x: auto;
  scrollbar-width: none;
}
.filter-row::-webkit-scrollbar { display: none; }
.filter-chip {
  flex: 0 0 auto;
  padding: 9px 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}
.filter-chip.active { border-color: var(--forest); background: var(--forest); color: white; }

.order-list { min-height: 230px; }
.order-row {
  width: 100%;
  min-height: 84px;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 14px 0;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  text-align: left;
}
.order-logo { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 7px; color: var(--forest); background: var(--mint); }
.order-logo svg { width: 20px; }
.order-info { min-width: 0; }
.order-line { justify-content: flex-start; gap: 7px; }
.order-id { font-family: "Manrope", sans-serif; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status-badge { flex: 0 0 auto; padding: 3px 6px; border-radius: 5px; background: #e8e9e3; color: #5c6661; font-size: 8px; font-weight: 800; text-transform: uppercase; }
.status-badge.paid { background: #fbe1af; color: #7d520a; }
.status-badge.processing { background: #d5eaf7; color: #1c6087; }
.status-badge.shipped, .status-badge.completed { background: var(--mint); color: var(--forest); }
.order-product, .order-time { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.order-product { margin-top: 5px; color: #4c5853; font-size: 11px; }
.order-time { margin-top: 2px; color: var(--muted); font-size: 9px; }
.order-value { display: flex; align-items: center; gap: 5px; white-space: nowrap; }
.order-value b { font: 700 12px "Manrope", sans-serif; }
.order-value svg { width: 15px; color: #9aa39e; }

.loading-state, .empty-state, .error-state { display: grid; place-items: center; min-height: 210px; text-align: center; color: var(--muted); font-size: 12px; }
.loading-state p, .empty-state p, .error-state p { margin: 8px 0; }
.spinner { width: 24px; height: 24px; border: 3px solid #d9ded8; border-top-color: var(--forest); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.bottom-nav {
  position: fixed;
  z-index: 20;
  bottom: 10px;
  left: 50%;
  width: min(calc(100% - 24px), 496px);
  min-height: 68px;
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  padding: 7px 7px calc(7px + var(--safe-bottom));
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 8px;
  background: rgba(17, 32, 28, .96);
  box-shadow: 0 16px 40px rgba(18, 40, 33, .25);
  backdrop-filter: blur(18px);
}
.nav-item { border: 0; background: transparent; color: #aeb9b5; display: grid; place-items: center; align-content: center; gap: 4px; font-size: 9px; font-weight: 700; }
.nav-item svg { width: 19px; }
.nav-item.active { color: var(--lime); background: rgba(255,255,255,.06); border-radius: 6px; }

.sheet-backdrop { position: fixed; inset: 0; z-index: 29; background: rgba(9, 21, 17, .5); backdrop-filter: blur(3px); }
.bottom-sheet {
  position: fixed;
  z-index: 30;
  left: 50%;
  bottom: 0;
  width: min(100%, 520px);
  max-height: 82dvh;
  overflow-y: auto;
  transform: translate(-50%, 105%);
  padding: 10px 20px calc(22px + var(--safe-bottom));
  border-radius: 12px 12px 0 0;
  background: var(--surface);
  box-shadow: 0 -22px 60px rgba(10, 32, 25, .24);
  transition: transform .28s ease;
}
.bottom-sheet.open { transform: translate(-50%, 0); }
.sheet-handle { width: 42px; height: 4px; margin: 1px auto 19px; border-radius: 999px; background: #d7dbd8; }
.sheet-header { margin-bottom: 22px; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
.detail-cell { padding: 13px; border: 1px solid var(--line); border-radius: 7px; }
.detail-cell small, .detail-cell b { display: block; }
.detail-cell small { color: var(--muted); font-size: 9px; margin-bottom: 4px; }
.detail-cell b { font-size: 12px; overflow-wrap: anywhere; }
.item-card { display: flex; justify-content: space-between; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--line); font-size: 11px; }
.item-card span:last-child { white-space: nowrap; font-weight: 700; }
.primary-button { width: 100%; min-height: 49px; margin-top: 20px; border: 0; border-radius: 7px; background: var(--forest); color: white; font-weight: 800; }
.primary-button:disabled { opacity: .55; }

.onboarding-view {
  width: min(100%, 520px);
  min-height: 100dvh;
  margin: 0 auto;
  padding: calc(var(--safe-top) + 24px) 24px calc(var(--safe-bottom) + 28px);
  background:
    linear-gradient(rgba(13, 77, 60, .045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(13, 77, 60, .045) 1px, transparent 1px),
    var(--paper);
  background-size: 28px 28px;
}
.onboarding-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.onboarding-brand { display: flex; align-items: center; gap: 10px; font: 800 16px "Manrope", sans-serif; }
.onboarding-user { min-width: 0; overflow: hidden; color: var(--forest); font: 700 12px "Manrope", sans-serif; text-overflow: ellipsis; white-space: nowrap; }
.onboarding-visual {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  height: 210px;
  margin: 34px 0 28px;
  overflow: hidden;
  border-radius: 8px;
  color: var(--lime);
  background: var(--forest);
}
.onboarding-visual > svg { width: 92px; height: 92px; stroke-width: 1.25; }
.onboarding-visual > span { position: absolute; right: 26px; bottom: 22px; display: grid; place-items: center; width: 50px; height: 50px; border-radius: 50%; color: var(--forest); background: var(--lime); }
.onboarding-visual > span svg { width: 24px; }
.onboarding-view h1 { max-width: 390px; margin: 7px 0 10px; font: 800 34px/1.12 "Manrope", sans-serif; }
.onboarding-copy { max-width: 410px; margin: 0 0 26px; color: var(--muted); font-size: 14px; line-height: 1.55; }
.marketplace-list { display: grid; gap: 10px; }
.marketplace-option { display: grid; grid-template-columns: 46px minmax(0, 1fr) 20px; align-items: center; gap: 12px; padding: 14px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.marketplace-option > span:nth-child(2) { min-width: 0; }
.marketplace-option b, .marketplace-option small { display: block; }
.marketplace-option b { font: 700 13px "Manrope", sans-serif; }
.marketplace-option small { margin-top: 3px; color: var(--muted); font-size: 10px; }
.marketplace-option > svg { width: 19px; color: var(--forest); }
.marketplace-option.demo-option { margin-top: 5px; border-top: 0; }
.marketplace-option.demo-option > svg { color: var(--muted); }
.marketplace-logo { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 7px; color: var(--forest); background: var(--mint); }
.marketplace-logo svg { width: 21px; }
.tiktok-logo { color: #fff; background: #161823; }
.secondary-button { width: 100%; min-height: 46px; border: 1px solid var(--line); background: var(--paper); color: var(--ink); font: 700 12px "Manrope", sans-serif; cursor: pointer; }
.secondary-button:disabled { opacity: .55; cursor: wait; }
.onboarding-button { display: flex; align-items: center; justify-content: center; gap: 8px; }
.onboarding-button svg { width: 18px; }
.onboarding-note { display: flex; align-items: center; justify-content: center; gap: 7px; margin: 14px 0 0; color: var(--muted); font-size: 10px; text-align: center; }
.onboarding-note svg { width: 15px; flex: 0 0 auto; }
.telegram-gate { min-height: 100vh; padding: max(28px, var(--safe-top)) 24px max(28px, var(--safe-bottom)); place-content: center; text-align: center; }
.telegram-gate:not([hidden]) { display: grid; }
.telegram-gate .onboarding-brand { justify-self: center; margin-bottom: 42px; }
.telegram-gate h1 { max-width: 420px; margin: 8px auto 10px; font: 800 30px/1.15 "Manrope", sans-serif; }
.telegram-gate #telegramGateMessage { max-width: 390px; margin: 0 auto; color: var(--muted); font-size: 14px; line-height: 1.55; }
.telegram-gate .primary-button { width: min(100%, 320px); margin: 24px auto 0; }
.gate-icon { display: grid; place-items: center; width: 76px; height: 76px; margin: 0 auto 24px; border-radius: 50%; color: #fff; background: #229ed9; }
.gate-icon svg { width: 34px; height: 34px; }

.toast { position: fixed; z-index: 40; left: 50%; bottom: calc(96px + var(--safe-bottom)); transform: translate(-50%, 20px); max-width: calc(100% - 36px); padding: 11px 15px; border-radius: 7px; background: var(--ink); color: white; box-shadow: var(--shadow); opacity: 0; pointer-events: none; font-size: 11px; transition: .2s ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

button:focus-visible { outline: 3px solid rgba(93, 167, 216, .55); outline-offset: 2px; }
button:active { transform: translateY(1px); }

@media (min-width: 700px) {
  body { padding: 24px 0; }
  .app-shell { min-height: calc(100dvh - 48px); border-radius: 10px; box-shadow: var(--shadow); }
  .onboarding-view { min-height: calc(100dvh - 48px); border-radius: 10px; box-shadow: var(--shadow); }
}

@media (max-width: 360px) {
  .app-shell { padding-left: 14px; padding-right: 14px; }
  .balance { font-size: 32px; }
  .quick-actions { gap: 6px; }
  .quick-action b { font-size: 10px; }
  .pulse-item { padding-left: 3px; padding-right: 3px; }
  .pulse-icon { display: none; }
  .filter-row { margin-left: -14px; margin-right: -14px; padding-left: 14px; }
}

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