/* Переводческая коллегия Бахаи — стиль сайта и админки */
:root {
    --ink: #23303e;
    --ink-soft: #5a6a7a;
    --navy: #17324f;
    --navy-hover: #24466b;
    --gold: #b08a3e;
    --gold-soft: #d9c49a;
    --paper: #faf7f1;
    --card: #ffffff;
    --line: #e7e0d3;
    --line-strong: #d6cbb7;
    --danger: #b23b3b;
    --ok: #2e7d4f;
    --warn: #8a6416;
    --radius: 12px;
    --shadow: 0 1px 2px rgba(23, 50, 79, 0.05), 0 4px 14px rgba(23, 50, 79, 0.05);
    --focus: 0 0 0 3px rgba(176, 138, 62, 0.35);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { font-size: 17px; -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    color: var(--ink);
    background: var(--paper);
    font-family: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.6;
}
h1, h2, h3, .brand-text { font-family: Georgia, "Times New Roman", serif; color: var(--navy); }
h1 { font-size: 1.7rem; margin: 0.2em 0 0.6em; font-weight: 600; line-height: 1.25; }
h2 { font-size: 1.25rem; margin: 1.4em 0 0.5em; font-weight: 600; }
a { color: var(--navy); text-underline-offset: 2px; }
a:hover { color: var(--gold); }
button, input, select, textarea { font: inherit; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 6px; }
.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.skip-link {
    position: absolute; left: 12px; top: -48px; background: var(--navy); color: #fff;
    padding: 8px 14px; border-radius: 8px; z-index: 100;
}
.skip-link:focus { top: 12px; }
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 22px; }
.hint { color: var(--ink-soft); font-size: 0.85rem; }
.empty-note { color: var(--ink-soft); font-style: italic; }
.doc-meta { color: var(--ink-soft); font-size: 0.88rem; }
code { background: #f1ece0; padding: 1px 6px; border-radius: 4px; font-size: 0.9em; }

/* ---------- Кнопки и теги ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    background: var(--navy); color: #fff; border: 1px solid var(--navy);
    padding: 9px 18px; border-radius: 8px; text-decoration: none; font-size: 0.95rem;
    cursor: pointer; line-height: 1.3; transition: background-color 150ms, border-color 150ms;
}
.btn:hover { background: var(--navy-hover); color: #fff; }
.btn:focus-visible { box-shadow: var(--focus); }
.btn-ghost { background: var(--card); color: var(--navy); border-color: var(--line-strong); }
.btn-ghost:hover { background: var(--paper); color: var(--navy); border-color: var(--gold-soft); }
.btn-small { padding: 5px 12px; font-size: 0.85rem; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.7; cursor: wait; }
.link-danger { background: none; border: none; color: var(--danger); cursor: pointer; font-size: 0.85rem; padding: 0; text-decoration: underline; }
.tag {
    display: inline-block; font-size: 0.74rem; background: #eef2f6; border-radius: 999px;
    padding: 2px 9px; color: var(--navy); margin: 2px 4px 2px 0; white-space: nowrap;
}
.tag-secret { background: #f7ecd9; color: var(--warn); }
.tag-warn { background: #fbeee6; color: #9a4b1d; }
.alert { padding: 10px 16px; border-radius: 10px; font-size: 0.95rem; margin: 14px 0; }
.alert-ok { background: #e9f4ec; color: var(--ok); border: 1px solid #cde5d4; }
.alert-error { background: #f9eaea; color: var(--danger); border: 1px solid #eccaca; }

/* ---------- Публичный сайт: шапка и подвал ---------- */
.site-header { background: rgba(255, 255, 255, 0.92); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; backdrop-filter: blur(6px); }
.header-inner { display: flex; align-items: center; flex-wrap: wrap; gap: 12px 18px; padding-top: 12px; padding-bottom: 12px; }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; }
.brand:hover { color: inherit; }
.star { width: 40px; height: 40px; color: var(--gold); flex: none; }
.star.small { width: 22px; height: 22px; }
.star.big { width: 72px; height: 72px; }
.brand-text { font-size: 1.15rem; letter-spacing: 0.02em; }
.main-nav { margin-left: auto; }
.main-nav ul { display: flex; gap: 2px; list-style: none; margin: 0; padding: 0; flex-wrap: wrap; }
.main-nav a {
    display: block; padding: 8px 14px; text-decoration: none; border-radius: 8px;
    color: var(--ink-soft); font-size: 0.95rem;
}
.main-nav a:hover { background: var(--paper); color: var(--navy); }
.main-nav a.active { color: var(--navy); font-weight: 600; box-shadow: inset 0 -2px 0 var(--gold); border-radius: 0; }
.main-content { padding: 32px 22px 64px; min-height: 60vh; }
.site-footer { border-top: 1px solid var(--line); background: var(--card); margin-top: 30px; }
.footer-inner { display: flex; align-items: center; gap: 10px; padding-top: 18px; padding-bottom: 18px; color: var(--ink-soft); font-size: 0.9rem; }

/* ---------- Главная и страницы ---------- */
.hero { text-align: center; padding: 30px 0 10px; }
.hero h1 { font-size: 2.1rem; margin-top: 14px; }
.home-body { max-width: 720px; margin: 0 auto; font-size: 1.05rem; }
.home-recent { max-width: 720px; margin: 30px auto 0; border-top: 1px solid var(--line); padding-top: 8px; }
.recent-list { padding-left: 20px; }
.recent-list li { margin: 6px 0; }
.page-body { max-width: 780px; }
.prose p { margin: 0.8em 0; }
.prose img { max-width: 100%; height: auto; border-radius: 10px; display: block; margin: 1em auto; }
.prose blockquote { border-left: 3px solid var(--gold-soft); margin: 1em 0; padding: 0.2em 1em; color: var(--ink-soft); font-style: italic; }
.prose .ql-align-center { text-align: center; }
.prose .ql-align-right { text-align: right; }
.prose .ql-align-justify { text-align: justify; }
.prose .ql-size-small { font-size: 0.85em; }
.prose .ql-size-large { font-size: 1.35em; }
.prose .ql-size-huge { font-size: 1.7em; }
.prose .ql-indent-1 { padding-left: 3em; }
.prose .ql-indent-2 { padding-left: 6em; }
.empty-state { max-width: 560px; margin: 40px auto; text-align: center; }

/* ---------- Каталог ---------- */
.catalog-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 14px; margin-bottom: 6px; }
.catalog-head h1 { margin-bottom: 0; }
.catalog-tools { display: flex; gap: 10px; flex-wrap: wrap; }
.search-field input, .sort-field select {
    height: 42px; padding: 0 14px; border: 1px solid var(--line-strong); border-radius: 10px;
    background: var(--card); color: var(--ink); min-width: 240px;
}
.sort-field select { min-width: 0; }
.search-field input:focus, .sort-field select:focus { border-color: var(--gold); box-shadow: var(--focus); outline: none; }
.cat-bar { display: flex; flex-wrap: wrap; gap: 8px; margin: 18px 0 8px; }
.cat-chip {
    border: 1px solid var(--line); background: var(--card); border-radius: 999px;
    padding: 6px 15px; text-decoration: none; color: var(--ink-soft); font-size: 0.9rem;
}
.cat-chip:hover { border-color: var(--gold-soft); color: var(--navy); }
.cat-chip.active { border-color: var(--navy); background: var(--navy); color: #fff; }
.cat-chip .cnt { opacity: 0.7; font-size: 0.82rem; margin-left: 2px; }
.cat-group { margin-top: 14px; }
.cat-heading { margin: 1.2em 0 0.6em; border-bottom: 1px solid var(--line); padding-bottom: 6px; font-size: 1.15rem; }
.doc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.doc-card {
    display: flex; gap: 14px; background: var(--card); border: 1px solid var(--line);
    border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow);
    transition: border-color 150ms, transform 150ms;
}
.doc-card:hover { border-color: var(--gold-soft); transform: translateY(-1px); }
.doc-card-icon {
    flex: none; width: 46px; height: 58px; border: 1.5px solid var(--gold); border-radius: 6px;
    color: var(--gold); font-size: 0.72rem; font-weight: 700; display: flex; align-items: center;
    justify-content: center; letter-spacing: 0.05em; background: #fffdf8;
}
.doc-card-body { min-width: 0; display: flex; flex-direction: column; flex: 1; }
.doc-card-title { font-weight: 600; text-decoration: none; display: block; margin-bottom: 4px; line-height: 1.35; overflow-wrap: anywhere; }
.doc-card-desc { margin: 2px 0 6px; color: var(--ink-soft); font-size: 0.88rem; }
.doc-card-meta { font-size: 0.82rem; color: var(--ink-soft); margin-top: auto; }
.doc-card-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }

/* ---------- Просмотр документа ---------- */
.viewer-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 14px; margin-bottom: 10px; }
.viewer-titles { min-width: 0; flex: 1; }
.viewer-titles h1 { margin: 4px 0 2px; font-size: 1.5rem; overflow-wrap: anywhere; }
.crumb { font-size: 0.9rem; text-decoration: none; color: var(--ink-soft); }
.viewer-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.doc-desc { max-width: 760px; color: var(--ink-soft); margin: 4px 0 0; }
.pdf-frame { margin-top: 16px; background: #e9e4d8; border-radius: var(--radius); overflow: hidden; }
.pdf-frame iframe { display: block; width: 100%; height: 80vh; min-height: 420px; border: 0; background: #fff; }
.pdf-frame:fullscreen { background: #000; border-radius: 0; }
.pdf-frame:fullscreen iframe { height: 100vh; min-height: 0; }
.pdf-fallback { font-size: 0.88rem; color: var(--ink-soft); padding: 10px 14px; margin: 0; background: var(--card); }

/* ---------- Админка: каркас ---------- */
.admin-body { background: #f4f1ea; }
.admin-topbar { background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 30; }
.admin-topbar-inner { max-width: 1280px; margin: 0 auto; padding: 10px 22px; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.admin-badge { color: var(--gold); font-size: 0.85rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }
.admin-topbar-actions { margin-left: auto; display: flex; gap: 8px; }
.admin-layout { max-width: 1280px; margin: 0 auto; display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 28px; padding: 24px 22px 60px; align-items: start; }
.admin-nav { position: sticky; top: 74px; }
.admin-nav ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.admin-nav a {
    display: block; padding: 9px 14px; border-radius: 8px; text-decoration: none; color: var(--ink-soft);
}
.admin-nav a:hover { background: #ece6d8; color: var(--navy); }
.admin-nav a.active { background: var(--navy); color: #fff; }
.admin-main { min-width: 0; }
.admin-main h1 { margin-top: 0; }
.admin-main > .alert { margin-top: 0; }
.table-wrap { overflow-x: auto; border-radius: var(--radius); background: var(--card); box-shadow: var(--shadow); border: 1px solid var(--line); margin: 10px 0 24px; }

/* Карточки статистики */
.stat-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; margin: 16px 0 22px; }
.stat-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); }
.stat-card b { display: block; font-size: 2rem; color: var(--navy); font-family: Georgia, serif; line-height: 1.1; }
.stat-card span { color: var(--ink-soft); font-size: 0.85rem; }
.quick-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; }

/* Панели и формы */
.panel {
    background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 20px 22px; margin: 14px 0 22px; box-shadow: var(--shadow);
}
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 4px 20px; }
.form-grid > .panel-section, .form-grid > fieldset { grid-column: 1 / -1; }
.form-grid > textarea, .form-grid > label:has(textarea) { grid-column: 1 / -1; }
.form-actions { grid-column: 1 / -1; margin-top: 12px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.panel label, .form-grid label { display: block; margin: 10px 0 4px; font-size: 0.9rem; color: var(--ink-soft); }
.panel label.chk, .form-grid label.chk { display: flex; align-items: center; gap: 8px; color: var(--ink); margin: 6px 0; }
.panel input[type=text], .panel input[type=password], .panel input[type=number], .panel input[type=search],
.panel input[type=email], .panel select, .panel textarea,
.login-card input, .toolbar input {
    width: 100%; max-width: 560px; padding: 9px 12px; border: 1px solid var(--line-strong); border-radius: 8px;
    background: #fff; color: var(--ink); margin-top: 3px;
}
.panel input:focus, .panel select:focus, .panel textarea:focus, .login-card input:focus, .toolbar input:focus {
    border-color: var(--gold); box-shadow: var(--focus); outline: none;
}
.panel textarea { max-width: 100%; }
.panel input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--navy); }
.panel-inline { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.panel-inline input[type=text], .panel-inline select { width: auto; min-width: 200px; margin-top: 0; }
.panel-inline button { margin-top: 0; }
.w80 { width: 84px !important; min-width: 0 !important; }
.perm-fieldset { border: 1px solid var(--line); border-radius: 10px; padding: 8px 14px 12px; margin: 14px 0; }
.perm-fieldset legend { padding: 0 6px; color: var(--ink-soft); font-size: 0.9rem; }
.code-input { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 0.85rem; width: 100%; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 12px 0 0; }
.toolbar .hint { margin-left: auto; }
.search-input { max-width: 340px; }
.upload-panel summary { cursor: pointer; font-weight: 600; color: var(--navy); padding: 4px 0; }
.upload-panel[open] summary { margin-bottom: 12px; }

/* Зона перетаскивания PDF и изображений */
.drop-zone {
    position: relative; display: flex; align-items: center; gap: 16px; margin: 14px 0 6px;
    padding: 22px; border: 1.5px dashed var(--gold-soft); border-radius: var(--radius);
    background: #fcfaf6; color: var(--navy); cursor: pointer; grid-column: 1 / -1;
    transition: background-color 180ms ease-out, border-color 180ms ease-out, transform 180ms ease-out;
}
.drop-zone:hover, .drop-zone.is-dragover { border-color: var(--gold); background: #f8f2e7; }
.drop-zone.is-dragover { transform: scale(1.005); }
.drop-zone:focus-visible { outline: none; box-shadow: var(--focus); }
.drop-zone.has-file { border-color: var(--ok); background: #f2f8f3; }
.drop-zone.has-error { border-color: var(--danger); background: #fcf2f2; }
.drop-zone-compact { padding: 16px 20px; cursor: default; }
.drop-zone-icon { width: 42px; height: 42px; flex: none; color: var(--gold); }
.drop-zone-copy { display: flex; flex-direction: column; min-width: 0; }
.drop-zone-copy strong { font-size: 1rem; }
.drop-zone-copy > span:not(.drop-zone-file-info) { color: var(--ink-soft); font-size: 0.86rem; }
.drop-zone-file-info { display: block; margin-top: 6px; color: var(--navy); font-size: 0.88rem; font-weight: 600; overflow-wrap: anywhere; }
.drop-zone.has-error .drop-zone-file-info { color: var(--danger); }
.drop-zone-file { display: block; margin-top: 12px; }
.drop-zone.is-enhanced .drop-zone-file { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.drop-zone-compact .btn { cursor: pointer; }
@media (prefers-reduced-motion: reduce) {
    .drop-zone, .doc-card, .btn { transition: none; }
}

/* Пояснение к правам просмотра */
.flag-note { margin: 8px 0 0; padding: 10px 12px; border-radius: 8px; background: #f7f1e3; color: #6b5420; font-size: 0.86rem; line-height: 1.5; border: 1px solid #ecdcb2; }
.flag-note.flash { animation: flagFlash 1.4s ease-out; }
@keyframes flagFlash { 0% { box-shadow: 0 0 0 4px rgba(176, 138, 62, 0.45); } 100% { box-shadow: 0 0 0 0 transparent; } }

/* Секретный документ: страницы-изображения */
/* ---------- Постраничный просмотр секретного документа ---------- */
.sv { margin-top: 18px; user-select: none; -webkit-user-select: none; background: var(--card); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); overflow: hidden; }
.sv-top { padding: 12px 14px 0; }
.sv-bottom { padding: 6px 14px 14px; border-top: 1px solid var(--line); }
.sv-bottom .sv-bar { padding-top: 10px; }
.sv-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 10px; padding: 10px 0 12px; }
.sv-btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line-strong); background: #fff; color: var(--navy); font: inherit; font-size: 0.92rem; cursor: pointer; transition: border-color 0.15s, background 0.15s; }
.sv-btn:hover:not(:disabled) { border-color: var(--navy); }
.sv-btn:disabled { opacity: 0.4; cursor: default; }
.sv-btn-primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.sv-btn-primary:hover:not(:disabled) { background: var(--navy); border-color: var(--gold); }
.sv-btn:focus-visible, .sv-goto input:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.sv-icon { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.sv-goto { display: inline-flex; align-items: center; gap: 8px; font-size: 0.92rem; color: var(--ink-soft); }
.sv-goto input { width: 4.6em; padding: 7px 8px; font: inherit; font-weight: 600; text-align: center; color: var(--ink); background: #fff; border: 1px solid var(--line-strong); border-radius: 10px; }
.sv-goto-total { white-space: nowrap; }
.sv-progress { height: 4px; background: var(--line); border-radius: 999px; overflow: hidden; }
.sv-progress span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--gold), var(--navy)); transition: width 0.25s ease; }
.sv-stage { position: relative; min-height: 60vh; display: flex; align-items: center; justify-content: center; padding: 24px; background-color: #e9e5dc; background-image: radial-gradient(#d6d0c1 1px, transparent 1px); background-size: 14px 14px; }
.sv-stage img { display: block; width: auto; height: auto; max-width: 100%; max-height: 82vh; border-radius: 4px; background: #fff; box-shadow: 0 10px 30px rgba(20, 30, 50, 0.25); -webkit-user-drag: none; transition: opacity 0.2s ease; }
.sv-stage.is-loading img { opacity: 0.55; }
.sv-status { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); margin: 0; padding: 10px 16px; border-radius: 999px; background: rgba(255, 255, 255, 0.95); color: var(--ink-soft); font-size: 0.9rem; box-shadow: var(--shadow); white-space: nowrap; }
.sv-status[hidden] { display: none; }
.sv-hint { margin: 10px 0 0; text-align: center; font-size: 0.82rem; color: var(--ink-soft); }
.sv-badge { display: inline-block; padding: 2px 10px; border-radius: 999px; background: #f7ecd9; color: var(--warn); font-size: 0.8rem; font-weight: 600; }
.sv:fullscreen { display: flex; flex-direction: column; background: #111; border: 0; border-radius: 0; box-shadow: none; }
.sv:fullscreen .sv-top, .sv:fullscreen .sv-bottom { background: #1b1f27; border-color: #2c3340; }
.sv:fullscreen .sv-goto { color: #d7dbe3; }
.sv:fullscreen .sv-goto input { color: #f2f2f2; background: #222831; border-color: #3a4150; }
.sv:fullscreen .sv-btn { background: #222831; color: #e8e8e8; border-color: #3a4150; }
.sv:fullscreen .sv-btn-primary { background: var(--gold); border-color: var(--gold); color: #1b1f27; }
.sv:fullscreen .sv-progress { background: #2c3340; }
.sv:fullscreen .sv-stage { flex: 1 1 auto; min-height: 0; padding: 12px; background-color: #111; background-image: none; }
.sv:fullscreen .sv-stage img { max-height: calc(100vh - 190px); box-shadow: none; }
.sv:fullscreen .sv-hint { color: #9aa3b2; }
.sv-zoom { display: inline-flex; align-items: center; gap: 6px; }
.sv-btn-icon { padding: 8px 12px; }
.sv-zoom-label { min-width: 8.5em; justify-content: center; }
.sv-stage.is-zoomed { display: block; overflow: auto; height: 78vh; padding: 12px; }
.sv-stage.is-zoomed img { margin: 0 auto; max-height: none; }
.sv:fullscreen .sv-stage.is-zoomed { display: block; height: auto; flex: 1 1 auto; min-height: 0; }
@media (max-width: 640px) {
    .sv-btn span, .sv-goto-label, .sv-hint { display: none; }
    .sv-stage { min-height: 50vh; padding: 12px; }
}

/* Таблицы */
.tbl { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.tbl th { text-align: left; color: var(--ink-soft); font-weight: 600; background: #faf8f3; border-bottom: 1px solid var(--line); padding: 10px 12px; white-space: nowrap; font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.03em; }
.tbl td { border-bottom: 1px solid var(--line); padding: 10px 12px; vertical-align: top; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover td { background: #fbf9f4; }
.tbl input[type=text], .tbl input[type=number] { padding: 5px 8px; border: 1px solid var(--line-strong); border-radius: 6px; width: 100%; }
.row-actions { white-space: nowrap; }
.row-actions a { font-size: 0.87rem; }
.inline { display: inline; }
.ua-cell { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.78rem; color: var(--ink-soft); }
.link-cell { min-width: 280px; }
.copy-row { display: flex; gap: 8px; align-items: center; }
.link-url { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 0.75rem; min-width: 0; flex: 1; padding: 5px 8px; border: 1px solid var(--line-strong); border-radius: 6px; background: #fbfaf7; }

/* Период и график статистики */
.period-tabs { display: inline-flex; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 2px; margin: 4px 0 14px; flex-wrap: wrap; }
.period-tab { padding: 6px 14px; border-radius: 8px; text-decoration: none; color: var(--ink-soft); font-size: 0.9rem; }
.period-tab.active { background: var(--navy); color: #fff; }
.chart { display: flex; align-items: flex-end; gap: 3px; height: 180px; padding: 10px 6px 0; border-bottom: 1px solid var(--line); }
.chart-col { flex: 1; min-width: 4px; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; position: relative; }
.chart-bar { width: 100%; max-width: 28px; background: linear-gradient(to top, var(--navy), #3d6a96); border-radius: 4px 4px 0 0; min-height: 0; }
.chart-col:hover .chart-bar { background: var(--gold); }
.chart-label { position: absolute; bottom: -22px; font-size: 0.7rem; color: var(--ink-soft); white-space: nowrap; }
.chart + .chart, section .chart { margin-bottom: 26px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); gap: 22px; }
.grid-2 section { min-width: 0; }

/* Редактор страниц (Quill) */
.editor-label { margin-top: 14px; }
.editor-shell { background: #fff; border-radius: 10px; border: 1px solid var(--line-strong); overflow: hidden; margin-top: 6px; }
.editor-shell .ql-toolbar.ql-snow { border: 0; border-bottom: 1px solid var(--line); background: #fbfaf7; }
.editor-shell .ql-container.ql-snow { border: 0; font-size: 1rem; }
.editor-shell .ql-editor { min-height: 340px; padding: 18px 22px; }
.editor-shell .ql-editor img { max-width: 100%; height: auto; border-radius: 6px; }
.ql-snow .ql-picker-label { color: var(--ink); }
.ql-snow .ql-stroke { stroke: var(--ink-soft); }

/* Медиатека */
.media-library { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; margin-top: 14px; }
.media-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); display: flex; flex-direction: column; }
.media-thumb { aspect-ratio: 4 / 3; background: repeating-conic-gradient(#f3efe6 0% 25%, #fff 0% 50%) 50% / 16px 16px; display: flex; align-items: center; justify-content: center; }
.media-thumb img { max-width: 100%; max-height: 100%; object-fit: contain; }
.media-meta { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 4px; font-size: 0.85rem; min-width: 0; }
.media-meta strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.media-actions { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 6px; flex-wrap: wrap; }
.media-dialog { border: 0; border-radius: var(--radius); padding: 0; width: min(880px, 94vw); max-height: 88vh; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25); }
.media-dialog::backdrop { background: rgba(23, 50, 79, 0.45); }
.media-dialog-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: #fff; }
.media-dialog-head h2 { margin: 0; font-size: 1.1rem; }
.media-dialog-upload { padding: 12px 18px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.media-dialog .media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; padding: 0 18px 18px; overflow-y: auto; max-height: 60vh; }
.media-pick { border: 2px solid transparent; border-radius: 10px; padding: 4px; background: #faf8f3; cursor: pointer; aspect-ratio: 4 / 3; }
.media-pick:hover, .media-pick:focus-visible { border-color: var(--gold); }
.media-pick img { width: 100%; height: 100%; object-fit: contain; display: block; }

/* Технические шаблоны */
.template-tabs { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; margin: 16px 0; }
.template-tab { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--card); text-decoration: none; color: var(--navy); }
.template-tab span { color: var(--ink-soft); font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 0.75rem; }
.template-tab:hover { border-color: var(--gold); }
.template-tab.active { border-color: var(--navy); box-shadow: inset 0 0 0 1px var(--navy); }
.template-editor-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.template-editor-head h2 { margin-top: 0; }
.template-editor-head p { margin-top: 0; }
.code-editor { display: grid; grid-template-columns: 52px minmax(0, 1fr); overflow: hidden; border: 1px solid var(--line-strong); border-radius: 10px; background: #f7f8fa; margin-top: 12px; }
.code-editor-lines { padding: 14px 12px; overflow: hidden; white-space: pre; text-align: right; user-select: none; color: #7a8591; background: #eef1f4; border-right: 1px solid #dce1e6; font: 0.85rem/1.55 ui-monospace, Menlo, Consolas, monospace; }
.code-editor .code-input { min-height: 520px; height: 60vh; max-width: none; margin: 0; padding: 14px 16px; border: 0; border-radius: 0; resize: vertical; white-space: pre; overflow: auto; line-height: 1.55; tab-size: 4; background: #fff; }
.code-editor .code-input:focus { box-shadow: inset var(--focus); }
.template-placeholders { margin: 12px 0; color: var(--ink-soft); }
.template-placeholders summary { cursor: pointer; }
.template-placeholders div { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }

/* Выбор логотипа */
.site-logo-image { display: block; object-fit: contain; }
.logo-editor { display: flex; align-items: center; gap: 22px; margin: 16px 0; }
.logo-preview { width: 140px; height: 140px; flex: none; display: grid; place-items: center; padding: 18px; border: 1px solid var(--line); border-radius: 12px; background: repeating-conic-gradient(#f3efe6 0% 25%, #fff 0% 50%) 50% / 16px 16px; }
.logo-controls { min-width: 0; flex: 1; }
.logo-controls > strong { display: block; overflow-wrap: anywhere; }
.logo-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.logo-actions label { cursor: pointer; }

/* ---------- Вход ---------- */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; background: radial-gradient(circle at top, #fff 0%, var(--paper) 70%); }
.login-card {
    background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 40px 40px;
    text-align: center; max-width: 420px; width: 100%; box-shadow: var(--shadow);
}
.login-card h1 { font-size: 1.25rem; margin-top: 10px; }
.login-card h2 { font-size: 1rem; color: var(--ink-soft); font-weight: 400; margin-top: 0; }
.login-card form { margin-top: 20px; }
.login-card input { margin-bottom: 14px; text-align: center; max-width: none; }
.login-home { margin-top: 18px; font-size: 0.88rem; }

/* ---------- Адаптивность ---------- */
@media (max-width: 900px) {
    .admin-layout { grid-template-columns: minmax(0, 1fr); gap: 16px; }
    .admin-nav { position: static; min-width: 0; }
    .admin-nav ul { flex-direction: row; overflow-x: auto; padding-bottom: 4px; }
    .admin-nav a { white-space: nowrap; }
    .admin-topbar-actions { margin-left: 0; }
    .main-nav { margin-left: 0; width: 100%; }
    .main-nav ul { overflow-x: auto; flex-wrap: nowrap; }
    .main-nav a { white-space: nowrap; }
    .search-field input { min-width: 0; width: 100%; }
    .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
    html { font-size: 16px; }
    .wrap, .admin-layout, .admin-topbar-inner { padding-left: 16px; padding-right: 16px; }
    .main-content { padding: 22px 16px 48px; }
    .drop-zone { padding: 18px 14px; gap: 12px; }
    .drop-zone-icon { width: 34px; height: 34px; }
    .doc-grid { grid-template-columns: 1fr; }
    .pdf-frame iframe { height: 70vh; min-height: 320px; }
    .login-card { padding: 30px 22px; }
    .chart-label { display: none; }
    .template-tabs { grid-template-columns: 1fr; }
    .template-editor-head { flex-direction: column; }
    .code-editor { grid-template-columns: 42px minmax(0, 1fr); }
    .code-editor .code-input { min-height: 400px; }
    .logo-editor { flex-direction: column; align-items: flex-start; }
}

/* Капча на входе в админку */
.captcha-row { display: flex; align-items: center; gap: 12px; margin: 8px 0; }
.captcha-img { display: block; border-radius: 8px; border: 1px solid var(--line); background: #f5f2eb; }
.captcha-refresh { font-size: 0.88rem; }
