:root {
  --bg: #070d19;
  --bg-2: #0b1220;
  --panel: #101b2d;
  --panel-2: #142238;
  --line: #1c3048;
  --line-soft: #17283d;
  --text: #f1f5f9;
  --muted: #93a4b8;
  --dim: #64748b;
  --teal: #2dd4bf;
  --teal-deep: #0f766e;
  --cyan: #22d3ee;
  --amber: #f59e0b;
  --red: #fb7185;
  --green: #34d399;
  --radius: 18px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); }
body {
  -webkit-font-smoothing: antialiased;
  background:
    radial-gradient(circle at 90% -10%, rgba(34, 211, 238, .11), transparent 38%),
    radial-gradient(circle at -10% 30%, rgba(45, 212, 191, .08), transparent 42%),
    var(--bg);
  overflow-x: hidden;
}
button, input { font: inherit; }
button { color: inherit; }
img { max-width: 100%; display: block; }
[hidden] { display: none !important; }

.ambient {
  position: fixed;
  width: 280px;
  height: 280px;
  border-radius: 50%;
  filter: blur(80px);
  pointer-events: none;
  opacity: .22;
  z-index: 0;
}
.ambient-a { top: -140px; right: -80px; background: var(--cyan); }
.ambient-b { bottom: 2%; left: -180px; background: var(--teal); opacity: .14; }

.app {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: max(14px, env(safe-area-inset-top)) 18px 12px;
  background: linear-gradient(180deg, rgba(7,13,25,.94), rgba(7,13,25,.72) 72%, transparent);
  backdrop-filter: blur(16px);
}
.brand { display: flex; align-items: center; gap: 11px; min-width: 0; }
.brand-logo { width: 38px; height: 38px; border-radius: 50%; }
.brand-name { font-size: 17px; font-weight: 700; letter-spacing: -.3px; }
.brand-sub { color: var(--muted); font-size: 10.5px; margin-top: 1px; white-space: nowrap; }
.avatar {
  width: 38px; height: 38px; border-radius: 50%;
  border: 1px solid var(--line);
  background: linear-gradient(145deg, #17304a, #0d1829);
  color: var(--teal); font-weight: 700; font-size: 14px;
  display: grid; place-items: center;
  cursor: pointer;
}

.view { padding: 8px 16px calc(104px + var(--safe-bottom)); }

.eyebrow {
  margin: 0 0 6px;
  color: var(--teal);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.8px;
}
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: clamp(27px, 7vw, 36px); line-height: 1.04; letter-spacing: -1.2px; margin-bottom: 8px; }
h2 { font-size: 20px; letter-spacing: -.4px; margin-bottom: 4px; }
h3 { font-size: 15px; margin-bottom: 6px; }
.subcopy { color: var(--muted); font-size: 13px; line-height: 1.45; margin-bottom: 18px; }
.mono { font-family: "Cascadia Mono", Consolas, monospace; }

.hero {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
  padding: 14px 2px 16px;
}
.hero-title { font-size: clamp(30px, 8vw, 40px); font-weight: 700; letter-spacing: -1.5px; line-height: 1; margin: 0; }
.hero-title span { color: var(--teal); }
.hero-copy { color: var(--muted); font-size: 12.5px; line-height: 1.45; margin-top: 8px; max-width: 270px; }
.live-pill {
  flex: 0 0 auto;
  display: inline-flex; align-items: center; gap: 7px;
  color: var(--green); font-size: 10.5px; font-weight: 700;
  border: 1px solid rgba(52, 211, 153, .22);
  background: rgba(52, 211, 153, .07);
  border-radius: 999px; padding: 7px 10px;
}
.live-pill .dot { background: var(--green); box-shadow: 0 0 0 4px rgba(52,211,153,.12); }

.summary-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; margin: 4px 0 18px; }
.stat {
  border: 1px solid var(--line-soft);
  background: linear-gradient(160deg, rgba(20,34,56,.86), rgba(13,23,39,.86));
  border-radius: 15px; padding: 12px 12px 11px;
}
.stat-value { font-size: 21px; font-weight: 700; letter-spacing: -.5px; }
.stat-label { color: var(--dim); font-size: 9.5px; margin-top: 3px; }
.stat.accent { border-color: rgba(45,212,191,.24); }

.section-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 20px 2px 10px; }
.section-head h2 { margin: 0; }
.count-muted { color: var(--dim); font-size: 11px; }

.chips { display: flex; gap: 7px; overflow-x: auto; scrollbar-width: none; padding: 2px 2px 8px; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  background: rgba(16,27,45,.72);
  color: var(--muted);
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 11px;
  cursor: pointer;
  transition: .18s ease;
}
.chip.is-active { color: var(--bg); background: var(--teal); border-color: var(--teal); font-weight: 700; }
.chip:active { transform: scale(.97); }

.cards { display: grid; gap: 11px; }
.alert-card {
  position: relative;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: linear-gradient(155deg, rgba(18,32,52,.95), rgba(12,21,36,.98));
  padding: 14px;
  overflow: hidden;
  animation: rise .28s ease both;
}
.alert-card::before {
  content: "";
  position: absolute; left: 0; top: 18px; bottom: 18px; width: 2px;
  border-radius: 2px; background: var(--teal); opacity: .8;
}
.alert-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  color: var(--teal); font-size: 9px; font-weight: 700; letter-spacing: 1.1px;
}
.badge.source-userbot { color: var(--cyan); }
.badge.source-manual { color: var(--amber); }
.alert-time { color: var(--dim); font-size: 10px; white-space: nowrap; }
.alert-channel { margin: 7px 0 2px; font-size: 14px; font-weight: 700; letter-spacing: -.2px; }
.alert-title { color: var(--muted); font-size: 10.5px; margin-bottom: 9px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.keywords { display: flex; flex-wrap: wrap; gap: 5px; margin: 7px 0 9px; }
.keyword {
  color: #a7f3d0; background: rgba(45,212,191,.08);
  border: 1px solid rgba(45,212,191,.14);
  padding: 3px 7px; border-radius: 6px; font-size: 9.5px;
}
.quote {
  margin: 0 0 12px;
  padding: 9px 10px 9px 12px;
  color: #d8e3ef;
  background: rgba(7,13,25,.46);
  border-left: 2px solid rgba(34,211,238,.55);
  border-radius: 0 8px 8px 0;
  font-size: 12.5px;
  line-height: 1.46;
}
.alert-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.reason { color: var(--dim); font-size: 9.5px; line-height: 1.35; }
.score {
  --score: 70;
  flex: 0 0 auto;
  width: 37px; height: 37px; border-radius: 50%;
  background: conic-gradient(var(--teal) calc(var(--score) * 1%), #1e3047 0);
  display: grid; place-items: center;
  position: relative;
}
.score::after { content: ""; position: absolute; inset: 4px; border-radius: 50%; background: #0d1829; }
.score span { position: relative; z-index: 1; font-size: 10px; font-weight: 700; color: var(--teal); }
.actions { display: grid; grid-template-columns: 1.2fr .9fr .8fr; gap: 6px; }
.btn {
  border: 1px solid var(--line);
  background: rgba(20,34,56,.8);
  border-radius: 10px;
  padding: 9px 8px;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: .18s ease;
  white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn.primary { color: #042f2e; background: var(--teal); border-color: var(--teal); font-weight: 700; }
.btn.ghost-danger { color: #fda4af; border-color: rgba(251,113,133,.22); background: rgba(251,113,133,.06); }
.btn.small { padding: 7px 9px; font-size: 10px; }
.btn.link { background: transparent; border-color: transparent; color: var(--teal); padding-left: 0; text-align: left; }
.btn:disabled { opacity: .55; }

.empty {
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 28px 18px;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
}
.empty strong { display: block; color: var(--text); font-size: 15px; margin-bottom: 4px; }

.list-card {
  border: 1px solid var(--line-soft);
  background: rgba(15,27,45,.78);
  border-radius: 14px;
  padding: 12px;
  display: flex; gap: 11px; align-items: flex-start;
}
.list-card + .list-card { margin-top: 8px; }
.list-icon { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; flex: 0 0 auto; background: rgba(45,212,191,.08); color: var(--teal); }
.list-icon svg { width: 17px; height: 17px; }
.list-main { min-width: 0; flex: 1; }
.list-title { font-size: 12.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-sub { color: var(--dim); font-size: 10px; margin-top: 3px; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); display: inline-block; margin-right: 5px; }
.status-dot.off { background: var(--red); }

.search-row { display: flex; gap: 8px; margin: 3px 0 10px; }
.search {
  flex: 1;
  border: 1px solid var(--line);
  background: rgba(16,27,45,.78);
  border-radius: 12px;
  color: var(--text);
  padding: 11px 12px;
  font-size: 12px;
  outline: none;
}
.search:focus { border-color: rgba(45,212,191,.55); box-shadow: 0 0 0 3px rgba(45,212,191,.08); }
.search::placeholder { color: var(--dim); }

.rule-group { margin-bottom: 14px; }
.rule-label { color: var(--dim); font-size: 9.5px; font-weight: 700; letter-spacing: 1.1px; margin: 14px 2px 7px; }
.rule-chip {
  display: inline-flex; align-items: center; gap: 5px;
  border: 1px solid var(--line); background: rgba(16,27,45,.7);
  border-radius: 8px; padding: 6px 8px; font-size: 10px; color: var(--text);
  margin: 0 5px 6px 0;
}
.rule-chip.negative { color: #fda4af; border-color: rgba(251,113,133,.18); background: rgba(251,113,133,.05); }
.rule-chip button { border: 0; background: transparent; color: var(--dim); padding: 0 0 0 2px; font-size: 14px; line-height: 1; cursor: pointer; }
.rule-add { display: flex; gap: 7px; margin-top: 8px; }
.rule-add .search { padding: 10px; }
.suggestion { border: 1px solid rgba(245,158,11,.18); background: rgba(245,158,11,.05); border-radius: 12px; padding: 11px; font-size: 10.5px; color: #fde68a; line-height: 1.4; margin-top: 10px; }

.health-row { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--line-soft); }
.health-row:last-child { border-bottom: 0; }
.health-label { font-size: 12px; color: var(--muted); }
.health-value { font-size: 11px; color: var(--text); font-weight: 600; }
.health-value.ok { color: var(--green); }
.health-value.bad { color: var(--red); }

.profile-card {
  border: 1px solid var(--line-soft);
  background: linear-gradient(145deg, rgba(20,34,56,.9), rgba(12,21,36,.9));
  border-radius: var(--radius);
  padding: 16px;
  display: flex; gap: 12px; align-items: center;
  margin-bottom: 14px;
}
.profile-avatar { width: 46px; height: 46px; border-radius: 50%; background: #17304a; display: grid; place-items: center; color: var(--teal); font-weight: 700; font-size: 17px; }
.profile-name { font-size: 15px; font-weight: 700; }
.profile-role { color: var(--dim); font-size: 10px; margin-top: 2px; }

.tabbar {
  position: fixed;
  z-index: 30;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 760px;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 2px;
  padding: 9px 8px calc(9px + var(--safe-bottom));
  background: rgba(8,15,28,.92);
  border-top: 1px solid rgba(28,48,72,.72);
  backdrop-filter: blur(22px);
}
.tab {
  position: relative;
  border: 0;
  background: transparent;
  color: var(--dim);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  font-size: 8.5px;
  padding: 5px 2px;
  border-radius: 10px;
  cursor: pointer;
}
.tab.is-active { color: var(--teal); }
.tab-icon { width: 20px; height: 20px; display: grid; place-items: center; }
.tab-icon svg { width: 20px; height: 20px; }
.tab-badge {
  position: absolute; top: 1px; left: calc(50% + 7px);
  min-width: 15px; height: 15px; padding: 0 4px;
  border-radius: 999px; background: var(--teal); color: var(--bg);
  font-size: 8px; line-height: 15px; text-align: center;
}

.sheet-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 40; backdrop-filter: blur(3px); }
.sheet {
  position: fixed; z-index: 50;
  left: 50%; bottom: 0; transform: translateX(-50%);
  width: 100%; max-width: 760px;
  background: #0e192b;
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 22px 22px 0 0;
  padding: 9px 18px calc(24px + var(--safe-bottom));
  animation: sheetUp .25s ease both;
  max-height: 82vh;
  overflow-y: auto;
}
.sheet-grab { width: 36px; height: 4px; border-radius: 3px; background: #334155; margin: 0 auto 16px; }
.sheet h2 { font-size: 18px; margin-bottom: 4px; }
.sheet-copy { color: var(--muted); font-size: 11.5px; line-height: 1.45; margin-bottom: 14px; }
.sheet-options { display: grid; gap: 7px; }
.sheet-option {
  text-align: left; border: 1px solid var(--line); background: rgba(20,34,56,.6);
  border-radius: 12px; padding: 12px; color: var(--text); font-size: 12px; cursor: pointer;
}
.sheet-option:active { border-color: var(--teal); }
.sheet-close { margin-top: 12px; width: 100%; }

.toast {
  position: fixed; z-index: 60;
  left: 50%; bottom: calc(94px + var(--safe-bottom)); transform: translateX(-50%);
  width: calc(100% - 36px); max-width: 500px;
  border: 1px solid rgba(45,212,191,.2);
  background: #102337; color: #d1fae5;
  border-radius: 12px; padding: 11px 13px; font-size: 11.5px;
  box-shadow: 0 16px 40px rgba(0,0,0,.4);
  animation: toastIn .2s ease both;
}
.toast.error { border-color: rgba(251,113,133,.3); color: #fecdd3; }

.gate {
  position: relative; z-index: 1;
  min-height: 100vh; min-height: 100dvh;
  max-width: 520px; margin: 0 auto;
  padding: 18vh 28px 40px;
  text-align: center;
}
.gate-mark { width: 92px; height: 92px; margin: 0 auto 18px; border-radius: 50%; overflow: hidden; border: 1px solid var(--line); }
.gate h1 { font-size: 30px; }
.gate-copy { color: var(--muted); font-size: 13px; line-height: 1.5; }
.gate-note { display: inline-flex; align-items: center; gap: 7px; margin-top: 16px; color: var(--dim); font-size: 10px; }
.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--teal); display: inline-block; }

.skeleton { border-radius: 14px; background: linear-gradient(90deg, #102033, #17283d, #102033); background-size: 200% 100%; animation: shimmer 1.3s infinite; }
.skeleton.wide { height: 58px; margin: 8px 0 18px; }
.skeleton.card { height: 180px; margin-bottom: 11px; }

.fade-in { animation: rise .25s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(7px); } to { opacity: 1; transform: none; } }
@keyframes sheetUp { from { transform: translate(-50%, 25px); opacity: .4; } to { transform: translate(-50%, 0); opacity: 1; } }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }
@keyframes shimmer { 0% { background-position: 0 0; } 100% { background-position: -200% 0; } }

@media (min-width: 680px) {
  .view { padding-left: 24px; padding-right: 24px; }
  .cards { grid-template-columns: 1fr 1fr; }
  .alert-card { min-height: 100%; }
  .summary-grid { gap: 12px; }
  .tabbar { border-radius: 20px 20px 0 0; }
}
@media (max-width: 360px) {
  .actions { grid-template-columns: 1fr 1fr; }
  .actions .btn.primary { grid-column: 1 / -1; }
  .brand-sub { display: none; }
}
