:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --panel: #ffffff;
  --text: #172033;
  --muted: #667085;
  --line: #d9e0ea;
  --accent: #146c94;
  --accent-dark: #0e4e6a;
  --warn: #b42318;
  --good: #117a51;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, Segoe UI, Arial, sans-serif;
  font-size: 15px;
}

a {
  color: var(--accent);
  text-decoration: none;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.15;
}

h2 {
  font-size: 18px;
}

button,
input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  font: inherit;
}

input,
textarea {
  margin-top: 8px;
  padding: 12px 13px;
  background: #fff;
}

textarea {
  resize: vertical;
  min-height: 118px;
  font-family: Consolas, Menlo, monospace;
  font-size: 13px;
}

button {
  border: 0;
  padding: 13px 16px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}

button:hover {
  background: var(--accent-dark);
}

.secondary-button {
  background: #fff;
  color: var(--accent-dark);
  border: 1px solid var(--line);
}

.secondary-button:hover {
  border-color: var(--accent);
  background: #eaf4f8;
}

.danger-button {
  width: auto;
  min-width: 86px;
  padding: 9px 12px;
  background: #fff3f1;
  color: var(--warn);
  border: 1px solid #f3b6b0;
}

.danger-button:hover {
  background: #ffe3df;
}

label {
  display: block;
  color: var(--muted);
  font-weight: 650;
}

table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

th,
td {
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

th:not(:first-child),
td:not(:first-child) {
  width: 96px;
  white-space: nowrap;
}

.truncate-cell {
  max-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 68px;
  padding: 0 28px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.topbar div {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.topbar span,
.muted {
  color: var(--muted);
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 20px;
  width: min(1180px, calc(100% - 32px));
  margin: 22px auto;
}

.layout.wide {
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, .8fr);
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 22px;
}

.span-2 {
  grid-column: 1 / -1;
}

.side-stack {
  display: grid;
  gap: 20px;
  align-content: start;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.section-title h1 {
  margin: 0;
}

.section-title > span {
  display: inline-grid;
  place-items: center;
  min-width: 34px;
  height: 34px;
  border-radius: 8px;
  background: #eaf4f8;
  color: var(--accent-dark);
  font-weight: 800;
}

.stack {
  display: grid;
  gap: 16px;
}

.site-list {
  display: grid;
  gap: 10px;
}

.site-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.site-row:hover {
  border-color: var(--accent);
}

.site-row strong,
.site-row small {
  display: block;
}

.site-main,
.site-title {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.site-main > span {
  min-width: 0;
}

.site-favicon {
  width: 24px;
  height: 24px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  object-fit: contain;
  flex: 0 0 auto;
}

.topbar .site-title {
  color: var(--text);
}

.site-row small {
  margin-top: 4px;
  color: var(--muted);
}

.delete-form {
  margin: 0;
}

.project-delete {
  margin-top: 16px;
}

.snippet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.snippet-header h2 {
  margin: 0;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: auto;
  min-height: 36px;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--accent-dark);
  font-size: 13px;
  line-height: 1;
  white-space: nowrap;
}

.icon-button:hover {
  border-color: var(--accent);
  background: #eaf4f8;
}

.icon-button svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: 0 0 auto;
}

.icon-button.copied {
  border-color: #98d2bb;
  background: #eaf8f2;
  color: var(--good);
}

.availability-card {
  display: grid;
  gap: 8px;
  margin-top: 16px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcff;
}

.monitoring-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 16px;
}

.monitoring-grid .availability-card,
.monitoring-grid .settings-form {
  margin-top: 0;
}

.availability-card > div {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.availability-card p {
  margin: 0;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 26px;
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f3f6fa;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  line-height: 1;
  white-space: nowrap;
}

.status-pill.up {
  border-color: #98d2bb;
  background: #eaf8f2;
  color: var(--good);
}

.status-pill.down {
  border-color: #f3b6b0;
  background: #fff3f1;
  color: var(--warn);
}

.status-pill.muted-status {
  color: var(--muted);
}

.status-error {
  color: var(--warn);
  font-size: 13px;
}

.settings-form {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.inline-form {
  margin: 0;
}

.cron-card {
  display: grid;
  gap: 12px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.cron-card h2 {
  margin: 0;
}

.cron-card p {
  margin-bottom: 0;
}

.cron-card textarea {
  min-height: 78px;
  resize: vertical;
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 650;
}

.toggle-row input {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--accent);
  flex: 0 0 auto;
}

.field-label {
  display: grid;
  gap: 8px;
}

.field-label input {
  margin-top: 0;
}

.stats-mini {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  white-space: nowrap;
}

.stats-mini b {
  color: var(--text);
}

.metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.metrics div {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcff;
}

.metrics strong {
  display: block;
  margin-bottom: 6px;
  font-size: 30px;
}

.metrics span {
  color: var(--muted);
}

.chart {
  display: flex;
  align-items: end;
  gap: 10px;
  height: 220px;
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.chart .muted {
  align-self: center;
}

.bar-wrap {
  display: grid;
  grid-template-rows: 1fr auto;
  gap: 8px;
  align-items: end;
  width: 48px;
  height: 100%;
}

.bar {
  width: 100%;
  border-radius: 6px 6px 0 0;
  background: var(--accent);
}

.bar-wrap small {
  color: var(--muted);
  text-align: center;
}

.periods {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.periods a {
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
}

.periods a.active {
  border-color: var(--accent);
  background: #eaf4f8;
  color: var(--accent-dark);
  font-weight: 750;
}

.custom-period {
  display: grid;
  grid-template-columns: repeat(2, minmax(150px, 1fr)) auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 18px;
}

.custom-period label {
  color: var(--muted);
  font-size: 13px;
}

.custom-period input {
  margin-top: 6px;
}

.custom-period button {
  min-height: 45px;
  white-space: nowrap;
}

.custom-period button.active {
  border-color: var(--accent);
  background: #eaf4f8;
  color: var(--accent-dark);
}

.alert {
  margin-bottom: 14px;
  padding: 12px 13px;
  border: 1px solid #f3b6b0;
  border-radius: 8px;
  background: #fff3f1;
  color: var(--warn);
}

.auth-page {
  display: grid;
  place-items: center;
  padding: 18px;
}

.auth-box {
  width: min(420px, 100%);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

@media (max-width: 860px) {
  .layout,
  .layout.wide {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
    padding: 16px;
  }

  .site-row,
  .section-title,
  .snippet-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .stats-mini {
    align-items: flex-start;
    flex-direction: column;
    white-space: normal;
  }

  .delete-form,
  .danger-button,
  .secondary-button {
    width: 100%;
  }

  .metrics {
    grid-template-columns: 1fr;
  }

  .custom-period {
    grid-template-columns: 1fr;
  }

  .monitoring-grid {
    grid-template-columns: 1fr;
  }

  .chart {
    overflow-x: auto;
  }
}
