/*
 * AURA — общий стиль админки (как на сайте: серый, графит, глубокие тени, день/ночь).
 * Подключается на всех страницах админки. Тема хранится в localStorage 'aura_theme' — общая с сайтом.
 */
@import url('https://fonts.googleapis.com/css2?family=Unbounded:wght@300;400;500&family=Onest:wght@400;500;600;700&family=Noto+Sans+Thai:wght@300;400;500;600;700&display=swap');

:root {
  --bg: #E7E8EA;
  --plate: #F4F5F6;
  --card: #FFFFFF;
  --card-hover: #FFFFFF;
  --ink: #1D1F23;
  --ink-2: #3A3D43;
  --ink-hover: #2A2D32;
  --on-ink: #FFFFFF;
  --soft: #6B6F77;
  --faint: #9A9EA5;
  --line: #D2D5D9;
  --line-2: #C3C7CC;
  --sunk: #EEF0F2;
  --sunk-2: #FAFAFB;
  --ok: #1F8F5C;
  --ok-soft: #DDF3E8;
  --warn: #8A5A00;
  --warn-soft: #FFF1D6;
  --err: #B3343A;
  --err-soft: #F7E1E3;
  --info: #1F5F8F;
  --info-soft: #DCEBF7;
  --violet: #5B2E9E;
  --violet-soft: #EEE5FA;
  --shadow-1: 0 1px 1px rgba(20, 22, 26, .04), 0 2px 4px -2px rgba(20, 22, 26, .06);
  --shadow-2: 0 1px 1px rgba(20, 22, 26, .04), 0 10px 24px -12px rgba(20, 22, 26, .18), 0 40px 70px -40px rgba(20, 22, 26, .30);
  --a-display: 'Unbounded', 'Onest', 'Noto Sans Thai', system-ui, sans-serif;
  --a-body: 'Onest', 'Noto Sans Thai', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --ease: cubic-bezier(.2, .7, .1, 1);

  /* совместимость со старыми страницами (вход, пользователи) */
  --desk: var(--bg);
  --paper: var(--card);
  --muted: var(--soft);
  --brand: var(--ink);
  --brand-dark: var(--ink-hover);
  --brand-soft: var(--sunk);
  --basil: var(--ok);
  --basil-soft: var(--ok-soft);
  --danger: var(--err);
  --danger-soft: var(--err-soft);
  --font: var(--a-body);
  --shadow-paper: 0 0 0 1px var(--line), var(--shadow-2);
}

[data-theme="dark"] {
  --bg: #111316;
  --plate: #181B1F;
  --card: #20242A;
  --card-hover: #262B31;
  --ink: #E9ECEF;
  --ink-2: #C5CBD2;
  --ink-hover: #FFFFFF;
  --on-ink: #15171A;
  --soft: #98A0A9;
  --faint: #6C737C;
  --line: #2B3036;
  --line-2: #3A4047;
  --sunk: #15181C;
  --sunk-2: #1C2025;
  --ok: #6FD3A2; --ok-soft: rgba(47, 163, 107, .18);
  --warn: #F1C46B; --warn-soft: rgba(241, 196, 107, .14);
  --err: #F08A90; --err-soft: rgba(240, 138, 144, .14);
  --info: #8CC3EC; --info-soft: rgba(140, 195, 236, .14);
  --violet: #C6A8F5; --violet-soft: rgba(198, 168, 245, .14);
  --shadow-1: 0 1px 1px rgba(0, 0, 0, .3), 0 2px 4px -2px rgba(0, 0, 0, .4);
  --shadow-2: 0 1px 1px rgba(0, 0, 0, .3), 0 10px 24px -12px rgba(0, 0, 0, .6), 0 40px 70px -40px rgba(0, 0, 0, .8);
  color-scheme: dark;
}

/* ---------- старые страницы: кнопки на графите, заголовки в новом шрифте ---------- */
.submit, .btn-primary { color: var(--on-ink) !important; }
body { font-family: var(--a-body); background: var(--bg); color: var(--ink); }
h1 { font-family: var(--a-display); font-weight: 400 !important; letter-spacing: -.02em !important; }
.brand-mark:has(.fa-utensils) { background: var(--ink) !important; }
.brand-mark .fa-utensils { display: none; }

/* ---------- базовые элементы ---------- */
.a-page { min-height: 100vh; padding: 20px 20px 60px; font-variant-numeric: tabular-nums; }
.a-page *, .a-page *::before, .a-page *::after { box-sizing: border-box; }
.a-wrap { max-width: 1320px; margin: 0 auto; }
.a-page [hidden] { display: none !important; }
.a-page :where(button, input, textarea) { font: inherit; color: inherit; }
.a-page :focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; border-radius: 8px; }

.a-head { position: sticky; top: 12px; z-index: 50; display: flex; align-items: center; gap: 14px; padding: 10px 12px 10px 18px; margin-bottom: 22px; border-radius: 22px;
  background: color-mix(in srgb, var(--plate) 82%, transparent); backdrop-filter: blur(14px) saturate(1.3); -webkit-backdrop-filter: blur(14px) saturate(1.3);
  box-shadow: 0 0 0 1px var(--line), 0 14px 30px -20px rgba(20, 22, 26, .45); }
.a-brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: inherit; margin-right: auto; min-width: 0; }
.a-mark { position: relative; width: 32px; height: 32px; flex: none; border-radius: 50%; background: var(--ink); }
.a-mark::before { content: ""; position: absolute; inset: 7px; border-radius: 50%; border: 2px dashed var(--bg); animation: a-spin 14s linear infinite; }
.a-mark::after { content: ""; position: absolute; inset: 12px; border-radius: 50%; background: var(--bg); }
@keyframes a-spin { to { transform: rotate(360deg); } }
.a-brand b { font-family: var(--a-display); font-weight: 500; font-size: 1.02rem; letter-spacing: .1em; }
.a-brand small { display: block; font-size: .78rem; color: var(--soft); letter-spacing: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.a-tools { display: flex; align-items: center; gap: 8px; }

.a-iconbtn, .theme-toggle { width: 42px; height: 42px; border: 0; border-radius: 50%; cursor: pointer; display: grid; place-items: center; background: var(--card); color: var(--ink); box-shadow: 0 0 0 1px var(--line), var(--shadow-1); transition: box-shadow .2s, transform .2s var(--ease); text-decoration: none; }
.a-iconbtn:hover, .theme-toggle:hover { box-shadow: 0 0 0 1px var(--line-2), 0 10px 20px -12px rgba(20, 22, 26, .4); transform: translateY(-1px); }
.a-iconbtn svg, .theme-toggle svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
[data-theme="dark"] .a-sun, :root:not([data-theme="dark"]) .a-moon { display: none; }

.a-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 18px; border: 0; border-radius: 999px; cursor: pointer; text-decoration: none; white-space: nowrap;
  background: var(--ink); color: var(--on-ink); font-weight: 600; font-size: 14px; box-shadow: 0 1px 0 rgba(255, 255, 255, .15) inset, 0 8px 18px -10px rgba(20, 22, 26, .55); transition: transform .2s var(--ease), background .2s; }
.a-btn:hover { background: var(--ink-hover); transform: translateY(-1px); }
.a-btn.line { background: var(--card); color: var(--ink); box-shadow: 0 0 0 1px var(--line-2), var(--shadow-1); }
.a-btn.line:hover { box-shadow: 0 0 0 1px var(--ink-2), 0 10px 20px -12px rgba(20, 22, 26, .4); }
.a-btn.sm { height: 34px; padding: 0 14px; font-size: 13px; }
.a-btn[disabled] { opacity: .5; cursor: default; transform: none; }
.a-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.a-card { background: var(--card); border-radius: 24px; box-shadow: 0 0 0 1px var(--line), var(--shadow-2); }

.a-title { font-family: var(--a-display); font-weight: 300; font-size: clamp(1.8rem, 1.3rem + 1.4vw, 2.6rem); letter-spacing: -.03em; line-height: 1.05; margin: 6px 0 18px; }

/* ---------- статусы ---------- */
.a-status { display: inline-flex; align-items: center; gap: 6px; padding: 4px 11px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--sunk); color: var(--ink-2); box-shadow: inset 0 0 0 1px var(--line); }
.a-status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.a-status.s1 { background: var(--warn-soft); color: var(--warn); box-shadow: none; }
.a-status.s2 { background: var(--info-soft); color: var(--info); box-shadow: none; }
.a-status.s3 { background: var(--violet-soft); color: var(--violet); box-shadow: none; }
.a-status.s4 { background: var(--ok-soft); color: var(--ok); box-shadow: none; }
.a-status.s5 { background: var(--err-soft); color: var(--err); box-shadow: none; }

/* ---------- панель фильтров ---------- */
.a-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 16px; }
.a-chip { height: 36px; padding: 0 14px; border: 0; border-radius: 999px; cursor: pointer; background: var(--card); color: var(--soft); font-size: 13px; font-weight: 600; box-shadow: 0 0 0 1px var(--line); display: inline-flex; align-items: center; gap: 6px; transition: color .15s, box-shadow .15s; }
.a-chip:hover { color: var(--ink); box-shadow: 0 0 0 1px var(--line-2); }
.a-chip[aria-pressed="true"] { background: var(--ink); color: var(--on-ink); box-shadow: none; }
.a-search { position: relative; margin-left: auto; }
.a-search input { height: 38px; width: 280px; border: 0; border-radius: 999px; padding: 0 16px 0 40px; background: var(--card); box-shadow: 0 0 0 1px var(--line); outline: none; }
.a-search input:focus { box-shadow: 0 0 0 2px var(--ink-2); }
.a-search svg { position: absolute; left: 14px; top: 50%; width: 16px; height: 16px; transform: translateY(-50%); fill: none; stroke: var(--faint); stroke-width: 2; stroke-linecap: round; }

/* ---------- список ---------- */
.a-layout { display: grid; grid-template-columns: minmax(0, 1fr) 460px; gap: 18px; align-items: start; }
.a-list { overflow: hidden; }
.a-row { display: grid; grid-template-columns: 76px minmax(0, 1fr) auto auto; gap: 4px 16px; align-items: center; padding: 15px 18px; border-top: 1px solid var(--line); color: inherit; text-decoration: none; cursor: pointer; transition: background .15s; }
.a-row:first-child { border-top: 0; }
.a-row:hover { background: var(--sunk-2); }
.a-row.active { background: var(--sunk); box-shadow: inset 3px 0 0 var(--ink); }
.a-row-id { font-family: var(--a-display); font-weight: 400; font-size: 15px; }
.a-row-time { display: block; font-size: 12px; color: var(--faint); margin-top: 2px; font-family: var(--a-body); }
.a-row-who { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.a-row-items { font-size: 13px; color: var(--soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.a-row-side { display: grid; justify-items: end; gap: 5px; }
.a-row-sum { font-size: 13px; font-weight: 600; white-space: nowrap; }
.a-row-src { font-size: 11px; color: var(--faint); }
.a-row-open { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; color: var(--faint); opacity: 0; transition: opacity .15s, background .15s, color .15s; }
.a-row:hover .a-row-open, .a-row.active .a-row-open { opacity: 1; }
.a-row-open:hover { background: var(--card); color: var(--ink); box-shadow: 0 0 0 1px var(--line); }
.a-row-open svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.a-empty, .a-loading, .a-error { padding: 44px 20px; text-align: center; color: var(--soft); }
.a-error { color: var(--err); }
.a-more { display: block; width: 100%; padding: 15px; border: 0; border-top: 1px solid var(--line); background: none; cursor: pointer; font-weight: 600; color: var(--ink); }
.a-more:hover { background: var(--sunk-2); }

/* ---------- карточка заявки (и в панели, и на отдельной странице) ---------- */
.rq { padding: 24px; display: grid; gap: 22px; }
.rq-head { display: flex; align-items: flex-start; gap: 10px; }
.rq-head h2 { font-family: var(--a-display); font-weight: 400; font-size: 1.5rem; letter-spacing: -.02em; line-height: 1.15; margin: 0 auto 0 0; }
.rq-head h2 small { display: block; margin-top: 6px; font-family: var(--a-body); font-size: 13px; font-weight: 400; color: var(--soft); letter-spacing: 0; }
.rq-sec h3 { margin: 0 0 10px; font-size: 12px; font-weight: 600; color: var(--faint); letter-spacing: .02em; }
.rq-statuses { display: flex; flex-wrap: wrap; gap: 6px; }
.rq-statuses button { border: 0; cursor: pointer; padding: 8px 13px; border-radius: 999px; font-size: 13px; font-weight: 600; background: var(--card); color: var(--soft); box-shadow: 0 0 0 1px var(--line); transition: box-shadow .15s, color .15s; }
.rq-statuses button:hover { color: var(--ink); box-shadow: 0 0 0 1px var(--line-2); }
.rq-statuses button.a-status { box-shadow: 0 0 0 2px currentColor; }
.rq-statuses button[disabled] { opacity: .55; cursor: default; }
.rq-kv { display: grid; grid-template-columns: 110px 1fr; gap: 8px 14px; margin: 0; font-size: 14px; }
.rq-kv dt { color: var(--soft); }
.rq-kv dd { margin: 0; word-break: break-word; }
.rq-links { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.rq-links a { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 13px; border-radius: 999px; background: var(--sunk); box-shadow: inset 0 0 0 1px var(--line); color: var(--ink); font-weight: 600; font-size: 13px; text-decoration: none; }
.rq-links a:hover { box-shadow: inset 0 0 0 1px var(--ink-2); }
.rq-items { width: 100%; border-collapse: collapse; font-size: 14px; }
.rq-items td { padding: 10px 0; border-top: 1px solid var(--line); vertical-align: top; }
.rq-items td:last-child { text-align: right; white-space: nowrap; padding-left: 14px; color: var(--ink-2); }
.rq-totals { display: grid; gap: 4px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line-2); font-weight: 600; }
.rq-totals div { display: flex; justify-content: space-between; }
.rq-comment { white-space: pre-wrap; padding: 13px 15px; border-radius: 16px; background: var(--sunk); box-shadow: inset 0 0 0 1px var(--line); font-size: 14px; }
.rq-note { width: 100%; min-height: 90px; border: 0; border-radius: 16px; padding: 12px 15px; background: var(--sunk); box-shadow: inset 0 0 0 1px var(--line); outline: none; resize: vertical; }
.rq-note:focus { box-shadow: inset 0 0 0 2px var(--ink-2); }
.rq-note-bar { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.rq-hint { font-size: 13px; color: var(--soft); }
.rq-hint.ok { color: var(--ok); }
.rq-hint.err { color: var(--err); }
.rq-history { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; }
.rq-history li { position: relative; display: flex; align-items: center; gap: 10px; padding: 7px 0 7px 18px; font-size: 13px; color: var(--soft); }
.rq-history li::before { content: ""; position: absolute; left: 4px; top: 0; bottom: 0; width: 1px; background: var(--line-2); }
.rq-history li::after { content: ""; position: absolute; left: 1px; top: 50%; width: 7px; height: 7px; margin-top: -3.5px; border-radius: 50%; background: var(--card); box-shadow: 0 0 0 1.5px var(--line-2); }
.rq-history li:first-child::before { top: 50%; }
.rq-history li:last-child::before { bottom: 50%; }
.rq-history .a-status { font-size: 11px; padding: 2px 9px; }

.a-detail { position: sticky; top: 96px; max-height: calc(100vh - 116px); overflow: auto; scrollbar-width: thin; }
.a-placeholder { padding: 60px 24px; text-align: center; color: var(--soft); display: grid; gap: 12px; justify-items: center; }
.a-placeholder .a-mark { width: 54px; height: 54px; opacity: .85; }
.a-placeholder .a-mark::before { inset: 12px; }
.a-placeholder .a-mark::after { inset: 21px; }

.a-toast { position: fixed; left: 50%; bottom: 24px; z-index: 200; transform: translateX(-50%); padding: 12px 20px; border-radius: 999px; background: var(--ink); color: var(--on-ink); font-weight: 600; font-size: 14px; box-shadow: 0 16px 36px -14px rgba(20, 22, 26, .7); animation: a-pop .35s var(--ease); }
@keyframes a-pop { from { transform: translate(-50%, 10px); opacity: 0; } }

/* ---------- отдельная страница заявки ---------- */
.a-single { max-width: 820px; margin: 0 auto; }
.a-single .rq { padding: 32px; }
.a-single .rq-head h2 { font-size: 2rem; }
@media print {
  .a-head, .rq-statuses, .rq-note-bar, .rq-links, .a-iconbtn, .a-btn { display: none !important; }
  .a-card { box-shadow: none; }
  body { background: #fff; color: #000; }
}

/* ---------- адаптив ---------- */
@media (max-width: 1040px) {
  .a-layout { grid-template-columns: 1fr; }
  .a-detail-wrap { position: fixed; inset: 0; z-index: 90; padding: 12px; background: rgba(17, 19, 22, .45); backdrop-filter: blur(4px); display: none; overflow: auto; }
  .a-detail-wrap.open { display: block; }
  .a-detail { position: static; max-height: none; max-width: 620px; margin: 0 auto; }
  .a-detail .a-placeholder { display: none; }
}
@media (max-width: 720px) {
  .a-page { padding: 10px 10px 40px; }
  .a-head { top: 8px; padding: 8px 8px 8px 14px; }
  .a-brand small { display: none; }
  .a-search { margin-left: 0; width: 100%; }
  .a-search input { width: 100%; font-size: 16px; }
  .a-row { grid-template-columns: 58px minmax(0, 1fr) auto; padding: 13px 14px; }
  .a-row-open { display: none; }
  .rq { padding: 20px; }
  .rq-kv { grid-template-columns: 90px 1fr; }
  .a-single .rq { padding: 22px; }
}
@media (prefers-reduced-motion: reduce) {
  .a-mark::before { animation: none; }
}

/* ---------- разделы админки в шапке ---------- */
.a-nav { display: flex; gap: 4px; padding: 4px; border-radius: 999px; background: var(--sunk); box-shadow: inset 0 0 0 1px var(--line); margin-right: auto; }
.a-nav a { height: 34px; padding: 0 15px; border-radius: 999px; display: inline-flex; align-items: center; gap: 7px; color: var(--soft); text-decoration: none; font-size: 13px; font-weight: 600; white-space: nowrap; transition: color .15s, background .15s; }
.a-nav a:hover { color: var(--ink); }
.a-nav a[aria-current="page"] { background: var(--card); color: var(--ink); box-shadow: 0 0 0 1px var(--line), var(--shadow-1); }
.a-nav b { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; display: inline-grid; place-items: center; background: var(--ink); color: var(--on-ink); font-size: 11px; }
.a-head .a-brand { margin-right: 0; }
.a-head .a-nav + .a-tools { margin-left: auto; }

/* ---------- сводка ---------- */
.v-stats { display: flex; flex-wrap: wrap; gap: 10px; margin: -6px 0 18px; }
.v-stat { padding: 10px 16px; border-radius: 18px; background: var(--card); box-shadow: 0 0 0 1px var(--line), var(--shadow-1); min-width: 120px; }
.v-stat b { display: block; font-family: var(--a-display); font-weight: 400; font-size: 1.35rem; letter-spacing: -.02em; }
.v-stat span { font-size: 12px; color: var(--soft); }
.v-stat.live b::after { content: ""; display: inline-block; width: 8px; height: 8px; margin-left: 8px; vertical-align: middle; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 4px var(--ok-soft); }
.v-check { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--soft); cursor: pointer; user-select: none; }
.v-check input { accent-color: var(--ink); width: 16px; height: 16px; }

/* ---------- строка визита ---------- */
.v-row .a-row-who { font-weight: 500; }
.v-flag { font-size: 15px; margin-right: 4px; }
.v-badges { display: flex; gap: 5px; justify-content: flex-end; flex-wrap: wrap; }
.v-badge { display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--sunk); color: var(--ink-2); box-shadow: inset 0 0 0 1px var(--line); white-space: nowrap; }
.v-badge svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.v-badge.bot { color: var(--faint); }
.v-quote { font-style: normal; color: var(--ink-2); }

/* ---------- карточка визита ---------- */
.v-geo { font-size: 15px; }
.v-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.v-chip { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 11px; border-radius: 999px; background: var(--sunk); box-shadow: inset 0 0 0 1px var(--line); font-size: 12px; color: var(--ink-2); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
a.v-chip, button.v-chip { border: 0; cursor: pointer; text-decoration: none; }
a.v-chip:hover, button.v-chip:hover { box-shadow: inset 0 0 0 1px var(--ink-2); color: var(--ink); }
.v-filter { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.v-filter .a-chip { height: 30px; font-size: 12px; }

.v-tl { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.v-ev { position: relative; display: grid; grid-template-columns: 46px 1fr; gap: 10px; align-items: baseline; padding: 6px 0; font-size: 13px; }
.v-ev time { font-size: 11px; color: var(--faint); text-align: right; font-variant-numeric: tabular-nums; }
.v-ev .v-txt { position: relative; padding-left: 18px; color: var(--ink-2); word-break: break-word; }
.v-ev .v-txt::before { content: ""; position: absolute; left: 2px; top: .45em; width: 7px; height: 7px; border-radius: 50%; background: var(--card); box-shadow: 0 0 0 1.5px var(--line-2); }
.v-ev.k-cart .v-txt::before { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-soft); }
.v-ev.k-order .v-txt { font-weight: 600; color: var(--ink); }
.v-ev.k-order .v-txt::before { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.v-ev.k-chat .v-txt::before { background: var(--info); box-shadow: 0 0 0 3px var(--info-soft); }
.v-ev.k-error .v-txt { color: var(--err); }
.v-ev.k-error .v-txt::before { background: var(--err); }
.v-ev.k-quiet .v-txt { color: var(--soft); }
.v-ev .v-sub { color: var(--faint); }
.v-ev button.v-link { border: 0; background: none; padding: 0; color: inherit; font: inherit; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }

.v-msg { display: grid; grid-template-columns: 46px 1fr; gap: 10px; padding: 5px 0; }
.v-msg time { font-size: 11px; color: var(--faint); text-align: right; padding-top: 10px; }
.v-bubble { max-width: 92%; padding: 10px 14px; border-radius: 18px; font-size: 14px; line-height: 1.45; white-space: pre-wrap; word-break: break-word; }
.v-msg.user .v-bubble { background: var(--ink); color: var(--on-ink); border-bottom-left-radius: 6px; justify-self: start; }
.v-msg.assistant .v-bubble { background: var(--sunk); box-shadow: inset 0 0 0 1px var(--line); border-bottom-left-radius: 6px; justify-self: start; }
.v-who { display: block; font-size: 11px; font-weight: 600; opacity: .65; margin-bottom: 3px; }
.v-note { display: block; margin-top: 6px; font-size: 12px; color: var(--ok); font-weight: 600; }
.v-note.err { color: var(--err); }

.v-chat { display: grid; gap: 2px; max-height: 520px; overflow: auto; padding-right: 4px; scrollbar-width: thin; }
.v-more-btn { margin-top: 10px; }

@media (max-width: 1100px) {
  .a-nav a { padding: 0 11px; }
}
@media (max-width: 720px) {
  .a-head { flex-wrap: wrap; }
  .a-nav { order: 3; width: 100%; margin-right: 0; overflow-x: auto; scrollbar-width: none; }
  .a-nav::-webkit-scrollbar { display: none; }
  .a-nav a { flex: 1 0 auto; justify-content: center; padding: 0 10px; font-size: 12.5px; }
  .v-stat { min-width: 0; flex: 1 1 28%; padding: 8px 12px; border-radius: 14px; }
  .v-stat b { font-size: 1.1rem; }
  .v-stat span { font-size: 11px; }
  .v-ev, .v-msg { grid-template-columns: 38px 1fr; }
}

/* ---------- лента с подгрузкой ---------- */
.v-sentinel { height: 1px; }
.v-tl-status { padding: 10px 0 2px; font-size: 13px; color: var(--soft); text-align: center; }
.v-tl-status:empty { display: none; }
.v-tl-status.err { color: var(--err); }
.v-tl-status .v-link { border: 0; background: none; padding: 0; color: inherit; font: inherit; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.v-day .v-txt { font-weight: 600; color: var(--ink-2); }
.v-day .v-txt::before { display: none; }
.v-chat .v-tl { gap: 0; }

/* =====================================================================
   Аналитика: графики и сводные таблицы
   ===================================================================== */
.a-page {
  /* категориальные цвета (проверены на различимость при дальтонизме) */
  --c1: #257de0; --c2: #f47230; --c3: #00b894; --c4: #f2a600;
  /* последовательная шкала одного цвета: мало → много */
  --q1: #cce3fd; --q2: #9dc8f7; --q3: #6aabf1; --q4: #338ced; --q5: #2370cd; --q6: #1757ac; --q7: #0e3d7e;
}
[data-theme="dark"] .a-page {
  --c1: #338ced; --c2: #e76624; --c3: #00a888; --c4: #d28e05;
  --q1: #1b2a3f; --q2: #1a3a63; --q3: #1b4f8c; --q4: #2370cd; --q5: #338ced; --q6: #6aabf1; --q7: #b6d5f8;
}

.an-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: -4px 0 20px; }
.an-bar .a-chip { height: 34px; }
.an-dates { display: inline-flex; align-items: center; gap: 6px; height: 40px; padding: 0 6px 0 14px; border-radius: 999px; background: var(--card); box-shadow: 0 0 0 1px var(--line), var(--shadow-1); font-size: 13px; color: var(--soft); }
.an-dates input, .an-dates select { height: 30px; border: 0; border-radius: 999px; background: var(--sunk); color: var(--ink); padding: 0 10px; font: inherit; font-size: 13px; }
.an-dates input:focus-visible, .an-dates select:focus-visible { outline: 2px solid var(--ink); outline-offset: 1px; }
.an-updated { margin-left: auto; font-size: 12px; color: var(--faint); }

.an-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 28px; }
.an-kpi { padding: 16px 18px; border-radius: 22px; background: var(--card); box-shadow: 0 0 0 1px var(--line), var(--shadow-1); min-width: 0; }
.an-kpi span { display: block; font-size: 12.5px; color: var(--soft); }
.an-kpi b { display: block; margin: 6px 0 4px; font-family: var(--a-display); font-weight: 300; font-size: clamp(1.4rem, 1.1rem + .8vw, 1.9rem); letter-spacing: -.03em; line-height: 1.1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.an-kpi small { display: block; font-size: 12px; color: var(--faint); }
.an-delta { font-weight: 600; }
.an-delta.up { color: var(--ok); }
.an-delta.down { color: var(--err); }
.an-delta.flat { color: var(--soft); }

.an-h { font-family: var(--a-display); font-weight: 400; font-size: 1.25rem; letter-spacing: -.02em; margin: 34px 0 14px; }
.an-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 14px; }
.an-card { grid-column: span 6; padding: 18px 20px 16px; border-radius: 24px; background: var(--card); box-shadow: 0 0 0 1px var(--line), var(--shadow-1); min-width: 0; }
.an-card.w12 { grid-column: span 12; }
.an-card.w8 { grid-column: span 8; }
.an-card.w4 { grid-column: span 4; }
.an-card h3 { margin: 0 0 2px; font-size: 15px; font-weight: 600; letter-spacing: -.01em; }
.an-card .an-sub { margin: 0 0 14px; font-size: 12.5px; color: var(--soft); }
.an-note { margin: 12px 0 0; font-size: 12.5px; color: var(--soft); }
.an-note b { color: var(--ink); }
.an-mini { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-bottom: 16px; }
.an-mini div { padding: 10px 12px; border-radius: 16px; background: var(--sunk); }
.an-mini b { display: block; font-family: var(--a-display); font-weight: 400; font-size: 1.2rem; letter-spacing: -.02em; }
.an-mini span { font-size: 12px; color: var(--soft); }

/* графики */
.ch-area { width: 100%; }
.ch-svg { display: block; overflow: visible; }
.ch-grid { stroke: var(--line); stroke-width: 1; stroke-dasharray: 2 4; }
.ch-base { stroke: var(--line-2, var(--line)); stroke-width: 1; }
.ch-tick { font-size: 11px; fill: var(--faint); font-variant-numeric: tabular-nums; }
.ch-line { stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.ch-line.dashed { stroke-dasharray: 5 4; }
.ch-fill { opacity: .08; }
.ch-dot { stroke: var(--card); stroke-width: 2; }
.ch-dot-hi { stroke: var(--card); stroke-width: 2; }
.ch-cross { stroke: var(--ink); stroke-width: 1; stroke-dasharray: 3 3; opacity: .4; }
.ch-col.hover path { opacity: .82; }
.ch-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 0 0 12px; font-size: 12.5px; color: var(--ink-2); }
.ch-legend-item { display: inline-flex; align-items: center; gap: 7px; }
.ch-sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; flex: none; }
.ch-sw.dashed { height: 0; border-top: 2px dashed currentColor; background: none !important; width: 14px; border-radius: 0; }
.ch-tip { position: fixed; z-index: 1000; display: none; pointer-events: none; min-width: 150px; max-width: 300px; padding: 10px 12px; border-radius: 14px; background: var(--card); color: var(--ink); box-shadow: 0 0 0 1px var(--line), 0 14px 34px rgba(0,0,0,.18); font-size: 12.5px; }
.ch-tip b { display: block; margin-bottom: 6px; font-weight: 600; }
.ch-tip-row { display: flex; align-items: center; gap: 8px; line-height: 1.6; }
.ch-tip-row span { color: var(--soft); }
.ch-tip-row em { margin-left: auto; padding-left: 12px; font-style: normal; font-weight: 600; font-variant-numeric: tabular-nums; }
.ch-empty { margin: 8px 0; font-size: 13px; color: var(--soft); }

.ch-hbars { display: grid; gap: 4px; }
.ch-hrow { display: grid; grid-template-columns: minmax(90px, 38%) 1fr auto; align-items: center; gap: 12px; padding: 5px 6px; margin: 0 -6px; border-radius: 10px; font-size: 13px; }
.ch-hrow:hover { background: var(--sunk); }
.ch-hlabel { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-2); }
.ch-hlabel small { margin-left: 6px; color: var(--faint); font-size: 11.5px; }
.ch-htrack { display: grid; gap: 2px; min-width: 0; }
.ch-hbar { height: 12px; border-radius: 0 4px 4px 0; min-width: 0; }
.ch-htrack .ch-hbar + .ch-hbar { height: 8px; }
.ch-hval { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--ink); text-align: right; white-space: nowrap; }

.ch-heat { display: grid; gap: 3px; align-items: center; font-size: 11px; color: var(--faint); }
.ch-heat-col { text-align: left; white-space: nowrap; overflow: visible; }
.ch-heat-row { padding-right: 8px; }
.ch-cell { display: block; aspect-ratio: 1 / 1; min-height: 12px; border-radius: 4px; background: var(--sunk); }
.ch-cell.q1 { background: var(--q1); } .ch-cell.q2 { background: var(--q2); } .ch-cell.q3 { background: var(--q3); }
.ch-cell.q4 { background: var(--q4); } .ch-cell.q5 { background: var(--q5); } .ch-cell.q6 { background: var(--q6); } .ch-cell.q7 { background: var(--q7); }
.ch-heat .ch-cell:hover { box-shadow: 0 0 0 2px var(--ink); }
.ch-heat-scale { display: flex; align-items: center; gap: 3px; margin-top: 12px; font-size: 11px; color: var(--faint); }
.ch-heat-scale .ch-cell { width: 14px; min-height: 14px; }
.ch-heat-scale span { margin: 0 6px; }

/* сводные таблицы */
.an-table-wrap { overflow-x: auto; margin: 0 -4px; padding: 0 4px; }
.an-table { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
.an-table th { position: sticky; top: 0; background: var(--card); text-align: right; font-weight: 600; font-size: 12px; color: var(--soft); padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; cursor: pointer; user-select: none; }
.an-table th:first-child, .an-table td:first-child { text-align: left; }
.an-table th[aria-sort="ascending"]::after { content: " ↑"; color: var(--ink); }
.an-table th[aria-sort="descending"]::after { content: " ↓"; color: var(--ink); }
.an-table td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; color: var(--ink-2); }
.an-table td:first-child { color: var(--ink); white-space: normal; min-width: 140px; }
.an-table tbody tr:hover td { background: var(--sunk); }
.an-table tfoot td { font-weight: 700; color: var(--ink); border-bottom: 0; border-top: 2px solid var(--line); }
.an-tabs { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 14px; }
.an-tabs .a-chip { height: 32px; font-size: 12.5px; }
.an-tabs .a-btn { margin-left: auto; }
.an-loading { opacity: .55; transition: opacity .2s; pointer-events: none; }

@media (max-width: 1100px) {
  .an-card, .an-card.w4, .an-card.w8 { grid-column: span 12; }
  .an-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  .an-kpis { gap: 8px; }
  .an-kpi { padding: 12px 14px; border-radius: 18px; }
  .an-card { padding: 14px 14px 12px; border-radius: 20px; }
  .ch-hrow { grid-template-columns: minmax(70px, 34%) 1fr auto; gap: 8px; }
  .an-mini { grid-template-columns: 1fr 1fr; }
  .an-updated { margin-left: 0; width: 100%; }
  .an-dates { flex-wrap: wrap; height: auto; padding: 8px 10px; border-radius: 20px; width: 100%; }
  .an-dates input { flex: 1 1 110px; min-width: 0; }
  .an-dates select { flex: 1 1 100%; }
}

/* =====================================================================
   Пользователи и роли
   ===================================================================== */
.u-grid { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 16px; align-items: start; }
.u-list { padding: 6px; }
.u-row { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: 14px; align-items: center; padding: 14px 16px; border-radius: 18px; }
.u-row + .u-row { box-shadow: 0 -1px 0 var(--line); border-radius: 0; }
.u-row.off { opacity: .55; }
.u-ava { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: var(--sunk); color: var(--ink); font-weight: 700; font-size: 15px; box-shadow: inset 0 0 0 1px var(--line); }
.u-row.admin .u-ava { background: var(--ink); color: var(--on-ink); box-shadow: none; }
.u-name { font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.u-meta { font-size: 12.5px; color: var(--soft); margin-top: 2px; }
.u-meta b { font-weight: 600; color: var(--ink-2); }
.u-tools { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.u-select { height: 34px; border: 0; border-radius: 999px; padding: 0 30px 0 14px; background: var(--sunk); color: var(--ink); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; }
.u-select:focus-visible, .u-input:focus-visible { outline: 2px solid var(--ink); outline-offset: 1px; }
.u-edit { grid-column: 2 / -1; display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; align-items: end; margin-top: 6px; }
.u-field { display: grid; gap: 6px; font-size: 12.5px; color: var(--soft); }
.u-input { height: 40px; border: 0; border-radius: 12px; padding: 0 12px; background: var(--sunk); color: var(--ink); font: inherit; font-size: 14px; width: 100%; min-width: 0; }
.u-pass { display: flex; gap: 6px; }
.u-form { padding: 20px; display: grid; gap: 12px; position: sticky; top: 16px; }
.u-form h3, .u-role h3 { margin: 0; font-size: 16px; font-weight: 600; }
.u-msg { min-height: 18px; font-size: 13px; color: var(--soft); }
.u-msg.ok { color: var(--ok); } .u-msg.err { color: var(--err); }
.u-tag { display: inline-flex; align-items: center; height: 22px; padding: 0 9px; border-radius: 999px; font-size: 11.5px; font-weight: 700; background: var(--sunk); color: var(--ink-2); box-shadow: inset 0 0 0 1px var(--line); vertical-align: 1px; }
.u-tag.admin { background: var(--ink); color: var(--on-ink); box-shadow: none; }
.u-tag.off { background: var(--err-soft); color: var(--err); box-shadow: none; }

.u-roles { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 16px; }
.u-role { padding: 20px; display: grid; gap: 14px; align-content: start; }
.u-role-head { display: flex; gap: 10px; align-items: flex-start; }
.u-role-head > div { flex: 1; min-width: 0; }
.u-role-head p { margin: 4px 0 0; font-size: 13px; color: var(--soft); }
.u-perms { display: grid; gap: 2px; }
.u-perm { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); }
.u-perm b { font-size: 14px; font-weight: 600; }
.u-perm small { display: block; font-size: 12px; color: var(--faint); margin-top: 2px; line-height: 1.35; }
.u-seg { display: inline-flex; padding: 3px; border-radius: 999px; background: var(--sunk); box-shadow: inset 0 0 0 1px var(--line); }
.u-seg label { position: relative; }
.u-seg input { position: absolute; opacity: 0; pointer-events: none; }
.u-seg span { display: inline-flex; align-items: center; height: 28px; padding: 0 11px; border-radius: 999px; font-size: 12.5px; font-weight: 600; color: var(--soft); cursor: pointer; white-space: nowrap; }
.u-seg input:checked + span { background: var(--card); color: var(--ink); box-shadow: 0 0 0 1px var(--line), var(--shadow-1); }
.u-seg input:checked + span.l0 { color: var(--faint); }
.u-seg input:checked + span.l2 { background: var(--ink); color: var(--on-ink); box-shadow: none; }
.u-seg input:focus-visible + span { outline: 2px solid var(--ink); outline-offset: 1px; }
.u-seg input:disabled + span { cursor: default; }
.u-level { font-size: 12.5px; font-weight: 700; padding: 4px 10px; border-radius: 999px; background: var(--sunk); color: var(--soft); }
.u-level.l1 { color: var(--info); background: var(--info-soft); }
.u-level.l2 { color: var(--ok); background: var(--ok-soft); }
.u-role-foot { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.u-role-foot .u-msg { flex: 1; }
.u-role.new { box-shadow: 0 0 0 2px var(--ink), var(--shadow-2); }
.u-note { margin: 0 0 16px; font-size: 13.5px; color: var(--soft); max-width: 760px; line-height: 1.5; }

@media (max-width: 980px) {
  .u-grid { grid-template-columns: 1fr; }
  .u-form { position: static; }
}
@media (max-width: 560px) {
  .u-row { grid-template-columns: 40px minmax(0, 1fr); }
  .u-tools { grid-column: 1 / -1; justify-content: flex-start; }
  .u-edit { grid-column: 1 / -1; grid-template-columns: 1fr; }
  .u-roles { grid-template-columns: 1fr; }
  .u-perm { grid-template-columns: 1fr; }
}

/* ---------- переключатель языка EN / RU / TH ---------- */
.a-lang { display: inline-flex; gap: 2px; padding: 3px; border-radius: 999px; background: var(--card); box-shadow: 0 0 0 1px var(--line); flex: none; }
.a-lang button { border: 0; background: none; min-width: 34px; height: 30px; padding: 0 8px; border-radius: 999px; cursor: pointer; font: 600 12px var(--a-body); letter-spacing: .02em; color: var(--soft); }
.a-lang button:hover { color: var(--ink); }
.a-lang button[aria-pressed="true"] { background: var(--ink); color: var(--on-ink); }
.a-lang button:focus-visible { outline: 2px solid var(--ink); outline-offset: 1px; }
@media (max-width: 760px) { .a-lang-head { display: none; } }
/* тайский: строки выше — чуть больше межстрочный интервал */
html[data-lang="th"] body { line-height: 1.6; }
