/* ============================================================
   Horion Mini App — mobil dizayn (Telegram Web App)
   ============================================================ */
:root {
  --brand: #DC04AF;
  --brand-2: #A00580;
  --brand-soft: rgba(220, 4, 175, 0.14);
  --bg: #0F1015;
  --surface: #181A22;
  --surface-2: #21242E;
  --border: #2B2F3A;
  --text: #EDEEF2;
  --muted: #9BA1AF;
  --success: #2ED47A;
  --danger: #FF4D6A;
  --warn: #FFB020;
  --radius: 18px;
  --font: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, system-ui, sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
[data-theme="light"] {
  --bg: #F2F3F7;
  --surface: #FFFFFF;
  --surface-2: #F5F6F9;
  --border: #E6E8EE;
  --text: #14161C;
  --muted: #6B7280;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; overscroll-behavior: none; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  user-select: none;
}
img { max-width: 100%; display: block; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }

/* ============ GATE (kirish kodi) ============ */
.gate {
  position: fixed; inset: 0; z-index: 100;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: var(--bg); padding: 32px;
  background-image: radial-gradient(600px 300px at 50% 0%, rgba(220, 4, 175, 0.12), transparent 70%);
}
.gate img { height: 40px; margin-bottom: 10px; }
.gate .g-sub { color: var(--muted); font-size: 14px; margin-bottom: 30px; }
.gate .g-dots { display: flex; gap: 14px; margin-bottom: 28px; }
.g-dot { width: 15px; height: 15px; border-radius: 50%; background: var(--surface-2); border: 1.5px solid var(--border); transition: .2s; }
.g-dot.on { background: var(--brand); border-color: var(--brand); transform: scale(1.15); }
.g-pad { display: grid; grid-template-columns: repeat(3, 76px); gap: 16px; }
.g-key {
  height: 76px; border-radius: 50%; background: var(--surface); font-size: 26px; font-weight: 600;
  display: grid; place-items: center; transition: .1s; border: 1px solid var(--border);
}
.g-key:active { background: var(--brand-soft); transform: scale(.92); }
.g-err { color: var(--danger); font-size: 14px; height: 20px; margin-top: 18px; }

/* ============ APP ============ */
.app { display: none; flex-direction: column; min-height: 100vh; padding-bottom: calc(72px + var(--safe-b)); }
.app.on { display: flex; }

.app-header {
  padding: 16px 18px 10px; display: flex; align-items: center; gap: 12px;
  position: sticky; top: 0; z-index: 10;
  background: linear-gradient(180deg, var(--bg) 70%, transparent);
}
.app-header img { height: 22px; }
.app-header .greet { margin-left: auto; text-align: right; }
.app-header .greet b { font-size: 14px; }
.app-header .greet span { font-size: 11px; color: var(--muted); display: block; }

.screen { padding: 6px 16px 20px; animation: fade .25s; }
@keyframes fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.screen-title { font-size: 22px; font-weight: 800; letter-spacing: -.02em; margin: 8px 2px 16px; }

/* Stat cards */
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px;
}
.stat { position: relative; overflow: hidden; }
.stat .ic { font-size: 20px; }
.stat .lbl { color: var(--muted); font-size: 12.5px; margin-top: 8px; }
.stat .val { font-size: 21px; font-weight: 800; letter-spacing: -.02em; margin-top: 2px; }
.stat .val.sm { font-size: 17px; }
.stat.wide { grid-column: 1 / -1; }
.stat.brand { background: linear-gradient(135deg, var(--brand), var(--brand-2)); border: none; color: #fff; }
.stat.brand .lbl { color: rgba(255,255,255,.85); }

.pos { color: var(--success); } .neg { color: var(--danger); }

.section-h { display: flex; align-items: center; margin: 24px 2px 12px; }
.section-h h3 { font-size: 16px; font-weight: 700; }
.section-h .more { margin-left: auto; color: var(--brand); font-size: 13px; font-weight: 600; }

/* List */
.list { display: flex; flex-direction: column; gap: 8px; }
.item {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  padding: 12px 14px; display: flex; align-items: center; gap: 12px;
}
.avatar {
  width: 42px; height: 42px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: 16px;
}
.avatar.gray { background: var(--surface-2); color: var(--muted); }
.item .info { flex: 1; min-width: 0; }
.item .info b { font-size: 14.5px; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .info span { font-size: 12.5px; color: var(--muted); }
.item .right { text-align: right; flex-shrink: 0; }
.item .right b { font-size: 14px; }
.item .right span { font-size: 11.5px; color: var(--muted); display: block; }

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 20px; font-size: 11.5px; font-weight: 700; }
.b-green { background: rgba(46,212,122,.16); color: var(--success); }
.b-red { background: rgba(255,77,106,.16); color: var(--danger); }
.b-warn { background: rgba(255,176,32,.16); color: var(--warn); }
.b-gray { background: var(--surface-2); color: var(--muted); }
.b-brand { background: var(--brand-soft); color: var(--brand); }

.tx-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; }
.tx-ic { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; font-size: 17px; flex-shrink: 0; }
.tx-ic.in { background: rgba(46,212,122,.14); } .tx-ic.out { background: rgba(255,77,106,.14); }

.empty { text-align: center; color: var(--muted); padding: 50px 20px; }
.empty .big { font-size: 44px; margin-bottom: 10px; }

.skeleton { background: linear-gradient(90deg, var(--surface) 25%, var(--surface-2) 50%, var(--surface) 75%); background-size: 200% 100%; animation: sk 1.2s infinite; border-radius: 14px; height: 66px; }
@keyframes sk { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* Segmented */
.seg { display: flex; gap: 4px; background: var(--surface-2); padding: 4px; border-radius: 12px; margin-bottom: 14px; }
.seg button { flex: 1; padding: 9px; border-radius: 9px; font-size: 13px; font-weight: 600; color: var(--muted); }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: 0 2px 8px rgba(0,0,0,.15); }

/* FAB */
.fab {
  position: fixed; right: 18px; bottom: calc(84px + var(--safe-b)); z-index: 20;
  width: 56px; height: 56px; border-radius: 50%;
  background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff;
  font-size: 28px; display: grid; place-items: center;
  box-shadow: 0 8px 24px rgba(220,4,175,.45); transition: transform .12s;
}
.fab:active { transform: scale(.9); }

/* ============ TAB BAR ============ */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; background: var(--surface); border-top: 1px solid var(--border);
  padding-bottom: var(--safe-b);
}
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 10px 0 8px; color: var(--muted); font-size: 10.5px; font-weight: 600; transition: .12s;
}
.tab .ti { font-size: 21px; line-height: 1; }
.tab.on { color: var(--brand); }
.tab.on .ti { transform: translateY(-1px); }

/* Modal (bottom sheet) */
.sheet-bg { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 40; display: none; }
.sheet-bg.on { display: block; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 41;
  background: var(--surface); border-radius: 22px 22px 0 0; padding: 8px 18px calc(24px + var(--safe-b));
  transform: translateY(100%); transition: transform .28s cubic-bezier(.2,.8,.2,1);
  max-height: 88vh; overflow-y: auto;
}
.sheet.on { transform: none; }
.sheet .grip { width: 40px; height: 4px; border-radius: 3px; background: var(--border); margin: 8px auto 16px; }
.sheet h3 { font-size: 18px; font-weight: 700; margin-bottom: 16px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 6px; }
.input {
  width: 100%; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px;
  padding: 13px 14px; color: var(--text); font-size: 15px; outline: none;
}
.input:focus { border-color: var(--brand); }
.btn-primary {
  width: 100%; background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff;
  padding: 15px; border-radius: 14px; font-size: 16px; font-weight: 700; margin-top: 6px;
}
.btn-primary:active { filter: brightness(1.1); }
.seg-2 { display: flex; gap: 8px; margin-bottom: 14px; }
.seg-2 button { flex: 1; padding: 12px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface-2); font-weight: 600; color: var(--muted); }
.seg-2 button.on-in { background: rgba(46,212,122,.16); color: var(--success); border-color: var(--success); }
.seg-2 button.on-out { background: rgba(255,77,106,.16); color: var(--danger); border-color: var(--danger); }

/* Toast */
.toast { position: fixed; left: 50%; top: 20px; transform: translateX(-50%); z-index: 60;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 18px;
  font-size: 14px; font-weight: 600; box-shadow: 0 8px 24px rgba(0,0,0,.3); animation: drop .3s; }
@keyframes drop { from { opacity: 0; transform: translate(-50%, -20px); } to { opacity: 1; transform: translate(-50%, 0); } }
.hdr-gear { width: 38px; height: 38px; border-radius: 11px; background: var(--surface); border: 1px solid var(--border); font-size: 17px; margin-left: 12px; display: grid; place-items: center; flex-shrink: 0; }
.hdr-gear:active { background: var(--surface-2); transform: scale(.94); }

.set-row { display: flex; align-items: center; gap: 12px; padding: 15px 2px; border-bottom: 1px solid var(--border); }
.set-row:last-child { border-bottom: none; }
.set-row .si { font-size: 20px; width: 26px; text-align: center; }
.set-row .st { flex: 1; min-width: 0; }
.set-row .st b { font-size: 14.5px; display: block; }
.set-row .st span { font-size: 12px; color: var(--muted); }
.set-row .chev { color: var(--muted); font-size: 20px; }

.toggle { width: 50px; height: 30px; border-radius: 20px; background: var(--surface-2); border: 1px solid var(--border); position: relative; transition: .2s; flex-shrink: 0; }
.toggle::after { content: ''; position: absolute; top: 2px; left: 2px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.toggle.on { background: var(--brand); border-color: var(--brand); }
.toggle.on::after { left: 22px; }

.hidden { display: none !important; }
