:root {
  --bg: #f4f6f5;
  --card: #ffffff;
  --ink: #111816;
  --ink2: #5b6763;
  --line: #e3e8e6;
  --brand: #0f7a5a;
  --brand2: #14a37a;
  --brand-soft: #e5f4ee;
  --warn: #b7791f;
  --warn-soft: #fdf3e1;
  --bad: #c0392b;
  --bad-soft: #fbeaea;
  --bubble-in: #ffffff;
  --bubble-out: #dcf5e9;
  --r: 16px;
  --shadow: 0 1px 2px rgba(16, 24, 22, .05), 0 4px 16px rgba(16, 24, 22, .05);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); }
body { min-height: 100dvh; touch-action: manipulation; }
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--brand); }
h1 { font-size: 26px; letter-spacing: -.02em; margin: 0 0 6px; }
h2 { font-size: 20px; letter-spacing: -.01em; margin: 0 0 4px; }
h3 { font-size: 16px; margin: 0 0 8px; }
p { margin: 0 0 10px; line-height: 1.45; }
.muted { color: var(--ink2); }
.small { font-size: 13px; }
.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 12px; }
.hidden { display: none !important; }

/* кнопкалар */
.btn {
  appearance: none; border: 0; border-radius: 12px; padding: 12px 16px; font-weight: 600; cursor: pointer;
  background: var(--brand); color: #fff; transition: transform .08s ease, opacity .15s; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.block { width: 100%; padding: 14px; font-size: 16px; }
.btn.ghost { background: var(--brand-soft); color: var(--brand); }
.btn.plain { background: transparent; color: var(--ink2); padding: 8px 10px; }
.btn.light { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.btn.danger { background: var(--bad-soft); color: var(--bad); }
.btn.sm { padding: 7px 12px; font-size: 13px; border-radius: 10px; }
.chip {
  border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 8px 14px; cursor: pointer; font-size: 14px;
}
.chip.on { background: var(--brand); border-color: var(--brand); color: #fff; }

/* өрістер */
.input, textarea.input, select.input {
  width: 100%; border: 1px solid var(--line); background: #fff; border-radius: 12px; padding: 12px 14px; outline: none;
}
.input:focus { border-color: var(--brand2); box-shadow: 0 0 0 3px rgba(20, 163, 122, .15); }
textarea.input { resize: vertical; min-height: 70px; line-height: 1.4; }
label.check { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; padding: 6px 0; }
label.check input { width: 20px; height: 20px; accent-color: var(--brand); margin: 1px 0 0; flex: none; }

/* карточкалар */
.card { background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); padding: 16px; }
.card + .card { margin-top: 12px; }
.card.tint { background: var(--brand-soft); box-shadow: none; }
.card.warn { background: var(--warn-soft); box-shadow: none; }
.card.bad { background: var(--bad-soft); box-shadow: none; }
.badge { display: inline-block; border-radius: 999px; padding: 3px 9px; font-size: 12px; font-weight: 600; background: #eef1f0; color: var(--ink2); }
.badge.green { background: var(--brand-soft); color: var(--brand); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }

/* бастау беті */
.welcome { max-width: 420px; margin: 0 auto; padding: 48px 20px 32px; min-height: 100dvh; display: flex; flex-direction: column; }
.logo { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 24px; letter-spacing: -.02em; }
.logo-mark {
  width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; color: #fff;
  background: linear-gradient(135deg, var(--brand2), var(--brand)); box-shadow: 0 6px 18px rgba(15, 122, 90, .35);
}
.logo-mark svg { width: 22px; height: 22px; }
.welcome .hero { margin: 40px 0 28px; }
.welcome .hero h1 { font-size: 30px; line-height: 1.15; }
.lang-switch { display: flex; gap: 6px; }
.lang-switch button { border: 0; background: transparent; color: var(--ink2); font-weight: 600; cursor: pointer; padding: 6px 8px; border-radius: 8px; }
.lang-switch button.on { background: #fff; color: var(--ink); box-shadow: var(--shadow); }

/* онбординг */
.wizard { max-width: 640px; margin: 0 auto; padding: 18px 16px 120px; }
.wizard-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.dots { display: flex; gap: 6px; }
.dots i { width: 22px; height: 5px; border-radius: 3px; background: #d6deda; }
.dots i.on { background: var(--brand2); }
.dots i.cur { background: var(--brand); width: 30px; }
.wizard-foot { position: fixed; left: 0; right: 0; bottom: 0; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); background: linear-gradient(transparent, var(--bg) 30%); }
.wizard-foot .inner { max-width: 640px; margin: 0 auto; }
.tabs { display: flex; background: #e9eeec; border-radius: 12px; padding: 3px; gap: 3px; }
.tabs button { flex: 1; border: 0; background: transparent; padding: 10px; border-radius: 10px; font-weight: 600; color: var(--ink2); cursor: pointer; }
.tabs button.on { background: #fff; color: var(--ink); box-shadow: var(--shadow); }
.qr-box { display: grid; place-items: center; padding: 18px; }
.qr-box canvas, .qr-box img { width: 220px; height: 220px; border-radius: 12px; background: #fff; padding: 10px; box-shadow: var(--shadow); }
.pair-code { font-size: 30px; font-weight: 800; letter-spacing: .12em; text-align: center; padding: 18px; background: #fff; border-radius: 14px; box-shadow: var(--shadow); }
ol.steps { padding-left: 20px; margin: 0; line-height: 1.7; }
.progress { height: 10px; background: #e2e8e5; border-radius: 6px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: linear-gradient(90deg, var(--brand2), var(--brand)); border-radius: 6px; transition: width .5s ease; }
.an-stages { list-style: none; padding: 0; margin: 16px 0 0; }
.an-stages li { display: flex; gap: 10px; align-items: center; padding: 7px 0; color: var(--ink2); }
.an-stages li.on { color: var(--ink); font-weight: 600; }
.an-stages li.ok { color: var(--brand); }
.an-stages li span.dot { width: 18px; height: 18px; border-radius: 50%; border: 2px solid #cfd8d4; display: grid; place-items: center; font-size: 11px; flex: none; }
.an-stages li.ok span.dot { background: var(--brand); border-color: var(--brand); color: #fff; }
.an-stages li.on span.dot { border-color: var(--brand2); animation: pulse 1s infinite alternate; }
@keyframes pulse { from { box-shadow: 0 0 0 0 rgba(20, 163, 122, .4); } to { box-shadow: 0 0 0 6px rgba(20, 163, 122, 0); } }
.stats3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 16px; }
.stats3 div { background: #fff; border-radius: 12px; padding: 12px; text-align: center; box-shadow: var(--shadow); }
.stats3 b { display: block; font-size: 22px; }

.section-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 6px; }
.section-head .ok { color: var(--brand); font-weight: 600; font-size: 13px; }
.kv { white-space: pre-wrap; line-height: 1.45; }
.ptable { width: 100%; border-collapse: collapse; }
.ptable td { padding: 8px 4px; border-top: 1px solid var(--line); vertical-align: top; }
.ptable td.price { white-space: nowrap; font-weight: 600; text-align: right; }

/* чат */
.bubbles { display: flex; flex-direction: column; gap: 6px; padding: 12px; background: #eef2ef; border-radius: 14px; min-height: 120px; }
.bubble { max-width: 82%; padding: 9px 12px; border-radius: 14px; line-height: 1.4; white-space: pre-wrap; word-wrap: break-word; box-shadow: 0 1px 1px rgba(0, 0, 0, .04); }
.bubble.in { background: var(--bubble-in); align-self: flex-start; border-bottom-left-radius: 4px; }
.bubble.out { background: var(--bubble-out); align-self: flex-end; border-bottom-right-radius: 4px; }
.bubble.owner { background: #e3ecff; }
.bubble.sys { align-self: center; background: transparent; box-shadow: none; color: var(--ink2); font-size: 12px; }
.bubble .meta { display: block; font-size: 11px; color: var(--ink2); margin-top: 3px; text-align: right; }
.bubble.draft { background: #fffbea; border: 1px dashed #e2c46b; align-self: flex-end; }
.composer { display: flex; gap: 8px; margin-top: 10px; }
.composer .input { border-radius: 22px; padding: 11px 16px; }
.composer .btn { border-radius: 22px; }

/* негізгі қосымша */
.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100dvh; }
.shell.with-sim { grid-template-columns: 220px 1fr 360px; }
.side { background: #fff; border-right: 1px solid var(--line); padding: 18px 12px; position: sticky; top: 0; height: 100dvh; display: flex; flex-direction: column; gap: 4px; }
.side .logo { padding: 0 8px 18px; font-size: 20px; }
.navbtn { display: flex; gap: 10px; align-items: center; border: 0; background: transparent; padding: 11px 12px; border-radius: 12px; cursor: pointer; font-weight: 600; color: var(--ink2); text-align: left; position: relative; }
.navbtn svg { width: 20px; height: 20px; flex: none; }
.navbtn.on { background: var(--brand-soft); color: var(--brand); }
.navbtn .count { margin-left: auto; background: var(--bad); color: #fff; border-radius: 999px; font-size: 11px; padding: 1px 7px; }
.main { padding: 22px 22px 100px; max-width: 900px; width: 100%; }
.main-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 16px; }
.sim { background: #fbfcfb; border-left: 1px solid var(--line); padding: 16px; position: sticky; top: 0; height: 100dvh; overflow-y: auto; }
.sim h3 { display: flex; align-items: center; gap: 8px; }
.sim .card { padding: 12px; }
.mobile-nav { display: none; }

.segment { display: flex; background: #e9eeec; border-radius: 14px; padding: 4px; }
.segment button { flex: 1; border: 0; background: transparent; padding: 12px; border-radius: 11px; cursor: pointer; font-weight: 700; color: var(--ink2); }
.segment button.on { background: #fff; color: var(--brand); box-shadow: var(--shadow); }
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.tile { background: #fff; border-radius: 14px; padding: 14px; box-shadow: var(--shadow); }
.tile b { display: block; font-size: 24px; letter-spacing: -.02em; margin-top: 4px; }
.tile span { color: var(--ink2); font-size: 13px; }
.list-item { display: flex; gap: 12px; align-items: center; padding: 12px; border-radius: 14px; background: #fff; box-shadow: var(--shadow); cursor: pointer; }
.list-item + .list-item { margin-top: 8px; }
.avatar { width: 42px; height: 42px; border-radius: 50%; background: linear-gradient(135deg, #cfe9df, #a7d8c5); display: grid; place-items: center; font-weight: 700; color: var(--brand); flex: none; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.feed-item { display: flex; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); font-size: 14px; white-space: pre-wrap; }
.feed-item:first-child { border-top: 0; }
.switch { position: relative; width: 50px; height: 30px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: #cfd8d4; border-radius: 30px; transition: .2s; cursor: pointer; }
.switch span::after { content: ''; position: absolute; width: 24px; height: 24px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.switch input:checked + span { background: var(--brand2); }
.switch input:checked + span::after { transform: translateX(20px); }
.setting { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.setting:first-of-type { border-top: 0; }
.meter { height: 8px; border-radius: 4px; background: #e2e8e5; overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--brand2); }
.meter.hot i { background: var(--warn); }
.plans { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.plan { border: 1.5px solid var(--line); border-radius: 14px; padding: 14px; background: #fff; cursor: pointer; }
.plan.on { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(15, 122, 90, .12); }
.plan b { font-size: 18px; display: block; margin: 4px 0; }
.plans.four { grid-template-columns: repeat(4, 1fr); }
.plan.enterprise { background: linear-gradient(135deg, #f0faf6, #fff); border-color: #bfe3d4; cursor: default; }
ul.features { margin: 0; padding-left: 0; list-style: none; }
ul.features li { padding: 6px 0 6px 26px; position: relative; line-height: 1.4; }
ul.features li::before { content: ''; position: absolute; left: 2px; top: 10px; width: 14px; height: 8px; border-left: 2.5px solid var(--brand2); border-bottom: 2.5px solid var(--brand2); transform: rotate(-45deg); }
.script { white-space: pre-wrap; line-height: 1.5; background: #f7f9f8; border-radius: 12px; padding: 12px; margin: 8px 0; }
.ai-note { font-size: 12px; color: var(--warn); background: var(--warn-soft); padding: 6px 10px; border-radius: 8px; }

.toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); background: #18211e; color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px; z-index: 50; box-shadow: var(--shadow); }
.spinner { width: 18px; height: 18px; border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
.spinner.dark { border-color: rgba(0,0,0,.15); border-top-color: var(--brand); }
@keyframes spin { to { transform: rotate(360deg); } }
.fade-in { animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.sim-fab { display: none; }

@media (max-width: 1180px) {
  .shell.with-sim { grid-template-columns: 220px 1fr; }
  .shell.with-sim .sim { position: fixed; right: 0; top: 0; width: min(380px, 100vw); z-index: 30; box-shadow: -10px 0 30px rgba(0,0,0,.1); transform: translateX(105%); transition: transform .25s; }
  .shell.with-sim .sim.open { transform: none; }
  .sim-fab { display: flex; position: fixed; right: 16px; bottom: 86px; z-index: 31; border-radius: 999px; box-shadow: 0 8px 24px rgba(15,122,90,.35); }
}
@media (max-width: 760px) {
  .shell, .shell.with-sim { display: block; }
  .side { display: none; }
  .main { padding: 16px 14px 110px; }
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .plans, .plans.four { grid-template-columns: 1fr 1fr; }
  .mobile-nav {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; background: rgba(255,255,255,.92); backdrop-filter: blur(16px);
    border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); z-index: 20;
  }
  .mobile-nav { overflow-x: auto; scrollbar-width: none; }
  .mobile-nav button { flex: 1 0 64px; border: 0; background: transparent; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 10.5px; font-weight: 600; color: var(--ink2); padding: 4px 0; cursor: pointer; position: relative; }
  .mobile-nav button svg { width: 22px; height: 22px; }
  .mobile-nav button.on { color: var(--brand); }
  .mobile-nav .count { position: absolute; top: 0; right: 22%; background: var(--bad); color: #fff; border-radius: 999px; font-size: 10px; padding: 0 5px; }
  .sim-fab { bottom: 84px; padding: 14px; }
  .sim-fab .fab-label { display: none; }
}

/* агенттер */
.agent {
  display: flex; gap: 12px; align-items: flex-start; background: var(--card); border: 1.5px solid var(--line);
  border-radius: var(--r); padding: 14px; cursor: pointer; transition: border-color .15s, background .15s;
}
.agent.on { border-color: var(--brand); background: var(--brand-soft); }
.agent.free { cursor: default; }
.agent .tick {
  flex: none; width: 24px; height: 24px; border-radius: 50%; border: 1.5px solid var(--line); display: grid; place-items: center;
  font-size: 13px; color: #fff; font-weight: 700;
}
.agent.on .tick { background: var(--brand); border-color: var(--brand); }
.agent-ic {
  flex: none; width: 40px; height: 40px; border-radius: 12px; background: var(--brand-soft); color: var(--brand);
  display: grid; place-items: center;
}
.agent-ic.sm { width: 30px; height: 30px; border-radius: 9px; }
.agent-ic.sm svg { width: 16px; height: 16px; }
.price-tag { text-align: right; white-space: nowrap; }
.price-tag b { display: block; }
.field > label { display: block; margin-bottom: 6px; }
.btn.soon { position: relative; }
.soon-tag {
  display: inline-block; margin-left: 8px; padding: 2px 8px; border-radius: 999px; background: #eef1f0; color: var(--ink2);
  font-size: 12px; font-weight: 600; vertical-align: middle;
}
.warn-text { color: var(--warn); }
.spend-row + .spend-row { margin-top: 10px; }
hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; }

/* кесте */
.cal-grid { padding: 10px; overflow-x: auto; }
.cal-wrap { display: grid; grid-template-columns: 46px repeat(7, minmax(92px, 1fr)); gap: 0; min-width: 700px; }
.cal-dh { height: 42px; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 12px; color: var(--ink2); }
.cal-dh b { font-size: 16px; color: var(--ink); }
.cal-dh.today b { background: var(--brand); color: #fff; border-radius: 999px; padding: 1px 8px; }
.cal-hours > div { font-size: 11px; color: var(--ink2); text-align: right; padding-right: 6px; transform: translateY(-6px); }
.cal-col { position: relative; border-left: 1px solid var(--line);
  background-image: repeating-linear-gradient(to bottom, var(--line) 0 1px, transparent 1px 44px); }
.cal-col.today { background-color: #f7fbf9; }
.cal-ev {
  position: absolute; left: 3px; right: 3px; border: 0; border-radius: 8px; padding: 3px 6px; text-align: left; cursor: pointer;
  background: var(--brand); color: #fff; font-size: 12px; overflow: hidden; line-height: 1.25;
}
.cal-ev.chat { background: #2f6fde; }
.cal-ev.done { opacity: .45; }
.cal-now { position: absolute; left: 0; right: 0; height: 2px; background: var(--bad); }
.cal-list { display: none; }
.cal-li { display: flex; gap: 10px; width: 100%; text-align: left; border: 0; background: none; padding: 8px 0; border-top: 1px solid var(--line); cursor: pointer; align-items: center; }
.cal-li:first-of-type { border-top: 0; }
@media (max-width: 760px) { .cal-grid { display: none; } .cal-list { display: block; } }
.sheet-bg { position: fixed; inset: 0; background: rgba(10, 20, 16, .35); display: grid; place-items: end center; z-index: 50; }
.sheet { background: #fff; width: 100%; max-width: 520px; border-radius: 20px 20px 0 0; padding: 20px 18px calc(20px + env(safe-area-inset-bottom)); position: relative; }
@media (min-width: 761px) { .sheet-bg { place-items: center; } .sheet { border-radius: 20px; } }
.sheet-x { position: absolute; right: 8px; top: 8px; }

/* әкімші панелі */
.client-row { display: block; width: 100%; text-align: left; border: 0; cursor: pointer; font: inherit; color: inherit; }
.client-row:hover { box-shadow: 0 0 0 1.5px var(--brand); }
.sheet.wide { max-width: 760px; max-height: 92dvh; overflow-y: auto; }
.row > .field { flex: 1; min-width: 0; }
