/* Кабинет Karaganda OIL. Цвета берутся из темы Telegram (themeParams), запасные заданы ниже. */
:root {
  --bg: #ffffff; --page: #f0f1f4; --text: #14181f; --hint: #6c7480; --link: #2481cc;
  --btn: #2481cc; --btn-text: #ffffff; --card: #ffffff; --line: rgba(20, 24, 31, .09);
  --danger: #d6453f; --ok: #2aa35a; --warn: #d98a00; --off: #98a0ab; --soft: rgba(36, 129, 204, .10);
  --radius: 14px; --tab-h: 58px;
  color-scheme: light;
}
:root[data-scheme="dark"] {
  --bg: #17212b; --page: #0e1621; --text: #f1f4f8; --hint: #8493a6; --link: #6ab3f3;
  --btn: #2f8fdc; --btn-text: #ffffff; --card: #17212b; --line: rgba(255, 255, 255, .09);
  --danger: #ff6b66; --ok: #4cc77f; --warn: #f0b13a; --off: #6d7a8a; --soft: rgba(106, 179, 243, .14);
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--page); color: var(--text); font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-text-size-adjust: 100%; overscroll-behavior: none;
}
#app { max-width: 720px; margin: 0 auto; min-height: 100%; display: flex; flex-direction: column; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.muted { color: var(--hint); }
.small { font-size: 13px; }
.nowrap { white-space: nowrap; }
.grow { flex: 1 1 auto; min-width: 0; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* каркас */
#top { position: sticky; top: 0; z-index: 5; background: var(--page); padding: 12px 16px 8px; padding-top: max(12px, env(safe-area-inset-top)); }
#top .title { font-size: 22px; font-weight: 700; display: flex; align-items: center; gap: 10px; }
#main { flex: 1 1 auto; padding: 4px 16px calc(var(--tab-h) + 28px + env(safe-area-inset-bottom)); }
#tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; display: flex; justify-content: center; background: var(--bg);
  border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
}
#tabs .inner { display: flex; width: 100%; max-width: 720px; }
.tab { flex: 1; height: var(--tab-h); border: 0; background: none; color: var(--hint); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 12px; position: relative; }
.tab svg { width: 24px; height: 24px; }
.tab.active { color: var(--link); font-weight: 600; }
.badge { position: absolute; top: 5px; left: calc(50% + 6px); min-width: 18px; height: 18px; border-radius: 9px; background: var(--danger); color: #fff; font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center; padding: 0 5px; }

/* карточки и строки */
.card { background: var(--card); border-radius: var(--radius); margin: 0 0 12px; overflow: hidden; }
.card.pad { padding: 14px 16px; }
.section-title { margin: 18px 4px 8px; font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--hint); }
.row { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: 0; }
.row.click { cursor: pointer; }
.row.click:active { background: var(--soft); }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--off); }
.dot.ok { background: var(--ok); } .dot.warn { background: var(--warn); } .dot.off { background: var(--off); }
.empty { text-align: center; color: var(--hint); padding: 36px 16px; }
.banner { border-radius: 12px; padding: 12px 14px; margin: 0 0 12px; background: var(--soft); }
.banner.warn { background: rgba(217, 138, 0, .14); }
.banner.danger { background: rgba(214, 69, 63, .13); }
.banner b { display: block; margin-bottom: 2px; }

/* кнопки */
.btn { border: 0; border-radius: 12px; padding: 11px 16px; font-weight: 600; background: var(--btn); color: var(--btn-text); min-height: 44px; }
.btn.secondary { background: var(--soft); color: var(--link); }
.btn.danger { background: rgba(214, 69, 63, .13); color: var(--danger); }
.btn.ghost { background: none; color: var(--link); padding: 8px 10px; min-height: 36px; }
.btn.small { padding: 7px 12px; min-height: 34px; font-size: 14px; border-radius: 10px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .45; cursor: default; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-row .btn { flex: 1 1 auto; }
.soon { font-size: 12px; font-weight: 500; opacity: .85; margin-left: 6px; }

/* сегмент, фишки */
.seg { display: flex; background: var(--bg); border-radius: 11px; padding: 3px; gap: 2px; }
.seg button { flex: 1; border: 0; background: none; padding: 7px 10px; border-radius: 9px; color: var(--hint); font-weight: 600; }
.seg button.on { background: var(--btn); color: var(--btn-text); }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 10px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 0; border-radius: 16px; padding: 6px 12px; background: var(--card); color: var(--text); font-size: 14px; }
.chip.on { background: var(--btn); color: var(--btn-text); }
.pill { display: inline-block; border-radius: 8px; padding: 2px 8px; font-size: 12px; font-weight: 600; background: var(--soft); color: var(--link); white-space: nowrap; }
.pill.ok { background: rgba(42, 163, 90, .15); color: var(--ok); }
.pill.warn { background: rgba(217, 138, 0, .16); color: var(--warn); }
.pill.off { background: rgba(152, 160, 171, .2); color: var(--hint); }
.pill.danger { background: rgba(214, 69, 63, .14); color: var(--danger); }

/* форма */
.field { display: block; margin: 0 0 12px; }
.field > span { display: block; font-size: 13px; color: var(--hint); margin: 0 0 4px 2px; }
.input { width: 100%; border: 1px solid var(--line); background: var(--page); border-radius: 11px; padding: 11px 12px; min-height: 44px; outline: none; }
.input:focus { border-color: var(--link); }
textarea.input { min-height: 70px; resize: vertical; }
.slots { display: flex; flex-wrap: wrap; gap: 8px; }
.slot-btn { border: 1px solid var(--line); background: var(--page); border-radius: 10px; padding: 8px 12px; font-weight: 600; min-width: 64px; }
.slot-btn.on { background: var(--btn); color: var(--btn-text); border-color: var(--btn); }
.check { display: flex; align-items: center; gap: 10px; margin: 6px 0 12px; }
.check input { width: 20px; height: 20px; }
.switch { position: relative; width: 50px; height: 30px; flex: none; }
.switch input { opacity: 0; width: 100%; height: 100%; margin: 0; position: absolute; z-index: 1; cursor: pointer; }
.switch i { position: absolute; inset: 0; background: var(--off); border-radius: 15px; transition: background .15s; }
.switch i::after { content: ""; position: absolute; left: 3px; top: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); }
.switch input:checked + i { background: var(--ok); }
.switch input:checked + i::after { transform: translateX(20px); }
.switch input:disabled { cursor: default; } .switch input:disabled + i { opacity: .5; }

/* расписание */
.daynav { display: flex; align-items: center; gap: 6px; margin: 4px 0 12px; }
.daynav .label { flex: 1; text-align: center; font-weight: 700; font-size: 17px; position: relative; }
.daynav .label::first-letter, .weekday b::first-letter { text-transform: uppercase; }
.daynav .label input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; }
.iconbtn { width: 40px; height: 40px; border: 0; border-radius: 12px; background: var(--card); color: var(--link); display: flex; align-items: center; justify-content: center; flex: none; }
.iconbtn svg { width: 20px; height: 20px; }
.slotrow { display: flex; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--line); align-items: flex-start; min-height: 58px; }
.slotrow:last-child { border-bottom: 0; }
.slotrow.past { opacity: .5; }
.slotrow .time { width: 46px; flex: none; font-weight: 700; font-variant-numeric: tabular-nums; padding-top: 2px; }
.slotrow .body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.slotrow .free { display: flex; align-items: center; gap: 8px; color: var(--hint); }
.booking { background: var(--soft); border-radius: 11px; padding: 9px 12px; cursor: pointer; }
.booking:active { filter: brightness(.95); }
.booking .l1 { display: flex; gap: 8px; align-items: baseline; justify-content: space-between; font-weight: 600; }
.booking .l2 { color: var(--hint); font-size: 13px; margin-top: 1px; }
.closed-row { display: flex; align-items: center; gap: 8px; color: var(--warn); font-weight: 600; }
.exc { align-items: flex-start; }
.exc-when { font-weight: 600; }
.exc-when::first-letter { text-transform: uppercase; }
.fab { position: fixed; right: max(16px, calc(50% - 344px)); bottom: calc(var(--tab-h) + 16px + env(safe-area-inset-bottom)); z-index: 4; border: 0; border-radius: 28px; height: 52px; padding: 0 20px 0 16px; background: var(--btn); color: var(--btn-text); font-weight: 700; display: flex; align-items: center; gap: 6px; box-shadow: 0 4px 14px rgba(0, 0, 0, .25); }
.fab svg { width: 22px; height: 22px; }
.weekday { display: flex; align-items: baseline; justify-content: space-between; padding: 12px 16px 6px; }
.weekday b { font-size: 16px; }
.weekday.today b { color: var(--link); }
.wk { padding: 4px 16px 12px; display: flex; flex-direction: column; gap: 4px; cursor: pointer; }
.wk .line { display: flex; gap: 8px; font-size: 14px; }
.wk .line .t { width: 44px; flex: none; font-weight: 600; font-variant-numeric: tabular-nums; }

/* диалоги */
.search { margin: 0 0 10px; }
.dlg { display: flex; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); cursor: pointer; align-items: flex-start; }
.dlg:last-child { border-bottom: 0; }
.dlg:active { background: var(--soft); }
.avatar { width: 44px; height: 44px; border-radius: 50%; flex: none; display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; font-size: 17px; }
.dlg .head { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.dlg .name { font-weight: 600; }
.dlg .preview { color: var(--hint); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin: 1px 0 5px; word-break: break-word; }
.dlg .tags { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.dlg.wait .name::after { content: ""; display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--danger); margin-left: 8px; }
.chat { display: flex; flex-direction: column; gap: 6px; padding: 4px 0 12px; }
.msg { max-width: 84%; padding: 8px 12px; border-radius: 16px; white-space: pre-wrap; word-break: break-word; background: var(--card); align-self: flex-start; border-bottom-left-radius: 5px; }
.msg.bot { align-self: flex-end; background: var(--btn); color: var(--btn-text); border-radius: 16px; border-bottom-right-radius: 5px; }
.msg.owner { align-self: flex-end; background: var(--ok); color: #fff; border-bottom-right-radius: 5px; }
.msg.followup, .msg.reminder { align-self: flex-end; background: var(--soft); color: var(--text); border: 1px dashed var(--link); border-bottom-right-radius: 5px; }
.msg .meta { display: block; font-size: 11px; opacity: .75; margin-top: 3px; text-align: right; }
.msg .tag { display: block; font-size: 11px; font-weight: 700; opacity: .8; margin-bottom: 2px; }
.msg .voices { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; white-space: normal; }
.msg .voice audio { width: 100%; min-width: 220px; height: 36px; }
.dayline { align-self: center; font-size: 12px; color: var(--hint); margin: 8px 0 2px; }
.actionbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 7; background: var(--bg); border-top: 1px solid var(--line); padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); display: flex; justify-content: center; }
.actionbar .inner { width: 100%; max-width: 720px; display: flex; flex-direction: column; gap: 6px; }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 6px 12px; padding: 12px 16px; font-size: 14px; }
.kv .k { color: var(--hint); }
.kv .v { word-break: break-word; }

/* настройки */
.srv { align-items: flex-start; }
.srv .dot { margin-top: 6px; }
.setrow { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.setrow:last-child { border-bottom: 0; }
.setrow.stack { flex-wrap: wrap; }
.setrow.stack .grow { flex-basis: 100%; }
.stepper { display: flex; align-items: center; gap: 8px; }
.kv { border-top: 1px solid var(--line); }
.stepper input { width: 70px; text-align: center; }
.result { margin-top: 10px; font-size: 14px; }
.result ul { margin: 6px 0 0; padding-left: 20px; }

/* шторка и уведомления */
.backdrop { position: fixed; inset: 0; z-index: 20; background: rgba(0, 0, 0, .45); display: flex; align-items: flex-end; justify-content: center; animation: fade .15s; }
.sheet { width: 100%; max-width: 720px; max-height: 92vh; overflow: auto; background: var(--bg); border-radius: 20px 20px 0 0; padding: 8px 16px calc(18px + env(safe-area-inset-bottom)); animation: up .18s ease-out; }
.sheet .grab { width: 38px; height: 4px; border-radius: 2px; background: var(--line); margin: 4px auto 10px; }
.sheet h3 { margin: 0 0 12px; font-size: 18px; }
.sheet .err { color: var(--danger); margin: 0 0 10px; font-size: 14px; }
#toast { position: fixed; left: 50%; bottom: calc(var(--tab-h) + 24px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 30; max-width: 90%; background: rgba(20, 24, 31, .92); color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px; pointer-events: none; opacity: 0; transition: opacity .2s; text-align: center; }
#toast.show { opacity: 1; }
#toast.error { background: rgba(190, 50, 45, .95); }
.center { min-height: 60vh; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 10px; padding: 24px; color: var(--hint); }
.spinner { width: 26px; height: 26px; border: 3px solid var(--line); border-top-color: var(--link); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(40px); opacity: .6; } }

/* расход нейросети (верхний блок «Настроек») */
.subtitle { margin: 14px 4px 6px; font-size: 13px; font-weight: 600; color: var(--hint); }
.pad-note { padding: 12px 16px 4px; }
.pad-note:last-child { padding-bottom: 12px; }
.tablewrap { overflow-x: auto; }
.ut { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.ut th { font-size: 12px; font-weight: 600; color: var(--hint); text-align: right; padding: 8px 6px; white-space: nowrap; }
.ut td { text-align: right; padding: 8px 6px; border-top: 1px solid var(--line); white-space: nowrap; }
.ut th:first-child, .ut td:first-child { text-align: left; padding-left: 14px; white-space: normal; }
.ut th:last-child, .ut td:last-child { padding-right: 14px; }
.ut tr.sub td { color: var(--hint); font-size: 13px; padding-top: 4px; padding-bottom: 4px; border-top: 0; }
.ut tr.sub td:first-child { padding-left: 28px; }
.ut tr.strong td { font-weight: 700; }
.ut.grid { margin-top: 10px; }
.ut.grid th:first-child, .ut.grid td:first-child { padding-left: 4px; }
.ut.grid th:last-child, .ut.grid td:last-child { padding-right: 4px; }
.ut tr.zero td { color: var(--hint); }
.seg-row { margin: 0 0 8px; }
.seg-row .seg { background: var(--page); }
.seg button { font-size: 14px; }
.chartcap { font-size: 14px; margin: 6px 0 2px; min-height: 20px; }
.bars { display: flex; gap: 2px; height: 140px; margin: 6px 0 2px; }
.bar { flex: 1 1 0; min-width: 0; border: 0; background: none; padding: 0; display: flex; flex-direction: column; }
.bw { flex: 1 1 auto; display: flex; align-items: flex-end; border-bottom: 1px solid var(--line); }
.bw i { display: block; width: 100%; background: var(--btn); opacity: .42; border-radius: 3px 3px 0 0; }
.bar.on .bw i { opacity: 1; }
.bl { height: 16px; flex: none; display: flex; justify-content: center; align-items: center; font-size: 9px; color: var(--hint); white-space: nowrap; }
.meterrow { margin: 0 0 12px; }
.mhead { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; margin-bottom: 5px; font-weight: 600; }
.mhead .muted, .mhead .danger-text { font-weight: 400; font-size: 13px; text-align: right; }
.danger-text { color: var(--danger); }
.meter { height: 10px; border-radius: 5px; background: var(--page); overflow: hidden; }
.meter i { display: block; height: 100%; border-radius: 5px; background: var(--ok); }
.meter i.warn { background: var(--warn); }
.meter i.over { background: var(--danger); }
.empty.small { padding: 16px; font-size: 14px; }
.ut.grid td:first-child { white-space: nowrap; }

/* ответ клиенту из кабинета и пометки WhatsApp */
.replybox { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.replybox .input.reply { flex: 1 1 200px; min-height: 52px; max-height: 140px; }
.replybox .replynote { flex: 1 0 100%; }
.msg .meta.fail { color: var(--danger, #d6453f); opacity: 1; font-weight: 600; text-align: left; }
/* лимит подписки Claude: красная плашка над всеми разделами, пока бот не отвечает клиентам */
.limit-banner { position: sticky; top: 0; z-index: 7; display: flex; gap: 8px; align-items: flex-start; background: #cf3b35; color: #fff; font-weight: 600; font-size: 14px; line-height: 1.35; padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top)); }
:root[data-scheme="dark"] .limit-banner { background: #b3302b; }
#app.has-limit #top { top: var(--limit-h, 0px); padding-top: 12px; }
.usage-toggle { display: flex; align-items: center; gap: 12px; width: 100%; margin: 4px 0 12px; padding: 12px 16px; border: 0; border-radius: var(--radius); background: var(--card); text-align: left; color: var(--text); }
.usage-toggle:active { background: var(--soft); }
.usage-toggle.open { margin-bottom: 8px; }
.usage-toggle .ut-title { display: block; font-weight: 700; font-size: 16px; }
.usage-toggle .ut-sum { display: block; font-size: 13px; color: var(--hint); margin-top: 2px; }
.usage-toggle .ut-sum.danger-text { color: var(--danger); }
.usage-toggle .chev { flex: none; color: var(--hint); font-size: 16px; transition: transform .15s; }
.usage-toggle.open .chev { transform: rotate(90deg); }
