:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --text: #172033;
  --muted: #667085;
  --line: #d9e1ec;
  --accent: #1769e0;
  --accent-dark: #0f55ba;
  --success: #087443;
  --danger: #b42318;
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

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

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

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

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

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
  padding: 10px 12px;
}

textarea {
  resize: vertical;
}

label {
  display: grid;
  gap: 6px;
  color: #344054;
  font-weight: 600;
}

hr {
  width: 100%;
  border: 0;
  border-top: 1px solid var(--line);
  margin: 20px 0;
}

.guest-page {
  background: linear-gradient(180deg, #eef4ff 0%, #f7f9fc 100%);
}

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

.auth-panel {
  width: min(430px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: 0 20px 50px rgba(16, 24, 40, 0.08);
}

.auth-panel-wide {
  width: min(720px, 100%);
}

.auth-heading {
  display: grid;
  gap: 10px;
  margin-bottom: 24px;
}

.auth-heading h1 {
  margin-bottom: 0;
}

.auth-heading p,
.muted {
  color: var(--muted);
}

.block {
  display: block;
  margin-top: 4px;
}

.mt {
  margin-top: 20px;
}

.brand,
.brand-mark {
  display: inline-flex;
  align-items: center;
}

.brand {
  gap: 10px;
  padding: 20px;
  color: #fff;
  font-weight: 800;
  font-size: 18px;
}

.brand-mark {
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  font-weight: 800;
}

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

.sidebar {
  background: #101828;
  color: #fff;
}

.nav {
  display: grid;
  gap: 4px;
  padding: 0 12px;
}

.nav a {
  color: #d0d5dd;
  padding: 11px 12px;
  border-radius: var(--radius);
  font-weight: 700;
}

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

.main-column {
  min-width: 0;
}

.topbar {
  height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 28px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.topbar span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.content {
  padding: 28px;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

.page-header h1 {
  margin-bottom: 6px;
}

.page-header p {
  color: var(--muted);
}

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

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

.panel-header h2 {
  margin: 0;
  font-size: 17px;
}

.split-grid {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.template-layout {
  display: grid;
  grid-template-columns: minmax(360px, 0.95fr) minmax(0, 1.05fr);
  gap: 20px;
  align-items: start;
}

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

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

.stats-grid-small {
  margin-bottom: 0;
}

.stat {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
}

.stat span {
  display: block;
  color: var(--muted);
  margin-bottom: 8px;
}

.stat strong {
  font-size: 28px;
}

.stat-text {
  font-size: 18px !important;
}

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

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

.form-actions {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}

.checkbox input {
  width: auto;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  border: 0;
  border-radius: var(--radius);
  padding: 9px 14px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  cursor: pointer;
}

.button:hover {
  background: var(--accent-dark);
  color: #fff;
}

.button-muted {
  background: #eef2f7;
  color: #1d2939;
}

.button-muted:hover {
  background: #e4e9f2;
  color: #1d2939;
}

.notice {
  margin: 18px 28px 0;
  border-radius: var(--radius);
  padding: 12px 14px;
  font-weight: 700;
}

.auth-panel .notice {
  margin: 0 0 16px;
}

.notice-success {
  color: var(--success);
  background: #ecfdf3;
  border: 1px solid #abefc6;
}

.notice-error {
  color: var(--danger);
  background: #fef3f2;
  border: 1px solid #fecdca;
}

.notice-impersonation {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: #854a0e;
  background: #fffaeb;
  border: 1px solid #fedf89;
}

.notice-impersonation form {
  margin: 0;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

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

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

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.badge {
  display: inline-flex;
  border-radius: 999px;
  background: #eef2f7;
  color: #344054;
  padding: 4px 9px;
  font-size: 12px;
  font-weight: 800;
}

.inline-search {
  display: flex;
  gap: 8px;
  min-width: 280px;
}

.inline-search input {
  flex: 1;
  min-width: 170px;
}

.inline-search input,
.inline-search select {
  width: auto;
}

.inline-search select {
  min-width: 170px;
}

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

.actions form {
  display: flex;
  gap: 8px;
}

.resource-title {
  color: var(--text);
  font-weight: 800;
}

.resource-title:hover {
  color: var(--accent);
}

.empty-state {
  color: var(--muted);
  padding: 18px 10px;
}

.settings-list {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.settings-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfdff;
  padding: 14px;
}

.instruction-box {
  display: grid;
  gap: 10px;
  border: 1px solid #abefc6;
  border-radius: var(--radius);
  background: #ecfdf3;
  color: #063f2a;
  padding: 14px;
  margin-bottom: 16px;
}

.instruction-box p {
  margin-bottom: 0;
}

.instruction-box code {
  border-radius: 5px;
  background: #fff;
  padding: 2px 5px;
}

.dns-record-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.dns-record {
  display: grid;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f8fbff;
  padding: 12px;
}

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

.dns-record code {
  display: block;
  overflow-x: auto;
  border: 1px solid #d6e2f2;
  border-radius: 6px;
  background: #fff;
  padding: 8px;
  color: #1d2939;
  white-space: nowrap;
}

.dns-record-highlight {
  background: #fff;
}

.editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.variable-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.variable-pills button {
  min-height: 32px;
  border: 1px solid #b8c6d9;
  border-radius: 999px;
  padding: 6px 10px;
  background: #f8fbff;
  color: #1d2939;
  font-weight: 800;
  cursor: pointer;
}

.variable-pills button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.preview-box {
  margin-top: 18px;
  display: grid;
  gap: 10px;
}

.preview-box iframe {
  width: 100%;
  min-height: 280px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

@media (max-width: 980px) {
  .app-shell,
  .split-grid,
  .template-layout,
  .list-summary,
  .dns-record-grid,
  .stats-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
  }

  .nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding-bottom: 12px;
  }

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

  .inline-search {
    min-width: 0;
  }
}
