:root {
  color-scheme: light dark;
  --bg: var(--tg-theme-bg-color, #f3f5f9);
  --card: var(--tg-theme-secondary-bg-color, #ffffff);
  --text: var(--tg-theme-text-color, #172033);
  --muted: var(--tg-theme-hint-color, #768198);
  --primary: var(--tg-theme-button-color, #2678ff);
  --primary-text: var(--tg-theme-button-text-color, #ffffff);
  --line: rgba(120, 130, 150, .18);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: Tahoma, Arial, sans-serif; padding-bottom: 84px; }
header { display: flex; justify-content: space-between; align-items: center; padding: 24px 18px 14px; }
h1 { margin: 4px 0 0; font-size: 22px; }
small, .muted { color: var(--muted); }
.badge { background: var(--primary); color: var(--primary-text); padding: 7px 11px; border-radius: 999px; font-size: 12px; }
main { padding: 8px 14px 24px; display: grid; gap: 12px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 16px; box-shadow: 0 8px 30px rgba(20,30,50,.06); }
.hero { background: linear-gradient(145deg, var(--primary), #7439e9); color: white; }
.hero .muted { color: rgba(255,255,255,.75); }
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; }
.metric { text-align: center; padding: 14px 7px; }
.metric strong { display: block; font-size: 24px; margin-bottom: 5px; }
.list { display: grid; gap: 8px; }
.item { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 13px; }
.item strong { display: block; margin-bottom: 5px; }
.item.action { cursor: pointer; }
.thread-item { display: flex; align-items: center; gap: 8px; }
.thread-main { position: relative; flex: 1; cursor: pointer; display: grid; gap: 4px; min-width: 0; }
.thread-actions, .toolbar-actions { display: flex; gap: 5px; flex-wrap: wrap; }
.notification-dot { position: absolute; top: 2px; left: 2px; width: 10px; height: 10px; border-radius: 50%; background: #ff3b30; box-shadow: 0 0 0 3px var(--card); }
.compact { padding: 8px 10px !important; font-size: 12px !important; }
.chat { display: grid; grid-auto-rows: max-content; align-content: start; gap: 8px; max-height: min(42dvh, 420px); overflow-y: auto; padding: 2px 4px 4px; }
.bubble { width: fit-content; min-width: 0; max-width: 88%; padding: 8px 11px; border-radius: 16px; line-height: 1.55; white-space: pre-wrap; word-break: break-word; }
.bubble.user { justify-self: start; background: var(--primary); color: var(--primary-text); border-bottom-left-radius: 4px; }
.bubble.admin { justify-self: end; background: var(--card); border: 1px solid var(--line); border-bottom-right-radius: 4px; }
.bubble small { display: block; margin-top: 6px; opacity: .7; font-size: 10px; }
.composer { position: sticky; bottom: 68px; display: flex; gap: 7px; background: var(--bg); padding: 8px 0; }
.composer textarea { flex: 1; min-height: 46px; max-height: 130px; resize: vertical; border: 1px solid var(--line); border-radius: 14px; padding: 11px; font: inherit; background: var(--card); color: var(--text); }
.composer button, .primary, .secondary { border: 0; border-radius: 12px; padding: 11px 14px; font: inherit; cursor: pointer; }
.composer button, .primary { background: var(--primary); color: var(--primary-text); }
.attach-button { display: grid; place-items: center; min-width: 46px; border-radius: 12px; background: var(--card); border: 1px solid var(--line); cursor: pointer; font-size: 20px; }
.attach-button input { display: none; }
.attachment { display: block; margin-top: 7px; width: 100%; border: 1px solid currentColor; border-radius: 10px; padding: 8px; background: transparent; color: inherit; text-align: right; cursor: pointer; }
.file-queue { display: grid; gap: 6px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 9px; }
.queued-file { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 7px; border-radius: 10px; background: var(--bg); }
.queued-file span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.queued-file button { border: 0; border-radius: 8px; padding: 6px 9px; background: #d93636; color: white; }
.profile-form { display: grid; gap: 10px; }
.profile-form label { display: grid; gap: 5px; color: var(--muted); }
.profile-form input, .profile-form select { border: 1px solid var(--line); border-radius: 11px; padding: 10px; font: inherit; background: var(--bg); color: var(--text); }
.profile-form .checkbox { display: flex; grid-auto-flow: column; justify-content: start; align-items: center; color: var(--text); }
.search-form { display: flex; gap: 7px; margin-bottom: 12px; }
.search-form input { min-width: 0; flex: 1; border: 1px solid var(--line); border-radius: 12px; padding: 11px; font: inherit; background: var(--bg); color: var(--text); }
.search-form button { border: 0; border-radius: 12px; padding: 10px 13px; font: inherit; background: var(--primary); color: var(--primary-text); }
.success { border-color: #2ba568; color: #16814d; }
.secondary { background: var(--card); color: var(--text); border: 1px solid var(--line); }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.progress { height: 10px; background: var(--line); border-radius: 99px; overflow: hidden; margin-top: 14px; }
.progress span { display: block; height: 100%; background: var(--primary); border-radius: inherit; }
.error { border-color: #e85252; color: #b92727; }
nav { position: fixed; bottom: 0; left: 0; right: 0; display: flex; gap: 7px; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); background: var(--card); border-top: 1px solid var(--line); }
nav button { position: relative; flex: 1; border: 0; border-radius: 12px; padding: 12px 8px; color: var(--muted); background: transparent; font: inherit; }
nav button.active { background: var(--primary); color: var(--primary-text); }
.tab-notification { position: absolute; top: 3px; left: 3px; min-width: 17px; height: 17px; padding: 0 4px; display: grid; place-items: center; border-radius: 99px; background: #ff3b30; color: white; font-size: 10px; }
