:root {
  --bg: var(--tg-theme-bg-color, #ffffff);
  --bg2: var(--tg-theme-secondary-bg-color, #f2f2f7);
  --text: var(--tg-theme-text-color, #000000);
  --hint: var(--tg-theme-hint-color, #8e8e93);
  --accent: var(--tg-theme-button-color, #007aff);
  --accent-text: var(--tg-theme-button-text-color, #ffffff);
  --danger: var(--tg-theme-destructive-text-color, #ff3b30);
  --radius: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
#app { max-width: 560px; margin: 0 auto; padding: 16px 16px calc(24px + env(safe-area-inset-bottom)); }
h1 { font-size: 24px; margin: 8px 0 8px; }
h2 { font-size: 20px; margin: 8px 0; }
p { margin: 8px 0; }
.muted { color: var(--hint); }
.small { font-size: 13px; }
.note { color: var(--hint); font-size: 13px; margin-top: 16px; }
.error { color: var(--danger); }
.center { min-height: 70vh; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.center-text { text-align: center; }

form { display: flex; flex-direction: column; gap: 12px; margin-top: 16px; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--hint); }
input { font: inherit; color: var(--text); background: var(--bg2); border: 0; border-radius: var(--radius);
  padding: 12px 14px; width: 100%; outline: none; }
input.code { font-size: 28px; letter-spacing: 10px; text-align: center; }
button { font: inherit; border: 0; cursor: pointer; }
button.primary { background: var(--accent); color: var(--accent-text); border-radius: var(--radius);
  padding: 13px; font-weight: 600; width: 100%; }
button:disabled { opacity: .55; }
button.link { background: none; color: var(--accent); padding: 8px 0; }

.account { display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--bg2); border-radius: var(--radius); padding: 12px 14px; }
.account-name { font-weight: 600; }
.quota { margin-top: 10px; font-size: 14px; color: var(--hint); }
.quota.empty { color: var(--danger); }

.tabs { display: flex; gap: 4px; background: var(--bg2); border-radius: var(--radius); padding: 3px; margin: 16px 0 12px; }
.tab { flex: 1; background: none; color: var(--text); padding: 8px; border-radius: 9px; font-size: 14px; }
.tab.active { background: var(--bg); font-weight: 600; box-shadow: 0 1px 3px rgba(0,0,0,.12); }

#filter { margin-bottom: 8px; }
.apps { list-style: none; margin: 0; padding: 0; }
.app { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--bg2); }
.app-info { flex: 1; min-width: 0; }
.app-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon { width: 48px; height: 48px; border-radius: 11px; flex: none; object-fit: cover; background: var(--bg2); }
.icon.big { width: 80px; height: 80px; border-radius: 18px; }
.icon.placeholder { display: flex; align-items: center; justify-content: center; color: var(--hint); font-weight: 600; font-size: 20px; }
button.get { background: var(--bg2); color: var(--accent); font-weight: 600; font-size: 14px;
  border-radius: 999px; padding: 6px 14px; flex: none; }

.progress-line { margin: 8px 0; }
.bar { height: 4px; background: var(--bg2); border-radius: 2px; overflow: hidden; margin-bottom: 6px; }
.bar > div { height: 100%; width: 0; background: var(--accent); transition: width .3s; }

.sheet { position: fixed; inset: 0; background: rgba(0,0,0,.4); display: flex; align-items: flex-end; z-index: 10; }
.sheet-body { background: var(--bg); width: 100%; max-width: 560px; margin: 0 auto; border-radius: 16px 16px 0 0;
  padding: 24px 20px calc(20px + env(safe-area-inset-bottom)); text-align: center; }
.sheet-body .primary { margin-top: 8px; }

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

.toast { position: fixed; left: 16px; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 20;
  background: rgba(30,30,30,.92); color: #fff; padding: 12px 14px; border-radius: var(--radius); font-size: 14px; }
[hidden] { display: none !important; }
.tg-login { display: flex; justify-content: center; min-height: 56px; margin: 24px 0 8px; }
.done-check { width: 56px; height: 56px; margin: 8px auto; border-radius: 50%; background: #34c759; color: #fff;
  font-size: 32px; line-height: 56px; font-weight: 700; }
