:root {
  --bg: #f4f5f1;
  --panel: #ffffff;
  --glass: rgba(255, 255, 255, 0.66);
  --glass-strong: rgba(255, 255, 255, 0.82);
  --panel-soft: #fafbf8;
  --ink: #151922;
  --muted: #647084;
  --line: #d7ddd4;
  --line-strong: #c6cec3;
  --accent: #0f766e;
  --accent-dark: #115e59;
  --logo-bg: #14201d;
  --blue: #1d4ed8;
  --blue-soft: #eff6ff;
  --warn: #b45309;
  --warn-soft: #fff7ed;
  --error: #b42318;
  --error-soft: #fff1f0;
  --ok: #15803d;
  --ok-soft: #ecfdf3;
  --shadow: 0 18px 45px rgba(19, 28, 22, 0.08);
  --shadow-soft: 0 8px 22px rgba(19, 28, 22, 0.06);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, #f9faf7 0, var(--bg) 290px),
    var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

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

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

button,
.button-link {
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0 16px;
  cursor: pointer;
  font-weight: 800;
}

button {
  background: var(--accent);
  color: white;
}

button:hover {
  background: var(--accent-dark);
}

.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--panel);
  border-color: var(--line);
  color: var(--ink);
}

.button-link:hover {
  background: #eef3ef;
}

button.ghost {
  border-color: var(--line);
  background: var(--panel);
  color: var(--ink);
}

button.ghost:hover {
  background: #eef3ef;
}

button.danger {
  border-color: #f2beb8;
  color: var(--error);
}

button.danger:hover {
  background: var(--error-soft);
}

.compact-button {
  min-height: 34px;
  padding: 0 12px;
  font-size: 13px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 20px;
  min-height: 66px;
  padding: 0 30px;
  border-bottom: 1px solid rgba(199, 207, 197, 0.82);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0.62)),
    rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(22px) saturate(1.22);
  box-shadow:
    0 18px 44px rgba(19, 28, 22, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.92);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  font-weight: 900;
  white-space: nowrap;
}

.brand-logo {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 5px;
  flex: 0 0 auto;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 10px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0) 42%),
    var(--logo-bg);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.24),
    inset 0 -9px 0 rgba(15, 118, 110, 0.48),
    inset 0 0 18px rgba(255, 255, 255, 0.04),
    0 12px 22px rgba(15, 23, 42, 0.18);
  filter: drop-shadow(0 5px 10px rgba(15, 23, 42, 0.08));
}

.brand-logo svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: #f8fafc;
  stroke-width: 1.85;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.28));
}

.topbar nav {
  display: flex;
  gap: 6px;
  margin-right: auto;
}

.topbar nav a {
  border-radius: 8px;
  padding: 9px 12px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 750;
}

.topbar nav a:hover {
  background: #eef3ef;
  color: var(--ink);
}

.topbar form {
  margin: 0;
}

.shell {
  width: min(1180px, calc(100% - 34px));
  margin: 30px auto 64px;
}

.auth-panel {
  min-height: calc(100vh - 128px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  align-items: center;
  gap: 52px;
}

.auth-panel h1 {
  font-size: 42px;
}

.auth-copy {
  max-width: 620px;
}

.auth-copy h1 {
  max-width: 12ch;
}

.welcome-panel {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  overflow: hidden;
  margin-bottom: 22px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  border-color: rgba(255, 255, 255, 0.72);
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.92), rgba(247, 250, 247, 0.58)),
    var(--glass);
  box-shadow:
    0 26px 55px rgba(19, 28, 22, 0.11),
    inset 0 1px 0 rgba(255, 255, 255, 0.92),
    inset 0 -1px 0 rgba(255, 255, 255, 0.42);
  backdrop-filter: blur(24px) saturate(1.18);
}

.welcome-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(110deg, transparent 0%, rgba(255, 255, 255, 0.34) 40%, rgba(255, 255, 255, 0.1) 50%, transparent 68%),
    linear-gradient(90deg, transparent 0%, rgba(15, 118, 110, 0.08) 42%, rgba(29, 78, 216, 0.06) 52%, transparent 70%);
  transform: translateX(-70%);
  animation: welcomeSweep 8s ease-in-out infinite;
}

.welcome-panel > * {
  position: relative;
  z-index: 1;
}

.welcome-panel h1 {
  font-size: 34px;
}

.welcome-panel .muted {
  margin: 10px 0 0;
}

.welcome-ready {
  overflow: hidden;
  max-height: 24px;
  opacity: 1;
  transition:
    opacity 420ms ease,
    max-height 420ms ease,
    margin-top 420ms ease;
}

.welcome-ready.is-hidden {
  max-height: 0;
  margin-top: 0;
  opacity: 0;
}

.welcome-mark {
  position: relative;
  overflow: hidden;
  display: grid;
  width: 74px;
  height: 74px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 10px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.18), transparent 42%),
    var(--logo-bg);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.24),
    inset 0 -10px 0 rgba(15, 118, 110, 0.48),
    inset 0 0 22px rgba(255, 255, 255, 0.05),
    0 20px 34px rgba(15, 23, 42, 0.18);
}

.welcome-mark::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, transparent 10%, rgba(255, 255, 255, 0.34) 42%, transparent 58%);
  transform: translateX(-72%);
  animation: glassShine 7s ease-in-out infinite;
}

.welcome-mark svg {
  position: relative;
  z-index: 1;
  width: 42px;
  height: 42px;
  fill: none;
  stroke: #f8fafc;
  stroke-width: 1.65;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.28));
}

@keyframes welcomeSweep {
  0%,
  46% {
    transform: translateX(-75%);
  }

  76%,
  100% {
    transform: translateX(75%);
  }
}

@keyframes glassShine {
  0%,
  42% {
    transform: translateX(-72%);
  }

  70%,
  100% {
    transform: translateX(72%);
  }
}

.page-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
}

.page-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

h1,
h2 {
  margin: 0;
  line-height: 1.12;
}

h1 {
  font-size: 32px;
  letter-spacing: 0;
}

h2 {
  font-size: 17px;
  margin-bottom: 16px;
}

p {
  line-height: 1.55;
}

.eyebrow {
  margin: 0 0 9px;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

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

.hint {
  margin-bottom: 0;
  font-size: 13px;
}

.card,
.metric {
  position: relative;
  border: 1px solid rgba(215, 221, 212, 0.78);
  border-radius: 8px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.88), rgba(255, 255, 255, 0.54)),
    var(--glass);
  box-shadow:
    0 18px 42px rgba(19, 28, 22, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.88),
    inset 0 -1px 0 rgba(255, 255, 255, 0.36);
  backdrop-filter: blur(20px) saturate(1.14);
}

.card::before,
.metric::before {
  content: "";
  position: absolute;
  inset: 1px 1px auto 1px;
  height: 42%;
  border-radius: 7px 7px 0 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.34), rgba(255, 255, 255, 0));
  pointer-events: none;
}

.card > *,
.metric > * {
  position: relative;
  z-index: 1;
}

.card {
  padding: 22px;
}

.grid.two {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 18px;
  margin-bottom: 18px;
}

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

.metric {
  padding: 18px;
  border-top: 4px solid var(--line-strong);
}

.metric:nth-child(1) {
  border-top-color: var(--accent);
}

.metric:nth-child(2) {
  border-top-color: var(--blue);
}

.metric:nth-child(3) {
  border-top-color: var(--ok);
}

.metric:nth-child(4) {
  border-top-color: var(--warn);
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
  margin-bottom: 8px;
}

.metric strong {
  display: block;
  font-size: 28px;
}

.metric.warn strong {
  color: var(--warn);
}

.form {
  display: grid;
  gap: 14px;
}

.form label {
  display: grid;
  gap: 7px;
  color: #596579;
  font-size: 14px;
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  transition: border-color 120ms ease, box-shadow 120ms ease, background 120ms ease;
}

input,
select {
  min-height: 42px;
  padding: 0 12px;
}

textarea {
  min-height: 92px;
  padding: 10px 12px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  outline: 0;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
}

input[readonly] {
  background: var(--panel-soft);
}

.narrow {
  max-width: 460px;
}

.notice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 18px;
  background: #e8f5f2;
  color: var(--accent-dark);
  border: 1px solid #b8ddd6;
  font-weight: 800;
}

.notice.error {
  background: var(--error-soft);
  color: var(--error);
  border-color: #f4b8b2;
}

.notice.success {
  background: var(--ok-soft);
  color: var(--ok);
  border-color: #bce4c5;
}

.notice-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.notice-actions a {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 10px;
  border: 1px solid currentColor;
  border-radius: 8px;
  color: inherit;
  background: rgba(255, 255, 255, 0.55);
  font-size: 13px;
}

.security-list {
  margin: 8px 0 0;
  padding-left: 20px;
}

.table {
  display: grid;
  gap: 10px;
}

.row,
.history-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto auto auto auto minmax(240px, 320px);
  align-items: center;
  gap: 12px;
  padding: 12px;
}

.subscription-row {
  grid-template-columns: minmax(260px, 1fr) auto auto auto;
}

.row span,
.history-row span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-top: 4px;
}

.inline-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.access-edit {
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.access-edit-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
}

.access-edit-head span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-top: 4px;
}

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

.access-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.history-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto auto;
  align-items: center;
  gap: 12px;
  padding: 12px;
}

.history-main {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.history-main strong {
  overflow-wrap: anywhere;
}

.pill {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.pill.ok {
  background: #dcfce7;
  color: #166534;
}

.muted-pill {
  background: #eceff3;
  color: #475467;
}

.warn-pill {
  background: var(--warn-soft);
  color: var(--warn);
}

.status-list,
.meta {
  display: grid;
  grid-template-columns: 118px minmax(0, 1fr);
  gap: 9px 16px;
  margin: 0;
}

.status-list dt,
.meta dt {
  color: var(--muted);
  font-weight: 900;
}

.status-list dd,
.meta dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.live-refresh {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  border-color: rgba(184, 221, 214, 0.74);
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.82), rgba(232, 245, 242, 0.7)),
    rgba(232, 245, 242, 0.84);
  color: var(--accent-dark);
  box-shadow:
    0 14px 28px rgba(15, 118, 110, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(12px) saturate(1.15);
}

.live-refresh:hover {
  background: #dff0ec;
}

.live-refresh.is-refreshing {
  opacity: 0.72;
}

.fetch-icon {
  position: relative;
  isolation: isolate;
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  flex: 0 0 auto;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.16), transparent 44%),
    #111b24;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.18),
    inset 0 -7px 0 rgba(15, 118, 110, 0.36),
    0 10px 18px rgba(15, 23, 42, 0.18);
}

.fetch-icon::before {
  content: "";
  position: absolute;
  inset: -8px;
  z-index: 0;
  border-radius: 50%;
  background:
    conic-gradient(from 0deg, transparent 0deg, transparent 250deg, rgba(255, 255, 255, 0.7) 284deg, transparent 318deg, transparent 360deg);
  animation: iconOrbit 1.45s linear infinite;
}

.fetch-icon::after {
  content: "";
  position: absolute;
  inset: 4px 5px;
  z-index: 1;
  border-radius: 7px;
  background:
    radial-gradient(circle at 32% 24%, rgba(255, 255, 255, 0.32), transparent 33%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.12), transparent 58%);
  pointer-events: none;
}

.fetch-icon svg {
  position: relative;
  z-index: 2;
  width: 21px;
  height: 21px;
  fill: none;
  stroke: #f8fafc;
  stroke-width: 2.25;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.25));
  animation: infinityGlow 2.2s ease-in-out infinite;
}

.refresh-count {
  min-width: 38px;
  border-radius: 999px;
  padding: 3px 8px;
  background: rgba(255, 255, 255, 0.75);
  font-size: 12px;
}

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

@keyframes infinityGlow {
  0%, 100% {
    filter:
      drop-shadow(0 2px 4px rgba(0, 0, 0, 0.25))
      drop-shadow(0 0 0 rgba(94, 234, 212, 0));
  }

  50% {
    filter:
      drop-shadow(0 2px 4px rgba(0, 0, 0, 0.25))
      drop-shadow(0 0 5px rgba(94, 234, 212, 0.45));
  }
}

.message-list {
  padding: 0;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.filter-form {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto;
  align-items: end;
  gap: 12px;
  margin-bottom: 18px;
}

.filter-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-weight: 800;
}

.access-summary {
  display: grid;
  gap: 14px;
  margin-bottom: 18px;
  border-left: 4px solid var(--blue);
}

.access-summary > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.access-summary strong {
  font-size: 17px;
}

.mailbox-list {
  display: grid;
  gap: 12px;
}

.mailbox-item {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.copy-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.copy-row input {
  font-weight: 800;
}

.copy-button {
  min-width: 84px;
}

.message-row {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr) 210px;
  gap: 16px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  align-items: center;
  background: var(--panel);
}

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

.message-row:hover {
  background: #f7faf7;
}

.customer-message-row {
  grid-template-columns: minmax(0, 1fr) auto;
}

.message-main {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr) 210px;
  gap: 16px;
  align-items: center;
  min-width: 0;
}

.message-delete-form {
  margin: 0;
}

.admin-message-delete-form {
  justify-self: end;
}

.admin-mail-row {
  grid-template-columns: minmax(0, 1fr) auto;
}

.admin-message-main,
.quarantine-message-main {
  display: grid;
  gap: 16px;
  align-items: center;
  min-width: 0;
}

.admin-message-main {
  grid-template-columns: 220px minmax(0, 1fr) auto 180px 180px;
}

.quarantine-message-main {
  grid-template-columns: 220px minmax(0, 1fr) minmax(180px, 0.7fr);
}

.sender {
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.message-subtitle {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.message-detail {
  max-width: 940px;
}

.message-detail-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.message-detail h1 {
  font-size: 27px;
  margin: 14px 0 20px;
  overflow-wrap: anywhere;
}

.message-detail h2 {
  margin-top: 24px;
}

.back {
  color: var(--accent-dark);
  font-weight: 900;
}

.evidence {
  margin: 0;
  padding-left: 20px;
  color: var(--muted);
}

.mail-body {
  overflow-wrap: anywhere;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background: var(--panel-soft);
  color: #222832;
}

.rendered-mail {
  line-height: 1.6;
}

.rendered-mail a {
  color: var(--blue);
  text-decoration: underline;
  font-weight: 800;
}

.rendered-mail p:first-child,
.rendered-mail h1:first-child,
.rendered-mail h2:first-child,
.rendered-mail h3:first-child {
  margin-top: 0;
}

.rendered-mail p:last-child {
  margin-bottom: 0;
}

.rendered-mail table {
  max-width: 100%;
  border-collapse: collapse;
}

.rendered-mail td,
.rendered-mail th {
  border: 1px solid var(--line);
  padding: 8px;
  vertical-align: top;
}

code {
  border-radius: 6px;
  padding: 2px 6px;
  background: #eef3ef;
}

.admin-frame {
  display: grid;
  grid-template-columns: 218px minmax(0, 1fr);
  gap: 24px;
  width: min(1480px, calc(100% - 34px));
  margin: 24px auto 64px;
}

.admin-sidebar {
  position: sticky;
  top: 90px;
  align-self: start;
  display: grid;
  gap: 5px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.8);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(18px);
}

.sidebar-label {
  margin: 4px 10px 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.admin-sidebar a {
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

.admin-sidebar a:hover,
.admin-sidebar a.active {
  background: #e8f5f2;
  color: var(--accent-dark);
}

.admin-shell {
  width: 100%;
  min-width: 0;
  margin: 6px 0 0;
}

.dashboard-metrics a {
  display: block;
}

.quick-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.quick-action {
  display: grid;
  gap: 5px;
  padding: 17px 18px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--panel);
  box-shadow: var(--shadow-soft);
}

.quick-action:hover {
  border-color: #9bc9c2;
  background: #f5fbf9;
}

.quick-action span,
.health-row span,
.issue-row span,
.compact-mail-row span,
.customer-card span,
.route-main span,
.route-main small,
.address-card span,
.service-line span {
  color: var(--muted);
  font-size: 13px;
}

.section-head,
.mailbox-card-head,
.customer-card-head,
.route-group-head,
.address-card-head,
.customer-hero,
.inbox-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.section-head {
  margin-bottom: 16px;
}

.section-head h2,
.mailbox-card-head h2 {
  margin-bottom: 0;
}

.text-link {
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 900;
}

.health-list,
.issue-list,
.compact-mail-list,
.route-list,
.service-stack {
  display: grid;
}

.health-row,
.issue-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
}

.health-row:last-child,
.issue-row:last-child {
  border-bottom: 0;
}

.health-row > div,
.issue-row > div,
.compact-mail-row > div {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.status-dot {
  width: 9px;
  height: 9px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--ok);
}

.error-dot {
  background: var(--error);
}

.live-dot {
  box-shadow: 0 0 0 4px rgba(21, 128, 61, 0.12);
}

.issue-row {
  justify-content: flex-start;
}

.empty-good,
.empty-inbox {
  display: grid;
  gap: 5px;
  padding: 20px;
  border: 1px dashed #a8d4b3;
  border-radius: 8px;
  background: var(--ok-soft);
}

.empty-good span,
.empty-inbox span {
  color: var(--muted);
}

.compact-mail-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto 185px;
  align-items: center;
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.compact-mail-row:last-child {
  border-bottom: 0;
}

.compact-mail-row time {
  color: var(--muted);
  font-size: 12px;
  text-align: right;
}

.otp-mini,
.inbox-code,
.service-code {
  border-radius: 7px;
  padding: 6px 10px;
  background: #e8f5f2;
  color: var(--accent-dark) !important;
  font-variant-numeric: tabular-nums;
  font-weight: 950;
  letter-spacing: 0.08em;
}

.admin-create-grid {
  display: grid;
  grid-template-columns: minmax(320px, 0.8fr) minmax(0, 1.2fr);
  gap: 18px;
  margin-bottom: 18px;
}

.customer-help {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
}

.directory-tools {
  align-items: end;
}

.directory-tools > div {
  display: grid;
  gap: 4px;
}

.search-input {
  width: min(420px, 100%);
}

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

.customer-card {
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--panel-soft);
}

.customer-card-head > div {
  display: grid;
  gap: 3px;
}

.customer-stats,
.customer-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.customer-stats span {
  border-radius: 999px;
  padding: 5px 9px;
  background: #eef3ef;
}

.password-reset {
  margin-top: auto;
}

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

.route-tools-grid {
  align-items: start;
}

.route-test {
  position: sticky;
  top: 90px;
}

.route-groups {
  display: grid;
  gap: 14px;
}

.route-group {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--panel-soft);
}

.route-group-head {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: #f1f6f2;
}

.route-group-head > div {
  display: grid;
  gap: 4px;
}

.route-group-head .eyebrow {
  margin: 0;
}

.route-row {
  display: grid;
  grid-template-columns: minmax(210px, 1fr) minmax(150px, auto) auto auto auto auto auto auto;
  align-items: center;
  gap: 10px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
}

.route-row-conflict {
  background: #fff8f7;
}

.route-row:target,
.access-edit:target,
.mailbox-card:target {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  background: #f7fbf8;
}

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

.route-main {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.route-main small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conflict-line {
  color: var(--error);
  font-weight: 800;
}

.route-conflict-summary {
  align-items: flex-start;
  display: grid;
  gap: 4px;
  margin-bottom: 16px;
}

.conflict-action {
  border-color: #f0b5ae;
  color: var(--error);
}

.route-assigned-at,
.assignment-time {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.error-pill {
  background: var(--error-soft);
  color: var(--error);
}

.health-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}

.health-summary > div {
  display: grid;
  gap: 6px;
}

.health-summary span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.health-summary strong {
  overflow-wrap: anywhere;
}

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

.mailbox-card {
  display: grid;
  gap: 16px;
}

.connection-error {
  margin: 0;
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--error-soft);
  color: var(--error);
  font-size: 13px;
}

.customer-hero {
  margin-bottom: 18px;
  padding: 22px 0 8px;
}

.customer-hero h1 {
  margin-bottom: 8px;
}

.customer-overview-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(320px, 0.75fr);
  gap: 18px;
  align-items: start;
  margin-bottom: 24px;
}

.latest-mail-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 100%;
  padding: 22px 24px;
  border: 1px solid #9fd5ca;
  border-radius: 10px;
  background: #eefbf8;
  box-shadow: var(--shadow-soft);
}

.latest-mail-card > div {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.latest-mail-card p {
  margin: 0;
  color: var(--muted);
}

.latest-mail-subject {
  color: #0b504b;
  font-size: 22px;
  letter-spacing: 0;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.latest-mail-meta,
.latest-mail-sender {
  overflow-wrap: anywhere;
}

.latest-mail-action {
  min-width: 130px;
  min-height: 44px;
  white-space: nowrap;
}

.waiting-card {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 22px;
  padding: 20px 22px;
  border: 1px dashed #9bc9c2;
  border-radius: 10px;
  background: #f4fbf9;
}

.waiting-card p {
  margin: 4px 0 0;
  color: var(--muted);
}

.waiting-icon {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border-radius: 50%;
  background: #d9f2ec;
  color: var(--accent-dark);
  font-weight: 950;
}

.customer-address-section,
.inbox-section {
  margin-bottom: 24px;
}

.customer-overview-grid .customer-address-section {
  margin-bottom: 0;
}

.customer-overview-grid .section-head {
  margin-bottom: 12px;
}

.customer-overview-grid .address-card-grid {
  grid-template-columns: 1fr;
}

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

.address-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  box-shadow: var(--shadow-soft);
}

.address-card-head {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-soft);
}

.address-card-head strong {
  min-width: 0;
  overflow-wrap: anywhere;
}

.service-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
}

.service-line:last-child {
  border-bottom: 0;
}

.service-line:hover {
  background: #f7faf7;
}

.service-line > div {
  display: grid;
  gap: 3px;
}

.compact-filter,
.mail-filter-bar,
.manual-assign-form,
.routing-fix-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.compact-filter select {
  min-width: 190px;
}

.customer-list .message-main {
  grid-template-columns: 210px minmax(0, 1fr) auto 180px;
}

.empty-inbox {
  margin: 18px;
}

.message-code {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
  padding: 14px 16px;
  border: 1px solid #9fd5ca;
  border-radius: 9px;
  background: #eefbf8;
}

.message-code span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.message-code strong {
  margin-right: auto;
  color: var(--accent-dark);
  font-size: 28px;
  letter-spacing: 0.12em;
}

.routing-fix-panel {
  display: grid;
  gap: 16px;
  margin: 20px 0;
  padding: 18px;
  border: 1px solid #f1ca96;
  border-radius: 9px;
  background: var(--warn-soft);
}

.routing-fix-panel h2,
.routing-fix-panel p {
  margin: 0;
}

.manual-assign-form {
  flex: 1;
}

.manual-assign-form select {
  min-width: 260px;
}

.mail-filter-bar {
  margin-bottom: 14px;
}

.mail-filter-bar input {
  flex: 1;
}

.mail-filter-bar select {
  width: 180px;
}

.quarantine-message-main small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

[data-filter-item][hidden] {
  display: none !important;
}

@media (max-width: 900px) {
  .auth-panel,
  .grid.two,
  .metrics,
  .quick-actions,
  .admin-create-grid,
  .customer-grid,
  .mailbox-grid,
  .address-card-grid,
  .health-summary {
    grid-template-columns: 1fr;
  }

  .admin-frame {
    display: block;
    width: min(100% - 24px, 1180px);
    margin-top: 14px;
  }

  .admin-sidebar {
    position: static;
    display: flex;
    overflow-x: auto;
    margin-bottom: 18px;
  }

  .admin-sidebar .sidebar-label {
    display: none;
  }

  .admin-sidebar a {
    white-space: nowrap;
  }

  .page-head,
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar {
    padding: 14px 16px;
  }

  .brand {
    white-space: normal;
  }

  .auth-copy h1 {
    max-width: none;
  }

  .welcome-panel {
    align-items: stretch;
    flex-direction: column;
    padding: 20px;
  }

  .welcome-panel h1 {
    font-size: 29px;
  }

  .welcome-mark {
    width: 58px;
    height: 58px;
  }

  .welcome-mark svg {
    width: 34px;
    height: 34px;
  }

  .topbar nav {
    flex-wrap: wrap;
    margin-right: 0;
  }

  .row,
  .message-row,
  .admin-mail-row,
  .subscription-row,
  .history-row,
  .status-list,
  .meta {
    grid-template-columns: 1fr;
  }

  .message-main {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .admin-message-main,
  .quarantine-message-main {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .admin-message-delete-form {
    justify-self: stretch;
  }

  .admin-message-delete-form button {
    width: 100%;
  }

  .inline-form,
  .copy-row,
  .filter-form,
  .field-pair {
    grid-template-columns: 1fr;
  }

  .access-edit-head,
  .access-actions {
    align-items: stretch;
    flex-direction: column;
  }

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

  .route-test {
    position: static;
  }

  .route-row,
  .compact-mail-row,
  .customer-list .message-main {
    grid-template-columns: 1fr;
  }

  .customer-overview-grid {
    grid-template-columns: 1fr;
  }

  .latest-mail-card,
  .customer-hero,
  .section-head,
  .directory-tools,
  .mailbox-card-head,
  .route-group-head,
  .address-card-head,
  .service-line,
  .message-code,
  .routing-fix-actions,
  .manual-assign-form,
  .mail-filter-bar {
    align-items: stretch;
    flex-direction: column;
  }

  .latest-mail-action,
  .manual-assign-form select,
  .mail-filter-bar select {
    width: 100%;
  }

  .compact-mail-row time {
    text-align: left;
  }
}

@media (prefers-reduced-motion: reduce) {
  .welcome-panel::before,
  .fetch-icon::before {
    animation: none;
  }
}
