:root {
  --bg: var(--tg-theme-bg-color, #ffffff);
  --bg2: var(--tg-theme-secondary-bg-color, #f2f3f5);
  --text: var(--tg-theme-text-color, #111);
  --hint: var(--tg-theme-hint-color, #8a8f98);
  --link: var(--tg-theme-link-color, #2481cc);
  --btn: var(--tg-theme-button-color, #2481cc);
  --btn-text: var(--tg-theme-button-text-color, #fff);
  --danger: #e5484d;
  --ok: #30a46c;
  --warn: #f5a524;
  --radius: 14px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
#app { min-height: 100vh; padding: 16px 16px calc(24px + env(safe-area-inset-bottom)); max-width: 560px; margin: 0 auto; }
.screen { animation: fade .18s ease-out; }
.hidden { display: none !important; }
.center { text-align: center; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.screen.center { min-height: 70vh; }
.muted { color: var(--hint); }
.tiny { font-size: 12px; }
.error { color: var(--danger); min-height: 1.4em; margin: 6px 0 0; font-size: 14px; }
h1 { font-size: 20px; margin: 0; }
h2 { margin: 12px 0 4px; }
.big-icon { font-size: 48px; }
@keyframes fade { from { opacity: 0; transform: translateY(4px);} to { opacity: 1; transform: none; } }

.topbar { display: flex; align-items: center; gap: 12px; padding: 4px 0 16px; }
.topbar h1 { flex: 1; }
.icon-btn { background: var(--bg2); border: 0; color: var(--text); width: 38px; height: 38px; border-radius: 50%; font-size: 18px; cursor: pointer; }

button { font: inherit; cursor: pointer; }
.primary { background: var(--btn); color: var(--btn-text); border: 0; border-radius: var(--radius); padding: 14px 18px; font-weight: 600; }
.primary:disabled { opacity: .55; }
.ghost { background: var(--bg2); color: var(--text); border: 0; border-radius: var(--radius); padding: 14px 18px; }
.danger { background: var(--danger); color: #fff; border: 0; border-radius: var(--radius); padding: 14px 18px; font-weight: 600; }
.wide { width: 100%; margin-top: 12px; }
.small { padding: 8px 12px; font-size: 14px; border-radius: 10px; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }

label { display: block; font-size: 13px; color: var(--hint); margin: 14px 0 6px; }
input { width: 100%; padding: 14px; font-size: 18px; border-radius: var(--radius); border: 1px solid transparent;
  background: var(--bg2); color: var(--text); outline: none; }
input:focus { border-color: var(--btn); }
.banner { border-radius: var(--radius); padding: 12px 14px; font-size: 14px; margin: 0 0 8px; }
.banner.info { background: var(--bg2); }
.banner.warn { background: rgba(245,165,36,.15); color: var(--text); }
.status { min-height: 1.4em; font-size: 14px; margin: 12px 0 0; }
.status.err { color: var(--danger); }
.status.ok { color: var(--ok); }

/* пин */
.pin-dots { display: flex; gap: 14px; margin: 18px 0 4px; }
.pin-dots span { width: 14px; height: 14px; border-radius: 50%; background: var(--bg2); border: 2px solid var(--hint); }
.pin-dots span.on { background: var(--btn); border-color: var(--btn); }
.pin-dots.shake { animation: shake .35s; }
@keyframes shake { 0%,100% { transform: translateX(0);} 25% { transform: translateX(-8px);} 75% { transform: translateX(8px);} }
.keypad { display: grid; grid-template-columns: repeat(3, 72px); gap: 12px; margin-top: 14px; }
.keypad button { height: 72px; border-radius: 50%; border: 0; background: var(--bg2); color: var(--text); font-size: 26px; }
.keypad button:active { filter: brightness(.9); }
.keypad button.ghost { font-size: 18px; }

/* список аккаунтов */
.list { display: flex; flex-direction: column; gap: 10px; }
.card { background: var(--bg2); border-radius: var(--radius); padding: 12px 14px; display: flex; gap: 12px; align-items: flex-start; }
.avatar { width: 44px; height: 44px; border-radius: 50%; background: var(--btn); color: var(--btn-text); display: flex; align-items: center;
  justify-content: center; font-weight: 700; font-size: 18px; flex-shrink: 0; }
.card .body { flex: 1; min-width: 0; }
.card .title { font-weight: 600; display: flex; align-items: center; gap: 8px; }
.card .sub { font-size: 13px; color: var(--hint); margin-top: 2px; word-break: break-word; }
.card .err { font-size: 12px; color: var(--danger); margin-top: 4px; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.dot.online { background: var(--ok); }
.dot.offline { background: var(--hint); }
.dot.dead { background: var(--danger); }
.dot.out { background: var(--warn); }
.card .actions { display: flex; flex-direction: column; gap: 6px; }
.card .actions button { white-space: nowrap; }

.modal { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 10; }
.modal-box { background: var(--bg); border-radius: 18px; padding: 20px; width: 100%; max-width: 360px; }
.modal-box p { margin: 0 0 16px; }
.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--text); color: var(--bg);
  padding: 10px 16px; border-radius: 12px; font-size: 14px; z-index: 20; max-width: 90vw; }
.spinner { width: 36px; height: 36px; border: 3px solid var(--bg2); border-top-color: var(--btn); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
