:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --text: #172033;
  --muted: #687386;
  --line: #dce2ea;
  --accent: #1264a3;
  --accent-strong: #0f4f80;
  --ok: #16845f;
  --warn: #b26b00;
  --danger: #b42318;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  letter-spacing: 0;
}

button,
input,
textarea {
  font: inherit;
}

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

.sidebar {
  background: #101828;
  color: #eef2f6;
  padding: 20px 16px;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 4px 4px 20px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: #e9f3ff;
  color: #0f4f80;
  font-weight: 800;
}

.brand h1 {
  margin: 0;
  font-size: 18px;
}

.brand p {
  margin: 3px 0 0;
  color: #aab4c2;
}

.nav {
  display: grid;
  gap: 6px;
}

.nav-item {
  width: 100%;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #d8dee8;
  cursor: pointer;
  padding: 11px 12px;
  text-align: left;
}

.nav-item:hover,
.nav-item.is-active {
  background: #1d2939;
  color: #ffffff;
}

.main {
  min-width: 0;
  padding: 24px;
}

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

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

h2,
h3 {
  margin: 0;
}

h2 {
  font-size: 24px;
}

h3 {
  font-size: 16px;
}

.account-box,
.toolbar,
.query-form {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

input,
textarea {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--text);
  padding: 8px 10px;
  outline: none;
}

textarea {
  min-width: 280px;
  resize: vertical;
}

input:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(18, 100, 163, 0.14);
}

.account-box {
  justify-content: flex-end;
}

.button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--text);
  cursor: pointer;
  padding: 8px 12px;
}

.button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
}

.button.primary:hover {
  background: var(--accent-strong);
}

.button.secondary:hover,
.button:hover {
  border-color: #b5c1cf;
}

.table-button {
  min-width: 64px;
}

.key-form {
  margin: 14px 0;
}

.notice {
  border-radius: 6px;
  margin-bottom: 14px;
  padding: 11px 12px;
  background: #e9f3ff;
  color: #16456b;
}

.notice.is-error {
  background: #fff1f0;
  color: var(--danger);
}

.view {
  display: none;
}

.view.is-active {
  display: grid;
  gap: 16px;
}

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

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

.metric {
  padding: 16px;
}

.metric span,
.info-grid span,
.muted {
  color: var(--muted);
}

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

.panel {
  min-width: 0;
  padding: 16px;
}

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

.split {
  display: grid;
  grid-template-columns: minmax(280px, 0.95fr) minmax(320px, 1.05fr);
  gap: 16px;
}

.message-list {
  display: grid;
  gap: 8px;
}

.batch-form {
  display: grid;
  gap: 10px;
}

.batch-form textarea {
  width: 100%;
}

.message-row {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  cursor: pointer;
  padding: 10px;
}

.message-row:hover {
  border-color: var(--accent);
}

.message-row strong {
  display: block;
  margin-bottom: 4px;
}

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

.message-group {
  display: grid;
  gap: 8px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.message-group:first-child {
  border-top: 0;
  padding-top: 0;
}

.message-group-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.message-group-head span {
  color: var(--muted);
}

.code-block {
  overflow: auto;
  white-space: pre-wrap;
  border-radius: 6px;
  background: #0f172a;
  color: #e5edf6;
  padding: 14px;
  line-height: 1.55;
}

.message-detail {
  overflow: auto;
  min-height: 360px;
  max-height: 560px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--text);
  padding: 0;
}

.message-detail-card {
  display: grid;
  gap: 14px;
  padding: 14px;
}

.message-detail-head {
  display: grid;
  gap: 6px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
}

.message-detail-head h4 {
  margin: 0;
  font-size: 17px;
}

.message-detail-head span {
  color: var(--muted);
}

.message-meta {
  display: grid;
  gap: 8px;
  margin: 0;
}

.message-meta div {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr);
  gap: 10px;
}

.message-meta dt {
  color: var(--muted);
}

.message-meta dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.message-body {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  border-top: 1px solid var(--line);
  padding-top: 14px;
  line-height: 1.65;
}

.message-body a {
  color: var(--accent);
}

.table-empty {
  color: var(--muted);
  padding: 10px 0;
}

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

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

.data-table th {
  color: var(--muted);
  font-weight: 600;
}

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

.info-grid div,
.status-card {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
}

.info-grid strong,
.status-card strong {
  display: block;
  margin-top: 6px;
  word-break: break-word;
}

.status-ok {
  color: var(--ok);
}

.status-error {
  color: var(--danger);
}

.provisioning {
  border-top: 1px solid var(--line);
  margin-top: 14px;
  padding-top: 14px;
}

.provisioning-head,
.provisioning-step {
  display: grid;
  gap: 8px;
  align-items: center;
}

.provisioning-head {
  grid-template-columns: minmax(0, 1fr) auto;
  margin-bottom: 10px;
}

.provisioning-step {
  grid-template-columns: 10px minmax(180px, 0.4fr) minmax(0, 1fr);
  min-height: 32px;
  border-top: 1px solid var(--line);
  padding: 8px 0;
}

.provisioning-step span:last-child {
  color: var(--muted);
  word-break: break-word;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

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

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

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

.domain-status-item {
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.domain-status-title {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  margin-bottom: 6px;
}

.login-shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(420px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 22px;
}

.login-brand {
  padding: 0 0 18px;
  color: var(--text);
}

.login-brand p {
  color: var(--muted);
}

.login-form {
  display: grid;
  gap: 12px;
}

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

  .sidebar {
    position: static;
  }

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

  .nav-item {
    text-align: center;
  }

  .topbar,
  .split {
    grid-template-columns: 1fr;
    flex-direction: column;
    align-items: stretch;
  }

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

@media (max-width: 640px) {
  .main {
    padding: 16px;
  }

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

  .metric-grid,
  .info-grid,
  .status-grid {
    grid-template-columns: 1fr;
  }

  .query-form input,
  .query-form .button,
  .toolbar .button {
    width: 100%;
  }
}
