:root {
  --ink: #182230;
  --ink-soft: #344054;
  --muted: #667085;
  --muted-2: #98a2b3;
  --line: #e4e7ec;
  --line-strong: #d0d5dd;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --surface-blue: #eff6ff;
  --blue: #2563eb;
  --blue-dark: #1d4ed8;
  --blue-soft: #dbeafe;
  --navy: #111827;
  --green: #039855;
  --green-soft: #ecfdf3;
  --amber: #dc6803;
  --amber-soft: #fffaeb;
  --red: #d92d20;
  --red-soft: #fef3f2;
  --shadow-sm: 0 1px 2px rgb(16 24 40 / 0.05);
  --shadow-md: 0 10px 30px rgb(16 24 40 / 0.12);
  --radius: 12px;
  --topbar-h: 72px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  color: var(--ink);
  background: #eef2f6;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  overflow: hidden;
}

button, input, textarea, select { font: inherit; }
button, select, label[for], input[type="checkbox"] { cursor: pointer; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 3px solid rgb(37 99 235 / 0.25);
  outline-offset: 1px;
}

svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

[hidden] { display: none !important; }

.app-shell {
  width: 100vw;
  height: 100vh;
  min-width: 1120px;
  background: var(--surface);
}

.topbar {
  height: var(--topbar-h);
  display: grid;
  grid-template-columns: 220px minmax(360px, 1fr) auto;
  align-items: center;
  gap: 24px;
  padding: 0 22px;
  color: #fff;
  background: var(--navy);
  border-bottom: 1px solid #27364b;
}

.brand { display: flex; align-items: center; gap: 11px; min-width: 0; }
.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--blue);
  border-radius: 11px;
}
.brand-mark svg { width: 22px; height: 22px; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 17px; letter-spacing: 0.01em; }
.brand small { margin-top: 2px; color: #98a2b3; font-size: 11px; }

.global-search {
  height: 42px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  color: var(--muted);
  background: #fff;
  border: 1px solid transparent;
  border-radius: 10px;
  max-width: 760px;
  justify-self: center;
  width: 100%;
}
.global-search:focus-within { box-shadow: 0 0 0 3px rgb(96 165 250 / 0.3); }
.global-search input { flex: 1; min-width: 0; border: 0; outline: 0; color: var(--ink); }
.global-search kbd {
  padding: 3px 7px;
  color: var(--muted);
  background: #f2f4f7;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 11px;
}

.topbar-actions { display: flex; align-items: center; gap: 10px; }

.btn {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 9px;
  font-weight: 650;
  white-space: nowrap;
  transition: 160ms ease;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary { color: #fff; background: var(--blue); border-color: var(--blue); box-shadow: 0 1px 2px rgb(16 24 40 / 0.1); }
.btn-primary:hover { background: var(--blue-dark); }
.btn-secondary { color: var(--ink-soft); background: #fff; border-color: var(--line-strong); }
.topbar .btn-secondary { color: #fff; background: #27364b; border-color: #3b4b61; }
.btn-ghost { color: var(--ink-soft); background: transparent; border-color: transparent; }
.btn-dark { color: #fff; background: #27364b; border-color: #475467; }
.btn.wide { width: 100%; }
.btn svg { width: 18px; height: 18px; }

.filter-count {
  min-width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--blue);
  border-radius: 999px;
  font-size: 11px;
}

.popover-wrap { position: relative; }
.filter-popover {
  position: absolute;
  z-index: 30;
  top: calc(100% + 10px);
  right: 0;
  width: 270px;
  padding: 14px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow-md);
}
.popover-title { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.check-row { display: grid; grid-template-columns: 20px 1fr auto; align-items: center; gap: 8px; padding: 10px 4px; border-top: 1px solid #f2f4f7; }
.check-row input { width: 16px; height: 16px; accent-color: var(--blue); }
.check-row b { color: var(--muted); font-size: 12px; }

.mailbox-switcher {
  height: 42px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 11px;
  color: #fff;
  background: #27364b;
  border: 1px solid #3b4b61;
  border-radius: 10px;
}
.mailbox-switcher span:not(.status-dot) { text-align: left; }
.mailbox-switcher small, .mailbox-switcher strong { display: block; }
.mailbox-switcher small { color: #98a2b3; font-size: 9px; }
.mailbox-switcher strong { max-width: 180px; overflow: hidden; text-overflow: ellipsis; font-size: 12px; }
.mailbox-switcher svg { width: 15px; height: 15px; color: #98a2b3; }
.status-dot { width: 8px; height: 8px; background: #32d583; border-radius: 50%; box-shadow: 0 0 0 3px rgb(50 213 131 / 0.12); }
.mailbox-popover {
  position: absolute;
  z-index: 40;
  top: calc(100% + 10px);
  right: 0;
  width: 330px;
  max-height: min(560px, calc(100vh - 100px));
  padding: 12px;
  overflow: auto;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow-md);
}
.mailbox-option {
  width: 100%;
  min-height: 54px;
  display: grid;
  grid-template-columns: 10px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  color: var(--ink);
  background: #fff;
  border: 0;
  border-radius: 9px;
  text-align: left;
}
.mailbox-option:first-child { grid-template-columns: 1fr auto; }
.mailbox-option:hover { background: #f8fafc; }
.mailbox-option.active { color: var(--blue-dark); background: var(--surface-blue); }
.mailbox-option i { width: 8px; height: 8px; border-radius: 50%; background: var(--muted-2); }
.mailbox-option i.online { background: var(--green); }
.mailbox-option i.error { background: var(--red); }
.mailbox-option strong, .mailbox-option small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mailbox-option small { margin-top: 3px; color: var(--muted); font-size: 10px; }
.mailbox-option b { color: var(--muted); font-size: 11px; }

.workspace {
  height: calc(100vh - var(--topbar-h));
  display: grid;
  grid-template-columns: 218px 324px minmax(480px, 1fr) 302px;
  background: #fff;
}

.system-banner {
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 22px;
  color: #93370d;
  background: #fffaeb;
  border-bottom: 1px solid #fedf89;
}
.system-banner div { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.system-banner strong { white-space: nowrap; }
.system-banner span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; }
.app-shell.has-banner .workspace { height: calc(100vh - var(--topbar-h) - 48px); }

.folder-rail, .thread-pane, .conversation-pane, .crm-pane { min-width: 0; min-height: 0; }

.folder-rail {
  display: flex;
  flex-direction: column;
  padding: 16px 12px 12px;
  background: #f8fafc;
  border-right: 1px solid var(--line);
}
.folder-item {
  width: 100%;
  min-height: 42px;
  display: grid;
  grid-template-columns: 22px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 0 11px;
  color: var(--ink-soft);
  background: transparent;
  border: 0;
  border-radius: 9px;
  text-align: left;
}
.folder-item:hover { background: #eef2f6; }
.folder-item.active { color: var(--blue-dark); background: var(--surface-blue); font-weight: 650; }
.folder-item svg { width: 18px; height: 18px; }
.folder-item b { min-width: 22px; color: var(--muted); font-size: 12px; text-align: right; }
.folder-item.active b { color: var(--blue-dark); }
.folder-item.muted { color: var(--muted); }
.danger-count { color: var(--red) !important; }
.rail-divider { height: 1px; margin: 12px 10px; background: var(--line); }
.rail-label { margin: 0 11px 6px; color: var(--muted-2); font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; }
.rail-spacer { flex: 1; }

.thread-pane { display: flex; flex-direction: column; background: #fff; border-right: 1px solid var(--line); }
.pane-head {
  min-height: 78px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
}
.pane-head h1 { margin: 0; font-size: 18px; }
.pane-head p { margin: 5px 0 0; color: var(--muted); font-size: 11px; }
.icon-button {
  width: 36px;
  height: 36px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  padding: 0;
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
}
.icon-button:hover { color: var(--ink); background: #f2f4f7; border-color: var(--line); }
.icon-button.active { color: #f79009; }
.icon-button.active svg { fill: currentColor; }
.icon-button.compact { width: 28px; height: 28px; }
.icon-button.light { color: #fff; }

.active-filter-row { display: flex; flex-wrap: wrap; gap: 5px; padding: 8px 12px 0; }
.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 8px;
  color: var(--blue-dark);
  background: var(--surface-blue);
  border: 1px solid #bfdbfe;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 650;
}
.filter-chip button { padding: 0; color: inherit; background: none; border: 0; line-height: 1; }

.thread-list { flex: 1; overflow: auto; scrollbar-width: thin; }
.load-more-button { width:100%; min-height:38px; padding:8px 12px; color:var(--blue-dark); background:#f8fafc; border:0; border-top:1px solid var(--line); font-size:10px; font-weight:700; }
.load-more-button:hover { background:var(--surface-blue); }
.load-more-button:disabled { color:var(--muted-2); cursor:wait; }
.thread-item {
  position: relative;
  width: 100%;
  min-height: 112px;
  display: grid;
  grid-template-columns: 32px 1fr auto;
  gap: 4px 9px;
  padding: 14px 15px 12px 13px;
  color: var(--ink);
  background: #fff;
  border: 0;
  border-bottom: 1px solid #f0f2f5;
  text-align: left;
}
.thread-item:hover { background: #f8fafc; }
.thread-item.selected { background: #f5f8ff; box-shadow: inset 3px 0 0 var(--blue); }
.thread-item.unread .sender, .thread-item.unread .subject { font-weight: 750; }
.thread-avatar {
  grid-row: 1 / 4;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  color: var(--blue-dark);
  background: var(--blue-soft);
  border-radius: 9px;
  font-size: 11px;
  font-weight: 750;
}
.sender { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.thread-time { color: var(--muted); font-size: 10px; }
.subject { grid-column: 2 / 4; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-soft); font-size: 12px; }
.preview { grid-column: 2 / 4; min-width: 0; display: flex; align-items: center; gap: 6px; }
.preview span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 11px; }
.paperclip { color: var(--muted-2); font-size: 12px; }
.thread-badges { grid-column: 2 / 4; display: flex; align-items: center; gap: 5px; min-height: 18px; }
.mini-badge { padding: 3px 6px; border-radius: 999px; color: var(--amber); background: var(--amber-soft); font-size: 9px; font-weight: 700; }
.mini-badge.blue { color: var(--blue-dark); background: var(--surface-blue); }
.mini-badge.mailbox-badge { max-width: 150px; overflow: hidden; text-overflow: ellipsis; color: #475467; background: #f2f4f7; white-space: nowrap; }
.unread-dot { position: absolute; top: 18px; left: 7px; width: 6px; height: 6px; background: var(--blue); border-radius: 50%; }

.empty-state { flex: 1; display: grid; place-content: center; justify-items: center; padding: 40px; text-align: center; }
.empty-state p { max-width: 230px; margin: 7px 0 16px; color: var(--muted); }
.empty-icon { width: 50px; height: 50px; display: grid; place-items: center; margin-bottom: 12px; color: var(--green); background: var(--green-soft); border-radius: 50%; font-size: 24px; }

.conversation-pane { position: relative; display: flex; flex-direction: column; background: #fcfcfd; border-right: 1px solid var(--line); }
.conversation-placeholder, .crm-placeholder { flex: 1; display: grid; place-content: center; justify-items: center; padding: 30px; color: var(--muted); text-align: center; }
.conversation-placeholder strong { margin-top: 14px; color: var(--ink); font-size: 16px; }
.conversation-placeholder p, .crm-placeholder p { max-width: 280px; line-height: 1.5; }
.placeholder-mark { width: 58px; height: 58px; display: grid; place-items: center; color: var(--blue); background: var(--surface-blue); border-radius: 16px; }
.placeholder-mark svg { width: 28px; height: 28px; }
#conversationContent { height: 100%; display: flex; flex-direction: column; min-height: 0; }
.conversation-head {
  min-height: 78px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 18px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}
.conversation-title-wrap { min-width: 0; display: flex; align-items: center; gap: 8px; }
.conversation-title-wrap > div { min-width: 0; }
.conversation-head h2 { margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 17px; }
.conversation-head p { margin: 5px 0 0; color: var(--muted); font-size: 11px; }
.conversation-actions { display: flex; align-items: center; }
.mobile-back { display: none; }
.message-scroll { flex: 1; min-height: 0; overflow: auto; padding: 16px 18px 12px; scrollbar-width: thin; }
.message-stack { display: flex; flex-direction: column; gap: 10px; max-width: 850px; margin: 0 auto; }
.message-card { padding: 14px 15px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.message-card.incoming.latest { border-color: #93c5fd; box-shadow: 0 0 0 1px #bfdbfe; }
.message-card.outgoing { margin-left: 34px; background: #f8fafc; }
.message-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.message-person { display: flex; gap: 10px; align-items: center; }
.message-avatar { width: 32px; height: 32px; display: grid; place-items: center; color: var(--blue-dark); background: var(--blue-soft); border-radius: 9px; font-size: 10px; font-weight: 750; }
.message-avatar.you { color: #344054; background: #eaecf0; }
.message-person strong, .message-person small { display: block; }
.message-person small { margin-top: 3px; color: var(--muted); font-size: 10px; }
.message-status { color: var(--green); font-size: 10px; }
.message-body { margin: 12px 0 0 42px; color: var(--ink-soft); font-size: 13px; line-height: 1.5; white-space: pre-wrap; }
.quote-toggle { display: inline-flex; align-items: center; gap: 5px; margin: 10px 0 0 42px; padding: 0; color: var(--muted); background: none; border: 0; font-size: 10px; }
.quote-content { margin: 8px 0 0 42px; padding: 8px 10px; color: var(--muted); background: #f8fafc; border-left: 3px solid var(--line-strong); font-size: 10px; line-height: 1.45; }
.attachment-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 8px; margin: 12px 0 0 42px; }
.attachment-card { min-width: 0; display: grid; grid-template-columns: 58px 1fr 24px; align-items: center; gap: 10px; padding: 8px; color: var(--ink); background: #f8fafc; border: 1px solid var(--line); border-radius: 9px; text-align: left; }
.attachment-card:hover { background: var(--surface-blue); border-color: #bfdbfe; }
.attachment-thumb { width: 58px; height: 48px; display: grid; place-items: center; overflow: hidden; color: var(--blue-dark); background: var(--blue-soft); border-radius: 7px; font-size: 10px; font-weight: 750; }
.attachment-thumb.pdf { color: var(--red); background: var(--red-soft); }
.attachment-info { min-width: 0; }
.attachment-info strong, .attachment-info span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attachment-info strong { font-size: 11px; }
.attachment-info span { margin-top: 4px; color: var(--muted); font-size: 9px; }
.attachment-download { color: var(--muted); font-size: 16px; text-align: center; }

.send-error { display: grid; grid-template-columns: 30px 1fr auto auto; align-items: center; gap: 10px; margin: 0 18px 8px; padding: 9px 10px; color: #7a271a; background: var(--red-soft); border: 1px solid #fda29b; border-radius: 10px; }
.send-error strong { color: var(--red); font-size: 12px; }
.send-error p { margin: 2px 0 0; font-size: 10px; }
.error-symbol { width: 25px; height: 25px; display: grid; place-items: center; color: #fff; background: var(--red); border-radius: 50%; font-weight: 800; }

.composer { margin: 0 18px 16px; padding: 12px; background: #fff; border: 1px solid var(--line-strong); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.composer-topline { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.reply-mode { min-width: 0; display: flex; align-items: center; gap: 10px; }
.reply-mode-button { padding: 0; color: var(--ink); background: none; border: 0; font-weight: 700; }
.reply-mode > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 10px; }
.text-button { padding: 0; color: var(--blue-dark); background: none; border: 0; font-size: 11px; font-weight: 650; }
.text-button:hover { text-decoration: underline; }
.text-button.danger { color: var(--red); }
.cc-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 9px 0 3px; }
.cc-fields label { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 7px; color: var(--muted); font-size: 10px; }
.cc-fields input { min-width: 0; padding: 6px 8px; border: 1px solid var(--line); border-radius: 7px; }
.composer textarea { width: 100%; min-height: 76px; resize: vertical; padding: 11px 2px; color: var(--ink); background: transparent; border: 0; outline: 0; line-height: 1.45; }
.composer-attachments { display: flex; flex-wrap: wrap; gap: 5px; }
.composer-file { display: inline-flex; align-items: center; gap: 5px; padding: 5px 7px; color: var(--ink-soft); background: #f2f4f7; border-radius: 7px; font-size: 10px; }
.composer-file button { padding: 0; color: var(--muted); background: none; border: 0; }
.composer-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 8px; border-top: 1px solid var(--line); }
.composer-tools, .send-group { display: flex; align-items: center; gap: 5px; min-width: 0; }
.composer-tools select { height: 32px; padding: 0 7px; color: var(--ink-soft); background: #fff; border: 1px solid transparent; border-radius: 7px; font-size: 10px; }
.composer-tools select:hover { border-color: var(--line); }
.autosave-status { margin-left: 4px; color: var(--muted-2); font-size: 9px; white-space: nowrap; }
.send-button { min-width: 105px; }
.send-spinner { width: 15px; height: 15px; border: 2px solid rgb(255 255 255 / 0.4); border-top-color: #fff; border-radius: 50%; animation: spin 0.7s linear infinite; }
.demo-error-button { padding: 5px 8px; color: var(--muted); background: transparent; border: 1px dashed var(--line-strong); border-radius: 7px; font-size: 9px; }
.demo-error-button:hover { color: var(--red); border-color: #fda29b; }
@keyframes spin { to { transform: rotate(360deg); } }

.crm-pane { overflow: auto; padding: 18px 16px; background: #fff; }
.crm-placeholder span { width: 48px; height: 48px; display: grid; place-items: center; color: var(--blue); background: var(--surface-blue); border-radius: 14px; font-weight: 800; }
.crm-head, .crm-section-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.section-kicker { color: var(--muted-2); font-size: 10px; font-weight: 750; text-transform: uppercase; letter-spacing: 0.08em; }
.match-badge { display: inline-flex; align-items: center; gap: 5px; color: var(--green); font-size: 9px; font-weight: 650; }
.match-badge i { width: 6px; height: 6px; background: var(--green); border-radius: 50%; }
.contact-card { display: flex; align-items: center; gap: 11px; padding: 18px 0 15px; }
.contact-avatar { width: 44px; height: 44px; display: grid; place-items: center; color: var(--blue-dark); background: var(--blue-soft); border-radius: 13px; font-size: 12px; font-weight: 800; }
.contact-card h3 { margin: 0 0 4px; font-size: 16px; }
.contact-card a { color: var(--muted); font-size: 10px; text-decoration: none; }
.crm-section { padding: 14px 0; border-top: 1px solid var(--line); }
.crm-section > strong, .crm-section-head strong { font-size: 11px; }
.deal-card { margin-top: 9px; padding: 11px; border: 1px solid var(--line); border-radius: 10px; }
.deal-card.active { color: var(--blue-dark); background: var(--surface-blue); border-color: #bfdbfe; }
.deal-card strong, .deal-card span { display: block; }
.deal-card strong { font-size: 11px; }
.deal-card span { margin-top: 5px; color: var(--muted); font-size: 9px; }
.deal-card.active span { color: #475467; }
.deal-picker { margin-top: 7px; padding: 6px; background: #fff; border: 1px solid var(--line-strong); border-radius: 10px; box-shadow: var(--shadow-md); }
.deal-option { width: 100%; padding: 9px; color: var(--ink); background: #fff; border: 0; border-radius: 7px; text-align: left; }
.deal-option:hover { background: #f2f4f7; }
.deal-option strong, .deal-option span { display: block; }
.deal-option strong { font-size: 10px; }
.deal-option span { margin-top: 3px; color: var(--muted); font-size: 9px; }
.other-deals { display: grid; gap: 7px; margin-top: 9px; }
.other-deal { padding: 8px 9px; background: #f8fafc; border: 1px solid #f0f2f5; border-radius: 8px; }
.other-deal strong, .other-deal span { display: block; }
.other-deal strong { font-size: 10px; }
.other-deal span { margin-top: 3px; color: var(--muted); font-size: 9px; }
.details-grid { display: grid; gap: 12px; }
.details-grid label, .details-grid div { display: grid; gap: 5px; }
.details-grid label, .details-grid span { color: var(--muted); font-size: 9px; }
.details-grid select { height: 34px; padding: 0 8px; color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: 8px; font-weight: 650; }
.details-grid strong { color: var(--ink); font-size: 10px; }
.task-warning { color: var(--amber) !important; }
.crm-actions { display: grid; gap: 6px; padding-top: 12px; }

.modal-backdrop {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 28px;
  background: rgb(15 23 42 / 0.82);
  backdrop-filter: blur(4px);
}
.light-backdrop { background: rgb(15 23 42 / 0.42); }
.attachment-viewer {
  position: relative;
  width: min(1100px, 92vw);
  height: min(760px, 88vh);
  display: grid;
  grid-template-rows: 68px 1fr 44px;
  color: #fff;
  background: #111827;
  border: 1px solid #475467;
  border-radius: 16px;
  box-shadow: 0 30px 90px rgb(0 0 0 / 0.35);
  overflow: hidden;
}
.attachment-viewer > header, .attachment-viewer > footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 20px; }
.attachment-viewer header { border-bottom: 1px solid #344054; }
.attachment-viewer header strong, .attachment-viewer header span { display: block; }
.attachment-viewer header span { margin-top: 4px; color: #98a2b3; font-size: 10px; }
.attachment-viewer footer { color: #98a2b3; border-top: 1px solid #344054; font-size: 10px; }
.viewer-actions { display: flex; align-items: center; gap: 8px; }
.viewer-stage { min-width: 0; min-height: 0; display: grid; place-items: center; padding: 26px 70px; overflow: auto; }
.viewer-preview {
  width: min(760px, 100%);
  height: min(520px, 100%);
  display: grid;
  place-items: center;
  color: var(--ink);
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 16px 50px rgb(0 0 0 / 0.35);
  overflow: hidden;
}
.viewer-preview svg { width: 100%; height: 100%; }
.viewer-native { width: 100%; height: 100%; display: grid; place-items: center; }
.viewer-native img { max-width: 100%; max-height: 100%; object-fit: contain; }
.viewer-native iframe { width: 100%; height: 100%; border: 0; background: #fff; }
.pdf-page { width: min(560px, 92%); min-height: 92%; padding: 50px; color: var(--ink); background: #fff; box-shadow: 0 16px 50px rgb(0 0 0 / 0.35); }
.pdf-page h2 { color: var(--red); }
.pdf-line { height: 8px; margin: 12px 0; background: #eaecf0; border-radius: 4px; }
.viewer-arrow { position: absolute; top: 50%; width: 46px; height: 70px; margin-top: -35px; color: #fff; background: rgb(255 255 255 / 0.08); border: 1px solid rgb(255 255 255 / 0.18); border-radius: 12px; font-size: 34px; }
.viewer-arrow:hover { background: rgb(255 255 255 / 0.16); }
.viewer-arrow.left { left: 16px; }
.viewer-arrow.right { right: 16px; }

.new-mail-modal { width: min(720px, 92vw); padding: 22px; background: #fff; border-radius: 16px; box-shadow: var(--shadow-md); }
.new-mail-modal header, .new-mail-modal footer { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.new-mail-modal h2 { margin: 5px 0 0; }
.new-mail-modal label { display: grid; gap: 6px; margin-top: 15px; color: var(--muted); font-size: 11px; font-weight: 650; }
.new-mail-modal input, .new-mail-modal textarea, .new-mail-modal select { width: 100%; padding: 10px 11px; color: var(--ink); background: #fff; border: 1px solid var(--line-strong); border-radius: 9px; }
.new-mail-modal textarea { resize: vertical; line-height: 1.45; }
.new-mail-modal footer { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.new-mail-modal footer span { color: var(--muted); font-size: 10px; }

.toast-region { position: fixed; z-index: 200; right: 20px; bottom: 20px; display: grid; gap: 8px; pointer-events: none; }
.toast { min-width: 280px; padding: 12px 14px; color: #fff; background: #101828; border-radius: 10px; box-shadow: var(--shadow-md); animation: toast-in 180ms ease; }
.toast.success { background: #05603a; }
.toast.error { background: #912018; }
.toast strong, .toast span { display: block; }
.toast span { margin-top: 3px; color: rgb(255 255 255 / 0.75); font-size: 10px; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

.login-backdrop {
  position: fixed;
  z-index: 500;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #eef2f6;
}
.login-card {
  width: min(420px, 94vw);
  padding: 30px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 24px 80px rgb(16 24 40 / 0.15);
}
.login-mark { margin-bottom: 18px; }
.login-card h2 { margin: 7px 0 8px; font-size: 23px; }
.login-card p { margin: 0 0 20px; color: var(--muted); line-height: 1.55; }
.login-card code { padding: 2px 5px; background: #f2f4f7; border-radius: 5px; }
.login-card label { display: grid; gap: 7px; margin-bottom: 14px; color: var(--ink-soft); font-size: 11px; font-weight: 700; }
.login-card input { height: 44px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 9px; }
.login-error { margin-bottom: 12px; padding: 10px; color: var(--red); background: var(--red-soft); border-radius: 8px; font-size: 11px; }

@media (max-width: 1400px) {
  .workspace { grid-template-columns: 76px 306px minmax(460px, 1fr) 286px; }
  .folder-rail { padding-inline: 8px; }
  .folder-item { grid-template-columns: 1fr; justify-items: center; padding: 0; }
  .folder-item span, .folder-item b, .rail-label { display: none; }
  .folder-item svg { width: 20px; height: 20px; }
  .mailbox-switcher { display: none; }
  .topbar { grid-template-columns: 170px minmax(360px, 1fr) auto; }
}

@media (max-width: 1180px) {
  .workspace { grid-template-columns: 72px 300px minmax(480px, 1fr); }
  .crm-pane { display: none; }
}

@media (max-height: 760px) {
  .composer textarea { min-height: 55px; }
  .composer { margin-bottom: 10px; }
  .message-card { padding-block: 11px; }
}
