:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --border: #e4e7ec;
  --text: #101828;
  --muted: #667085;
  --accent: #15803d;
  --accent-hover: #166534;
  --accent-soft: #dcfce7;
  --danger: #d92d20;
  --danger-soft: #fee4e2;
  --warn: #b54708;
  --warn-soft: #fef0c7;
  --info: #175cd3;
  --info-soft: #d1e9ff;
  --purple: #6941c6;
  --purple-soft: #ebe9fe;
  --gray-soft: #f2f4f7;
  --sidebar: #0c111d;
  --sidebar-text: #cecfd2;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c111d; --surface: #161b26; --surface-2: #1f242f; --border: #333741; --text: #f5f5f6; --muted: #94969c;
    --accent: #22c55e; --accent-hover: #16a34a; --accent-soft: #053321; --danger: #f97066; --danger-soft: #55160c;
    --warn: #fdb022; --warn-soft: #4e1d09; --info: #53b1fd; --info-soft: #102a56; --purple: #9e77ed; --purple-soft: #2c1c5f;
    --gray-soft: #1f242f; --sidebar: #0a0d14; --shadow: 0 1px 2px rgba(0,0,0,.4);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0c111d; --surface: #161b26; --surface-2: #1f242f; --border: #333741; --text: #f5f5f6; --muted: #94969c;
  --accent: #22c55e; --accent-hover: #16a34a; --accent-soft: #053321; --danger: #f97066; --danger-soft: #55160c;
  --warn: #fdb022; --warn-soft: #4e1d09; --info: #53b1fd; --info-soft: #102a56; --purple: #9e77ed; --purple-soft: #2c1c5f;
  --gray-soft: #1f242f; --sidebar: #0a0d14; --shadow: 0 1px 2px rgba(0,0,0,.4);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--font); font-size: 14px; line-height: 1.5; color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 22px; font-weight: 700; }
h2 { font-size: 16px; font-weight: 600; }
h3 { font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.r { text-align: right; }
.mono { font-variant-numeric: tabular-nums; }
.mt { margin-top: 16px; }
.pre { white-space: pre-wrap; word-break: break-word; }

/* ---------- Layout ---------- */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.sidebar { background: var(--sidebar); color: var(--sidebar-text); padding: 20px 12px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px; }
.brand { font-weight: 900; font-size: 20px; letter-spacing: 2px; color: #fff; padding: 4px 12px 20px; }
.brand span { color: #4ade80; }
.brand small { display: block; font-size: 10px; letter-spacing: 1px; font-weight: 500; color: #85888e; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px; color: var(--sidebar-text); font-weight: 500; }
.nav a:hover { background: #1f242f; text-decoration: none; color: #fff; }
.nav a.active { background: #1f242f; color: #fff; }
.nav a .count { margin-left: auto; background: var(--accent); color: #fff; border-radius: 10px; padding: 0 7px; font-size: 11px; font-weight: 600; }
.nav svg { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.sidebar-footer { margin-top: auto; padding: 12px; border-top: 1px solid #1f242f; font-size: 13px; }
.sidebar-footer .user { color: #fff; font-weight: 600; }
.sidebar-footer .row { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.sidebar-footer button, .sidebar-footer select { background: #1f242f; color: var(--sidebar-text); border: 1px solid #333741; border-radius: 6px; padding: 4px 8px; font: inherit; font-size: 12px; cursor: pointer; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 12px 24px; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20; }
.topbar .search { flex: 1; max-width: 420px; }
.topbar .spacer { flex: 1; }
.topbar .menu-btn { display: none; }
.content { padding: 24px; max-width: 1400px; width: 100%; }

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); margin-top: 4px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- Cards / grid ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-body { padding: 18px 20px; }
.card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; padding: 14px 20px; border-bottom: 1px solid var(--border); }
/* Заголовок не сжимается до столбика: кнопкам не хватает места — они переносятся строкой ниже */
.card-head > h2 { flex: none; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.detail { display: grid; grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr); gap: 16px; align-items: start; }
.stack { display: flex; flex-direction: column; gap: 16px; }

.kpi-group h3 { margin-bottom: 10px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); display: block; color: inherit; }
a.kpi:hover { text-decoration: none; border-color: var(--accent); }
.kpi .label { color: var(--muted); font-size: 12px; font-weight: 500; }
.kpi .value { font-size: 24px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }
.kpi .value.sm { font-size: 18px; }

dl.props { display: grid; grid-template-columns: 140px 1fr; gap: 8px 12px; margin: 0; }
dl.props dt { color: var(--muted); }
dl.props dd { margin: 0; word-break: break-word; }

/* ---------- Table ---------- */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 10px 14px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
.table th { font-size: 12px; color: var(--muted); font-weight: 600; background: var(--surface-2); white-space: nowrap; }
.table th[data-sort] { cursor: pointer; user-select: none; }
.table th[data-sort]:hover { color: var(--text); }
.table tbody tr.clickable { cursor: pointer; }
.table tbody tr.clickable:hover { background: var(--surface-2); }
.table tr:last-child td { border-bottom: none; }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table.compact th, .table.compact td { padding: 7px 10px; }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); }

.pager { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-top: 1px solid var(--border); gap: 8px; flex-wrap: wrap; }

/* ---------- Forms ---------- */
label.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 500; }
label.field > span { color: var(--muted); }
input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; width: 100%; min-height: 38px; }
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
input[type="checkbox"] { width: auto; min-height: 0; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; }
.form-grid .full { grid-column: 1 / -1; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.filters > * { width: auto; min-width: 130px; flex: 0 1 auto; }
.filters input[type="search"] { min-width: 220px; flex: 1 1 220px; }
.field-error { color: var(--danger); font-size: 12px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-weight: 600; font-size: 13px; padding: 8px 14px; min-height: 38px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; white-space: nowrap; text-decoration: none; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hover); }
.btn.danger { color: var(--danger); }
.btn.sm { padding: 4px 10px; min-height: 30px; font-size: 12px; }
.btn.ghost { border-color: transparent; background: transparent; }
.icon-btn { position: relative; }
.icon-btn .dot { position: absolute; top: 4px; right: 4px; min-width: 16px; height: 16px; border-radius: 8px; background: var(--danger); color: #fff; font-size: 10px; display: grid; place-items: center; padding: 0 4px; }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--gray-soft); color: var(--muted); }
.badge.green { background: var(--accent-soft); color: var(--accent); }
.badge.blue { background: var(--info-soft); color: var(--info); }
.badge.orange { background: var(--warn-soft); color: var(--warn); }
.badge.red { background: var(--danger-soft); color: var(--danger); }
.badge.purple { background: var(--purple-soft); color: var(--purple); }

/* ---------- Timeline / lists ---------- */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: 10px 0; border-bottom: 1px solid var(--border); }
.timeline li:last-child { border-bottom: none; }
.timeline .meta { font-size: 12px; color: var(--muted); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); padding: 0 12px; overflow-x: auto; }
.tabs button { background: none; border: none; font: inherit; font-weight: 600; color: var(--muted); padding: 12px 10px; border-bottom: 2px solid transparent; cursor: pointer; white-space: nowrap; }
.tabs button.active { color: var(--text); border-bottom-color: var(--accent); }

.file-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.file { border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--surface-2); display: flex; flex-direction: column; }
.file .thumb { height: 110px; display: grid; place-items: center; background: repeating-conic-gradient(var(--gray-soft) 0 25%, var(--surface) 0 50%) 0 0 / 16px 16px; }
.file .thumb img { max-width: 100%; max-height: 110px; object-fit: contain; }
.file .thumb .ext { font-weight: 800; font-size: 20px; color: var(--muted); }
.file .info { padding: 8px 10px; font-size: 12px; }
.file .info .name { font-weight: 600; word-break: break-all; }
.file .info .row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }

.status-steps { display: flex; gap: 4px; flex-wrap: wrap; }
.status-steps button { flex: 0 1 auto; font: inherit; font-size: 12px; font-weight: 600; padding: 7px 10px; border-radius: 6px; border: 1px solid var(--border); background: var(--surface); color: var(--muted); cursor: pointer; }
.status-steps button.done { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.status-steps button.current { background: var(--accent); color: #fff; border-color: var(--accent); }

.totals { width: 100%; }
.totals td { padding: 5px 0; }
.totals td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.totals tr.strong td { font-weight: 700; font-size: 16px; border-top: 1px solid var(--border); padding-top: 10px; }
.totals tr.sep td { border-top: 1px dashed var(--border); }

.bar { height: 8px; background: var(--gray-soft); border-radius: 4px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--accent); border-radius: 4px; }

/* ---------- Modal / toast / dropdown ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(12, 17, 29, .55); display: grid; place-items: center; z-index: 100; padding: 16px; }
.modal { background: var(--surface); border-radius: 12px; width: 100%; max-width: 560px; max-height: calc(100vh - 32px); overflow: auto; box-shadow: 0 20px 40px rgba(0,0,0,.25); }
.modal.wide { max-width: 760px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-body { padding: 20px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--border); }
.toasts { position: fixed; bottom: 16px; right: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast { background: var(--text); color: var(--surface); padding: 10px 16px; border-radius: 8px; box-shadow: var(--shadow); max-width: 360px; }
.toast.error { background: var(--danger); color: #fff; }
.dropdown { position: absolute; right: 0; top: calc(100% + 6px); width: 340px; max-height: 420px; overflow: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 12px 24px rgba(0,0,0,.15); z-index: 50; }
.dropdown .item { display: block; padding: 10px 14px; border-bottom: 1px solid var(--border); color: inherit; }
.dropdown .item:hover { background: var(--surface-2); text-decoration: none; }
.dropdown .item.unread { background: var(--accent-soft); }
.rel { position: relative; }

/* ---------- Auth pages ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.auth .card { width: 100%; max-width: 400px; }
.auth .brand { color: var(--text); text-align: center; padding: 0 0 8px; font-size: 26px; }
.auth .brand span { color: var(--accent); }
.auth form { display: flex; flex-direction: column; gap: 14px; }
.alert { padding: 10px 12px; border-radius: 8px; background: var(--danger-soft); color: var(--danger); font-size: 13px; }
.alert.ok { background: var(--accent-soft); color: var(--accent); }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .detail { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 260px; z-index: 90; transform: translateX(-100%); transition: transform .2s; }
  .shell.nav-open .sidebar { transform: none; }
  .shell.nav-open::after { content: ""; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 80; }
  .topbar .menu-btn { display: inline-flex; }
  .topbar { padding: 10px 16px; }
  .content { padding: 16px; }
  .grid-2, .grid-3, .form-grid { grid-template-columns: 1fr; }
  .dropdown { position: fixed; left: 16px; right: 16px; width: auto; top: 60px; }
  dl.props { grid-template-columns: 1fr; gap: 2px; }
  dl.props dd { margin-bottom: 8px; }
  .filters > * { flex: 1 1 140px; }
  /* Таблицы → карточки на телефоне */
  table.responsive thead { display: none; }
  table.responsive, table.responsive tbody, table.responsive tr, table.responsive td { display: block; width: 100%; }
  table.responsive tr { padding: 10px 14px; border-bottom: 1px solid var(--border); }
  table.responsive td { border: none; padding: 2px 0; text-align: left !important; display: flex; justify-content: space-between; gap: 12px; }
  table.responsive td::before { content: attr(data-label); color: var(--muted); font-size: 12px; flex: none; }
  table.responsive td[data-label=""]::before { content: none; }
  .kpi .value { font-size: 20px; }
}

.qty-input { width: 90px; min-height: 32px; padding: 4px 8px; }
.price-input { width: 100px; min-height: 32px; padding: 4px 8px; text-align: right; }
details summary { cursor: pointer; }
#mail-out { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 12px; max-height: 420px; overflow: auto; margin: 0; }
#mail-card .actions input { width: auto; flex: 1 1 200px; }
.sidebar-footer .muted-dark { color: #85888e; margin-top: 2px; }

/* Атрибут hidden сильнее любых display у классов */
[hidden] { display: none !important; }

/* ---------- Блог: редактор ---------- */
#post-form.detail { grid-template-columns: minmax(0, 1fr) 300px; }
.md-toolbar { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.md-split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.md-input { font: 14px/1.6 ui-monospace, "SF Mono", Menlo, monospace; min-height: 420px; }
.md-preview { border: 1px solid var(--border); border-radius: 8px; padding: 16px 18px; background: var(--surface); max-height: 640px; overflow: auto; margin-top: 4px; font-size: 15px; line-height: 1.65; }
.md-preview h2 { font-size: 20px; margin: 18px 0 8px; } .md-preview h3 { font-size: 16px; margin: 14px 0 6px; }
.md-preview p { margin: 0 0 10px; } .md-preview ul, .md-preview ol { padding-left: 20px; margin: 0 0 10px; }
.md-preview blockquote { margin: 0 0 10px; padding: 6px 12px; border-left: 3px solid var(--accent); background: var(--surface-2); }
.md-preview img { max-width: 100%; border-radius: 8px; } .md-preview figure { margin: 0 0 12px; }
.md-preview figcaption { font-size: 12px; color: var(--muted); }
.cover-img { width: 100%; border-radius: 8px; border: 1px solid var(--border); aspect-ratio: 1200 / 630; object-fit: cover; }
@media (max-width: 1100px) { #post-form.detail { grid-template-columns: 1fr; } .md-split { grid-template-columns: 1fr; } }
.vat-select { width: auto; min-height: 28px; padding: 2px 6px; font-size: 13px; margin-left: 4px; }

/* ---------- Редактор наклеек ---------- */
.card-head .row { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.stk { display: grid; grid-template-columns: minmax(300px, 380px) minmax(0, 1fr); gap: 16px; align-items: start; }
.stk-main { position: sticky; top: 16px; }
.stk-layouts { display: grid; gap: 8px; }
.stk-layout { display: flex; align-items: center; gap: 12px; padding: 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.stk-layout:hover { border-color: var(--accent); }
.stk-layout.active { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.stk-layout > span:last-child { display: flex; flex-direction: column; gap: 2px; }
.stk-mini { position: relative; width: 44px; flex: none; background: #fff; border: 1px solid #d0d5dd; }
.stk-mini i { position: absolute; border: 1px solid #98a2b3; border-radius: 50%; }
.stk-files { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.stk-thumb { display: flex; flex-direction: column; gap: 4px; padding: 6px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); color: var(--text); font: inherit; font-size: 11px; cursor: pointer; text-align: left; word-break: break-all; }
.stk-thumb img { width: 100%; height: 72px; object-fit: contain; background: repeating-conic-gradient(var(--gray-soft) 0 25%, var(--surface) 0 50%) 0 0 / 12px 12px; border-radius: 4px; }
.stk-thumb:hover, .stk-thumb.active { border-color: var(--accent); }
.stk-thumb.active { box-shadow: 0 0 0 2px var(--accent-soft); }
.stk-canvas { background: #111827; border-radius: 8px; padding: 8px; }
.stk-canvas canvas { display: block; width: 100%; height: auto; border-radius: 6px; touch-action: none; cursor: grab; }
.stk-canvas canvas:active { cursor: grabbing; }
.stk-zoom { display: flex; align-items: center; gap: 10px; font-size: 13px; margin: 8px 0; }
.stk-zoom input { flex: 1; accent-color: var(--accent); }
.stk-zoom output { min-width: 48px; text-align: right; font-variant-numeric: tabular-nums; }
.stk-wide { width: 100%; }
.stk-toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 8px; }
.stk-toolbar .spacer { flex: 1; }
.stk-stage { background: var(--gray-soft); border-radius: 8px; padding: 20px; margin: 12px 0; display: flex; justify-content: center; }
.stk-paper { position: relative; width: min(100%, 620px); aspect-ratio: 210 / 297; background: #fff; box-shadow: 0 8px 30px rgba(0, 0, 0, .18); }
.stk-hint { position: absolute; inset: 0; display: grid; place-items: center; color: #667085; font-size: 14px; }
.stk-sticker { position: absolute; padding: 0; border: 1px dashed rgba(21, 128, 61, .6); border-radius: 50%; background: transparent; overflow: hidden; cursor: pointer; }
.stk-sticker:hover { border-color: #15803d; background: rgba(21, 128, 61, .06); }
.stk-sticker.filled { border-color: rgba(16, 24, 40, .18); }
.stk-sticker.selected { border: 2px solid #175cd3; box-shadow: 0 0 0 3px rgba(23, 92, 211, .25); z-index: 1; }
.stk-sticker img { width: 100%; height: 100%; display: block; pointer-events: none; }
@media (max-width: 1100px) {
  .stk { grid-template-columns: 1fr; }
  .stk-main { position: static; }
  .stk-stage { padding: 10px; }
}

/* ---------- Посылки (apaczka.pl) ---------- */
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.timeline li .row { display: flex; flex-wrap: wrap; gap: 6px; }
.mt-s { margin-top: 8px; }
.form-grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.ship-quote { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding-top: 4px; border-top: 1px solid var(--border); }
.ship-quote [data-quote-out] { font-weight: 600; color: var(--text); }
@media (max-width: 820px) { .form-grid.four { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* ---------- Настройки: вкладки ---------- */
.page-tabs { padding: 0; margin-bottom: 16px; }
.settings-panels { max-width: 860px; }
.settings-panels > .hidden { display: none !important; }

/* ---------- Ссылка для клиента ---------- */
.link-box { display: flex; flex-direction: column; gap: 8px; }
.link-box input { width: 100%; font: inherit; font-size: 13px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); color: var(--text); }
.link-box .row, .card-body > .row { display: flex; flex-wrap: wrap; gap: 6px; }

/* ---------- Пользователи ---------- */
.actions-cell { white-space: nowrap; text-align: right; }
.actions-cell .btn + .btn { margin-left: 6px; }
.role-list { margin: 10px 0 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.role-list .badge { margin-right: 6px; }
.credentials { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 12px; margin: 10px 0; user-select: all; }

/* ---------- Импорт клиентов ---------- */
.drop-admin { display: flex; align-items: center; gap: 12px; padding: 14px; border: 1.5px dashed var(--border); border-radius: 10px; cursor: pointer; background: var(--surface-2); font-weight: 600; }
.drop-admin:hover { border-color: var(--accent); }
.drop-admin input { max-width: 220px; }
.import-summary { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 12px 0 8px; }
.import-preview { max-height: 320px; overflow: auto; }

/* ---------- Рассылки ---------- */
.nl-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(360px, 1fr); gap: 16px; align-items: start; }
.nl-preview-card { position: sticky; top: 16px; }
.nl-preview { background: var(--gray-soft); padding: 12px; display: flex; justify-content: center; border-radius: 0 0 var(--radius) var(--radius); }
.nl-preview iframe { width: 100%; height: 72vh; min-height: 480px; border: 0; background: #fff; border-radius: 8px; box-shadow: var(--shadow); transition: width .2s; }
.nl-preview.mobile iframe { width: 375px; max-width: 100%; }
textarea.code { display: block; width: 100%; min-height: 460px; border: 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); padding: 14px 16px; font: 12.5px/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; background: var(--surface-2); color: var(--text); resize: vertical; tab-size: 2; white-space: pre; }
textarea.code:focus { outline: none; background: var(--surface); }
.nl-tools { display: flex; flex-wrap: wrap; gap: 6px; }
.nl-tools select.btn { padding-right: 24px; }
.nl-count { padding: 10px 12px; border-radius: 8px; background: var(--accent-soft); }
.title-input { font: inherit; font-weight: 700; border: 1px solid transparent; border-radius: 8px; padding: 2px 6px; margin-left: -7px; background: transparent; color: var(--text); width: min(560px, 100%); }
.title-input:hover, .title-input:focus { border-color: var(--border); background: var(--surface); outline: none; }
.progress { height: 10px; border-radius: 999px; background: var(--gray-soft); overflow: hidden; }
.progress .bar { height: 100%; background: var(--accent); border-radius: 999px; transition: width .4s; }
.nl-kpis { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.nl-links { margin: 6px 0 0; padding-left: 18px; word-break: break-all; }
@media (max-width: 1100px) { .nl-grid { grid-template-columns: 1fr; } .nl-preview-card { position: static; } }
.card-head:has(.nl-tools) { flex-wrap: wrap; }
.nl-tools select.btn { width: auto; max-width: 200px; min-height: 30px; font-size: 12px; }

/* ---------- Входящие ---------- */
.mail { display: grid; grid-template-columns: minmax(300px, 400px) minmax(0, 1fr); gap: 16px; align-items: start; }
.mail-list { overflow: hidden; }
.mail-tools { padding: 12px 12px 0; display: flex; flex-direction: column; gap: 8px; border-bottom: 1px solid var(--border); }
.mail-tools input { width: 100%; padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; font: inherit; background: var(--surface); color: var(--text); }
.mail-tabs { padding: 0; border-bottom: 0; }
.mail-tabs button { padding: 8px 8px; font-size: 12.5px; }
.mail-items { list-style: none; margin: 0; padding: 0; max-height: calc(100vh - 260px); overflow: auto; }
.mail-items a { display: block; padding: 10px 14px; border-bottom: 1px solid var(--border); color: inherit; text-decoration: none; border-left: 3px solid transparent; }
.mail-items a:hover { background: var(--surface-2); }
.mail-items a.active { background: var(--accent-soft); border-left-color: var(--accent); }
.mail-items a.unread .mail-from, .mail-items a.unread .mail-subject { font-weight: 800; }
.mail-items a.unread { border-left-color: var(--info); }
.mail-from { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-subject { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-snippet { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-badges { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.mail-badges:empty { display: none; }
.mail-view { min-height: 400px; overflow: hidden; }
.mail-head { padding: 16px 20px; border-bottom: 1px solid var(--border); }
.mail-head h2 { margin: 4px 0 10px; font-size: 19px; }
.mail-meta { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.mail-client { display: flex; gap: 6px; align-items: flex-start; flex-wrap: wrap; }
.mail-client a.badge { text-decoration: none; }
.mail-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.mail-back { display: none; }
.mail-files { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; padding: 12px 20px; border-bottom: 1px solid var(--border); }
.mail-file { display: flex; gap: 10px; align-items: center; border: 1px solid var(--border); border-radius: 8px; padding: 8px; background: var(--surface-2); }
.mail-thumb { flex: none; width: 56px; height: 56px; border: 0; border-radius: 6px; padding: 0; cursor: zoom-in; display: grid; place-items: center; overflow: hidden;
  background: repeating-conic-gradient(var(--gray-soft) 0 25%, var(--surface) 0 50%) 0 0 / 12px 12px; }
.mail-thumb img { width: 100%; height: 100%; object-fit: cover; }
.mail-thumb .ext { font-weight: 800; font-size: 13px; color: var(--muted); }
.mail-file .info { min-width: 0; font-size: 12px; }
.mail-file .name { font-weight: 600; word-break: break-all; }
.mail-file .row { display: flex; gap: 4px; margin-top: 4px; flex-wrap: wrap; }
.mail-images { display: flex; gap: 10px; align-items: center; padding: 8px 20px 0; flex-wrap: wrap; }
.mail-body { display: block; width: 100%; height: 62vh; min-height: 360px; border: 0; background: #fff; }
.lightbox { text-align: center; background: repeating-conic-gradient(var(--gray-soft) 0 25%, var(--surface) 0 50%) 0 0 / 16px 16px; border-radius: 8px; padding: 8px; }
.lightbox img { max-width: 100%; max-height: 70vh; }
@media (max-width: 900px) {
  .mail { grid-template-columns: 1fr; }
  .mail.reading .mail-list { display: none; }
  .mail:not(.reading) .mail-view { display: none; }
  .mail-back { display: inline-block; }
  .mail-items { max-height: none; }
}

/* ---------- Входящие: настройка ---------- */
.mode-pick { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px; }
.mode-pick .mode { position: relative; display: flex; flex-direction: column; gap: 4px; padding: 12px 14px; border: 1.5px solid var(--border); border-radius: 10px; cursor: pointer; }
.mode-pick .mode.active { border-color: var(--accent); background: var(--accent-soft); }
.mode-pick input { position: absolute; opacity: 0; pointer-events: none; }
.setup-step { display: grid; grid-template-columns: 32px minmax(0, 1fr); gap: 12px; padding: 14px 0; border-top: 1px solid var(--border); }
.setup-step .num { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; background: var(--gray-soft); color: var(--muted); }
.setup-step.ok .num { background: var(--accent); color: #fff; }
.setup-step ol { margin: 0; padding-left: 18px; display: grid; gap: 4px; }
.table.dns code, .setup-step code { font-size: 12.5px; }
.copy-input { flex: 1; min-width: 0; font: inherit; font-size: 13px; padding: 6px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); color: var(--text); }
.dns code.break { word-break: break-all; }

/* Настройки → Сайт: галерея */
.gallery-admin { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.gallery-admin-item { display: grid; gap: 6px; border: 1px solid var(--border); border-radius: 10px; padding: 8px; background: var(--surface); }
.gallery-admin-item img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 6px; background: var(--gray-soft); }
.gallery-admin-item.is-hidden img { opacity: .35; }
.gallery-admin-item input:not([type]) { width: 100%; }
.gallery-admin-actions { display: flex; justify-content: space-between; align-items: center; gap: 6px; flex-wrap: wrap; }
.gallery-admin.logos { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.gallery-admin.logos img { aspect-ratio: 2 / 1; object-fit: contain; padding: 10px;
  background: repeating-conic-gradient(var(--gray-soft) 0 25%, var(--surface) 0 50%) 0 0 / 14px 14px; }
.slot-preview { display: grid; grid-template-columns: minmax(160px, 280px) 1fr; gap: 16px; align-items: start; }
.slot-preview img { width: 100%; border-radius: 10px; border: 1px solid var(--border);
  background: repeating-conic-gradient(var(--gray-soft) 0 25%, var(--surface) 0 50%) 0 0 / 14px 14px; }
@media (max-width: 640px) { .slot-preview { grid-template-columns: 1fr; } }
.gallery-admin-item { position: relative; }
.gallery-admin-item .cover-badge { position: absolute; top: 14px; left: 14px; }
.small-h { font-size: 14px; margin: 0 0 2px; }
.review-admin { display: grid; gap: 8px; border: 1px solid var(--border); border-radius: 10px; padding: 12px; background: var(--surface); }
.review-admin.is-hidden { opacity: .55; }


/* Контакты */
.ct-tabs .tab-count { display: inline-block; min-width: 20px; margin-left: 4px; padding: 0 6px; border-radius: 999px; background: var(--gray-soft); color: var(--muted); font-size: 11.5px; text-align: center; }
.ct-tabs button.active .tab-count { background: var(--accent-soft); color: var(--accent); }
.ct-hint { margin: 0; padding: 10px 16px 0; }
.ct-bulk { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 8px 16px; background: var(--info-soft); border-bottom: 1px solid var(--border); }
.ct-table .ct-check { width: 32px; }
.ct-table .ct-actions { text-align: right; }
.nl-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.check.chip { padding: 5px 10px; border: 1px solid var(--border); border-radius: 999px; cursor: pointer; }
.check.chip:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }

/* Входящие: неизвестный отправитель */
.mail-unknown { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 10px; padding: 10px 14px; border-radius: 10px; background: var(--warn-soft); border: 1px solid var(--warn); }
.mail-modes { display: flex; gap: 8px; flex-wrap: wrap; }
.mail-suggest { margin: 0; padding: 8px 12px; border-radius: 8px; background: var(--info-soft); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.mail-cust-list { min-height: 140px; }
.mail-modes input[type="radio"] { width: auto; height: auto; margin: 0; }

/* Входящие: аватар, ссылки-кнопки, плашка push */
.avatar { flex: none; width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; font-weight: 800;
  background: var(--warn-soft); color: var(--warn); }
.avatar.known { background: var(--accent-soft); color: var(--accent); }
.linklike { background: none; border: 0; padding: 0; font: inherit; color: var(--info); cursor: pointer; text-decoration: underline; }
.push-promo .card-body { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 16px; }
.push-promo .grow { flex: 1; min-width: 200px; }
.push-ico { font-size: 22px; }
#push-promo:not(:empty) { margin-bottom: 16px; }

/* Доступ ролей */
.access-table th.center, .access-table td.center { text-align: center; }
.access-cell { display: inline-flex; padding: 6px; border-radius: 8px; cursor: pointer; }
.access-cell.changed { background: var(--warn-soft); }
.access-cell input { width: 18px; height: 18px; margin: 0; }

/* Визуализации: миниатюра картинки леденца */
.viz-thumb { display: block; width: 56px; height: 90px; object-fit: cover; object-position: top; border-radius: 8px; border: 1px solid var(--border); }

/* ── Календарь ── */
.cal-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.cal-card { padding: 12px; }
.cal-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.cal-nav { display: flex; align-items: center; gap: 6px; }
.cal-nav b { min-width: 150px; text-align: center; text-transform: capitalize; }
.cal-filters { display: flex; flex-wrap: wrap; gap: 14px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-top: 1px solid var(--border); border-left: 1px solid var(--border); }
.cal-head { padding: 6px; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: capitalize; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); background: var(--surface-2); }
.cal-day { min-height: 104px; padding: 4px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); cursor: pointer; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cal-day:hover { background: var(--surface-2); }
.cal-day.other { background: var(--surface-2); }
.cal-day.other .cal-num { color: var(--muted); }
.cal-day.sel { box-shadow: inset 0 0 0 2px var(--info); }
.cal-num { font-size: 12px; font-weight: 600; width: 22px; height: 22px; display: grid; place-items: center; border-radius: 50%; }
.cal-day.today .cal-num { background: var(--accent); color: #fff; }
.cal-items { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cal-item { display: block; width: 100%; text-align: left; font: inherit; font-size: 11.5px; line-height: 1.35; padding: 1px 5px; border-radius: 4px; border: 0; cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-decoration: none; color: var(--text); }
.cal-item.ev { background: var(--info-soft); color: var(--info); }
.cal-item.ev.done { text-decoration: line-through; opacity: .6; }
.cal-item.ord { background: var(--warn-soft); color: var(--warn); }
.cal-item.ord.late { background: var(--danger-soft); color: var(--danger); font-weight: 600; }
.cal-item.ord.past { background: var(--gray-soft); color: var(--muted); }
.cal-item.lead { background: var(--purple-soft); color: var(--purple); }
.cal-item.nl { background: var(--accent-soft); color: var(--accent); }
.cal-item.nl.past { background: var(--gray-soft); color: var(--muted); }
.cal-time { font-weight: 600; }
.cal-more { font-size: 11px; color: var(--muted); padding-left: 5px; }
.cal-dots { display: none; gap: 3px; }
.cal-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; flex: none; }
.cal-dot.ev { background: var(--info); } .cal-dot.ord { background: var(--warn); } .cal-dot.late { background: var(--danger); } .cal-dot.lead { background: var(--purple); } .cal-dot.nl { background: var(--accent); }
.cal-legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 10px; }
.cal-legend .cal-dot { margin-right: 5px; }
.cal-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.cal-row { display: flex; align-items: center; gap: 8px; padding: 7px 0; border-bottom: 1px solid var(--border); }
.cal-row:last-child { border-bottom: 0; }
.cal-row.done .cal-row-main b { text-decoration: line-through; color: var(--muted); }
.cal-row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; text-align: left; background: none; border: 0; padding: 0; font: inherit; color: var(--text); cursor: pointer; text-decoration: none; }
.cal-row-main b { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; }
.cal-check { flex: none; width: 20px; height: 20px; border-radius: 6px; border: 1.5px solid var(--border); background: var(--surface); color: var(--accent); font-weight: 700; cursor: pointer; display: grid; place-items: center; padding: 0; }
.cal-row.done .cal-check { background: var(--accent-soft); border-color: var(--accent); }
.cal-agenda-day { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; margin: 12px 0 2px; }
.cal-agenda-day:first-child { margin-top: 0; }
.cal-agenda-day.today { color: var(--accent); }
.cal-agenda-day.late { color: var(--danger); }
.cal-quick, .cal-modal-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.cal-modal-actions { justify-content: space-between; }
.mail-reminders { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.mail-reminders .badge { cursor: pointer; border: 0; font: inherit; font-size: 12px; }
@media (max-width: 1100px) { .cal-layout { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 820px) {
  .cal-day { min-height: 54px; align-items: center; }
  .cal-items { display: none; }
  .cal-dots { display: flex; }
  .cal-nav b { min-width: 0; }
}
.mail-reminders:empty { display: none; }

/* Fakturownia: проверка перед выставлением */
.inv-h { font-size: 13px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); margin: 18px 0 8px; }
.inv-warnings { margin-bottom: 4px; }
.inv-warn-list { list-style: none; margin: 0; padding: 10px 12px; border-radius: 8px; background: var(--warn-soft); color: var(--warn); display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.inv-warn-list li.bad { color: var(--danger); font-weight: 600; }
.inv-ok { padding: 10px 12px; border-radius: 8px; background: var(--accent-soft); color: var(--accent); font-size: 13px; }
.inv-compare .small { padding: 8px 0; color: var(--muted); }
.inv-table td, .inv-table th { font-size: 13px; }
.inv-totals { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 18px; margin-top: 10px; font-size: 14px; }
.inv-ksef-note { margin-top: 12px; padding: 10px 12px; border-radius: 8px; background: var(--info-soft); color: var(--info); font-size: 13px; }

/* ---------- Доска производства ---------- */
.pb-load .card-body { padding-top: 12px; padding-bottom: 12px; }
.pb-load-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-bottom: 10px; }
.pb-days { display: grid; grid-template-columns: repeat(14, minmax(34px, 1fr)); gap: 4px; overflow-x: auto; }
.pb-day { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; color: var(--muted); }
.pb-day b { font-size: 12px; color: var(--text); min-height: 15px; }
.pb-day.today span { color: var(--accent); font-weight: 700; }
.pb-bar { width: 100%; height: 44px; background: var(--gray-soft); border-radius: 4px; display: flex; align-items: flex-end; overflow: hidden; }
.pb-bar i { display: block; width: 100%; background: var(--accent); border-radius: 4px 4px 0 0; }
.pb-day.over .pb-bar i { background: var(--danger); }
.pb-day.over b { color: var(--danger); }
.pb-board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(250px, 1fr); gap: 12px; overflow-x: auto; margin-top: 16px; padding-bottom: 8px; align-items: start; }
.pb-col { background: var(--gray-soft); border-radius: 12px; padding: 10px; min-height: 160px; border: 2px dashed transparent; }
.pb-col.readonly { opacity: .8; }
.pb-col.over { border-color: var(--accent); background: var(--accent-soft); }
.pb-col header { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin: 2px 4px 10px; }
.pb-list { display: flex; flex-direction: column; gap: 8px; }
.pb-empty { text-align: center; color: var(--muted); font-size: 12px; padding: 16px 0; }
.pb-card { background: var(--surface); box-shadow: var(--shadow); border: 1px solid var(--border); border-radius: 10px; padding: 10px; display: flex; flex-direction: column; gap: 4px; }
.pb-card[draggable] { cursor: grab; }
.pb-card.dragging { opacity: .4; }
.pb-card.late { border-color: var(--danger); box-shadow: inset 3px 0 0 var(--danger); }
.pb-top { display: flex; align-items: center; gap: 6px; }
.pb-qty { margin-left: auto; font-weight: 700; }
.pb-cust { font-weight: 600; }
.pb-pers { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pb-foot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.pb-late { color: var(--danger); font-weight: 700; }
.pb-move { margin-left: auto; display: flex; gap: 2px; }
.pb-move .btn { padding: 2px 8px; }
@media (max-width: 820px) { .pb-board { grid-auto-columns: 82%; scroll-snap-type: x mandatory; } .pb-col { scroll-snap-align: start; } }

/* ===== Входящие как Gmail ===== */
.gm { display: grid; grid-template-columns: 216px minmax(0, 1fr); gap: 16px; align-items: start; }
.gm-side { position: sticky; top: 76px; display: flex; flex-direction: column; gap: 12px; }
.gm-compose { display: inline-flex; align-items: center; gap: 12px; align-self: flex-start; padding: 16px 22px; border: 0; border-radius: 16px;
  background: var(--info-soft); color: var(--text); font: inherit; font-weight: 700; font-size: 14px; cursor: pointer; box-shadow: var(--shadow); transition: box-shadow .15s; }
.gm-compose:hover { box-shadow: 0 2px 6px rgba(16, 24, 40, .18); }
.gm-folders { display: flex; flex-direction: column; }
.gm-folders button { display: flex; align-items: center; gap: 12px; padding: 7px 14px 7px 18px; border: 0; border-radius: 0 999px 999px 0; background: none;
  font: inherit; font-size: 13.5px; color: var(--text); cursor: pointer; text-align: left; }
.gm-folders button:hover { background: var(--gray-soft); }
.gm-folders button.active { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.gm-ico { width: 18px; text-align: center; flex: none; }
.gm-fname { flex: 1; }
.gm-count { font-size: 12px; font-weight: 700; }
.gm-main { overflow: visible; min-height: 420px; position: relative; }
.gm-toolbar { display: flex; align-items: center; gap: 4px; padding: 6px 10px; border-bottom: 1px solid var(--border); flex-wrap: wrap; min-height: 48px; }
.gm-toolbar .spacer { flex: 1; }
.gm-sep { width: 1px; height: 22px; background: var(--border); margin: 0 4px; }
.gm-check { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 50%; cursor: pointer; flex: none; }
.gm-check:hover { background: var(--gray-soft); }
.gm-check input { width: 16px; height: 16px; margin: 0; cursor: pointer; }
.gm-bulk { display: inline-flex; gap: 2px; }
.gm-search { flex: 1 1 240px; max-width: 520px; margin-left: auto; padding: 8px 14px; border: 1px solid transparent; border-radius: 999px; font: inherit; background: var(--gray-soft); color: var(--text); }
.gm-search:focus { background: var(--surface); border-color: var(--border); outline: none; box-shadow: var(--shadow); }
.gm-range { margin: 0 4px 0 8px; white-space: nowrap; }

/* строки списка */
.gm-rows { list-style: none; margin: 0; padding: 0; }
.gm-row { position: relative; display: grid; grid-template-columns: 40px minmax(0, 1fr); align-items: center; padding: 0 8px 0 4px;
  border-bottom: 1px solid var(--border); background: var(--surface-2); cursor: pointer; }
.gm-row.unread { background: var(--surface); }
.gm-row:hover { box-shadow: inset 1px 0 0 var(--border), inset -1px 0 0 var(--border), 0 1px 3px rgba(16, 24, 40, .12); z-index: 1; }
.gm-row.sel { background: var(--info-soft); }
.gm-link { display: grid; grid-template-columns: 220px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 9px 4px; color: inherit; text-decoration: none; min-width: 0; }
.gm-link:hover { text-decoration: none; }
.gm-from { display: flex; align-items: center; gap: 8px; min-width: 0; }
.gm-from-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gm-n { color: var(--muted); font-size: 12px; font-weight: 400; }
.gm-text { display: flex; align-items: center; gap: 6px; min-width: 0; white-space: nowrap; overflow: hidden; }
.gm-text .badge { flex: none; font-size: 11px; padding: 1px 7px; }
.gm-subj { flex: none; max-width: 60%; overflow: hidden; text-overflow: ellipsis; }
.gm-snip { color: var(--muted); overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.gm-date { font-size: 12px; color: var(--muted); white-space: nowrap; text-align: right; min-width: 56px; }
.gm-clip { margin-right: 6px; }
.gm-row.unread .gm-from-name, .gm-row.unread .gm-subj, .gm-row.unread .gm-date { font-weight: 800; color: var(--text); }
.gm-quick { position: absolute; right: 8px; top: 6px; display: none; gap: 2px; background: inherit; }
.gm-row:hover .gm-quick { display: inline-flex; }
.gm-row:hover .gm-date { visibility: hidden; }
.avatar.sm { width: 26px; height: 26px; font-size: 10.5px; }
.avatar.me { background: var(--info-soft); color: var(--info); }

/* чипы вложений */
.gm-chips { grid-column: 2; display: flex; flex-wrap: wrap; gap: 6px; padding: 0 4px 10px 266px; }
.gm-chips.static { padding: 8px 0 0; }
.gm-chip { display: inline-flex; align-items: center; gap: 6px; max-width: 220px; padding: 4px 10px; border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface); color: var(--text); font: inherit; font-size: 12px; cursor: pointer; }
.gm-chip:hover { background: var(--gray-soft); }
.gm-chip.in-order { border-color: var(--accent); }
.gm-chip.more { cursor: default; color: var(--muted); }
.gm-chip-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.gm-chip-ok { color: var(--accent); font-weight: 800; }
.gm-chip button { border: 0; background: none; cursor: pointer; color: var(--muted); padding: 0 0 0 2px; font: inherit; }

/* переписка */
.gm-thread { padding: 4px 20px 20px; }
.gm-subject { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 14px 0 10px 50px; }
.gm-subject h2 { margin: 0; font-size: 21px; font-weight: 600; overflow-wrap: anywhere; }
.gm-labels { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.gm-labels a.badge { text-decoration: none; }
.gm-thread .mail-unknown { margin: 0 0 10px 50px; }
.gm-thread .mail-reminders { display: flex; gap: 6px; flex-wrap: wrap; margin: 0 0 8px 50px; }
.gm-thread .mail-reminders:empty { display: none; }
#msgs { border-top: 1px solid var(--border); }
.gm-msg { border-bottom: 1px solid var(--border); }
.gm-msg-head { display: flex; gap: 12px; align-items: flex-start; padding: 12px 0; cursor: pointer; }
.gm-msg.open .gm-msg-head { padding-bottom: 6px; }
.gm-msg-who { flex: 1; min-width: 0; }
.gm-msg-who > div:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gm-msg-sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gm-msg-date { white-space: nowrap; padding-top: 2px; }
.gm-msg.auto:not(.open) .gm-msg-head { padding: 8px 0; opacity: .8; }
.gm-msg-body { padding: 0 0 16px 50px; }
.gm-msg-subject { font-weight: 700; margin-bottom: 8px; }
.gm-msg-text { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; line-height: 1.55; }
.gm-msg-text a, .gm-quote a { color: var(--info); }
.gm-dots { margin-top: 8px; padding: 0 8px; height: 16px; line-height: 10px; border: 0; border-radius: 6px; background: var(--gray-soft); color: var(--muted); cursor: pointer; font-size: 12px; }
.gm-dots:hover { background: var(--border); }
.gm-quote { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13px; color: var(--muted); border-left: 2px solid var(--border); padding-left: 12px; margin-top: 8px; max-height: 360px; overflow: auto; }
.gm-msg-foot { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: 12px; }
.gm-msg-foot a.badge { text-decoration: none; }
.gm-bundle { display: block; width: 100%; border: 0; border-bottom: 1px solid var(--border); background: repeating-linear-gradient(var(--surface) 0 3px, var(--border) 3px 4px) center / 100% 9px no-repeat;
  padding: 8px 0; cursor: pointer; text-align: center; }
.gm-bundle span { display: inline-block; padding: 4px 14px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); font-size: 12.5px; font-weight: 600; color: var(--muted); }

/* вложения в письме */
.gm-atts { margin-top: 16px; padding-top: 12px; border-top: 1px dashed var(--border); }
.gm-atts-head { margin-bottom: 8px; }
.gm-att-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; max-width: 980px; }
.gm-att { position: relative; display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--surface); transition: box-shadow .15s, border-color .15s; }
.gm-att[draggable] { cursor: grab; }
.gm-att:hover { box-shadow: 0 2px 8px rgba(16, 24, 40, .15); }
.gm-att.sel { border-color: var(--info); box-shadow: 0 0 0 2px var(--info-soft); }
.gm-att.in-order { border-color: var(--accent); }
.gm-att.dragging { opacity: .45; }
.gm-att-thumb { display: grid; place-items: center; height: 112px; padding: 0; border: 0; border-bottom: 1px solid var(--border); background: var(--gray-soft); cursor: zoom-in; overflow: hidden; }
.gm-att-thumb img { width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
.gm-att-ext { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 30px; }
.gm-att-ext b { font-size: 11px; color: var(--muted); letter-spacing: .5px; }
.gm-att-check { position: absolute; top: 6px; left: 6px; width: 26px; height: 26px; display: grid; place-items: center; border-radius: 6px; background: var(--surface); box-shadow: var(--shadow); cursor: pointer; }
.gm-att-check input { margin: 0; width: 15px; height: 15px; cursor: pointer; }
.gm-att.in-order .gm-att-check { display: none; }
.gm-att-info { padding: 8px 10px 0; font-size: 12.5px; min-width: 0; }
.gm-att-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gm-att-order { display: inline-block; margin-top: 4px; font-size: 12px; font-weight: 700; color: var(--accent); text-decoration: none; }
.gm-att-actions { display: flex; gap: 4px; padding: 6px 8px 8px; justify-content: space-between; }

/* панели переноса в заказ */
.gm-selbar { position: sticky; bottom: 12px; z-index: 5; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 0 20px 12px; padding: 10px 14px;
  border-radius: 12px; background: var(--sidebar); color: #fff; box-shadow: 0 8px 24px rgba(0, 0, 0, .25); }
.gm-selbar .btn.ghost { color: #fff; }
.gm-selbar-hint { color: #cecfd2 !important; }
.gm-dock { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 120; width: min(860px, calc(100vw - 32px)); padding: 12px 14px;
  border-radius: 14px; background: var(--surface); border: 1px solid var(--border); box-shadow: 0 12px 36px rgba(0, 0, 0, .28); }
.gm-dock-title { font-weight: 700; font-size: 13px; margin-bottom: 8px; }
.gm-dock-targets { display: flex; gap: 8px; flex-wrap: wrap; }
.gm-drop { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-width: 108px; min-height: 58px; padding: 8px 12px;
  border: 2px dashed var(--border); border-radius: 10px; font-size: 13px; text-align: center; transition: background .1s, border-color .1s; }
.gm-drop.new { border-color: var(--accent); color: var(--accent); font-weight: 700; }
.gm-drop.over { border-style: solid; border-color: var(--accent); background: var(--accent-soft); transform: scale(1.04); }
.gm-pick { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.gm-pick input[type="radio"] { width: auto; height: auto; margin: 0; }

/* ответ */
.gm-reply { padding: 16px 0 0 50px; }
.gm-reply > .btn { border-radius: 999px; padding: 8px 22px; }
.gm-reply-card { border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 2px 8px rgba(16, 24, 40, .12); padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; background: var(--surface); }
.gm-reply-card.drag, .gm-compose-win.drag { outline: 2px dashed var(--info); outline-offset: -4px; }
.gm-reply-to { display: flex; align-items: center; gap: 8px; }
.gm-reply-to .spacer, .gm-reply-bar .spacer { flex: 1; }
.gm-reply-subj, .gm-reply-card textarea { width: 100%; border: 0; border-bottom: 1px solid var(--border); padding: 6px 2px; font: inherit; background: transparent; color: var(--text); }
.gm-reply-card textarea { border: 0; resize: vertical; min-height: 120px; outline: none; font-size: 14px; line-height: 1.5; }
.gm-reply-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.gm-cw-files { display: flex; flex-wrap: wrap; gap: 6px; }
.gm-cw-files:empty { display: none; }

/* окно «Новое письмо» */
.gm-compose-win { position: fixed; right: 24px; bottom: 0; z-index: 110; width: 540px; max-width: calc(100vw - 16px); height: min(560px, calc(100vh - 80px));
  display: flex; flex-direction: column; background: var(--surface); border-radius: 12px 12px 0 0; box-shadow: 0 8px 40px rgba(0, 0, 0, .3); overflow: hidden; }
.gm-compose-win.max { right: 50%; bottom: 50%; transform: translate(50%, 50%); width: min(1000px, calc(100vw - 48px)); height: calc(100vh - 96px); border-radius: 12px; }
.gm-compose-win.min { height: auto; width: 300px; }
.gm-compose-win.min .gm-cw-body, .gm-compose-win.min .gm-cw-foot { display: none; }
.gm-compose-win.min .gm-cw-head { cursor: pointer; }
.gm-cw-head { display: flex; align-items: center; gap: 4px; padding: 10px 10px 10px 16px; background: var(--gray-soft); font-size: 14px; }
.gm-cw-head .spacer, .gm-cw-foot .spacer { flex: 1; }
.gm-cw-btn { width: 28px; height: 28px; border: 0; border-radius: 6px; background: none; color: var(--muted); cursor: pointer; font-size: 13px; }
.gm-cw-btn:hover { background: var(--border); color: var(--text); }
.gm-cw-body { flex: 1; display: flex; flex-direction: column; padding: 0 16px; min-height: 0; position: relative; }
.gm-cw-line { display: flex; align-items: center; gap: 8px; border-bottom: 1px solid var(--border); padding: 4px 0; }
.gm-cw-line span { color: var(--muted); font-size: 13px; min-width: 42px; }
.gm-cw-line input { flex: 1; border: 0; padding: 6px 0; font: inherit; background: transparent; color: var(--text); outline: none; }
.gm-cw-body textarea { flex: 1; border: 0; resize: none; padding: 10px 0; font: inherit; font-size: 14px; line-height: 1.5; background: transparent; color: var(--text); outline: none; min-height: 120px; }
.gm-cw-body .gm-cw-files { padding-bottom: 8px; }
.gm-cw-drop { display: none; position: absolute; inset: 8px; border: 2px dashed var(--info); border-radius: 10px; background: color-mix(in srgb, var(--info-soft) 85%, transparent);
  place-items: center; font-weight: 700; color: var(--info); pointer-events: none; }
.gm-compose-win.drag .gm-cw-drop { display: grid; }
.gm-cw-foot { display: flex; align-items: center; gap: 8px; padding: 10px 16px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.gm-cw-foot .btn.primary { border-radius: 999px; padding: 8px 22px; }

@media (max-width: 1100px) {
  .gm-link { grid-template-columns: 170px minmax(0, 1fr) auto; }
  .gm-chips { padding-left: 216px; }
}
@media (max-width: 900px) {
  .gm { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .gm-side { position: static; }
  .gm-compose { position: fixed; right: 16px; bottom: 16px; z-index: 60; padding: 16px 18px; border-radius: 18px; box-shadow: 0 4px 16px rgba(0, 0, 0, .25); }
  .gm.reading .gm-compose { display: none; }
  .gm-folders { flex-direction: row; overflow-x: auto; gap: 6px; scrollbar-width: none; }
  .gm-folders button { flex: none; border-radius: 999px; padding: 6px 12px; border: 1px solid var(--border); background: var(--surface); }
  .gm.reading .gm-side { display: none; }
  .gm-search { order: 5; flex-basis: 100%; max-width: none; margin: 4px 0 2px; }
  .gm-link { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "from date" "text text"; gap: 2px 8px; padding: 10px 4px; }
  .gm-from { grid-area: from; }
  .gm-date { grid-area: date; }
  .gm-text { grid-area: text; flex-wrap: wrap; white-space: normal; padding-left: 34px; }
  .gm-subj { max-width: 100%; white-space: nowrap; }
  .gm-snip { flex-basis: 100%; white-space: nowrap; }
  .gm-chips { padding: 0 4px 10px 38px; }
  .gm-quick { display: none !important; }
  .gm-row:hover .gm-date { visibility: visible; }
  .gm-tl { display: none; }
  .gm-thread { padding: 4px 12px 16px; }
  .gm-subject, .gm-msg-body, .gm-reply, .gm-thread .mail-unknown, .gm-thread .mail-reminders { padding-left: 0; margin-left: 0; }
  .gm-att-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .gm-compose-win, .gm-compose-win.max { inset: 0; width: auto; height: auto; max-width: none; transform: none; border-radius: 0; }
  .gm-compose-win.min { inset: auto 8px 0 auto; width: 260px; border-radius: 12px 12px 0 0; }
  .gm-selbar { margin: 0 12px 12px; }
  .chat-hint { display: none; }
  .content:has(.gm.reading) > div > .page-head, .content:has(.gm.reading) #push-promo { display: none; }
}
.gm-embedded { border-top-style: dotted; }
.gm-embedded .gm-att-grid { margin-top: 8px; }
