:root {
  --bg: #0d0f14;
  --card: #151823;
  --card2: #1b1f2e;
  --border: #262c40;
  --text: #e8eaf2;
  --muted: #8b93a8;
  --accent: #a06bff;
  --accent2: #6b5bff;
  --green: #3ddc84;
  --red: #ff5c7a;
  --gold: #ffc44d;
  --radius: 16px;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, 'Segoe UI', Roboto, 'Inter', sans-serif;
  padding-bottom: 76px;
  min-height: 100vh;
}

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px 12px;
  background: linear-gradient(180deg, rgba(160,107,255,.12), transparent);
  position: sticky; top: 0; backdrop-filter: blur(12px); z-index: 5;
}
.brand { display: flex; gap: 12px; align-items: center; }
.logo {
  width: 42px; height: 42px; border-radius: 14px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent2)); font-size: 20px;
}
.topbar h1 { font-size: 17px; font-weight: 700; }
.topbar p { font-size: 12px; color: var(--muted); margin-top: 2px; }
.live { width: 9px; height: 9px; border-radius: 50%; background: var(--green); box-shadow: 0 0 10px var(--green); }
.live.off { background: var(--red); box-shadow: 0 0 10px var(--red); }

main { padding: 6px 14px 20px; }

.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; margin-bottom: 12px;
}
.card h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); margin-bottom: 12px; }

.statrow { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 10px; }
.stat { background: var(--card2); border-radius: 12px; padding: 12px; }
.stat b { font-size: 22px; display: block; }
.stat span { font-size: 11px; color: var(--muted); }

.vc { display: flex; justify-content: space-between; align-items: center; padding: 9px 0; border-top: 1px solid var(--border); font-size: 14px; }
.vc:first-of-type { border-top: none; }
.vc .who { color: var(--muted); font-size: 12.5px; margin-top: 3px; }

.pill { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.pill.proj { background: rgba(160,107,255,.16); color: #c9a8ff; }
.pill.div { background: rgba(255,196,77,.14); color: var(--gold); }
.pill.old { background: rgba(255,92,122,.14); color: var(--red); }

.app-item { background: var(--card2); border-radius: 12px; padding: 13px; margin-bottom: 10px; }
.app-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 6px; flex-wrap: wrap; }
.app-nick { font-weight: 700; font-size: 15px; }
.app-sub { font-size: 12px; color: var(--muted); margin-bottom: 10px; }
.btnrow { display: flex; gap: 8px; }
.btn {
  flex: 1; border: none; border-radius: 10px; padding: 10px; font-weight: 700; font-size: 13px; cursor: pointer;
  color: #fff; transition: opacity .15s;
}
.btn:active { opacity: .7; }
.btn.ok { background: linear-gradient(135deg, #2ecc71, #27ae60); }
.btn.no { background: linear-gradient(135deg, #ff5c7a, #e74c3c); }

.rankline { display: flex; justify-content: space-between; padding: 7px 0; border-top: 1px solid var(--border); font-size: 14px; }
.rankline:first-of-type { border-top: none; }
.rankline .cnt { color: var(--muted); }
.projname { font-size: 13px; color: var(--muted); margin: 10px 0 4px; }

.tabsheet { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.chip {
  background: var(--card2); border: 1px solid var(--border); color: var(--muted);
  border-radius: 999px; padding: 7px 14px; font-size: 13px; cursor: pointer;
}
.chip.on { background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff; border-color: transparent; }

/* ИИ-чат */
.chat { display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 85%; padding: 11px 14px; border-radius: 16px; font-size: 14px; line-height: 1.45; white-space: pre-wrap; word-break: break-word; }
.msg.me { align-self: flex-end; background: linear-gradient(135deg, var(--accent), var(--accent2)); border-bottom-right-radius: 5px; }
.msg.bot { align-self: flex-start; background: var(--card2); border: 1px solid var(--border); border-bottom-left-radius: 5px; }
.chatbar {
  position: fixed; left: 0; right: 0; bottom: 70px; padding: 10px 14px;
  display: flex; gap: 8px; background: var(--bg);
}
.chatbar input {
  flex: 1; background: var(--card2); border: 1px solid var(--border); color: var(--text);
  border-radius: 12px; padding: 12px 14px; font-size: 14px; outline: none;
}
.chatbar input:focus { border-color: var(--accent); }
.chatbar button {
  background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff; border: none;
  border-radius: 12px; padding: 0 18px; font-size: 16px; cursor: pointer;
}
.bigbtn {
  width: 100%; border: none; border-radius: var(--radius); padding: 15px; font-size: 15px; font-weight: 700;
  color: #fff; background: linear-gradient(135deg, var(--accent), var(--accent2)); cursor: pointer;
}
.analyze-out { font-size: 14px; line-height: 1.55; white-space: pre-wrap; word-break: break-word; }
.hint { color: var(--muted); font-size: 13px; text-align: center; padding: 30px 10px; }

.bigstate { font-size: 26px; font-weight: 800; margin: 6px 0 4px; }
.bigstate.on { color: var(--green); text-shadow: 0 0 24px rgba(61,220,132,.4); }
.center { text-align: center; }
.muted { color: var(--muted); font-size: 13px; margin: 6px 0 12px; }
.muted.small { font-size: 11.5px; margin: 8px 0 0; }
.field {
  width: 100%; background: var(--card2); border: 1px solid var(--border); color: var(--text);
  border-radius: 12px; padding: 11px 13px; font-size: 14px; outline: none; margin-bottom: 8px;
}
.field:focus { border-color: var(--accent); }
.fieldrow { display: flex; gap: 8px; }
.picker { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }

/* Нижние табы */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; display: flex;
  background: rgba(21,24,35,.92); backdrop-filter: blur(14px); border-top: 1px solid var(--border);
  padding: 6px 4px calc(8px + env(safe-area-inset-bottom));
}
.tab {
  flex: 1; background: none; border: none; color: var(--muted); font-size: 10.5px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 5px 0; position: relative;
}
.tab span { font-size: 19px; }
.tab.active { color: var(--accent); }
.badge {
  position: absolute; top: 0; right: calc(50% - 22px);
  background: var(--red); color: #fff; font-size: 10px; font-weight: 700;
  min-width: 16px; height: 16px; border-radius: 999px; display: grid; place-items: center; padding: 0 4px;
}
.toast {
  position: fixed; bottom: 90px; left: 50%; transform: translateX(-50%);
  background: var(--card2); border: 1px solid var(--border); color: var(--text);
  padding: 10px 18px; border-radius: 12px; font-size: 13.5px; z-index: 50; max-width: 88%;
}
.toast.err { border-color: var(--red); }
