:root {
  --bg: #f5f7f4;
  --surface: #ffffff;
  --surface-2: #f0f1f6;
  --border: #e3e5ec;
  --text: #1c1f2a;
  --muted: #6b7183;
  --accent: #1f9d45;
  --accent-soft: #e5f4e9;
  --brand-orange: #f28a1e;
  --accent-text: #ffffff;
  --danger: #d13b3b;
  --ok: #1f9d55;
  --rail: #0e3b22;
  --rail-text: #b7d8c1;
  --bubble-me: #1f9d45;
  --bubble-me-text: #ffffff;
  --bubble: #ffffff;
  --shadow: 0 6px 24px rgba(20, 20, 50, .12);
  --radius: 10px;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  font-size: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12131a;
    --surface: #1a1c25;
    --surface-2: #232633;
    --border: #2d3040;
    --text: #e6e7ee;
    --muted: #9095a8;
    --accent: #3dbb62;
    --accent-soft: #183a25;
    --brand-orange: #f59a3c;
    --rail: #082416;
    --rail-text: #a3c9ae;
    --bubble-me: #1c8a3d;
    --bubble: #232633;
    --shadow: 0 6px 24px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--danger); min-height: 1.2em; margin: 4px 0; }
h1, h2, h3 { margin: 0; font-weight: 600; }
h2 { font-size: 18px; }
a { color: var(--accent); }
button { font: inherit; color: inherit; cursor: pointer; }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
label { display: block; font-weight: 500; margin: 10px 0 0; }
label > input, label > select, label > textarea { margin-top: 4px; font-weight: 400; }
label.check { display: flex; align-items: center; gap: 8px; font-weight: 400; }
label.check input { width: auto; margin: 0; }

.btn {
  border: 1px solid var(--border); background: var(--surface); border-radius: 8px;
  padding: 8px 14px; font-weight: 500;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .6; cursor: default; }
.icon-btn { border: 0; background: transparent; border-radius: 6px; width: 30px; height: 30px; font-size: 16px; color: var(--muted); }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.link-btn { border: 0; background: none; color: var(--accent); padding: 0; font-size: 12px; font-weight: 500; }

/* ---------- Login ---------- */
.login { min-height: 100%; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(circle at 15% 10%, var(--accent-soft), transparent 50%), radial-gradient(circle at 90% 95%, rgba(242,138,30,.12), transparent 45%), var(--bg); }
.login-card { width: 100%; max-width: 360px; background: var(--surface); padding: 32px; border-radius: 16px; box-shadow: var(--shadow); text-align: center; }
.login-card label { text-align: left; }
.login-card h1 { margin-top: 18px; font-size: 22px; }
.login-logo { width: 100%; max-width: 250px; height: auto; display: block; margin: 0 auto; }
.login-org { margin: 8px 0 0; font-size: 12.5px; font-weight: 600; color: var(--brand-orange); letter-spacing: .2px; }
.login-card { border-top: 4px solid var(--accent); }
.login-card .btn { margin-top: 12px; padding: 10px; }
.brand-mark { position: relative; width: 40px; height: 40px; border-radius: 10px; background: #fff; color: #1f9d45; font-size: 22px; display: grid; place-items: center; font-weight: 700; letter-spacing: .5px; margin: 0 auto; }
.brand-mark::after { content: ''; position: absolute; top: 6px; right: 6px; width: 7px; height: 7px; border-radius: 50%; background: #f28a1e; }
.brand-mark.big { width: 56px; height: 56px; font-size: 20px; border-radius: 14px; }

/* ---------- Layout ---------- */
.app { display: flex; height: 100vh; }
.rail { width: 76px; background: var(--rail); display: flex; flex-direction: column; align-items: center; padding: 14px 0; gap: 6px; flex-shrink: 0; }
.rail .brand-mark { margin-bottom: 14px; }
.rail-btn { position: relative; border: 0; background: transparent; color: var(--rail-text); width: 64px; padding: 8px 0; border-radius: 10px; display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 11px; }
.rail-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; stroke-linecap: round; }
.rail-btn:hover { background: rgba(255,255,255,.08); color: #fff; }
.rail-btn.active { background: rgba(255,255,255,.14); color: #fff; box-shadow: inset 3px 0 0 var(--brand-orange); }
.rail-spacer { flex: 1; }
.rail-me { border: 0; background: none; padding: 0; border-radius: 50%; }
.badge { position: absolute; top: 2px; right: 8px; background: var(--brand-orange); color: #fff; font-size: 10px; min-width: 18px; height: 18px; border-radius: 9px; display: grid; place-items: center; padding: 0 5px; font-weight: 600; }

.view { flex: 1; display: flex; min-width: 0; }
.sidebar { width: 290px; background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; padding: 16px 12px; gap: 10px; flex-shrink: 0; }
.sidebar.narrow { width: 210px; }
.sidebar-head { display: flex; align-items: center; justify-content: space-between; padding: 0 4px; }
.head-actions { display: flex; gap: 2px; }
.search { background: var(--surface-2); border-color: transparent; }
.list-section { overflow-y: auto; flex: 1; margin: 0 -4px; padding: 0 4px; }
.list-title { display: flex; justify-content: space-between; align-items: center; font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); font-weight: 600; margin: 14px 8px 6px; }
.conv-list, .folder-list, .mail-list { list-style: none; margin: 0; padding: 0; }
.conv-item { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: 8px; cursor: pointer; }
.conv-item:hover { background: var(--surface-2); }
.conv-item.active { background: var(--accent-soft); }
.conv-item .meta { flex: 1; min-width: 0; }
.conv-item .name { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-item.unread .name { font-weight: 700; }
.conv-item .preview { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-item .hash { width: 32px; height: 32px; border-radius: 8px; background: var(--surface-2); display: grid; place-items: center; color: var(--muted); font-weight: 600; flex-shrink: 0; }
.pill { background: var(--brand-orange); color: #fff; border-radius: 10px; font-size: 11px; padding: 1px 7px; font-weight: 600; }

.pane { flex: 1; display: flex; flex-direction: column; min-width: 0; background: var(--bg); }
.empty-state { margin: auto; text-align: center; color: var(--muted); }
.empty-icon { font-size: 40px; margin-bottom: 8px; }

/* ---------- Avatars ---------- */
.avatar { position: relative; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 600; font-size: 12px; flex-shrink: 0; }
.avatar.lg { width: 56px; height: 56px; font-size: 18px; }
.avatar.sm { width: 24px; height: 24px; font-size: 10px; }
.avatar .dot { position: absolute; right: -1px; bottom: -1px; width: 10px; height: 10px; border-radius: 50%; background: var(--ok); border: 2px solid var(--surface); }
.avatar.lg .dot { width: 14px; height: 14px; }
.av0 { background: #4f46e5; } .av1 { background: #0e9f6e; } .av2 { background: #d97706; } .av3 { background: #db2777; }
.av4 { background: #0891b2; } .av5 { background: #7c3aed; } .av6 { background: #dc2626; } .av7 { background: #4b5563; }

/* ---------- Chat ---------- */
.chat-head { display: flex; align-items: center; gap: 12px; padding: 12px 20px; background: var(--surface); border-bottom: 1px solid var(--border); min-height: 62px; }
.chat-head .title { flex: 1; min-width: 0; }
.chat-head .title h3 { font-size: 16px; }
.chat-head .title p { margin: 2px 0 0; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.messages { flex: 1; overflow-y: auto; padding: 16px 20px; display: flex; flex-direction: column; gap: 2px; }
.day-sep { text-align: center; color: var(--muted); font-size: 12px; margin: 14px 0 8px; }
.msg { display: flex; gap: 10px; align-items: flex-end; max-width: 75%; position: relative; }
.msg.me { align-self: flex-end; flex-direction: row-reverse; }
.msg .avatar-slot { width: 32px; flex-shrink: 0; }
.msg .bubble { background: var(--bubble); border: 1px solid var(--border); padding: 7px 11px; border-radius: 14px; white-space: pre-wrap; word-wrap: break-word; overflow-wrap: anywhere; min-width: 0; }
.msg.me .bubble { background: var(--bubble-me); color: var(--bubble-me-text); border-color: transparent; }
.msg.me .bubble a { color: inherit; }
.msg .sender { font-size: 12px; font-weight: 600; margin-bottom: 2px; color: var(--accent); }
.msg .time { font-size: 10.5px; opacity: .7; margin-left: 8px; float: right; margin-top: 5px; }
.msg.deleted .bubble { font-style: italic; opacity: .6; }
.msg.grouped { margin-top: -0px; }
.msg.first { margin-top: 8px; }
.msg-actions { display: none; gap: 2px; align-self: center; }
.msg:hover .msg-actions { display: flex; }
.msg-actions button { border: 0; background: var(--surface); border-radius: 6px; font-size: 12px; padding: 3px 6px; color: var(--muted); box-shadow: 0 1px 3px rgba(0,0,0,.1); }
.attachments { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.att { display: inline-flex; align-items: center; gap: 6px; background: rgba(127,127,127,.12); border-radius: 8px; padding: 5px 9px; font-size: 12px; text-decoration: none; color: inherit; max-width: 260px; }
.att span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.att-img { display: block; max-width: 260px; max-height: 200px; border-radius: 8px; margin-top: 6px; }
.typing { font-size: 12px; color: var(--muted); padding: 0 22px 4px; height: 18px; }
.composer { padding: 10px 20px 16px; }
.composer-box { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 6px; display: flex; flex-direction: column; gap: 4px; }
.composer-box:focus-within { border-color: var(--accent); }
.composer-row { display: flex; align-items: flex-end; gap: 4px; }
.composer textarea { border: 0; resize: none; max-height: 160px; min-height: 36px; padding: 8px; background: transparent; }
.composer textarea:focus { outline: none; }
.pending-files { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 4px; }
.pending-files:empty { display: none; }
.chip { display: inline-flex; align-items: center; gap: 4px; background: var(--accent-soft); border-radius: 14px; padding: 3px 4px 3px 10px; font-size: 12.5px; }
.chip button { border: 0; background: none; padding: 0 5px; color: var(--muted); font-size: 14px; line-height: 1; }
.load-more { align-self: center; margin-bottom: 8px; }

/* ---------- Mail ---------- */
.folder-list li { padding: 8px 12px; border-radius: 8px; cursor: pointer; display: flex; justify-content: space-between; font-weight: 500; }
.folder-list li:hover { background: var(--surface-2); }
.folder-list li.active { background: var(--accent-soft); color: var(--accent); }
.folder-list b { font-size: 12px; }
.mail-list-col { width: 360px; border-right: 1px solid var(--border); background: var(--surface); display: flex; flex-direction: column; flex-shrink: 0; }
.mail-list-head { padding: 16px 12px 10px; display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }
.mail-list { overflow-y: auto; flex: 1; }
.mail-item { padding: 10px 14px; border-bottom: 1px solid var(--border); cursor: pointer; display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; border-left: 3px solid transparent; }
.mail-item:hover { background: var(--surface-2); }
.mail-item.active { background: var(--accent-soft); }
.mail-item.unread { border-left-color: var(--brand-orange); }
.mail-item.unread .from, .mail-item.unread .subject { font-weight: 700; }
.mail-item .from { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mail-item .date { font-size: 12px; color: var(--muted); }
.mail-item .subject { grid-column: 1 / -1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mail-item .snippet { grid-column: 1 / -1; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mail-item .flags { font-size: 12px; color: var(--muted); }
.star { color: #e3a008; }
.high { color: var(--danger); font-weight: 700; }
.list-empty { padding: 30px; text-align: center; color: var(--muted); }
.reader { overflow-y: auto; }
.reader-toolbar { display: flex; gap: 6px; padding: 12px 24px; border-bottom: 1px solid var(--border); background: var(--surface); flex-wrap: wrap; position: sticky; top: 0; }
.reader-body { padding: 20px 28px 40px; max-width: 900px; }
.reader-body h2 { font-size: 22px; margin-bottom: 16px; }
.mail-meta { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 18px; }
.mail-meta .who { flex: 1; min-width: 0; }
.mail-meta .who div { font-size: 13px; color: var(--muted); margin-top: 2px; }
.mail-text { white-space: pre-wrap; line-height: 1.55; overflow-wrap: anywhere; background: var(--surface); padding: 18px 20px; border-radius: var(--radius); border: 1px solid var(--border); }

/* ---------- Pages (directory/admin) ---------- */
.page { flex: 1; overflow-y: auto; padding: 24px 28px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.filters { display: flex; gap: 8px; }
.filters .search { width: 280px; }
.filters select { width: 200px; }
.people-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.person { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 18px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.person .avatar { margin-bottom: 6px; }
.person .name { font-weight: 600; }
.person .sub { font-size: 12.5px; color: var(--muted); }
.person .actions { display: flex; gap: 6px; margin-top: 10px; }
.person .actions .btn { padding: 5px 10px; font-size: 12.5px; }
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table th { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .4px; }
.table tr:last-child td { border-bottom: 0; }
.tag { font-size: 11.5px; padding: 2px 8px; border-radius: 10px; background: var(--surface-2); }
.tag.ok { background: rgba(31,157,85,.15); color: var(--ok); }
.tag.off { background: rgba(209,59,59,.15); color: var(--danger); }
.tag.admin { background: var(--accent-soft); color: var(--accent); }

/* ---------- Modal, menu, toasts ---------- */
dialog { border: 0; padding: 0; border-radius: 14px; box-shadow: var(--shadow); background: var(--surface); color: var(--text); width: min(520px, calc(100vw - 32px)); }
dialog.wide { width: min(760px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(10, 10, 30, .45); }
.modal { padding: 22px 24px; display: flex; flex-direction: column; max-height: calc(100vh - 60px); }
.modal h3 { font-size: 17px; margin-bottom: 6px; }
.modal-body { overflow-y: auto; margin: 0 -4px; padding: 0 4px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.modal textarea.mail-body { min-height: 260px; resize: vertical; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.picker { position: relative; margin-top: 4px; }
.picker-box { display: flex; flex-wrap: wrap; gap: 4px; border: 1px solid var(--border); border-radius: 8px; padding: 4px; background: var(--surface); }
.picker-box:focus-within { outline: 2px solid var(--accent); outline-offset: -1px; }
.picker-box input { border: 0; flex: 1; min-width: 120px; padding: 4px 6px; }
.picker-box input:focus { outline: none; }
.suggest { position: absolute; z-index: 5; left: 0; right: 0; top: 100%; margin-top: 2px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow); list-style: none; padding: 4px; max-height: 220px; overflow-y: auto; }
.suggest li { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 6px; cursor: pointer; }
.suggest li.active, .suggest li:hover { background: var(--accent-soft); }
.suggest small { color: var(--muted); }
.pick-list { list-style: none; padding: 0; margin: 8px 0 0; max-height: 320px; overflow-y: auto; }
.pick-list li { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 8px; cursor: pointer; }
.pick-list li:hover { background: var(--surface-2); }
.pick-list .grow { flex: 1; min-width: 0; }
.pick-list small { color: var(--muted); display: block; }
.cc-toggle { float: right; font-weight: 400; }

.menu { position: fixed; z-index: 50; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); padding: 6px; min-width: 200px; }
.menu .menu-head { padding: 8px 10px 10px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.menu .menu-head small { color: var(--muted); display: block; }
.menu button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 8px 10px; border-radius: 6px; }
.menu button:hover { background: var(--surface-2); }
.toasts { position: fixed; top: 14px; right: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast { background: var(--text); color: var(--bg); padding: 10px 14px; border-radius: 10px; box-shadow: var(--shadow); max-width: 340px; cursor: pointer; animation: pop .2s ease-out; }
.toast.err { background: var(--danger); color: #fff; }
@keyframes pop { from { transform: translateY(8px); opacity: 0; } }

/* ---------- Small screens ---------- */
.back-btn { display: none; }
@media (max-width: 900px) {
  .mail-list-col { width: 280px; }
  .sidebar.narrow { width: 170px; }
}
@media (max-width: 720px) {
  .app { flex-direction: column-reverse; }
  .rail { width: 100%; flex-direction: row; padding: 4px 8px; justify-content: space-around; height: 60px; }
  .rail .brand-mark, .rail-spacer { display: none; }
  .rail-btn { width: auto; flex: 1; }
  .rail-btn.active { box-shadow: inset 0 3px 0 var(--brand-orange); }
  .view { min-height: 0; }
  .sidebar, .sidebar.narrow, .mail-list-col { width: 100%; border-right: 0; }
  .view.has-open .sidebar, .view.has-open .mail-list-col { display: none; }
  .view:not(.has-open) .pane { display: none; }
  #view-mail .sidebar { display: none; }
  #view-mail:not(.has-open) .mail-list-col { display: flex; }
  .back-btn { display: inline-grid; }
  .msg { max-width: 92%; }
  .page { padding: 16px; }
  .filters { flex-direction: column; width: 100%; }
  .filters .search, .filters select { width: 100%; }
  .row2 { grid-template-columns: 1fr; }
  .mobile-folders { display: block !important; }
}
.mobile-folders { display: none; }
.mobile-row { width: 100%; }
.mobile-row select { width: auto; margin-right: 6px; }
.inline-user { display: inline-flex; align-items: center; gap: 8px; }

/* ---------- Outside mail ---------- */
.chip.ext { background: rgba(8,145,178,.14); border: 1px dashed rgba(8,145,178,.6); }
.ext-addr { white-space: nowrap; color: #0e7490; }
.tag.ext { background: rgba(8,145,178,.14); color: #0e7490; }
.outside-note { margin: 8px 0 0; padding: 8px 12px; border-radius: 8px; background: rgba(8,145,178,.1); color: #0e7490; font-size: 13px; }
.delivery { margin: -6px 0 16px; padding: 8px 12px; border-radius: 8px; font-size: 13px; }
.delivery.ok { background: rgba(31,157,85,.12); color: var(--ok); }
.delivery.bad { background: rgba(209,59,59,.1); color: var(--danger); }
.delivery.wait { background: rgba(242,138,30,.14); color: #b45f06; }
.suggest li.blocked { cursor: default; background: none; }
.small { font-size: 12px; }
.table td.wrap, .wrap { white-space: normal; max-width: 260px; overflow-wrap: anywhere; }
.extmail-card { border-left-color: #0891b2; }
.extmail-card > p { margin: 12px 0 0; }
@media (prefers-color-scheme: dark) {
  .ext-addr, .tag.ext, .outside-note { color: #67d4ea; }
}

/* ---------- Licence ---------- */
.mono { font-family: Consolas, "Cascadia Mono", monospace; font-size: 12.5px; word-break: break-all; }
.license-card { background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--accent); border-radius: 12px; padding: 18px 20px; margin-bottom: 26px; }
.license-main { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.license-title { font-size: 16px; font-weight: 600; margin-bottom: 4px; display: flex; align-items: center; gap: 8px; }
.license-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border); }
.license-stats small { display: block; color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .4px; margin-bottom: 2px; }
.tag.warn { background: rgba(242,138,30,.18); color: #b45f06; }
.license-alert { background: rgba(209,59,59,.1); color: var(--danger); padding: 10px 12px; border-radius: 8px; font-weight: 500; }
.license-banner { position: fixed; top: 10px; left: 50%; transform: translateX(-50%); z-index: 60; background: var(--surface); color: var(--text); border: 1px solid var(--brand-orange); border-left: 4px solid var(--brand-orange); box-shadow: var(--shadow); padding: 8px 14px; border-radius: 10px; font-size: 13px; max-width: calc(100vw - 32px); }
.license-banner .link-btn { font-size: 13px; margin-left: 6px; }
.page h3 { font-size: 16px; }

/* ---------- Calls ---------- */
.avatar.xl { width: 96px; height: 96px; font-size: 32px; }
.call-btn { font-size: 18px; width: 38px; height: 38px; }
.live-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: #e5484d; box-shadow: 0 0 0 0 rgba(229,72,77,.6); animation: pulse 1.6s infinite; flex-shrink: 0; }
@keyframes pulse { 70% { box-shadow: 0 0 0 8px rgba(229,72,77,0); } 100% { box-shadow: 0 0 0 0 rgba(229,72,77,0); } }
.conv-call-banner { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 8px 20px; background: var(--accent-soft); border-bottom: 1px solid var(--border); font-weight: 500; }
.conv-call-banner .btn { padding: 5px 12px; }

.round-btn { width: 52px; height: 52px; border-radius: 50%; border: 0; font-size: 21px; display: grid; place-items: center; background: rgba(255,255,255,.14); color: #fff; transition: transform .1s, background .15s; }
.round-btn:hover { background: rgba(255,255,255,.24); transform: scale(1.05); }
.round-btn.on { background: #fff; color: #111; }
.round-btn.accept { background: #1f9d45; }
.round-btn.decline { background: #e5484d; }

.call-incoming { position: fixed; z-index: 120; top: 18px; left: 50%; transform: translateX(-50%); width: min(420px, calc(100vw - 32px));
  background: #10261a; color: #fff; border-radius: 18px; padding: 16px 18px; display: flex; align-items: center; gap: 14px; box-shadow: 0 16px 50px rgba(0,0,0,.45); animation: pop .2s ease-out; }
.call-incoming .avatar { animation: pulse 1.6s infinite; }
.call-incoming .who { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.call-incoming .who span { font-size: 13px; opacity: .8; }
.call-incoming .ring-actions { display: flex; gap: 8px; }
.call-incoming .round-btn { width: 46px; height: 46px; font-size: 19px; }

.call-overlay { position: fixed; inset: 0; z-index: 110; background: #0b1510; color: #fff; display: flex; flex-direction: column; }
.call-overlay.minimized { visibility: hidden; pointer-events: none; }
.call-top { display: flex; justify-content: space-between; align-items: center; padding: 14px 20px; gap: 12px; }
.call-kind { opacity: .7; }
.btn.ghost { background: rgba(255,255,255,.1); border-color: transparent; color: #fff; }
.btn.ghost:hover { background: rgba(255,255,255,.2); }
.call-grid { flex: 1; min-height: 0; display: grid; gap: 10px; padding: 0 16px; grid-template-columns: 1fr; grid-auto-rows: 1fr; }
.call-grid[data-count="2"] { grid-template-columns: 1fr 1fr; }
.call-grid[data-count="3"], .call-grid[data-count="4"] { grid-template-columns: 1fr 1fr; }
.call-grid[data-count="5"], .call-grid[data-count="6"], .call-grid[data-count="7"], .call-grid[data-count="8"] { grid-template-columns: repeat(3, 1fr); }
.call-tile { position: relative; background: #17251d; border-radius: 14px; overflow: hidden; min-height: 0; }
.call-tile video { width: 100%; height: 100%; object-fit: cover; display: block; }
.call-tile .tile-avatar { position: absolute; inset: 0; display: none; place-items: center; background: #17251d; }
.call-tile.no-video .tile-avatar { display: grid; }
.call-tile .tile-name { position: absolute; left: 10px; bottom: 10px; background: rgba(0,0,0,.55); padding: 3px 10px; border-radius: 8px; font-size: 13px; }
.call-waiting { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; font-size: 17px; opacity: .9; }
.call-waiting .avatar { animation: pulse 1.6s infinite; }
.call-self { position: absolute; right: 20px; bottom: 96px; width: 220px; aspect-ratio: 16/9; object-fit: cover; border-radius: 12px; background: #000; border: 2px solid rgba(255,255,255,.25); box-shadow: 0 6px 20px rgba(0,0,0,.4); }
.call-self.mirror { transform: scaleX(-1); }
.call-self.off { opacity: .15; }
.call-controls { display: flex; justify-content: center; gap: 14px; padding: 16px; }
.call-pill { position: fixed; z-index: 115; bottom: 18px; left: 50%; transform: translateX(-50%); background: #10261a; color: #fff; border-radius: 30px; padding: 8px 10px 8px 16px; display: flex; align-items: center; gap: 10px; box-shadow: var(--shadow); max-width: calc(100vw - 32px); }
.call-pill .btn { padding: 5px 12px; border-radius: 20px; }
.call-pill .btn:not(.danger) { background: rgba(255,255,255,.15); border-color: transparent; color: #fff; }
.call-pill .btn.danger { background: #e5484d; color: #fff; border-color: transparent; }
@media (max-width: 720px) {
  .call-grid[data-count] { grid-template-columns: 1fr; }
  .call-self { width: 110px; bottom: 92px; right: 12px; }
  .call-pill { bottom: 70px; }
}
.call-incoming .who b, .call-incoming .who span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 480px) {
  .call-incoming { flex-wrap: wrap; justify-content: center; }
  .call-incoming .who { flex-basis: calc(100% - 80px); }
  .call-incoming .ring-actions { width: 100%; justify-content: center; gap: 22px; }
}

/* ---------- Mail signature & logo ---------- */
.signature { white-space: pre-wrap; line-height: 1.5; padding: 12px 14px; margin-top: 6px; border-radius: 8px; background: var(--surface); border: 1px solid var(--border); font-size: 13.5px; }
.signature .mail-logo, .mail-text .mail-logo { display: block; width: 180px; max-width: 60%; height: auto; margin-top: 14px; }
.logo-note { display: flex; align-items: center; gap: 10px; font-size: 12.5px; color: var(--muted); margin: 8px 0 0; }
.logo-note img { height: 22px; width: auto; }
.sig-preview { margin-top: 10px; }
.sig-preview small { display: block; margin: 6px 0 4px; color: var(--muted); }
.sig-row { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); max-width: 460px; }
.sig-edit textarea { font-family: inherit; }
.placeholders { font-size: 12.5px; color: var(--muted); margin: 6px 0; }
.placeholders code { background: var(--surface-2); border-radius: 5px; padding: 1px 6px; color: var(--text); }
.signature-card { border-left-color: var(--brand-orange); }

/* ---------- Email account / mail server ---------- */
.form-section { margin: 18px 0 4px; font-size: 14px; color: var(--text); border-top: 1px solid var(--border); padding-top: 14px; }
label.check > span { flex: 1; }

/* ---------- Mail retention & admin mailbox view ---------- */
.retention-note { margin-top: auto; font-size: 11.5px; line-height: 1.4; color: var(--muted); padding: 10px 6px 0; border-top: 1px solid var(--border); }
.viewas-banner { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 12px 12px 0; padding: 10px 12px;
  border-radius: 10px; background: rgba(242,138,30,.14); border: 1px solid var(--brand-orange); }
.viewas-banner small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.viewas-banner .btn { white-space: nowrap; padding: 6px 10px; }
.readonly-label { align-self: center; font-size: 13px; }

/* ---------- Import old mail ---------- */
.import-progress { margin-top: 12px; }
.import-progress .bar { height: 10px; border-radius: 6px; background: var(--surface-2); overflow: hidden; }
.import-progress .bar span { display: block; height: 100%; width: 2%; background: var(--accent); transition: width .4s; }
.import-progress p { margin: 6px 0 0; font-size: 13px; color: var(--muted); }

/* ---------- Two-step sign-in ---------- */
.code-help { margin: 4px 0 10px; }
.code-input { font-size: 22px; letter-spacing: 4px; text-align: center; font-variant-numeric: tabular-nums; }
#login-back { margin-top: 6px; }
.tf-setup { display: flex; gap: 18px; align-items: flex-start; flex-wrap: wrap; margin: 8px 0 12px; }
.tf-qr { width: 200px; height: 200px; background: #fff; padding: 8px; border-radius: 10px; border: 1px solid var(--border, #ddd); flex: none; }
.tf-steps { flex: 1; min-width: 220px; margin: 0; padding-left: 20px; line-height: 1.55; }
.tf-steps li { margin-bottom: 8px; }
.tf-secret { font-size: 13px; letter-spacing: 1px; word-break: break-all; user-select: all; }
.tf-codes { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin: 12px 0; }
.tf-codes code { font-size: 16px; text-align: center; padding: 8px; border-radius: 8px; background: var(--surface-2); letter-spacing: 1px; user-select: all; }
.tf-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
