:root {
  --bg: #f4f6f9;
  --panel: #ffffff;
  --text: #1d2433;
  --muted: #6b7489;
  --line: #e3e7ee;
  --accent: #1f7a5c;
  --accent-soft: #e3f3ec;
  --warn: #b7791f;
  --warn-soft: #fdf3e1;
  --danger: #c0392b;
  --danger-soft: #fbe9e7;
  --sidebar: #17322a;
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12161d; --panel: #1b212b; --text: #e6e9ef; --muted: #98a1b3;
    --line: #2b3340; --accent: #3fb68b; --accent-soft: #1d3a30;
    --warn: #e0a64a; --warn-soft: #3a2f1c; --danger: #e46a5c; --danger-soft: #3b211e;
    --sidebar: #0e1f1a;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg); color: var(--text);
}
.app { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
  width: 220px; flex-shrink: 0; background: var(--sidebar); color: #cfe3da;
  display: flex; flex-direction: column; padding: 20px 12px;
  position: sticky; top: 0; height: 100vh;
}
.logo { font-size: 24px; font-weight: 700; color: #fff; padding: 0 10px 20px; }
.logo span { color: #6fd3a8; }
nav a {
  display: block; padding: 9px 12px; border-radius: 8px; color: inherit;
  text-decoration: none; margin-bottom: 2px;
}
nav a:hover { background: rgba(255,255,255,.07); }
nav a.active { background: rgba(111,211,168,.18); color: #fff; font-weight: 600; }
.sidebar-foot { margin-top: auto; font-size: 12px; opacity: .6; padding: 0 10px; }

main { flex: 1; padding: 28px 32px 60px; min-width: 0; max-width: 1200px; }
h1 { font-size: 24px; margin: 0 0 20px; }
h2 { font-size: 17px; margin: 0 0 12px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head h1 { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* Cards */
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); margin-bottom: 20px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.card .label { color: var(--muted); font-size: 13px; }
.card .value { font-size: 24px; font-weight: 700; margin: 4px 0; font-variant-numeric: tabular-nums; }
.card.accent { border-left: 4px solid var(--accent); }
.card.warn { border-left: 4px solid var(--warn); background: var(--warn-soft); }
.progress { height: 8px; background: var(--line); border-radius: 4px; overflow: hidden; margin-top: 8px; }
.progress > div { height: 100%; background: var(--accent); }
.progress.hot > div { background: var(--danger); }

/* Tables */
.table-wrap { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; background: var(--bg); }
tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.annulled td { opacity: .5; text-decoration: line-through; }
tr.annulled td.actions { text-decoration: none; opacity: 1; }
td.actions { white-space: nowrap; text-align: right; }
.empty { padding: 40px; text-align: center; color: var(--muted); }

/* Badges */
.badge { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 12px; font-weight: 600; background: var(--line); color: var(--muted); }
.badge.ok { background: var(--accent-soft); color: var(--accent); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }

/* Buttons & forms */
button, .btn {
  font: inherit; cursor: pointer; border: 1px solid var(--line); background: var(--panel);
  color: var(--text); padding: 8px 14px; border-radius: 8px; text-decoration: none; display: inline-block;
}
button:hover, .btn:hover { border-color: var(--muted); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.primary:hover { filter: brightness(1.08); }
button.danger { color: var(--danger); }
button.link { border: none; background: none; padding: 4px 6px; color: var(--accent); }
button.link.danger { color: var(--danger); }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }

label { display: block; margin-bottom: 12px; }
label > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
input, select, textarea {
  font: inherit; width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--panel); color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.toolbar input, .toolbar select { width: auto; }
.row { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
.row3 { display: grid; gap: 12px; grid-template-columns: 1fr 1fr 1fr; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.hint { background: var(--accent-soft); border-radius: 8px; padding: 10px 12px; font-size: 13px; margin-bottom: 12px; }
.hint.warn { background: var(--warn-soft); }

.items-table td { padding: 4px; border: none; }
.items-table input { padding: 6px 8px; }

/* Modal */
.modal { position: fixed; inset: 0; background: rgba(10,15,25,.5); display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow-y: auto; z-index: 50; }
.modal.hidden { display: none; }
.modal-box { background: var(--panel); border-radius: 12px; padding: 24px; width: 100%; max-width: 560px; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal-box.wide { max-width: 760px; }

#toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(calc(100% + 40px));
  background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 8px; transition: transform .25s, visibility .25s; z-index: 60;
  visibility: hidden; max-width: calc(100vw - 32px);
}
#toast.show { transform: translateX(-50%) translateY(0); visibility: visible; }

/* Chart */
.chart { width: 100%; height: 200px; }
.chart text { fill: var(--muted); font-size: 11px; }
.chart .bar { fill: var(--accent); }
.chart .bar.cur { fill: var(--warn); }

.hidden { display: none !important; }
a { color: var(--accent); }

/* Login */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px;
  background: linear-gradient(160deg, var(--sidebar) 0%, var(--sidebar) 40%, var(--bg) 40%); }
.login-box { background: var(--panel); border-radius: 14px; padding: 32px; width: 100%; max-width: 420px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.login-logo { font-size: 30px; font-weight: 800; margin-bottom: 6px; }
.login-logo span { color: var(--accent); }
.tabs { display: flex; gap: 4px; background: var(--bg); padding: 4px; border-radius: 10px; margin-bottom: 16px; }
.tabs button { flex: 1; border: none; background: none; padding: 8px; border-radius: 8px; color: var(--muted); }
.tabs button.active { background: var(--panel); color: var(--text); font-weight: 600; box-shadow: 0 1px 3px rgba(0,0,0,.1); }
code { background: var(--bg); padding: 1px 5px; border-radius: 4px; }
.sidebar-foot .user-name { font-weight: 600; color: #fff; font-size: 13px; opacity: 1; }
.sidebar-foot { opacity: .85; }
.sidebar-foot button.link { color: #6fd3a8; padding: 4px 0; }
a.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }

/* Print */
#print-area { display: none; }
@media print {
  body.printing .app, body.printing .modal, body.printing #toast { display: none !important; }
  body.printing #print-area { display: block; }
  body { background: #fff; color: #000; }
}
.doc { font-family: "Times New Roman", serif; color: #000; font-size: 14px; max-width: 760px; margin: 0 auto; }
.doc h1 { font-size: 20px; text-align: center; margin: 20px 0; }
.doc table { border-collapse: collapse; width: 100%; margin: 10px 0; }
.doc th, .doc td { border: 1px solid #000; padding: 6px 8px; background: none; color: #000; text-transform: none; font-size: 13px; letter-spacing: 0; }
.doc .bank td { font-size: 13px; }
.doc .noborder td { border: none; padding: 2px 0; }
.doc .sign { display: flex; justify-content: space-between; margin-top: 40px; gap: 40px; }
.doc .sig { flex: 1; }
.doc .sig-line { height: 64px; border-bottom: 1px solid #000; position: relative; }
.doc .sig-line img.facsimile { position: absolute; left: 12%; bottom: -14px; max-height: 78px; max-width: 76%; }
.doc .sig-label { font-size: 12px; padding-top: 4px; }
.doc.contract h3 { font-size: 15px; margin: 16px 0 6px; }
.doc.contract p { margin: 4px 0; text-align: justify; }
.doc table.parties td { vertical-align: top; width: 50%; font-size: 13px; }
.receipt { font-family: "Courier New", monospace; max-width: 340px; margin: 0 auto; border: 1px dashed #000; padding: 16px; color: #000; font-size: 13px; }
.receipt .c { text-align: center; }
.receipt hr { border: none; border-top: 1px dashed #000; }
.receipt .r { display: flex; justify-content: space-between; gap: 10px; }

@media (max-width: 800px) {
  .app { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; padding: 12px 16px; }
  .logo { padding-bottom: 8px; }
  nav { display: flex; overflow-x: auto; gap: 4px; }
  nav a { white-space: nowrap; }
  .sidebar-foot { margin-top: 8px; display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
  main { padding: 20px 16px 60px; }
  .row, .row3 { grid-template-columns: 1fr; }
}

/* --- v3: уведомления, сохранение, отчёты, QR --- */
.nav-badge { display: inline-block; min-width: 18px; padding: 0 6px; border-radius: 9px; background: #e46a5c; color: #fff; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; margin-left: 4px; }
.alerts h2 { margin-bottom: 8px; }
.alert { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); }
.alert:first-of-type { border-top: none; }
.alert .dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; background: var(--muted); }
.alert.danger .dot { background: var(--danger); }
.alert.warn .dot { background: var(--warn); }
.alert.info .dot { background: var(--accent); }
.alert .txt { flex: 1; }
.alert button { white-space: nowrap; }
.save-status { font-size: 11px; margin-top: 4px; opacity: .8; }
.save-status.error { color: #ffb4a8; opacity: 1; font-weight: 600; }
.save-status.saving, .save-status.pending { opacity: .6; }
label.check { display: flex; gap: 8px; align-items: center; cursor: pointer; }
label.check input { width: auto; margin: 0; }
.bar2 { height: 7px; background: var(--line); border-radius: 4px; overflow: hidden; margin: 2px 0; }
.bar2 > div { height: 100%; border-radius: 4px; }
.bar2 .b1, .legend.b1 { background: var(--accent); }
.bar2 .b2, .legend.b2 { background: var(--muted); opacity: .5; }
.legend { display: inline-block; width: 10px; height: 10px; border-radius: 2px; vertical-align: middle; margin: 0 4px 0 10px; }
td.pos { color: var(--accent); } td.neg { color: var(--danger); }
.doc .qr-block { display: flex; align-items: center; gap: 14px; margin: 16px 0; }
.doc .qr { width: 140px; height: 140px; }
.doc .qr svg { width: 100%; height: 100%; }

/* --- v4: аккаунты, подключение «Мой налог», факсимиле --- */
.nalog-chip { display: block; margin: 6px 0 2px; font-size: 12px; border: none; padding: 0; background: none; text-align: left; }
.nalog-chip.ok { color: #6fd3a8; }
button.nalog-chip.off { color: #ffd38a; cursor: pointer; text-decoration: underline; }
.connect-card { display: flex; gap: 16px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-bottom: 20px; border-left: 4px solid var(--warn); }
.connect-card h2 { margin-bottom: 4px; }
.connect-card p { margin: 0; }
.fax-row { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; }
.fax-preview { width: 260px; height: 110px; border: 1px dashed var(--line); border-radius: 8px; display: flex; align-items: center; justify-content: center;
  background: #fff repeating-conic-gradient(#f1f3f6 0 25%, #fff 0 50%) 0 0 / 16px 16px; }
.fax-preview img { max-width: 92%; max-height: 92%; }
.fax-actions { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.fax-actions label.check { margin: 0; }

/* --- v5: конструктор договоров --- */
.contract-editor { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.ce-form .card { margin-bottom: 16px; }
.ce-preview { position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow: auto; border-radius: var(--radius); border: 1px solid var(--line); background: #e9ecf1; }
.ce-paper { background: #fff; color: #000; margin: 16px; padding: 28px 32px; box-shadow: 0 2px 10px rgba(0,0,0,.12); font-size: 12px; }
.ce-paper .doc { font-size: 12.5px; }
.ce-paper .doc h1 { font-size: 16px; }
.doc .contract-head { display: flex; justify-content: space-between; margin-bottom: 12px; }
.doc p.li { padding-left: 18px; }
.doc mark { background: #ffe08a; color: #000; }
.doc table.items { margin: 6px 0 10px; }
.sec { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; margin-bottom: 8px; background: var(--panel); }
.sec.off { opacity: .55; }
.sec-head { display: flex; align-items: center; gap: 6px; }
.sec-head input[type=checkbox] { width: auto; margin: 0; }
.sec-head .sec-title { flex: 1; border-color: transparent; font-weight: 600; padding: 4px 6px; }
.sec-head .sec-title:hover, .sec-head .sec-title:focus { border-color: var(--line); }
.sec-head button.link { padding: 2px 6px; }
.sec-head button:disabled { opacity: .3; cursor: default; }
.sec textarea { margin-top: 6px; font-size: 13px; line-height: 1.45; }
.sec-snippet { font-size: 12px; color: var(--muted); padding: 2px 6px 0 28px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
details.vars { margin-bottom: 10px; }
details.vars summary { cursor: pointer; font-size: 13px; color: var(--accent); }
.var-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip { font: 12px/1.2 ui-monospace, Consolas, monospace; padding: 4px 8px; border-radius: 14px; background: var(--accent-soft); color: var(--accent); border: none; }
.chip:hover { filter: brightness(.95); }
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; margin-bottom: 8px; }
.tpl-card { border: 1px solid var(--line); border-radius: 8px; padding: 12px; }
.tpl-card.mine { border-color: var(--accent); }
.tpl-card p { margin: 6px 0; }
@media (max-width: 1100px) {
  .contract-editor { grid-template-columns: minmax(0, 1fr); }  /* minmax(0,…): иначе колонка не уже содержимого и форма уезжает за экран */
  .ce-preview { position: static; max-height: none; }
}
@media (max-width: 600px) { .ce-paper { padding: 16px; margin: 8px; } }

/* --- v6: новый клиент внутри формы --- */
.client-pick { display: flex; gap: 8px; }
.client-pick select { flex: 1; min-width: 0; }
.client-pick button { white-space: nowrap; }
.inline-box { border: 1px dashed var(--accent); background: var(--accent-soft); border-radius: 10px; padding: 12px 14px; margin: -4px 0 14px; }
.inline-box-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.inline-box label { margin-bottom: 8px; }
@media (max-width: 600px) { .client-pick { flex-direction: column; } }

/* --- v7: отправка документов --- */
.pdf-holder { position: fixed; left: -10000px; top: 0; width: 186mm; background: #fff; color: #000; }
.pdf-holder .doc { max-width: none; }
.doc-checks { display: flex; flex-direction: column; gap: 4px; margin: 4px 0 12px; }
.doc-checks label.check { margin: 0; }

/* --- v8: быстрое подключение почты --- */
.oauth-row { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.oauth-btn { font-weight: 600; padding: 10px 18px; border-radius: 10px; }
.oauth-btn.yandex { background: #fc3f1d; border-color: #fc3f1d; color: #fff; }
.oauth-btn.google { background: #fff; border-color: #dadce0; color: #3c4043; }
details.mail-manual { margin: 12px 0; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
details.mail-manual summary { cursor: pointer; color: var(--accent); }

/* --- v9: 152-ФЗ — согласия, cookie, юридические страницы --- */
.cookie-banner { position: fixed; left: 16px; right: 16px; bottom: 16px; z-index: 1000; max-width: 760px; margin: 0 auto;
  display: flex; gap: 16px; align-items: center; background: var(--panel); color: var(--text);
  border: 1px solid var(--line); border-radius: 12px; padding: 14px 18px; box-shadow: 0 10px 40px rgba(0,0,0,.25); }
.cookie-banner p { margin: 0; font-size: 13px; line-height: 1.5; }
.cookie-banner a { color: var(--accent); }
.cookie-banner button { flex-shrink: 0; }
@media (max-width: 600px) { .cookie-banner { flex-direction: column; align-items: stretch; } }
@media print { .cookie-banner { display: none; } }

.consent-checks { margin: 4px 0 14px; display: flex; flex-direction: column; gap: 8px; }
.consent-checks label.check { margin: 0; align-items: flex-start; font-size: 13px; line-height: 1.45; }
.consent-checks label.check input { margin-top: 2px; }
.consent-checks label.check > span { display: inline; color: var(--text); font-size: 13px; margin: 0; }
.consent-checks a, .legal-links a { color: var(--accent); }
.legal-links { display: flex; flex-wrap: wrap; gap: 4px 12px; justify-content: center; margin-top: 18px; font-size: 12px; }
.sidebar-foot .legal-links { justify-content: flex-start; margin-top: 10px; gap: 2px 8px; }
.sidebar-foot .legal-links a { color: #9fc9b8; }

.legal-page { min-height: 100vh; background: var(--bg); }
.legal-head { background: var(--sidebar); color: #cfe3da; }
.legal-head .in { max-width: 860px; margin: 0 auto; padding: 14px 16px; display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.legal-head .logo { font-size: 22px; font-weight: 800; color: #fff; text-decoration: none; }
.legal-head .logo span { color: #6fd3a8; }
.legal-head nav { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 13px; }
.legal-head nav a { color: #cfe3da; text-decoration: none; }
.legal-head nav a.active, .legal-head nav a:hover { color: #fff; text-decoration: underline; }
.legal { max-width: 860px; margin: 24px auto; padding: 32px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; line-height: 1.6; font-size: 15px; }
.legal h1 { font-size: 26px; line-height: 1.25; margin: 0 0 6px; }
.legal h2 { font-size: 18px; margin: 28px 0 8px; }
.legal h3 { font-size: 15px; margin: 18px 0 6px; }
.legal p, .legal li { margin: 6px 0; }
.legal ol, .legal ul { padding-left: 22px; }
.legal a { color: var(--accent); }
.legal .edition { color: var(--muted); font-size: 13px; margin-bottom: 20px; }
.legal .table-wrap { margin: 10px 0; }
.legal table { font-size: 13px; }
.legal td, .legal th { vertical-align: top; }
.legal .req { background: var(--bg); border-radius: 8px; padding: 12px 16px; }
.legal-foot { max-width: 860px; margin: 0 auto 32px; padding: 0 16px; color: var(--muted); font-size: 12px; text-align: center; }
@media (max-width: 600px) { .legal { padding: 20px 16px; margin: 0; border-radius: 0; border-left: 0; border-right: 0; } .legal h1 { font-size: 22px; } }
@media print { .legal-head, .legal-foot, .cookie-banner { display: none; } .legal { border: 0; padding: 0; margin: 0; } }

/* --- v10: гид, вопросы и ответы, техподдержка --- */
.nav-sep { height: 1px; background: rgba(255,255,255,.12); margin: 8px 10px; }
@media (max-width: 800px) { .nav-sep { width: 1px; height: auto; margin: 4px 2px; flex-shrink: 0; } }

.tour-layer { position: fixed; inset: 0; z-index: 2000; }
.tour-hl { position: fixed; border-radius: 10px; box-shadow: 0 0 0 9999px rgba(10,15,25,.6); outline: 2px solid #6fd3a8;
  transition: left .25s, top .25s, width .25s, height .25s; pointer-events: none; }
.tour-pop { position: fixed; width: 340px; max-width: calc(100vw - 32px); background: var(--panel); color: var(--text);
  border-radius: 12px; padding: 18px 18px 14px; box-shadow: 0 20px 60px rgba(0,0,0,.35); transition: left .25s, top .25s; }
.tour-pop.center { left: 50% !important; top: 50% !important; transform: translate(-50%, -50%); width: 420px; }
.tour-pop.bottom { left: 16px !important; right: 16px; top: auto !important; bottom: 16px; width: auto; max-width: none; }
.tour-pop h3 { margin: 4px 28px 6px 0; font-size: 17px; }
.tour-pop .tour-text { margin: 0 0 14px; line-height: 1.5; }
.tour-x { position: absolute; top: 8px; right: 8px; border: none; background: none; font-size: 22px; line-height: 1; padding: 4px 8px; color: var(--muted); }
.tour-x:hover { color: var(--text); }
.tour-nav { display: flex; gap: 8px; align-items: center; }
.tour-nav button.link { padding-left: 0; color: var(--muted); }
@media print { .tour-layer { display: none; } }

.faq-search { width: 100%; max-width: 560px; margin-bottom: 16px; }
.faq-cat h2 { font-size: 16px; margin: 20px 0 8px; }
.faq-item { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 8px; }
.faq-item summary { cursor: pointer; padding: 12px 16px; font-weight: 600; list-style-position: inside; }
.faq-item[open] summary { border-bottom: 1px solid var(--line); }
.faq-a { padding: 10px 16px 14px; line-height: 1.6; }
.faq-a ol, .faq-a ul { margin: 4px 0; padding-left: 20px; }
.faq-a a { color: var(--accent); }

.support-grid { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 20px; align-items: start; }
@media (max-width: 1100px) { .support-grid { grid-template-columns: 1fr; } }
.support-grid textarea { width: 100%; resize: vertical; }
.shot-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.shot-prev { max-width: 100%; max-height: 220px; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 10px; }
.ticket { border-top: 1px solid var(--line); padding: 10px 0; }
.ticket:first-child { border-top: none; padding-top: 0; }
.ticket summary { cursor: pointer; }
.ticket summary .badge { margin-right: 6px; }
.ticket-msg { white-space: pre-wrap; margin: 8px 0; font-size: 13px; }
.ticket-reply { white-space: pre-wrap; background: var(--accent-soft); border-radius: 8px; padding: 10px 12px; font-size: 13px; }

/* --- v11: мобильная версия --- */
@media (max-width: 800px) {
  /* iOS Safari увеличивает страницу при фокусе на поле со шрифтом < 16px */
  input, select, textarea { font-size: 16px; }
  /* Меню: прокрутка пальцем без системной полосы, справа — затухание как подсказка, что меню листается */
  nav { scrollbar-width: none; -webkit-overflow-scrolling: touch; padding-bottom: 2px;
    -webkit-mask-image: linear-gradient(90deg, #000 85%, transparent); mask-image: linear-gradient(90deg, #000 85%, transparent); }
  nav::-webkit-scrollbar { display: none; }
  nav a { padding: 8px 12px; }
  /* Шапка: только имя, «Мой налог», статус и «Выйти»; документы — внизу страницы входа и в Настройках */
  .sidebar-foot { font-size: 12px; row-gap: 2px; }
  .sidebar-foot .user-name + .small, .sidebar-foot .legal-links { display: none; }
  .page-head { flex-wrap: wrap; gap: 10px; }
  .page-head h1 { font-size: 22px; }
  .toolbar { gap: 6px; }
  .toolbar button, .toolbar .btn { padding: 7px 11px; font-size: 13px; }
  .toolbar select { font-size: 16px; }
  .modal { padding: 16px 10px; }
  .modal-box { padding: 18px 16px; }
  .form-actions { flex-wrap: wrap; }
  /* «Последние поступления» на Главной: без колонки клиента, описание переносится */
  table.recent td:nth-child(3) { display: none; }
  table.recent td { padding: 8px 6px; }
  table.recent td:first-child { white-space: nowrap; color: var(--muted); font-size: 12px; }
  table.recent td.num { white-space: nowrap; }
  #toast { bottom: calc(16px + env(safe-area-inset-bottom)); text-align: center; }
}

/* Таблицы данных на телефоне — карточками: каждая строка становится блоком «подпись — значение»
   (подписи из заголовков колонок проставляет app.js → cardTables) */
@media (max-width: 600px) {
  .table-wrap.cards { overflow: visible; }
  .table-wrap.cards table, .table-wrap.cards tbody, .table-wrap.cards tr, .table-wrap.cards td { display: block; width: auto; }
  .table-wrap.cards tr.th-row { display: none; }
  .table-wrap.cards tr { padding: 10px 14px; border-bottom: 1px solid var(--line); }
  .table-wrap.cards tr:last-child { border-bottom: none; }
  /* Обычный блок, подпись — слева через float: вложенные элементы ячейки (имя + «Физлицо · 4%», кнопки) идут своим потоком справа */
  .table-wrap.cards td { border: none; padding: 3px 0; text-align: right; overflow-wrap: anywhere; min-height: 22px; }
  .table-wrap.cards td::before { content: attr(data-label); float: left; margin-right: 12px; color: var(--muted); font-size: 12px; line-height: 22px; }
  .table-wrap.cards td:not([data-label]), .table-wrap.cards td[data-label=""] { text-align: left; padding-top: 6px; }
  .table-wrap.cards td:not([data-label])::before, .table-wrap.cards td[data-label=""]::before { display: none; }
  .table-wrap.cards td:empty { display: none; }
  .table-wrap.cards td.num { font-weight: 600; }
}

@media (max-width: 600px) {
  .cookie-banner { left: 8px; right: 8px; bottom: calc(8px + env(safe-area-inset-bottom)); padding: 10px 12px; gap: 10px;
    flex-direction: row; align-items: center; }
  .cookie-banner p { font-size: 12px; line-height: 1.4; }
  .cookie-banner button { padding: 8px 12px; }
  .tour-pop.bottom { bottom: calc(16px + env(safe-area-inset-bottom)); }
  .login-box { padding: 24px 20px; }
}
@media (max-width: 600px) {
  /* Конструктор договоров: заголовок раздела на всю ширину, кнопки (✎ ↑ ↓ ✕) — второй строкой справа */
  .sec-head { flex-wrap: wrap; row-gap: 2px; }
  .sec-head .sec-title { flex: 1 1 calc(100% - 32px); min-width: 0; }
  .sec-head [data-toggle] { margin-left: auto; }
  .sec-head button.link { padding: 4px 10px; }
  .sec-snippet { padding-left: 6px; }
}
@media (max-width: 600px) {
  /* Страницы документов: меню — одной строкой с прокруткой пальцем */
  .legal-head .in { padding: 10px 12px; gap: 6px; }
  .legal-head nav { flex-wrap: nowrap; overflow-x: auto; width: 100%; gap: 4px; padding-bottom: 2px; }
  .legal-head nav a { white-space: nowrap; padding: 6px 10px; border-radius: 16px; background: rgba(255,255,255,.06); font-size: 12px; }
  .legal-head nav a.active { background: rgba(111,211,168,.2); text-decoration: none; }
  .legal { font-size: 14px; }
  .legal ol, .legal ul { padding-left: 18px; }
}
@media (max-width: 600px) {
  /* «Требует внимания»: текст на всю ширину, кнопка действия — под ним */
  .alert { flex-wrap: wrap; row-gap: 2px; align-items: flex-start; }
  .alert .dot { margin-top: 6px; }
  .alert .txt { flex: 1 1 calc(100% - 20px); }
  .alert button { margin-left: 19px; padding-left: 0; }
}
