/* Эмулятор приложения: нативные элементы в цветах ДС Холодильник.ру. */
:root {
  --sky: #00aaff; --sky-deep: #0099e5; --success: #02d15c; --danger: #f62434;
  --text: #333333; --muted: #8f8f8f; --surface: #f5f5f5; --border: #ebebeb;
  --bar-h: 52px; --tabs-h: 58px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body { background: #e4e7eb; color: var(--text); font: 15px/1.4 -apple-system, system-ui, "Segoe UI", Roboto, sans-serif; overflow: hidden; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; }

.app {
  position: relative; height: 100dvh; max-width: 560px; margin: 0 auto; background: #fff;
  display: flex; flex-direction: column; box-shadow: 0 0 40px rgba(0, 0, 0, 0.08);
}

/* ——— нативная шапка ——— */
.bar {
  flex: none; display: flex; align-items: center; gap: 4px;
  height: calc(var(--bar-h) + env(safe-area-inset-top)); padding: env(safe-area-inset-top) 6px 0;
  background: #fff; border-bottom: 1px solid var(--border); position: relative; z-index: 2;
}
.bar-btn { position: relative; width: 44px; height: 44px; border: 0; background: none; font-size: 22px; cursor: pointer; flex: none; border-radius: 12px; }
.bar-btn:active { background: var(--surface); }
#back { font-size: 34px; line-height: 1; color: var(--sky-deep); font-weight: 300; }
.bar-title { flex: 1; text-align: center; font-weight: 800; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-btn b, .badge {
  position: absolute; top: 2px; right: 0; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--danger); color: #fff; font-size: 11px; font-weight: 800; line-height: 18px; font-style: normal; text-align: center;
}
.bar-btn.log b { background: #333; }
.user.in { background: #e6faef; }

/* ——— веб-view ——— */
.webview { flex: 1; min-height: 0; position: relative; background: var(--surface); }
.webview iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; display: block; }

/* ——— нативное меню ——— */
.tabs {
  flex: none; display: flex; height: calc(var(--tabs-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom); background: #fff; border-top: 1px solid var(--border);
}
.tabs span { position: relative; flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 20px; opacity: 0.5; cursor: default; }
.tabs i { font-style: normal; font-size: 10px; font-weight: 700; margin-top: 2px; }
.tabs .on { opacity: 1; color: var(--sky); cursor: pointer; }
.tabs .badge { top: 4px; right: calc(50% - 22px); }

/* ——— шторки ——— */
.dim { position: fixed; inset: 0; z-index: 30; background: rgba(0, 0, 0, 0.45); animation: fade 0.2s; }
@keyframes fade { from { opacity: 0; } }
.sheet {
  position: fixed; left: 50%; bottom: 0; z-index: 31; transform: translateX(-50%);
  width: 100%; max-width: 560px; max-height: 88dvh; overflow-y: auto;
  background: #fff; border-radius: 24px 24px 0 0; padding: 10px 20px calc(20px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 10px; animation: up 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes up { from { transform: translate(-50%, 100%); } }
.grab { width: 40px; height: 5px; border-radius: 3px; background: var(--border); margin: 0 auto 6px; flex: none; }
.sheet h3 { margin: 0; font-size: 21px; font-weight: 900; text-align: center; }
.sheet-ic { font-size: 44px; text-align: center; }
.muted { color: var(--muted); margin: 0; text-align: center; }
.small { font-size: 13px; }
.lbl { font-size: 13px; font-weight: 700; color: var(--muted); }
.inp { width: 100%; padding: 14px; border: 1px solid var(--border); border-radius: 12px; font: inherit; font-size: 17px; background: var(--surface); }
/* Кнопки — пресеты ДС: Primary (тёмная), Success, Ghost */
.nbtn { width: 100%; border: 0; border-radius: 14px; padding: 15px; font-weight: 800; font-size: 16px; cursor: pointer; }
.nbtn.primary { background: #333333; color: #fff; }
.nbtn.green { background: var(--success); color: #fff; }
.nbtn.ghost { background: var(--surface); }
.nbtn:disabled { opacity: 0.6; }
.sep { margin-top: 8px; padding-top: 12px; border-top: 1px solid var(--border); font-size: 12px; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.sheet-spin { width: 34px; height: 34px; margin: 30px auto; border-radius: 50%; border: 4px solid #e5f6ff; border-top-color: var(--sky); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.log-list { display: flex; flex-direction: column; gap: 8px; }
.log-row { background: var(--surface); border-radius: 12px; padding: 10px 12px; display: flex; flex-direction: column; gap: 3px; }
.log-head { font-weight: 800; font-size: 13px; }
.log-row code { font: 12px/1.35 ui-monospace, Menlo, monospace; word-break: break-all; color: #555; }
.log-row code.ok { color: #02bc53; }
.log-row code.bad { color: var(--danger); }

/* ——— нативное уведомление ——— */
.native-toast {
  position: fixed; left: 50%; top: calc(var(--bar-h) + 10px + env(safe-area-inset-top)); z-index: 40;
  transform: translateX(-50%); max-width: 90vw;
  background: #333333; color: #fff; padding: 12px 18px; border-radius: 14px; font-weight: 700; font-size: 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25); animation: fade 0.2s;
}
