:root {
  --bg: #f0f2f5;
  --surface: #fff;
  --surface-2: #f8f9fa;
  --line: #dee2e6;
  --line-soft: #e9ecef;
  --line-strong: #ced4da;
  --ink: #212529;
  --ink-2: #6c757d;
  --ink-3: #adb5bd;
  --black: #101010;
  --black-hover: #2a2a2a;
  --ok: #22bb66;
  --ok-ink: #177a43;
  --veil: rgba(16, 16, 16, 0.4);
  --focus: rgba(16, 16, 16, 0.15);
  --danger: var(--ink-2);
  --mono: ui-monospace, 'SF Mono', Menlo, Consolas, 'Liberation Mono', monospace;
  --r-card: 12px;
  --r-btn: 8px;
  --r-ic: 10px;
  --tabs: 60px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  font: 400 16px/1.5 'Space Grotesk', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  background: var(--bg);
  min-height: 100vh;
}

[hidden] { display: none !important; }

button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; }
b { font-weight: 500; }
small { display: block; color: var(--ink-2); font-size: 14px; line-height: 1.4; }
code { font: 500 13px/1 var(--mono); background: var(--surface-2); padding: 2px 6px; border-radius: 4px; color: var(--ink); }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.screen { min-height: 100vh; }

.phone {
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  padding: 16px 16px calc(var(--tabs) + 24px);
}

.mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--black);
  color: #fff;
  font: 600 16px/1 inherit;
  flex-shrink: 0;
}
.mark.big { width: 48px; height: 48px; border-radius: 12px; font-size: 24px; margin: 0 auto 14px; }

.welcome { text-align: center; padding: 40px 0 24px; }
.welcome h1 { font: 600 20px/1.25 inherit; }
.welcome p { color: var(--ink-2); font-size: 14px; margin-top: 6px; }

.seg {
  display: flex;
  height: 44px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-btn);
  background: var(--surface);
  overflow: hidden;
  margin-bottom: 16px;
}
.seg-btn { flex: 1; color: var(--ink-2); font-weight: 500; font-size: 15px; }
.seg-btn.active { background: var(--black); color: #fff; }
.seg-btn:hover:not(.active) { background: var(--surface-2); }
.seg-btn:focus-visible { outline-offset: -3px; }

.stack { display: flex; flex-direction: column; gap: 12px; }
.stack.tight { gap: 8px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font: 500 14px/1.4 inherit; }
.field small { font-size: 13px; }
.field small b { color: var(--ink); }
.field input, .field select, textarea {
  width: 100%;
  height: 48px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-btn);
  padding: 12px 14px;
  font-size: 16px;
  color: var(--ink);
}
textarea { height: auto; min-height: 96px; resize: vertical; line-height: 1.5; }
.field input:focus, .field select:focus, textarea:focus { outline: none; border-color: var(--black); box-shadow: 0 0 0 3px var(--focus); }
.field input::placeholder, textarea::placeholder { color: var(--ink-3); }
.field select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cpath d='M4 6l4 4 4-4' fill='none' stroke='%236c757d' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 16px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  height: 40px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-btn);
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
  font-size: 15px;
  line-height: 1;
}
.btn:hover { background: var(--surface-2); }
.btn.big { width: 100%; height: 48px; }
.btn.small { height: 36px; padding: 0 12px; font-size: 14px; }
.btn.primary { background: var(--black); border-color: var(--black); color: #fff; }
.btn.primary:hover { background: var(--black-hover); border-color: var(--black-hover); }
.btn.primary:active { background: #000; }
.btn.primary i { font-size: 18px; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--ink-2); height: 44px; }
.btn.ghost:hover { background: transparent; color: var(--ink); }
.btn.ghost.danger { color: var(--danger); }
.btn.file { cursor: pointer; }
.btn:disabled { opacity: .5; cursor: wait; }
.btn.leave { margin-top: 12px; }

.iconbtn {
  width: 40px;
  height: 40px;
  border-radius: var(--r-btn);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  color: var(--ink-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}
.iconbtn:hover { color: var(--ink); }

.alert {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--black);
  border-radius: var(--r-btn);
  padding: 12px 14px;
  font-size: 14px;
  color: var(--ink);
}
.alert::before {
  content: attr(data-tag);
  display: block;
  width: max-content;
  font: 500 12px/1 var(--mono);
  color: var(--ink-2);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 3px 6px;
  margin-bottom: 8px;
}

.top { display: grid; grid-template-columns: 40px 1fr 40px; align-items: center; height: 56px; margin-bottom: 12px; }
.top h1 { grid-column: 2; text-align: center; font: 600 24px/1.2 inherit; letter-spacing: -0.01em; }
.top .iconbtn[data-back] { grid-column: 1; }
.top .iconbtn:not([data-back]) { grid-column: 3; }

.lead { color: var(--ink-2); font-size: 16px; }
.tip { text-align: center; font-size: 13px; color: var(--ink-2); padding: 4px 8px; }
.tip.mono { font-family: var(--mono); font-weight: 500; }
.foot { text-align: center; color: var(--ink-3); font-size: 13px; padding-top: 12px; }
.empty { padding: 28px 16px; text-align: center; color: var(--ink-2); font-size: 14px; }

.card, .list {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  overflow: hidden;
}
.card-h {
  height: 40px;
  display: flex;
  align-items: center;
  padding: 0 16px;
  border-bottom: 1px solid var(--line-soft);
  font: 500 12px/1 var(--mono);
  color: var(--ink-2);
}
.session { margin-top: 24px; }

.row, .rowbtn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 56px;
  padding: 14px 16px;
  text-align: left;
  border-bottom: 1px solid var(--line-soft);
  background: var(--surface);
}
.row:last-child, .rowbtn:last-child { border-bottom: 0; }
.row { cursor: pointer; }
.rowbtn:hover, .rowbtn:active { background: var(--surface-2); }
.rowbtn.danger b { color: var(--danger); }
.rowbtn:focus-visible, .row:focus-visible { outline-offset: -3px; }
.grow { flex: 1; min-width: 0; }
.grow > b { display: block; font: 500 16px/1.4 inherit; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.grow small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.grow small b { display: inline; color: var(--ink); }
.sheet .grow small { white-space: normal; }
.ic {
  width: 36px;
  height: 36px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-ic);
  background: var(--surface);
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  flex-shrink: 0;
}
.chev { font-size: 12px; color: var(--ink-3); }
.tag {
  display: inline-block;
  font: 500 12px/1 var(--mono);
  padding: 3px 6px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--ink-2);
  white-space: nowrap;
}
.tag.dim { color: var(--ink-3); }

.switch { position: relative; width: 44px; height: 26px; flex-shrink: 0; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch i { position: absolute; inset: 0; border-radius: 999px; background: var(--line); transition: background .15s ease; }
.switch i::after {
  content: "";
  position: absolute;
  top: 1px;
  left: 1px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  border: 1px solid var(--line-strong);
  transition: transform .15s ease, border-color .15s ease;
}
.switch input:checked + i { background: var(--black); }
.switch input:checked + i::after { transform: translateX(18px); border-color: var(--black); }
.switch input:focus-visible + i { outline: 3px solid var(--focus); outline-offset: 2px; }

.status { display: inline-flex; align-items: center; gap: 8px; font: 500 14px/1 inherit; color: var(--ink-2); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--line-strong); display: inline-block; flex-shrink: 0; }
.status.on { color: var(--ok-ink); }
.status.on .dot { background: var(--ok); }
.status.wait .dot { background: #fff; border: 2px solid var(--ink-2); animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .4; } }

.contact {
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 16px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  margin-bottom: 12px;
}
.contact-body { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; min-width: 0; }
.contact-name { font: 600 20px/1.25 inherit; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.contact-foot { grid-column: 1 / -1; border-top: 1px solid var(--line-soft); padding-top: 14px; margin-top: 2px; }
.contact-foot .lead { font-size: 14px; }
.avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--bg);
  border: 1px solid var(--line);
  flex-shrink: 0;
}
.photo-row { display: flex; align-items: center; gap: 16px; }

.stats { margin-top: 24px; }
.stats-body { padding: 20px 16px; text-align: center; border-bottom: 1px solid var(--line-soft); }
.stats .ic { width: 44px; height: 44px; font-size: 18px; margin: 0 auto 12px; }
.stats-n { font: 600 32px/1.1 inherit; display: inline-flex; align-items: center; gap: 8px; }
.stats-n .dot { background: var(--ok); }
.stats-sub { font-size: 14px; color: var(--ink-2); margin-top: 4px; }
.stats-off { font: 500 16px/1.4 inherit; }
.tag-line { font: 500 12px/1.4 var(--mono); color: var(--ink-3); margin-top: 6px; }
.stats-foot { padding: 14px 16px; text-align: left; }
.stats-foot h4 { font: 500 14px/1.4 inherit; color: var(--ink-2); margin-bottom: 4px; }
.stats-name { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; font: 500 16px/1.4 inherit; }
.stats-name b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stats-time { font: 500 14px/1.4 var(--mono); white-space: nowrap; }
.stats-num { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 2px; font: 500 13px/1.4 var(--mono); color: var(--ink-2); }
.stats-line { text-align: center; font-size: 13px; color: var(--ink-2); margin-top: 24px; }
.stats-line .dot { background: var(--ok); vertical-align: middle; margin-right: 4px; }
.stats-line code { background: none; padding: 0; }
.skeleton { height: 14px; border-radius: 4px; background: var(--line-soft); margin: 8px auto; }
.skeleton.w30 { width: 30%; }
.skeleton.w45 { width: 45%; }
.skeleton.w60 { width: 60%; }
.stats-foot .skeleton { margin: 8px 0; }

.cmd { padding: 12px 16px; border-bottom: 1px solid var(--line-soft); }
.cmd:last-child { border-bottom: 0; }
.cmd code { display: inline-block; margin-bottom: 4px; }
.cmd small { color: var(--ink-2); }

.tabs {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--tabs);
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--line);
  z-index: 40;
  padding-bottom: env(safe-area-inset-bottom);
}
.tabs-brand, .rail-logout { display: none; }
.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--ink-2);
  font: 500 12px/1 inherit;
}
.tab i { font-size: 18px; }
.tab.active { color: var(--ink); font-weight: 600; }
.tab:focus-visible { outline-offset: -3px; }

.sheet {
  position: fixed;
  inset: 0;
  background: var(--veil);
  display: none;
  align-items: flex-end;
  justify-content: center;
  z-index: 100;
}
.sheet.open { display: flex; }
.sheet-card {
  width: 100%;
  max-width: 100%;
  max-height: 92vh;
  background: var(--bg);
  border-radius: 16px 16px 0 0;
  box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.05);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: rise .2s ease-out;
}
.sheet-card::before { content: ''; display: block; width: 36px; height: 4px; border-radius: 999px; background: var(--line-strong); margin: 8px auto 0; flex-shrink: 0; }
@keyframes rise { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet-h { display: grid; grid-template-columns: 40px 1fr 40px; align-items: center; height: 56px; padding: 0 16px; flex-shrink: 0; }
.sheet-h h2 { grid-column: 2; text-align: center; font: 600 20px/1.25 inherit; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sheet-h .iconbtn { grid-column: 3; }
.sheet-b { padding: 12px 16px 28px; overflow: auto; min-height: 0; -webkit-overflow-scrolling: touch; }
.sheet-b > * { flex-shrink: 0; }
body.locked { overflow: hidden; }

.pair { display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; padding: 16px; }
.pair small { font-size: 13px; }
.code { font: 600 36px/1 var(--mono); letter-spacing: 0.12em; color: var(--ink); padding: 8px 0; }
.qr { width: min(240px, 100%); padding: 10px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.steps { padding-left: 22px; color: var(--ink-2); font-size: 16px; display: flex; flex-direction: column; gap: 8px; }
.steps b { color: var(--ink); }

.toast {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(var(--tabs) + 16px);
  z-index: 200;
  background: var(--black);
  color: #fff;
  padding: 12px 16px;
  border-radius: var(--r-btn);
  font: 500 14px/1.4 inherit;
  max-width: calc(100vw - 32px);
}
.toast.error { background: var(--surface); color: var(--ink); border: 1px solid var(--black); }

@media (prefers-reduced-motion: reduce) {
  .sheet-card { animation: none; }
  .status.wait .dot { animation: none; }
  .switch i, .switch i::after { transition: none; }
}

@media (min-width: 900px) {
  :root { --tabs: 0px; }
  .app { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
  .tabs {
    position: sticky;
    top: 0;
    height: 100vh;
    flex-direction: column;
    justify-content: flex-start;
    gap: 4px;
    padding: 24px 16px;
    border-top: 0;
    border-right: 1px solid var(--line);
  }
  .tabs-brand { display: flex; align-items: center; gap: 10px; font: 600 18px/1 inherit; padding: 0 8px 24px; }
  .tab { flex: 0 0 auto; flex-direction: row; justify-content: flex-start; gap: 12px; height: 40px; padding: 0 12px; border-radius: var(--r-btn); font-size: 15px; font-weight: 500; }
  .tab i { font-size: 18px; width: 20px; text-align: center; }
  .tab.active { background: var(--black); color: #fff; font-weight: 500; }
  .tab:hover:not(.active) { background: var(--surface-2); }
  .rail-logout { display: inline-flex; margin-top: auto; justify-content: flex-start; padding: 0 12px; }
  .phone { max-width: 640px; padding: 40px 24px 48px; }
  .stats { display: grid; grid-template-columns: 1fr 1fr; }
  .stats .card-h { grid-column: 1 / -1; }
  .stats-body { border-bottom: 0; border-right: 1px solid var(--line-soft); }
  .stats-foot { align-self: center; }
  .sheet { align-items: center; padding: 24px; }
  .sheet-card { width: 560px; border-radius: var(--r-card); border: 1px solid var(--line); max-height: 88vh; box-shadow: none; }
  .sheet-card::before { display: none; }
  .toast { bottom: 24px; }
}
