:root {
  --bg: #eef2f6;
  --surface: #ffffff;
  --surface-soft: #f7f9fc;
  --ink: #16202d;
  --muted: #647184;
  --line: #d9e2ec;
  --line-strong: #bcc9d8;
  --brand: #155e75;
  --brand-strong: #0f3f52;
  --accent: #7c3aed;
  --accent-strong: #5b21b6;
  --ok: #168449;
  --warn: #b56a00;
  --error: #b42318;
  --shadow: 0 18px 44px rgba(22, 32, 45, 0.10);
  --shadow-soft: 0 10px 26px rgba(22, 32, 45, 0.07);
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  background:
    linear-gradient(135deg, rgba(21, 94, 117, 0.08), transparent 34%),
    linear-gradient(45deg, rgba(124, 58, 237, 0.06), transparent 38%),
    var(--bg);
  color: var(--ink);
}

body {
  min-height: 100vh;
  margin: 0;
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  content: "";
  background-image:
    linear-gradient(rgba(22, 32, 45, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(22, 32, 45, 0.045) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: linear-gradient(to bottom, black, transparent 68%);
}

main {
  width: min(1160px, calc(100% - 32px));
  margin: 0 auto;
  padding: 34px 0 56px;
}

.app-body main {
  padding-top: 26px;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 8px;
  font-size: clamp(30px, 5vw, 56px);
  line-height: 1;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 12px;
  font-size: 18px;
  letter-spacing: 0;
}

p {
  line-height: 1.55;
}

a {
  color: var(--brand);
}

button,
input,
select {
  font: inherit;
}

button,
.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  padding: 10px 16px;
  background: var(--brand);
  color: #fff;
  box-shadow: 0 10px 22px rgba(21, 94, 117, 0.18);
  cursor: pointer;
  font-weight: 750;
  text-decoration: none;
  transition: transform 0.16s ease, background 0.16s ease, box-shadow 0.16s ease;
}

button:hover,
.button-link:hover {
  background: var(--brand-strong);
  transform: translateY(-1px);
}

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

.button-link.secondary {
  background: #334155;
  box-shadow: 0 10px 22px rgba(51, 65, 85, 0.14);
}

.ghost-button {
  min-height: 34px;
  border: 1px solid var(--line);
  padding: 7px 10px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
  box-shadow: none;
}

.ghost-button:hover {
  background: #fff;
  color: var(--brand-strong);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(190px, auto) 1fr auto;
  gap: 18px;
  align-items: center;
  border-bottom: 1px solid rgba(217, 226, 236, 0.86);
  padding: 12px max(16px, calc((100vw - 1160px) / 2));
  background: rgba(248, 250, 252, 0.88);
  box-shadow: 0 8px 28px rgba(22, 32, 45, 0.06);
  backdrop-filter: blur(14px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-weight: 850;
  text-decoration: none;
}

.brand-mark {
  position: relative;
  display: inline-block;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background:
    linear-gradient(135deg, var(--brand), var(--accent)),
    var(--brand);
  box-shadow: 0 10px 22px rgba(21, 94, 117, 0.25);
}

.brand-mark::after {
  position: absolute;
  inset: 8px 6px;
  border: 2px solid rgba(255, 255, 255, 0.9);
  border-top: 0;
  border-radius: 2px 2px 5px 5px;
  content: "";
}

.main-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.main-nav a {
  border-radius: 8px;
  padding: 8px 10px;
  color: #334155;
  font-weight: 750;
  text-decoration: none;
}

.main-nav a:hover {
  background: #e6edf4;
  color: var(--brand-strong);
}

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

.account span {
  max-width: 240px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account form {
  margin: 0;
}

code {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 2px 6px;
  background: var(--surface-soft);
}

.login-shell {
  min-height: calc(100vh - 90px);
  display: grid;
  place-items: center;
}

.login-panel {
  width: min(100%, 440px);
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 8px;
  padding: 28px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.login-panel::before {
  display: block;
  width: 46px;
  height: 46px;
  border-radius: 8px;
  margin-bottom: 16px;
  background: linear-gradient(135deg, var(--brand), var(--accent));
  box-shadow: 0 16px 34px rgba(21, 94, 117, 0.22);
  content: "";
}

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

.login-panel label,
.upload-form label,
.form-grid label {
  display: grid;
  gap: 8px;
  color: #263445;
  font-weight: 750;
}

.login-panel label {
  margin: 16px 0;
}

input,
select,
.upload-form input[type="file"] {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 11px 12px;
  background: #fff;
  color: var(--ink);
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

input:focus,
select:focus {
  outline: 3px solid rgba(21, 94, 117, 0.18);
  border-color: var(--brand);
}

input[type="checkbox"] {
  width: auto;
}

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

.notice {
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 12px 14px;
  margin: 16px 0;
  font-weight: 650;
}

.notice.warn {
  border-color: #f5cc76;
  background: #fff7df;
  color: #654700;
}

.notice.ok {
  border-color: #9ed8b6;
  background: #e7f8ef;
  color: #115b34;
}

.notice.error {
  border-color: #f2a59e;
  background: #fff0ef;
  color: var(--error);
}

.toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
}

.toolbar h1 {
  color: #0f172a;
}

.toolbar p {
  max-width: 660px;
  margin-bottom: 0;
  color: var(--muted);
}

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

.actions form {
  margin: 0;
}

.grid,
.admin-grid,
.domain-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.admin-grid {
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.domain-grid {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  margin-bottom: 0;
}

.card,
.panel,
.admin-tile {
  border: 1px solid rgba(217, 226, 236, 0.96);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow-soft);
}

.card,
.panel {
  padding: 18px;
}

.panel {
  margin-bottom: 18px;
}

.panel > :last-child,
.card > :last-child {
  margin-bottom: 0;
}

.card {
  border-left-width: 5px;
}

.card.ok {
  border-left-color: var(--ok);
}

.card.warn {
  border-left-color: var(--warn);
}

.card.neutral {
  border-left-color: #53657a;
}

.admin-tile,
.domain-card {
  display: grid;
  gap: 10px;
  min-height: 138px;
  padding: 20px;
  color: var(--ink);
  text-decoration: none;
  transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}

.admin-tile:hover,
.domain-card:hover {
  border-color: var(--brand);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.admin-tile strong {
  font-size: 20px;
}

.admin-tile span {
  color: var(--muted);
  line-height: 1.45;
}

.domain-card strong {
  display: block;
  font-size: 20px;
}

.domain-card span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.domain-card dl {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 6px 0 0;
}

.domain-card dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.domain-card dd {
  margin: 4px 0 0;
  font-size: 22px;
  font-weight: 850;
}

.chart-wrap {
  min-height: 180px;
  margin-top: 8px;
}

.chart-wrap.is-empty {
  display: none;
}

.mini-table {
  display: grid;
  gap: 8px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.mini-table > div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
}

.mini-table b {
  color: var(--ink);
}

.quick-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.quick-links a {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--surface-soft);
  text-decoration: none;
  font-weight: 750;
  transition: background 0.16s ease, border-color 0.16s ease, transform 0.16s ease;
}

.quick-links a:hover {
  border-color: var(--brand);
  background: #fff;
  transform: translateY(-1px);
}

.upload-form {
  display: grid;
  gap: 14px;
  max-width: 560px;
}

.mailbox-panel {
  margin-bottom: 16px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

.checkbox {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  color: #263445;
  font-weight: 750;
}

.switch {
  display: inline-flex;
  align-items: center;
}

.switch input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.switch span {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  border-radius: 999px;
  background: #cbd5e1;
}

.switch span::after {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  content: "";
  transition: transform 0.16s ease;
}

.switch input:checked + span {
  background: var(--brand);
}

.switch input:checked + span::after {
  transform: translateX(20px);
}

.checks {
  display: grid;
  gap: 8px;
}

.check {
  display: grid;
  grid-template-columns: 64px minmax(180px, 1fr) minmax(220px, 2fr);
  gap: 12px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  padding: 9px 0;
}

.check:last-child {
  border-bottom: 0;
}

.check span,
.status-pill {
  border-radius: 999px;
  padding: 4px 8px;
  text-align: center;
  font-size: 12px;
  font-weight: 800;
}

.check small {
  color: var(--muted);
  overflow-wrap: anywhere;
}

.check.ok span {
  background: #e7f8ef;
  color: #115b34;
}

.check.warn span {
  background: #fff7df;
  color: #654700;
}

.check.fail span {
  background: #fff0ef;
  color: var(--error);
}

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

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 10px 8px;
  text-align: left;
  vertical-align: middle;
}

th {
  color: #526070;
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

tbody tr:hover {
  background: rgba(21, 94, 117, 0.035);
}

td input {
  min-width: 180px;
}

.status-pill {
  display: inline-block;
  background: #e8edf3;
  color: #314154;
}

@media (max-width: 720px) {
  .topbar {
    position: static;
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 12px;
  }

  .main-nav,
  .account {
    justify-content: flex-start;
  }

  .account {
    flex-wrap: wrap;
  }

  main {
    width: min(100% - 22px, 1160px);
    padding-top: 20px;
  }

  .toolbar {
    display: block;
  }

  .actions {
    justify-content: flex-start;
    margin-top: 16px;
  }

  .check {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .check span {
    width: max-content;
  }
}
