:root {
  --font-display: 'Exo 2', sans-serif;
  --font-ui: 'IBM Plex Sans', sans-serif;
  --blue: #378ADD;
  --green: #639922;
  --amber: #EF9F27;
  --red: #E24B4A;
  --text: #E8EAF0;
  --text-muted: #A8ABBF;
  --text-dim: #5A5E78;
}

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

body {
  min-height: 100svh;
  background:
    radial-gradient(ellipse 80% 60% at 50% -10%, rgba(30,50,90,0.55), transparent 55%),
    radial-gradient(ellipse 50% 40% at 20% 80%, rgba(20,40,20,0.2), transparent 50%),
    #07090F;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 36px 24px 60px;
  font-family: var(--font-ui);
  color: var(--text);
}

.page-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  margin-bottom: 28px;
  text-align: center;
}
.page-header img {
  width: 110px;
  height: auto;
  filter: drop-shadow(0 6px 18px rgba(0,0,0,0.35));
  margin-bottom: 4px;
}
.page-label {
  font-family: var(--font-display);
  font-size: 12px;
  color: var(--text-dim);
  letter-spacing: .2em;
  text-transform: uppercase;
}
.page-back {
  font-family: var(--font-display);
  font-size: 13px;
  color: var(--text-dim);
  text-decoration: none;
  border: 1px solid rgba(255,255,255,0.07);
  background: rgba(255,255,255,0.03);
  border-radius: 999px;
  padding: 5px 13px;
  margin-top: 8px;
  transition: background .15s, color .15s;
}
.page-back:hover { background: rgba(255,255,255,0.07); color: var(--text-muted); }

/* ── Phone frame ── */
.phone-frame {
  width: 375px;
  height: 812px;
  background: #0B0E18;
  border-radius: 52px;
  border: 1.5px solid rgba(255,255,255,0.18);
  box-shadow:
    0 0 0 3px rgba(0,0,0,0.85),
    0 0 0 4.5px rgba(255,255,255,0.07),
    0 48px 110px rgba(0,0,0,0.75),
    inset 0 0 0 1px rgba(255,255,255,0.04);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
  flex-shrink: 0;
}
.phone-frame::before {
  content: '';
  position: absolute;
  right: -5px; top: 168px;
  width: 4px; height: 72px;
  background: rgba(255,255,255,0.13);
  border-radius: 2px 0 0 2px;
  z-index: 20;
}
.phone-frame::after {
  content: '';
  position: absolute;
  left: -5px; top: 122px;
  width: 4px; height: 36px;
  background: rgba(255,255,255,0.13);
  border-radius: 0 2px 2px 0;
  box-shadow: 0 54px 0 rgba(255,255,255,0.13), 0 102px 0 rgba(255,255,255,0.13);
  z-index: 20;
}
.dynamic-island {
  position: absolute;
  top: 10px; left: 50%;
  transform: translateX(-50%);
  width: 120px; height: 34px;
  background: #000;
  border-radius: 20px;
  z-index: 10;
}

/* ── Status bar ── */
.status-bar {
  flex-shrink: 0;
  height: 52px;
  display: flex;
  align-items: flex-end;
  padding: 0 28px 9px;
  justify-content: space-between;
  position: relative; z-index: 5;
}
.status-time {
  font-family: var(--font-display);
  font-size: 15px; font-weight: 600;
  color: var(--text); letter-spacing: .02em;
}
.status-icons { display: flex; align-items: center; gap: 6px; }

/* ── App nav ── */
.app-nav {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 18px 10px;
  background: rgba(11,14,24,0.98);
  border-bottom: 1px solid rgba(255,255,255,0.07);
  min-height: 54px;
}
.app-icon {
  width: 34px; height: 34px;
  border-radius: 10px;
  background: rgba(55,138,221,0.14);
  border: 1px solid rgba(55,138,221,0.22);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.app-nav-info { flex: 1; min-width: 0; }
.app-nav-title {
  font-family: var(--font-display);
  font-size: 15px; font-weight: 700;
  color: var(--text); line-height: 1.25;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.app-nav-sub {
  font-size: 11px; color: var(--text-dim); line-height: 1.3;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.nav-back-btn {
  width: 32px; height: 32px;
  border-radius: 9px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  color: var(--text-muted);
  font-size: 16px; font-weight: 600;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: background .15s;
}
.nav-back-btn:hover { background: rgba(255,255,255,0.1); }

/* ── Site tabs ── */
.site-tabs {
  flex-shrink: 0;
  display: flex;
  padding: 8px 14px; gap: 7px;
  overflow-x: auto;
  background: rgba(10,13,20,0.7);
  border-bottom: 1px solid rgba(255,255,255,0.05);
  scrollbar-width: none;
}
.site-tabs::-webkit-scrollbar { display: none; }
.site-tab {
  flex-shrink: 0;
  font-family: var(--font-display);
  font-size: 12px; font-weight: 500;
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.04);
  color: var(--text-dim);
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
  display: flex; align-items: center; gap: 5px;
  white-space: nowrap;
}
.site-tab.active {
  background: rgba(55,138,221,0.14);
  border-color: rgba(55,138,221,0.34);
  color: var(--blue);
}
.tab-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.tab-dot-amber { background: #EF9F27; }
.tab-dot-red   { background: #E24B4A; }
.tab-dot-green { background: #639922; }
.tab-dot-blue  { background: #378ADD; }

/* ── Chat area ── */
.chat-area {
  flex: 1;
  overflow-y: auto;
  padding: 10px 12px 4px;
  display: flex;
  flex-direction: column;
  gap: 0;
  scrollbar-width: none;
  background: #0B0E18;
}
.chat-area::-webkit-scrollbar { display: none; }

/* ── Date divider ── */
.date-div {
  text-align: center; font-size: 11px;
  color: var(--text-dim);
  margin: 6px 0 10px;
  position: relative;
}
.date-div::before {
  content: '';
  position: absolute; top: 50%; left: 0; right: 0;
  height: 1px; background: rgba(255,255,255,0.06);
  transform: translateY(-50%);
}
.date-div span { position: relative; background: #0B0E18; padding: 0 8px; }

/* ── Message bubbles ── */
.msg-row { display: flex; gap: 7px; margin-bottom: 8px; align-items: flex-end; }
.msg-row.msg-left  { max-width: 88%; }
.msg-row.msg-right { flex-direction: row-reverse; margin-left: auto; max-width: 80%; }
.msg-av {
  width: 26px; height: 26px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-size: 8px; font-weight: 700;
  flex-shrink: 0; letter-spacing: 0;
}
.msg-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.msg-author {
  font-size: 10px; color: var(--text-dim);
  margin-bottom: 1px; padding-left: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 180px;
}
.msg-author-ai { color: rgba(55,138,221,0.75); }
.bubble {
  padding: 7px 11px;
  border-radius: 17px;
  font-size: 13px; line-height: 1.5;
  color: var(--text); word-break: break-word;
}
.bubble-other {
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.06);
  border-bottom-left-radius: 4px;
}
.bubble-own {
  background: rgba(55,138,221,0.22);
  border: 1px solid rgba(55,138,221,0.28);
  border-bottom-right-radius: 4px;
}
.bubble-ai {
  background: rgba(55,138,221,0.09);
  border: 1px solid rgba(55,138,221,0.18);
  border-bottom-left-radius: 4px;
  color: rgba(190,220,255,0.9);
}
.msg-time { font-size: 10px; color: var(--text-dim); padding-left: 2px; opacity: .65; }
.msg-time-right { text-align: right; padding-right: 2px; padding-left: 0; }

/* явка bubble */
.bubble-cnt {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 14px;
  padding: 6px 11px;
  display: flex; align-items: baseline; gap: 5px;
}
.cnt-label { font-size: 10px; color: var(--text-dim); }
.cnt-num { font-family: var(--font-display); font-size: 19px; font-weight: 700; color: var(--blue); line-height: 1; }
.cnt-unit { font-size: 11px; color: var(--text-dim); }

/* ── Branch list (Задачи view) ── */
.branch-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
}
.branch-card {
  background: linear-gradient(180deg, rgba(22,28,40,0.98), rgba(16,21,30,0.98));
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 14px;
  padding: 12px 14px;
  cursor: pointer;
  transition: border-color .15s, transform .15s;
  position: relative;
  overflow: hidden;
}
.branch-card::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  border-radius: 14px 0 0 14px;
}
.branch-card:active { transform: scale(0.985); }

/* left accent by status */
.branch-card.bc-red::before   { background: var(--red); }
.branch-card.bc-amber::before { background: var(--amber); }
.branch-card.bc-blue::before  { background: var(--blue); }
.branch-card.bc-green::before { background: var(--green); }

.branch-card-top {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 6px;
}
.branch-card-info { flex: 1; min-width: 0; }
.branch-card-title {
  font-family: var(--font-display);
  font-size: 13px; font-weight: 600;
  color: var(--text); line-height: 1.35;
  margin-bottom: 2px;
}
.branch-card-meta { font-size: 11px; color: var(--text-dim); line-height: 1.4; }

/* badges */
.branch-badge {
  font-family: var(--font-display);
  font-size: 10px; font-weight: 600;
  padding: 3px 8px;
  border-radius: 999px;
  flex-shrink: 0;
  white-space: nowrap;
}
.badge-br { background: rgba(226,75,74,0.15); border: 1px solid rgba(226,75,74,0.3); color: #E24B4A; }
.badge-ba { background: rgba(239,159,39,0.15); border: 1px solid rgba(239,159,39,0.3); color: #EF9F27; }
.badge-bb { background: rgba(55,138,221,0.15); border: 1px solid rgba(55,138,221,0.3); color: #378ADD; }
.badge-bg2{ background: rgba(99,153,34,0.15);  border: 1px solid rgba(99,153,34,0.3);  color: #639922; }

/* progress bar */
.branch-prow {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}
.branch-pbar {
  flex: 1;
  height: 4px;
  background: rgba(255,255,255,0.07);
  border-radius: 2px;
  overflow: hidden;
}
.branch-pfill {
  height: 100%; border-radius: 2px;
}
.pfill-fr { background: var(--red); }
.pfill-fa { background: var(--amber); }
.pfill-fb { background: var(--blue); }
.pfill-fg { background: var(--green); }
.branch-ppct {
  font-family: var(--font-display);
  font-size: 11px;
  color: var(--text-dim);
  flex-shrink: 0;
  width: 30px;
  text-align: right;
}

/* branch section header */
.bsection-head {
  font-family: var(--font-display);
  font-size: 11px;
  letter-spacing: .13em;
  text-transform: uppercase;
  color: var(--text-dim);
  padding: 10px 14px 4px;
  flex-shrink: 0;
  border-top: 1px solid rgba(255,255,255,0.05);
  background: #0B0E18;
}
.bsection-head:first-child { border-top: none; }

/* ── Branch detail progress bar ── */
.branch-detail-progress {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  background: rgba(10,13,20,0.9);
  border-bottom: 1px solid rgba(255,255,255,0.05);
}
.branch-detail-progress .branch-pbar { flex: 1; height: 5px; }
.detail-pct {
  font-family: var(--font-display);
  font-size: 13px; font-weight: 500;
  color: var(--text-muted);
  flex-shrink: 0;
}

/* ── Role bar ── */
.role-bar {
  flex-shrink: 0;
  display: flex;
  gap: 6px;
  padding: 7px 14px 6px;
  background: rgba(10,13,20,0.92);
  border-top: 1px solid rgba(255,255,255,0.05);
  overflow-x: auto;
  scrollbar-width: none;
}
.role-bar::-webkit-scrollbar { display: none; }
.role-pill {
  flex-shrink: 0;
  font-family: var(--font-display);
  font-size: 11px; font-weight: 500;
  padding: 4px 11px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.1);
  background: rgba(255,255,255,0.04);
  color: var(--text-dim);
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
  white-space: nowrap;
}
.role-pill.active {
  background: rgba(55,138,221,0.14);
  border-color: rgba(55,138,221,0.38);
  color: var(--blue);
}

/* ── Compose ── */
.compose-row {
  flex-shrink: 0;
  display: flex;
  gap: 8px;
  padding: 8px 14px 10px;
  background: rgba(10,13,20,0.97);
  align-items: center;
}
.compose-input {
  flex: 1;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 22px;
  padding: 9px 14px;
  font-family: var(--font-ui);
  font-size: 13px; color: var(--text);
  outline: none;
  transition: border-color .18s;
  min-width: 0;
}
.compose-input:focus { border-color: rgba(55,138,221,0.4); }
.compose-input::placeholder { color: var(--text-dim); }
.compose-btn {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: rgba(55,138,221,0.18);
  border: 1px solid rgba(55,138,221,0.32);
  color: var(--blue);
  font-size: 17px; font-weight: 600;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .18s, border-color .18s;
  flex-shrink: 0; line-height: 1;
}
.compose-btn:hover { background: rgba(55,138,221,0.30); border-color: rgba(55,138,221,0.52); }

/* ── Bottom tab bar ── */
.tab-bar {
  flex-shrink: 0;
  display: flex;
  background: rgba(9,12,19,0.98);
  border-top: 1px solid rgba(255,255,255,0.07);
  padding: 8px 0 22px;
}
.tbar-item {
  flex: 1;
  display: flex; flex-direction: column; align-items: center;
  gap: 3px; cursor: pointer; padding: 4px 0;
}
.tbar-item.active .tbar-icon { color: var(--blue); opacity: 1; }
.tbar-item.active .tbar-label { color: var(--blue); opacity: 1; }
.tbar-icon { color: var(--text-dim); opacity: .55; transition: opacity .15s, color .15s; }
.tbar-label {
  font-family: var(--font-display);
  font-size: 9px; color: var(--text-dim);
  letter-spacing: .04em; opacity: .55;
  transition: opacity .15s, color .15s;
}
.tbar-badge {
  position: relative;
}
.tbar-badge::after {
  content: attr(data-count);
  position: absolute;
  top: -4px; right: -8px;
  background: var(--red);
  color: #fff;
  font-family: var(--font-display);
  font-size: 8px; font-weight: 700;
  width: 14px; height: 14px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  line-height: 14px; text-align: center;
}

/* show/hide helpers */
.hidden { display: none !important; }

@media (max-width: 420px) {
  body { padding: 0; background: #0B0E18; justify-content: flex-start; }
  .page-header, .page-back { display: none; }
  .phone-frame {
    width: 100vw; height: 100svh;
    border-radius: 0; border: none; box-shadow: none;
  }
  .phone-frame::before, .phone-frame::after { display: none; }
  .dynamic-island { display: none; }
  .status-bar { height: 44px; }
}