*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  color-scheme: light;
  --page: #f6f7f9;
  --page-2: #eceff3;
  --ink: #121416;
  --ink-2: #353a42;
  --muted: #737985;
  --faint: #a4a9b2;
  --surface: rgba(255, 255, 255, .86);
  --surface-solid: #ffffff;
  --surface-soft: #f7f8fa;
  --line: rgba(24, 27, 32, .11);
  --line-strong: rgba(24, 27, 32, .18);
  --nav: rgba(255, 255, 255, .58);
  --dark: #15171b;
  --blue: #1c4f9f;
  --green: #20734d;
  --purple: #6848b8;
  --amber: #9b5c18;
  --success: #187348;
  --success-bg: #edf8f2;
  --error: #b42318;
  --error-bg: #fff1ef;
  --warn: #9a5b13;
  --warn-bg: #fff7e8;
  --shadow-soft: 0 18px 60px rgba(21, 23, 27, .10), 0 2px 10px rgba(21, 23, 27, .05);
  --shadow-tight: 0 10px 28px rgba(21, 23, 27, .08), 0 1px 4px rgba(21, 23, 27, .05);
  --focus: 0 0 0 4px rgba(28, 79, 159, .16);
  --radius: 8px;
  --sidebar-width: 264px;
  --sidebar-collapsed: 74px;
}

html { min-height: 100%; }

body {
  min-height: 100vh;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  background: linear-gradient(135deg, var(--page), var(--page-2));
  text-rendering: optimizeLegibility;
}

button, input, textarea { font: inherit; }
button { color: inherit; }
a { color: var(--blue); text-decoration: none; font-weight: 650; }
a:hover { text-decoration: underline; }

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  min-height: 100vh;
  transition: grid-template-columns .18s ease;
}

.app-sidebar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-width: 0;
  height: 100vh;
  padding: 14px 12px;
  border-right: 1px solid rgba(24, 27, 32, .1);
  background: rgba(255, 255, 255, .9);
  box-shadow: 8px 0 30px rgba(21, 23, 27, .04);
  backdrop-filter: blur(18px);
}

.sidebar-top {
  display: grid;
  gap: 18px;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 46px;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: var(--dark);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.18);
}

.brand-mark img {
  width: 26px;
  height: 26px;
  object-fit: contain;
  filter: brightness(0) invert(1);
}

.brand-text { min-width: 0; }

.brand-lockup strong {
  display: block;
  overflow: hidden;
  color: var(--ink);
  font-size: .92rem;
  font-weight: 820;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-lockup span {
  display: block;
  margin-top: 1px;
  color: var(--muted);
  font-size: .68rem;
  font-weight: 760;
  letter-spacing: .09em;
  text-transform: uppercase;
}

.sidebar-toggle,
.topbar-menu {
  flex: 0 0 auto;
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid rgba(21, 23, 27, .1);
  border-radius: 8px;
  background: rgba(255,255,255,.72);
  color: var(--ink-2);
  cursor: pointer;
  transition: background .16s ease, border-color .16s ease, color .16s ease, transform .08s ease;
}

.sidebar-toggle:hover,
.topbar-menu:hover {
  border-color: rgba(21,23,27,.18);
  background: #fff;
  color: var(--ink);
}

.collapse-icon { transition: transform .18s ease; }

.module-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-section-label {
  margin: 0 10px 5px;
  color: var(--faint);
  font-size: .66rem;
  font-weight: 820;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  width: 100%;
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: .82rem;
  font-weight: 780;
  white-space: nowrap;
  transition: color .16s ease, background .16s ease, border-color .16s ease;
}

.nav-icon {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  flex: 0 0 24px;
  border-radius: 6px;
  color: currentColor;
  background: rgba(21,23,27,.04);
}

.nav-label {
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-item:hover {
  color: var(--ink);
  background: rgba(21,23,27,.045);
}

.nav-item.active {
  color: var(--ink);
  background: rgba(21,23,27,.07);
  border-color: rgba(21,23,27,.06);
}

.logout-form { margin: 0; }

.logout-button {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  width: 100%;
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid rgba(21, 23, 27, .1);
  border-radius: 8px;
  background: rgba(255,255,255,.62);
  color: var(--ink-2);
  cursor: pointer;
  font-size: .82rem;
  font-weight: 760;
}

.logout-button:hover { background: #fff; }

body.sidebar-collapsed .app-shell {
  grid-template-columns: var(--sidebar-collapsed) minmax(0, 1fr);
}

body.sidebar-collapsed .app-sidebar {
  padding-inline: 10px;
}

body.sidebar-collapsed .sidebar-header {
  justify-content: center;
}

body.sidebar-collapsed .brand-text,
body.sidebar-collapsed .nav-label,
body.sidebar-collapsed .sidebar-section-label,
body.sidebar-collapsed .logout-label {
  display: none;
}

body.sidebar-collapsed .brand-lockup {
  justify-content: center;
}

body.sidebar-collapsed .sidebar-toggle {
  position: absolute;
  left: 56px;
  top: 18px;
  width: 28px;
  height: 28px;
  box-shadow: 0 8px 20px rgba(21,23,27,.12);
}

body.sidebar-collapsed .collapse-icon {
  transform: rotate(180deg);
}

body.sidebar-collapsed .nav-item,
body.sidebar-collapsed .logout-button {
  justify-content: center;
  padding-inline: 0;
}

.sidebar-scrim { display: none; }

.app-main {
  min-width: 0;
  padding: 18px 28px 52px;
}

.app-topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 74px;
  margin: -18px -28px 18px;
  padding: 14px 28px;
  border-bottom: 1px solid rgba(24, 27, 32, .08);
  background: rgba(246, 247, 249, .86);
  backdrop-filter: blur(16px);
}

.topbar-menu {
  display: none;
}

.topbar-copy {
  min-width: 0;
  flex: 1;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  color: var(--muted);
  font-size: .65rem;
  font-weight: 820;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.app-topbar h1 {
  overflow: hidden;
  margin-top: 2px;
  color: var(--ink);
  font-size: 1.36rem;
  line-height: 1.15;
  font-weight: 860;
  letter-spacing: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-topbar p {
  overflow: hidden;
  max-width: 680px;
  margin-top: 3px;
  color: var(--ink-2);
  font-size: .86rem;
  font-weight: 560;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.topbar-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  padding: 5px 10px;
  border: 1px solid rgba(21,23,27,.09);
  border-radius: 999px;
  background: rgba(255,255,255,.72);
  color: var(--muted);
  font-size: .72rem;
  font-weight: 760;
  white-space: nowrap;
}

.topbar-pill strong {
  color: var(--ink);
  font-weight: 860;
}

.content {
  width: min(100%, 1360px);
  margin: 0 auto;
  padding-bottom: 0;
}

#main-content > .tool-shell {
  display: grid;
  gap: 16px;
}

.tool-card {
  --module: var(--blue);
  display: grid;
  grid-template-columns: minmax(280px, 380px) minmax(0, 1fr);
  min-height: 390px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.76);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow-tight);
  backdrop-filter: blur(20px);
}

.tool-card.variant-green { --module: var(--green); }
.tool-card.variant-purple { --module: var(--purple); }
.tool-card.variant-amber { --module: var(--amber); }

.tool-intro {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 24px;
  padding: 28px;
  color: #fff;
  background:
    linear-gradient(145deg, rgba(255,255,255,.12), transparent 30%),
    linear-gradient(135deg, color-mix(in srgb, var(--module) 88%, #111 12%), #14171c 78%);
}

.tool-intro::after {
  content: "";
  position: absolute;
  inset: 0 0 0 auto;
  width: 1px;
  background: rgba(255,255,255,.18);
}

.tool-kicker {
  position: relative;
  z-index: 1;
  display: inline-flex;
  width: max-content;
  min-height: 26px;
  align-items: center;
  padding: 3px 10px;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 999px;
  background: rgba(255,255,255,.11);
  color: rgba(255,255,255,.82);
  font-size: .68rem;
  font-weight: 820;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.tool-intro h2 {
  position: relative;
  z-index: 1;
  max-width: 520px;
  margin-top: 18px;
  color: #fff;
  font-size: clamp(1.42rem, 1.55vw, 2rem);
  line-height: 1.08;
  font-weight: 850;
}

.tool-intro p {
  position: relative;
  z-index: 1;
  max-width: 520px;
  margin-top: 16px;
  color: rgba(255,255,255,.72);
  font-size: .96rem;
}

.workflow-strip {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.workflow-strip span {
  min-height: 28px;
  padding: 5px 10px;
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 999px;
  background: rgba(255,255,255,.09);
  color: rgba(255,255,255,.78);
  font-size: .72rem;
  font-weight: 740;
}

.tool-form {
  display: flex;
  flex-direction: column;
  padding: 26px;
  background: rgba(255,255,255,.74);
}

.form-topline {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.email-mode-tabs {
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 3px;
  width: min(100%, 320px);
  margin-bottom: 18px;
  padding: 3px;
  border: 1px solid rgba(21,23,27,.1);
  border-radius: 8px;
  background: rgba(21,23,27,.045);
}

.email-mode-tab {
  min-height: 34px;
  padding: 7px 12px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: .78rem;
  font-weight: 820;
  white-space: nowrap;
  transition: background .16s ease, border-color .16s ease, color .16s ease, box-shadow .16s ease;
}

.email-mode-tab:hover {
  color: var(--ink);
  background: rgba(255,255,255,.58);
}

.email-mode-tab.active {
  border-color: rgba(255,255,255,.9);
  background: #fff;
  color: var(--ink);
  box-shadow: 0 6px 16px rgba(21,23,27,.07);
}

label {
  display: block;
  color: var(--ink);
  font-size: .9rem;
  font-weight: 820;
}

.input-hint {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: .78rem;
  font-weight: 580;
}

.input-hint code {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  margin-left: 3px;
  padding: 2px 7px;
  border: 1px solid rgba(21,23,27,.11);
  border-radius: 6px;
  background: rgba(255,255,255,.7);
  color: var(--ink-2);
  font-family: "SF Mono", "Cascadia Code", Consolas, monospace;
  font-size: .72rem;
}

textarea {
  width: 100%;
  flex: 1;
  min-height: 220px;
  resize: vertical;
  padding: 16px;
  border: 1px solid rgba(21,23,27,.12);
  border-radius: 8px;
  outline: none;
  background:
    linear-gradient(180deg, rgba(255,255,255,.96), rgba(250,249,246,.96));
  color: var(--ink);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.9);
  font-family: "SF Mono", "Cascadia Code", Consolas, monospace;
  font-size: .88rem;
  line-height: 1.75;
  transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
}

textarea::placeholder { color: var(--faint); }
textarea:hover:not(:disabled) { border-color: rgba(21,23,27,.2); background: #fff; }
textarea:focus { border-color: var(--module, var(--blue)); box-shadow: var(--focus), inset 0 1px 0 rgba(255,255,255,.9); background: #fff; }
textarea:disabled { cursor: not-allowed; opacity: .58; }

.actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.btn,
.btn-import,
.logout-button,
.btn-submit,
.btn-back {
  border-radius: 8px;
  font-weight: 800;
  letter-spacing: 0;
  transition: transform .08s ease, background .16s ease, border-color .16s ease, color .16s ease, box-shadow .16s ease, opacity .16s ease;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 10px 16px;
  border: 1px solid transparent;
  cursor: pointer;
  font-size: .84rem;
  white-space: nowrap;
}

.btn-primary {
  background: var(--dark);
  color: #fff;
  box-shadow: 0 10px 22px rgba(21,23,27,.16);
}

.btn-primary:hover:not(:disabled) {
  background: #24272e;
  transform: translateY(-1px);
}

.btn-secondary,
.btn-ghost {
  border-color: rgba(21,23,27,.12);
  background: rgba(255,255,255,.72);
  color: var(--ink-2);
}

.btn-secondary:hover:not(:disabled),
.btn-ghost:hover:not(:disabled) {
  background: #fff;
  border-color: rgba(21,23,27,.2);
}

.btn:disabled {
  cursor: not-allowed;
  opacity: .44;
  box-shadow: none;
}

.btn-import {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 36px;
  padding: 8px 12px;
  border: 1px solid rgba(21,23,27,.12);
  background: rgba(255,255,255,.68);
  color: var(--ink-2);
  cursor: pointer;
  font-size: .78rem;
}

.btn-import:hover {
  border-color: color-mix(in srgb, var(--module, var(--blue)) 36%, rgba(21,23,27,.12));
  background: color-mix(in srgb, var(--module, var(--blue)) 9%, #fff);
  color: var(--ink);
}

.btn:focus-visible,
.btn-import:focus-visible,
.logout-button:focus-visible,
.nav-item:focus-visible,
.sidebar-toggle:focus-visible,
.topbar-menu:focus-visible,
.email-mode-tab:focus-visible,
.btn-submit:focus-visible,
.btn-back:focus-visible,
textarea:focus-visible,
input:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

.visually-hidden-file {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.htmx-indicator { display: none; }
.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator { display: inline-block; }
.btn.htmx-request .btn-text,
.btn.htmx-request .btn-icon { display: none; }
.btn.htmx-request .btn-spinner { display: inline-block; }

.btn-spinner {
  display: none;
  width: 15px;
  height: 15px;
  border: 2px solid rgba(255,255,255,.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .72s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.status-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 34px;
  margin-top: 12px;
  color: var(--muted);
}
.status-wrap:empty { min-height: 0; margin: 0; }

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  flex: 0 0 auto;
}

.status-msg { font-size: .84rem; font-weight: 700; }
.status-wrap.running .status-dot { background: #d9822b; animation: pulse 1.2s infinite; }
.status-wrap.running .status-msg { color: var(--warn); }
.status-wrap.done .status-dot { background: var(--success); }
.status-wrap.done .status-msg { color: var(--success); }
.status-wrap.error .status-dot { background: var(--error); }
.status-wrap.error .status-msg { color: var(--error); }
@keyframes pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .35; transform: scale(.82); } }

.result-zone:empty {
  min-height: 120px;
  border: 1px dashed rgba(21,23,27,.14);
  border-radius: 8px;
  background: rgba(255,255,255,.35);
}

.result-zone > .status-wrap,
.result-zone > [id$="-poller"] {
  padding: 18px 20px;
  border: 1px solid rgba(255,255,255,.74);
  border-radius: 8px;
  background: rgba(255,255,255,.72);
  box-shadow: var(--shadow-tight);
  backdrop-filter: blur(18px);
}

.result-zone > [id$="-poller"] .status-wrap {
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.table-wrap {
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.78);
  border-radius: 8px;
  background: rgba(255,255,255,.82);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(20px);
}

.table-wrap-inner { overflow-x: auto; }

.result-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid rgba(21,23,27,.08);
  background: rgba(255,255,255,.58);
}

.result-meta-label {
  color: var(--ink);
  font-size: .88rem;
  font-weight: 820;
}

.result-count {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 3px 10px;
  border: 1px solid rgba(21,23,27,.1);
  border-radius: 999px;
  background: rgba(255,255,255,.75);
  color: var(--muted);
  font-size: .72rem;
  font-weight: 820;
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: .8rem;
}

thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 11px 14px;
  border-bottom: 1px solid rgba(21,23,27,.1);
  background: rgba(248,247,244,.94);
  color: var(--muted);
  font-size: .68rem;
  font-weight: 850;
  letter-spacing: .08em;
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
}

tbody td {
  max-width: 290px;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(21,23,27,.07);
  color: var(--ink-2);
  vertical-align: top;
  word-break: break-word;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: rgba(28, 79, 159, .035); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 23px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: .68rem;
  font-weight: 850;
  white-space: nowrap;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 999px; flex: 0 0 auto; }
.badge-active, .badge-ok { background: var(--success-bg); color: var(--success); }
.badge-active::before, .badge-ok::before { background: var(--success); }
.badge-exited { background: #f4f1ff; color: #6d3ec3; }
.badge-exited::before { background: #7a4be0; }
.badge-uncertain { background: #eef4ff; color: #315cb8; }
.badge-uncertain::before { background: #315cb8; }
.badge-notfound { background: rgba(21,23,27,.06); color: var(--muted); }
.badge-notfound::before { background: var(--faint); }
.badge-err { background: var(--error-bg); color: var(--error); }
.badge-err::before { background: var(--error); }

.empty-state {
  display: grid;
  place-items: center;
  gap: 10px;
  min-height: 240px;
  padding: 42px 20px;
  color: var(--muted);
  text-align: center;
}
.empty-state svg { opacity: .38; }
.empty-state p { font-size: .86rem; font-weight: 650; }

.email-results {
  display: grid;
  gap: 18px;
  margin-top: 14px;
}

.email-card {
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.78);
  border-radius: 8px;
  background: rgba(255,255,255,.88);
  box-shadow: var(--shadow-tight);
  backdrop-filter: blur(18px);
}

.email-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 20px;
  border-bottom: 1px solid rgba(21,23,27,.08);
  background: rgba(248,247,244,.76);
}

.email-buyer-line {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.email-buyer-line strong {
  color: var(--ink);
  font-size: 1rem;
  font-weight: 850;
}

.email-buyer-line span {
  display: inline-flex;
  min-height: 23px;
  align-items: center;
  padding: 2px 8px;
  border: 1px solid rgba(21,23,27,.1);
  border-radius: 999px;
  background: rgba(255,255,255,.7);
  color: var(--muted);
  font-size: .72rem;
  font-weight: 780;
}

.email-site {
  display: inline-block;
  margin-top: 4px;
  font-size: .8rem;
}

.email-copy-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.btn-copy {
  min-height: 32px;
  padding: 6px 10px;
  border: 1px solid rgba(21,23,27,.12);
  border-radius: 8px;
  background: rgba(255,255,255,.76);
  color: var(--ink-2);
  cursor: pointer;
  font-size: .74rem;
  font-weight: 820;
}

.btn-copy:hover {
  border-color: rgba(21,23,27,.2);
  background: #fff;
}

.btn-copy.primary-copy {
  border-color: var(--dark);
  background: var(--dark);
  color: #fff;
}

.btn-copy.copied {
  border-color: rgba(24,115,72,.22);
  background: var(--success-bg);
  color: var(--success);
}

.email-section {
  padding: 18px 20px 0;
}

.email-card .email-section:last-of-type {
  padding-bottom: 20px;
}

.email-label {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: .68rem;
  font-weight: 850;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.email-subject {
  padding: 12px 14px;
  border: 1px solid rgba(21,23,27,.08);
  border-radius: 8px;
  background: rgba(255,255,255,.72);
  color: var(--ink);
  font-size: .92rem;
  font-weight: 760;
  line-height: 1.5;
}

.email-body,
.email-detail-block pre {
  white-space: pre-wrap;
  word-break: break-word;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.email-body {
  margin: 0;
  padding: 16px;
  border: 1px solid rgba(21,23,27,.08);
  border-radius: 8px;
  background: #fff;
  color: var(--ink-2);
  font-size: .92rem;
  line-height: 1.72;
}

.copy-payload {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
  white-space: pre-wrap;
}

.email-details {
  margin: 0 20px 20px;
  border: 1px solid rgba(21,23,27,.08);
  border-radius: 8px;
  background: rgba(248,247,244,.58);
}

.email-details summary {
  cursor: pointer;
  padding: 10px 12px;
  color: var(--muted);
  font-size: .78rem;
  font-weight: 820;
}

.email-detail-block {
  padding: 0 12px 12px;
}

.email-detail-block strong {
  display: block;
  margin-bottom: 5px;
  color: var(--ink-2);
  font-size: .75rem;
}

.email-detail-block pre {
  margin: 0;
  max-height: 220px;
  overflow: auto;
  padding: 10px;
  border-radius: 8px;
  background: rgba(255,255,255,.72);
  color: var(--muted);
  font-size: .76rem;
  line-height: 1.55;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-wrapper,
.error-wrapper {
  width: 100%;
  max-width: 420px;
}
.error-wrapper { max-width: 460px; text-align: center; }

.login-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 26px;
}
.login-logo-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  background: var(--dark);
  border-radius: 8px;
}
.login-logo-icon img {
  width: 28px;
  height: 28px;
  object-fit: contain;
  filter: brightness(0) invert(1);
}
.login-logo-text strong { display: block; color: var(--ink); font-size: .92rem; font-weight: 820; }
.login-logo-text span { display: block; margin-top: 2px; color: var(--muted); font-size: .7rem; font-weight: 780; letter-spacing: .08em; text-transform: uppercase; }

.login-card {
  padding: 30px;
  border: 1px solid rgba(255,255,255,.78);
  border-radius: 8px;
  background: rgba(255,255,255,.78);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(20px);
}
.login-card h1 { margin-bottom: 4px; color: var(--ink); font-size: 1.08rem; font-weight: 850; }
.subtitle { margin-bottom: 26px; color: var(--muted); font-size: .84rem; }
.field { margin-bottom: 16px; }

input[type="text"],
input[type="password"] {
  width: 100%;
  min-height: 42px;
  padding: 9px 12px;
  border: 1px solid rgba(21,23,27,.12);
  border-radius: 8px;
  background: rgba(255,255,255,.75);
  color: var(--ink);
  outline: none;
  transition: background .16s ease, border-color .16s ease, box-shadow .16s ease;
}
input[type="text"]:focus,
input[type="password"]:focus { background: #fff; border-color: var(--blue); box-shadow: var(--focus); }

.btn-submit {
  width: 100%;
  min-height: 42px;
  margin-top: 8px;
  border: 1px solid var(--dark);
  background: var(--dark);
  color: #fff;
  cursor: pointer;
}
.btn-submit:hover { background: #24272e; }

.error-banner {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 18px;
  padding: 10px 12px;
  border: 1px solid rgba(180,35,24,.18);
  border-radius: 8px;
  background: var(--error-bg);
  color: var(--error);
  font-size: .8rem;
  font-weight: 700;
}
.login-footer,
.error-footer { margin-top: 20px; color: var(--muted); font-size: .72rem; text-align: center; }

.error-badge {
  display: inline-grid;
  place-items: center;
  width: 58px;
  height: 58px;
  margin-bottom: 20px;
  border-radius: 8px;
}
.error-badge.e4xx { background: var(--warn-bg); color: var(--warn); }
.error-badge.e5xx { background: var(--error-bg); color: var(--error); }
.error-code { margin-bottom: 8px; color: var(--muted); font-size: .68rem; font-weight: 820; letter-spacing: .12em; text-transform: uppercase; }
.error-title { margin-bottom: 6px; color: var(--ink); font-size: 1.1rem; font-weight: 850; }
.error-msg { margin-bottom: 28px; color: var(--muted); font-size: .86rem; line-height: 1.6; }
.btn-back {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 9px 16px;
  border: 1px solid var(--dark);
  background: var(--dark);
  color: #fff;
  font-size: .84rem;
}
.btn-back:hover { background: #24272e; text-decoration: none; }

@supports not (color: color-mix(in srgb, white, black)) {
  .tool-intro { background: linear-gradient(135deg, var(--module), #14171c 78%); }
  .btn-import:hover { border-color: rgba(21,23,27,.2); background: #fff; }
}

@media (max-width: 1120px) {
  .tool-card {
    grid-template-columns: 1fr;
  }
  .tool-intro {
    min-height: 250px;
  }
  .topbar-actions { display: none; }
}

@media (max-width: 900px) {
  .app-shell,
  body.sidebar-collapsed .app-shell {
    display: block;
  }

  .app-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(292px, calc(100vw - 42px));
    height: 100dvh;
    transform: translateX(-102%);
    transition: transform .2s ease;
  }

  body.sidebar-open { overflow: hidden; }
  body.sidebar-open .app-sidebar { transform: translateX(0); }

  .sidebar-scrim {
    position: fixed;
    inset: 0;
    z-index: 35;
    display: block;
    background: rgba(18, 20, 22, .34);
    opacity: 0;
    pointer-events: none;
    transition: opacity .18s ease;
  }

  body.sidebar-open .sidebar-scrim {
    opacity: 1;
    pointer-events: auto;
  }

  body.sidebar-collapsed .brand-text,
  body.sidebar-collapsed .nav-label,
  body.sidebar-collapsed .sidebar-section-label,
  body.sidebar-collapsed .logout-label {
    display: block;
  }

  body.sidebar-collapsed .sidebar-header {
    justify-content: space-between;
  }

  body.sidebar-collapsed .brand-lockup {
    justify-content: flex-start;
  }

  body.sidebar-collapsed .sidebar-toggle {
    position: static;
    width: 34px;
    height: 34px;
    box-shadow: none;
  }

  body.sidebar-collapsed .collapse-icon {
    transform: none;
  }

  body.sidebar-collapsed .nav-item,
  body.sidebar-collapsed .logout-button {
    justify-content: flex-start;
    padding-inline: 10px;
  }

  .app-main {
    padding: 14px 16px 34px;
  }

  .app-topbar {
    min-height: 68px;
    margin: -14px -16px 14px;
    padding: 12px 16px;
    align-items: center;
  }

  .topbar-menu { display: inline-grid; }

  .topbar-copy h1,
  .app-topbar h1 {
    font-size: 1.12rem;
  }

  .app-topbar p {
    max-width: none;
  }

  .tool-intro,
  .tool-form {
    padding: 22px;
  }
}

@media (max-width: 560px) {
  body { font-size: 13px; }
  .app-main {
    padding-inline: 10px;
  }
  .app-topbar {
    margin-inline: -10px;
    padding-inline: 10px;
  }
  .eyebrow { display: none; }
  .form-topline {
    display: grid;
    gap: 12px;
  }
  .email-card-head {
    display: grid;
  }
  .email-copy-actions {
    justify-content: flex-start;
  }
  .actions .btn { width: 100%; }
  textarea { min-height: 220px; }
  .tool-intro h2 { font-size: 1.7rem; }
}
