:root {
  --bg: #04060d;
  --bg-2: #070b18;
  --card: rgba(13, 19, 38, 0.62);
  --card-solid: #0b1226;
  --stroke: rgba(80, 140, 255, 0.14);
  --stroke-strong: rgba(80, 140, 255, 0.32);
  --blue: #3b82f6;
  --blue-deep: #2563eb;
  --cyan: #22d3ee;
  --text: #e9efff;
  --muted: #8b96b8;
  --muted-2: #5b6584;
  --green: #34d399;
  --red: #f87171;
  --amber: #fbbf24;
  --grad: linear-gradient(135deg, #2563eb 0%, #38bdf8 60%, #22d3ee 100%);
  --glow: 0 0 26px rgba(37, 99, 235, 0.38);
  --radius: 18px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

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

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  min-height: 100%;
  overscroll-behavior-y: none;
}

body { padding-bottom: calc(88px + env(safe-area-inset-bottom)); }

#bg3d {
  position: fixed; inset: 0; z-index: 0;
  width: 100%; height: 100%;
  pointer-events: none;
}

.bg-vignette {
  position: fixed; inset: 0; z-index: 1; pointer-events: none;
  background:
    radial-gradient(120% 65% at 50% -10%, rgba(37, 99, 235, 0.20), transparent 60%),
    radial-gradient(90% 50% at 100% 110%, rgba(34, 211, 238, 0.10), transparent 55%),
    linear-gradient(180deg, rgba(4,6,13,0) 55%, rgba(4,6,13,.72) 100%);
}

#app, #gate { position: relative; z-index: 2; }

/* ---------- gate / lock ---------- */
#gate {
  min-height: 100vh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 18px; padding: 32px;
  text-align: center;
}
.gate-logo {
  width: 92px; height: 92px; border-radius: 28px;
  background: var(--grad);
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--glow), inset 0 0 30px rgba(255,255,255,.18);
  font-size: 44px;
  animation: floaty 3.2s ease-in-out infinite;
}
@keyframes floaty { 0%,100% { transform: translateY(0);} 50% { transform: translateY(-8px);} }
.gate-title { font-size: 24px; font-weight: 800; letter-spacing: .4px; }
.gate-sub { color: var(--muted); font-size: 14px; line-height: 1.55; max-width: 300px; }
.gate-spinner {
  width: 30px; height: 30px; border-radius: 50%;
  border: 3px solid rgba(59,130,246,.2); border-top-color: var(--cyan);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.gate-denied .gate-logo { background: linear-gradient(135deg, #7f1d1d, #ef4444); box-shadow: 0 0 26px rgba(239,68,68,.4); }

/* ---------- header ---------- */
.header { padding: 18px 16px 6px; }
.header-top { display: flex; align-items: center; justify-content: space-between; }
.brand-eyebrow {
  font-size: 11px; font-weight: 700; letter-spacing: 3px; color: var(--muted);
  text-transform: uppercase;
}
.brand-title {
  font-size: 30px; font-weight: 800; letter-spacing: .3px; margin-top: 2px;
  background: linear-gradient(100deg, #fff 20%, #93c5fd 60%, #22d3ee 100%);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.live-badge {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 13px; border-radius: 999px;
  background: rgba(52, 211, 153, 0.10); border: 1px solid rgba(52, 211, 153, 0.35);
  color: #6ee7b7; font-size: 12.5px; font-weight: 600;
}
.live-dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--green);
  box-shadow: 0 0 10px rgba(52,211,153,.9);
  animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse { 0%,100% { opacity: 1; transform: scale(1);} 50% { opacity: .45; transform: scale(.75);} }

.sys-chips { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: rgba(59, 130, 246, 0.10); border: 1px solid var(--stroke);
  color: #a9c4ff;
}
.chip b { color: #fff; font-weight: 700; }

/* ---------- layout ---------- */
.view { display: none; padding: 8px 16px 24px; }
.view.active { display: block; animation: fadein .25s ease; }
@keyframes fadein { from { opacity: 0; transform: translateY(6px);} to { opacity: 1; transform: none;} }

.section-card {
  background: var(--card);
  border: 1px solid var(--stroke);
  border-radius: 22px;
  padding: 18px 16px;
  margin-top: 14px;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 12px 40px rgba(2, 6, 18, 0.55);
}
.section-head { display: flex; align-items: center; gap: 12px; margin-bottom: 4px; }
.section-num {
  width: 34px; height: 34px; border-radius: 11px; flex: none;
  background: rgba(59,130,246,.16); border: 1px solid var(--stroke-strong);
  color: #93c5fd; font-weight: 800; font-size: 15px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: inset 0 0 14px rgba(59,130,246,.15);
}
.section-title { font-size: 17.5px; font-weight: 800; }
.section-sub { color: var(--muted); font-size: 12.5px; margin-top: 1px; }

/* finance strip */
.fin-strip { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 14px; }
.fin-card {
  background: var(--card); border: 1px solid var(--stroke); border-radius: var(--radius);
  padding: 13px 14px; backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  position: relative; overflow: hidden;
}
.fin-card::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(80% 90% at 100% 0%, rgba(34,211,238,.08), transparent 55%);
}
.fin-label { font-size: 11.5px; color: var(--muted); font-weight: 600; }
.fin-value { font-size: 21px; font-weight: 800; margin-top: 3px; letter-spacing: .2px; }
.fin-value small { font-size: 13px; color: var(--muted); font-weight: 700; }
.fin-extra { font-size: 11px; color: var(--muted-2); margin-top: 2px; }

/* segments */
.seg-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 14px; }
.seg-card {
  background: rgba(7, 11, 24, 0.72);
  border: 1px solid var(--stroke); border-radius: var(--radius);
  padding: 14px; cursor: pointer; text-align: left;
  color: var(--text); font-family: var(--font);
  transition: transform .12s ease, border-color .15s ease, box-shadow .2s ease;
  position: relative; overflow: hidden;
}
.seg-card:active { transform: scale(.97); border-color: var(--stroke-strong); box-shadow: var(--glow); }
.seg-name { font-size: 12.5px; color: #c0cdec; font-weight: 600; line-height: 1.3; min-height: 32px; display:flex; align-items:flex-start; gap:6px; }
.seg-count { font-size: 26px; font-weight: 800; margin-top: 6px; letter-spacing: .3px; }
.seg-card.wide { grid-column: 1 / -1; }

.skeleton {
  position: relative; overflow: hidden; color: transparent !important; border-radius: 8px;
  background: rgba(90, 120, 190, 0.12) !important; min-width: 48px;
}
.skeleton::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(100deg, transparent 25%, rgba(140, 175, 255, 0.16) 50%, transparent 75%);
  animation: shimmer 1.3s infinite; background-size: 200% 100%;
}
@keyframes shimmer { from { background-position: 180% 0; } to { background-position: -80% 0; } }

.search-btn {
  width: 100%; margin-top: 12px; padding: 15px;
  border-radius: 16px; border: 1px solid var(--stroke-strong);
  background: rgba(10, 16, 34, 0.85); color: var(--text);
  font-size: 15px; font-weight: 700; font-family: var(--font);
  display: flex; align-items: center; justify-content: center; gap: 9px;
  cursor: pointer; transition: box-shadow .2s;
}
.search-btn:active { box-shadow: var(--glow); }

/* ---------- buttons & inputs ---------- */
.btn {
  border: none; border-radius: 14px; padding: 12px 16px;
  font-size: 14px; font-weight: 700; font-family: var(--font);
  cursor: pointer; color: #fff;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  transition: transform .1s ease, opacity .15s, box-shadow .2s;
}
.btn:active { transform: scale(.96); }
.btn:disabled { opacity: .45; pointer-events: none; }
.btn-primary { background: var(--grad); box-shadow: 0 4px 22px rgba(37, 99, 235, 0.4); }
.btn-ghost { background: rgba(59, 130, 246, 0.12); border: 1px solid var(--stroke-strong); color: #a9c4ff; }
.btn-danger { background: rgba(248, 113, 113, 0.14); border: 1px solid rgba(248,113,113,.4); color: #fca5a5; }
.btn-green { background: rgba(52, 211, 153, 0.14); border: 1px solid rgba(52,211,153,.4); color: #6ee7b7; }
.btn-sm { padding: 8px 12px; font-size: 12.5px; border-radius: 11px; }
.btn-block { width: 100%; }

.input {
  width: 100%; padding: 13px 14px; border-radius: 14px;
  border: 1px solid var(--stroke-strong); background: rgba(5, 9, 20, 0.8);
  color: var(--text); font-size: 15px; font-family: var(--font);
  outline: none; transition: border-color .15s, box-shadow .15s;
}
.input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(59,130,246,.18); }
.input::placeholder { color: var(--muted-2); }
.row { display: flex; gap: 8px; align-items: center; }
.row > .input { flex: 1; }

.label { font-size: 12px; color: var(--muted); font-weight: 700; margin: 12px 0 6px; letter-spacing: .3px; }

/* toggle */
.toggle { position: relative; width: 52px; height: 30px; flex: none; cursor: pointer; }
.toggle input { display: none; }
.toggle .track {
  position: absolute; inset: 0; border-radius: 999px;
  background: rgba(90, 110, 160, 0.25); border: 1px solid var(--stroke);
  transition: background .2s, border-color .2s, box-shadow .2s;
}
.toggle .thumb {
  position: absolute; top: 3.5px; left: 4px; width: 23px; height: 23px; border-radius: 50%;
  background: #cbd5f0; transition: transform .18s ease, background .2s;
}
.toggle input:checked + .track { background: rgba(37, 99, 235, 0.55); border-color: var(--blue); box-shadow: 0 0 14px rgba(37,99,235,.5); }
.toggle input:checked + .track + .thumb { transform: translateX(21px); background: #fff; }

/* ---------- tab bar ---------- */
.tabbar {
  position: fixed; left: 12px; right: 12px; bottom: calc(10px + env(safe-area-inset-bottom));
  z-index: 40;
  display: flex; border-radius: 22px; overflow: hidden;
  background: rgba(8, 12, 26, 0.86);
  border: 1px solid var(--stroke-strong);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  box-shadow: 0 10px 44px rgba(2, 5, 16, 0.8);
}
.tab {
  flex: 1; padding: 11px 4px 10px; text-align: center; cursor: pointer;
  background: none; border: none; color: var(--muted); font-family: var(--font);
  font-size: 10.5px; font-weight: 700; display: flex; flex-direction: column; align-items: center; gap: 3px;
  transition: color .15s;
}
.tab svg { width: 22px; height: 22px; }
.tab.active { color: #7cc4ff; }
.tab.active svg { filter: drop-shadow(0 0 8px rgba(59, 130, 246, 0.9)); }

/* ---------- overlays ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 60; display: none;
  background: rgba(2, 4, 10, 0.7); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.overlay.open { display: flex; align-items: flex-end; animation: fadein .18s ease; }
.sheet {
  width: 100%; max-height: 92vh; overflow-y: auto;
  background: linear-gradient(180deg, #0a1124 0%, #060a18 100%);
  border: 1px solid var(--stroke-strong); border-bottom: none;
  border-radius: 26px 26px 0 0;
  padding: 10px 16px calc(26px + env(safe-area-inset-bottom));
  animation: slideup .24s cubic-bezier(.2,.9,.3,1);
}
@keyframes slideup { from { transform: translateY(60px); opacity: .4; } to { transform: none; opacity: 1; } }
.sheet-grip { width: 44px; height: 5px; border-radius: 3px; background: rgba(120,140,190,.35); margin: 4px auto 12px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.sheet-title { font-size: 19px; font-weight: 800; }
.sheet-close {
  width: 34px; height: 34px; border-radius: 12px; border: 1px solid var(--stroke);
  background: rgba(59,130,246,.1); color: #a9c4ff; font-size: 16px; cursor: pointer;
}

/* list rows */
.list { margin-top: 8px; }
.list-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 10px; border-radius: 14px; cursor: pointer;
  border-bottom: 1px solid rgba(80, 140, 255, 0.07);
  transition: background .12s;
}
.list-row:active { background: rgba(59, 130, 246, 0.09); }
.avatar {
  width: 40px; height: 40px; border-radius: 50%; flex: none;
  background: var(--grad); display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 16px; color: #fff;
  box-shadow: 0 0 14px rgba(37, 99, 235, 0.35);
}
.avatar.gray { background: linear-gradient(135deg, #334155, #475569); box-shadow: none; }
.lr-main { flex: 1; min-width: 0; }
.lr-title { font-size: 14.5px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lr-sub { font-size: 12px; color: var(--muted); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lr-right { text-align: right; font-size: 12px; color: var(--muted); flex: none; }

.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 3.5px 9px;
  font-size: 11px; font-weight: 700; border-radius: 999px;
}
.badge-green { background: rgba(52,211,153,.12); color: #6ee7b7; border: 1px solid rgba(52,211,153,.35); }
.badge-red { background: rgba(248,113,113,.1); color: #fca5a5; border: 1px solid rgba(248,113,113,.3); }
.badge-blue { background: rgba(59,130,246,.13); color: #93c5fd; border: 1px solid var(--stroke-strong); }
.badge-gray { background: rgba(120,140,180,.12); color: #aab6d4; border: 1px solid rgba(120,140,180,.25); }
.badge-amber { background: rgba(251,191,36,.1); color: #fcd34d; border: 1px solid rgba(251,191,36,.3); }

/* user card */
.uc-head { display: flex; gap: 14px; align-items: center; padding: 6px 0 12px; }
.uc-avatar { width: 58px; height: 58px; font-size: 24px; border-radius: 20px; }
.uc-name { font-size: 19px; font-weight: 800; }
.uc-id { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.uc-badges { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 7px; }

.stat-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.mini-card {
  background: rgba(7, 11, 24, 0.75); border: 1px solid var(--stroke);
  border-radius: 14px; padding: 11px 12px;
}
.mini-label { font-size: 11px; color: var(--muted); font-weight: 700; }
.mini-value { font-size: 17px; font-weight: 800; margin-top: 2px; }

.key-card {
  background: rgba(7, 11, 24, 0.8); border: 1px solid var(--stroke);
  border-radius: 16px; padding: 14px; margin-top: 10px;
}
.key-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.key-info { font-size: 12.5px; color: var(--muted); margin-top: 8px; line-height: 1.65; }
.key-info b { color: var(--text); font-weight: 700; }
.key-actions { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 12px; }

.divider { height: 1px; background: linear-gradient(90deg, transparent, rgba(80,140,255,.25), transparent); margin: 16px 0 6px; }

/* charts */
.chart-wrap { margin-top: 12px; }
.chart-title { font-size: 13px; font-weight: 800; color: #b9c8ea; margin-bottom: 6px; }
.chart-svg { width: 100%; height: auto; display: block; }
.legend { display: flex; gap: 14px; margin-top: 6px; flex-wrap: wrap; }
.legend-item { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--muted); font-weight: 600; }
.legend-dot { width: 9px; height: 9px; border-radius: 3px; }

.pills { display: flex; gap: 8px; margin-top: 14px; }
.pill {
  flex: 1; padding: 9px; border-radius: 12px; text-align: center; cursor: pointer;
  border: 1px solid var(--stroke); background: rgba(7,11,24,.6);
  color: var(--muted); font-size: 13px; font-weight: 700; font-family: var(--font);
  transition: all .15s;
}
.pill.active {
  background: rgba(37, 99, 235, 0.22); border-color: var(--blue);
  color: #fff; box-shadow: 0 0 16px rgba(37,99,235,.3);
}

/* price grid */
.price-row { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.price-name { flex: 1; font-size: 13px; font-weight: 600; color: #c0cdec; }
.price-input { width: 92px; text-align: right; padding: 9px 10px; font-size: 14px; }

/* progress */
.progress { height: 10px; border-radius: 6px; background: rgba(59,130,246,.12); overflow: hidden; margin-top: 10px; }
.progress-fill { height: 100%; border-radius: 6px; background: var(--grad); width: 0%; transition: width .4s ease; box-shadow: 0 0 12px rgba(34,211,238,.7); }

/* toast */
#toast {
  position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(20px);
  background: rgba(10, 16, 34, 0.95); border: 1px solid var(--stroke-strong);
  border-radius: 14px; padding: 12px 18px; z-index: 100;
  font-size: 13.5px; font-weight: 600; color: var(--text);
  opacity: 0; pointer-events: none; transition: all .25s ease;
  max-width: 86vw; text-align: center;
  box-shadow: 0 8px 30px rgba(2,5,16,.8);
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.ok { border-color: rgba(52,211,153,.5); }
#toast.err { border-color: rgba(248,113,113,.5); }

/* confirm modal */
#confirm {
  position: fixed; inset: 0; z-index: 90; display: none;
  align-items: center; justify-content: center; padding: 28px;
  background: rgba(2, 4, 10, 0.75); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
#confirm.open { display: flex; animation: fadein .15s; }
.confirm-box {
  width: 100%; max-width: 340px; background: #0a1124;
  border: 1px solid var(--stroke-strong); border-radius: 22px; padding: 22px;
  box-shadow: 0 18px 60px rgba(2,5,16,.9);
}
.confirm-title { font-size: 17px; font-weight: 800; }
.confirm-text { font-size: 13.5px; color: var(--muted); margin-top: 8px; line-height: 1.55; }
.confirm-actions { display: flex; gap: 9px; margin-top: 18px; }
.confirm-actions .btn { flex: 1; }

.empty { text-align: center; color: var(--muted-2); font-size: 13px; padding: 22px 0; }
.mt8 { margin-top: 8px; } .mt12 { margin-top: 12px; } .mt16 { margin-top: 16px; }
.muted { color: var(--muted); } .small { font-size: 12px; }
.load-more { width: 100%; margin-top: 10px; }
