:root {
  --font-body: "Manrope", "Segoe UI Variable", "Segoe UI", sans-serif;
  --font-display: "Space Grotesk", "Trebuchet MS", sans-serif;
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 12px;
  --shadow-lg: 0 32px 80px rgba(3, 10, 25, 0.18);
  --shadow-md: 0 20px 48px rgba(3, 10, 25, 0.12);
  --grid-line: rgba(255, 255, 255, 0.18);
  --transition: 180ms ease;
}

body[data-theme="aurora"] {
  --bg: #edf6ff;
  --bg-soft: rgba(255, 255, 255, 0.72);
  --panel: rgba(255, 255, 255, 0.84);
  --panel-strong: rgba(255, 255, 255, 0.94);
  --panel-inset: rgba(242, 247, 255, 0.88);
  --text: #0f1d32;
  --muted: #63718d;
  --accent: #0068ff;
  --accent-2: #00a1ff;
  --success: #0c9f61;
  --danger: #c03a47;
  --border: rgba(0, 82, 204, 0.12);
}

body[data-theme="sand"] {
  --bg: #fff4e8;
  --bg-soft: rgba(255, 250, 245, 0.7);
  --panel: rgba(255, 252, 248, 0.88);
  --panel-strong: rgba(255, 252, 248, 0.96);
  --panel-inset: rgba(255, 246, 237, 0.92);
  --text: #312119;
  --muted: #7c655a;
  --accent: #cc5b22;
  --accent-2: #ff914d;
  --success: #0f8b55;
  --danger: #c4394f;
  --border: rgba(160, 82, 45, 0.14);
}

body[data-theme="graphite"] {
  --bg: #e7ecf3;
  --bg-soft: rgba(247, 249, 252, 0.72);
  --panel: rgba(253, 254, 255, 0.9);
  --panel-strong: rgba(255, 255, 255, 0.97);
  --panel-inset: rgba(239, 243, 249, 0.96);
  --text: #1d2735;
  --muted: #647082;
  --accent: #0f63cc;
  --accent-2: #2f80ed;
  --success: #0a8d62;
  --danger: #be415f;
  --border: rgba(58, 77, 102, 0.14);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--font-body);
  background:
    radial-gradient(circle at 12% 10%, rgba(0, 161, 255, 0.18), transparent 30%),
    radial-gradient(circle at 88% 16%, rgba(255, 145, 77, 0.18), transparent 28%),
    linear-gradient(180deg, #ffffff 0%, var(--bg) 100%);
  color: var(--text);
  position: relative;
  overflow-x: hidden;
}

.ambient {
  position: fixed;
  width: 42vw;
  height: 42vw;
  filter: blur(70px);
  opacity: 0.45;
  border-radius: 50%;
  pointer-events: none;
}

.ambient-a {
  top: -10vw;
  left: -12vw;
  background: rgba(0, 161, 255, 0.25);
}

.ambient-b {
  top: 12vw;
  right: -16vw;
  background: rgba(255, 145, 77, 0.22);
}

.ambient-c {
  bottom: -18vw;
  left: 18vw;
  background: rgba(15, 99, 204, 0.16);
}

.app-shell {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 20px;
  padding: 18px;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  backdrop-filter: blur(24px);
  box-shadow: var(--shadow-lg);
  border-radius: var(--radius-xl);
}

.inset {
  background: var(--panel-inset);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9);
  border-radius: var(--radius-lg);
}

.sidebar {
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  position: sticky;
  top: 18px;
  max-height: calc(100vh - 36px);
}

.brand {
  display: flex;
  gap: 14px;
  align-items: center;
}

.brand-mark {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  border-radius: 20px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: white;
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0.08em;
}

.brand h1,
.topbar h2 {
  margin: 0;
  font-family: var(--font-display);
  letter-spacing: -0.04em;
}

.eyebrow {
  margin: 0 0 4px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.72rem;
  color: var(--muted);
}

.muted {
  color: var(--muted);
}

.sidebar-controls,
.sidebar-block,
.field,
.panel,
.compose-form,
.compose-preview,
.auth-pane {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.block-head,
.panel-head,
.toolbar,
.message-actions,
.message-meta,
.sender-row,
.settings-grid,
.activity-grid {
  display: flex;
  gap: 10px;
  align-items: center;
}

.block-head,
.panel-head {
  justify-content: space-between;
}

.toolbar.wrap {
  flex-wrap: wrap;
}

label span,
.block-head span {
  font-size: 0.92rem;
  font-weight: 700;
}

input,
select,
textarea,
button {
  font: inherit;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--panel-strong);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition);
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(0, 102, 255, 0.34);
  box-shadow: 0 0 0 4px rgba(15, 99, 204, 0.12);
}

textarea {
  min-height: 120px;
  resize: vertical;
}

button {
  border: 1px solid var(--border);
  background: var(--panel-strong);
  color: var(--text);
  border-radius: 999px;
  padding: 11px 16px;
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition), background var(--transition);
}

button:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

button.primary {
  border-color: transparent;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: white;
}

button.ghost {
  padding: 8px 12px;
}

.section-nav {
  display: grid;
  gap: 8px;
}

.nav-pill {
  justify-content: flex-start;
  border-radius: 18px;
}

.nav-pill.active {
  background: linear-gradient(135deg, rgba(15, 99, 204, 0.16), rgba(0, 161, 255, 0.14));
  border-color: rgba(15, 99, 204, 0.22);
}

.folder-list,
.select-list,
.log-list,
.attachment-list {
  display: grid;
  gap: 10px;
  min-height: 40px;
}

.folder-item,
.select-item,
.attachment-item,
.log-item,
.scheduled-item {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  padding: 12px 14px;
  border-radius: 16px;
  background: var(--panel-strong);
  border: 1px solid var(--border);
}

.folder-item.active,
.select-item.active {
  border-color: rgba(15, 99, 204, 0.24);
  background: linear-gradient(135deg, rgba(15, 99, 204, 0.12), rgba(0, 161, 255, 0.1));
}

.inline-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.workspace {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.topbar {
  padding: 22px 24px;
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-start;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: 10px;
  width: min(100%, 700px);
}

.stat-card {
  padding: 14px 16px;
  border-radius: 18px;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.8), rgba(244, 248, 255, 0.72));
  border: 1px solid var(--border);
}

.stat-card strong {
  display: block;
  font-size: 1.4rem;
  font-family: var(--font-display);
}

.panel {
  display: none;
  padding: 20px;
  gap: 16px;
}

.panel.active {
  display: flex;
}

.mail-layout,
.compose-grid,
.triple-grid,
.contacts-grid,
.settings-grid,
.activity-grid {
  display: grid;
  gap: 16px;
}

.mail-layout {
  grid-template-columns: 1.15fr 0.85fr;
}

.compose-grid {
  grid-template-columns: 1.15fr 0.85fr;
}

.triple-grid {
  grid-template-columns: 0.9fr 0.9fr 1.2fr;
}

.contacts-grid {
  grid-template-columns: 0.7fr 1.25fr 0.95fr;
}

.settings-grid {
  grid-template-columns: 1.4fr 0.8fr;
}

.activity-grid {
  grid-template-columns: 1fr 1fr;
}

.span-2 {
  grid-column: span 2;
}

.mail-list,
.message-view,
.compose-form,
.compose-preview {
  padding: 16px;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  text-align: left;
  padding: 11px 10px;
  border-bottom: 1px solid rgba(99, 113, 141, 0.12);
  vertical-align: top;
}

th {
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
}

tbody tr {
  cursor: pointer;
  transition: background var(--transition);
}

tbody tr:hover,
tbody tr.active {
  background: rgba(15, 99, 204, 0.08);
}

.w-40 {
  width: 40px;
}

.message-view {
  gap: 14px;
}

.message-meta {
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(15, 99, 204, 0.1);
  color: var(--accent);
  font-size: 0.82rem;
}

iframe {
  width: 100%;
  min-height: 420px;
  border: 0;
  border-radius: 18px;
  background: white;
}

.grid-2,
.grid-3 {
  display: grid;
  gap: 12px;
}

.grid-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: var(--panel-strong);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.toggle input {
  width: auto;
  margin: 0;
}

.code-editor {
  display: grid;
  grid-template-columns: 56px 1fr;
  border: 1px solid var(--border);
  background: #071120;
  border-radius: 18px;
  overflow: hidden;
}

.code-editor pre,
.code-editor textarea {
  margin: 0;
  min-height: 220px;
  font-family: "IBM Plex Mono", "Consolas", monospace;
  font-size: 0.9rem;
}

.code-editor pre {
  padding: 14px 10px;
  text-align: right;
  color: #74a4ff;
  background: linear-gradient(180deg, rgba(22, 38, 66, 0.96), rgba(10, 20, 34, 0.96));
}

.code-editor textarea {
  border: 0;
  border-radius: 0;
  color: #eff5ff;
  background: transparent;
  resize: vertical;
}

.dropzone {
  border: 1px dashed rgba(15, 99, 204, 0.28);
  border-radius: 18px;
  padding: 18px;
  text-align: center;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(241, 247, 255, 0.72));
}

.dropzone.dragover {
  border-color: var(--accent);
  background: linear-gradient(180deg, rgba(15, 99, 204, 0.12), rgba(0, 161, 255, 0.1));
}

.preview-shell {
  background:
    linear-gradient(transparent 31px, var(--grid-line) 32px),
    linear-gradient(90deg, transparent 31px, var(--grid-line) 32px),
    linear-gradient(135deg, rgba(15, 99, 204, 0.08), rgba(255, 255, 255, 0.4));
  background-size: 32px 32px, 32px 32px, cover;
  padding: 16px;
  border-radius: 22px;
  min-height: 520px;
}

.preview-shell.owa {
  background:
    linear-gradient(180deg, rgba(15, 99, 204, 0.08), rgba(0, 161, 255, 0.04)),
    var(--panel-strong);
}

.rich-preview {
  min-height: 420px;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: white;
  padding: 18px;
  overflow: auto;
}

.sender-rows {
  display: grid;
  gap: 10px;
}

.sender-row {
  display: grid;
  grid-template-columns: 1fr 1fr auto auto;
  gap: 8px;
  padding: 12px;
  border-radius: 16px;
  background: var(--panel-strong);
  border: 1px solid var(--border);
}

.sender-row .toggle {
  padding: 10px;
}

.compact .select-item,
.compact .scheduled-item,
.compact .log-item {
  padding: 10px 12px;
}

.log-list {
  max-height: 480px;
  overflow: auto;
}

.log-item {
  display: grid;
  gap: 6px;
}

.log-item header {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.status-ok {
  color: var(--success);
}

.status-fail {
  color: var(--danger);
}

.toast-host {
  position: fixed;
  right: 18px;
  bottom: 18px;
  display: grid;
  gap: 10px;
  z-index: 20;
}

.hidden {
  display: none !important;
}

.auth-summary .auth-user-card {
  padding: 14px;
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(15, 99, 204, 0.12), rgba(0, 161, 255, 0.08));
  border: 1px solid rgba(15, 99, 204, 0.14);
}

.auth-overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(8, 14, 28, 0.34);
  backdrop-filter: blur(12px);
  z-index: 30;
}

.auth-card {
  width: min(100%, 460px);
  padding: 28px;
  border-radius: 28px;
  background: var(--panel-strong);
  border: 1px solid var(--border);
  box-shadow: 0 40px 120px rgba(0, 0, 0, 0.24);
}

.auth-card h2 {
  margin: 0 0 8px;
  font-family: var(--font-display);
}

.auth-pane {
  margin-top: 16px;
}

.toast {
  min-width: 260px;
  max-width: 360px;
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(13, 24, 40, 0.92);
  color: white;
  box-shadow: var(--shadow-md);
}

.toast.error {
  background: rgba(160, 33, 57, 0.96);
}

.empty {
  color: var(--muted);
  padding: 14px;
  border: 1px dashed var(--border);
  border-radius: 16px;
  text-align: center;
}

@media (max-width: 1440px) {
  .app-shell,
  .mail-layout,
  .compose-grid,
  .triple-grid,
  .contacts-grid,
  .settings-grid,
  .activity-grid {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    max-height: none;
  }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(120px, 1fr));
  }
}

@media (max-width: 960px) {
  .app-shell {
    padding: 12px;
    gap: 12px;
  }

  .topbar,
  .panel {
    padding: 16px;
  }

  .grid-2,
  .grid-3,
  .sender-row {
    grid-template-columns: 1fr;
  }

  .topbar {
    flex-direction: column;
  }

  .stats-grid {
    width: 100%;
  }
}

body[data-theme="aurora"] {
  --bg: #e7ebf2;
  --panel: #f7f8fb;
  --panel-strong: #ffffff;
  --panel-inset: #eef1f6;
  --text: #1f2937;
  --muted: #5f6b7d;
  --accent: #2f5bd2;
  --accent-2: #1e40af;
  --border: #cfd6e3;
  --shadow-lg: 0 18px 48px rgba(15, 23, 42, 0.08);
  --shadow-md: 0 10px 24px rgba(15, 23, 42, 0.06);
}

body[data-theme="sand"] {
  --bg: #efe7d9;
  --panel: #fbf8f1;
  --panel-strong: #fffdf9;
  --panel-inset: #f3ede2;
  --text: #32261d;
  --muted: #6e5e51;
  --accent: #8b5e34;
  --accent-2: #6d4220;
  --border: #d7ccb9;
  --shadow-lg: 0 18px 48px rgba(61, 43, 25, 0.08);
  --shadow-md: 0 10px 24px rgba(61, 43, 25, 0.06);
}

body[data-theme="graphite"] {
  --bg: #1e232d;
  --panel: #262d39;
  --panel-strong: #303846;
  --panel-inset: #232a35;
  --text: #edf2f7;
  --muted: #9aa7bb;
  --accent: #7aa2ff;
  --accent-2: #4c7ae6;
  --border: #3c4658;
  --shadow-lg: 0 22px 54px rgba(0, 0, 0, 0.28);
  --shadow-md: 0 12px 28px rgba(0, 0, 0, 0.2);
}

body {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.55), rgba(0, 0, 0, 0)) , var(--bg);
  color: var(--text);
}

.ambient,
.sidebar,
.sidebar-foot,
.sidebar-controls,
.sidebar-block {
  display: none !important;
}

.app-shell {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px;
  min-height: 100vh;
}

.auth-locked .app-shell {
  visibility: hidden;
  pointer-events: none;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  backdrop-filter: none;
}

.inset,
.soft-card {
  background: var(--panel-inset);
  border: 1px solid var(--border);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.topbar {
  display: grid;
  grid-template-columns: 1.35fr auto auto;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
}

.topbar-group {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.topbar-left select {
  min-width: 220px;
  max-width: 340px;
}

.topbar-center {
  justify-content: center;
}

.topbar-right {
  justify-content: flex-end;
}

.topbar-label,
.compact-field span {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--muted);
}

.compact-field {
  display: flex;
  align-items: center;
  gap: 8px;
}

.compact-field select {
  width: auto;
  min-width: 88px;
}

.auth-badge {
  display: grid;
  gap: 2px;
  padding: 8px 12px;
  min-width: 190px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel-strong);
}

.stats-grid {
  display: flex;
  gap: 8px;
  width: auto;
}

.stat-card {
  min-width: 86px;
  padding: 8px 10px;
  border-radius: 12px;
  background: var(--panel-strong);
}

.stat-card strong {
  font-size: 1rem;
  font-family: var(--font-body);
}

.main-shell {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 12px;
  min-height: 0;
  flex: 1;
}

.nav-rail {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px 12px;
}

.nav-rail.collapsed {
  width: 76px;
}

.nav-rail.collapsed .rail-brand strong,
.nav-rail.collapsed .rail-brand .eyebrow,
.nav-rail.collapsed .nav-pill,
.nav-rail.collapsed .rail-footer {
  display: none;
}

.rail-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 4px 10px;
  border-bottom: 1px solid var(--border);
}

.brand-mark,
.auth-mark {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.section-nav {
  display: grid;
  gap: 6px;
}

.nav-pill {
  justify-content: flex-start;
  padding: 10px 12px;
  border-radius: 12px;
  background: transparent;
}

.nav-pill.active {
  background: rgba(47, 91, 210, 0.1);
  border-color: rgba(47, 91, 210, 0.24);
  color: var(--accent);
}

.rail-footer {
  margin-top: auto;
  display: grid;
  gap: 8px;
}

.version-chip {
  padding: 8px 10px;
  border-radius: 12px;
  background: var(--panel-strong);
  border: 1px solid var(--border);
  font-size: 0.88rem;
}

.workspace {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.panel {
  display: none;
  flex-direction: column;
  gap: 12px;
  padding: 14px;
}

.panel.active {
  display: flex;
}

.desktop-head {
  align-items: flex-start;
}

.desktop-head h2 {
  margin: 4px 0 0;
  font-size: 1.35rem;
}

.desktop-toolbar {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel-inset);
  flex-wrap: wrap;
}

.icon-button {
  width: 40px;
  padding: 0;
  font-size: 1.1rem;
}

.compose-layout,
.templates-layout,
.contacts-layout,
.settings-layout,
.logs-layout {
  display: grid;
  gap: 12px;
}

.compose-layout {
  grid-template-columns: minmax(320px, 440px) minmax(0, 1fr);
}

.compose-pane,
.editor-pane,
.settings-sidebar,
.settings-main {
  padding: 14px;
}

.form-grid,
.settings-scroll {
  display: grid;
  gap: 12px;
}

.inline-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
}

.option-stack,
.attachments-card {
  display: grid;
  gap: 10px;
}

.compose-actions-stack {
  display: grid;
  gap: 8px;
}

.status-line {
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.editor-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.editor-tabs {
  display: inline-flex;
  gap: 6px;
  padding: 4px;
  border-radius: 12px;
  background: var(--panel-strong);
  border: 1px solid var(--border);
}

.editor-tab {
  padding: 8px 12px;
  border: 0;
  box-shadow: none;
  background: transparent;
}

.editor-tab.active {
  background: rgba(47, 91, 210, 0.14);
  color: var(--accent);
}

.editor-panels {
  display: grid;
}

.editor-panel {
  display: none;
}

.editor-panel.active {
  display: block;
}

.grow {
  display: grid;
  gap: 8px;
}

.html-workbench {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 0.9fr);
  gap: 12px;
}

.preview-column,
.preview-shell-wide {
  min-height: 100%;
}

.preview-shell {
  min-height: 520px;
  padding: 12px;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.4), rgba(0, 0, 0, 0)) , var(--panel-strong);
}

.preview-shell-wide {
  min-height: 620px;
}

.mail-table,
.message-view,
.templates-list-pane,
.template-details-pane,
.contacts-groups-pane,
.contacts-table-pane,
.contact-form-pane,
.queue-pane,
.logs-pane {
  padding: 12px;
}

.mail-table table,
.contacts-table-pane table {
  background: var(--panel-strong);
  border-radius: 12px;
  overflow: hidden;
}

.mail-table tbody tr:hover,
.mail-table tbody tr.active,
.contacts-table-pane tbody tr:hover {
  background: rgba(47, 91, 210, 0.08);
}

.templates-layout {
  grid-template-columns: 320px minmax(0, 1fr);
}

.template-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.template-form-grid .span-2 {
  grid-column: span 2;
}

.template-body-grid {
  display: grid;
  grid-template-columns: minmax(240px, 0.9fr) minmax(0, 1.2fr);
  gap: 12px;
  margin-top: 12px;
}

.template-plain-preview {
  min-height: 300px;
  margin: 0;
  padding: 12px;
  border-radius: 12px;
  background: var(--panel-strong);
  border: 1px solid var(--border);
  white-space: pre-wrap;
}

.contacts-layout {
  grid-template-columns: 280px minmax(0, 1fr) 320px;
}

.settings-layout {
  grid-template-columns: 280px minmax(0, 1fr);
}

.settings-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding-bottom: 12px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.settings-scroll {
  max-height: calc(100vh - 230px);
  overflow: auto;
  padding-right: 4px;
}

.protocol-group {
  display: grid;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel-strong);
}

.protocol-group h3 {
  margin: 0;
}

.group-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.inline-toggle-row {
  align-items: center;
}

.settings-subgrid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.logs-layout {
  grid-template-columns: 320px minmax(0, 1fr);
}

.stats-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

.mini-stat {
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--panel-inset);
  border: 1px solid var(--border);
}

.mini-stat span {
  color: var(--muted);
  font-size: 0.85rem;
}

.mini-stat strong {
  font-size: 1.1rem;
}

.log-list {
  max-height: 520px;
}

.log-item,
.scheduled-item,
.folder-item,
.select-item,
.attachment-item {
  border-radius: 12px;
}

.wide {
  width: 100%;
}

.auth-overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(15, 23, 42, 0.28);
  backdrop-filter: blur(8px);
  z-index: 40;
}

.auth-card {
  width: min(100%, 440px);
  padding: 24px;
  border-radius: 18px;
  background: var(--panel-strong);
  border: 1px solid var(--border);
  box-shadow: 0 28px 80px rgba(15, 23, 42, 0.2);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.hidden {
  display: none !important;
}

@media (max-width: 1440px) {
  .topbar {
    grid-template-columns: 1fr;
  }

  .topbar-center,
  .topbar-right {
    justify-content: flex-start;
  }

  .compose-layout,
  .templates-layout,
  .contacts-layout,
  .settings-layout,
  .logs-layout,
  .html-workbench,
  .template-body-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 1024px) {
  .main-shell {
    grid-template-columns: 1fr;
  }

  .nav-rail {
    flex-direction: row;
    align-items: center;
    overflow: auto;
  }

  .section-nav {
    display: flex;
    flex-wrap: wrap;
  }

  .rail-footer {
    display: none;
  }

  .settings-subgrid,
  .template-form-grid,
  .grid-2 {
    grid-template-columns: 1fr;
  }

  .template-form-grid .span-2 {
    grid-column: auto;
  }
}

@media (max-width: 720px) {
  .app-shell {
    padding: 10px;
  }

  .topbar-left select,
  .compact-field select,
  .desktop-toolbar input,
  .desktop-toolbar select {
    min-width: 0;
    width: 100%;
  }

  .stats-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .stats-grid {
    flex-wrap: wrap;
  }
}
