:root {
  /* Telegram Wallet-inspired palette — dark-first (Wallet's signature look). */
  --bg: #000000;
  --surface: #1c1c1e;
  --surface-2: #232326;
  --surface-elevated: #2c2c2e;
  --hairline: rgba(255,255,255,0.08);
  --text: #ffffff;
  --text-secondary: #ffffff;
  --muted: #8e8e93;
  --muted-2: #636366;

  --accent: #0098ea;
  --accent-2: #4abdff;
  --accent-grad: linear-gradient(135deg, #4abdff 0%, #0098ea 60%, #0077c2 100%);
  --accent-soft: rgba(0,152,234,0.16);

  --success: #34c759;
  --success-soft: rgba(52,199,89,0.16);
  --danger: #ff453a;
  --danger-soft: rgba(255,69,58,0.16);
  --warning: #ff9f0a;
  --warning-soft: rgba(255,159,10,0.16);

  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 12px;
  --radius-pill: 999px;

  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f2f2f7;
    --surface: #ffffff;
    --surface-2: #f9f9fb;
    --surface-elevated: #ffffff;
    --hairline: rgba(60,60,67,0.12);
    --text: #000000;
    --text-secondary: #1c1c1e;
    --muted: #8a8a8e;
    --muted-2: #aeaeb2;
    --accent-soft: rgba(0,152,234,0.10);
    --success-soft: rgba(52,199,89,0.12);
    --danger-soft: rgba(255,69,58,0.12);
    --warning-soft: rgba(255,159,10,0.12);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding-bottom: calc(72px + var(--safe-bottom));
}
body.no-tabbar { padding-bottom: 24px; }

a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

/* ===== Top bar ===== */
/* Sticky so Back + Home stay visible on every section while the page scrolls. */
.topbar {
  position: sticky;
  top: 0;
  z-index: 800;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px 6px;
  gap: 10px;
  background: var(--bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}
.topbar-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  flex: 1;
  text-align: center;
}
.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--surface-2);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: var(--text);
  cursor: pointer;
  flex-shrink: 0;
}
.icon-btn:active { background: var(--surface-elevated); }
.icon-btn.spacer { visibility: hidden; }

/* ===== Page shell ===== */
.page {
  flex: 1;
  padding: 4px 18px 28px;
}
.page-title {
  font-size: 28px;
  font-weight: 700;
  margin: 10px 0 4px;
  letter-spacing: -0.3px;
}
.page-sub {
  font-size: 14.5px;
  color: var(--muted);
  margin-bottom: 20px;
}

/* ===== Hero balance card (Wallet's signature element) ===== */
.hero {
  position: relative;
  border-radius: var(--radius-xl);
  background:
    radial-gradient(120% 140% at 20% -10%, rgba(0,152,234,0.35) 0%, rgba(0,152,234,0) 55%),
    var(--surface);
  padding: 26px 22px 22px;
  margin: 6px 0 20px;
  overflow: hidden;
  border: 1px solid var(--hairline);
}
.hero-label {
  font-size: 13.5px;
  color: var(--muted);
  font-weight: 500;
  margin-bottom: 6px;
}
.hero-value {
  font-size: 40px;
  font-weight: 700;
  letter-spacing: -0.5px;
  line-height: 1.1;
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.hero-value .unit { font-size: 18px; font-weight: 600; color: var(--muted); }
.hero-foot {
  margin-top: 10px;
  font-size: 13.5px;
  color: var(--muted);
}
.hero-icon {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--accent-grad);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  margin-bottom: 14px;
  box-shadow: 0 6px 18px rgba(0,152,234,0.35);
}

/* ===== Circular action row ===== */
.action-row {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 8px;
  margin-bottom: 22px;
}
.action-circle {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text);
  padding: 0;
}
.action-circle .circle {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  border: 1px solid var(--hairline);
}
.action-circle.primary .circle {
  background: var(--accent-grad);
  box-shadow: 0 6px 16px rgba(0,152,234,0.3);
}
.action-circle:active .circle { filter: brightness(0.9); }
.action-circle .a-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  text-align: center;
}
.action-circle .a-count {
  font-size: 10.5px;
  color: var(--muted);
}

/* ===== Grouped buttons (Wallet-style tiles, side by side) ===== */
/* Default: a 2-column grid of tappable tiles. Add .linear to a .list-section
   for the classic single-column full-width list (used where a row carries
   its own inline control or trailing value, e.g. balance history, friend
   requests with an accept button, admin approve rows). */
.list-section {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 18px;
}
.list-section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin: 22px 4px 8px;
}
.list-row {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  padding: 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--hairline);
  cursor: pointer;
  background: var(--surface);
}
.list-row:active { background: var(--surface-2); }
.list-row.static { cursor: default; }
.list-row .row-body { width: 100%; }
.list-row .row-title,
.list-row .row-sub { white-space: normal; }
.list-row .row-chevron { display: none; }

/* ===== Linear modifier: classic single-column list ===== */
.list-section.linear {
  display: block;
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--hairline);
  overflow: hidden;
}
.list-section.linear .list-row {
  flex-direction: row;
  align-items: center;
  gap: 12px;
  padding: 13px 16px;
  border-radius: 0;
  border: none;
  border-bottom: 1px solid var(--hairline);
}
.list-section.linear .list-row:last-child { border-bottom: none; }
.list-section.linear .row-body { width: auto; flex: 1; min-width: 0; }
.list-section.linear .row-title,
.list-section.linear .row-sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-section.linear .row-chevron { display: block; }

/* Tile that spans both columns (e.g. lone/odd item, or wide content) */
.list-row.span-2 { grid-column: 1 / -1; }

.row-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  flex-shrink: 0;
}
.row-icon.accent { background: var(--accent-soft); color: var(--accent-2); }
.row-icon.success { background: var(--success-soft); color: var(--success); }
.row-icon.warning { background: var(--warning-soft); color: var(--warning); }
.row-icon.danger { background: var(--danger-soft); color: var(--danger); }

.row-body { flex: 1; min-width: 0; }
.row-title {
  font-size: 15.5px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.row-sub {
  font-size: 13px;
  color: var(--muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.row-trail {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
  flex-shrink: 0;
}
.row-value { font-size: 15px; font-weight: 600; }
.row-value.positive { color: var(--success); }
.row-value.negative { color: var(--danger); }
.row-chevron { color: var(--muted-2); font-size: 15px; margin-left: 2px; }

/* ===== Buttons ===== */
.pill-btn {
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-pill);
  padding: 16px 18px;
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  width: 100%;
}
.pill-btn:active { filter: brightness(1.15); }
@media (prefers-color-scheme: light) { .pill-btn:active { filter: brightness(0.96); } }

.cta-btn {
  background: var(--accent-grad);
  color: #fff;
  border: none;
  border-radius: var(--radius-pill);
  padding: 17px;
  font-size: 16px;
  font-weight: 600;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(0,152,234,0.28);
}
.cta-btn:disabled { background: var(--muted-2); box-shadow: none; cursor: default; }
.cta-btn.danger { background: var(--danger); box-shadow: 0 8px 20px rgba(255,69,58,0.28); }
.cta-btn.secondary { background: var(--surface-elevated); color: var(--text); box-shadow: none; border: 1px solid var(--hairline); }

.link-btn {
  background: none;
  border: none;
  color: var(--danger);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  display: block;
  margin: 18px auto;
}

/* ===== Account / avatar card (kept for compatibility, restyled) ===== */
.account-card {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 10px;
  cursor: pointer;
}
.account-card:active { background: var(--surface-2); }

.avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--accent-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  font-weight: 700;
  color: var(--accent-2);
  flex-shrink: 0;
}

.account-info { flex: 1; min-width: 0; }
.account-name { font-size: 15.5px; font-weight: 600; color: var(--text); }
.account-meta { font-size: 13px; color: var(--muted); margin-top: 2px; }

/* ===== Segmented tabs (gender / period pickers) ===== */
.seg-tabs {
  display: grid;
  grid-auto-flow: column;
  gap: 6px;
  background: var(--surface-2);
  border-radius: var(--radius-pill);
  padding: 4px;
  margin-bottom: 18px;
}
.seg-tab {
  background: none;
  border: none;
  border-radius: var(--radius-pill);
  padding: 10px 6px;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}
.seg-tab.active {
  background: var(--surface-elevated);
  color: var(--text);
}

.date-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.date-nav .date-text {
  font-size: 16px;
  font-weight: 600;
  text-align: center;
  flex: 1;
}
.arrow-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--surface-2);
  border: none;
  font-size: 17px;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}
.arrow-btn:active { filter: brightness(1.2); }
.arrow-btn:disabled { opacity: 0.3; }

.period-tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 18px;
}
.period-tab {
  background: var(--surface-2);
  border: 1.5px solid transparent;
  border-radius: var(--radius-md);
  padding: 12px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: 12.5px;
  cursor: pointer;
  color: var(--text-secondary);
}
.period-tab .p-icon { font-size: 20px; }
.period-tab.active {
  border-color: var(--accent);
  color: var(--accent-2);
  background: var(--accent-soft);
}

.slots-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 18px;
}
.slot-btn {
  background: var(--surface);
  border: 1.5px solid var(--hairline);
  border-radius: var(--radius-md);
  padding: 14px 4px;
  font-size: 14px;
  text-align: center;
  cursor: pointer;
  color: var(--text);
}
.slot-btn:active, .slot-btn.selected {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-2);
}

.empty-state {
  text-align: center;
  color: var(--muted);
  padding: 50px 20px;
  font-size: 15px;
}

.spinner {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 3px solid var(--surface-2);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
  margin: 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

.center-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 30px;
  gap: 18px;
  background: var(--bg);
}

.logo-img { width: 88px; height: 88px; object-fit: contain; border-radius: 22px; }
.app-name { font-size: 20px; font-weight: 700; margin-top: 4px; color: var(--text); }

.badge {
  display: inline-block;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  font-size: 12.5px;
  font-weight: 600;
}
.badge.warning { background: var(--warning-soft); color: var(--warning); }
.badge.success { background: var(--success-soft); color: var(--success); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.accent { background: var(--accent-soft); color: var(--accent-2); }
.badge.neutral { background: var(--surface-2); color: var(--muted); }

.result-icon { font-size: 52px; margin-bottom: 6px; }
.result-title { font-size: 21px; font-weight: 700; margin-bottom: 6px; color: var(--text); }
.result-sub { color: var(--muted); font-size: 14px; margin-bottom: 20px; }
.result-shot {
  max-width: 100%;
  border-radius: var(--radius-md);
  border: 1px solid var(--hairline);
  margin-bottom: 20px;
}

.toast {
  position: fixed;
  bottom: calc(84px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface-elevated);
  color: var(--text);
  padding: 12px 20px;
  border-radius: var(--radius-pill);
  font-size: 14px;
  opacity: 0;
  transition: opacity 0.25s;
  pointer-events: none;
  z-index: 999;
  max-width: 90%;
  text-align: center;
  border: 1px solid var(--hairline);
  box-shadow: 0 8px 24px rgba(0,0,0,0.35);
}
.toast.show { opacity: 1; }

/* ===== Collapsible actions (grouped buttons, expand on tap) ===== */
.actions-toggle {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 10px;
}
.actions-toggle .row-icon { margin: 0; }
.actions-toggle .t-label { flex: 1; text-align: left; }
.actions-toggle .t-chevron {
  font-size: 18px;
  color: var(--muted);
  transition: transform 0.25s ease;
}
.actions-toggle.open .t-chevron { transform: rotate(90deg); }
.actions-toggle.open { border-color: var(--accent); }

.collapsible {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.28s ease;
}
.collapsible.open { grid-template-rows: 1fr; }
.collapsible > .collapsible-inner { overflow: hidden; min-height: 0; }

/* ===== Bottom tab bar ===== */
.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--hairline);
  padding: 8px 6px calc(8px + var(--safe-bottom));
  z-index: 900;
  backdrop-filter: blur(20px);
}
.tab-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 500;
  padding: 4px 2px;
  cursor: pointer;
}
.tab-item .t-icon { font-size: 21px; line-height: 1; }
.tab-item.active { color: var(--accent-2); }

/* ===== Simple form fields ===== */
.field {
  margin-bottom: 16px;
}
.field label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 6px;
  font-weight: 500;
}
.field input, .field textarea {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
  padding: 14px;
  font-size: 15px;
  color: var(--text);
  font-family: inherit;
}
.field input:focus, .field textarea:focus {
  outline: none;
  border-color: var(--accent);
}

/* ===== Chat bubbles (AI yordamchi) ===== */
.chat-bubble {
  align-self: flex-start;
  max-width: 82%;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  font-size: 14.5px;
  line-height: 1.4;
  white-space: pre-wrap;
  background: var(--surface-2);
  color: var(--text);
}
.chat-bubble.mine {
  align-self: flex-end;
  background: var(--accent-grad);
  color: #fff;
}
