/* ServiceDeskie — интерфейс исполнителей.
   Шрифт Inter (OFL), иконки Feather (MIT). Цвета — через переменные, тёмная тема — те же роли. */

@font-face {
  font-family: "Inter";
  src: url("/static/fonts/inter-cyrillic.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Inter";
  src: url("/static/fonts/inter-latin.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329,
    U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ---------- токены ---------- */
:root {
  color-scheme: light;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Consolas, monospace;

  --bg: #f3f3f6;
  --sidebar: #f7f7f9;
  --panel: #ffffff;
  --panel-2: #f8f8fa;
  --hover: #f0f0f4;
  --active: #ededfd;
  --line: #e6e6ec;
  --line-strong: #d4d4dd;
  --text: #15151c;
  --text-2: #4a4a56;
  --muted: #868694;
  --accent: #5b5bd6;
  --accent-hover: #4d4dc9;
  --accent-soft: #ececfd;
  --ring: rgba(91, 91, 214, 0.28);
  --success: #15a14a;
  --success-hover: #12903f;
  --danger: #dc2626;
  --warn: #d97706;

  --bubble-in: #ffffff;
  --bubble-out: #e9e9fc;
  --note: #fff7df;
  --note-line: #f0d78c;

  --st-new: #2f6fe4;         --st-new-bg: #e8f0fe;
  --st-in_progress: #b45309; --st-in_progress-bg: #fdf2e1;
  --st-waiting: #7c3aed;     --st-waiting-bg: #f2ecff;
  --st-resolved: #15803d;    --st-resolved-bg: #e5f6eb;
  --st-closed: #6b6b77;      --st-closed-bg: #eeeef2;
  --pr-high: #e0590b;
  --pr-critical: #dc2626;

  --shadow-sm: 0 1px 2px rgba(20, 20, 40, 0.06);
  --shadow: 0 1px 2px rgba(20, 20, 40, 0.05), 0 6px 16px rgba(20, 20, 40, 0.07);
  --shadow-lg: 0 16px 48px rgba(20, 20, 40, 0.18), 0 2px 6px rgba(20, 20, 40, 0.06);
  --r-sm: 6px;
  --r: 10px;
  --r-lg: 14px;
  --sidebar-w: 236px;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d0d11;
  --sidebar: #111116;
  --panel: #1a1a20;
  --panel-2: #1f1f26;
  --hover: #24242d;
  --active: #26264a;
  --line: #2a2a33;
  --line-strong: #373742;
  --text: #ececf1;
  --text-2: #b6b6c2;
  --muted: #80808d;
  --accent: #7b7bf0;
  --accent-hover: #8c8cf4;
  --accent-soft: #25254b;
  --ring: rgba(123, 123, 240, 0.32);
  --success: #1fae55;
  --success-hover: #23bd5e;
  --bubble-in: #20202a;
  --bubble-out: #2b2b5a;
  --note: #2a2515;
  --note-line: #5a4a1b;
  --st-new: #7aa7ff;         --st-new-bg: #1b2a47;
  --st-in_progress: #f0b35f; --st-in_progress-bg: #3a2a14;
  --st-waiting: #b99bff;     --st-waiting-bg: #2c2147;
  --st-resolved: #6fd894;    --st-resolved-bg: #15321f;
  --st-closed: #a3a3ae;      --st-closed-bg: #2a2a31;
  --pr-high: #fb8c3c;
  --pr-critical: #f87171;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 6px 16px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.55), 0 2px 6px rgba(0, 0, 0, 0.3);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0d0d11;
    --sidebar: #111116;
    --panel: #1a1a20;
    --panel-2: #1f1f26;
    --hover: #24242d;
    --active: #26264a;
    --line: #2a2a33;
    --line-strong: #373742;
    --text: #ececf1;
    --text-2: #b6b6c2;
    --muted: #80808d;
    --accent: #7b7bf0;
    --accent-hover: #8c8cf4;
    --accent-soft: #25254b;
    --ring: rgba(123, 123, 240, 0.32);
    --success: #1fae55;
    --success-hover: #23bd5e;
    --bubble-in: #20202a;
    --bubble-out: #2b2b5a;
    --note: #2a2515;
    --note-line: #5a4a1b;
    --st-new: #7aa7ff;         --st-new-bg: #1b2a47;
    --st-in_progress: #f0b35f; --st-in_progress-bg: #3a2a14;
    --st-waiting: #b99bff;     --st-waiting-bg: #2c2147;
    --st-resolved: #6fd894;    --st-resolved-bg: #15321f;
    --st-closed: #a3a3ae;      --st-closed-bg: #2a2a31;
    --pr-high: #fb8c3c;
    --pr-critical: #f87171;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 6px 16px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.55), 0 2px 6px rgba(0, 0, 0, 0.3);
  }
}

/* ---------- основа ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; height: 100%; }
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 var(--font);
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { letter-spacing: -0.015em; }
button, input, select, textarea { font: inherit; color: inherit; }
code { font: 12.5px var(--mono); background: var(--panel-2); border: 1px solid var(--line); border-radius: 5px; padding: 0 5px; }
kbd {
  display: inline-block;
  min-width: 18px;
  padding: 0 5px;
  font: 600 11px/17px var(--mono);
  text-align: center;
  color: var(--text-2);
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: 5px;
}
.i { flex: none; display: block; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: 12.5px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
::selection { background: var(--accent-soft); }
[hidden] { display: none !important; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- кнопки и поля ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  font-weight: 550;
  font-size: 13px;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  transition: background 0.12s, border-color 0.12s, box-shadow 0.12s, transform 0.06s;
}
.btn:hover { background: var(--hover); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 1px 2px rgba(60, 60, 180, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.14);
}
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.success { background: var(--success); border-color: var(--success); color: #fff; box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.14); }
.btn.success:hover { background: var(--success-hover); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--hover); color: var(--text); }
.btn.danger-ghost { color: var(--danger); }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12.5px; border-radius: 7px; }
.btn.lg { height: 42px; font-size: 14.5px; border-radius: 10px; }
.btn.wide { width: 100%; }
.btn[disabled], .btn.htmx-request { opacity: 0.6; pointer-events: none; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex: none;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn.on { color: var(--accent); background: var(--accent-soft); }

.link { color: var(--accent); font-size: 13px; }
.link-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font-size: 12.5px;
  font-weight: 550;
  cursor: pointer;
}
.link-btn:hover { text-decoration: underline; }
.link-btn.danger { color: var(--danger); }

.input, .select {
  width: 100%;
  height: 36px;
  padding: 0 11px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  transition: border-color 0.12s, box-shadow 0.12s;
}
textarea.input { height: auto; padding: 8px 11px; line-height: 1.5; resize: vertical; }
.input:focus, .select:focus { outline: 0; border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
.select {
  appearance: none;
  padding-right: 30px;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23868694' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}
.field { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; font-weight: 550; color: var(--text-2); }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }
.ghost-input { border-color: transparent; background: transparent; padding: 0 8px; font-weight: 600; }
.ghost-input:hover { border-color: var(--line); }

/* ---------- значки ---------- */
.st {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 20px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}
.st i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.st-new { color: var(--st-new); background: var(--st-new-bg); }
.st-in_progress { color: var(--st-in_progress); background: var(--st-in_progress-bg); }
.st-waiting { color: var(--st-waiting); background: var(--st-waiting-bg); }
.st-resolved { color: var(--st-resolved); background: var(--st-resolved-bg); }
.st-closed { color: var(--st-closed); background: var(--st-closed-bg); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex: none; }
.dot.st-new, .dot.st-in_progress, .dot.st-waiting, .dot.st-resolved, .dot.st-closed { background: currentColor; }

.pr { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.pr-high { color: var(--pr-high); }
.pr-critical { color: var(--pr-critical); }
.pr-critical .i { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.35; } }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 20px;
  padding: 0 7px;
  border-radius: 6px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text-2);
  font-size: 11.5px;
  font-weight: 550;
  white-space: nowrap;
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chip.muted { color: var(--muted); }
.chip.removable { height: 26px; padding: 0 9px; border-radius: 999px; color: var(--text); text-decoration: none; }
.chip.removable:hover { border-color: var(--line-strong); }
.badge { font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); }
.badge.warn { background: #fde8e8; color: #b42318; }
.badge.ghost { background: var(--panel-2); color: var(--muted); border: 1px solid var(--line); }
:root[data-theme="dark"] .badge.warn { background: #3b1717; color: #fca5a5; }

.stars { display: inline-flex; gap: 1px; color: var(--line-strong); letter-spacing: 0; }
.stars .on { color: #f5a524; font-style: normal; }
.stars i { font-style: normal; }

/* ---------- аватары ---------- */
.av {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: hsl(var(--h) 70% 92%);
  color: hsl(var(--h) 45% 32%);
  font-weight: 650;
  font-size: 12.5px;
  letter-spacing: 0.02em;
  user-select: none;
}
.av-sm { width: 28px; height: 28px; font-size: 11px; }
.av-lg { width: 44px; height: 44px; font-size: 15px; }
:root[data-theme="dark"] .av { background: hsl(var(--h) 30% 24%); color: hsl(var(--h) 75% 82%); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .av { background: hsl(var(--h) 30% 24%); color: hsl(var(--h) 75% 82%); }
}

/* ---------- каркас приложения ---------- */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
}
/* clip, а не hidden: фокус на поле ввода не должен прокручивать каркас вбок */
.main { min-width: 0; min-height: 0; overflow: hidden; overflow: clip; position: relative; }
.main.page { overflow: hidden auto; }

/* боковое меню */
.sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 14px 10px 10px;
  background: var(--sidebar);
  border-right: 1px solid var(--line);
  overflow-y: auto;
  z-index: 40;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 12px;
  color: var(--text);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.02em;
}
.brand:hover { text-decoration: none; }
.logo {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  color: #fff;
  background: linear-gradient(135deg, #6366f1 0%, #3b82f6 55%, #22b4ee 100%);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}
.logo .i { transform: translate(-1px, 1px); }
.nav { display: flex; flex-direction: column; gap: 1px; }
.nav-label {
  padding: 14px 10px 6px;
  font-size: 11px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 34px;
  padding: 0 10px;
  border-radius: 8px;
  color: var(--text-2);
  font-weight: 550;
  font-size: 13.5px;
  transition: background 0.1s, color 0.1s;
}
.nav-item:hover { background: var(--hover); color: var(--text); text-decoration: none; }
.nav-item .i { color: var(--muted); }
.nav-item.active {
  background: var(--panel);
  color: var(--text);
  box-shadow: var(--shadow-sm), inset 0 0 0 1px var(--line);
}
.nav-item.active .i { color: var(--accent); }
.nav-count {
  margin-left: auto;
  font-size: 12px;
  font-weight: 650;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.nav-count.hot {
  min-width: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  line-height: 20px;
  text-align: center;
}
.sidebar-foot { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--line); }
.me { display: flex; align-items: center; gap: 10px; padding: 4px 6px; }
.me-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.me-text b { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-text small { font-size: 11.5px; color: var(--muted); }
.foot-actions { display: flex; gap: 2px; padding: 6px 2px 0; }
.foot-actions form { margin: 0; }
.build { padding: 6px 8px 0; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.when-dark, .notify-on { display: none; }
:root[data-theme="dark"] .when-dark { display: block; }
:root[data-theme="dark"] .when-light { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .when-dark { display: block; }
  :root:not([data-theme="light"]) .when-light { display: none; }
}
html.notify .notify-on { display: block; }
html.notify .notify-off { display: none; }
html.notify [data-notify-toggle] { color: var(--accent); }
.menu-btn { display: none; margin-left: -6px; }
.scrim { display: none; }

/* ---------- список заявок ---------- */
.main.inbox { display: grid; grid-template-columns: minmax(300px, 372px) minmax(0, 1fr); }
.list-pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--panel);
  border-right: 1px solid var(--line);
}
.list-head { padding: 14px 14px 10px; border-bottom: 1px solid var(--line); }
.list-title { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.list-title h1 { margin: 0; font-size: 17px; font-weight: 700; }
.list-total {
  padding: 0 8px;
  border-radius: 999px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  line-height: 20px;
  font-variant-numeric: tabular-nums;
}
.list-tools { display: flex; gap: 6px; }
.search {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 34px;
  padding: 0 8px 0 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--panel-2);
  color: var(--muted);
  transition: border-color 0.12s, box-shadow 0.12s, background 0.12s;
}
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); background: var(--panel); }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--text); }
.search input::-webkit-search-cancel-button { cursor: pointer; }
.filter-btn { border: 1px solid var(--line); }
.filter-panel { width: 250px; display: flex; flex-direction: column; gap: 12px; padding: 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.list-scroll { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }

.row {
  position: relative;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 11px;
  padding: 12px 14px 12px 14px;
  border-bottom: 1px solid var(--line);
  color: inherit;
  transition: background 0.1s;
}
.row:hover { background: var(--hover); text-decoration: none; }
.row.active { background: var(--active); }
.row.active::before { content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }
.row-main { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.row-top { display: flex; align-items: baseline; gap: 8px; }
.row-name { flex: 1; min-width: 0; font-weight: 550; font-size: 13px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-time { font-size: 11.5px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.row-subject { font-size: 13.5px; font-weight: 550; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-num { color: var(--muted); font-weight: 500; margin-right: 6px; font-variant-numeric: tabular-nums; }
.row-snippet { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-snippet b { color: var(--text-2); font-weight: 550; }
.row-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-top: 5px; }
.row.unread .row-name { color: var(--text); font-weight: 650; }
.row.unread .row-subject { font-weight: 700; }
.row.unread .row-snippet { color: var(--text-2); }
.unread-dot {
  position: absolute;
  right: 14px;
  top: 38px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.row.unread .row-subject { padding-right: 18px; }
.list-empty { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 48px 20px; text-align: center; color: var(--muted); }
.list-empty p { margin: 8px 0 0; font-weight: 600; color: var(--text-2); }
.empty-ic { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 14px; background: var(--panel-2); border: 1px solid var(--line); }
.row.flash { animation: row-in 1.2s ease-out; }
@keyframes row-in { from { background: var(--accent-soft); } }

/* ---------- заявка ---------- */
.detail-pane { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; overflow: hidden; overflow: clip; background: var(--bg); }
.empty-detail { margin: auto; max-width: 380px; padding: 40px 24px; text-align: center; color: var(--text-2); }
.empty-detail h2 { margin: 0 0 6px; font-size: 18px; color: var(--text); }
.empty-detail p { margin: 0 0 18px; line-height: 1.55; }
.empty-art {
  display: grid;
  place-items: center;
  width: 68px;
  height: 68px;
  margin: 0 auto 18px;
  border-radius: 20px;
  color: var(--accent);
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 18%, transparent);
}
.empty-keys { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; font-size: 12.5px; color: var(--muted); }
.empty-keys kbd { margin-right: 3px; }

.ticket { position: relative; display: flex; flex-direction: column; height: 100%; min-height: 0; }
.ticket-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.back-btn { display: none; margin-left: -8px; }
.th-main { flex: 1; min-width: 0; }
.th-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; min-height: 20px; }
.th-num { font-size: 12.5px; font-weight: 650; color: var(--muted); font-variant-numeric: tabular-nums; }
.th-link { font-size: 12px; color: var(--muted); }
.th-subject { margin: 2px 0 0; }
.th-subject input {
  width: 100%;
  margin-left: -7px;
  padding: 2px 6px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.3;
  text-overflow: ellipsis;
}
.th-subject input:hover { border-color: var(--line); }
.th-subject input:focus { outline: 0; border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); background: var(--panel); }
.th-actions { display: flex; align-items: center; gap: 8px; }
.props-btn { display: none; }

.ticket-body { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 296px; }
.conv-col { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.conv-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 18px 24px 8px; overscroll-behavior: contain; scroll-behavior: smooth; }

/* переписка */
.conv { display: flex; flex-direction: column; max-width: 880px; margin: 0 auto; padding-bottom: 6px; }
.conv-start {
  display: flex;
  align-items: center;
  gap: 10px;
  align-self: center;
  margin: 4px 0 6px;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--text-2);
  font-size: 12.5px;
}
.conv-start-ic { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; color: #fff; background: linear-gradient(135deg, #6366f1, #22b4ee); }
.day { display: flex; justify-content: center; margin: 18px 0 8px; }
.day span { padding: 2px 10px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); color: var(--muted); font-size: 11.5px; font-weight: 650; }
.evt { display: flex; justify-content: center; align-items: baseline; gap: 6px; margin: 7px 0; color: var(--muted); font-size: 12px; text-align: center; }
.evt time { font-size: 11px; opacity: 0.8; }

.msg { display: flex; align-items: flex-start; gap: 10px; max-width: min(78%, 640px); margin-top: 12px; animation: msg-in 0.18s ease-out; }
.msg.cont { margin-top: 3px; }
.msg-user { align-self: flex-start; }
.msg-operator, .msg-note { align-self: flex-end; flex-direction: row-reverse; }
.av-space { width: 28px; flex: none; }
.msg-body { min-width: 0; display: flex; flex-direction: column; }
.msg-operator .msg-body, .msg-note .msg-body { align-items: flex-end; }
.msg-head { display: flex; align-items: center; gap: 6px; margin: 0 6px 3px; font-size: 12px; color: var(--text-2); }
.msg-head b { font-weight: 650; }
.note-tag { display: inline-flex; align-items: center; gap: 3px; padding: 0 6px; border-radius: 5px; background: #fde68a; color: #854d0e; font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; }
:root[data-theme="dark"] .note-tag { background: #5a4a1b; color: #fde68a; }
.bubble {
  position: relative;
  max-width: 100%;
  padding: 8px 12px 5px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--bubble-in);
  box-shadow: var(--shadow-sm);
}
.msg-user:not(.cont) .bubble { border-top-left-radius: 5px; }
.msg-operator .bubble { background: var(--bubble-out); border-color: transparent; }
.msg-operator:not(.cont) .bubble { border-top-right-radius: 5px; }
.msg-note .bubble { background: var(--note); border-color: var(--note-line); border-style: dashed; }
.msg-note:not(.cont) .bubble { border-top-right-radius: 5px; }
.txt { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.5; }
.txt a { text-decoration: underline; text-underline-offset: 2px; }
.msg-time { display: block; margin-top: 1px; text-align: right; font-size: 10.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.atts { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 2px; }
.thumb { display: block; border-radius: 11px; overflow: hidden; border: 1px solid var(--line); background: var(--panel-2); }
.thumb img { display: block; max-width: min(280px, 100%); max-height: 220px; object-fit: cover; transition: transform 0.2s; }
.thumb:hover img { transform: scale(1.02); }
.file {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 200px;
  max-width: 320px;
  padding: 8px 10px;
  border-radius: 11px;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--text);
}
.file:hover { border-color: var(--line-strong); text-decoration: none; }
.file-ic { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; background: var(--accent-soft); color: var(--accent); flex: none; }
.file-text { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.3; }
.file-text b { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-text small { color: var(--muted); font-size: 11.5px; }
.file > .i { color: var(--muted); }
@keyframes msg-in { from { opacity: 0; transform: translateY(4px); } }

/* поле ответа */
.composer {
  margin: 0 16px 16px;
  padding: 8px 10px 10px;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--panel);
  box-shadow: var(--shadow);
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
.composer:focus-within { border-color: var(--accent); box-shadow: var(--shadow), 0 0 0 3px var(--ring); }
.composer.note { background: var(--note); border-color: var(--note-line); }
.composer.note:focus-within { box-shadow: var(--shadow), 0 0 0 3px rgba(240, 190, 60, 0.3); }
.cmp-top { display: flex; align-items: center; gap: 10px; }
.cmp-tabs { display: inline-flex; padding: 2px; border-radius: 9px; background: var(--panel-2); border: 1px solid var(--line); }
.composer.note .cmp-tabs { background: rgba(255, 255, 255, 0.5); }
:root[data-theme="dark"] .composer.note .cmp-tabs { background: rgba(0, 0, 0, 0.2); }
.cmp-tab {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 26px;
  padding: 0 10px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}
.cmp-tab.on { background: var(--panel); color: var(--text); box-shadow: var(--shadow-sm); }
.cmp-tab[disabled] { opacity: 0.4; cursor: not-allowed; }
.cmp-hint { flex: 1; min-width: 0; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.composer textarea {
  display: block;
  width: 100%;
  min-height: 46px;
  max-height: 40vh;
  margin: 4px 0;
  padding: 8px 4px;
  border: 0;
  outline: 0;
  resize: none;
  background: transparent;
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}
.composer textarea::placeholder { color: var(--muted); }
.cmp-files { display: flex; flex-wrap: wrap; gap: 6px; }
.cmp-files:not(:empty) { margin: 0 0 8px; }
.file-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 4px 0 10px;
  border-radius: 8px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  font-size: 12.5px;
  max-width: 260px;
}
.file-chip span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-chip button { width: 22px; height: 22px; border: 0; border-radius: 6px; background: none; color: var(--muted); cursor: pointer; display: grid; place-items: center; }
.file-chip button:hover { background: var(--hover); color: var(--text); }
.cmp-bar { display: flex; align-items: center; gap: 8px; }
.cmp-kbd { font-size: 11.5px; color: var(--muted); }
.send-group { display: flex; margin-left: auto; }
.send-group > .btn { border-radius: 8px 0 0 8px; }
.send-group .split { height: 32px; padding: 0 8px; border-radius: 0 8px 8px 0; border-left: 1px solid rgba(255, 255, 255, 0.28); }
.composer.note .send-group .dropdown { display: none; }
.composer.note .send-group > .btn { border-radius: 8px; background: #b7791f; border-color: #b7791f; }
.composer.note .send-group > .btn:hover { background: #a36a17; }

/* свойства заявки */
.props {
  min-height: 0;
  overflow-y: auto;
  padding: 2px 18px 24px;
  background: var(--panel);
  border-left: 1px solid var(--line);
}
.p-sec { padding: 16px 0; border-bottom: 1px solid var(--line); }
.p-sec:last-child { border-bottom: 0; }
.p-sec h4 { margin: 0 0 9px; font-size: 11px; font-weight: 650; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); }
.seg {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 2px;
  padding: 2px;
  border-radius: 9px;
  background: var(--panel-2);
  border: 1px solid var(--line);
}
.seg-btn {
  height: 28px;
  padding: 0 4px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text-2);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.seg-btn:hover { color: var(--text); background: var(--hover); }
.seg-btn.on { background: var(--panel); color: var(--text); box-shadow: var(--shadow-sm); }
.seg-btn.pr-high.on { color: var(--pr-high); }
.seg-btn.pr-critical.on { background: var(--pr-critical); color: #fff; }
.person { display: flex; align-items: center; gap: 12px; }
.person-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.35; }
.person-text b { font-size: 14px; }
.person-text a, .person-text small { font-size: 12.5px; }
.person-text small { color: var(--muted); }
.warn-box { display: flex; align-items: center; gap: 6px; margin-top: 10px; padding: 7px 10px; border-radius: 8px; background: #fdecec; color: #b42318; font-size: 12.5px; font-weight: 550; }
:root[data-theme="dark"] .warn-box { background: #3b1717; color: #fca5a5; }
.kv { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 7px 12px; margin: 12px 0 0; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; font-weight: 550; font-variant-numeric: tabular-nums; }
.hist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.hist a {
  display: grid;
  grid-template-columns: 8px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  padding: 6px 8px;
  margin: 0 -8px;
  border-radius: 8px;
  color: var(--text);
  font-size: 12.5px;
}
.hist a:hover { background: var(--hover); text-decoration: none; }
.hist-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hist time { color: var(--muted); font-size: 11.5px; }
.poller { display: none; }

/* ---------- выпадающие меню ---------- */
.dropdown { position: relative; }
.dropdown > summary { list-style: none; cursor: pointer; }
.dropdown > summary::-webkit-details-marker { display: none; }
.dd-panel {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 60;
  min-width: 220px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: var(--shadow-lg);
  animation: pop 0.12s ease-out;
}
.dd-right { left: auto; right: 0; }
.dd-up { top: auto; bottom: calc(100% + 6px); }
@keyframes pop { from { opacity: 0; transform: translateY(-4px) scale(0.98); } }
.dd-up { animation-name: pop-up; }
@keyframes pop-up { from { opacity: 0; transform: translateY(4px) scale(0.98); } }
.dd-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--text);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  white-space: nowrap;
}
.dd-item:hover, .dd-item:focus-visible { background: var(--hover); outline: 0; }
.dd-item .st { pointer-events: none; }
.tpl-list { width: 340px; max-height: 320px; overflow-y: auto; }
.tpl { flex-direction: column; align-items: flex-start; gap: 2px; white-space: normal; }
.tpl b { font-size: 13px; }
.tpl small { font-size: 12px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.dd-form { display: flex; flex-direction: column; gap: 10px; padding: 8px; width: 260px; }

/* ---------- всплывающие уведомления, окна ---------- */
.toasts {
  position: fixed;
  left: 50%;
  bottom: 22px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  transform: translateX(-50%);
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: min(460px, calc(100vw - 32px));
  padding: 10px 14px 10px 12px;
  border-radius: 12px;
  background: #1c1c26;
  color: #fff;
  font-size: 13.5px;
  font-weight: 550;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.25);
  pointer-events: auto;
  animation: toast-in 0.22s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
.toast .i { color: #86efac; }
.toast.error { background: #b42318; }
.toast.error .i { color: #fff; }
.toast.out { animation: toast-out 0.2s ease-in forwards; }
:root[data-theme="dark"] .toast:not(.error) { background: #2c2c3a; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px) scale(0.96); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(6px); } }

.modal {
  width: min(420px, calc(100vw - 32px));
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
  color: var(--text);
  box-shadow: var(--shadow-lg);
}
.modal::backdrop { background: rgba(10, 10, 20, 0.45); backdrop-filter: blur(2px); }
.modal h3 { margin: 0 0 14px; font-size: 16px; }
.keys { display: grid; grid-template-columns: auto 1fr; gap: 10px 16px; margin: 0 0 18px; font-size: 13.5px; align-items: center; }
.keys dt { white-space: nowrap; }
.keys dd { margin: 0; color: var(--text-2); }
.modal form { display: flex; justify-content: flex-end; }

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: grid;
  place-items: center;
  padding: 32px;
  background: rgba(8, 8, 14, 0.82);
  backdrop-filter: blur(4px);
  animation: fade 0.15s ease-out;
  cursor: zoom-out;
}
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 10px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5); }
.lightbox .icon-btn { position: absolute; top: 16px; right: 16px; color: #fff; background: rgba(255, 255, 255, 0.12); }
@keyframes fade { from { opacity: 0; } }

/* индикатор загрузки htmx */
.htmx-request .row, .detail-pane.htmx-request .ticket { transition: opacity 0.2s 0.15s; }
.detail-pane.htmx-request > * { opacity: 0.55; }

/* ---------- вход ---------- */
body.auth { background: var(--panel); }
.auth-wrap { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); min-height: 100vh; min-height: 100dvh; }
.auth-art {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 36px 44px;
  overflow: hidden;
  color: #fff;
  background:
    radial-gradient(900px 500px at 0% 0%, rgba(167, 139, 250, 0.55) 0%, transparent 60%),
    radial-gradient(700px 500px at 100% 100%, rgba(34, 211, 238, 0.45) 0%, transparent 60%),
    linear-gradient(140deg, #4338ca 0%, #3b5bdb 45%, #1d7fd8 100%);
}
.auth-art::before, .auth-art::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.14);
}
.auth-art::before { width: 520px; height: 520px; right: -180px; top: -160px; }
.auth-art::after { width: 340px; height: 340px; left: -120px; bottom: -120px; }
.art-brand { position: relative; display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; }
.art-brand .logo { background: rgba(255, 255, 255, 0.18); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.3); }
.art-chat { position: relative; display: flex; flex-direction: column; gap: 10px; width: min(400px, 100%); margin: 40px auto; }
.demo {
  max-width: 86%;
  padding: 9px 14px 10px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.45;
  box-shadow: 0 10px 30px rgba(10, 10, 40, 0.22);
  animation: float-in 0.6s cubic-bezier(0.2, 0.9, 0.3, 1.1) both;
}
.demo-name { display: block; font-size: 11.5px; font-weight: 650; opacity: 0.7; margin-bottom: 2px; }
.demo.in { align-self: flex-start; background: #fff; color: #15151c; border-bottom-left-radius: 5px; }
.demo.out { align-self: flex-end; background: #1e1b4b; color: #fff; border-bottom-right-radius: 5px; }
.demo.sys { align-self: center; padding: 5px 12px; background: rgba(255, 255, 255, 0.16); font-size: 12.5px; box-shadow: none; backdrop-filter: blur(6px); }
.demo-react { display: inline-block; margin-left: 4px; padding: 0 6px; border-radius: 999px; background: #ececfd; font-size: 12px; }
.demo:nth-child(2) { animation-delay: 0.35s; }
.demo:nth-child(3) { animation-delay: 0.7s; }
.demo:nth-child(4) { animation-delay: 1.05s; }
@keyframes float-in { from { opacity: 0; transform: translateY(12px) scale(0.97); } }
.art-tag { position: relative; margin: 0; font-size: 18px; font-weight: 600; line-height: 1.4; letter-spacing: -0.01em; opacity: 0.95; }
.auth-side { display: grid; place-items: center; padding: 32px 20px; background: var(--panel); }
.auth-form { display: flex; flex-direction: column; gap: 14px; width: 100%; max-width: 360px; }
.auth-form h1 { margin: 6px 0 0; font-size: 26px; font-weight: 750; letter-spacing: -0.03em; }
.auth-form > .muted { margin: -8px 0 6px; }
.auth-logo { display: none; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; }
.alert { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 10px; font-size: 13.5px; font-weight: 550; }
.alert.error { background: #fdecec; color: #b42318; }
:root[data-theme="dark"] .alert.error { background: #3b1717; color: #fca5a5; }
.error-wrap { display: grid; place-items: center; min-height: 100vh; padding: 20px; }
.error-card { text-align: center; }
.err-code { font-size: 72px; font-weight: 800; letter-spacing: -0.05em; background: linear-gradient(135deg, #6366f1, #22b4ee); -webkit-background-clip: text; background-clip: text; color: transparent; }
.error-card p { margin: 0 0 20px; color: var(--text-2); }

/* ---------- страницы: сводка, настройки ---------- */
.page-wrap { max-width: 1180px; margin: 0 auto; padding: 26px 28px 56px; }
.page-wrap.narrow { max-width: 820px; }
.page-head { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 20px; }
.page-head h1 { margin: 0 0 4px; font-size: 24px; font-weight: 750; letter-spacing: -0.03em; }
.page-head p { margin: 0; max-width: 640px; line-height: 1.55; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-sm); }
.card h2 { display: flex; align-items: center; gap: 8px; margin: 0 0 14px; font-size: 15px; font-weight: 700; }
.list-card { overflow: hidden; margin-bottom: 18px; }
.form-card { padding: 18px 20px 20px; }
.grid-form { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; align-items: end; }
.grid-form .check, .grid-form .btn { grid-column: span 1; }
.row-form { display: flex; gap: 10px; }
.stack-form { display: flex; flex-direction: column; gap: 12px; align-items: flex-start; }
.stack-form .field { width: 100%; }
.op-row { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.op-row:last-child { border-bottom: 0; }
.op-row.off { opacity: 0.6; }
.op-main { flex: 1; min-width: 0; }
.op-main .ghost-input { height: 30px; margin-left: -8px; font-size: 14px; max-width: 320px; }
.op-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-top: 2px; }
.op-actions { display: flex; align-items: center; gap: 6px; }
.op-actions form { display: flex; gap: 6px; margin: 0; }
.inline-edit { margin: 0; }
.cat-row { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line); margin: 0; }
.cat-row:last-child { border-bottom: 0; }
.cat-row.off .ghost-input { color: var(--muted); text-decoration: line-through; }
.cat-row .ghost-input { flex: 1; height: 32px; }
.drag { color: var(--muted); }
.order { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); }
.order .input { width: 72px; height: 30px; padding: 0 8px; }
.switch { position: relative; display: inline-block; width: 36px; height: 20px; flex: none; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch i { position: absolute; inset: 0; border-radius: 999px; background: var(--line-strong); transition: background 0.15s; pointer-events: none; }
.switch i::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25); transition: transform 0.15s; }
.switch input:checked + i { background: var(--success); }
.switch input:checked + i::after { transform: translateX(16px); }
.switch input:focus-visible + i { outline: 2px solid var(--accent); outline-offset: 2px; }
.reply-list { display: flex; flex-direction: column; gap: 12px; margin-bottom: 18px; }
.reply-card { padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; margin: 0; }
.reply-top { display: flex; align-items: center; gap: 10px; }
.title-input { flex: 1; height: 32px; font-size: 14px; margin-left: -8px; }
.reply-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* сводка */
.kpis { display: grid; gap: 12px; margin-bottom: 12px; }
.kpis.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.kpis.three { grid-template-columns: repeat(3, minmax(0, 1fr)); margin-bottom: 16px; }
.kpi {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 16px 13px;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--panel);
  box-shadow: var(--shadow-sm);
  color: inherit;
  transition: border-color 0.12s, box-shadow 0.12s, transform 0.12s;
}
a.kpi:hover { border-color: var(--line-strong); box-shadow: var(--shadow); text-decoration: none; transform: translateY(-1px); }
.kpi-label { font-size: 12.5px; font-weight: 550; color: var(--text-2); }
.kpi-value { font-size: 26px; font-weight: 750; letter-spacing: -0.03em; line-height: 1.15; }
.kpi-value small { font-size: 14px; font-weight: 600; color: var(--muted); }
.kpi-sub { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); }
.dash-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
.span-2 { grid-column: span 2; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; gap: 10px; padding: 16px 18px 4px; }
.card-head h2 { margin: 0; }
.card-head .muted { font-size: 12.5px; }
.legend { display: flex; gap: 16px; font-size: 12.5px; color: var(--text-2); }
.lg-item { display: inline-flex; align-items: center; gap: 6px; }
.lg-item b { color: var(--text); font-weight: 700; }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; }
.empty-note { padding: 8px 18px 20px; margin: 0; }

/* цвета графиков: слоты 1–2 эталонной палитры (проверены валидатором на этих фонах) */
.viz { --series-1: #2a78d6; --series-2: #eb6834; --grid: #ececf0; --baseline: #d4d4dd; }
:root[data-theme="dark"] .viz { --series-1: #3987e5; --series-2: #d95926; --grid: #2a2a33; --baseline: #3a3a45; }
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) .viz { --series-1: #3987e5; --series-2: #d95926; --grid: #2a2a33; --baseline: #3a3a45; }
}
.sw.s1, .bar.s1, .tt-key.s1 { background: var(--series-1); }
.sw.s2, .bar.s2, .tt-key.s2 { background: var(--series-2); }

.colchart { position: relative; height: 236px; margin: 14px 18px 4px 18px; }
.gridlines { position: absolute; inset: 0 0 26px 30px; display: flex; flex-direction: column; justify-content: space-between; }
.gl { position: relative; height: 0; border-top: 1px solid var(--grid); }
.gl:last-child { border-top-color: var(--baseline); }
.gl span { position: absolute; right: calc(100% + 8px); top: -8px; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.cols { position: absolute; inset: 0 0 0 30px; display: flex; }
.col { flex: 1; display: flex; flex-direction: column; align-items: stretch; min-width: 0; border-radius: 8px; cursor: default; }
.col:hover, .col:focus-visible { background: var(--panel-2); outline: 0; }
.col .bars { flex: 1; display: flex; align-items: flex-end; justify-content: center; gap: 2px; min-height: 0; }
.bar { position: relative; display: block; width: min(12px, 36%); height: calc(var(--v) / var(--max) * 100%); border-radius: 4px 4px 0 0; transition: filter 0.12s; }
.col:hover .bar, .col:focus-visible .bar { filter: brightness(1.12) saturate(1.05); }
.bar em { position: absolute; left: 50%; bottom: calc(100% + 3px); transform: translateX(-50%); font-style: normal; font-size: 11px; font-weight: 650; color: var(--text-2); }
.xl { height: 26px; line-height: 26px; text-align: center; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.col.today .xl { color: var(--text); font-weight: 700; }
.table-view { margin: 4px 18px 14px; font-size: 12.5px; }
.table-view summary { display: inline-block; cursor: pointer; color: var(--muted); font-weight: 550; }
.table-view summary:hover { color: var(--text); }
.table-view table, table.team { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.table-view table { margin-top: 8px; max-height: 240px; }
.table-view th, .table-view td, .team th, .team td { padding: 7px 10px; border-bottom: 1px solid var(--line); text-align: right; }
.table-view th:first-child, .table-view td:first-child, .team th:first-child, .team td:first-child { text-align: left; }
.table-view th, .team th { font-size: 11px; font-weight: 650; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.team { margin: 8px 0 6px; font-size: 13px; }
.team td { padding: 9px 18px; }
.team th { padding: 8px 18px; }
.team tr:last-child td { border-bottom: 0; }
.team-name { display: inline-flex; align-items: center; gap: 10px; font-weight: 550; }
.hbars { list-style: none; display: flex; flex-direction: column; gap: 8px; margin: 12px 18px 18px; padding: 0; }
.hbars li { display: grid; grid-template-columns: minmax(96px, 40%) minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 3px 6px; margin: 0 -6px; border-radius: 7px; font-size: 13px; }
.hbars li:hover, .hbars li:focus-visible { background: var(--panel-2); outline: 0; }
.hb-label { color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hb-track { display: block; }
.hb-bar { display: block; height: 10px; min-width: 3px; border-radius: 0 4px 4px 0; background: var(--series-1); }
.hb-val { min-width: 2ch; text-align: right; font-weight: 650; font-variant-numeric: tabular-nums; }
.viz-tip {
  position: fixed;
  z-index: 150;
  min-width: 150px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  box-shadow: var(--shadow-lg);
  font-size: 12.5px;
  pointer-events: none;
}
.tt-title { margin-bottom: 5px; font-size: 11.5px; color: var(--muted); font-weight: 600; }
.tt-row { display: flex; align-items: center; gap: 8px; line-height: 1.7; }
.tt-key { width: 12px; height: 2px; border-radius: 2px; }
.tt-val { font-weight: 750; font-variant-numeric: tabular-nums; }
.tt-name { color: var(--text-2); }

/* ---------- адаптивность ---------- */
@media (max-width: 1360px) {
  .ticket-body { grid-template-columns: minmax(0, 1fr); }
  .props-btn { display: inline-grid; }
  .props {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 30;
    width: min(320px, 92%);
    border-left: 1px solid var(--line);
    box-shadow: var(--shadow-lg);
    transform: translateX(105%);
    transition: transform 0.2s ease;
  }
  .ticket-body { position: relative; overflow: hidden; overflow: clip; }
  .ticket.show-props .props { transform: none; }
  .ticket.show-props .props-btn { color: var(--accent); background: var(--accent-soft); }
}
@media (max-width: 1024px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: var(--sidebar-w);
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    box-shadow: var(--shadow-lg);
  }
  .app.nav-open .sidebar { transform: none; }
  .app.nav-open .scrim { display: block; position: fixed; inset: 0; z-index: 35; background: rgba(10, 10, 20, 0.35); }
  .menu-btn { display: inline-grid; }
  .main.inbox { grid-template-columns: minmax(280px, 340px) minmax(0, 1fr); }
  .grid-form { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 760px) {
  .main.inbox { grid-template-columns: minmax(0, 1fr); }
  .main.inbox.has-ticket .list-pane { display: none; }
  .main.inbox:not(.has-ticket) .detail-pane { display: none; }
  .back-btn { display: inline-grid; }
  .ticket-head { padding: 10px 12px; gap: 8px; flex-wrap: wrap; }
  .th-main { flex-basis: calc(100% - 40px); }
  .th-actions { width: 100%; justify-content: flex-end; }
  .th-subject input { font-size: 16px; }
  .conv-scroll { padding: 12px 12px 6px; }
  .msg { max-width: 92%; }
  .composer { margin: 0 8px 8px; }
  .cmp-kbd, .cmp-hint { display: none; }
  .tpl-list { width: min(320px, calc(100vw - 32px)); }
  .page-wrap { padding: 18px 14px 40px; }
  .dash-grid { grid-template-columns: minmax(0, 1fr); }
  .span-2 { grid-column: auto; }
  .kpis.four, .kpis.three { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .auth-wrap { grid-template-columns: minmax(0, 1fr); }
  .auth-art { display: none; }
  .auth-logo { display: flex; }
  .op-row { flex-wrap: wrap; }
  .op-actions { width: 100%; justify-content: flex-end; flex-wrap: wrap; }
  .cat-row { flex-wrap: wrap; }
  .cat-row .ghost-input { flex-basis: 100%; }
  .row-form { flex-direction: column; }
  .toasts { bottom: 12px; }
}
