:root {
  --bg: #f4f0e8;
  --card: rgba(255, 255, 255, 0.92);
  --text: #1f1d18;
  --muted: #6f6656;
  --line: rgba(31, 29, 24, 0.12);
  --accent: #0f766e;
  --danger: #b42318;
  --success: #157f3b;
  --shadow: 0 18px 40px rgba(54, 39, 9, 0.08);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(15, 118, 110, 0.12), transparent 35%),
    linear-gradient(180deg, #f8f4ec 0%, #f1e7d4 100%);
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
button, .button-primary, .button-secondary {
  border: 0;
  border-radius: 999px;
  padding: 0.9rem 1.2rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
button, .button-primary { background: var(--accent); color: white; }
.button-secondary { background: transparent; border: 1px solid var(--line); }
.shell-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 1.2rem 1.6rem;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(14px);
  position: sticky;
  top: 0;
}
.admin-shell {
  background: rgba(26, 33, 50, 0.9);
  color: #f7f4ed;
  border-bottom-color: rgba(255, 255, 255, 0.08);
}
.brand-block {
  display: flex;
  align-items: center;
  gap: 1.1rem;
  min-width: 0;
  flex: 1 1 auto;
}
.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 84px;
  height: 84px;
  padding: 0;
  flex: 0 0 auto;
}
.brand-logo {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.brand-copy {
  min-width: 0;
  display: flex;
  align-items: center;
}
.tagline, .eyebrow, .form-hint, .error-inline { color: var(--muted); }
.tagline {
  margin: 0;
  white-space: nowrap;
}
.shell-nav, .hero-actions, .status-row, .page-heading { display: flex; gap: 0.9rem; align-items: center; }
.page { width: min(1120px, calc(100vw - 2rem)); margin: 2rem auto 4rem; }
.hero { display: grid; grid-template-columns: 1.7fr 1fr; gap: 1.5rem; align-items: stretch; }
.card, .feature-card {
  background: var(--card);
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 28px;
  box-shadow: var(--shadow);
  padding: 1.6rem;
}
.feature-card { background: linear-gradient(145deg, rgba(15, 118, 110, 0.1), rgba(255, 255, 255, 0.96)); }
.narrow { max-width: 520px; margin: 0 auto; }
.stack { display: grid; gap: 1rem; }
.top-gap { margin-top: 1rem; }
.two-col { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.full-width { grid-column: 1 / -1; }
label { display: grid; gap: 0.4rem; font-weight: 600; }
input, select {
  width: 100%;
  padding: 0.85rem 1rem;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.95);
}
textarea {
  width: 100%;
  padding: 0.85rem 1rem;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.95);
  resize: vertical;
  font: inherit;
}
.flash { border-radius: 18px; padding: 0.95rem 1rem; margin-bottom: 1rem; }
.flash-error { background: rgba(180, 35, 24, 0.1); color: var(--danger); }
.flash-success { background: rgba(21, 127, 59, 0.12); color: var(--success); }
.mailbox-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1rem; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.stat-card strong { display: block; font-size: 2rem; margin-bottom: 0.35rem; }
.status-badge { font-size: 0.85rem; padding: 0.25rem 0.6rem; border-radius: 999px; background: rgba(31, 29, 24, 0.08); }
.status-healthy { background: rgba(21, 127, 59, 0.15); color: var(--success); }
.status-error { background: rgba(180, 35, 24, 0.12); color: var(--danger); }
.split-layout { display: grid; grid-template-columns: minmax(0, 380px) minmax(0, 1fr); gap: 1rem; }
.content-stack { display: grid; gap: 1rem; }
.content { min-width: 0; }
.sidebar { display: grid; gap: 0.5rem; align-content: start; }
.sidebar-link, .message-row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1rem;
  border-radius: 18px;
  border: 1px solid transparent;
}
.message-row-link {
  flex: 1 1 auto;
  min-width: 0;
}
.message-select-row {
  display: flex;
  align-items: stretch;
  gap: 0.75rem;
}
.message-select-row input[type="checkbox"] {
  width: auto;
  align-self: center;
}
.bulk-actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
}
.bulk-actions select {
  width: auto;
  min-width: 160px;
}
.sidebar-link.active, .message-row:hover {
  background: rgba(15, 118, 110, 0.08);
  border-color: rgba(15, 118, 110, 0.15);
}
.message-list { display: grid; gap: 0.75rem; }
.message-row-title, .message-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}
.message-chip-row { margin-top: 0.35rem; }
.table-list { display: grid; gap: 0.8rem; }
.table-row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem;
  border-radius: 18px;
  background: rgba(255,255,255,0.7);
  border: 1px solid rgba(31,29,24,0.08);
  min-width: 0;
  overflow: hidden;
}
.table-row > div { min-width: 0; flex: 1 1 auto; }
.table-row strong,
.table-row p,
.table-row time {
  overflow-wrap: anywhere;
  word-break: break-word;
}
.table-row time {
  flex: 0 0 110px;
  text-align: right;
}
.table-row-wide { align-items: flex-start; }
.compact-form { min-width: 180px; }
.message-body {
  white-space: pre-wrap;
  font-family: "Cascadia Code", monospace;
  background: rgba(15, 118, 110, 0.05);
  padding: 1rem;
  border-radius: 18px;
}
.message-heading {
  justify-content: space-between;
  align-items: flex-start;
}
.metadata-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}
.metadata-grid p {
  margin: 0.35rem 0 0;
  overflow-wrap: anywhere;
}
.message-actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
}
.filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}
.card-subtle {
  margin-bottom: 1rem;
  padding: 1rem;
  background: rgba(15, 118, 110, 0.04);
  border-radius: 22px;
}
.checkbox-field {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-weight: 600;
}
.checkbox-field input {
  width: auto;
}
.status-warning {
  background: rgba(202, 138, 4, 0.15);
  color: #8a5b00;
}
.html-mail-frame {
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 1rem;
  background: rgba(255, 255, 255, 0.96);
  overflow: auto;
}
.html-mail-frame img {
  max-width: 100%;
  height: auto;
}
.attachment-preview {
  margin-top: 0.85rem;
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.9);
}
.attachment-preview img,
.attachment-preview iframe {
  display: block;
  width: 100%;
  min-height: 320px;
  border: 0;
}
.tag-chip {
  padding: 0.55rem 0.85rem;
  border-radius: 999px;
  border: 1px solid rgba(15, 118, 110, 0.16);
  background: rgba(15, 118, 110, 0.08);
  color: var(--text);
}
.chip-form button {
  font-weight: 600;
}
.modal-overlay {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: rgba(20, 24, 33, 0.55);
  backdrop-filter: blur(10px);
  z-index: 20;
}
.modal-overlay:target {
  display: flex;
}
.modal-dialog {
  width: min(720px, calc(100vw - 2rem));
  max-height: calc(100vh - 3rem);
  overflow: auto;
}
.qr-code { max-width: 220px; width: 100%; display: block; margin-bottom: 1rem; }
.inline-form { display: inline-flex; }
@media (max-width: 860px) {
  .hero, .split-layout, .two-col { grid-template-columns: 1fr; }
  .shell-header, .page-heading { flex-direction: column; align-items: flex-start; }
  .message-heading { align-items: flex-start; }
  .brand-mark {
    width: 64px;
    height: 64px;
  }
  .brand-block {
    width: 100%;
  }
  .brand-copy {
    min-width: 0;
  }
  .tagline {
    white-space: normal;
  }
}
