/* app/static/app.css — Telegram Web look: chat-list sidebar, chat-background canvas, message-bubble cards */
:root {
  --bg: #ffffff;
  --bg-2: #f4f4f5;
  --canvas: #dfe7d5;
  --canvas-2: #c9d9b6;
  --text: #000000;
  --text-2: #707579;
  --line: #e4e4e5;
  --accent: #3390ec;
  --accent-ink: #ffffff;
  --accent-soft: rgba(51, 144, 236, .12);
  --out: #eeffde;
  --green: #4fae4e;
  --yellow: #e8a33d;
  --red: #e53935;
  --purple: #8774e1;
  --shadow: 0 1px 2px rgba(16, 35, 47, .15);
  --radius: 12px;
  --font: Roboto, -apple-system, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #212121;
    --bg-2: #181818;
    --canvas: #0f0f0f;
    --canvas-2: #1c1c1c;
    --text: #ffffff;
    --text-2: #aaaaaa;
    --line: #2f2f2f;
    --accent: #8774e1;
    --accent-soft: rgba(135, 116, 225, .16);
    --out: #766ac8;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 15px/1.4 var(--font); color: var(--text); background: var(--bg-2); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, .mono { font-family: "Roboto Mono", ui-monospace, Menlo, Consolas, monospace; font-size: 13px; }

.app { display: grid; grid-template-columns: 320px 1fr; height: 100vh; }

/* ---------- sidebar = chat list ---------- */
.sidebar { background: var(--bg); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.side-head { display: flex; align-items: center; gap: 10px; padding: 10px 14px; height: 56px; }
.burger { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; color: var(--text-2); font-size: 20px; }
.brand-pill { flex: 1; height: 40px; border-radius: 22px; background: var(--bg-2); display: flex; align-items: center; padding: 0 16px; color: var(--text-2); font-weight: 500; }
.burger:hover { background: var(--bg-2); text-decoration: none; }
.project-switch { gap: 10px; padding: 0 6px 0 14px; }
.project-switch select { flex: 1; min-width: 0; border: 0; background: transparent; padding: 0; color: var(--text); font-weight: 500; box-shadow: none; cursor: pointer; }
.project-switch select:focus { box-shadow: none; }
.pdot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.topbar .crumb { color: var(--text-2); font-weight: 400; }
.nav { overflow-y: auto; padding: 4px 8px 12px; }
.nav a { display: flex; gap: 12px; align-items: center; padding: 9px 10px; border-radius: 12px; color: var(--text); text-decoration: none; }
.nav a:hover { background: var(--bg-2); }
.nav a.on { background: var(--accent); color: var(--accent-ink); }
.nav a.on .sub { color: rgba(255, 255, 255, .8); }
.avatar { width: 48px; height: 48px; border-radius: 50%; flex: none; display: grid; place-items: center; font-size: 22px; color: #fff; }
.nav .t { font-weight: 500; }
.nav .sub { font-size: 13.5px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav .txt { min-width: 0; }
.nav .unread { margin-left: auto; min-width: 22px; height: 22px; padding: 0 7px; border-radius: 11px; background: var(--green); color: #fff; font-size: 12.5px; font-weight: 500; display: grid; place-items: center; }
.nav a.on .unread { background: #fff; color: var(--accent); }
.note { word-wrap: break-word; }
.note .note-body { white-space: pre-wrap; }
.note .how { margin: -4px 0 10px; }
.ad-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; margin-bottom: 8px; }
.ad-grid .ad { max-width: none; }
.ad-grid .bubble { background: var(--bg-2); }
.chips { display: flex; flex-wrap: wrap; gap: 4px; margin: 4px 0 6px; }
.chip { font-size: 11.5px; padding: 1px 7px; border-radius: 9px; background: var(--accent-soft); color: var(--accent); }
.note.unseen { border-left: 3px solid var(--green); }
.note .when { float: right; font-size: 12px; color: var(--text-2); }
.side-foot { margin-top: auto; padding: 10px 18px; font-size: 13px; color: var(--text-2); border-top: 1px solid var(--line); }

.av-blue { background: linear-gradient(#72d5fd, #2a9ef1); }
.av-green { background: linear-gradient(#a0de7e, #54cb68); }
.av-orange { background: linear-gradient(#ffcd6a, #ffa85c); }
.av-red { background: linear-gradient(#ff885e, #ff516a); }
.av-violet { background: linear-gradient(#e0a2f3, #d669ed); }
.av-cyan { background: linear-gradient(#53edd6, #28c9b7); }
.av-pink { background: linear-gradient(#ffa8a8, #ff719a); }
.av-gray { background: linear-gradient(#b8c2cc, #8a96a3); }

/* ---------- main = chat ---------- */
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.topbar { height: 56px; flex: none; background: var(--bg); border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 12px; padding: 0 20px; }
.topbar .avatar { width: 40px; height: 40px; font-size: 18px; }
.topbar h1 { font-size: 16px; margin: 0; font-weight: 500; }
.topbar .sub { font-size: 13.5px; color: var(--text-2); }
.topbar .right { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.canvas {
  flex: 1; overflow-y: auto; padding: 20px;
  background-color: var(--canvas);
  background-image:
    radial-gradient(circle at 15% 20%, var(--canvas-2) 0 2px, transparent 3px),
    radial-gradient(circle at 70% 60%, var(--canvas-2) 0 2px, transparent 3px),
    radial-gradient(circle at 40% 85%, var(--canvas-2) 0 1.5px, transparent 2.5px);
  background-size: 120px 120px, 160px 160px, 90px 90px;
}
.wrap { max-width: 1180px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; }

/* ---------- bubbles / cards ---------- */
.card { background: var(--bg); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; }
.card h2 { font-size: 15px; margin: 0 0 10px; font-weight: 500; color: var(--accent); }
.card h3 { font-size: 14px; margin: 14px 0 6px; font-weight: 500; }
.hint { color: var(--text-2); font-size: 13.5px; }
.service { align-self: center; background: rgba(0, 0, 0, .22); color: #fff; padding: 4px 12px; border-radius: 14px; font-size: 13.5px; font-weight: 500; }
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat .v { font-size: 22px; font-weight: 500; }
.stat .k { color: var(--text-2); font-size: 13px; }

/* sponsored message preview */
.ad { max-width: 440px; }
.ad .bubble { background: var(--bg); border-radius: 12px 12px 12px 4px; box-shadow: var(--shadow); padding: 8px 12px 10px; position: relative; border-left: 3px solid var(--accent); }
.ad .label { font-size: 13px; color: var(--accent); font-weight: 500; }
.ad .title { font-weight: 500; color: var(--accent); margin-top: 2px; }
.ad .body { white-space: pre-wrap; word-wrap: break-word; margin-top: 2px; }
.ad .meta { font-size: 12px; color: var(--text-2); text-align: right; margin-top: 4px; }
.ad .btn-bar { margin-top: 4px; background: var(--accent-soft); color: var(--accent); text-align: center; border-radius: 10px; padding: 8px; font-weight: 500; font-size: 14px; }

/* ---------- tables ---------- */
.tbl-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th { text-align: left; font-weight: 500; color: var(--text-2); font-size: 12.5px; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: none; }
td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--bg-2); }

/* ---------- badges ---------- */
.badge { display: inline-block; padding: 2px 9px; border-radius: 11px; font-size: 12.5px; font-weight: 500; white-space: nowrap; }
.b-scale, .b-ok { background: rgba(79, 174, 78, .16); color: var(--green); }
.b-watch, .b-warn { background: rgba(232, 163, 61, .18); color: var(--yellow); }
.b-kill, .b-bad { background: rgba(229, 57, 53, .14); color: var(--red); }
.b-fraud { background: var(--red); color: #fff; }
.b-nodata { background: var(--bg-2); color: var(--text-2); }
.b-info { background: var(--accent-soft); color: var(--accent); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }

/* ---------- forms ---------- */
label { display: block; font-size: 13px; color: var(--text-2); margin: 10px 0 4px; }
input[type=text], input[type=password], input[type=number], select, textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--bg);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; outline: none;
}
textarea { resize: vertical; min-height: 90px; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.btn { display: inline-flex; align-items: center; gap: 6px; border: 0; font: inherit; font-weight: 500; cursor: pointer; border-radius: 10px; padding: 9px 16px; background: var(--accent); color: var(--accent-ink); text-decoration: none; }
.btn:hover { filter: brightness(1.06); text-decoration: none; }
.btn.ghost { background: transparent; color: var(--accent); }
.btn.ghost:hover { background: var(--accent-soft); }
.btn.danger { background: transparent; color: var(--red); }
.btn.small { padding: 5px 10px; font-size: 13px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; }
.row > * { flex: 1 1 160px; }
.row > .btn, .row > form { flex: 0 0 auto; }
.inline { display: inline; }

.flash { padding: 10px 14px; border-radius: 12px; background: var(--out); box-shadow: var(--shadow); align-self: flex-end; max-width: 640px; }
.flash.error { background: rgba(229, 57, 53, .15); color: var(--red); }
.copy { cursor: pointer; border-bottom: 1px dashed var(--text-2); }
.issues { list-style: none; padding: 0; margin: 0; }
.issues li { padding: 6px 0; border-bottom: 1px solid var(--line); display: flex; gap: 8px; align-items: baseline; }
.issues li:last-child { border-bottom: 0; }
.kw { display: inline-block; background: var(--bg-2); border-radius: 8px; padding: 2px 8px; margin: 2px; font-size: 13.5px; }
.kw small { color: var(--text-2); margin-left: 4px; }
.progress { height: 4px; background: var(--bg-2); border-radius: 2px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--accent); }
.muted { color: var(--text-2); }
.nowrap { white-space: nowrap; }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: var(--bg); }
.login .box { width: 100%; max-width: 360px; text-align: center; }
.login .logo { width: 120px; height: 120px; border-radius: 50%; margin: 0 auto 18px; display: grid; place-items: center; font-size: 54px; color: #fff; background: linear-gradient(#72d5fd, #2a9ef1); }
.login h1 { font-size: 26px; font-weight: 500; margin: 0 0 6px; }

/* desktop-only bits */
.menu-btn, .tabbar, .backdrop, .m-only { display: none; }

/* ---------- mobile: Telegram iOS/Android layout ---------- */
@media (max-width: 900px) {
  html, body { height: auto; }
  body { padding-bottom: calc(60px + env(safe-area-inset-bottom)); background: var(--canvas); }
  .app { display: block; height: auto; }

  /* drawer = Telegram side menu */
  .sidebar {
    position: fixed; z-index: 40; inset: 0 auto 0 0; width: min(84vw, 320px);
    transform: translateX(-102%); transition: transform .22s ease; box-shadow: 0 0 24px rgba(0, 0, 0, .25);
    padding-top: env(safe-area-inset-top);
  }
  body.drawer-open .sidebar { transform: none; }
  .backdrop { display: block; position: fixed; inset: 0; z-index: 30; background: rgba(0, 0, 0, .4); opacity: 0; pointer-events: none; transition: opacity .2s; }
  body.drawer-open .backdrop { opacity: 1; pointer-events: auto; }
  body.drawer-open { overflow: hidden; }
  .nav a { padding: 7px 10px; }
  .nav .avatar { width: 42px; height: 42px; font-size: 19px; }

  /* sticky app bar */
  .main { min-height: 100vh; }
  .topbar { position: sticky; top: 0; z-index: 20; height: auto; min-height: 56px; padding: calc(6px + env(safe-area-inset-top)) 10px 6px; gap: 10px; }
  .menu-btn { display: grid; place-items: center; position: relative; width: 40px; height: 40px; flex: none; border: 0; border-radius: 50%; background: transparent; color: var(--text-2); font-size: 20px; cursor: pointer; }
  .menu-btn:active { background: var(--bg-2); }
  .menu-dot { position: absolute; top: 8px; right: 7px; width: 9px; height: 9px; border-radius: 50%; background: var(--green); border: 2px solid var(--bg); }
  .topbar > .avatar { display: none; }
  .topbar .ttl { min-width: 0; flex: 1; }
  .topbar h1 { font-size: 16.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .topbar .crumb { display: block; font-size: 12.5px; margin-top: -1px; }
  .topbar .sub { display: none; }
  .topbar .right .btn { padding: 7px 10px; font-size: 13px; }

  /* bottom tab bar */
  .tabbar {
    display: flex; position: fixed; z-index: 25; left: 0; right: 0; bottom: 0;
    background: var(--bg); border-top: 1px solid var(--line);
    padding: 4px 4px env(safe-area-inset-bottom);
  }
  .tabbar a, .tabbar button {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 5px 2px 6px;
    font: 500 11px/1.2 var(--font); color: var(--text-2); background: none; border: 0; text-decoration: none; cursor: pointer;
  }
  .tabbar .ic { font-size: 21px; line-height: 26px; position: relative; filter: grayscale(.6); }
  .tabbar a.on { color: var(--accent); }
  .tabbar a.on .ic { filter: none; }
  .tab-badge { position: absolute; top: -3px; left: 15px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--red); color: #fff; font: 600 11px/18px var(--font); font-style: normal; text-align: center; }

  /* content */
  .canvas { padding: 10px 10px 16px; overflow: visible; }
  .wrap { gap: 10px; }
  .card { padding: 12px 14px; border-radius: 14px; }
  .g2, .g3 { grid-template-columns: 1fr; }
  .g4 { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat .v { font-size: 19px; }
  .row > * { flex: 1 1 100%; }
  .row > .btn { flex: 1 1 100%; justify-content: center; }
  input[type=text], input[type=password], input[type=number], select, textarea { font-size: 16px; } /* no iOS zoom */
  .btn { padding: 11px 16px; }
  .btn.small { padding: 7px 11px; }
  .ad { max-width: none; }
  .flash { align-self: stretch; max-width: none; }
  table { font-size: 13.5px; }
  th, td { padding: 8px 8px; }
  .m-only { display: block; }
  .d-only { display: none; }
  .service { font-size: 12.5px; }
}

/* cell cards (mobile replacement for the wide verdict table) */
.cell-cards { display: flex; flex-direction: column; gap: 8px; }
.cell-card { display: block; padding: 10px 12px; border-radius: 12px; background: var(--bg-2); color: var(--text); text-decoration: none; }
.cell-card:hover { text-decoration: none; }
.cell-card .top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.cell-card .nm { font-weight: 500; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell-card .kv { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px 10px; margin-top: 8px; }
.cell-card .kv div { font-size: 12px; color: var(--text-2); }
.cell-card .kv b { display: block; font-size: 14.5px; color: var(--text); font-weight: 500; font-variant-numeric: tabular-nums; }
.cell-card .why { font-size: 12.5px; color: var(--text-2); margin-top: 6px; }

