:root {
  --ink: #17231f;
  --muted: #65736d;
  --bg: #e8f0ea;
  --card: #fffdf5;
  --brand: #31584d;
  --brand-deep: #193831;
  --yellow: #ffd93d;
  --mint: #6f8871;
  --line: #d7e1da;
  --danger: #b34840;
}

body { background: var(--bg); color: var(--ink); }
.app { grid-template-columns: 266px minmax(0, 1fr); }
.side { position: relative; display: flex; flex-direction: column; overflow: hidden; padding: 30px 17px; background: var(--brand-deep); color: var(--mist, #e8f0ea); }
.side::before { content: ""; position: absolute; right: -95px; bottom: -95px; width: 280px; height: 280px; border: 1px solid rgba(232,240,234,.14); border-radius: 50%; }
.side > * { position: relative; z-index: 1; }
/* The landing logo is dark ink on a light ground, so it sits on a light chip
   here instead of directly on the dark sidebar. */
.brand { display: inline-flex; min-height: 48px; align-items: center; padding: 8px 14px; border-radius: 14px; background: var(--card); box-shadow: 0 6px 18px rgba(9,20,16,.22); }
.brand img { display: block; width: 148px; height: auto; }
.tag { margin: 10px 0 31px; padding-left: 2px; color: #b8c8ae; font-size: 15px; }
.nav { gap: 7px; }
.nav button { display: flex; align-items: center; min-height: 48px; border-radius: 13px; padding: 11px 14px; color: #dce7df; font-weight: 700; }
.nav button.active, .nav button:hover { background: rgba(255,255,255,.12); color: #fff; }
.side-foot { position: static; width: 100%; margin-top: auto; padding-top: 20px; }
.side-foot .btn { width: 100%; border-color: var(--yellow); background: var(--yellow); color: var(--ink); box-shadow: none; }

.main { max-width: 1240px; padding: 42px; }
.top { margin-bottom: 32px; }.top h1 { color: var(--brand-deep); font-size: clamp(27px,3vw,36px); font-weight: 800; letter-spacing: -.035em; }.top p { font-size: 16px; }
.pill { padding: 8px 12px; background: #dbe7dd; color: var(--brand-deep); }.card { border: 1px solid var(--line); border-radius: 20px; background: var(--card); box-shadow: 0 12px 30px rgba(23,35,31,.07); }.card h3, .number, .section { color: var(--brand-deep); }.section { font-size: 23px; font-weight: 800; }.muted { color: var(--muted); }
.btn { border: 2px solid var(--brand); border-radius: 12px; background: var(--brand); box-shadow: 3px 4px 0 var(--brand-deep); }.btn:hover { transform: translate(1px,1px); box-shadow: 2px 3px 0 var(--brand-deep); }.btn.ghost { border-color: var(--brand-deep); background: transparent; color: var(--brand-deep); box-shadow: none; }.btn.ghost:hover { background: #edf4ee; }.btn.warn { border-color: var(--danger); background: var(--danger); box-shadow: 3px 4px 0 #6d2f2a; }.btn.mint { border-color: var(--mint); background: var(--mint); box-shadow: 3px 4px 0 var(--brand-deep); }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; width: 44px; padding: 0; }
.icon-btn svg { width: 20px; height: 20px; }
.notice { display: flex; gap: 13px; align-items: center; padding: 16px 18px; border: 1px solid #f0dc9a; border-left: 5px solid var(--yellow); border-radius: 16px; background: #fffaea; color: #4a3c05; font-size: 15px; line-height: 1.45; box-shadow: 0 8px 22px rgba(23,35,31,.05); }
.notice::before { content: "💡"; flex: none; display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: #fff1c2; font-size: 16px; }
/* An empty section should read as a card that starts at the top, not as text
   floating in the middle of the page. */
.card.empty { display: grid; justify-items: start; gap: 12px; padding: 24px; text-align: left; }.chip { background: #dfe9df; color: var(--brand-deep); }.avatar { border-radius: 16px; background: linear-gradient(135deg, var(--yellow), #d6b829); color: var(--brand-deep); }.teacher,.lesson { transition: transform .18s ease, box-shadow .18s ease; }.teacher:hover { transform: translateY(-2px); box-shadow: 0 16px 32px rgba(23,35,31,.12); }.lesson.active { border-color: #9dbca2; background: #f2f8f1; }.stripe { background: #aebdb2; }.lesson.active .stripe { background: var(--mint); }
.chat { border-radius: 20px; }
/* Triage tabs and the lead stage a seller needs to see before opening a chat. */
/* A single 520px column left a wide screen mostly empty and the form very tall. */
@media (min-width: 900px) {
  .card.form { max-width: 860px; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 16px; }
  .card.form > h2, .card.form > p, .card.form > textarea, .card.form > button, .card.form > .row { grid-column: 1 / -1; }
}
.chat-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
/* В узком окне двенадцать вкладок ложатся в четыре-шесть рядов и съедают
   экран: список чатов начинается ниже сгиба. Там лента остаётся лентой
   и листается вбок — то же решение, что в Mini App. */
@media (max-width: 559px) {
  .chat-tabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: thin; }
  .chat-tabs > * { flex: 0 0 auto; }
}
.chat-tab { min-height: 38px; padding: 8px 15px; border: 1px solid var(--line); border-radius: 99px; background: var(--card); color: var(--brand-deep); font-weight: 700; }
.chat-tab.active { border-color: var(--brand-deep); background: var(--brand-deep); color: #fff; }
.lead-stage { display: block; width: fit-content; max-width: 100%; margin: 6px 0 2px; padding: 3px 9px; border-radius: 99px; background: #e8eee9; color: var(--brand-deep); font-size: 12px; font-weight: 700; }
.lead-stage.warning { background: #fbe6cf; color: #8a4a06; }
.lead-stage.positive { background: #d8ecdd; color: #1c6438; }
.lead-stage.hot { background: #fbd9e2; color: #96143c; }
.chat-clear { display: block; width: fit-content; margin-top: 9px; padding: 3px 10px; border: 1px solid var(--line); border-radius: 99px; color: var(--muted); font-size: 12px; font-weight: 700; }
.chat-clear:hover { border-color: var(--brand); color: var(--brand); }
.main--chats .chat { height: calc(100dvh - 186px); }
/* The chats view is a workspace: give the conversation the height it needs and
   trim the page padding around it. */
.main--chats { padding: 22px 24px 16px; }
.main--chats .top { margin-bottom: 14px; }
.main--chats .chat { height: calc(100dvh - 132px); max-height: none; min-height: 460px; }
@media (max-width: 780px) { .main--chats { padding: 14px 12px 12px; } .main--chats .chat { height: calc(100dvh - 150px); } }.chat-list button.active { background: #e1ece3; color: var(--brand-deep); }.bubble.me { background: #dbe9de; }.send input,.send textarea,.form input,.form select,.admin-tools input,.admin-tools select { border-color: var(--line); border-radius: 12px; }.send input:focus,.send textarea:focus,.form input:focus,.form select:focus { border-color: var(--brand); outline: 3px solid rgba(49,88,77,.16); }
.auth-card { max-width: 560px; padding: 32px; }.auth-card h2 { margin: 0; color: var(--brand-deep); font-size: 30px; }.auth-divider { display: flex; align-items: center; gap: 12px; margin: 24px 0; color: var(--muted); font-size: 13px; }.auth-divider::before,.auth-divider::after { content: ""; height: 1px; flex: 1; background: var(--line); }.auth-choice { width: 100%; justify-content: center; }
/* Some buttons are anchors (a real link opens Telegram in one tap, where a
   popup would be blocked); make them look and size like the buttons. */
a.btn { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
a.auth-choice { display: flex; }.auth-secondary { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }.auth-email { display: grid; gap: 10px; }.text-action { margin-top: 14px; padding: 0; border: 0; background: transparent; color: var(--brand); font-weight: 700; text-decoration: underline; }
.portal-toast { position: fixed; right: 22px; bottom: 22px; z-index: 50; max-width: min(420px,calc(100vw - 32px)); padding: 13px 16px; border: 1px solid #9dbca2; border-radius: 12px; background: #eef7ee; color: var(--brand-deep); box-shadow: 0 16px 40px rgba(23,35,31,.16); opacity: 0; pointer-events: none; transform: translateY(12px); transition: .2s ease; }.portal-toast.error { border-color: #e3a8a1; background: #fff2f0; color: #8a332c; }.portal-toast.success,.portal-toast.error { opacity: 1; transform: none; }
.settings-layout { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 16px; }.settings-wide { grid-column: 1/-1; }.security-list { display: grid; gap: 10px; margin: 0 0 16px; }.security-list div,.session-list div { display: flex; justify-content: space-between; gap: 12px; padding-bottom: 9px; border-bottom: 1px solid var(--line); }.security-list dt,.session-list span { font-weight: 700; }.security-list dd { margin: 0; color: var(--muted); text-align: right; overflow-wrap: anywhere; }.inline-form { margin-top: 14px; }.check-row { display: flex; gap: 9px; align-items: flex-start; color: var(--ink); }.check-row input { margin-top: 4px; }.settings-wide .actions { margin-top: 16px; }.session-list { display: grid; gap: 10px; }.session-list small { color: var(--muted); text-align: right; }
.dashboard-hero,.teacher-hero { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 30px; border-radius: 22px; background: linear-gradient(120deg, var(--brand-deep), var(--brand)); color: #fff; }.dashboard-hero h2,.teacher-hero h2 { max-width: 700px; margin: 7px 0; font-size: clamp(27px,4vw,42px); line-height: 1.08; letter-spacing: -.035em; }.dashboard-hero p,.teacher-hero p { max-width: 630px; color: #e8f0ea; }.eyebrow { color: var(--yellow); font-size: 12px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }.dashboard-hero .btn.ghost { border-color: #fff; color: #fff; background: transparent; }.dashboard-balance,.teacher-stats { min-width: 190px; display: grid; gap: 6px; padding: 20px; border: 1px solid rgba(255,255,255,.28); border-radius: 16px; background: rgba(255,255,255,.1); }.dashboard-balance span,.teacher-stats span { color: #e8f0ea; }.dashboard-balance b,.teacher-stats b { font-size: 31px; }
/* Balance card: a quiet label, the sum as the hero figure, and the two actions
   side by side instead of two stacked underlined links. */
.dashboard-balance { grid-template-columns: auto auto; justify-content: start; gap: 3px 16px; padding: 21px 22px; }
.dashboard-balance > span { grid-column: 1/-1; color: rgba(232,240,234,.74); font-size: 12px; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
.dashboard-balance > b { grid-column: 1/-1; margin-bottom: 11px; font-size: 40px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -.035em; line-height: 1.02; }
.dashboard-balance .text-action { justify-self: start; width: fit-content; margin-top: 0; padding-bottom: 2px; border-bottom: 1px solid rgba(255,217,61,.4); color: var(--yellow); font-size: 14px; font-weight: 700; text-align: left; text-decoration: none; }
.dashboard-balance .text-action:hover { border-bottom-color: var(--yellow); }
.wallet-hint { grid-column: 1/-1; margin-top: 10px; color: rgba(232,240,234,.6); font-size: 12px; line-height: 1.4; }
.teacher-stats b { font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -.03em; }.next-steps { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 16px; margin-top: 28px; }.next-steps p { margin-bottom: 0; }
.portal-dialog { width: min(500px,calc(100vw - 28px)); padding: 0; border: 0; border-radius: 20px; background: var(--card); color: var(--ink); box-shadow: 0 24px 70px rgba(23,35,31,.32); }.portal-dialog::backdrop { background: rgba(23,35,31,.5); backdrop-filter: blur(3px); }.portal-dialog form { position: relative; padding: 28px; }.portal-dialog h2 { margin: 0 34px 8px 0; font-size: 26px; }.dialog-close { position: absolute; top: 14px; right: 16px; width: 34px; height: 34px; border: 0; border-radius: 50%; background: #e8f0ea; color: var(--brand-deep); font-size: 25px; line-height: 1; }.dialog-actions { justify-content: flex-end; margin-top: 20px; }
.slot-board { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 10px; }.slot { display: grid; gap: 4px; padding: 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--card); color: var(--brand-deep); text-align: left; }.slot span { color: var(--muted); font-size: 13px; }.slot.open { border-color: #9dbca2; background: #f2f8f1; }.slot.closed { opacity: .68; }.admin-tools { display: flex; gap: 10px; margin: 18px 0; }.admin-tools input,.admin-tools select { min-height: 44px; padding: 10px; background: var(--card); }.admin-tools input { flex: 1; }.record-kind { display: inline-block; margin-right: 8px; color: var(--brand); font-size: 12px; font-weight: 800; text-transform: uppercase; }

@media (max-width: 780px) { .side { flex-direction: row; padding: calc(10px + env(safe-area-inset-top)) 12px 10px; }.side::before { display: none; }.brand { min-height: 34px; }.brand img { width: 135px; height: 36px; }.tag { display: none; }.main { padding: 24px 16px 34px; }.top h1 { font-size: 27px; }.nav button { border-radius: 10px; }.card { border-radius: 16px; }.settings-layout { grid-template-columns: 1fr; }.settings-wide { grid-column: auto; }.dashboard-hero,.teacher-hero { align-items: flex-start; flex-direction: column; padding: 24px; }.dashboard-balance,.teacher-stats { width: 100%; }.next-steps,.slot-board { grid-template-columns: 1fr; }.admin-tools { flex-direction: column; } }

/* Very wide screens: let the workspace grow instead of leaving wide empty
   margins, while keeping a comfortable reading width for text pages. */
@media (min-width: 1700px) {
  .main { max-width: 1440px; }
  .main--chats .chat { grid-template-columns: 340px minmax(0, 1fr); }
}

/* Lead dossier shown above the thread, so a manager can qualify without the Mini App. */
.dossier { margin-bottom: 14px; padding: 14px 16px; border: 1px solid #cfe0d4; border-radius: 16px; background: #f3f8f4; }
.dossier-banner { margin-bottom: 10px; padding: 9px 12px; border-radius: 12px; background: #e2eee5; color: var(--brand-deep); font-size: 13px; font-weight: 700; }
.dossier-banner.warn { background: #fbe6cf; color: #8a4a06; }
.dossier-user-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 8px; }
.dossier-user { color: var(--brand); font-weight: 700; }
.dossier-user-row .text-action { margin-top: 0; }
.dossier-lead { margin-top: 10px; padding-top: 10px; border-top: 1px solid #dfeae1; }
.dossier-lead pre { margin: 6px 0 0; font: inherit; font-size: 13px; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--ink); }
.dossier-actions { margin-bottom: 14px; }
.admin-moderation { display: block; }
