:root {
  --bg: #f1f3f8; --card: #ffffff; --card2: #f6f7fb; --text: #121826; --muted: #6b7385; --line: rgba(18, 24, 38, .08);
  --accent: #16a34a; --accent-2: #0ea5a4; --indigo: #5b5bd6; --warn: #f59e0b; --bad: #e5484d; --info: #3b82f6;
  --hero-a: #16a34a; --hero-b: #0e9fae; --shadow: 0 1px 2px rgba(18, 24, 38, .05), 0 6px 18px rgba(18, 24, 38, .06);
  --radius: 18px; --tab-h: 64px;
}
:root[data-theme="dark"] {
  --bg: #0e1116; --card: #171b23; --card2: #1d222c; --text: #f2f4f8; --muted: #97a0b3; --line: rgba(255, 255, 255, .08);
  --accent: #34d27b; --accent-2: #22c3c1; --indigo: #8b8bf5; --warn: #fbbf24; --bad: #ff6369; --info: #60a5fa;
  --hero-a: #138a43; --hero-b: #0b7c88; --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.35 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif; }
body { min-height: 100vh; }
#app { max-width: 520px; margin: 0 auto; padding: 14px 14px calc(var(--tab-h) + 28px + env(safe-area-inset-bottom)); }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; padding: 0; }
h1, h2, h3, p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.row { display: flex; align-items: center; gap: 10px; }
.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.col { display: flex; flex-direction: column; gap: 10px; }
.gap-lg { gap: 16px; }
.num { font-variant-numeric: tabular-nums; }
.green { color: var(--accent); } .red { color: var(--bad); } .amber { color: var(--warn); }

.card { background: var(--card); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.card.flat { box-shadow: none; border: 1px solid var(--line); }
.section-title { display: flex; justify-content: space-between; align-items: baseline; margin: 18px 4px 8px; font-weight: 700; font-size: 17px; }
.section-title a, .link { color: var(--indigo); font-size: 14px; font-weight: 600; text-decoration: none; }

/* шапка */
.top { display: flex; align-items: center; gap: 12px; padding: 4px 4px 12px; }
.avatar { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; color: #fff;
  background: linear-gradient(135deg, var(--indigo), var(--accent-2)); flex: none; }
.top h1 { font-size: 20px; letter-spacing: -.2px; }
.back { width: 38px; height: 38px; border-radius: 12px; background: var(--card); box-shadow: var(--shadow); display: grid; place-items: center; font-size: 18px; flex: none; }

/* главная карточка баланса */
.hero { position: relative; overflow: hidden; border-radius: 24px; padding: 18px; color: #fff;
  background: radial-gradient(120% 140% at 100% 0%, rgba(255, 255, 255, .22), transparent 55%), linear-gradient(135deg, var(--hero-a), var(--hero-b));
  box-shadow: 0 10px 28px rgba(14, 159, 174, .28); }
.hero .label { opacity: .85; font-size: 14px; }
.hero .big { font-size: 40px; font-weight: 800; letter-spacing: -1px; margin: 2px 0 10px; }
.hero .chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 999px; font-size: 13px; font-weight: 600; background: rgba(255, 255, 255, .18); }
.chip.solid { background: var(--card2); color: var(--text); }
.chip.good { background: rgba(22, 163, 74, .14); color: var(--accent); }
.chip.bad { background: rgba(229, 72, 77, .14); color: var(--bad); }
.chip.warn { background: rgba(245, 158, 11, .16); color: var(--warn); }
.chip.info { background: rgba(59, 130, 246, .14); color: var(--info); }
.pulse { width: 8px; height: 8px; border-radius: 50%; background: #b9ffd2; box-shadow: 0 0 0 0 rgba(185, 255, 210, .7); animation: pulse 1.8s infinite; }
.pulse.off { background: rgba(255, 255, 255, .5); animation: none; }
@keyframes pulse { 70% { box-shadow: 0 0 0 9px rgba(185, 255, 210, 0); } 100% { box-shadow: 0 0 0 0 rgba(185, 255, 210, 0); } }
.hero .foot { margin-top: 12px; padding-top: 10px; border-top: 1px solid rgba(255, 255, 255, .22); display: flex; justify-content: space-between; font-size: 13px; opacity: .92; }

/* плитки */
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 12px; }
.tile { background: var(--card); border-radius: 16px; padding: 12px 10px; box-shadow: var(--shadow); text-align: center; }
.tile .v { font-weight: 800; font-size: 18px; margin-top: 2px; }
.tile .k { font-size: 12px; color: var(--muted); }

/* внимание */
.alert { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 16px; background: var(--card); box-shadow: var(--shadow); text-align: left; width: 100%; border-left: 4px solid var(--info); }
.alert.bad { border-left-color: var(--bad); } .alert.warn { border-left-color: var(--warn); } .alert.good { border-left-color: var(--accent); }
.alert .ic { font-size: 22px; }
.alert .go { color: var(--indigo); font-weight: 700; font-size: 14px; white-space: nowrap; }

/* бизнес-карточка */
.biz { display: block; width: 100%; text-align: left; background: var(--card); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.biz + .biz { margin-top: 10px; }
.tilebox { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; font-size: 26px; background: var(--card2); flex: none; }
.biz .t { font-weight: 700; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar { height: 8px; border-radius: 99px; background: var(--card2); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .6s ease; }
.bar.low > i { background: linear-gradient(90deg, var(--warn), #fb923c); }
.bar.empty > i { background: var(--bad); }
.biz .meta { display: flex; justify-content: space-between; margin-top: 8px; font-size: 13px; }
.biz-add { display: block; width: 100%; text-align: left; border: 2px dashed var(--line); border-radius: var(--radius); padding: 14px; margin-top: 10px; }
.biz-add.ready { border-color: var(--accent); }

/* кнопки */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 12px 16px; border-radius: 14px; font-weight: 700; background: var(--card2); }
.btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; box-shadow: 0 6px 16px rgba(22, 163, 74, .3); }
.btn.danger { color: var(--bad); background: rgba(229, 72, 77, .1); }
.btn.block { display: flex; width: 100%; }
.btn.sm { padding: 8px 12px; border-radius: 12px; font-size: 14px; }
.btn[disabled] { opacity: .45; pointer-events: none; box-shadow: none; }
.btn:active { transform: scale(.98); }

/* сетка показателей */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat { background: var(--card); border-radius: 16px; padding: 12px; box-shadow: var(--shadow); }
.stat .k { font-size: 12px; color: var(--muted); }
.stat .v { font-size: 20px; font-weight: 800; margin-top: 2px; letter-spacing: -.3px; }
.stat .s { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* сегменты */
.seg { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 10px; scrollbar-width: none; }
.seg::-webkit-scrollbar { display: none; }
.seg button { flex: none; padding: 8px 12px; border-radius: 12px; background: var(--card); font-weight: 600; font-size: 14px; box-shadow: var(--shadow); }
.seg button.on { background: var(--text); color: var(--bg); }

/* списки */
.item { display: flex; align-items: center; gap: 12px; padding: 12px; background: var(--card); border-radius: 16px; box-shadow: var(--shadow); }
.item + .item { margin-top: 10px; }
.dots { display: inline-flex; gap: 4px; }
.dots i { width: 9px; height: 9px; border-radius: 50%; background: var(--line); }
.dots i.on { background: var(--accent); }
.medal { width: 30px; text-align: center; font-weight: 800; }
.me { outline: 2px solid var(--indigo); }

/* нижняя панель */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; background: color-mix(in srgb, var(--card) 92%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom); }
.tabbar nav { max-width: 520px; margin: 0 auto; height: var(--tab-h); display: grid; grid-template-columns: repeat(4, 1fr); }
.tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; text-decoration: none; color: var(--muted); font-size: 11px; font-weight: 600; }
.tabbar a .e { font-size: 22px; filter: grayscale(1); opacity: .65; }
.tabbar a.on { color: var(--text); }
.tabbar a.on .e { filter: none; opacity: 1; }

/* тосты и шторка */
.toast { position: fixed; left: 50%; top: 14px; transform: translate(-50%, -140%); z-index: 50; max-width: min(92vw, 460px); padding: 11px 16px; border-radius: 14px;
  background: var(--text); color: var(--bg); font-weight: 600; font-size: 14px; box-shadow: 0 10px 30px rgba(0, 0, 0, .25); transition: transform .3s ease; text-align: center; }
.toast.show { transform: translate(-50%, 0); }
.toast.bad { background: var(--bad); color: #fff; }
.scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, .45); z-index: 40; display: flex; align-items: flex-end; justify-content: center; animation: fade .2s; }
.sheet { width: 100%; max-width: 520px; background: var(--card); border-radius: 24px 24px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); animation: up .25s ease; }
@keyframes fade { from { opacity: 0; } } @keyframes up { from { transform: translateY(40px); opacity: 0; } }

/* ввод */
input[type=text] { width: 100%; padding: 13px 14px; border-radius: 14px; border: 1px solid var(--line); background: var(--card2); color: var(--text); font: inherit; outline: none; }
input[type=text]:focus { border-color: var(--indigo); }
.pick { display: block; width: 100%; text-align: left; border-radius: 16px; padding: 12px; background: var(--card); box-shadow: var(--shadow); border: 2px solid transparent; }
.pick + .pick { margin-top: 10px; }
.pick.on { border-color: var(--accent); }
.switch { width: 50px; height: 30px; border-radius: 99px; background: var(--line); position: relative; flex: none; transition: .2s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.switch.on { background: var(--accent); } .switch.on::after { left: 23px; }
.center { text-align: center; }
.splash { min-height: 70vh; display: grid; place-items: center; text-align: center; color: var(--muted); }
.spin { width: 30px; height: 30px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--indigo); animation: rot 1s linear infinite; margin: 0 auto 12px; }
@keyframes rot { to { transform: rotate(360deg); } }
.tip { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 16px; background: var(--card2); font-size: 14px; color: var(--muted); margin-top: 14px; }

.hero .spark { margin-top: 14px; }
.hero .sparkcap { display: flex; justify-content: space-between; font-size: 11px; opacity: .7; margin-top: 3px; }
.qas { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 12px; }
.qa { background: var(--card); border-radius: 16px; padding: 12px 6px; box-shadow: var(--shadow); font-weight: 700; font-size: 13px; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.qa .e { font-size: 24px; }
.qa.hot { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; }
