:root {
  --bg: #f4f6f7;
  --panel: #ffffff;
  --panel-soft: #eef3f1;
  --ink: #18201d;
  --muted: #64716b;
  --line: #d9e0dc;
  --accent: #14746f;
  --accent-dark: #0b5351;
  --danger: #b42318;
  --shadow: 0 18px 48px rgba(22, 33, 29, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  color: var(--accent-dark);
}

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

#root {
  min-height: 100vh;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  border-radius: 7px;
  background: var(--accent);
  color: white;
  cursor: pointer;
  min-height: 40px;
  padding: 0 14px;
  white-space: nowrap;
}

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

button.secondary,
.icon-button {
  background: var(--panel-soft);
  color: var(--ink);
}

.danger-button {
  background: #fee4e2;
  color: var(--danger);
  min-height: 34px;
  padding: 0 10px;
}

.danger-button:hover {
  background: #fecdca;
}

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

.sidebar {
  border-right: 1px solid var(--line);
  background: var(--panel);
  display: flex;
  flex-direction: column;
  gap: 0;
  min-height: 100vh;
  padding: 18px;
  overflow-y: auto;
}

.brand {
  align-items: center;
  display: flex;
  gap: 10px;
  margin-bottom: 18px;
  min-width: 0;
}

.brand-mark.large {
  font-size: 28px;
  height: 64px;
  width: 64px;
}

.brand-mark {
  align-items: center;
  background: var(--accent);
  border-radius: 8px;
  color: white;
  display: flex;
  flex: 0 0 auto;
  font-weight: 800;
  height: 38px;
  justify-content: center;
  width: 38px;
}

.brand h1,
.toolbar h2,
.empty-state h3 {
  margin: 0;
}

.brand h1 {
  font-size: 17px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand p,
.eyebrow,
.empty-state p {
  color: var(--muted);
  margin: 4px 0 0;
}

.brand p {
  font-size: 12px;
  line-height: 1.35;
}

.login,
.alias-form {
  border-top: 1px solid var(--line);
  padding-top: 14px;
  margin-top: 14px;
}

label,
.section-heading,
.eyebrow {
  color: var(--muted);
  display: block;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

.alias-create-row {
  grid-template-columns: minmax(130px, 1fr) minmax(120px, auto) minmax(110px, auto) auto;
}

.user-create-row {
  grid-template-columns: 1fr;
}

.form-title {
  align-items: center;
  display: flex;
  justify-content: space-between;
}

.form-title span,
.muted {
  color: var(--muted);
  font-size: 13px;
}

input,
select {
  border: 1px solid var(--line);
  border-radius: 7px;
  min-height: 40px;
  outline: 0;
  padding: 0 11px;
  width: 100%;
}

input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(20, 116, 111, 0.14);
}

.section-heading {
  align-items: center;
  display: flex;
  justify-content: space-between;
  margin: 24px 0 10px;
}

.icon-button {
  min-height: 32px;
  padding: 0;
  width: 32px;
}

.alias-list {
  display: grid;
  gap: 7px;
  min-height: 0;
  overflow-y: auto;
  padding-right: 2px;
}

.alias-item,
.alias-open {
  align-items: center;
  background: transparent;
  border-radius: 7px;
  color: var(--ink);
  display: flex;
  justify-content: space-between;
  min-height: 42px;
  min-width: 0;
  padding: 0 9px;
  text-align: left;
}

.alias-row {
  align-items: center;
  border-radius: 7px;
  display: grid;
  gap: 6px;
  grid-template-columns: minmax(0, 1fr) minmax(58px, auto);
  min-width: 0;
}

.alias-item:hover,
.alias-item.active,
.alias-row:hover,
.alias-row.active {
  background: var(--panel-soft);
}

.alias-open {
  min-width: 0;
}

.alias-open span,
.alias-item span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.alias-open:hover {
  background: transparent;
  color: var(--ink);
}

.alias-item small,
.alias-open small {
  color: var(--muted);
}

.copy-button {
  background: var(--panel-soft);
  color: var(--ink);
  min-height: 34px;
  padding: 0 10px;
}

.row-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.profile-box {
  align-items: center;
  background: var(--panel-soft);
  border-radius: 8px;
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(0, 1fr) auto;
  justify-content: space-between;
  margin: 12px 0;
  padding: 12px;
}

.profile-box span {
  color: var(--muted);
  font-size: 13px;
  text-transform: capitalize;
}

.profile-box div {
  min-width: 0;
}

.main {
  min-width: 0;
  padding: 20px;
  overflow: hidden;
}

.toolbar {
  align-items: center;
  display: flex;
  justify-content: space-between;
  margin-bottom: 18px;
}

.toolbar h2 {
  font-size: 24px;
}

.toolbar-actions {
  display: flex;
  gap: 8px;
}

.content-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(280px, 420px) minmax(0, 1fr);
  height: calc(100vh - 100px);
}

.message-list,
.message-detail {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: auto;
}

.message-item {
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  padding: 14px;
}

.message-item:hover,
.message-item.active {
  background: var(--panel-soft);
}

.message-item strong,
.message-meta {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.message-detail {
  padding: 20px;
}

.detail-header {
  border-bottom: 1px solid var(--line);
  margin-bottom: 18px;
  padding-bottom: 18px;
}

.detail-header h3 {
  font-size: 22px;
  margin: 0 0 10px;
}

.detail-row {
  color: var(--muted);
  font-size: 14px;
  margin-top: 5px;
}

.message-body {
  background: #fbfcfc;
  border: 1px solid var(--line);
  border-radius: 8px;
  line-height: 1.55;
  min-height: 180px;
  padding: 16px;
  white-space: pre-wrap;
}

.body-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.body-tab {
  background: var(--panel-soft);
  color: var(--ink);
  min-height: 34px;
}

.body-tab.active {
  background: var(--accent);
  color: white;
}

.html-preview {
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  height: min(680px, calc(100vh - 260px));
  min-height: 320px;
  width: 100%;
}

.empty-state {
  align-items: center;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  height: 100%;
  justify-content: center;
  text-align: center;
}

.toast {
  background: var(--ink);
  border-radius: 8px;
  bottom: 18px;
  box-shadow: var(--shadow);
  color: white;
  left: 50%;
  max-width: min(460px, calc(100vw - 28px));
  padding: 12px 14px;
  position: fixed;
  transform: translateX(-50%);
}

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

.admin-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}

.admin-panel.wide {
  grid-column: 1 / -1;
}

.admin-panel h3 {
  margin: 0 0 14px;
}

.panel-title-row {
  align-items: flex-start;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  margin-bottom: 14px;
}

.panel-title-row h3 {
  margin-bottom: 4px;
}

.stats-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(3, 1fr);
}

.stats-grid div {
  background: var(--panel-soft);
  border-radius: 8px;
  padding: 14px;
}

.stats-grid strong,
.stats-grid span {
  display: block;
}

.stats-grid strong {
  font-size: 24px;
}

.stats-grid span {
  color: var(--muted);
  font-size: 13px;
}

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

.domain-helper {
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(0, 1fr) minmax(180px, auto);
  margin-bottom: 14px;
}

.domain-status {
  align-items: center;
  background: var(--panel-soft);
  border-radius: 7px;
  color: var(--muted);
  display: flex;
  font-size: 13px;
  min-height: 40px;
  padding: 0 12px;
}

.domain-status.ready {
  color: var(--accent-dark);
  font-weight: 700;
}

.dns-table {
  display: grid;
  gap: 8px;
}

.dns-row {
  align-items: center;
  background: #fbfcfc;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 10px;
  grid-template-columns: 70px 80px minmax(0, 1fr) 80px 80px auto;
  padding: 10px 12px;
}

.dns-head {
  background: transparent;
  border: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  min-height: auto;
  padding-bottom: 0;
  text-transform: uppercase;
}

.dns-row code,
.setup-note code {
  background: var(--panel-soft);
  border-radius: 6px;
  overflow: hidden;
  padding: 7px 8px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.setup-note {
  background: var(--panel-soft);
  border-radius: 8px;
  color: var(--muted);
  line-height: 1.5;
  margin-top: 12px;
  padding: 12px;
}

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

.user-row {
  align-items: center;
  background: #fbfcfc;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(140px, 190px) minmax(0, 1fr) minmax(170px, auto);
  padding: 12px;
}

.user-row span {
  color: var(--muted);
  display: block;
  font-size: 13px;
  text-transform: capitalize;
}

.user-row code {
  background: var(--panel-soft);
  border-radius: 6px;
  overflow: hidden;
  padding: 8px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.toast.error {
  background: var(--danger);
}

.login-page {
  align-items: center;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.82), rgba(244,246,247,0.95)),
    radial-gradient(circle at 20% 10%, rgba(20,116,111,0.16), transparent 34%),
    radial-gradient(circle at 85% 18%, rgba(64,93,86,0.12), transparent 28%);
  display: flex;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}

.landing-page {
  align-items: center;
  background: #f8faf9;
  display: flex;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
  text-align: center;
}

.landing-hero {
  margin: 0 auto;
  max-width: 680px;
  width: min(680px, 100%);
}

.landing-hero h1 {
  color: var(--ink);
  font-size: clamp(40px, 8vw, 74px);
  line-height: 1;
  margin: 0 0 16px;
}

.landing-meta {
  color: var(--muted);
  font-size: 15px;
  font-weight: 700;
  line-height: 1.5;
  margin: 0 auto 24px;
  max-width: 560px;
}

.landing-actions {
  align-items: center;
  justify-content: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 26px 0 0;
}

.primary-link,
.secondary-link {
  align-items: center;
  border-radius: 7px;
  display: inline-flex;
  font-weight: 800;
  min-height: 44px;
  padding: 0 16px;
}

.primary-link {
  background: var(--accent);
  color: white;
}

.primary-link:hover {
  background: var(--accent-dark);
  color: white;
}

.secondary-link {
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--ink);
}

.login-hero {
  max-width: 720px;
  width: min(720px, 100%);
}

.login-hero h1 {
  font-size: clamp(36px, 6vw, 64px);
  line-height: 1;
  margin: 18px 0 16px;
}

.hero-copy {
  color: var(--muted);
  font-size: 18px;
  line-height: 1.6;
  margin: 0 0 24px;
  max-width: 620px;
}

.login-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 10px;
  max-width: 520px;
  padding: 18px;
}

.route-link {
  display: inline-block;
  font-weight: 700;
  margin-top: 18px;
}

.admin-shell {
  min-height: 100vh;
}

.admin-topbar {
  align-items: center;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  padding: 16px 24px;
}

.admin-topbar .brand {
  margin-bottom: 0;
}

.admin-topbar nav {
  align-items: center;
  display: flex;
  gap: 14px;
}

.admin-main {
  margin: 0 auto;
  max-width: 1180px;
  padding: 28px 22px;
}

.admin-hero {
  margin-bottom: 22px;
}

.admin-hero h1 {
  font-size: 40px;
  margin: 4px 0 8px;
}

.admin-hero p:last-child {
  color: var(--muted);
  line-height: 1.5;
  max-width: 760px;
}

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

.alias-table-row {
  align-items: center;
  background: #fbfcfc;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(0, 1fr) 180px auto;
  padding: 12px;
}

.alias-table-row span {
  color: var(--muted);
}

@media (max-width: 860px) {
  .app-shell,
  .content-grid,
  .admin-grid {
    grid-template-columns: 1fr;
  }

  .alias-create-row,
  .admin-form,
  .domain-helper,
  .user-row,
  .dns-row,
  .alias-table-row {
    grid-template-columns: 1fr;
  }

  .dns-head {
    display: none;
  }

  .panel-title-row {
    flex-direction: column;
  }

  .admin-topbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    min-height: auto;
  }

  .content-grid {
    height: auto;
  }

  .main {
    overflow: visible;
    padding: 16px;
  }

  .toolbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
  }

  .row-actions {
    justify-content: stretch;
  }

  .row-actions button {
    flex: 1;
  }

  .message-list,
  .message-detail {
    min-height: 320px;
  }
}
