:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --panel: #ffffff;
  --text: #17202c;
  --muted: #667085;
  --line: #d8e0ea;
  --accent: #1264c8;
  --accent-dark: #0b4c99;
  --danger: #b42318;
  --ok: #067647;
  --warn: #b54708;
  --soft-blue: #eef5ff;
  --soft-green: #ecfdf3;
  --soft-red: #fef3f2;
  --soft-amber: #fffaeb;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 15px;
  line-height: 1.45;
}

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

.topbar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 18px;
  min-height: 64px;
  padding: 10px 24px;
  background: #101828;
  color: white;
}

.brand,
.nav a {
  color: white;
  text-decoration: none;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
}

.brand-mark {
  display: inline-flex;
  width: 34px;
  height: 34px;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 8px;
  font-size: 13px;
}

.nav {
  display: flex;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
}

.nav a {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 6px;
  color: rgba(255, 255, 255, 0.86);
}

.nav a:hover {
  background: rgba(255, 255, 255, 0.1);
  color: white;
}

.page {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 28px 20px 56px;
}

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

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

h1 {
  margin-bottom: 7px;
  font-size: 28px;
}

h2 {
  font-size: 18px;
}

p {
  margin: 0;
  color: var(--muted);
}

.actions,
.card-actions,
.row-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

button,
.button {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  padding: 8px 14px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent);
  color: white;
  font: inherit;
  text-decoration: none;
  cursor: pointer;
}

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

.secondary,
.ghost {
  background: white;
  color: var(--accent);
}

.ghost {
  background: transparent;
  color: white;
  border-color: rgba(255, 255, 255, 0.45);
}

.small {
  min-height: 34px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  color: var(--accent);
  text-decoration: none;
  font: inherit;
  cursor: pointer;
}

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

.login-panel,
.form,
.empty,
.site-card,
.history-item,
.guide {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
}

.login-panel {
  max-width: 420px;
  margin: 70px auto;
  padding: 26px;
}

.login-panel p {
  margin-bottom: 18px;
}

.form {
  display: grid;
  gap: 20px;
  padding: 22px;
}

.form.compact {
  padding: 0;
  border: 0;
  box-shadow: none;
}

.form.wide {
  max-width: 940px;
}

.test-mail-form {
  margin-top: 16px;
}

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

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

.form-grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form-grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

label {
  display: grid;
  gap: 7px;
  font-weight: 600;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 11px;
  background: white;
  color: var(--text);
  font: inherit;
}

textarea {
  resize: vertical;
  font-family: Consolas, monospace;
}

.help-text {
  font-size: 13px;
}

.checks {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.check input {
  width: auto;
}

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

.site-card,
.history-item {
  display: grid;
  gap: 16px;
  padding: 18px;
}

.site-main,
.history-top {
  display: flex;
  justify-content: space-between;
  gap: 14px;
}

.site-url {
  display: block;
  margin-top: 6px;
  overflow-wrap: anywhere;
  font-size: 14px;
}

.status-stack {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

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

.metrics div {
  min-width: 0;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
}

.metrics dt {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.metrics dd {
  margin: 0;
  overflow-wrap: anywhere;
  font-weight: 700;
}

.metric-note {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
}

.countdown {
  color: var(--accent);
}

.countdown.soon {
  color: var(--warn);
}

.compact-metrics {
  grid-template-columns: repeat(2, minmax(0, 140px));
}

.pill,
.status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.pill {
  background: var(--soft-blue);
  color: #1849a9;
}

.status.on {
  background: var(--soft-green);
  color: var(--ok);
}

.status.off {
  background: #f2f4f7;
  color: var(--muted);
}

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

.status.bad {
  background: var(--soft-red);
  color: var(--danger);
}

.error-text {
  color: var(--danger);
  overflow-wrap: anywhere;
}

.empty,
.guide {
  display: grid;
  gap: 14px;
  padding: 22px;
}

.guide {
  max-width: 860px;
}

.guide ol {
  margin: 0;
  padding-left: 22px;
  color: var(--text);
}

.guide li + li {
  margin-top: 8px;
}

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

.history-message {
  color: var(--text);
}

.messages {
  display: grid;
  gap: 10px;
  margin-bottom: 18px;
}

.message {
  padding: 11px 13px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: white;
}

.message.success {
  border-color: #abefc6;
  background: var(--soft-green);
}

.message.error {
  border-color: #fecdca;
  background: var(--soft-red);
}

@media (max-width: 900px) {
  .topbar {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .nav {
    justify-content: flex-start;
  }

  .site-grid,
  .form-grid.two,
  .form-grid.three {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .page {
    padding: 20px 14px 40px;
  }

  .page-head,
  .site-main,
  .history-top {
    flex-direction: column;
  }

  .actions,
  .actions form,
  .actions button,
  .actions .button,
  .card-actions,
  .card-actions form,
  .card-actions button,
  .card-actions .small {
    width: 100%;
  }

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

  .login-panel {
    margin: 24px auto;
  }
}
