/* ============================================================ токены */
:root {
  --bg: #f6f5f2;
  --panel: #ffffff;
  --panel-2: #faf9f6;
  --line: #e7e4dd;
  --line-2: #d8d4cb;
  --text: #1d1c1a;
  --muted: #6e6a62;
  --accent: #e2b007;          /* золото Fayz: фон главной кнопки */
  --accent-ink: #1f1800;      /* текст на золоте (контраст ~10:1) */
  --accent-soft: #fbf1d3;
  --accent-text: #8a6400;     /* золото для текста и ссылок на светлом фоне */
  --ok: #2e8b4f;
  --warn: #a8690e;
  --danger: #c2392a;
  --danger-soft: #fdecea;
  --hot: #fffaea;
  --workspace: #e9e7e2;
  --shadow: 0 1px 2px rgba(20, 18, 12, .06), 0 4px 16px rgba(20, 18, 12, .06);
  --shadow-lg: 0 10px 40px rgba(20, 18, 12, .18);
  --r: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121314; --panel: #1b1c1e; --panel-2: #202124; --line: #2c2e31; --line-2: #3b3d41;
    --text: #e9e7e2; --muted: #9c988f; --accent: #e9bb21; --accent-ink: #1f1800; --accent-soft: #3a3116;
    --accent-text: #f0c94a; --ok: #5fc183; --warn: #e3a53b; --danger: #ff7262; --danger-soft: #3b1e1a;
    --hot: #2b2614; --workspace: #0d0e0f; --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121314; --panel: #1b1c1e; --panel-2: #202124; --line: #2c2e31; --line-2: #3b3d41;
  --text: #e9e7e2; --muted: #9c988f; --accent: #e9bb21; --accent-ink: #1f1800; --accent-soft: #3a3116;
  --accent-text: #f0c94a; --ok: #5fc183; --warn: #e3a53b; --danger: #ff7262; --danger-soft: #3b1e1a;
  --hot: #2b2614; --workspace: #0d0e0f; --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.25);
  color-scheme: dark;
}

/* ============================================================ основа */
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent-text); text-decoration: none; }
h1, h2, h3 { margin: 0; letter-spacing: -.01em; }
h1 { font-size: 22px; font-weight: 650; }
h2 { font-size: 15px; font-weight: 650; }
kbd { font: 11px ui-monospace, Menlo, monospace; padding: 1px 5px; border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: 4px; color: var(--muted); background: var(--panel); }
.muted { color: var(--muted); font-weight: normal; }
.grow { flex: 1; }
.nowrap { white-space: nowrap; }
.strong { font-weight: 600; }
.lead { color: var(--muted); margin: -6px 0 16px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.ic { display: inline-flex; width: 18px; height: 18px; flex: none; }
.ic svg { width: 100%; height: 100%; }
.ic.sm { width: 14px; height: 14px; }
.ic.big { width: 40px; height: 40px; color: var(--line-2); }
.ic.gold { color: var(--accent-text); }
.ic.gold svg, .star.on svg { fill: currentColor; }

/* ============================================================ кнопки и поля */
.btn { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 14px; border: 1px solid var(--line-2); background: var(--panel); border-radius: 8px; cursor: pointer; white-space: nowrap; font-weight: 500; color: var(--text); transition: border-color .15s, background .15s; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 650; }
.btn.primary:hover { filter: brightness(.96); }
.btn.danger { color: var(--danger); }
.btn.danger-solid { background: var(--danger); border-color: var(--danger); color: #fff; font-weight: 600; }
.btn.block { width: 100%; justify-content: center; height: 40px; }
.btn[hidden] { display: none; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border: 0; background: transparent; border-radius: 8px; color: var(--muted); cursor: pointer; flex: none; }
.icon-btn:hover { background: var(--bg); color: var(--text); }
.chip-btn { display: inline-flex; align-items: center; gap: 5px; height: 26px; padding: 0 10px; border: 1px solid var(--line-2); background: var(--panel); border-radius: 999px; cursor: pointer; font-size: 12.5px; color: var(--accent-text); font-weight: 600; }
.chip-btn:hover { background: var(--accent-soft); border-color: var(--accent); }
.chip-btn .ic { width: 14px; height: 14px; }
.link-btn { border: 0; background: none; padding: 0; color: var(--accent-text); cursor: pointer; font-weight: 600; font-size: 12px; }

input[type=text], input[type=search], input[type=password], input[type=date], input[type=number], input:not([type]), select, textarea {
  width: 100%; height: 36px; padding: 0 10px; border: 1px solid var(--line-2); border-radius: 8px; background: var(--panel); transition: border-color .15s, box-shadow .15s;
}
textarea { height: auto; padding: 8px 10px; resize: vertical; line-height: 1.4; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input.search { width: 260px; padding-left: 32px; background: var(--panel) no-repeat 10px center / 15px url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23999' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E"); }

/* сегментированный переключатель */
.seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--bg); border: 1px solid var(--line); border-radius: 9px; }
.seg button { height: 28px; padding: 0 11px; border: 0; background: transparent; border-radius: 6px; cursor: pointer; color: var(--muted); font-weight: 600; font-size: 13px; white-space: nowrap; }
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--panel); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.12); }
.seg.sm button { height: 24px; padding: 0 9px; font-size: 12px; }
.seg.lang-seg button.on { background: var(--accent); color: var(--accent-ink); }
.mobile-only { display: none; }

.badge { display: inline-block; padding: 1px 7px; border-radius: 5px; background: var(--bg); border: 1px solid var(--line); font-size: 11.5px; font-weight: 600; color: var(--muted); }
.crumbs { display: flex; align-items: center; gap: 4px; font-size: 12.5px; color: var(--muted); margin-bottom: 4px; flex-wrap: wrap; }
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--text); text-decoration: underline; }
.crumbs .sep { width: 12px; height: 12px; opacity: .6; }

/* ============================================================ каркас */
.layout { display: grid; grid-template-columns: 240px 1fr; height: 100vh; }
.layout > * { min-width: 0; }
main { overflow: auto; min-width: 0; }
.side { display: flex; flex-direction: column; gap: 2px; padding: 14px 10px 10px; background: var(--panel); border-right: 1px solid var(--line); min-height: 0; }
.brand { display: flex; align-items: center; gap: 8px; padding: 2px 8px 12px; color: var(--muted); font-size: 12px; font-weight: 600; letter-spacing: .02em; }
.brand-logo { width: 112px; height: 40px; background: url(/assets/header.png) left center / auto 100% no-repeat; border-radius: 6px; flex: none; }
.brand-logo.big { width: 220px; height: 56px; margin: 0 auto 18px; }
:root[data-theme="dark"] .brand-logo { background-color: #fff; background-origin: content-box; padding: 3px 6px; box-sizing: content-box; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .brand-logo { background-color: #fff; background-origin: content-box; padding: 3px 6px; box-sizing: content-box; } }
.search-btn { display: flex; align-items: center; gap: 8px; height: 34px; padding: 0 10px; margin: 0 2px 8px; border: 1px solid var(--line); background: var(--bg); border-radius: 8px; color: var(--muted); cursor: pointer; }
.search-btn:hover { border-color: var(--line-2); color: var(--text); }
.search-btn span { flex: 1; text-align: left; }
.nav-scroll { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 1px; }
.nav-sec { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin: 16px 10px 4px; opacity: .85; }
.nav-link { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 7px; color: var(--text); font-weight: 500; }
.nav-link .ic { color: var(--muted); }
.nav-link:hover { background: var(--bg); }
.nav-link.active { background: var(--accent-soft); color: var(--text); font-weight: 650; }
.nav-link.active .ic { color: var(--accent-text); }
.me { display: flex; align-items: center; gap: 8px; padding: 10px 4px 2px; border-top: 1px solid var(--line); margin-top: 8px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 12px; flex: none; }
.me-name { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.2; }
.me-name b { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-name span { font-size: 11.5px; color: var(--muted); }

/* ============================================================ страницы */
.page { padding: 26px 32px 40px; max-width: 1240px; margin: 0 auto; }
.page.narrow { max-width: 820px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.head-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.with-label { display: flex; align-items: center; gap: 8px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); overflow: hidden; }
.card.pad { padding: 18px; overflow: visible; }
.card-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 6px; }
.card-head a { font-size: 13px; font-weight: 600; }
.card-foot { display: flex; justify-content: flex-end; gap: 8px; padding-top: 14px; margin-top: 6px; border-top: 1px solid var(--line); }

.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 650; padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--panel-2); }
.table td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tr.row { cursor: pointer; }
.table tr.row:hover td { background: var(--panel-2); }
.table td.clip { max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-actions { text-align: right; white-space: nowrap; width: 1%; }
.row-actions .icon-btn { opacity: 0; }
tr.row:hover .row-actions .icon-btn, .row-actions .icon-btn:focus-visible { opacity: 1; }
.cell-doc { display: flex; gap: 10px; align-items: center; }
.cell-doc .ic { color: var(--muted); }
.cell-doc b { font-weight: 600; display: block; }
.cell-doc small { color: var(--muted); font-size: 12.5px; }

.empty { padding: 48px 20px; text-align: center; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 10px; }
.empty p { margin: 0; }
.empty.small { padding: 22px 16px; font-size: 13px; }
.row-gap { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }

/* главная */
.hero { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; margin: 4px 0 22px; flex-wrap: wrap; }
.hero h1 { font-size: 26px; }
.hero p { margin: 4px 0 0; }
.hero p::first-letter { text-transform: uppercase; }
.stats { display: flex; gap: 10px; }
.stats div { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 10px 16px; min-width: 150px; }
.stats b { display: block; font-size: 24px; line-height: 1.1; }
.stats span { color: var(--muted); font-size: 12.5px; }
.actions-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 22px; }
.action-card { display: flex; gap: 12px; align-items: flex-start; padding: 16px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); color: var(--text); box-shadow: var(--shadow); transition: transform .12s, border-color .12s; }
.action-card:hover { border-color: var(--accent); transform: translateY(-1px); }
.action-card > .ic { width: 36px; height: 36px; padding: 8px; border-radius: 9px; background: var(--accent-soft); color: var(--accent-text); }
.action-card b { display: block; }
.action-card span { color: var(--muted); font-size: 12.5px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.list { padding: 4px 6px 8px; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: 8px; color: var(--text); }
.list-item:hover { background: var(--panel-2); }
.list-item > .ic { color: var(--muted); }
.li-main { flex: 1; min-width: 0; }
.li-main b { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.li-main span { color: var(--muted); font-size: 12.5px; }

/* история */
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.filters .search { flex: 1; min-width: 220px; }
.date-range { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
.date-range .date-in { width: 140px; }

/* каталог */
.catalog { display: grid; grid-template-columns: 236px 1fr; gap: 20px; align-items: start; }
.subnav { position: sticky; top: 16px; display: flex; flex-direction: column; gap: 1px; }
.subnav-item { display: flex; align-items: center; gap: 8px; text-align: left; padding: 7px 10px; border: 0; background: none; border-radius: 7px; cursor: pointer; color: var(--text); line-height: 1.3; }
.subnav-item > span:not(.ic):not(.n) { flex: 1; }
.subnav-item .n { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.subnav-item:hover { background: var(--panel); }
.subnav-item.on { background: var(--panel); box-shadow: inset 3px 0 0 var(--accent), var(--shadow); font-weight: 600; }
.subnav-item .ic { width: 15px; height: 15px; color: var(--accent-text); }
.subnav-sep { height: 1px; background: var(--line); margin: 6px 8px; }
.popular { margin-bottom: 16px; }
.popular .label, .fsec-title { font-weight: 650; }
.popular .label { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 8px; }
.pop-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.pop-card { display: flex; gap: 10px; align-items: flex-start; padding: 12px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); color: var(--text); font-weight: 500; font-size: 13px; line-height: 1.35; }
.pop-card:hover { border-color: var(--accent); }
.pop-card .ic { color: var(--accent-text); }
.doc-row { display: grid; grid-template-columns: 32px 1fr auto; align-items: center; gap: 8px; padding: 8px 14px 8px 8px; border-bottom: 1px solid var(--line); color: var(--text); }
.doc-row:last-child { border-bottom: 0; }
.doc-row:hover { background: var(--panel-2); }
.doc-title span { display: block; }
.doc-title small { color: var(--muted); font-size: 12px; }
.star { color: var(--line-2); }
.star:hover, .star.on { color: var(--accent); }
.langs-mini { display: inline-flex; gap: 3px; }
.langs-mini span { font-size: 10.5px; font-weight: 700; padding: 1px 5px; border-radius: 4px; color: var(--line-2); border: 1px solid var(--line); }
.langs-mini span.has { color: var(--muted); border-color: var(--line-2); }

/* ============================================================ редактор */
.editor-page { display: flex; flex-direction: column; height: 100vh; }
.ed-bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 22px; background: var(--panel); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.ed-head { min-width: 0; flex: 1 1 320px; }
.ed-title { font-size: 17px; font-weight: 650; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ed-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); margin-right: 4px; white-space: nowrap; }
.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.dot-green { background: var(--ok); } .dot-amber { background: var(--warn); } .dot-gray { background: var(--line-2); } .dot-red { background: var(--danger); }
.ed-layout { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(380px, 43%) 1fr; }
.ed-form { overflow-y: auto; padding: 16px 18px 40px; min-width: 0; }
.pv { display: flex; flex-direction: column; min-height: 0; min-width: 0; background: var(--workspace); border-left: 1px solid var(--line); }
.pv-head { display: flex; align-items: center; gap: 10px; padding: 8px 16px; border-bottom: 1px solid var(--line); background: var(--panel); font-size: 13px; }
.pv-scroll { flex: 1; overflow: auto; padding: 18px; }
.sheet { margin: 0 auto; overflow: hidden; background: #fff; box-shadow: var(--shadow-lg); border-radius: 2px; }
.sheet iframe { display: block; border: 0; transform-origin: 0 0; background: #fff; }

.progress { display: flex; align-items: center; gap: 10px; font-size: 12.5px; color: var(--muted); margin: 0 2px 12px; }
.progress .bar { flex: 1; height: 6px; background: var(--line); border-radius: 99px; overflow: hidden; }
.progress .bar i { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width .25s; }

.fsec { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); margin-bottom: 10px; }
.fsec > summary { display: flex; align-items: center; gap: 8px; padding: 11px 14px; cursor: pointer; list-style: none; user-select: none; }
.fsec > summary::-webkit-details-marker { display: none; }
.fsec .chev { width: 15px; height: 15px; color: var(--muted); transition: transform .15s; }
.fsec[open] .chev { transform: rotate(90deg); }
.fsec-title { font-size: 13.5px; }
.cnt { font-size: 11.5px; font-weight: 700; color: var(--muted); background: var(--bg); padding: 1px 7px; border-radius: 99px; font-variant-numeric: tabular-nums; }
.cnt.full { background: color-mix(in srgb, var(--ok) 16%, transparent); color: var(--ok); }
.fsec-body { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; padding: 2px 14px 14px; }

.fld { grid-column: span 2; display: flex; flex-direction: column; gap: 4px; min-width: 0; border-radius: 8px; }
.fld.half { grid-column: span 1; }
.fld-cap { font-size: 12px; color: var(--muted); font-weight: 500; line-height: 1.3; }
.fld .req { color: var(--danger); }
.fld.hot input { background: var(--hot); border-color: color-mix(in srgb, var(--accent) 60%, var(--line-2)); }
.fld.bad input { border-color: var(--danger); background: var(--danger-soft); }
.fld-help { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; font-size: 12px; color: var(--muted); }
.fld-help:empty { display: none; }
.fld-help .ic { width: 14px; height: 14px; }
.fld.bad .fld-help { color: var(--danger); font-weight: 600; }
.fld.warn .fld-help { color: var(--warn); }
.fld-help .words { font-style: italic; }
.fld .chip-btn { align-self: flex-start; margin-top: 2px; }
.fld.flash { animation: flash .9s; }
@keyframes flash { 0%, 60% { box-shadow: 0 0 0 4px var(--accent-soft); } 100% { box-shadow: none; } }
.radios { display: flex; flex-direction: column; gap: 4px; }
.radio { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border: 1px solid var(--line-2); border-radius: 8px; cursor: pointer; }
.radio:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.radio input { accent-color: var(--accent); margin: 0; }
.combo { display: flex; flex-direction: column; gap: 6px; }
.combo-pick { color: var(--muted); }

/* ============================================================ окна, меню, поиск, уведомления */
.overlay { position: fixed; inset: 0; background: rgba(15, 14, 10, .42); display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 50; animation: fade .12s; }
.overlay.top { align-items: flex-start; padding-top: 12vh; }
@keyframes fade { from { opacity: 0; } }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-lg); width: min(460px, 100%); max-height: 86vh; display: flex; flex-direction: column; overflow: hidden; }
.modal.wide { width: min(640px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 6px 20px; }
.modal-head h3 { font-size: 16px; }
.modal-body { padding: 8px 20px 18px; overflow: auto; }
.modal-body p { margin: 0 0 8px; }
.modal-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 16px; border-top: 1px solid var(--line); background: var(--panel-2); }
.bad-list { margin: 6px 0 0; padding-left: 18px; color: var(--danger); font-weight: 600; }

.menu { position: fixed; z-index: 60; min-width: 220px; max-height: 60vh; overflow: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow-lg); padding: 5px; animation: fade .1s; }
.menu-item { display: flex; align-items: center; gap: 9px; width: 100%; padding: 7px 10px; border: 0; background: none; border-radius: 6px; cursor: pointer; text-align: left; color: var(--text); }
.menu-item:hover { background: var(--bg); }
.menu-item .ic { color: var(--muted); width: 16px; height: 16px; }
.menu-item span:nth-of-type(2) { flex: 1; }
.menu-item.danger, .menu-item.danger .ic { color: var(--danger); }
.menu-hint { color: var(--muted); font-size: 12px; }
.menu-sep { height: 1px; background: var(--line); margin: 5px 4px; }
.menu-head { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 8px 10px 4px; }

.cmdk { margin: -8px -20px -18px; }
.overlay.top .modal { width: min(620px, 100%); }
.cmdk-input { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.cmdk-input .ic { color: var(--muted); }
.cmdk-input input { border: 0; box-shadow: none !important; padding: 0; height: 30px; font-size: 16px; background: transparent; }
.cmdk-results { max-height: 52vh; overflow: auto; padding: 6px; }
.cmdk-group { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 10px 10px 4px; }
.cmdk-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; background: none; border-radius: 7px; cursor: pointer; text-align: left; color: var(--text); }
.cmdk-item.on { background: var(--accent-soft); }
.cmdk-item .ic { color: var(--muted); }
.cmdk-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cmdk-item .muted { font-size: 12px; white-space: nowrap; }

.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: #1d1c1a; color: #fff; padding: 10px 16px; border-radius: 9px; box-shadow: var(--shadow-lg); z-index: 70; animation: fade .15s; transition: opacity .35s; }
.toast.err { background: var(--danger); }
.toast.out { opacity: 0; }

/* вход */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; background: radial-gradient(1200px 500px at 50% -10%, var(--accent-soft), transparent), var(--bg); }
.login-card { width: min(380px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow-lg); padding: 28px 28px 24px; display: flex; flex-direction: column; gap: 12px; }
.login-card h1 { font-size: 18px; text-align: center; margin-bottom: 4px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); cursor: pointer; }
.check input { accent-color: var(--accent); }
.err { color: var(--danger); font-size: 13px; min-height: 1px; }

/* ============================================================ адаптив */
@media (max-width: 1180px) {
  .actions-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pop-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .catalog { grid-template-columns: 1fr; }
  .subnav { position: static; flex-direction: row; overflow-x: auto; padding-bottom: 4px; }
  .subnav-item { white-space: nowrap; }
  .subnav-sep { display: none; }
}
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; grid-template-rows: auto 1fr; height: auto; min-height: 100vh; }
  main { overflow: visible; }
  .side { flex-direction: row; align-items: center; flex-wrap: wrap; border-right: 0; border-bottom: 1px solid var(--line); padding: 8px 12px; }
  .brand { padding: 0; }
  .search-btn { margin: 0; flex: 1; }
  .nav-scroll { flex-basis: 100%; flex-direction: row; overflow-x: auto; order: 5; min-width: 0; }
  .brand > span { display: none; }
  .ed-title { font-size: 15px; }
  .nav-sec { display: none; }
  .nav-link { white-space: nowrap; }
  .me { border: 0; margin: 0; padding: 0; }
  .me-name { display: none; }
  .page { padding: 18px 16px 32px; }
  .two-col { grid-template-columns: 1fr; }
  input.search { width: 100%; }
  .editor-page { height: auto; }
  .ed-layout { grid-template-columns: 1fr; }
  .ed-layout[data-show="form"] .pv, .ed-layout[data-show="preview"] .ed-form { display: none; }
  .pv { min-height: 80vh; border-left: 0; }
  .mobile-only { display: inline-flex; margin: 10px 16px 0; align-self: flex-start; }
  .ed-bar { padding: 12px 16px; }
}
@media (max-width: 560px) {
  .actions-grid, .pop-grid { grid-template-columns: 1fr; }
  .fsec-body { grid-template-columns: 1fr; }
  .fld.half { grid-column: span 2; }
  .stats { width: 100%; }
  .stats div { flex: 1; min-width: 0; }
}

/* ============================================================ канцелярия и настройки */
.badge.red { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, transparent); background: var(--danger-soft); }
.badge.gold { color: var(--accent-text); border-color: color-mix(in srgb, var(--accent) 45%, transparent); background: var(--accent-soft); }
.table td.num { font-weight: 700; font-variant-numeric: tabular-nums; }
.table td small.sub { display: block; color: var(--muted); font-size: 12px; }
.table tr.cancelled td { color: var(--muted); }
.table tr.cancelled td.num, .table tr.cancelled td.strong { text-decoration: line-through; }
.row-flags { text-align: right; white-space: nowrap; width: 1%; }
.row-flags .badge { margin-right: 6px; }
.icon-btn.on { color: var(--accent-text); }
.icon-btn.ghost { opacity: .25; cursor: default; }
.icon-btn.ghost:hover { background: none; color: var(--muted); }
select.auto-w, input.auto-w { width: auto; min-width: 120px; }
.small-link { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; margin-left: auto; }
.small-link .ic { width: 15px; height: 15px; }
.link-btn.danger { color: var(--danger); }

.reg-number { display: flex; flex-direction: column; gap: 8px; padding: 12px 14px; margin: 4px 14px 12px; border-radius: 10px; background: var(--accent-soft); }
.reg-number-row { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.reg-number .check { color: var(--text); }
.reg-number b { font-size: 20px; font-variant-numeric: tabular-nums; }
.reg-extras { display: flex; flex-direction: column; gap: 8px; padding: 4px 14px 4px; }
.reg-extras:empty { display: none; }
.reg-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; }
.reg-line .ic { width: 16px; height: 16px; color: var(--muted); }
.notice { display: flex; align-items: center; gap: 8px; margin: 4px 14px 10px; padding: 9px 12px; border-radius: 8px; background: var(--danger-soft); color: var(--danger); font-weight: 600; font-size: 13px; }
.reg-badge { height: 32px; padding: 0 12px; font-variant-numeric: tabular-nums; }
.reg-badge.cancelled { color: var(--muted); text-decoration: line-through; }

.settings-card { margin-bottom: 16px; }
.settings-card > h2 { margin-bottom: 2px; }
.settings-card > p { margin: 0 0 10px; font-size: 13px; }
.settings-card .fsec-body { padding: 4px 0 0; }
.tokens { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.token { display: inline-flex; align-items: baseline; gap: 6px; padding: 4px 9px; border: 1px dashed var(--line-2); background: var(--panel-2); border-radius: 7px; cursor: pointer; font: 600 12.5px ui-monospace, Menlo, monospace; color: var(--text); }
.token small { font: 11.5px -apple-system, Arial, sans-serif; color: var(--muted); }
.token:hover { border-color: var(--accent); background: var(--accent-soft); }
.num-preview { grid-column: span 2; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 10px 12px; border-radius: 9px; background: var(--accent-soft); }
.num-chip { padding: 2px 9px; border-radius: 6px; background: var(--panel); border: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.types { display: flex; flex-direction: column; gap: 6px; align-items: stretch; }
.types-head, .types-row { display: grid; grid-template-columns: 90px 1fr 150px 32px; gap: 8px; align-items: center; }
.types-head { font-size: 11.5px; color: var(--muted); font-weight: 600; }
.types .chip-btn { align-self: flex-start; }
.person { display: flex; align-items: center; gap: 10px; padding: 6px 0; }
.person small { display: block; font-size: 11.5px; }
.avatar.sm { width: 30px; height: 30px; background: var(--accent-soft); color: var(--accent-text); }
.avatar.sm .ic { width: 16px; height: 16px; }
.warn-text { color: var(--warn); font-weight: 600; }
.sticky-save { position: sticky; bottom: 0; display: flex; justify-content: flex-end; padding: 12px 0; background: linear-gradient(transparent, var(--bg) 35%); }
@media (max-width: 560px) { .types-head, .types-row { grid-template-columns: 70px 1fr 90px 32px; } }
.check.fld { flex-direction: row; align-items: center; gap: 8px; }

.badge.green { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 35%, transparent); background: color-mix(in srgb, var(--ok) 10%, transparent); }

/* правила «с даты» */
.rules { display: flex; flex-direction: column; gap: 10px; margin: 14px 0 10px; }
.rule { border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px 12px; background: var(--panel-2); }
.rule.active { border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); background: var(--panel); box-shadow: inset 3px 0 0 var(--accent); }
.rule-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.rule-head > .ic { color: var(--muted); width: 16px; height: 16px; }
.rule-from { display: inline-flex; align-items: center; gap: 8px; }
.rule-from input { height: 30px; min-width: 150px; }
.settings-card .rule .fsec-body { padding: 0; }
.doc-pick { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.doc-pick-cur { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; min-width: 0; }
.doc-pick-cur .ic { color: var(--accent-text); }

/* выбор бланка */
.pick { display: flex; flex-direction: column; gap: 10px; }
.pick-bar { display: flex; gap: 10px; align-items: center; }
.pick-bar .search { flex: 1; width: auto; }
.pick-list { max-height: 46vh; overflow: auto; border: 1px solid var(--line); border-radius: 10px; }
.pick-row { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 12px; border: 0; border-bottom: 1px solid var(--line); background: var(--panel); text-align: left; cursor: pointer; color: var(--text); }
.pick-row:last-child { border-bottom: 0; }
.pick-row:hover { background: var(--panel-2); }
.pick-row.on { background: var(--accent-soft); font-weight: 600; }
.pick-row > span:not(.ic) { flex: 1; }
.pick-row .ic { color: var(--muted); }
.pick-note { margin: 0; font-size: 12.5px; }
.types-wrap { margin-top: 10px; }

/* настройки: меню разделов слева, раздел справа */
.settings-layout { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 22px; align-items: start; max-width: 1100px; }
.settings-side { position: sticky; top: 16px; display: flex; flex-direction: column; gap: 12px; }
.settings-nav { display: flex; flex-direction: column; gap: 2px; }
.settings-nav-item { display: flex; align-items: flex-start; gap: 10px; width: 100%; padding: 10px 12px; border: 0; background: none; border-radius: 9px; cursor: pointer; text-align: left; color: var(--text); }
.settings-nav-item > .ic { margin-top: 1px; color: var(--muted); }
.settings-nav-item:hover { background: var(--panel); }
.settings-nav-item.on { background: var(--panel); box-shadow: inset 3px 0 0 var(--accent), var(--shadow); }
.settings-nav-item.on > .ic { color: var(--accent-text); }
.sn-text { display: flex; flex-direction: column; min-width: 0; }
.sn-text b { font-weight: 600; }
.sn-text small { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.settings-tip { font-size: 12.5px; margin: 0 12px; }
.settings-main { min-width: 0; }
.settings-main .settings-card { margin-bottom: 0; }
@media (max-width: 900px) {
  .settings-layout { grid-template-columns: minmax(0, 1fr); }
  .settings-side { position: static; min-width: 0; }
  .settings-nav { flex-direction: row; overflow-x: auto; }
  .settings-nav-item { width: auto; flex: none; }
  .settings-tip { display: none; }
}

/* правила журнала: компактный список, форма по клику */
.sub-head { font-weight: 650; font-size: 13.5px; margin: 14px 0 8px; }
.sub-head .muted { font-weight: normal; font-size: 12.5px; }
.rr-list { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; margin-bottom: 8px; }
.rr { border-bottom: 1px solid var(--line); }
.rr:last-child { border-bottom: 0; }
.rr-head { display: grid; grid-template-columns: 8px 190px minmax(70px, max-content) 12px minmax(0, 1fr) minmax(0, 1.1fr) 32px; align-items: center; gap: 10px; padding: 9px 8px 9px 14px; cursor: pointer; }
.rr-head:hover { background: var(--panel-2); }
.rr-when { font-weight: 600; white-space: nowrap; }
.rr-when small { margin-left: 6px; color: var(--ok); font-size: 11.5px; font-weight: 700; }
code.rr-format, input.mono { font: 13px ui-monospace, Menlo, monospace; }
code.rr-format { background: var(--bg); border: 1px solid var(--line); padding: 1px 6px; border-radius: 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rr-arrow { color: var(--muted); }
.rr-sample { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rr-doc { color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rr.open { background: var(--panel-2); }
.rr.open .rr-head:hover { background: transparent; }
.rr-edit { display: flex; flex-direction: column; gap: 16px; padding: 4px 18px 18px 32px; }
.rr-line { display: flex; flex-direction: column; gap: 6px; }
.rr-format-edit { display: flex; gap: 8px; }
.rr-format-edit input { flex: 1; min-width: 0; }
.rr-preview { display: flex; align-items: baseline; gap: 8px; font-size: 13px; }
.rr-preview b { font-size: 15px; font-variant-numeric: tabular-nums; }
.btn.sm { height: 36px; padding: 0 11px; font-size: 13px; gap: 5px; }
.btn.sm .ic { width: 16px; height: 16px; }
.doc-line { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.adv { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 12px; }
.adv summary { display: flex; align-items: center; gap: 6px; cursor: pointer; list-style: none; font-weight: 600; font-size: 13.5px; }
.adv summary::-webkit-details-marker { display: none; }
.adv summary .muted { font-weight: normal; font-size: 12.5px; }
.adv .chev { width: 15px; height: 15px; color: var(--muted); transition: transform .15s; }
.adv[open] .chev { transform: rotate(90deg); }
.adv-body { display: flex; flex-direction: column; gap: 12px; padding: 12px 0 2px 21px; }
.types-wrap { margin-top: 6px; }
@media (max-width: 760px) {
  .rr-head { grid-template-columns: 8px minmax(0, 1fr) auto 32px; }
  .rr-format, .rr-arrow, .rr-doc { display: none; }
  .rr-edit { padding-left: 16px; }
  .rr-format-edit { flex-wrap: wrap; }
}

/* переключатели частей номера */
.fmt-row { display: flex; align-items: center; gap: 16px; }
.fmt-row input { flex: 1; min-width: 0; }
.fmt-out { display: flex; flex-direction: column; min-width: 150px; line-height: 1.25; }
.fmt-out small { font-size: 11.5px; color: var(--muted); }
.fmt-out b { font-size: 16px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.fmt-builder { display: flex; flex-wrap: wrap; gap: 12px 22px; }
.fmt-part { display: flex; flex-direction: column; gap: 5px; }
.fmt-part .fld-cap { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; font-weight: 650; }
.rr-doc-line { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding-top: 14px; border-top: 1px solid var(--line); }
.rr-doc-line .fld-cap { margin: 0; }
@media (max-width: 760px) { .fmt-row { flex-direction: column; align-items: stretch; gap: 8px; } }

/* пример номера: один + «ещё N видов» */
.sample { display: inline-flex; align-items: baseline; gap: 8px; min-width: 0; white-space: nowrap; }
.sample .more { font-size: 12px; font-weight: 500; color: var(--muted); }
.fmt-out .sample b { font-size: 16px; }
.rr-sample { overflow: hidden; }
.fmt-out { max-width: 45%; }

/* ============================================================ сворачивание меню и формы */
.brand-row { display: flex; align-items: center; gap: 4px; padding-bottom: 12px; }
.brand-row .brand { flex: 1; padding-bottom: 0; min-width: 0; }
.side-toggle { width: 28px; height: 28px; }
.side-toggle .ic { width: 16px; height: 16px; }
.layout { transition: grid-template-columns .18s ease; }
@media (min-width: 901px) {
.layout.side-collapsed { grid-template-columns: 64px 1fr; }
.side-collapsed .side { padding: 12px 8px 10px; align-items: stretch; }
.side-collapsed .brand-row { flex-direction: column; gap: 8px; }
.side-collapsed .brand { padding: 0; justify-content: center; }
.side-collapsed .brand-logo { width: 38px; height: 38px; background-size: auto 100%; border-radius: 50%; }
.side-collapsed .brand > span, .side-collapsed .nav-link > span:not(.ic), .side-collapsed .search-btn > span:not(.ic), .side-collapsed .search-btn kbd, .side-collapsed .me-name { display: none; }
.side-collapsed .nav-sec { font-size: 0; margin: 10px 8px 6px; height: 1px; background: var(--line); opacity: 1; }
.side-collapsed .search-btn { justify-content: center; padding: 0; margin: 0 0 8px; }
.side-collapsed .nav-link { justify-content: center; padding: 9px 0; }
.side-collapsed .me { flex-direction: column; gap: 6px; padding-top: 10px; }

}
.form-rail { display: none; }
.ed-layout { transition: grid-template-columns .18s ease; }
@media (min-width: 901px) {
.ed-layout.form-collapsed { grid-template-columns: 48px 1fr; }
.form-collapsed .ed-form { padding: 0; overflow: hidden; }
.form-collapsed .ed-form-inner { display: none; }
.form-collapsed .form-rail { display: flex; flex-direction: column; align-items: center; gap: 12px; width: 100%; height: 100%; padding: 14px 0; border: 0; border-right: 1px solid var(--line); background: var(--panel); color: var(--muted); cursor: pointer; font-weight: 600; font-size: 13px; }
.form-collapsed .form-rail:hover { color: var(--text); background: var(--panel-2); }
.form-rail > span:last-child { writing-mode: vertical-rl; transform: rotate(180deg); letter-spacing: .04em; }
.form-collapsed .hide-form { display: none; }
}
@media (max-width: 900px) { .side-toggle, .hide-form { display: none; } }

/* ============================================================ логотип в меню: «орбитальный маяк» */
.brand-lockup { position: relative; display: inline-flex; align-items: center; gap: 10px; flex: 1; min-width: 0; padding: 2px 6px; color: var(--text); text-decoration: none; }
.bl-mark-shell { position: relative; flex: none; width: 34px; height: 34px; }
.bl-mark { position: relative; z-index: 3; display: block; width: 100%; height: 100%; border-radius: 50%; }
.bl-orbit { position: absolute; inset: -5px; z-index: 4; border: 1px dashed color-mix(in srgb, var(--accent) 55%, transparent); border-radius: 50%; pointer-events: none; animation: bl-orbit 4s linear infinite; }
.bl-orbit--two { inset: -1px; border-color: color-mix(in srgb, var(--accent) 30%, transparent); animation-duration: 3s; animation-direction: reverse; }
.bl-orbit span { position: absolute; top: -3px; left: calc(50% - 3px); width: 6px; height: 6px; border: 1px solid var(--panel); border-radius: 50%; background: var(--accent-text); box-shadow: 0 0 7px var(--accent); }
.bl-orbit--two span { background: var(--accent); }
.bl-name { position: relative; display: inline-flex; flex-direction: column; min-width: 0; line-height: 1.05; }
.bl-word { display: flex; flex-direction: column; font-size: 15px; font-weight: 800; letter-spacing: -.03em; white-space: nowrap; }
.bl-word b { font-weight: 800; color: var(--accent-text); }
.bl-signal { position: absolute; left: 0; right: 0; bottom: -5px; height: 2px; border-radius: 99px; background: linear-gradient(90deg, transparent, var(--accent), transparent); opacity: 0; transform: scaleX(0); animation: bl-signal 4s ease-in-out infinite; }
@keyframes bl-orbit { to { transform: rotate(360deg); } }
@keyframes bl-signal { 0%, 14%, 74%, 100% { opacity: 0; transform: scaleX(0); } 30%, 58% { opacity: 1; transform: scaleX(1); } }
@media (prefers-reduced-motion: reduce) { .bl-orbit, .bl-signal { animation: none; } .bl-signal { opacity: 0; } }
@media (min-width: 901px) {
  .side-collapsed .brand-lockup { justify-content: center; padding: 4px 0; flex: none; }
  .side-collapsed .bl-name { display: none; }
}
@media (max-width: 900px) { .bl-word { flex-direction: row; gap: 4px; } .bl-signal { display: none; } }
.login-sub { text-align: center; margin: -8px 0 6px; font-size: 13px; }

/* ---- пользователи */
.stack { display: flex; flex-direction: column; gap: 14px; }
.form-err { color: var(--danger); font-size: 13px; font-weight: 600; }
.form-err:empty { display: none; }
.sec-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 2px; }
.sec-head h2 { margin: 0; }
.pw-row { display: flex; gap: 6px; align-items: center; }
.pw-row input { flex: 1; min-width: 0; }
td.mono, .share-box { font: 13px ui-monospace, Menlo, monospace; }
.check-hint { display: block; font-size: 12px; margin-top: 1px; }
.check:has(.check-hint) { align-items: flex-start; }
.check:has(input:disabled) { cursor: default; opacity: .75; }
.share-box { margin: 0; padding: 12px 14px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; white-space: pre-wrap; user-select: all; color: var(--text); }
.users-table { margin-top: 6px; border-top: 1px solid var(--line); }
.users-table td .badge { margin-left: 4px; }
.table tr.off td { color: var(--muted); }
.me-name.clickable { cursor: pointer; border-radius: 6px; }
.me-name.clickable:hover b { color: var(--accent-text); }
.avatar.clickable { cursor: pointer; }

/* ---- фирменный бланк */
.chip-select { align-self: flex-start; height: 28px; padding: 0 8px; border: 1px solid var(--line-2); background: var(--panel); border-radius: 999px; font-size: 12.5px; color: var(--accent-text); font-weight: 600; cursor: pointer; max-width: 100%; }
.chip-select:hover { border-color: var(--accent); background: var(--accent-soft); }
.fld textarea { resize: vertical; min-height: 60px; line-height: 1.45; }
.pick-sec { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 650; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-top: 2px; }
.pick-sec .ic { width: 15px; height: 15px; }
.ic.own-star { color: var(--accent); }
.ic.own-star svg { fill: currentColor; }
.own-blanks { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 10px; }
.own-card { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid color-mix(in srgb, var(--accent) 40%, var(--line)); background: var(--accent-soft); border-radius: 10px; cursor: pointer; text-align: left; color: var(--text); }
.own-card:hover { border-color: var(--accent); }
.own-card.on { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft), inset 0 0 0 1px var(--accent); }
.own-card img { width: 38px; height: 40px; flex: none; background: #fff; border-radius: 6px; padding: 3px; }
.own-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; line-height: 1.25; }
.own-text b { font-size: 13.5px; }
.own-text small { font-size: 12px; color: var(--muted); }
.own-card > .ic { color: var(--accent); }

/* ---- ИИ-помощник */
.ai-btn { align-self: flex-start; margin-top: 2px; }
.ai-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.ai-legend { font-size: 12px; }
.ai-out { min-height: 120px; }
.ai-diff { white-space: pre-wrap; font: 14px/1.55 'Times New Roman', 'Liberation Serif', serif; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2); max-height: 46vh; overflow: auto; }
.ai-diff ins, .ai-legend ins { text-decoration: none; background: color-mix(in srgb, var(--ok) 22%, transparent); border-radius: 3px; padding: 0 1px; }
.ai-diff del, .ai-legend del { color: var(--danger); background: var(--danger-soft); border-radius: 3px; padding: 0 1px; }
.ai-notes { margin: 10px 0 0; padding-left: 18px; font-size: 13px; color: var(--muted); }
.ai-notes li + li { margin-top: 2px; }
.ai-ok { display: flex; align-items: center; gap: 8px; padding: 14px; border-radius: 10px; background: var(--panel-2); color: var(--ok); font-weight: 600; }
.ai-wait { display: flex; align-items: center; gap: 10px; padding: 14px; color: var(--muted); }
.ai-note { font-size: 12px; margin: 0; }
.spinner { width: 16px; height: 16px; border: 2px solid var(--line-2); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- компактная шапка редактора: одна строка, все элементы высотой 32px */
.ed-bar { padding: 8px 18px; gap: 6px 14px; }
.ed-head { flex: 1 1 220px; }
.ed-head .crumbs { font-size: 12px; margin-bottom: 1px; }
.ed-title { font-size: 15.5px; -webkit-line-clamp: 1; }
.ed-actions { gap: 6px; }
.ed-actions .status { margin-right: 2px; }
.ed-actions .btn,
.ed-actions .reg-badge { height: 32px; padding: 0 11px; gap: 6px; font-size: 13px; border-radius: 8px; }
.ed-actions .reg-badge { border: 1px solid var(--line-2); font-weight: 600; }
.ed-actions .btn .ic, .ed-actions .reg-badge .ic { width: 16px; height: 16px; }
.ed-actions .btn .ic.sm { width: 14px; height: 14px; margin-left: -2px; }
.ed-actions .btn.icon-only { width: 32px; padding: 0; justify-content: center; }
.ed-actions .seg { height: 32px; padding: 2px; align-items: stretch; border-color: var(--line-2); border-radius: 8px; }
.ed-actions .seg button { height: auto; padding: 0 9px; font-size: 12.5px; border-radius: 6px; }
.ed-actions > .icon-btn { width: 32px; height: 32px; border: 1px solid var(--line-2); background: var(--panel); color: var(--text); }
.ed-actions > .icon-btn:hover { border-color: var(--muted); }
@media (max-width: 640px) {
  /* на телефоне у вспомогательных кнопок — только значки (подпись в подсказке), «Печать» остаётся с текстом */
  .ed-actions .btn:not(.primary) { font-size: 0; gap: 0; width: 32px; padding: 0; justify-content: center; }
  .ed-actions .btn:not(.primary) .ic.sm { display: none; }
}
.ed-head .crumbs { flex-wrap: nowrap; overflow: hidden; white-space: nowrap; min-width: 0; }
.ed-head .crumbs > * { flex: none; }
.ed-head .crumbs > :last-child { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }

/* ---- плотность как в ZavodControl (только на компьютере): меню 208px, пункты ~29px, шрифт 13px */
@media (min-width: 901px) {
  .layout { grid-template-columns: 208px 1fr; }
  .layout.side-collapsed { grid-template-columns: 60px 1fr; }
  .side { padding: 10px 8px 8px; }
  .brand-row { padding-bottom: 8px; }
  .brand-lockup { gap: 9px; padding: 2px 4px; }
  .bl-mark-shell { width: 30px; height: 30px; }
  .bl-word { font-size: 14px; }
  .side-toggle { width: 26px; height: 26px; }
  .search-btn { height: 30px; margin: 0 0 6px; padding: 0 9px; font-size: 12.5px; gap: 7px; }
  .search-btn .ic { width: 15px; height: 15px; }
  .nav-scroll { gap: 0; }
  .nav-sec { font-size: 10px; letter-spacing: .07em; margin: 12px 9px 3px; }
  .nav-link { gap: 9px; padding: 5px 9px; min-height: 29px; font-size: 13px; line-height: 1.3; border-radius: 7px; }
  .nav-link .ic { width: 17px; height: 17px; }
  .nav-link > span:not(.ic) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .side-collapsed .nav-link { padding: 6px 0; }
  .me { gap: 7px; padding: 8px 2px 0; margin-top: 6px; }
  .me .avatar { width: 28px; height: 28px; font-size: 11px; }
  .me-name b { font-size: 12.5px; }
  .me-name span { font-size: 11px; }
  .me .icon-btn { width: 28px; height: 28px; }

  /* форма редактора: поля 34px, шрифт 13px, разделы плотнее */
  .ed-form { padding: 12px 14px 32px; }
  .ed-form input[type=text], .ed-form input[type=date], .ed-form input:not([type]), .ed-form select { height: 34px; font-size: 13px; }
  .ed-form textarea { font-size: 13px; padding: 7px 10px; }
  .ed-form .progress { margin-bottom: 10px; }
  .ed-form .fsec { margin-bottom: 8px; }
  .ed-form .fsec > summary { padding: 9px 12px; }
  .ed-form .fsec-title { font-size: 13px; }
  .ed-form .fsec-body { gap: 8px 10px; padding: 0 12px 12px; }
  .ed-form .fld { gap: 3px; }
  .ed-form .fld-cap { font-size: 11.5px; }
}

/* ---- ширина формы редактора: уже по умолчанию, граница тянется мышью */
@media (min-width: 901px) {
  .ed-layout { position: relative; grid-template-columns: var(--form-w, clamp(330px, 34%, 460px)) 1fr; }
  .ed-layout.resizing { transition: none; user-select: none; cursor: col-resize; }
  .ed-layout.resizing iframe { pointer-events: none; }
  .ed-split { position: absolute; top: 0; bottom: 0; left: var(--form-w, clamp(330px, 34%, 460px)); width: 9px; margin-left: -5px; cursor: col-resize; z-index: 5; touch-action: none; }
  .ed-split::after { content: ''; position: absolute; top: 0; bottom: 0; left: 4px; width: 1px; background: transparent; transition: background .15s, box-shadow .15s; }
  .ed-split:hover::after, .resizing .ed-split::after { background: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
  .form-collapsed .ed-split { display: none; }
}
@media (max-width: 900px) { .ed-split { display: none; } }

/* ---- мгновенная подсказка у бокового меню */
.side-tip { position: fixed; z-index: 1000; transform: translateY(-50%); padding: 5px 9px; border-radius: 6px; background: #2b2a27; color: #fff; font-size: 12.5px; font-weight: 500; line-height: 1.25; white-space: nowrap; pointer-events: none; opacity: 0; transition: opacity .08s; box-shadow: 0 4px 14px rgba(0,0,0,.18); }
.side-tip.on { opacity: 1; }
.side-tip::before { content: ''; position: absolute; left: -4px; top: 50%; width: 8px; height: 8px; background: inherit; transform: translateY(-50%) rotate(45deg); border-radius: 1px; }
:root[data-theme="dark"] .side-tip { background: #f2f0ea; color: #1d1c1a; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .side-tip { background: #f2f0ea; color: #1d1c1a; } }

/* ---- избранное под подгруппами каталога */
.fav-panel { margin-top: 14px; padding: 10px 6px 6px; border-top: 1px solid var(--line); }
.fav-head { display: flex; align-items: center; gap: 6px; padding: 0 6px 6px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.fav-head .ic { width: 14px; height: 14px; color: var(--accent); }
.fav-head .n { margin-left: auto; font-weight: 600; letter-spacing: 0; font-variant-numeric: tabular-nums; }
.fav-list { display: flex; flex-direction: column; gap: 1px; max-height: 52vh; overflow-y: auto; }
.fav-item { display: flex; align-items: center; gap: 6px; padding: 5px 4px 5px 8px; border-radius: 7px; color: var(--text); font-size: 13px; line-height: 1.3; }
.fav-item:hover { background: var(--panel); }
.fav-title { flex: 1; min-width: 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.fav-item .icon-btn { width: 24px; height: 24px; opacity: .55; }
.fav-item:hover .icon-btn { opacity: 1; }
.fav-item .icon-btn .ic { width: 14px; height: 14px; }
.fav-empty { margin: 0; padding: 2px 6px; font-size: 12px; color: var(--muted); line-height: 1.45; }
.fav-empty .ic { width: 12px; height: 12px; vertical-align: -1px; color: var(--accent); }
@media (max-width: 900px) { .fav-panel { display: none; } }
.fav-panel input.fav-search { height: 28px; margin: 0 0 6px; padding: 0 9px; font-size: 12.5px; border-radius: 7px; }

/* ---- справочник: данные из госреестра по ИНН / ПИНФЛ */
.reg-form { display: flex; flex-direction: column; gap: 10px; }
.reg-search { display: flex; align-items: flex-end; gap: 8px; }
.reg-search .fld { flex: 1; max-width: 280px; }
.reg-search input { font: 15px ui-monospace, Menlo, monospace; letter-spacing: .06em; }
.reg-search .btn { height: 36px; }
.reg-msg { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.reg-msg:empty { display: none; }
.reg-msg.err { color: var(--danger); font-weight: 600; }
.reg-msg.warn { color: var(--warn); font-weight: 600; }
.reg-msg .ic { width: 15px; height: 15px; }
.reg-card { border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2); padding: 12px 14px; }
.reg-card-head { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 650; color: var(--ok); margin-bottom: 8px; }
.reg-card-head .ic { width: 15px; height: 15px; }
.reg-card-head .muted { font-weight: 500; }
.reg-list { display: grid; grid-template-columns: max-content 1fr; gap: 5px 14px; margin: 0; font-size: 13px; }
.reg-list dt { color: var(--muted); }
.reg-list dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }
.reg-list dd.mono { font: 13px ui-monospace, Menlo, monospace; }
.reg-empty { text-align: center; padding: 14px 8px; color: var(--muted); font-size: 13px; }
.reg-empty p { margin: 6px 0 0; }
.reg-empty .ic.big { width: 26px; height: 26px; opacity: .6; }
.reg-legacy { display: flex; gap: 8px; align-items: flex-start; margin: 10px 0 0; padding: 8px 10px; border-radius: 8px; background: var(--danger-soft); color: var(--danger); font-size: 12.5px; }
.reg-legacy .ic { width: 15px; height: 15px; flex: none; margin-top: 1px; }
td.mono { font: 12.5px ui-monospace, Menlo, monospace; }
.reg-form .fsec-body { padding: 0; }
.inn-input { font: 15px ui-monospace, Menlo, monospace !important; letter-spacing: .06em; max-width: 220px; }
/* кнопки раздела («По ИНН», «Подставить») — без переноса текста; при нехватке места уходят на строку ниже */
.fsec > summary { flex-wrap: wrap; row-gap: 6px; }
.fsec > summary .chip-btn { white-space: nowrap; flex: none; }
.fsec-tools { display: flex; gap: 6px; margin-left: auto; }
.auto-note { display: flex; align-items: center; gap: 8px; margin: 0 0 10px; padding: 8px 12px; border-radius: 9px; background: var(--accent-soft); color: var(--accent-text); font-size: 12.5px; line-height: 1.35; }
.auto-note > span { flex: 1; }
.auto-note .ic { width: 15px; height: 15px; flex: none; }
.auto-note.warn { background: var(--danger-soft); color: var(--danger); }
.auto-note .link-btn { white-space: nowrap; }

/* ---- поле даты и календарь */
.date-in { position: relative; display: flex; align-items: center; min-width: 0; }
.date-in .date-text { width: 100%; padding-right: 34px; font-variant-numeric: tabular-nums; }
.date-in .date-btn { position: absolute; right: 3px; top: 50%; transform: translateY(-50%); display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border: 0; border-radius: 6px; background: none; color: var(--muted); cursor: pointer; }
.date-in .date-btn:hover, .date-in.open .date-btn { color: var(--accent-text); background: var(--accent-soft); }
.date-in .date-btn .ic { width: 16px; height: 16px; }
.date-in.bad .date-text { border-color: var(--danger); background: var(--danger-soft); }
.date-in.open .date-text { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.ic.flip { transform: rotate(180deg); }

.dp { position: fixed; z-index: 1200; width: 268px; padding: 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-lg, 0 12px 32px rgba(0,0,0,.16)); color: var(--text); font-size: 13px; user-select: none; }
.dp-head { display: flex; align-items: center; gap: 2px; margin-bottom: 6px; }
.dp-title { display: inline-flex; align-items: center; gap: 4px; height: 30px; padding: 0 8px; border: 0; border-radius: 7px; background: none; color: var(--text); font-weight: 650; font-size: 14px; cursor: pointer; }
.dp-title:hover { background: var(--bg); }
.dp-title .ic { width: 14px; height: 14px; color: var(--muted); }
.dp-nav { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border: 0; border-radius: 7px; background: none; color: var(--muted); cursor: pointer; }
.dp-nav:hover { background: var(--bg); color: var(--text); }
.dp-nav .ic { width: 16px; height: 16px; }
.dp-week, .dp-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.dp-week span { text-align: center; font-size: 11px; font-weight: 600; color: var(--muted); padding: 4px 0; }
.dp-day { height: 32px; border: 0; border-radius: 8px; background: none; color: var(--text); font-size: 13px; font-variant-numeric: tabular-nums; cursor: pointer; }
.dp-day:hover { background: var(--bg); }
.dp-day.we { color: color-mix(in srgb, var(--text) 70%, var(--danger)); }
.dp-day.out { color: var(--muted); opacity: .5; }
.dp-day.today { box-shadow: inset 0 0 0 1.5px var(--accent); font-weight: 650; }
.dp-day.on { background: var(--accent); color: var(--accent-ink); font-weight: 700; box-shadow: none; opacity: 1; }
.dp-months { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; padding: 4px 0; }
.dp-month { height: 40px; border: 0; border-radius: 8px; background: none; color: var(--text); text-transform: capitalize; cursor: pointer; }
.dp-month:hover { background: var(--bg); }
.dp-month.today { box-shadow: inset 0 0 0 1.5px var(--accent); }
.dp-month.on { background: var(--accent); color: var(--accent-ink); font-weight: 700; }
.dp-foot { display: flex; align-items: center; margin-top: 8px; padding: 8px 4px 0; border-top: 1px solid var(--line); }
.dp-foot .muted-link { color: var(--muted); }

/* ---- «+ Создать» у Ф.И.О. работника: добавить по ПИНФЛ */
.fld.has-add { position: relative; }
.fld-add { position: absolute; top: -3px; right: 0; display: inline-flex; align-items: center; gap: 3px; height: 20px; padding: 0 7px; border: 0; border-radius: 6px; background: none; color: var(--accent-text); font-size: 11.5px; font-weight: 650; cursor: pointer; }
.fld-add:hover, .fld-add.on { background: var(--accent-soft); }
.fld-add .ic { width: 12px; height: 12px; }
.person-new { display: flex; flex-direction: column; gap: 4px; margin-top: 4px; padding: 8px; border: 1px dashed color-mix(in srgb, var(--accent) 55%, var(--line)); border-radius: 8px; background: var(--panel-2); }
.person-new[hidden] { display: none; }
.person-row { display: flex; gap: 6px; }
.person-row input { flex: 1; min-width: 0; font: 13px ui-monospace, Menlo, monospace; letter-spacing: .04em; }
.person-row .btn.sm { height: 34px; }
.person-msg { font-size: 12px; color: var(--muted); }
.person-msg:empty { display: none; }

/* ---- справочник должностей и подсказки при вводе */
.pos-filters { margin: -4px 0 12px; }
.pos-list td.more-cell { text-align: center; padding: 12px; }
.sug { position: fixed; z-index: 1200; max-height: 300px; overflow-y: auto; padding: 4px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow-lg); }
.sug-item { display: flex; flex-direction: column; gap: 1px; width: 100%; padding: 6px 9px; border: 0; border-radius: 7px; background: none; color: var(--text); text-align: left; cursor: pointer; font-size: 13px; line-height: 1.3; }
.sug-item small { font-size: 11.5px; color: var(--muted); }
.sug-item:hover, .sug-item.on { background: var(--accent-soft); }
.pos-list .badge { white-space: nowrap; }

/* ---- каталог: прокручивается только список документов (и, при нехватке места, левая колонка) */
@media (min-width: 901px) {
  .catalog-page { height: 100%; display: flex; flex-direction: column; padding-bottom: 16px; }
  .catalog-page .catalog { flex: 1; min-height: 0; align-items: stretch; }
  .catalog-page .subnav { position: static; overflow-y: auto; min-height: 0; padding-bottom: 8px; }
  .catalog-page .catalog-main { min-height: 0; overflow-y: auto; padding: 2px 4px 8px 2px; }
}
