.hidden {
  display: none !important;
}

.mail-container {
  max-width: none !important;
  margin: 0 !important;
  padding: 0 !important;
  width: 100%;
}

.mail-shell {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  padding: 1rem;
}

.admin-layout {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.admin-addbar {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
}

@media (min-width: 901px) {
  .admin-layout {
    display: grid;
    grid-template-columns: 420px 1fr;
  }

  #admin-add-email {
    flex: 1;
    min-width: 280px;
  }
}

.mail-sidebar {
  width: 240px;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-card);
  position: sticky;
  top: 1rem;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
}

.mail-sidebar-top {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 0.75rem;
}

.mail-burger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.mail-burger:hover {
  background: #252525;
  border-color: #3a3a3a;
}

.compose-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-right: 0.5rem;
}

.mail-nav {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.mail-nav-spacer {
  flex: 1;
}

.mail-nav .btn {
  width: 100%;
  text-align: center;
  display: block;
}

.mail-main {
  flex: 1;
  min-width: 0;
}

.mail-profilebar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
  background: var(--bg-card);
  margin-bottom: 1rem;
}

.mail-profile-left {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  min-width: 0;
}

.mail-profile-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: flex-end;
}

.mail-search {
  margin-bottom: 0.75rem;
}

.mail-search-inner {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.mail-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 900;
  display: none;
}

/* Mobile: hide sidebar and toggle with burger */
@media (max-width: 900px) {
  .mail-sidebar {
    display: none;
    position: fixed;
    left: 1rem;
    /* Ниже header, чтобы меню не перекрывало шапку/контент. */
    top: 6rem;
    height: auto;
    z-index: 1000;
    width: 56px;
    padding: 0.35rem;
    transition: width 0.2s ease, padding 0.2s ease;
  }

  body.mail-sidebar-open {
    overflow: hidden;
  }

  /* Header поверх сайдбара, чтобы кнопка-бургер в header не скрывалась. */
  .mail-profilebar {
    position: relative;
    z-index: 1101;
  }

  .mail-nav {
    display: none;
  }

  body.mail-sidebar-open .mail-sidebar {
    display: flex;
    width: 240px;
    height: calc(100vh - 7rem);
    padding: 0.75rem;
  }

  body.mail-sidebar-open .mail-nav {
    display: flex;
  }

  body.mail-sidebar-open .mail-overlay {
    display: block;
  }

  body.mail-sidebar-open .mail-main {
    margin-left: 240px;
  }

  .compose-text {
    display: none;
  }

  .compose-icon {
    margin-right: 0;
  }
}

@media (min-width: 901px) {
  .mail-overlay {
    display: none !important;
  }

  .mail-burger {
    display: none !important;
  }
}

.mail-search input {
  width: 100%;
  font-family: var(--font);
  font-size: 14px;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  outline: none;
  box-sizing: border-box;
}

.mail-search input:focus {
  border-color: var(--accent);
}

.mail-view h2 {
  margin: 0 0 0.75rem;
}

.mail-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.mail-message {
  border: 0;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  padding: 0.6rem 0.25rem;
  background: transparent;
  cursor: pointer;
}

.mail-message:hover {
  background: rgba(255, 255, 255, 0.04);
}

.mail-message .subject {
  font-weight: 700;
  margin-bottom: 0.35rem;
}

.mail-message--unseen .subject {
  font-weight: 900;
}

.mail-message .meta {
  color: var(--text-muted);
  font-size: 12px;
  margin-bottom: 0.5rem;
}

.mail-message .preview {
  color: var(--text);
  opacity: 0.95;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mail-body {
  white-space: pre-wrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 13px;
  line-height: 1.6;
  margin-top: 0.75rem;
  border-top: 1px solid var(--border);
  padding-top: 0.75rem;
}

.mail-compose-textarea,
.mail-raw {
  font-family: inherit;
}

.mail-view textarea {
  width: 100%;
  font-family: var(--font);
  font-size: 14px;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  box-sizing: border-box;
  resize: vertical;
}

.mail-message-body {
  white-space: pre-wrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono",
    "Courier New", monospace;
  font-size: 13px;
  line-height: 1.6;
  margin-top: 0.75rem;
  border-top: 1px solid var(--border);
  padding-top: 0.75rem;
  color: var(--text);
}

.mail-attachments {
  margin-top: 0.75rem;
}

.mail-attachment-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.35rem 0;
}

