:root {
  --wine: #B01E3E; --wine-2: #8E1631; --brown: #5C3034; --ink: #2B1D1F; --muted: #7D6A6C;
  --bg: #FBF7F5; --card: #FFFFFF; --line: #EEE3E0; --soft: #F6ECEA; --ok: #2E7D4F; --warn: #B7791F; --bad: #B3261E;
  --radius: 14px; --tabs-h: 62px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root { --ink: #F3E9E7; --muted: #B9A6A8; --bg: #1B1415; --card: #261D1E; --line: #3A2D2F; --soft: #30252700; --soft: #2F2426; --wine: #E0587A; --wine-2: #C84868; --brown: #D9B3B7; }
}
[hidden] { display: none !important; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.4 -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; }
body { padding-bottom: calc(var(--tabs-h) + var(--safe-b)); }
header#top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 8px; padding: 12px 16px;
  background: var(--card); border-bottom: 1px solid var(--line); }
header h1 { margin: 0; font-size: 18px; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#brand { color: var(--muted); font-size: 12px; max-width: 45%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
button.icon { border: 0; background: none; font-size: 28px; line-height: 1; color: var(--wine); padding: 0 6px 0 0; cursor: pointer; }
main { padding: 12px 12px 24px; max-width: 760px; margin: 0 auto; }
nav#tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; display: flex; background: var(--card);
  border-top: 1px solid var(--line); padding-bottom: var(--safe-b); height: calc(var(--tabs-h) + var(--safe-b)); }
nav#tabs a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--muted); text-decoration: none; font-size: 11px; position: relative; }
nav#tabs a b { font-size: 20px; font-weight: normal; }
nav#tabs a.on { color: var(--wine); font-weight: 600; }
#badge { position: absolute; top: 6px; right: calc(50% - 22px); background: var(--wine); color: #fff; font-style: normal;
  font-size: 10px; min-width: 17px; height: 17px; border-radius: 9px; display: flex; align-items: center; justify-content: center; padding: 0 4px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 10px; }
.card h3 { margin: 0 0 6px; font-size: 15px; }
.row { display: flex; align-items: center; gap: 8px; }
.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 10px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.kpi b { display: block; font-size: 24px; color: var(--wine); }
.kpi span { color: var(--muted); font-size: 12.5px; }
.section { margin: 18px 4px 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.list > a, .list > div.item { display: flex; align-items: center; gap: 10px; padding: 12px 14px; background: var(--card);
  border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 8px; color: inherit; text-decoration: none; }
.list .grow { flex: 1; min-width: 0; }
.list .t { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list .s { color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chev { color: var(--muted); font-size: 20px; }
.pill { display: inline-block; font-size: 11.5px; padding: 2px 8px; border-radius: 10px; background: var(--soft); color: var(--brown); white-space: nowrap; }
.pill.new { background: #FDE7EC; color: var(--wine); } .pill.confirmed { background: #E3F4EA; color: var(--ok); }
.pill.declined { background: #FFF1DB; color: var(--warn); } .pill.closed { background: var(--soft); color: var(--muted); }
@media (prefers-color-scheme: dark) { .pill.new { background: #4A2230; } .pill.confirmed { background: #1E3A2A; } .pill.declined { background: #45361C; } }
.seg { display: flex; background: var(--soft); border-radius: 12px; padding: 3px; margin-bottom: 10px; overflow-x: auto; }
.seg button { flex: 1; border: 0; background: none; padding: 8px 10px; border-radius: 9px; color: var(--muted); font: inherit; white-space: nowrap; cursor: pointer; }
.seg button.on { background: var(--card); color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 0; border-radius: 11px; padding: 10px 14px;
  font: inherit; font-weight: 600; cursor: pointer; background: var(--wine); color: #fff; text-decoration: none; }
.btn.sec { background: var(--soft); color: var(--ink); } .btn.ghost { background: none; color: var(--wine); padding: 8px; }
.btn.bad { background: #FBE3E1; color: var(--bad); } .btn.block { width: 100%; }
.btn:disabled { opacity: .5; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.actions .btn { flex: 1; min-width: 120px; }
input, textarea, select { width: 100%; font: inherit; color: var(--ink); background: var(--card); border: 1px solid var(--line);
  border-radius: 11px; padding: 10px 12px; outline: none; }
input:focus, textarea:focus, select:focus { border-color: var(--wine); }
textarea { min-height: 120px; resize: vertical; }
label.f { display: block; margin: 10px 0 4px; font-size: 13px; color: var(--muted); }
.search { position: sticky; top: 58px; z-index: 3; background: var(--bg); padding-bottom: 8px; }
.tl { display: flex; flex-direction: column; gap: 6px; }
.bubble { max-width: 86%; padding: 8px 11px; border-radius: 14px; background: var(--card); border: 1px solid var(--line); white-space: pre-wrap; word-wrap: break-word; }
.bubble.me { align-self: flex-end; background: #FCE8ED; border-color: #F4CBD6; }
.bubble.ai { background: var(--soft); }
@media (prefers-color-scheme: dark) { .bubble.me { background: #4A2230; border-color: #5E2B3C; } }
.bubble .at { display: block; font-size: 11px; color: var(--muted); margin-top: 3px; }
.event { align-self: center; font-size: 12px; color: var(--muted); text-align: center; padding: 2px 10px; }
.composer { position: sticky; bottom: calc(var(--tabs-h) + var(--safe-b)); background: var(--bg); padding: 8px 0; display: flex; gap: 8px; }
.composer textarea { min-height: 44px; height: 44px; }
.toggle { display: flex; align-items: flex-start; gap: 12px; padding: 12px 14px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 8px; }
.toggle .grow { flex: 1; }
.sw { position: relative; width: 46px; height: 28px; flex: none; }
.sw input { opacity: 0; width: 0; height: 0; }
.sw span { position: absolute; inset: 0; background: #D8CACC; border-radius: 16px; transition: .2s; }
.sw span:before { content: ""; position: absolute; width: 22px; height: 22px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; }
.sw input:checked + span { background: var(--wine); } .sw input:checked + span:before { transform: translateX(18px); }
#toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--tabs-h) + var(--safe-b) + 12px); z-index: 20;
  background: #2B1D1F; color: #fff; padding: 10px 16px; border-radius: 12px; max-width: 90%; font-size: 14px; box-shadow: 0 6px 20px rgba(0,0,0,.2); }
#toast.bad { background: var(--bad); }
#modal { position: fixed; inset: 0; z-index: 30; background: rgba(20,10,12,.45); display: flex; align-items: flex-end; justify-content: center; }
#modal .sheet { width: 100%; max-width: 760px; max-height: 92vh; overflow: auto; background: var(--bg); border-radius: 18px 18px 0 0;
  padding: 16px 16px calc(16px + var(--safe-b)); }
#modal h2 { margin: 0 0 8px; font-size: 17px; }
.preview { background: var(--card); border: 1px dashed var(--line); border-radius: 12px; padding: 10px; white-space: pre-wrap; }
.empty { text-align: center; color: var(--muted); padding: 36px 12px; }
.loading { text-align: center; color: var(--muted); padding: 40px; }
.login { text-align: center; padding: 40px 18px; }
.login img { width: 120px; height: 120px; border-radius: 50%; }
hr { border: 0; border-top: 1px solid var(--line); margin: 12px 0; }
a { color: var(--wine); }
/* оформление юридических ботов */
:root[data-theme="lawyer"] { --wine: #D9480F; --wine-2: #B83A0A; --brown: #3A3F47; --ink: #1E2024; --muted: #6B6F78;
  --bg: #F5F5F7; --card: #FFFFFF; --line: #E6E6EA; --soft: #EEEEF1; }
:root[data-theme="lawyer"] .pill.new, :root[data-theme="lawyer"] .bubble.me { background: #FFE8DC; border-color: #FFD2BD; }
:root[data-theme="lawyer"] .pill.new { color: var(--wine); }
.pill.taken { background: #E4EEFF; color: #2A5DB0; } .pill.enroute { background: #FFF1DB; color: var(--warn); }
@media (prefers-color-scheme: dark) {
  :root[data-theme="lawyer"] { --wine: #FF6A2B; --wine-2: #E85A1E; --brown: #C9CDD4; --ink: #F2F2F4; --muted: #9A9EA8;
    --bg: #141518; --card: #1E2024; --line: #2C2F35; --soft: #26292E; }
  :root[data-theme="lawyer"] .pill.new, :root[data-theme="lawyer"] .bubble.me { background: #3A2418; border-color: #54301D; }
  .pill.taken { background: #1D2A40; } .pill.enroute { background: #45361C; }
}
/* экран ПИН-кода */
.pin { text-align: center; padding: 18px 12px 8px; max-width: 360px; margin: 0 auto; }
.pin img { width: 76px; height: 76px; border-radius: 50%; }
.pin h2 { margin: 10px 0 14px; font-size: 19px; }
.dots { display: flex; justify-content: center; gap: 14px; min-height: 18px; }
.dots i { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--wine); display: inline-block; }
.dots i.on { background: var(--wine); }
.dots.shake { animation: shake .35s; }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }
.pad { display: grid; grid-template-columns: repeat(3, 76px); gap: 14px 22px; justify-content: center; margin: 6px 0 16px; }
.pad button { width: 76px; height: 76px; border-radius: 50%; border: 0; background: var(--card); color: var(--ink);
  font: 500 28px/1 -apple-system, "Segoe UI", Roboto, sans-serif; box-shadow: 0 1px 3px rgba(0,0,0,.12); cursor: pointer; }
.pad button:active { background: var(--soft); }
.pad button[data-k="del"] { background: none; box-shadow: none; font-size: 26px; }
.pad button.ok { background: var(--wine); color: #fff; }

/* ===================== современный слой: стекло, иконки, аватары, скелетоны, анимации ===================== */
:root { --shadow: 0 1px 2px rgba(40,20,25,.05), 0 6px 18px rgba(40,20,25,.05); --radius: 16px; }
@media (prefers-color-scheme: dark) { :root { --shadow: 0 1px 2px rgba(0,0,0,.35); } }
header#top { background: var(--card); background: color-mix(in srgb, var(--card) 80%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(16px); backdrop-filter: saturate(180%) blur(16px);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 70%, transparent); padding-top: calc(12px + env(safe-area-inset-top, 0px)); }
header h1 { font-size: 20px; font-weight: 750; letter-spacing: -.01em; }
nav#tabs { background: var(--card); background: color-mix(in srgb, var(--card) 82%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(18px); backdrop-filter: saturate(180%) blur(18px);
  border-top: 1px solid color-mix(in srgb, var(--line) 70%, transparent); }
nav#tabs a { gap: 3px; font-size: 11.5px; font-weight: 500; }
nav#tabs a b { position: relative; display: flex; align-items: center; justify-content: center; width: 58px; height: 30px; border-radius: 16px; transition: background .2s; }
nav#tabs a b svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
nav#tabs a.on { font-weight: 650; }
nav#tabs a.on b { background: color-mix(in srgb, var(--wine) 14%, transparent); }
nav#tabs a.on b svg { stroke-width: 2.1; }
#badge { top: -3px; right: 6px; box-shadow: 0 0 0 2px var(--card); }
.card, .kpi, .list > a, .list > div.item, .toggle { border-color: color-mix(in srgb, var(--line) 75%, transparent); box-shadow: var(--shadow); }
.kpi { padding: 14px; transition: transform .15s; }
.kpi b { font-size: 28px; font-weight: 750; letter-spacing: -.02em; }
.kpi:active, .list > a:active { transform: scale(.985); }
.list > a { transition: transform .15s, background .15s; }
.btn { transition: transform .12s, filter .12s; }
.btn:active { transform: scale(.97); filter: brightness(.95); }
.section { font-weight: 650; font-size: 12px; letter-spacing: .06em; }
.av { flex: none; width: 40px; height: 40px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 15px; background: hsl(var(--h, 340) 60% 90%); color: hsl(var(--h, 340) 45% 30%); }
.av.big { width: 54px; height: 54px; font-size: 20px; }
@media (prefers-color-scheme: dark) { .av { background: hsl(var(--h, 340) 28% 26%); color: hsl(var(--h, 340) 70% 82%); } }
.ttl { font-weight: 750; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sk-wrap { padding-top: 4px; }
.sk-row { display: flex; gap: 12px; align-items: center; padding: 14px; background: var(--card); border-radius: var(--radius); margin-bottom: 8px; box-shadow: var(--shadow); }
.sk { display: block; border-radius: 8px; background: var(--soft);
  background: linear-gradient(90deg, var(--soft) 25%, color-mix(in srgb, var(--soft) 45%, var(--card)) 50%, var(--soft) 75%);
  background-size: 200% 100%; animation: sk 1.1s linear infinite; }
.sk-av { width: 40px; height: 40px; border-radius: 50%; flex: none; }
.sk-l { height: 12px; width: 62%; margin-bottom: 9px; } .sk-s { height: 10px; width: 38%; }
@keyframes sk { from { background-position: 200% 0; } to { background-position: -200% 0; } }
#view.enter { animation: enter .2s ease-out; }
@keyframes enter { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
#modal { animation: fade .18s ease-out; }
#modal .sheet { animation: up .22s cubic-bezier(.2,.8,.2,1); border-radius: 22px 22px 0 0; }
#modal .sheet::before { content: ""; display: block; width: 38px; height: 4px; border-radius: 2px; background: var(--line); margin: -6px auto 12px; }
@keyframes fade { from { opacity: 0; } } @keyframes up { from { transform: translateY(40px); opacity: .6; } }
#toast { border-radius: 14px; background: rgba(35,25,27,.92); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); animation: fade .2s; }
.empty-ic { font-size: 34px; margin-bottom: 8px; }
#ptr { position: fixed; top: calc(56px + env(safe-area-inset-top, 0px)); left: 50%; transform: translate(-50%, 0); z-index: 4; width: 38px; height: 38px;
  border-radius: 50%; background: var(--card); box-shadow: var(--shadow); display: flex; align-items: center; justify-content: center; opacity: 0; pointer-events: none; }
#ptr svg { width: 20px; height: 20px; fill: none; stroke: var(--wine); stroke-width: 2.2; stroke-linecap: round; transition: transform .2s; }
#ptr.ready svg { transform: rotate(180deg); }
#ptr.spin { opacity: 1; transform: translate(-50%, 24px); } #ptr.spin svg { animation: rot .7s linear infinite; }
@keyframes rot { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { *, *::before { animation: none !important; transition: none !important; } }
.bell { display: flex; align-items: center; gap: 12px; }
.bell .bi { font-size: 26px; width: 44px; height: 44px; border-radius: 14px; background: var(--soft); display: flex; align-items: center; justify-content: center; flex: none; }
.bell b { font-size: 14.5px; }
.sw input:disabled + span { opacity: .45; }
