/* KompNK Mail — дизайн-система */
:root {
  --bg: #f3f6fb; --surface: #ffffff; --surface-2: #f7f9fd; --surface-3: #eef2f9;
  --border: #e2e8f2; --border-strong: #cfd8e6;
  --text: #0e1a36; --muted: #64728c; --faint: #94a0b6;
  --accent: #1d6fe8; --accent-strong: #1559c2; --accent-soft: #e6f0fe; --on-accent: #fff;
  --danger: #d62d3d; --danger-soft: #fdecee; --success: #12814a; --success-soft: #e5f6ec;
  --warn: #b86e00; --warn-soft: #fff3dc; --star: #f4a21d;
  --row-read: #f5f7fb; --row-hover: #eaf1fd;
  --shadow-sm: 0 1px 2px rgba(14,26,54,.06);
  --shadow: 0 4px 16px rgba(14,26,54,.08);
  --shadow-lg: 0 16px 48px rgba(14,26,54,.18);
  --radius: 14px; --radius-sm: 9px;
  --font: Inter, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0b1120; --surface: #121a2d; --surface-2: #162036; --surface-3: #1b2740;
  --border: #243150; --border-strong: #32426a;
  --text: #e7ecf7; --muted: #8e9cb8; --faint: #62708e;
  --accent: #4d8dff; --accent-strong: #75a6ff; --accent-soft: #18284b; --on-accent: #07111f;
  --danger: #ff6b78; --danger-soft: #3a1b22; --success: #4cd08a; --success-soft: #12301f;
  --warn: #f1b34a; --warn-soft: #36290f; --star: #f7b23b;
  --row-read: #0f1729; --row-hover: #1a2745;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.4); --shadow: 0 4px 16px rgba(0,0,0,.35);
  --shadow-lg: 0 16px 48px rgba(0,0,0,.6);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    --bg: #0b1120; --surface: #121a2d; --surface-2: #162036; --surface-3: #1b2740;
    --border: #243150; --border-strong: #32426a;
    --text: #e7ecf7; --muted: #8e9cb8; --faint: #62708e;
    --accent: #4d8dff; --accent-strong: #75a6ff; --accent-soft: #18284b; --on-accent: #07111f;
    --danger: #ff6b78; --danger-soft: #3a1b22; --success: #4cd08a; --success-soft: #12301f;
    --warn: #f1b34a; --warn-soft: #36290f; --star: #f7b23b;
    --row-read: #0f1729; --row-hover: #1a2745;
    --shadow-sm: 0 1px 2px rgba(0,0,0,.4); --shadow: 0 4px 16px rgba(0,0,0,.35);
    --shadow-lg: 0 16px 48px rgba(0,0,0,.6);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: 15px; 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; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; line-height: 1.25; letter-spacing: -.01em; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ic { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round; }
.ic-sm { width: 16px; height: 16px; }
.muted { color: var(--muted); } .faint { color: var(--faint); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
kbd { font: 600 12px var(--font); background: var(--surface-3); border: 1px solid var(--border-strong);
  border-bottom-width: 2px; border-radius: 6px; padding: 1px 7px; }
code { font: 13px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; background: var(--surface-3);
  padding: 1px 6px; border-radius: 6px; }

/* ───── Кнопки ───── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 16px;
  border-radius: 10px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font-weight: 600; font-size: 14px; transition: background .15s, border-color .15s, transform .05s, box-shadow .15s;
  white-space: nowrap; text-decoration: none !important; }
.btn:hover { background: var(--surface-3); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); box-shadow: 0 2px 8px rgba(29,111,232,.28); }
.btn-primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn-danger { color: var(--danger); } .btn-danger:hover { background: var(--danger-soft); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-sm { height: 34px; padding: 0 12px; font-size: 13px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.icon-btn { display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; border: 0;
  background: transparent; color: var(--muted); transition: background .15s, color .15s; text-decoration: none !important; }
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn[disabled], .icon-btn.is-off { opacity: .35; pointer-events: none; }
.icon-btn.danger:hover { background: var(--danger-soft); color: var(--danger); }

/* ───── Каркас ───── */
.topbar { position: sticky; top: 0; z-index: 40; height: 64px; display: flex; align-items: center; gap: 12px;
  padding: 0 20px 0 12px; background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(12px); border-bottom: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 18px; color: var(--text);
  letter-spacing: -.02em; width: 236px; text-decoration: none !important; }
.brand img { width: 36px; height: 36px; border-radius: 50%; }
.brand span b { color: var(--accent); font-weight: 800; }
.search { flex: 1; max-width: 680px; position: relative; }
.search input { width: 100%; height: 42px; border-radius: 12px; border: 1px solid transparent; background: var(--surface-3);
  padding: 0 44px 0 42px; transition: background .15s, border-color .15s, box-shadow .15s; }
.search input:focus { outline: 0; background: var(--surface); border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.search .ic { position: absolute; left: 13px; top: 11px; color: var(--muted); pointer-events: none; }
.search kbd { position: absolute; right: 10px; top: 9px; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.avatar { width: 40px; height: 40px; border-radius: 50%; display: inline-grid; place-items: center; color: #fff;
  font-weight: 700; flex: none; user-select: none; }
.avatar.sm { width: 32px; height: 32px; font-size: 13px; }
.avatar.lg { width: 48px; height: 48px; font-size: 18px; }
.menu { position: relative; }
.menu-panel { position: absolute; right: 0; top: calc(100% + 8px); min-width: 250px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 8px; z-index: 60; }
.menu-panel .who { padding: 10px 12px 12px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.menu-panel .who b { display: block; } .menu-panel .who span { font-size: 13px; color: var(--muted); word-break: break-all; }
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 12px; border: 0; border-radius: 8px;
  background: none; text-align: left; color: var(--text); font-size: 14px; text-decoration: none !important; }
.menu-item:hover { background: var(--surface-3); }
.menu-item .ic { color: var(--muted); }

.shell { display: grid; grid-template-columns: 260px minmax(0, 1fr); min-height: calc(100vh - 64px); }
.sidebar { position: sticky; top: 64px; align-self: start; height: calc(100vh - 64px); overflow-y: auto; padding: 16px 12px 24px; }
.compose-btn { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; height: 52px; margin-bottom: 18px;
  border-radius: 16px; background: var(--accent); color: var(--on-accent); font-weight: 700; font-size: 15px;
  box-shadow: 0 6px 18px rgba(29,111,232,.32); text-decoration: none !important; transition: background .15s, transform .1s, box-shadow .15s; }
.compose-btn:hover { background: var(--accent-strong); box-shadow: 0 8px 24px rgba(29,111,232,.4); }
.compose-btn:active { transform: translateY(1px); }
.nav { display: grid; gap: 2px; }
.nav-item { display: flex; align-items: center; gap: 12px; height: 42px; padding: 0 12px; border-radius: 10px;
  color: var(--muted); font-weight: 500; text-decoration: none !important; transition: background .12s, color .12s; }
.nav-item:hover { background: var(--surface-3); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.nav-item .badge { margin-left: auto; font-size: 12px; font-weight: 700; min-width: 22px; text-align: center; padding: 1px 7px;
  border-radius: 999px; background: var(--surface-3); color: var(--muted); }
.nav-item.active .badge, .nav-item .badge.hot { background: var(--accent); color: var(--on-accent); }
.nav-sep { height: 1px; background: var(--border); margin: 14px 8px; }
.nav-hint { margin: 18px 12px 0; font-size: 12.5px; color: var(--faint); display: flex; gap: 8px; align-items: center; }

.main { padding: 20px 24px 48px; min-width: 0; }
.container { max-width: 1080px; margin: 0 auto; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.page-title { display: flex; align-items: center; gap: 12px; font-size: 24px; font-weight: 800; margin-bottom: 16px; }
.page-title .ic { color: var(--accent); width: 26px; height: 26px; }
.page-title small { font-size: 14px; font-weight: 500; color: var(--muted); }

/* ───── Список писем ───── */
.list-card { overflow: hidden; }
.list-toolbar { display: flex; align-items: center; gap: 6px; padding: 8px 12px; min-height: 56px; border-bottom: 1px solid var(--border); background: var(--surface); }
.list-toolbar .grow { flex: 1; }
.chk { appearance: none; width: 18px; height: 18px; margin: 0; border: 2px solid var(--border-strong); border-radius: 5px;
  background: var(--surface); display: inline-grid; place-items: center; cursor: pointer; flex: none; transition: .12s; }
.chk:hover { border-color: var(--accent); }
.chk:checked { background: var(--accent); border-color: var(--accent); }
.chk:checked::after { content: ""; width: 9px; height: 5px; border-left: 2px solid var(--on-accent); border-bottom: 2px solid var(--on-accent); transform: rotate(-45deg) translate(1px,-1px); }
.filters { display: flex; gap: 6px; flex-wrap: wrap; }
.pill { white-space: nowrap; flex: none; display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 13px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface); color: var(--muted); font-size: 13px; font-weight: 600; text-decoration: none !important; }
.pill:hover { background: var(--surface-3); color: var(--text); }
.pill.active { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.sel-count { font-weight: 700; padding: 0 8px; }

.mail-row { display: grid; grid-template-columns: auto auto 210px minmax(0,1fr) auto; align-items: center; gap: 10px;
  padding: 0 16px 0 12px; min-height: 62px; border-bottom: 1px solid var(--border); background: var(--row-read); cursor: pointer; position: relative;
  transition: background .1s; }
.mail-row:last-child { border-bottom: 0; }
.mail-row.unread { background: var(--surface); }
.mail-row:hover { background: var(--row-hover); }
.mail-row.selected { background: var(--accent-soft); }
.mail-row.focused { box-shadow: inset 3px 0 0 var(--accent); }
.mail-row .who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.mail-row .who span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-row .who .avatar, .mail-row.unread .who .avatar { color: #fff; font-weight: 700; }
.mail-row.unread .who span, .mail-row.unread .subj { font-weight: 700; color: var(--text); }
.mail-row .who span { color: var(--muted); } .mail-row.unread .who span { color: var(--text); }
.mail-row .text { min-width: 0; display: flex; gap: 8px; align-items: baseline; }
.mail-row .subj { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text); flex: 0 1 auto; max-width: 62%; }
.mail-row .snip { color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1 1 0; min-width: 0; font-size: 14px; }
.mail-row .meta { display: flex; align-items: center; gap: 10px; justify-content: flex-end; color: var(--muted); font-size: 13px; white-space: nowrap; }
.mail-row.unread .meta .date { color: var(--text); font-weight: 700; }
.mail-row .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.mail-row .row-actions { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); display: none; gap: 2px; background: var(--row-hover); padding-left: 8px; }
.mail-row:hover .row-actions { display: flex; }
.mail-row:hover .meta { visibility: hidden; }
.star { border: 0; background: none; padding: 4px; color: var(--border-strong); border-radius: 8px; display: inline-grid; transition: color .12s, transform .12s; }
.star:hover { color: var(--star); transform: scale(1.12); }
.star.on { color: var(--star); } .star.on .ic { fill: var(--star); }
.tag { font-size: 11.5px; font-weight: 700; padding: 1px 8px; border-radius: 999px; background: var(--surface-3); color: var(--muted); }
.tag.err { background: var(--danger-soft); color: var(--danger); } .tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.draft { background: var(--danger-soft); color: var(--danger); }
.pager { display: flex; align-items: center; justify-content: flex-end; gap: 6px; padding: 10px 14px; color: var(--muted); font-size: 13px; border-top: 1px solid var(--border); background: var(--surface); }
.empty { text-align: center; padding: 72px 24px; color: var(--muted); }
.empty .badge-ic { width: 84px; height: 84px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; margin: 0 auto 18px; }
.empty .badge-ic .ic { width: 38px; height: 38px; }
.empty h3 { color: var(--text); font-size: 20px; margin-bottom: 6px; }

/* ───── Просмотр письма ───── */
.view-bar { display: flex; align-items: center; gap: 4px; margin-bottom: 14px; flex-wrap: wrap; }
.view-bar .sp { flex: 1; }
.mail-card { overflow: hidden; }
.mail-head { padding: 24px 28px 18px; }
.mail-head h1 { font-size: 24px; font-weight: 800; word-break: break-word; margin-bottom: 18px; display: flex; align-items: flex-start; gap: 10px; }
.sender-row { display: flex; align-items: center; gap: 14px; }
.sender-row .info { min-width: 0; flex: 1; }
.sender-row b { font-size: 15px; } .sender-row .addr { color: var(--muted); font-size: 13.5px; word-break: break-all; }
.sender-row .when { color: var(--muted); font-size: 13px; text-align: right; white-space: nowrap; }
.details { margin-top: 10px; font-size: 13.5px; color: var(--muted); display: grid; gap: 2px; padding-left: 62px; }
.details b { color: var(--text); font-weight: 600; }
.banner { display: flex; align-items: center; gap: 12px; padding: 12px 28px; font-size: 14px; border-top: 1px solid var(--border); background: var(--surface-2); flex-wrap: wrap; }
.banner.warn { background: var(--warn-soft); color: var(--warn); } .banner.err { background: var(--danger-soft); color: var(--danger); }
.banner .grow { flex: 1; min-width: 200px; }
.mail-body { padding: 4px 28px 24px; }
.mail-frame-wrap { background: #fff; border-radius: 10px; border: 1px solid var(--border); overflow: hidden; }
.mail-frame { width: 100%; border: 0; display: block; min-height: 80px; background: #fff; color-scheme: light; }
.attach { padding: 18px 28px 22px; border-top: 1px solid var(--border); }
.attach h3 { font-size: 14px; margin-bottom: 12px; display: flex; align-items: center; gap: 10px; }
.attach-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.file { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); color: var(--text); text-decoration: none !important; transition: .12s; min-width: 0; }
.file:hover { border-color: var(--accent); background: var(--accent-soft); }
.file .ficon { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; font-size: 11px; font-weight: 800; color: #fff; flex: none; letter-spacing: .02em; background: #64748b; }
.file[data-kind="pdf"] .ficon { background: #e5484d; } .file[data-kind="doc"] .ficon { background: #2b6fe6; }
.file[data-kind="sheet"] .ficon { background: #1f9d55; } .file[data-kind="slides"] .ficon { background: #e8772e; }
.file[data-kind="archive"] .ficon { background: #8b5cf6; } .file[data-kind="image"] .ficon { background: #0ea5a4; } .file[data-kind="media"] .ficon { background: #d946a8; }
.file .fname { font-weight: 600; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file .fsize { font-size: 12px; color: var(--muted); } .file .fmeta { min-width: 0; }
.thumbs { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.thumbs a { display: block; border-radius: 12px; overflow: hidden; border: 1px solid var(--border); }
.thumbs img { display: block; height: 120px; width: auto; max-width: 260px; object-fit: cover; }
.thread { padding: 18px 28px 22px; border-top: 1px solid var(--border); }
.thread h3 { font-size: 14px; margin-bottom: 8px; }
.thread a { display: flex; gap: 12px; padding: 8px 10px; border-radius: 10px; color: var(--text); text-decoration: none !important; align-items: center; }
.thread a:hover { background: var(--surface-3); }
.reply-bar { padding: 16px 28px 24px; display: flex; gap: 10px; flex-wrap: wrap; border-top: 1px solid var(--border); }

/* ───── Написание письма ───── */
.compose-card { overflow: hidden; }
.compose-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 20px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.compose-head h1 { font-size: 17px; font-weight: 800; }
.save-state { font-size: 13px; color: var(--muted); }
.field { display: flex; align-items: flex-start; gap: 10px; padding: 6px 20px; border-bottom: 1px solid var(--border); min-height: 48px; }
.field > label { width: 64px; padding-top: 11px; color: var(--muted); font-size: 14px; flex: none; }
.field > .ctl { flex: 1; min-width: 0; position: relative; }
.field input.plain { width: 100%; border: 0; background: none; height: 36px; margin-top: 3px; outline: 0; font-size: 15px; }
.field .extra { padding-top: 9px; display: flex; gap: 10px; font-size: 13px; }
.field .extra button { border: 0; background: none; color: var(--accent); font-weight: 600; padding: 2px 4px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 5px 0; min-height: 36px; cursor: text; }
.chips input { border: 0; outline: 0; background: none; flex: 1; min-width: 160px; height: 28px; font-size: 15px; }
.chip { display: inline-flex; align-items: center; gap: 4px; height: 28px; padding: 0 6px 0 10px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: 13.5px; font-weight: 600; max-width: 100%; }
.chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip.bad { background: var(--danger-soft); color: var(--danger); }
.chip button { border: 0; background: none; color: inherit; width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; padding: 0; opacity: .75; }
.chip button:hover { opacity: 1; background: rgba(0,0,0,.08); }
.suggest { position: absolute; left: 0; top: 100%; z-index: 30; min-width: 320px; max-width: 100%; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); overflow: hidden; }
.suggest button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 12px; border: 0; background: none; text-align: left; }
.suggest button:hover, .suggest button.on { background: var(--accent-soft); }
.suggest .nm { font-weight: 600; font-size: 14px; } .suggest .ad { font-size: 12.5px; color: var(--muted); }
.editor-bar { display: flex; align-items: center; gap: 2px; padding: 6px 14px; border-bottom: 1px solid var(--border); flex-wrap: wrap; background: var(--surface); }
.editor-bar button { min-width: 34px; height: 34px; padding: 0 8px; border: 0; border-radius: 8px; background: none; color: var(--muted); display: inline-grid; place-items: center; font-size: 15px; }
.editor-bar button:hover { background: var(--surface-3); color: var(--text); }
.editor-bar .sep { width: 1px; height: 20px; background: var(--border); margin: 0 6px; }
.editor { min-height: 320px; padding: 18px 22px; outline: 0; line-height: 1.6; word-break: break-word; overflow-wrap: anywhere; }
.editor:empty::before { content: attr(data-placeholder); color: var(--faint); }
.editor blockquote, .prose blockquote { margin: 8px 0; padding: 2px 0 2px 14px; border-left: 3px solid var(--border-strong); color: var(--muted); }
.editor .quote-head { color: var(--muted); font-size: 14px; }
.editor img { max-width: 100%; height: auto; }
.dropzone { margin: 0 20px 14px; border: 2px dashed var(--border-strong); border-radius: 12px; padding: 14px 16px; display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 14px; transition: .15s; }
.dropzone.over { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.dropzone label { color: var(--accent); font-weight: 600; cursor: pointer; }
.att-list { padding: 0 20px 6px; display: flex; flex-wrap: wrap; gap: 8px; }
.att-item { display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 6px 0 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); font-size: 13.5px; max-width: 100%; }
.att-item .nm { max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.att-item small { color: var(--muted); }
.att-item button { border: 0; background: none; width: 24px; height: 24px; border-radius: 6px; color: var(--muted); display: grid; place-items: center; padding: 0; }
.att-item button:hover { background: var(--danger-soft); color: var(--danger); }
.compose-foot { display: flex; align-items: center; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--border); background: var(--surface-2); flex-wrap: wrap; }
.split { display: inline-flex; position: relative; }
.split .btn:first-child { border-radius: 10px 0 0 10px; padding: 0 20px; }
.split .btn:last-child { border-radius: 0 10px 10px 0; padding: 0 10px; border-left: 1px solid rgba(255,255,255,.3); }
.popover { position: absolute; bottom: calc(100% + 8px); left: 0; z-index: 50; width: 280px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-lg); padding: 8px; }
.popover h4 { margin: 6px 10px 8px; font-size: 13px; color: var(--muted); font-weight: 600; }
.popover .opt { display: flex; align-items: center; justify-content: space-between; width: 100%; padding: 9px 10px; border: 0; background: none; border-radius: 8px; text-align: left; font-size: 14px; }
.popover .opt:hover { background: var(--surface-3); } .popover .opt small { color: var(--muted); }
.popover .custom { padding: 8px 10px; display: grid; gap: 8px; border-top: 1px solid var(--border); margin-top: 6px; }
.sched-note { display: inline-flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--accent); font-weight: 600; background: var(--accent-soft); padding: 5px 8px 5px 12px; border-radius: 999px; }
.sched-note button { border: 0; background: none; color: inherit; display: grid; padding: 2px; }

/* ───── Формы, настройки, контакты ───── */
.form-card { padding: 24px 28px; margin-bottom: 18px; }
.form-card h2 { font-size: 17px; margin-bottom: 4px; } .form-card > p { margin: 0 0 18px; color: var(--muted); font-size: 14px; }
.row { display: grid; gap: 6px; margin-bottom: 16px; } .row label, .lbl { font-weight: 600; font-size: 13.5px; }
.row small { color: var(--muted); font-size: 12.5px; }
.input, select.input, textarea.input { width: 100%; height: 44px; padding: 0 14px; border: 1px solid var(--border-strong); border-radius: 10px; background: var(--surface); transition: .15s; }
textarea.input { height: auto; min-height: 96px; padding: 10px 14px; resize: vertical; line-height: 1.5; }
.input:focus { outline: 0; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.seg { display: inline-flex; padding: 4px; background: var(--surface-3); border-radius: 12px; gap: 4px; }
.seg label { cursor: pointer; } .seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 18px; border-radius: 9px; font-weight: 600; color: var(--muted); font-size: 14px; }
.seg input:checked + span { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.seg input:focus-visible + span { outline: 2px solid var(--accent); }
.kv { display: grid; grid-template-columns: 160px 1fr; gap: 8px 16px; font-size: 14px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; font-weight: 600; word-break: break-all; }
.info-box { background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 16px 18px; }
.contacts-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.contact { display: flex; align-items: center; gap: 12px; padding: 14px; }
.contact .info { flex: 1; min-width: 0; } .contact b, .contact .em { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.contact .em { color: var(--muted); font-size: 13px; }
.edit-form { display: grid; grid-template-columns: 1fr 1fr auto; gap: 10px; align-items: center; }

/* ───── Вход / регистрация ───── */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(1100px 600px at 15% -10%, color-mix(in srgb, var(--accent) 22%, transparent), transparent 60%),
              radial-gradient(900px 500px at 100% 110%, color-mix(in srgb, #14b8c6 20%, transparent), transparent 60%), var(--bg); }
.auth-card { width: 100%; max-width: 440px; padding: 40px 36px; text-align: center; box-shadow: var(--shadow-lg); border-radius: 22px; }
.auth-card .logo { width: 92px; height: 92px; border-radius: 50%; margin: 0 auto 18px; display: block; box-shadow: var(--shadow); }
.auth-card h1 { font-size: 27px; font-weight: 800; margin-bottom: 6px; } .auth-card p { color: var(--muted); margin: 0 0 24px; }
.auth-card .btn { height: 50px; font-size: 15px; border-radius: 12px; }
.features { display: grid; gap: 10px; text-align: left; margin: 26px 0 0; padding: 20px 0 0; border-top: 1px solid var(--border); font-size: 14px; color: var(--muted); }
.features div { display: flex; gap: 10px; align-items: center; } .features .ic { color: var(--accent); }
.steps { display: flex; justify-content: center; gap: 8px; margin-bottom: 24px; }
.steps i { width: 32px; height: 5px; border-radius: 3px; background: var(--border-strong); } .steps i.on { background: var(--accent); }
.addr-input { display: flex; align-items: center; border: 1px solid var(--border-strong); border-radius: 12px; overflow: hidden; background: var(--surface); transition: .15s; }
.addr-input:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.addr-input input { flex: 1; border: 0; background: none; height: 50px; padding: 0 14px; outline: 0; font-size: 16px; min-width: 0; }
.addr-input span { padding: 0 14px; color: var(--muted); background: var(--surface-3); height: 50px; display: grid; place-items: center; font-weight: 600; }
.hint { min-height: 22px; text-align: left; margin: 8px 2px 14px; font-size: 13.5px; } .hint.ok { color: var(--success); } .hint.bad { color: var(--danger); }
.auth-card .flash { text-align: left; }
@keyframes bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
.bob { animation: bob 2.2s ease-in-out infinite; }

/* ───── Уведомления, модалки ───── */
.flashes { display: grid; gap: 8px; margin-bottom: 16px; }
.flash { display: flex; align-items: center; gap: 10px; padding: 11px 14px; border-radius: 12px; font-size: 14px; font-weight: 500; background: var(--success-soft); color: var(--success); transition: opacity .4s; }
.flash.error { background: var(--danger-soft); color: var(--danger); }
.toasts { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 200; display: grid; gap: 10px; justify-items: center; width: min(92vw, 520px); pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 14px; background: #16203a; color: #fff; padding: 12px 14px 12px 18px; border-radius: 14px; box-shadow: var(--shadow-lg); font-size: 14px; animation: rise .25s ease-out; max-width: 100%; }
:root[data-theme="dark"] .toast { background: #e7ecf7; color: #0e1a36; }
.toast .t-btn { border: 0; background: none; color: #7fb0ff; font-weight: 700; padding: 4px 8px; border-radius: 8px; font-size: 14px; }
:root[data-theme="dark"] .toast .t-btn { color: #1559c2; }
.toast .t-btn:hover { background: rgba(255,255,255,.12); }
.toast .bar { height: 3px; border-radius: 2px; background: currentColor; opacity: .35; position: absolute; left: 14px; right: 14px; bottom: 4px; transform-origin: left; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.modal-back { position: fixed; inset: 0; background: rgba(8,14,30,.5); backdrop-filter: blur(3px); z-index: 150; display: grid; place-items: center; padding: 20px; animation: fade .15s; }
@keyframes fade { from { opacity: 0; } }
.modal { background: var(--surface); border-radius: 18px; box-shadow: var(--shadow-lg); width: 100%; max-width: 440px; padding: 26px; border: 1px solid var(--border); }
.modal h3 { font-size: 19px; margin-bottom: 8px; } .modal p { margin: 0 0 22px; color: var(--muted); }
.modal .btns { display: flex; justify-content: flex-end; gap: 10px; }
.modal.wide { max-width: 620px; } .modal .keys { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 28px; margin-top: 14px; font-size: 14px; }
.modal .keys div { display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 5px 0; border-bottom: 1px dashed var(--border); }
.modal .keys h4 { grid-column: 1 / -1; margin: 10px 0 0; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }

.error-page { text-align: center; padding: 100px 20px; } .error-page h1 { font-size: 72px; color: var(--accent); margin-bottom: 8px; }
.scrim { display: none; }
.only-mobile { display: none; }

/* ───── Адаптив ───── */
@media (max-width: 960px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 90; left: 0; top: 64px; bottom: 0; width: 280px; background: var(--surface); transform: translateX(-102%); transition: transform .22s ease; box-shadow: var(--shadow-lg); height: auto; }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .scrim { display: block; position: fixed; inset: 64px 0 0 0; background: rgba(8,14,30,.45); z-index: 80; }
  #help-btn { display: none; }
  .topbar { padding-right: 10px; gap: 6px; }
  .filters { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .filters::-webkit-scrollbar { display: none; }
  .tb-default { flex-wrap: nowrap !important; min-width: 0; }
  .list-toolbar { padding: 8px; gap: 4px; }
  .only-mobile { display: inline-grid; } .brand { width: auto; } .brand span { display: none; } .search kbd { display: none; }
  .main { padding: 14px 12px 40px; }
  .mail-row { grid-template-columns: auto auto minmax(0,1fr) auto; grid-template-rows: auto auto; padding: 10px 12px 10px 8px; row-gap: 0; }
  .mail-row .who { grid-column: 3; } .mail-row .meta { grid-column: 4; grid-row: 1; } .mail-row .text { grid-column: 3 / 5; grid-row: 2; }
  .mail-row .avatar { display: none; } .mail-row .row-actions { display: none !important; } .mail-row:hover .meta { visibility: visible; }
  .mail-row .subj { max-width: 100%; } .mail-row .snip { display: none; }
  .mail-head, .mail-body, .attach, .thread, .reply-bar, .banner { padding-left: 16px; padding-right: 16px; } .details { padding-left: 0; }
  .grid2, .edit-form { grid-template-columns: 1fr; } .kv { grid-template-columns: 1fr; }
  .field { padding: 4px 12px; } .field > label { width: 52px; } .dropzone, .att-list { margin-left: 12px; margin-right: 12px; padding-left: 0; padding-right: 0; }
  .form-card { padding: 18px 16px; } .sender-row .when { display: none; }
}
@media print {
  .topbar, .sidebar, .view-bar, .reply-bar, .scrim, .toasts, .banner, .thread { display: none !important; }
  .shell { display: block; } .main { padding: 0; } .card { border: 0; box-shadow: none; } body { background: #fff; }
}
