:root {
  --bg: #070a08;
  --panel: #0f1511;
  --raise: #172019;
  --line: #213026;
  --text: #f1f5f2;
  --muted: #8b998f;
  --green: #33d67e;
  --green-ink: #04110a;
  --teal: #1fb6c9;
  --teal-soft: rgba(31, 182, 201, 0.14);
  --green-soft: rgba(51, 214, 126, 0.13);
  --warn: #f2b84b;
  --danger: #ef6b6b;
  --radius: 14px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
body {
  font: 15px/1.4 "Onest", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }

#app { display: flex; flex-direction: column; height: 100dvh; max-width: 720px; margin: 0 auto; }
main { flex: 1; min-height: 0; position: relative; }
.view { position: absolute; inset: 0; overflow-y: auto; padding: 12px 14px 18px; }

/* Шапка */
.top { display: flex; align-items: center; gap: 10px; padding: 12px 16px 10px; border-bottom: 1px solid var(--line); }
.mark { flex: none; }
.brand-name { font-family: "Unbounded", sans-serif; font-weight: 600; font-size: 14px; letter-spacing: 0.01em; }
.brand-sub { font-size: 12.5px; color: var(--muted); }
.brand-sub.warn { color: var(--warn); }

/* Нижние вкладки */
.tabs { display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid var(--line); background: var(--panel); padding-bottom: var(--safe-bottom); }
.tab { position: relative; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 9px 0 8px; background: none; border: 0; color: var(--muted); font-size: 11.5px; font-weight: 500; }
.tab svg { width: 22px; height: 22px; }
.tab.on { color: var(--green); }
.badge { position: absolute; top: 5px; left: calc(50% + 6px); min-width: 17px; height: 17px; padding: 0 5px; border-radius: 9px; background: var(--green); color: var(--green-ink); font: 600 11px/17px "Onest", sans-serif; font-style: normal; text-align: center; }

/* Списки */
.list { display: flex; flex-direction: column; gap: 8px; }
.search input { width: 100%; height: 40px; margin-bottom: 10px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); outline: none; }
.search input:focus { border-color: var(--teal); }
.empty { padding: 48px 20px; text-align: center; color: var(--muted); }
.empty b { display: block; margin-bottom: 6px; color: var(--text); font-weight: 600; }

.row { display: flex; gap: 12px; align-items: center; padding: 11px 12px; border-radius: var(--radius); background: var(--panel); border: 1px solid transparent; text-align: left; width: 100%; }
.row:active { background: var(--raise); }
.avatar { flex: none; width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; font-weight: 600; color: var(--green-ink); background: linear-gradient(135deg, var(--green), var(--teal)); }
.row-main { flex: 1; min-width: 0; }
.row-top { display: flex; align-items: baseline; gap: 8px; }
.row-name { flex: 1; min-width: 0; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-time { flex: none; font-size: 12px; color: var(--muted); }
.row-bottom { display: flex; align-items: center; gap: 6px; margin-top: 2px; }
.row-text { flex: 1; min-width: 0; color: var(--muted); font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-text .who { color: var(--teal); }
.pill { flex: none; font-size: 11px; font-weight: 600; padding: 2px 7px; border-radius: 999px; background: var(--raise); color: var(--muted); }
.pill.bot { background: var(--teal-soft); color: var(--teal); }
.pill.me { background: var(--green-soft); color: var(--green); }
.pill.count { background: var(--green); color: var(--green-ink); }

/* Чат */
.chat-view { display: flex; flex-direction: column; padding: 0; overflow: hidden; }
.chat-head { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--line); background: var(--panel); }
.icon-btn { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; border: 0; background: none; color: var(--text); }
.chat-title { flex: 1; min-width: 0; }
.chat-title > div:first-child { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.switch { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); user-select: none; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.track { position: relative; width: 40px; height: 24px; border-radius: 12px; background: var(--raise); border: 1px solid var(--line); transition: background 0.2s; }
.thumb { position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: var(--muted); transition: transform 0.2s, background 0.2s; }
.switch input:checked + .track { background: var(--teal-soft); border-color: var(--teal); }
.switch input:checked + .track .thumb { transform: translateX(16px); background: var(--teal); }

.messages { flex: 1; overflow-y: auto; padding: 14px 12px; display: flex; flex-direction: column; gap: 6px; }
.day { align-self: center; margin: 8px 0 4px; font-size: 12px; color: var(--muted); padding: 2px 10px; border-radius: 999px; background: var(--panel); }
.msg { max-width: 82%; padding: 8px 11px 6px; border-radius: 14px; white-space: pre-wrap; word-wrap: break-word; }
.msg .meta { display: flex; justify-content: flex-end; gap: 6px; margin-top: 2px; font-size: 11px; color: var(--muted); }
.msg.client { align-self: flex-start; background: var(--panel); border-bottom-left-radius: 5px; }
.msg.bot { align-self: flex-end; background: var(--teal-soft); border: 1px solid rgba(31, 182, 201, 0.25); border-bottom-right-radius: 5px; }
.msg.owner { align-self: flex-end; background: var(--green-soft); border: 1px solid rgba(51, 214, 126, 0.25); border-bottom-right-radius: 5px; }
.msg.bot .meta b { color: var(--teal); font-weight: 600; }
.msg.owner .meta b { color: var(--green); font-weight: 600; }

.composer { display: flex; align-items: flex-end; gap: 8px; padding: 8px 10px calc(8px + var(--safe-bottom)); border-top: 1px solid var(--line); background: var(--panel); }
.composer textarea { flex: 1; resize: none; max-height: 140px; min-height: 40px; padding: 9px 13px; border-radius: 20px; border: 1px solid var(--line); background: var(--bg); outline: none; line-height: 1.35; }
.composer textarea:focus { border-color: var(--teal); }
.send { flex: none; width: 40px; height: 40px; border-radius: 50%; border: 0; display: grid; place-items: center; background: var(--green); color: var(--green-ink); }
.send:disabled { opacity: 0.5; }
.hint { padding: 8px 12px; font-size: 12.5px; color: var(--muted); text-align: center; border-top: 1px solid var(--line); background: var(--panel); }

/* Заявки */
.chips { display: flex; gap: 6px; margin-bottom: 12px; overflow-x: auto; }
.chip { flex: none; height: 32px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); color: var(--muted); font-size: 13px; font-weight: 500; }
.chip b { color: var(--green); font-weight: 600; margin-left: 2px; }
.chip.on { border-color: var(--green); color: var(--text); background: var(--green-soft); }

.card { padding: 13px 14px; border-radius: var(--radius); background: var(--panel); border: 1px solid var(--line); }
.card-top { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; }
.card-kind { font-weight: 600; flex: 1; }
.src { font-size: 11px; font-weight: 600; padding: 2px 7px; border-radius: 999px; }
.src.bot { background: var(--teal-soft); color: var(--teal); }
.src.site { background: var(--green-soft); color: var(--green); }
.card-sum { font-family: "Unbounded", sans-serif; font-size: 17px; font-weight: 500; margin: 2px 0 4px; }
.card-line { font-size: 13.5px; color: var(--muted); }
.card-line strong { color: var(--text); font-weight: 500; }
.card-visit { display: inline-flex; align-items: center; gap: 6px; margin-top: 8px; padding: 5px 10px; border-radius: 10px; background: var(--teal-soft); color: var(--teal); font-weight: 500; font-size: 13.5px; }
.card-actions { display: flex; gap: 8px; margin-top: 12px; }
.btn { flex: 1; height: 38px; border-radius: 11px; border: 1px solid var(--line); background: var(--raise); font-weight: 600; font-size: 13.5px; }
.btn.primary { background: var(--green); border-color: var(--green); color: var(--green-ink); }
.btn.ghost { background: none; }
.btn:disabled { opacity: 0.55; }
.status-tag { font-size: 12px; color: var(--muted); }

/* Курс */
.rate-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.rate-card { padding: 14px; border-radius: var(--radius); background: var(--panel); border: 1px solid var(--line); }
.rate-card .label { font-size: 12.5px; color: var(--muted); }
.rate-card .value { font-family: "Unbounded", sans-serif; font-size: 22px; font-weight: 500; margin-top: 6px; }
.rate-card.buy .value { color: var(--green); }
.rate-card.sell .value { color: var(--teal); }
.rate-mid { margin: 12px 2px 18px; font-size: 13.5px; color: var(--muted); }
.rate-mid strong { color: var(--text); font-weight: 500; }
.section-title { font-weight: 600; margin: 4px 2px 10px; }
.stepper { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; border-radius: var(--radius); background: var(--panel); border: 1px solid var(--line); margin-bottom: 8px; }
.stepper .name { font-size: 14px; }
.stepper .name small { display: block; color: var(--muted); font-size: 12px; }
.stepper .ctl { display: flex; align-items: center; gap: 6px; }
.stepper button { width: 34px; height: 34px; border-radius: 10px; border: 1px solid var(--line); background: var(--raise); font-size: 18px; line-height: 1; }
.stepper input { width: 70px; height: 34px; text-align: center; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); outline: none; }
.stepper input:focus { border-color: var(--teal); }
.note { margin-top: 14px; padding: 12px 14px; border-radius: var(--radius); background: var(--raise); color: var(--muted); font-size: 13.5px; }
.note a { color: var(--teal); }

.toast { position: fixed; left: 50%; bottom: calc(76px + var(--safe-bottom)); transform: translateX(-50%); max-width: calc(100% - 32px); padding: 10px 14px; border-radius: 12px; background: var(--raise); border: 1px solid var(--line); font-size: 13.5px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4); z-index: 10; }
.toast.err { border-color: var(--danger); }

.skeleton { height: 64px; border-radius: var(--radius); background: linear-gradient(90deg, var(--panel), var(--raise), var(--panel)); background-size: 200% 100%; animation: sh 1.2s infinite; }
@keyframes sh { to { background-position: -200% 0; } }
