:root, [data-theme='light'] {
  /* Палитра приложения (mobile/lib/theme.dart · Palette.light) */
  --bg: #F3F4F7; --surf: #FFFFFF; --surf2: #EEF0F4; --ink: #0F1320; --mut: #5B6274; --line: #E4E6EC;
  --acc: #006FAA; --acc-fill: #006FAA; --acc-h: #00578A; --soft: #E1F1FA; --brand: #008FD4; --globe: #008FD4; --ring: #0F1320;
  --ok: #16794A; --okBg: #E3F4EA; --warn: #A15C00; --warnBg: #FFF1DC; --bad: #C2312C; --badBg: #FCE8E7;
  --hero: #0F1320; --hero-ink: #FFFFFF; --bar: #9CCBE6; --focus: #7CC2EA; --scrim: rgba(6, 9, 18, 0.5);
  color-scheme: light;
}
[data-theme='dark'] {
  /* Palette.darkP */
  --bg: #0B0F1A; --surf: #151B2B; --surf2: #1C2336; --ink: #F2F4F8; --mut: #9AA3B8; --line: #252D42;
  --acc: #5CC2F2; --acc-fill: #0A78B4; --acc-h: #8AD3F5; --soft: #12324A; --brand: #2AA7E6; --globe: #2AA7E6; --ring: #FFFFFF;
  --ok: #4CC58A; --okBg: #123326; --warn: #F2B65C; --warnBg: #3A2A12; --bad: #FF7A73; --badBg: #3D1A1A;
  --hero: #0A78B4; --hero-ink: #FFFFFF; --bar: #1F6E9C; --focus: #5CC2F2; --scrim: rgba(0, 0, 0, 0.65);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  [data-theme='system'] {
    --bg: #0B0F1A; --surf: #151B2B; --surf2: #1C2336; --ink: #F2F4F8; --mut: #9AA3B8; --line: #252D42;
    --acc: #5CC2F2; --acc-fill: #0A78B4; --acc-h: #8AD3F5; --soft: #12324A; --brand: #2AA7E6; --globe: #2AA7E6; --ring: #FFFFFF;
    --ok: #4CC58A; --okBg: #123326; --warn: #F2B65C; --warnBg: #3A2A12; --bad: #FF7A73; --badBg: #3D1A1A;
    --hero: #0A78B4; --hero-ink: #FFFFFF; --bar: #1F6E9C; --focus: #5CC2F2; --scrim: rgba(0, 0, 0, 0.65);
    color-scheme: dark;
  }
}
:root {
  font-family: 'Manrope', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color: var(--ink); background: var(--bg);
}
* { box-sizing: border-box; }
body { margin: 0; }
a { color: var(--acc); text-decoration: none; }
a:hover { color: var(--acc-h); text-decoration: none; }
a.btn, a.btn:hover, a.pill, a.pill:hover, .nav a, .nav a:hover, a.tq, a.tq:hover, a.brand, a.brand:hover { text-decoration: none; }
a.btn.primary, a.btn.primary:hover { color: #fff; }
a.btn:not(.primary) { color: var(--ink); }
h1 { margin: 0; font-size: 28px; font-weight: 800; letter-spacing: -0.02em; }
h2 { margin: 0; font-size: 16px; font-weight: 800; }

.layout { display: grid; grid-template-columns: var(--side-w, 248px) minmax(0, 1fr); min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; overflow-y: auto; overflow-x: hidden; padding: 24px 14px; background: var(--surf); border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 24px; }
.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px; color: var(--ink); text-decoration: none; }
.brand b { font-size: 16px; font-weight: 800; white-space: nowrap; }
.brand b span { color: var(--acc); }
.brand small { display: block; font-size: 12px; color: var(--mut); font-weight: 600; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { height: 42px; border-radius: 12px; padding: 0 12px; display: flex; align-items: center; gap: 10px; text-decoration: none; font-size: 14px; font-weight: 600; color: var(--mut); }
.nav a.active { background: var(--soft); color: var(--acc); font-weight: 800; }
.nav a:hover { background: var(--surf2); }
.nav .badge { margin-left: auto; font-size: 12px; font-weight: 800; color: #fff; background: var(--bad-fill, #C2312C); border-radius: 999px; padding: 1px 8px; }
.me { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 14px; background: var(--surf2); }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--hero); color: var(--hero-ink); display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 800; flex-shrink: 0; }
.me div { min-width: 0; flex: 1; }
.me b { display: block; font-size: 13px; }
.me small { font-size: 12px; color: var(--mut); }
.main { min-width: 0; padding: 18px 32px 40px; display: flex; flex-direction: column; gap: 20px; }
.topbar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.search-form { flex: 0 1 420px; margin-left: auto; min-width: 220px; }
.search { width: 100%; height: 44px; border-radius: 12px; background: var(--surf); border: 1px solid var(--line); display: flex; align-items: center; gap: 10px; padding: 0 14px; color: var(--mut); }
.search input { flex: 1; min-width: 0; border: 0; outline: none; background: transparent; font: inherit; font-size: 14px; color: var(--ink); }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 14px; }
.page-head p { margin: 4px 0 0; font-size: 14px; color: var(--mut); }
.actions { display: flex; flex-wrap: wrap; gap: 10px; }

.card { background: var(--surf); border-radius: 20px; padding: 20px 22px; min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.grid { display: grid; gap: 20px; grid-template-columns: repeat(auto-fit, minmax(var(--min, 300px), 1fr)); align-items: start; }
.stack { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.kpi { display: flex; flex-direction: column; gap: 6px; }
.kpi span { font-size: 13px; font-weight: 700; color: var(--mut); }
.kpi b { font-size: 30px; font-weight: 800; letter-spacing: -0.02em; }

.btn { height: 40px; padding: 0 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--surf); color: var(--ink); font: inherit; font-size: 14px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--surf2); }
.btn.primary { background: var(--acc-fill); border-color: var(--acc-fill); color: #fff; }
.btn.primary:hover { filter: brightness(1.1); }
.btn.danger { color: var(--bad); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { height: 34px; padding: 0 12px; font-size: 13px; }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible { outline: 3px solid var(--focus); outline-offset: 1px; }

.chip { display: inline-flex; align-items: center; font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.chip-ok { color: var(--ok); background: var(--okBg); } .chip-warn { color: var(--warn); background: var(--warnBg); }
.chip-bad { color: var(--bad); background: var(--badBg); } .chip-acc { color: var(--acc); background: var(--soft); }
.chip-mut { color: var(--mut); background: var(--surf2); }
.pills { display: flex; flex-wrap: wrap; gap: 8px; }
.pill { height: 36px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--surf); color: var(--ink); font: inherit; font-size: 13px; font-weight: 700; cursor: pointer; }
.pill[aria-pressed='true'] { border-color: var(--acc); background: var(--soft); color: var(--acc); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; padding: 10px 12px; font-size: 12px; font-weight: 700; color: var(--mut); text-transform: uppercase; letter-spacing: 0.04em; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 11px 12px; font-size: 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td.r, th.r { text-align: right; }
tr.click { cursor: pointer; } tr.click:hover td { background: var(--surf2); }
.neg { color: var(--bad); font-weight: 800; } .pos { color: var(--ok); font-weight: 800; }
.muted { color: var(--mut); }

.kv { margin: 0; } .kv div { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); font-size: 14px; }
.kv dt { color: var(--mut); } .kv dd { margin: 0; font-weight: 700; text-align: right; }

.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 700; }
.field small { font-weight: 500; color: var(--mut); }
input, select, textarea { height: 42px; border-radius: 12px; border: 1px solid var(--line); padding: 0 12px; font: inherit; font-size: 14px; color: var(--ink); background: var(--surf); min-width: 0; }
textarea { height: auto; padding: 10px 12px; resize: vertical; }
.form { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.form .full { grid-column: 1 / -1; }
.error { color: var(--bad); font-weight: 700; font-size: 14px; margin: 0; }
.modal-bg { position: fixed; inset: 0; background: var(--scrim); display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 50; }
.modal { width: min(640px, 100%); max-height: 90vh; overflow: auto; background: var(--surf); border-radius: 22px; padding: 22px; display: flex; flex-direction: column; gap: 14px; }

.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-box { width: min(400px, 100%); display: flex; flex-direction: column; gap: 12px; }
.login-box > form:not(.prefs) { background: var(--surf); border-radius: 24px; padding: 32px; display: flex; flex-direction: column; gap: 16px; }

.bars { height: 170px; display: flex; align-items: flex-end; gap: 5px; }
.bars span { flex: 1; border-radius: 4px; background: var(--bar); min-height: 3px; }
.bar-row { display: flex; align-items: center; gap: 12px; padding: 7px 0; font-size: 14px; }
.bar-row b { width: 140px; flex-shrink: 0; } .bar-row em { width: 70px; text-align: right; font-style: normal; color: var(--mut); font-size: 13px; }
.bar-track { flex: 1; height: 10px; background: var(--surf2); border-radius: 999px; overflow: hidden; } .bar-track i { display: block; height: 100%; background: var(--acc-fill); }

.tickets { display: flex; flex-wrap: wrap; gap: 20px; align-items: flex-start; }
.tickets > .q { flex: 1 1 260px; min-width: 0; } .tickets > .chat { flex: 3 1 420px; min-width: 0; } .tickets > .info { flex: 1 1 260px; min-width: 0; }
.tq { display: flex; flex-direction: column; gap: 4px; padding: 12px 14px; border-radius: 14px; border: 0; background: transparent; text-align: left; font: inherit; color: var(--ink); cursor: pointer; width: 100%; }
.tq[aria-current='true'] { background: var(--soft); }
.tq:hover { background: var(--surf2); }
.tq .row { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; }
.tq .last { font-size: 13px; color: var(--mut); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msgs { display: flex; flex-direction: column; gap: 10px; min-height: 300px; max-height: 55vh; overflow: auto; padding: 4px; }
.msg { max-width: 76%; padding: 10px 14px; border-radius: 16px 16px 16px 4px; background: var(--surf2); display: flex; flex-direction: column; gap: 4px; align-self: flex-start; white-space: pre-wrap; }
.msg.staff { align-self: flex-end; background: var(--acc-fill); color: #fff; border-radius: 16px 16px 4px 16px; }
.msg.system { align-self: center; background: transparent; color: var(--mut); font-size: 13px; }
.msg small { font-size: 11px; opacity: 0.85; }
.reply { display: flex; gap: 8px; margin-top: 12px; }
.reply textarea { flex: 1; }
.lang-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px; }
.empty { padding: 30px; text-align: center; color: var(--mut); }
@media (max-width: 700px) { .main { padding: 16px; } }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* --- Go + htmx admin additions --- */
.kpi .chip { align-self: flex-start; }
dialog.modal { border: 0; box-shadow: none; color: var(--ink); margin: auto; }
dialog.modal:not([open]) { display: none; }
dialog.modal::backdrop { background: var(--scrim); }
.pill input { position: absolute; opacity: 0; pointer-events: none; }
label.pill { display: inline-flex; align-items: center; position: relative; }
label.pill:has(input:checked) { border-color: var(--acc); background: var(--soft); color: var(--acc); }
a.pill { display: inline-flex; align-items: center; text-decoration: none; }
.htmx-request .btn.primary, .btn.primary.htmx-request { opacity: .6; }
.flash { background: var(--okBg); color: var(--ok); font-weight: 700; padding: 10px 14px; border-radius: 12px; }
.err:empty { display: none; }
.check { flex-direction: row !important; align-items: center; gap: 10px; }
.check input { height: 18px; }
form.inline { display: inline; }
.lang-text[hidden] { display: none; }
.lang-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }

/* --- logo, theme & language switchers --- */
.logo { color: var(--ring); } .logo .g { fill: var(--globe); }
.prefs { display: flex; gap: 6px; padding: 0 4px; }
.prefs select { height: 34px; font-size: 13px; padding: 0 8px; flex: 1; }
.seg { display: inline-flex; background: var(--surf2); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button { height: 28px; min-width: 32px; border: 0; border-radius: 8px; background: transparent; color: var(--mut); cursor: pointer; font: inherit; font-size: 13px; display: inline-flex; align-items: center; justify-content: center; }
.seg button[aria-pressed='true'] { background: var(--surf); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.12); }
.login .prefs { justify-content: flex-end; padding: 0; }
.login .prefs select { flex: 0 1 180px; }

/* --- quick replies, settings, chat translation --- */
.clip { max-width: 360px; overflow: hidden; text-overflow: ellipsis; color: var(--mut); }
.notice { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px; border: 1px solid var(--line); }
.notice p { margin: 4px 0 0; color: var(--mut); font-size: 14px; }
.notice.warn { background: var(--warnBg); border-color: transparent; }
.notice.warn b { color: var(--warn); }
.lang-cards { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.lang-card { display: flex; flex-direction: column; gap: 10px; }
.lang-card .card-head { margin-bottom: 2px; }
.lang-card h2 small { font-weight: 700; font-size: 12px; margin-left: 4px; }
.lang-card.main { outline: 2px solid var(--acc-fill); outline-offset: -2px; }
.sticky-actions { position: sticky; bottom: 0; padding: 12px 0; background: linear-gradient(transparent, var(--bg) 35%); }
.label { margin: 0 0 8px; font-size: 13px; font-weight: 700; }
.provider { display: flex; flex-direction: column; gap: 12px; padding: 16px; border-radius: 16px; background: var(--surf2); }
.provider h3 { margin: 0; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.provider input { background: var(--surf); }
.chip-btn { border: 0; cursor: pointer; font: inherit; font-size: 12px; font-weight: 700; gap: 5px; }
.chip-btn svg { width: 14px; height: 14px; }
.msg .orig { font-size: 12.5px; opacity: .75; border-top: 1px solid color-mix(in srgb, currentColor 25%, transparent); padding-top: 4px; margin-top: 2px; }
.msg .orig b { font-size: 11px; letter-spacing: .04em; margin-right: 4px; }
.notice-line { margin: 0 0 8px; font-size: 13px; color: var(--warn); background: var(--warnBg); padding: 8px 12px; border-radius: 10px; }
.pill-add { color: var(--mut); border-style: dashed; }
.chat .card-head { flex-wrap: wrap; } .chat .card-head .actions { align-items: center; }

/* --- collapsible menu & breadcrumbs --- */
.btn.icon { width: 40px; padding: 0; }
.crumbs { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1 1 260px; font-size: 14px; color: var(--mut); white-space: nowrap; overflow: hidden; }
.crumbs a { color: var(--mut); font-weight: 600; }
.crumbs a:hover { color: var(--ink); }
.crumbs b { color: var(--ink); font-weight: 800; overflow: hidden; text-overflow: ellipsis; }
.crumbs .sep { opacity: .5; }
.only-mini { display: none; }
.nav a { position: relative; }
.scrim { display: none; }

html.side-mini { --side-w: 72px; }
@media (min-width: 901px) {
  .side-mini .side { padding: 20px 10px; align-items: center; }
  .side-mini .side .tx, .side-mini .side .prefs { display: none; }
  .side-mini .brand { padding: 0; justify-content: center; }
  .side-mini .nav { width: 100%; }
  .side-mini .nav a { justify-content: center; padding: 0; }
  .side-mini .nav .badge { position: absolute; top: 4px; right: 6px; margin: 0; padding: 0 5px; font-size: 10px; }
  .side-mini .me { flex-direction: column; padding: 8px 0; width: 100%; background: transparent; }
  .side-mini .me .btn { width: 40px; padding: 0; }
  .side-mini .only-mini { display: inline-flex; }
}
@media (max-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .side { position: fixed; left: 0; top: 0; bottom: 0; width: 264px; z-index: 40; transform: translateX(-100%); transition: transform .2s ease; }
  .side-open .side { transform: none; box-shadow: 0 10px 40px rgba(0,0,0,.35); }
  .side-open .scrim { display: block; position: fixed; inset: 0; z-index: 30; background: var(--scrim); }
  .main { padding: 14px 16px 32px; }
  .search-form { flex: 1 1 100%; margin-left: 0; }
}
.me .tx { min-width: 0; overflow: hidden; }
.me .tx b, .me .tx small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me form { flex-shrink: 0; }
a.brand:hover { color: var(--ink); }
.me .btn { width: 36px; padding: 0; }
.me .btn .tx { display: none; }
.me .btn .only-mini { display: inline-flex; }

/* --- pagination --- */
.pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-top: 14px; font-size: 13px; }
.pager .pages { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.pager .btn.sm { min-width: 34px; padding: 0 10px; }
.pager .btn.cur { background: var(--acc-fill); border-color: var(--acc-fill); color: #fff; cursor: default; }
.pager .btn[aria-disabled="true"] { opacity: .4; cursor: default; }
.pager .gap { color: var(--mut); padding: 0 2px; }
.inline-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; margin-top: 20px; padding-top: 20px; border-top: 1px solid var(--line); }
.inline-form .err { flex-basis: 100%; }
#sms > .muted { margin-bottom: 16px !important; }

/* SMS service */
.tabs { gap: 6px; } .tabs .pill { height: 34px; }
.tabs-sep { width: 1px; align-self: stretch; background: var(--line); margin: 0 4px; }
.filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; margin-bottom: 16px; }
.filters .field { min-width: 160px; } .filters .grow { flex: 1; min-width: 220px; } .filters .or { padding-bottom: 10px; }
.filters .err { flex-basis: 100%; }
form.inline { display: inline; }
.nowrap { white-space: nowrap; }
.text-bad { color: var(--bad); }
tr.row-bad td:first-child { box-shadow: inset 3px 0 0 var(--bad); }
tr.row-active td { background: var(--soft); }
a.kpi { color: inherit; } a.kpi:hover b { color: var(--acc); }
.legend { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--mut); flex-wrap: wrap; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; margin-left: 8px; }
.lg-ok, .sbar .ok, .stack .ok { background: var(--ok); } .lg-bad, .sbar .bad, .stack .bad { background: var(--bad); }
.lg-pend, .sbar .pend, .stack .pend { background: var(--bar); } .lg-warn, .sbar .warn { background: var(--warn); }
.sbars { height: 200px; display: flex; align-items: stretch; gap: 4px; padding-bottom: 18px; }
.sbar { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; position: relative; min-width: 0; }
.sbar .col { display: flex; flex-direction: column; border-radius: 4px; overflow: hidden; min-height: 3px; background: var(--surf2); }
.sbar .col i { display: block; min-height: 0; }
.sbar small { position: absolute; bottom: -18px; left: 0; font-size: 10px; color: var(--mut); white-space: nowrap; }
.sbar:hover .col { outline: 2px solid var(--focus); }
.bar-track.stack { display: flex; align-items: stretch; } .bar-track.stack i { height: auto; flex: none; }
a.bar-row { color: inherit; } a.bar-row:hover b { color: var(--acc); }
.donut-wrap { display: flex; align-items: center; gap: 24px; flex-wrap: wrap; }
.donut { --pok: 0; --pbad: 0; width: 150px; height: 150px; border-radius: 50%; flex-shrink: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: radial-gradient(closest-side, var(--surf) 68%, transparent 69%),
    conic-gradient(var(--ok) 0 calc(var(--pok) * 1%), var(--bad) 0 calc((var(--pok) + var(--pbad)) * 1%), var(--bar) 0); }
.donut b { font-size: 26px; font-weight: 800; } .donut small { font-size: 12px; color: var(--mut); }
.donut-list { display: flex; flex-direction: column; gap: 8px; flex: 1; min-width: 180px; }
.donut-list a { display: flex; justify-content: space-between; align-items: center; gap: 12px; color: inherit; }
.err-row { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.err-row span { color: var(--bad); overflow-wrap: anywhere; } .err-row:last-child { border-bottom: 0; }
pre.json { background: var(--surf2); border-radius: 12px; padding: 14px; font-size: 12px; overflow: auto; max-height: 360px; margin: 12px 0 0; }
h3.sub { font-size: 15px; margin: 24px 0 12px; }
.notice.ok { background: var(--okBg); border-color: transparent; padding: 12px 14px; border-radius: 12px; }
.notice.bad { background: var(--badBg); border-color: transparent; padding: 12px 14px; border-radius: 12px; }
.sms-log td { vertical-align: top; }
.kpis .kpi .chip { white-space: normal; }
.clip2 { max-width: 340px; color: var(--mut); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.clip2 { white-space: normal; min-width: 220px; }
.sms-log td.acts { white-space: nowrap; } .sms-log td.acts > * { margin: 0 4px 4px 0; vertical-align: middle; }
.sbars + .table-wrap { margin-top: 24px; }

/* client card: communication */
table.chtable th.c, table.chtable td.c { text-align: center; width: 54px; padding-left: 4px; padding-right: 4px; }
table.chtable td:first-child { white-space: normal; }
.yn { display: inline-flex; width: 26px; height: 26px; border-radius: 50%; align-items: center; justify-content: center; font-weight: 800; }
.yn.yes { background: var(--okBg); color: var(--ok); } .yn.no { background: var(--surf2); color: var(--mut); }
p.small { font-size: 12px; margin: 8px 0 0; }
.note-row { display: flex; gap: 14px; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.note-row:last-of-type { border-bottom: 0; }
.note-row.unread .note-main b { color: var(--acc); }
.note-main { flex: 1; min-width: 0; overflow-wrap: anywhere; } .note-meta { text-align: right; white-space: nowrap; }
.note-ch { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 4px; }
.aud { display: flex; flex-wrap: wrap; gap: 6px; }
details.raw { margin-top: 16px; }
details.raw summary { cursor: pointer; color: var(--muted); font-size: 13px; }
details.raw pre { max-height: 320px; overflow: auto; font-size: 12px; background: var(--bg); padding: 12px; border-radius: 10px; }

/* ---------- alerts, confirmations, toasts (SweetAlert2-style, see ui.js) ---------- */
dialog.sw { border: 0; padding: 0; background: transparent; max-width: calc(100vw - 32px); overflow: visible; }
dialog.sw::backdrop { background: rgba(9, 13, 24, .45); animation: sw-fade .18s ease-out; }
.sw-box { width: 440px; max-width: 100%; background: var(--surf); color: var(--ink); border-radius: 20px; padding: 32px 28px 24px; text-align: center; box-shadow: 0 24px 60px rgba(9, 13, 24, .28); animation: sw-pop .3s cubic-bezier(.2, .9, .3, 1.2); }
dialog.sw.sw-out .sw-box { animation: sw-hide .16s ease-in forwards; }
dialog.sw.sw-out::backdrop { opacity: 0; transition: opacity .16s; }
.sw-title { margin: 0 0 8px; font-size: 21px; line-height: 1.3; font-weight: 800; }
.sw-text { margin: 0; color: var(--mut); font-size: 15px; line-height: 1.5; white-space: pre-line; overflow-wrap: anywhere; }
.sw-actions { display: flex; justify-content: center; gap: 10px; margin-top: 24px; flex-wrap: wrap; }
.sw-actions .btn { min-width: 112px; height: 44px; }
.btn.sw-danger { background: #C2312C; border-color: #C2312C; color: #fff; }
.btn.sw-danger:hover { background: #A52824; border-color: #A52824; }
.sw-icon { width: 76px; height: 76px; margin: 0 auto 18px; }
.sw-icon svg { width: 100%; height: 100%; fill: none; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.sw-icon .ring { stroke-dasharray: 151; stroke-dashoffset: 151; animation: sw-draw .5s ease-out forwards; opacity: .9; }
.sw-icon .mark { stroke-dasharray: 48; stroke-dashoffset: 48; animation: sw-draw .35s .35s ease-out forwards; stroke-width: 3.6; }
.sw-icon .m2 { animation-delay: .5s; }
.sw-icon .dot { stroke: none; opacity: 0; animation: sw-dot .2s .6s ease-out forwards; }
.sw-success { color: var(--ok); } .sw-error { color: var(--bad); } .sw-warning { color: var(--warn); }
.sw-question { color: var(--acc); } .sw-info { color: var(--acc); }
.sw-icon svg { stroke: currentColor; } .sw-icon .dot { fill: currentColor; }
.sw-error svg { animation: sw-shake .4s .55s; } .sw-warning svg { animation: sw-pulse .6s .5s; }
.sw-toasts { position: fixed; top: 16px; right: 16px; z-index: 1000; display: flex; flex-direction: column; gap: 10px; width: min(380px, calc(100vw - 32px)); pointer-events: none; }
.sw-toast { pointer-events: auto; position: relative; overflow: hidden; display: flex; align-items: center; gap: 12px; padding: 14px 40px 16px 14px; background: var(--surf); color: var(--ink); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 12px 32px rgba(9, 13, 24, .18); animation: sw-in .3s cubic-bezier(.2, .9, .3, 1.15); }
.sw-toast.sw-out { animation: sw-away .2s ease-in forwards; }
.sw-toast .sw-icon { width: 30px; height: 30px; margin: 0; flex: none; }
.sw-toast-text { font-size: 14px; font-weight: 700; line-height: 1.4; overflow-wrap: anywhere; }
.sw-x { position: absolute; top: 6px; right: 6px; width: 28px; height: 28px; border: 0; background: none; color: var(--mut); font-size: 20px; line-height: 1; border-radius: 8px; cursor: pointer; }
.sw-x:hover { background: var(--surf2); color: var(--ink); }
.sw-bar { position: absolute; left: 0; bottom: 0; height: 3px; width: 100%; background: currentColor; opacity: .35; transform-origin: left; animation: sw-timer linear forwards; color: var(--ok); }
.sw-toast:has(.sw-error) .sw-bar { color: var(--bad); }
.sw-toast.paused .sw-bar { animation-play-state: paused; }
@keyframes sw-fade { from { opacity: 0; } }
@keyframes sw-pop { 0% { transform: scale(.7); opacity: 0; } 45% { transform: scale(1.04); opacity: 1; } 80% { transform: scale(.98); } 100% { transform: scale(1); } }
@keyframes sw-hide { to { transform: scale(.9); opacity: 0; } }
@keyframes sw-draw { to { stroke-dashoffset: 0; } }
@keyframes sw-dot { to { opacity: 1; } }
@keyframes sw-shake { 25% { transform: translateX(-4px); } 50% { transform: translateX(4px); } 75% { transform: translateX(-2px); } }
@keyframes sw-pulse { 50% { transform: scale(1.08); } }
@keyframes sw-in { from { transform: translateX(110%); opacity: 0; } }
@keyframes sw-away { to { transform: translateX(110%); opacity: 0; } }
@keyframes sw-timer { to { transform: scaleX(0); } }
@media (prefers-reduced-motion: reduce) {
  .sw-box, .sw-toast, .sw-icon *, dialog.sw::backdrop { animation-duration: 1ms !important; animation-delay: 0s !important; }
}
@media (max-width: 600px) { .sw-toasts { top: auto; bottom: 16px; right: 16px; left: 16px; width: auto; } }
fieldset.field { border: 0; padding: 0; margin: 0; min-width: 0; display: flex; flex-wrap: wrap; gap: 8px 20px; }
fieldset.field legend { padding: 0; margin-bottom: 8px; font-size: 13px; font-weight: 700; color: var(--mut); }
fieldset.field small { flex-basis: 100%; }

/* ---------- invoice page and invoice template editor ---------- */
.inv-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); gap: 20px; align-items: start; }
.inv-layout.tpl { grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.05fr); }
.inv-preview { position: sticky; top: 16px; }
.inv-preview iframe { width: 100%; height: calc(100vh - 150px); min-height: 520px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.inv-preview select { height: 36px; border-radius: 10px; border: 1px solid var(--line); background: var(--surf); color: var(--ink); font: inherit; font-size: 13px; padding: 0 10px; max-width: 60%; }
@media (max-width: 1100px) { .inv-layout, .inv-layout.tpl { grid-template-columns: 1fr; } .inv-preview { position: static; } }
.swatches { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.swatch { width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--surf); box-shadow: 0 0 0 1px var(--line); cursor: pointer; padding: 0; }
.swatch[aria-pressed='true'] { box-shadow: 0 0 0 2px var(--ink); }
.swatches input[type=color] { width: 44px; height: 32px; border: 1px solid var(--line); border-radius: 8px; background: var(--surf); padding: 2px; cursor: pointer; }
.swatches code { font-size: 12px; color: var(--mut); }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 6px 16px; }
.radios { display: flex; flex-direction: column; gap: 6px; }
.radios .field.check span { font-weight: 400; }
td.wrap { white-space: normal; }
.lines-edit td { padding: 6px 4px; border-bottom: 0; }
.lines-edit input { width: 100%; height: 38px; border-radius: 10px; border: 1px solid var(--line); background: var(--surf); color: var(--ink); font: inherit; padding: 0 10px; }
.lines-edit input.r { text-align: right; }
dialog.modal.wide { width: min(820px, 100%); }
.sticky-actions { position: sticky; bottom: 12px; z-index: 5; background: var(--surf); padding: 12px; border-radius: 14px; border: 1px solid var(--line); box-shadow: 0 8px 24px rgba(9, 13, 24, .12); }
#inv-tpl .card { display: flex; flex-direction: column; gap: 14px; }
.err.sw-shake { animation: sw-shake .4s; }
