/* ARS-X 3.3 — единый дизайн админки (admin.ars-x.ru) и службы поддержки (help.ars-x.ru): те же шрифт, цвета и темы, что в программе.
   Тема и цветовая схема общие с программой (sfera_theme, arsx_color_scheme). */
:root {
  --paper: #f2f5f8; --surface: #ffffff; --ink: #151b24; --muted: #667085; --line: #e2e7ee; --soft: #f1f4f8;
  --brand: #1267e5; --brand-dark: #0d4da8; --button-primary: #0a3f91; --nav-hover: #eaf2ff;
  --signal: var(--brand); --signal-ink: #ffffff; --ok: #17855a; --warn: #a86a12; --bad: #c03a32;
  --rail: 256px; --radius: 12px; --font: Inter, "Golos Text", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
  color-scheme: light;
}
:root[data-theme="dark"] { --paper: #0e141b; --surface: #161d27; --ink: #e8edf3; --muted: #9aa5b4; --line: #26303d; --soft: #1d2631;
  --brand: #6da8ff; --brand-dark: #4b8de9; --button-primary: #4b8de9; --nav-hover: #233246;
  --signal-ink: #0d1424; --ok: #4cc28d; --warn: #e0a64a; --bad: #f0776f; --shadow: none; color-scheme: dark; }
html[data-color-scheme="ocean"] { --brand:#1267e5; --brand-dark:#0d4da8; --button-primary:#0a3f91; --nav-hover:#eaf2ff; }
html[data-theme="dark"][data-color-scheme="ocean"] { --brand:#6da8ff; --brand-dark:#4b8de9; --button-primary:#4b8de9; --nav-hover:#233246; }
html[data-color-scheme="violet"] { --brand:#7c3aed; --brand-dark:#5b21b6; --button-primary:#5b21b6; --nav-hover:#f1eafe; }
html[data-theme="dark"][data-color-scheme="violet"] { --brand:#c4b5fd; --brand-dark:#a78bfa; --button-primary:#7c3aed; --nav-hover:#2c2041; }
html[data-color-scheme="emerald"] { --brand:#0ca678; --brand-dark:#087f5b; --button-primary:#087f5b; --nav-hover:#e6f6ef; }
html[data-theme="dark"][data-color-scheme="emerald"] { --brand:#7ddfc0; --brand-dark:#32b886; --button-primary:#168764; --nav-hover:#18372e; }
html[data-color-scheme="olive"] { --brand:#7a8f45; --brand-dark:#596b2d; --button-primary:#596b2d; --nav-hover:#eff2e6; }
html[data-theme="dark"][data-color-scheme="olive"] { --brand:#c1d48a; --brand-dark:#8fae57; --button-primary:#718c42; --nav-hover:#2a3120; }
html[data-color-scheme="amber"] { --brand:#c47a11; --brand-dark:#9a5b00; --button-primary:#9a5b00; --nav-hover:#fff2df; }
html[data-theme="dark"][data-color-scheme="amber"] { --brand:#f1c078; --brand-dark:#d7953c; --button-primary:#ad6f1c; --nav-hover:#3a2c1a; }
html[data-color-scheme="ruby"] { --brand:#c43d5a; --brand-dark:#962d46; --button-primary:#962d46; --nav-hover:#fae9ed; }
html[data-theme="dark"][data-color-scheme="ruby"] { --brand:#f09aaf; --brand-dark:#d55c75; --button-primary:#ad4058; --nav-hover:#3b2028; }
html[data-color-scheme="teal"] { --brand:#11877f; --brand-dark:#0f6b66; --button-primary:#0f6b66; --nav-hover:#e4f4f2; }
html[data-theme="dark"][data-color-scheme="teal"] { --brand:#82d8d0; --brand-dark:#3faaa1; --button-primary:#267f78; --nav-hover:#183633; }
html[data-color-scheme="original"] { --paper:#F5F6F8; --soft:#F5F6F8; --brand:#7C4DFF; --brand-dark:#5F35E8; --button-primary:#7C4DFF; --nav-hover:#F1EDFF; }
html[data-theme="dark"][data-color-scheme="original"] { --paper:#151519; --surface:#202026; --soft:#28282F; --line:#34343B; --brand:#7C4DFF; --brand-dark:#A58AFF; --button-primary:#7C4DFF; --nav-hover:#2C2540; }

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--paper); color: var(--ink); font: 15px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--signal); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--signal); outline-offset: 2px; }
[hidden] { display: none !important; }

/* каркас */
.shell { display: grid; grid-template-columns: var(--rail) 1fr; min-height: 100vh; }
.rail { position: sticky; top: 0; height: 100vh; background: var(--surface); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-width: 0; }
.rail-head { display: flex; align-items: center; gap: 10px; padding: 16px 16px 12px; }
.rail-head img { height: 26px; }
.rail-head .what { font-weight: 600; font-size: 14px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rail nav { flex: 1; overflow-y: auto; padding: 4px 8px 16px; }
.rail nav a { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 10px; color: var(--ink); text-decoration: none;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rail nav a:hover { background: var(--soft); }
.rail nav a[aria-current="page"]:hover { background: var(--nav-hover); }
.rail nav a[aria-current="page"] { background: var(--nav-hover); color: var(--brand-dark); font-weight: 600; }
html[data-theme="dark"] .rail nav a[aria-current="page"] { color: var(--brand); }
.rail nav .count { margin-left: auto; font-size: 12px; font-variant-numeric: tabular-nums; opacity: .8; }
.rail nav .group { margin: 16px 10px 4px; font-size: 11.5px; letter-spacing: .06em; text-transform: uppercase; font-weight: 600; color: var(--muted); }
.rail-foot { border-top: 1px solid var(--line); padding: 12px 16px; font-size: 13px; color: var(--muted); }
.rail-foot button { background: none; border: 0; padding: 0; color: var(--signal); cursor: pointer; }
.grip { position: absolute; top: 0; right: -4px; width: 8px; height: 100%; cursor: col-resize; z-index: 5; }
.grip::after { content: ""; position: absolute; top: 0; bottom: 0; left: 3px; width: 2px; background: transparent; transition: background .15s; }
.grip:hover::after, .grip.dragging::after { background: var(--signal); }
body.resizing { cursor: col-resize; user-select: none; }

.main { min-width: 0; padding: 20px 28px 48px; }
.topbar { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.topbar h1 { font-size: 22px; line-height: 1.25; margin: 0; font-weight: 650; }
.topbar .spacer { flex: 1; }
.burger { display: none; background: none; border: 1px solid var(--line); border-radius: 6px; width: 40px; height: 40px; cursor: pointer; }

/* телефон: меню выезжает поверх */
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .rail { position: fixed; left: 0; top: 0; z-index: 30; width: min(86vw, 320px); transform: translateX(-102%); transition: transform .2s ease; box-shadow: 0 0 0 100vmax transparent; }
  body.menu-open .rail { transform: none; box-shadow: 0 0 0 100vmax rgba(10, 14, 20, .45); }
  .grip { display: none; }
  .burger { display: inline-grid; place-items: center; }
  .main { padding: 14px 16px 40px; }
}
@media (prefers-reduced-motion: reduce) { .rail { transition: none; } }

/* элементы */
.btn { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 6px 14px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); cursor: pointer; font-weight: 500; text-decoration: none; color: var(--ink); white-space: nowrap; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--button-primary); color: #fff; border-color: var(--button-primary); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); border-color: var(--button-primary); }
.btn.danger { color: var(--bad); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.small { min-height: 30px; padding: 3px 10px; font-size: 14px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel > .pad, .pad { padding: 16px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }

/* сводка — одна полоса цифр, а не набор карточек */
.strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.strip > div { padding: 14px 16px; border-right: 1px solid var(--line); }
.strip > div:last-child { border-right: 0; }
.strip b { display: block; font-size: 24px; line-height: 1.2; font-weight: 650; font-variant-numeric: tabular-nums; }
.strip span { color: var(--muted); font-size: 13px; }

/* таблицы */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: var(--soft); position: sticky; top: 0; }
tr:last-child td { border-bottom: 0; }
tbody tr.click { cursor: pointer; }
tbody tr.click:hover td { background: var(--soft); }
.empty { padding: 28px 16px; text-align: center; color: var(--muted); }

/* статусы: цвет несёт смысл */
.chip { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12.5px; border: 1px solid currentColor; white-space: nowrap; }
.chip.ok { color: var(--ok); } .chip.warn { color: var(--warn); } .chip.bad { color: var(--bad); } .chip.info { color: var(--signal); } .chip.mute { color: var(--muted); }

/* формы */
.form { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px 16px; }
.form .wide { grid-column: 1 / -1; }
label.f { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
label.f > span.req::after { content: " *"; color: var(--bad); }
input[type=text], input[type=email], input[type=tel], input[type=number], input[type=password], input[type=date], input[type=search], select, textarea {
  width: 100%; min-height: 38px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink); }
textarea { min-height: 96px; resize: vertical; }
input[aria-invalid="true"], select[aria-invalid="true"], textarea[aria-invalid="true"] { border-color: var(--bad); }
.field-error { color: var(--bad); font-size: 12.5px; min-height: 0; }
label.check { display: flex; gap: 8px; align-items: center; color: var(--ink); font-size: 14px; }
.phone { display: grid; grid-template-columns: 96px 1fr; gap: 6px; }

/* выезжающая карточка */
.sheet-back { position: fixed; inset: 0; background: rgba(10, 14, 20, .45); z-index: 40; }
.sheet { position: fixed; top: 0; right: 0; bottom: 0; width: min(760px, 100vw); background: var(--paper); z-index: 41; overflow-y: auto; border-left: 1px solid var(--line); }
.sheet header { position: sticky; top: 0; background: var(--surface); border-bottom: 1px solid var(--line); padding: 14px 18px; display: flex; gap: 12px; align-items: center; z-index: 2; }
.sheet header h2 { font-size: 18px; margin: 0; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sheet .body { padding: 16px 18px 40px; display: grid; gap: 16px; }
.sheet h3 { font-size: 15px; margin: 0 0 8px; }
dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
dl.kv dt { color: var(--muted); } dl.kv dd { margin: 0; word-break: break-word; }

.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--ink); color: var(--paper); padding: 10px 16px; border-radius: 8px; z-index: 60; max-width: calc(100vw - 32px); }
.toast.bad { background: var(--bad); color: #fff; }

/* переписка поддержки */
.thread { display: grid; gap: 10px; }
.msg { padding: 10px 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); max-width: 92%; }
.msg.out { justify-self: end; background: color-mix(in srgb, var(--signal) 10%, var(--surface)); border-color: color-mix(in srgb, var(--signal) 35%, var(--line)); }
.msg.note { background: color-mix(in srgb, var(--warn) 10%, var(--surface)); border-style: dashed; justify-self: stretch; max-width: 100%; }
.msg.system { color: var(--muted); font-size: 13px; border: 0; background: none; padding: 0 4px; }
.msg .who { font-size: 12.5px; color: var(--muted); margin-bottom: 4px; }
.msg .text { white-space: pre-wrap; word-break: break-word; }

/* вход */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login form { width: min(400px, 100%); display: grid; gap: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 28px; box-shadow: var(--shadow); }
.login img { height: 28px; margin-bottom: 8px; }
.login h1 { font-size: 20px; margin: 0; }

/* редактор блоков сайта */
.block { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.block > .head { display: flex; gap: 8px; align-items: center; padding: 8px 10px; border-bottom: 1px solid var(--line); background: var(--soft); }
.block > .head select { width: auto; min-height: 32px; }
.block > .fields { padding: 12px; display: grid; gap: 10px; }

/* 3.3: переключатель темы, вкладки, окна, kanban */
.theme-tools { display: flex; gap: 6px; align-items: center; margin-top: 8px; }
.theme-tools button { background: var(--soft); border: 1px solid var(--line); color: var(--ink); border-radius: 8px; padding: 3px 10px; cursor: pointer; font-size: 13px; }
.theme-tools select { width: auto; min-height: 28px; padding: 2px 6px; font-size: 13px; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs button { background: none; border: 0; border-bottom: 2px solid transparent; padding: 8px 14px; cursor: pointer; color: var(--muted); white-space: nowrap; font-weight: 500; }
.tabs button[aria-selected="true"], .tabs button.on { color: var(--brand-dark); border-bottom-color: var(--brand); }
html[data-theme="dark"] .tabs button[aria-selected="true"], html[data-theme="dark"] .tabs button.on { color: var(--brand); }
.modal-back { position: fixed; inset: 0; background: rgba(10, 14, 20, .5); z-index: 50; display: grid; place-items: center; padding: 16px; }
.modal { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 22px; width: min(480px, 100%); max-height: 90vh; overflow: auto; display: grid; gap: 12px; box-shadow: 0 20px 50px rgba(0, 0, 0, .25); }
.modal h3 { margin: 0; font-size: 17px; }
code.secret { display: block; padding: 10px 12px; background: var(--soft); border: 1px dashed var(--line); border-radius: 8px; font-family: ui-monospace, Menlo, Consolas, monospace; word-break: break-all; user-select: all; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button { background: var(--surface); border: 0; padding: 6px 14px; cursor: pointer; color: var(--muted); }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on, .seg button[aria-pressed="true"] { background: var(--nav-hover); color: var(--brand-dark); font-weight: 600; }
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(260px, 1fr); gap: 12px; overflow-x: auto; align-items: start; padding-bottom: 8px; }
.kcol { background: var(--soft); border: 1px solid var(--line); border-radius: var(--radius); display: flex; flex-direction: column; min-height: 220px; }
.kcol.over { outline: 2px dashed var(--brand); outline-offset: -4px; }
.kcol > header { display: flex; align-items: center; gap: 8px; padding: 10px 12px; font-weight: 600; }
.kcount { margin-left: auto; font-size: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 0 8px; color: var(--muted); font-variant-numeric: tabular-nums; }
.kbody { padding: 0 8px 8px; display: grid; gap: 8px; align-content: start; flex: 1; }
.kempty { color: var(--muted); font-size: 13px; text-align: center; padding: 18px 6px; }
.kcard { background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--line); border-radius: 10px; padding: 10px 12px; cursor: grab; box-shadow: var(--shadow); display: grid; gap: 6px; }
.kcard.drag { opacity: .45; }
.kcard.prio-high, .kcard.prio-urgent { border-left-color: var(--bad); }
.kcard.prio-normal { border-left-color: var(--brand); }
.kcard.prio-low { border-left-color: var(--muted); }
.kcard.late { border-color: var(--bad); }
.knum { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.ksubj { font-weight: 600; line-height: 1.3; cursor: pointer; background: none; border: 0; padding: 0; text-align: left; color: var(--ink); }
.kfoot { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); flex-wrap: wrap; }
.kfoot select { width: auto; min-height: 28px; padding: 2px 6px; font-size: 12.5px; margin-left: auto; }
.avatar { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--nav-hover); color: var(--brand-dark); font-size: 11px; font-weight: 700; }
.late-text { color: var(--bad); }
.kcard .khead { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ksubj { display: block; }
.logo-pair img { height: 26px; display: block; }
.logo-pair .logo-dark { display: none; }
html[data-theme="dark"] .logo-pair .logo-light { display: none; }
html[data-theme="dark"] .logo-pair .logo-dark { display: block; }
.login .logo-pair img { height: 30px; margin-bottom: 8px; }
