:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Microsoft YaHei", sans-serif;
  color: #19233a;
  background: #f6f8fc;
  font-synthesis: none;
  --blue: #246bfd;
  --blue-dark: #1854d8;
  --blue-soft: #edf3ff;
  --navy: #17233d;
  --text: #263247;
  --muted: #718096;
  --line: #e7ebf2;
  --surface: #ffffff;
  --surface-soft: #f8fafd;
  --danger: #dc3d4b;
  --success: #1da574;
  --shadow: 0 12px 32px rgba(31, 45, 78, 0.08);
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: #f6f8fc;
}

button,
input,
select {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

a {
  color: inherit;
  text-decoration: none;
}

.hidden {
  display: none !important;
}

.eyebrow {
  display: block;
  margin-bottom: 7px;
  color: #6680a8;
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

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

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 11px;
  background: var(--blue);
  box-shadow: 0 8px 20px rgba(36, 107, 253, 0.25);
  color: #fff;
  font-size: 18px;
  font-weight: 800;
}

.brand-copy,
.brand > span:last-child {
  display: flex;
  min-width: 0;
  flex-direction: column;
}

.brand b {
  color: var(--navy);
  font-size: 15px;
  line-height: 1.25;
}

.brand small {
  margin-top: 2px;
  color: #8995a9;
  font-size: 10px;
  letter-spacing: 0.08em;
}

.primary-button,
.secondary-button,
.new-mailbox-button,
.copy-button,
.text-button,
.delete-button,
.archive-json,
.archive-back {
  border: 0;
  border-radius: 9px;
  font-weight: 650;
  transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease,
    transform 0.18s ease;
}

.primary-button {
  min-height: 42px;
  padding: 0 20px;
  background: var(--blue);
  color: #fff;
  box-shadow: 0 7px 16px rgba(36, 107, 253, 0.2);
}

.primary-button:hover {
  background: var(--blue-dark);
  transform: translateY(-1px);
}

.secondary-button {
  min-height: 40px;
  padding: 0 17px;
  border: 1px solid #dce3ed;
  background: #fff;
  color: #46556e;
}

.secondary-button:hover {
  border-color: #bdc9d9;
  background: #f9fbfd;
}

.icon-button {
  display: grid;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid #e1e6ee;
  border-radius: 9px;
  background: #fff;
  color: #53627a;
  font-size: 19px;
  line-height: 1;
  transition: border-color 0.18s ease, background 0.18s ease, color 0.18s ease;
}

.icon-button:hover {
  border-color: #cbd5e1;
  background: #f8fafc;
  color: var(--blue);
}

.mobile-only {
  display: none;
}

/* Public mailbox */

.mail-app {
  display: grid;
  min-height: 100vh;
  grid-template-columns: 248px minmax(0, 1fr);
}

.sidebar {
  position: relative;
  z-index: 5;
  display: flex;
  height: 100vh;
  flex-direction: column;
  padding: 28px 18px 20px;
  border-right: 1px solid var(--line);
  background: #fbfcfe;
}

.sidebar > .brand {
  padding: 0 9px;
}

.new-mailbox-button {
  display: flex;
  min-height: 45px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 28px 3px 22px;
  background: var(--blue);
  box-shadow: 0 9px 22px rgba(36, 107, 253, 0.2);
  color: #fff;
}

.new-mailbox-button:hover {
  background: var(--blue-dark);
  transform: translateY(-1px);
}

.new-mailbox-button span {
  font-size: 21px;
  font-weight: 400;
}

.primary-nav,
.admin-nav {
  display: grid;
  gap: 4px;
}

.nav-item {
  display: grid;
  min-height: 42px;
  grid-template-columns: 24px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: #66758d;
  font-size: 13px;
  text-align: left;
}

.nav-item:hover {
  background: #f1f5fb;
  color: var(--navy);
}

.nav-item.active {
  background: var(--blue-soft);
  color: var(--blue);
  font-weight: 700;
}

.nav-icon {
  color: currentColor;
  font-size: 18px;
  text-align: center;
}

.nav-count {
  display: grid;
  min-width: 21px;
  height: 21px;
  place-items: center;
  border-radius: 7px;
  background: var(--blue);
  color: #fff;
  font-size: 10px;
}

.sidebar-mailbox {
  margin: 24px 3px 0;
  padding: 15px;
  border: 1px solid #e3e9f2;
  border-radius: 12px;
  background: #fff;
}

.sidebar-label {
  display: block;
  margin-bottom: 7px;
  color: #96a0b0;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.sidebar-mailbox strong {
  display: block;
  overflow: hidden;
  color: #34425a;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.expiry-track {
  height: 4px;
  margin: 13px 0 8px;
  overflow: hidden;
  border-radius: 4px;
  background: #edf0f5;
}

.expiry-track span {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: var(--blue);
  transition: width 0.4s ease;
}

.sidebar-mailbox small {
  color: #8995a8;
  font-size: 10px;
}

.sidebar-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
  padding: 14px 7px 0;
  border-top: 1px solid var(--line);
  color: #909bad;
  font-size: 10px;
}

.sidebar-footer a:hover {
  color: var(--blue);
}

.mail-workspace {
  min-width: 0;
  height: 100vh;
  overflow: hidden;
  background: #f6f8fc;
}

.mail-topbar {
  display: flex;
  height: 68px;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 0 26px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
}

.topbar-title,
.topbar-actions,
.current-address {
  display: flex;
  align-items: center;
}

.topbar-title {
  min-width: 0;
  gap: 8px;
}

.topbar-title h1 {
  margin: 0 4px 0 0;
  color: var(--navy);
  font-size: 19px;
  letter-spacing: -0.02em;
}

.topbar-title > span:last-child {
  overflow: hidden;
  color: #8994a6;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-dot {
  width: 6px;
  height: 6px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #c0c8d4;
}

.status-dot.online {
  background: var(--success);
  box-shadow: 0 0 0 3px rgba(29, 165, 116, 0.1);
}

.topbar-actions {
  gap: 9px;
}

.current-address {
  height: 36px;
  gap: 8px;
  padding-left: 13px;
  border: 1px solid #e1e6ee;
  border-radius: 9px;
  background: #fff;
}

.current-address > span {
  max-width: 260px;
  overflow: hidden;
  color: #40506a;
  font-size: 12px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.copy-button {
  align-self: stretch;
  padding: 0 12px;
  border-left: 1px solid #e8ebf1;
  border-radius: 0 8px 8px 0;
  background: #f8fafc;
  color: var(--blue);
  font-size: 11px;
}

.copy-button:hover {
  background: var(--blue-soft);
}

.welcome-state {
  display: flex;
  width: min(620px, calc(100% - 48px));
  min-height: calc(100vh - 68px);
  margin: 0 auto;
  align-items: center;
  flex-direction: column;
  justify-content: center;
  padding: 44px 0 70px;
  text-align: center;
}

.welcome-art {
  position: relative;
  display: grid;
  width: 128px;
  height: 112px;
  margin-bottom: 26px;
  place-items: center;
}

.welcome-art::before,
.welcome-art::after {
  position: absolute;
  width: 90px;
  height: 90px;
  border-radius: 30px;
  background: #eaf1ff;
  content: "";
  transform: rotate(12deg);
}

.welcome-art::after {
  width: 70px;
  height: 70px;
  background: #dbe7ff;
  transform: rotate(-9deg);
}

.welcome-envelope {
  position: relative;
  z-index: 2;
  display: grid;
  width: 58px;
  height: 48px;
  place-items: center;
  border-radius: 13px;
  background: var(--blue);
  box-shadow: 0 12px 26px rgba(36, 107, 253, 0.24);
  color: #fff;
  font-size: 24px;
}

.welcome-art i {
  position: absolute;
  z-index: 3;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #73a0ff;
}

.welcome-art i:nth-of-type(1) {
  top: 13px;
  right: 10px;
}

.welcome-art i:nth-of-type(2) {
  bottom: 7px;
  left: 16px;
  width: 5px;
  height: 5px;
}

.welcome-art i:nth-of-type(3) {
  top: 26px;
  left: 3px;
  width: 4px;
  height: 4px;
}

.welcome-state h2 {
  margin: 0;
  color: var(--navy);
  font-size: clamp(27px, 4vw, 38px);
  letter-spacing: -0.04em;
}

.welcome-state > p {
  max-width: 480px;
  margin: 14px 0 25px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.75;
}

.welcome-features {
  display: flex;
  gap: 22px;
  margin-top: 27px;
  color: #8591a5;
  font-size: 11px;
}

.welcome-features span::before {
  margin-right: 6px;
  color: var(--success);
  content: "✓";
  font-weight: 800;
}

.mail-columns {
  display: grid;
  height: calc(100vh - 68px);
  min-height: 0;
  grid-template-columns: minmax(300px, 35%) minmax(0, 1fr);
  gap: 1px;
  background: var(--line);
}

.message-pane,
.reader-pane {
  min-height: 0;
  background: #fff;
}

.message-pane {
  display: flex;
  min-width: 0;
  flex-direction: column;
}

.pane-toolbar {
  min-height: 92px;
  padding: 19px 20px 15px;
  border-bottom: 1px solid var(--line);
}

.pane-toolbar > div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 12px;
}

.pane-toolbar h2 {
  margin: 0;
  color: var(--navy);
  font-size: 15px;
}

.pane-toolbar > div span {
  color: #929cad;
  font-size: 10px;
}

.search-box {
  display: flex;
  height: 34px;
  align-items: center;
  gap: 7px;
  padding: 0 10px;
  border: 1px solid #e4e8ef;
  border-radius: 8px;
  background: #f9fafc;
  color: #8f9aab;
}

.search-box:focus-within {
  border-color: #a9c3ff;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(36, 107, 253, 0.08);
}

.search-box input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 11px;
}

.message-list {
  min-height: 0;
  overflow-y: auto;
}

.message-item {
  position: relative;
  display: grid;
  width: 100%;
  min-height: 105px;
  grid-template-columns: 36px minmax(0, 1fr) auto;
  align-items: start;
  gap: 11px;
  padding: 17px 17px 15px;
  border: 0;
  border-bottom: 1px solid #edf0f5;
  background: #fff;
  color: inherit;
  text-align: left;
  transition: background 0.15s ease;
}

.message-item:hover {
  background: #f9fbff;
}

.message-item.selected {
  background: #f1f5ff;
}

.message-item.selected::before {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 3px;
  background: var(--blue);
  content: "";
}

.message-avatar,
.sender-avatar {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 11px;
  background: #eaf1ff;
  color: #3f74dc;
  font-weight: 750;
}

.message-avatar {
  width: 36px;
  height: 36px;
  font-size: 13px;
}

.message-item-body,
.message-item-top {
  display: flex;
  min-width: 0;
}

.message-item-body {
  flex-direction: column;
}

.message-item-top {
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.message-item-top strong {
  overflow: hidden;
  color: #344159;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.message-item-top time {
  flex: 0 0 auto;
  color: #9aa3b1;
  font-size: 9px;
  font-weight: 500;
}

.message-subject {
  margin-top: 5px;
  overflow: hidden;
  color: #56647b;
  font-size: 11px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.message-preview {
  display: -webkit-box;
  margin-top: 4px;
  overflow: hidden;
  color: #929cad;
  font-size: 10px;
  line-height: 1.45;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.clip {
  margin-top: 42px;
  color: #98a3b3;
  font-size: 12px;
}

.list-empty,
.search-empty {
  display: flex;
  align-items: center;
  flex-direction: column;
  justify-content: center;
  color: #8d98aa;
  text-align: center;
}

.list-empty {
  min-height: 260px;
}

.list-empty > span {
  margin-bottom: 11px;
  color: #b1bbca;
  font-size: 31px;
}

.list-empty b {
  color: #67758d;
  font-size: 13px;
}

.list-empty small {
  margin-top: 5px;
  font-size: 10px;
}

.search-empty {
  padding: 50px 20px;
  font-size: 11px;
}

.reader-pane {
  min-width: 0;
  overflow: hidden;
}

.reader-empty {
  display: flex;
  height: 100%;
  align-items: center;
  flex-direction: column;
  justify-content: center;
  padding: 30px;
  color: #9aa4b5;
  text-align: center;
}

.reader-empty-icon {
  display: grid;
  width: 68px;
  height: 68px;
  margin-bottom: 20px;
  place-items: center;
  border-radius: 22px;
  background: #f0f4fb;
  color: #9ab1d8;
  font-size: 27px;
  transform: rotate(-5deg);
}

.reader-empty h2 {
  margin: 0;
  color: #627087;
  font-size: 15px;
}

.reader-empty p {
  margin: 7px 0 0;
  font-size: 11px;
}

.reader-content {
  display: flex;
  height: 100%;
  flex-direction: column;
}

.reader-content.loading {
  opacity: 0.58;
  pointer-events: none;
}

.reader-header {
  flex: 0 0 auto;
  padding: 24px 28px 0;
  border-bottom: 1px solid var(--line);
}

.reader-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.reader-title-row h2 {
  margin: 0;
  overflow: hidden;
  color: var(--navy);
  font-size: clamp(19px, 2.2vw, 25px);
  letter-spacing: -0.025em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attachment-badge,
.archive-pill {
  flex: 0 0 auto;
  padding: 4px 8px;
  border-radius: 6px;
  background: #f1f4f8;
  color: #708099;
  font-size: 9px;
  font-weight: 700;
}

.sender-row {
  display: flex;
  align-items: center;
  margin-top: 19px;
}

.sender-avatar {
  width: 37px;
  height: 37px;
  margin-right: 11px;
  font-size: 13px;
}

.sender-details {
  display: flex;
  min-width: 0;
  flex: 1;
  flex-direction: column;
}

.sender-details strong {
  overflow: hidden;
  color: #38465e;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sender-details span {
  margin-top: 3px;
  overflow: hidden;
  color: #929cad;
  font-size: 9px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sender-row > time {
  margin-left: 12px;
  color: #929cad;
  font-size: 9px;
  white-space: nowrap;
}

.reader-tabs {
  display: flex;
  gap: 22px;
  margin-top: 18px;
}

.reader-tab {
  position: relative;
  height: 38px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #909aab;
  font-size: 10px;
  font-weight: 650;
}

.reader-tab.active {
  color: var(--blue);
}

.reader-tab.active::after {
  position: absolute;
  right: 0;
  bottom: -1px;
  left: 0;
  height: 2px;
  border-radius: 2px;
  background: var(--blue);
  content: "";
}

.reader-body {
  min-height: 0;
  flex: 1;
  overflow: hidden;
  background: #fff;
}

.reader-body iframe {
  width: 100%;
  height: 100%;
  border: 0;
  background: #fff;
}

.reader-body pre {
  height: 100%;
  margin: 0;
  overflow: auto;
  padding: 28px;
  background: #fff;
  color: #3d4b62;
  font: 12px/1.75 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre-wrap;
}

.spinning {
  animation: spin 0.8s linear infinite;
}

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

/* Dialog */

.create-dialog {
  width: min(470px, calc(100vw - 32px));
  padding: 0;
  overflow: visible;
  border: 0;
  border-radius: 16px;
  box-shadow: 0 26px 80px rgba(20, 31, 55, 0.24);
}

.create-dialog::backdrop {
  background: rgba(22, 31, 50, 0.48);
  backdrop-filter: blur(3px);
}

.dialog-card {
  padding: 26px;
}

.dialog-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 25px;
}

.dialog-heading h2 {
  margin: 0;
  color: var(--navy);
  font-size: 22px;
}

.dialog-heading p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.field-label {
  display: block;
  margin: 17px 0 7px;
  color: #4d5a70;
  font-size: 11px;
  font-weight: 700;
}

.address-input,
.token-input,
.select-wrap {
  display: flex;
  height: 44px;
  align-items: center;
  border: 1px solid #dce3ed;
  border-radius: 9px;
  background: #fff;
}

.address-input:focus-within,
.token-input:focus-within,
.select-wrap:focus-within {
  border-color: #9ab8fb;
  box-shadow: 0 0 0 3px rgba(36, 107, 253, 0.08);
}

.address-input input,
.token-input input,
.select-wrap select {
  width: 100%;
  min-width: 0;
  height: 100%;
  padding: 0 12px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 13px;
}

.address-input > span {
  align-self: stretch;
  display: flex;
  align-items: center;
  padding: 0 12px;
  border-left: 1px solid #e5e9ef;
  background: #f8fafc;
  color: #718096;
  font-size: 12px;
  white-space: nowrap;
}

.select-wrap select {
  cursor: pointer;
}

.form-error {
  margin-top: 12px;
  padding: 9px 11px;
  border: 1px solid #f6d4d8;
  border-radius: 8px;
  background: #fff5f6;
  color: #bf3442;
  font-size: 11px;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  margin-top: 27px;
}

.toast {
  position: fixed;
  z-index: 100;
  right: 22px;
  bottom: 22px;
  max-width: min(360px, calc(100vw - 44px));
  padding: 11px 15px;
  border-radius: 9px;
  background: #1d293d;
  box-shadow: 0 14px 36px rgba(20, 30, 50, 0.22);
  color: #fff;
  font-size: 12px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

/* Admin */

.admin-app {
  display: grid;
  min-height: 100vh;
  grid-template-columns: 230px minmax(0, 1fr);
}

.admin-sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  display: flex;
  width: 230px;
  flex-direction: column;
  padding: 28px 18px 22px;
  border-right: 1px solid var(--line);
  background: #fbfcfe;
}

.admin-sidebar > .brand {
  padding: 0 9px 27px;
}

.admin-nav {
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.admin-sidebar-footer {
  display: grid;
  gap: 15px;
  margin-top: auto;
  padding: 18px 10px 0;
  border-top: 1px solid var(--line);
  color: #7d899d;
  font-size: 10px;
}

.server-state {
  display: flex;
  align-items: center;
  gap: 7px;
}

.server-state i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 3px rgba(29, 165, 116, 0.1);
}

.admin-sidebar-footer a:hover {
  color: var(--blue);
}

.admin-workspace {
  grid-column: 2;
  min-width: 0;
  padding: 0 34px 48px;
}

.admin-topbar {
  display: flex;
  min-height: 92px;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid var(--line);
}

.admin-topbar h1 {
  margin: 0;
  color: var(--navy);
  font-size: 23px;
  letter-spacing: -0.03em;
}

.admin-account {
  display: flex;
  align-items: center;
  gap: 10px;
}

.admin-avatar {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 10px;
  background: #eaf1ff;
  color: var(--blue);
  font-size: 12px;
  font-weight: 750;
}

.admin-account > span:nth-child(2) {
  display: flex;
  flex-direction: column;
}

.admin-account b {
  color: #425069;
  font-size: 11px;
}

.admin-account small {
  margin-top: 2px;
  color: #929cad;
  font-size: 9px;
}

.text-button {
  padding: 7px 10px;
  background: transparent;
  color: var(--blue);
  font-size: 10px;
}

.text-button:hover {
  background: var(--blue-soft);
}

.admin-login {
  display: grid;
  width: min(760px, 100%);
  min-height: 370px;
  grid-template-columns: 0.8fr 1.2fr;
  margin: 76px auto 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
  box-shadow: var(--shadow);
}

.login-visual {
  display: grid;
  place-items: center;
  background: #edf3ff;
}

.login-visual span {
  display: grid;
  width: 96px;
  height: 96px;
  place-items: center;
  border: 1px solid #bed0fa;
  border-radius: 30px;
  background: #fff;
  box-shadow: 0 18px 42px rgba(36, 107, 253, 0.14);
  color: var(--blue);
  font-size: 44px;
}

.login-copy {
  align-self: center;
  padding: 42px;
}

.login-copy h2 {
  margin: 0;
  color: var(--navy);
  font-size: 24px;
  letter-spacing: -0.03em;
}

.login-copy > p {
  margin: 10px 0 21px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.7;
}

.token-input .text-button {
  margin-right: 4px;
}

.login-button {
  width: 100%;
  margin-top: 17px;
}

.admin-dashboard {
  padding-top: 26px;
}

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

.stat-card {
  display: flex;
  min-width: 0;
  min-height: 126px;
  align-items: flex-start;
  gap: 13px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #fff;
  box-shadow: 0 6px 18px rgba(31, 45, 78, 0.035);
}

.stat-icon {
  display: grid;
  width: 37px;
  height: 37px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 10px;
  font-size: 16px;
}

.stat-blue .stat-icon {
  background: #eaf1ff;
  color: #3370e6;
}

.stat-violet .stat-icon {
  background: #f0ebff;
  color: #7653d6;
}

.stat-cyan .stat-icon {
  background: #e8f8fa;
  color: #208b9a;
}

.stat-amber .stat-icon {
  background: #fff4df;
  color: #b67919;
}

.stat-card > div {
  display: flex;
  min-width: 0;
  flex-direction: column;
}

.stat-card small {
  color: #7f8b9f;
  font-size: 10px;
  font-weight: 650;
}

.stat-card strong {
  margin: 7px 0 5px;
  color: var(--navy);
  font-size: 25px;
  letter-spacing: -0.04em;
}

.stat-card div span {
  overflow: hidden;
  color: #a0a9b7;
  font-size: 9px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-section {
  margin-top: 20px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 6px 18px rgba(31, 45, 78, 0.03);
}

.section-heading {
  display: flex;
  min-height: 74px;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 0 22px;
  border-bottom: 1px solid var(--line);
}

.section-heading h2 {
  margin: 0;
  color: var(--navy);
  font-size: 15px;
}

.section-note {
  color: #8d98a9;
  font-size: 10px;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  padding: 20px 22px;
}

.setting-card {
  display: grid;
  min-width: 0;
  min-height: 76px;
  grid-template-columns: 35px minmax(0, 1fr) auto;
  align-items: center;
  gap: 11px;
  margin: 0;
  padding: 13px;
  border: 1px solid #e7ebf1;
  border-radius: 10px;
  background: #fafbfd;
}

.setting-icon {
  display: grid;
  width: 35px;
  height: 35px;
  place-items: center;
  border-radius: 9px;
  background: #edf3ff;
  color: var(--blue);
}

.setting-card > span:nth-child(2) {
  display: flex;
  min-width: 0;
  flex-direction: column;
}

.setting-card b {
  color: #435169;
  font-size: 11px;
}

.setting-card small {
  margin-top: 4px;
  color: #929cad;
  font-size: 9px;
  line-height: 1.4;
}

.number-input {
  display: flex;
  height: 35px;
  align-items: center;
  border: 1px solid #dce2ec;
  border-radius: 8px;
  background: #fff;
}

.number-input input {
  width: 58px;
  height: 100%;
  padding: 0 7px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  text-align: right;
}

.number-input i {
  padding-right: 9px;
  color: #929cad;
  font-size: 9px;
  font-style: normal;
}

.settings-actions {
  display: flex;
  min-height: 62px;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 0 22px;
  border-top: 1px solid var(--line);
}

.settings-actions > span {
  color: #929cad;
  font-size: 9px;
}

.mailbox-heading {
  justify-content: flex-start;
}

.mailbox-heading > div:first-child {
  margin-right: auto;
}

.admin-search {
  width: min(250px, 32vw);
}

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

.admin-table {
  display: grid;
  min-width: 880px;
  grid-template-columns: minmax(230px, 1.8fr) 80px 65px 120px 120px 60px;
  align-items: center;
  gap: 15px;
  padding: 0 22px;
}

.admin-table-head {
  height: 41px;
  border-bottom: 1px solid var(--line);
  background: #fafbfd;
  color: #8a96a8;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.admin-table-row {
  min-height: 65px;
  border-bottom: 1px solid #eef1f5;
  color: #66748b;
  font-size: 10px;
}

.admin-table-row:last-child {
  border-bottom: 0;
}

.admin-table-row:hover {
  background: #fbfcff;
}

.table-address {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
}

.table-address > span:first-child {
  display: grid;
  width: 31px;
  height: 31px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 9px;
  background: #edf3ff;
  color: #3e73dd;
  font-weight: 750;
}

.table-address > span:last-child {
  display: flex;
  min-width: 0;
  flex-direction: column;
}

.table-address strong {
  overflow: hidden;
  color: #3d4c64;
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.table-address small {
  margin-top: 3px;
  color: #9ba5b4;
  font-size: 8px;
}

.status-badge {
  display: inline-flex;
  width: max-content;
  align-items: center;
  gap: 5px;
  padding: 4px 7px;
  border-radius: 6px;
  font-size: 9px;
  font-weight: 700;
}

.status-badge::before {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  content: "";
}

.status-badge.active {
  background: #eaf8f2;
  color: #18865f;
}

.status-badge.expired {
  background: #fff3e3;
  color: #ae721b;
}

.status-badge.disabled {
  background: #f3f4f6;
  color: #7d8796;
}

.table-count {
  color: #45536a;
}

.delete-button {
  padding: 6px 8px;
  background: transparent;
  color: #b84a55;
  font-size: 9px;
}

.delete-button:hover {
  background: #fff0f2;
  color: var(--danger);
}

.admin-empty {
  min-width: 880px;
  padding: 44px 20px;
  color: #929cad;
  font-size: 11px;
  text-align: center;
}

.table-footer {
  display: flex;
  min-height: 50px;
  align-items: center;
  justify-content: space-between;
  padding: 0 22px;
  border-top: 1px solid var(--line);
  color: #718096;
  font-size: 10px;
}

.table-footer small {
  color: #9aa4b3;
  font-size: 9px;
}

/* Server-rendered mailbox archive */

.archive-page {
  min-height: 100vh;
  background: #f4f7fb;
}

.archive-shell {
  width: min(980px, calc(100% - 34px));
  margin: 0 auto;
  padding: 26px 0 50px;
}

.archive-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
}

.archive-back,
.archive-json {
  display: inline-flex;
  min-height: 36px;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  border: 1px solid #dce3ed;
  background: #fff;
  color: #53627a;
  font-size: 11px;
}

.archive-back:hover,
.archive-json:hover {
  border-color: #bfcbdc;
  color: var(--blue);
}

.archive-hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 26px 28px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 8px 26px rgba(31, 45, 78, 0.05);
}

.archive-hero h1 {
  margin: 0;
  color: var(--navy);
  font-size: clamp(20px, 4vw, 30px);
  letter-spacing: -0.035em;
  overflow-wrap: anywhere;
}

.archive-hero p {
  margin: 9px 0 0;
  color: #7c889c;
  font-size: 11px;
  line-height: 1.6;
}

.archive-list {
  display: grid;
  gap: 10px;
}

.archive-message {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 5px 16px rgba(31, 45, 78, 0.025);
}

.archive-message details > summary {
  display: grid;
  min-height: 72px;
  grid-template-columns: 38px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 12px;
  padding: 12px 17px;
  cursor: pointer;
  list-style: none;
}

.archive-message details > summary::-webkit-details-marker {
  display: none;
}

.archive-message details[open] > summary {
  border-bottom: 1px solid var(--line);
  background: #fbfcff;
}

.archive-avatar {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 11px;
  background: #eaf1ff;
  color: #3f74dc;
  font-size: 13px;
  font-weight: 750;
}

.archive-summary-main {
  display: flex;
  min-width: 0;
  flex-direction: column;
}

.archive-summary-main strong,
.archive-summary-main span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.archive-summary-main strong {
  color: #344159;
  font-size: 12px;
}

.archive-summary-main span {
  margin-top: 4px;
  color: #8a96a8;
  font-size: 9px;
}

.archive-message time {
  color: #8d98aa;
  font-size: 9px;
  white-space: nowrap;
}

.archive-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 28px;
  padding: 13px 20px;
  border-bottom: 1px solid var(--line);
  color: #718096;
  font-size: 10px;
}

.archive-meta span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.archive-meta b {
  margin-right: 7px;
  color: #49566d;
}

.archive-message iframe {
  display: block;
  width: 100%;
  min-height: 460px;
  border: 0;
  background: #fff;
}

.archive-empty {
  padding: 70px 25px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  color: #8e99aa;
  text-align: center;
}

.archive-empty > span {
  font-size: 35px;
}

.archive-empty h2 {
  margin: 13px 0 5px;
  color: #526078;
  font-size: 15px;
}

.archive-empty p {
  margin: 0;
  font-size: 10px;
}

@media (max-width: 980px) {
  .mail-app {
    grid-template-columns: 210px minmax(0, 1fr);
  }

  .sidebar {
    padding-right: 14px;
    padding-left: 14px;
  }

  .mail-columns {
    grid-template-columns: minmax(270px, 39%) minmax(0, 1fr);
  }

  .admin-app {
    grid-template-columns: 190px minmax(0, 1fr);
  }

  .admin-sidebar {
    width: 190px;
    padding-right: 12px;
    padding-left: 12px;
  }

  .admin-workspace {
    padding-right: 22px;
    padding-left: 22px;
  }

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

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

@media (max-width: 720px) {
  .mobile-only {
    display: grid;
  }

  .mail-app {
    display: block;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(280px, 86vw);
    box-shadow: 18px 0 50px rgba(22, 31, 50, 0.18);
    transform: translateX(-105%);
    transition: transform 0.22s ease;
  }

  .sidebar-open .sidebar {
    transform: translateX(0);
  }

  .sidebar-open::after {
    position: fixed;
    z-index: 4;
    inset: 0;
    background: rgba(26, 34, 51, 0.35);
    content: "";
  }

  .mail-topbar {
    height: 62px;
    padding: 0 13px;
  }

  .topbar-title h1 {
    font-size: 16px;
  }

  .topbar-title > span:last-child,
  .current-address {
    display: none !important;
  }

  .welcome-state {
    min-height: calc(100vh - 62px);
  }

  .mail-columns {
    display: block;
    height: calc(100vh - 62px);
  }

  .message-pane,
  .reader-pane {
    height: 100%;
  }

  .reader-pane {
    display: none;
  }

  .mail-columns.reader-open .message-pane {
    display: none;
  }

  .mail-columns.reader-open .reader-pane {
    display: block;
  }

  .reader-header {
    padding: 14px 17px 0;
  }

  .reader-header > .icon-button {
    margin-bottom: 14px;
  }

  .reader-title-row h2 {
    font-size: 19px;
  }

  .sender-row > time {
    display: none;
  }

  .reader-body pre {
    padding: 20px;
  }

  .admin-app {
    display: block;
  }

  .admin-sidebar {
    position: static;
    width: auto;
    height: auto;
    padding: 17px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .admin-sidebar > .brand {
    padding: 0;
  }

  .admin-nav,
  .admin-sidebar-footer {
    display: none;
  }

  .admin-workspace {
    padding: 0 15px 36px;
  }

  .admin-topbar {
    min-height: 74px;
  }

  .admin-topbar h1 {
    font-size: 19px;
  }

  .admin-account > span:nth-child(2) {
    display: none;
  }

  .admin-login {
    min-height: 0;
    grid-template-columns: 1fr;
    margin-top: 28px;
  }

  .login-visual {
    display: none;
  }

  .login-copy {
    padding: 28px 22px;
  }

  .stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .stat-card {
    min-height: 112px;
    padding: 15px;
  }

  .stat-card > .stat-icon {
    display: none;
  }

  .section-heading {
    padding: 0 16px;
  }

  .section-note {
    display: none;
  }

  .settings-grid {
    padding: 16px;
  }

  .setting-card {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .setting-icon {
    display: none;
  }

  .settings-actions {
    align-items: flex-end;
    flex-direction: column;
    padding: 14px 16px;
  }

  .mailbox-heading {
    min-height: 120px;
    flex-wrap: wrap;
    padding-top: 16px;
    padding-bottom: 16px;
  }

  .mailbox-heading > div:first-child {
    width: calc(100% - 48px);
  }

  .admin-search {
    width: calc(100% - 48px);
    order: 3;
  }

  .table-footer {
    padding: 0 16px;
  }

  .archive-shell {
    width: min(100% - 22px, 980px);
    padding-top: 15px;
  }

  .archive-header {
    margin-bottom: 15px;
  }

  .archive-hero {
    align-items: flex-start;
    flex-direction: column;
    padding: 20px;
  }

  .archive-message details > summary {
    grid-template-columns: 36px minmax(0, 1fr) auto;
  }

  .archive-message summary .archive-pill {
    display: none;
  }

  .archive-message time {
    grid-column: 2;
  }

  .archive-message iframe {
    min-height: 400px;
  }
}

@media (max-width: 420px) {
  .welcome-features {
    gap: 12px;
  }

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

  .stat-card {
    min-height: 90px;
  }

  .stat-card > .stat-icon {
    display: grid;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
