:root {
  color-scheme: light;
  --bg: #f5f7fa;
  --panel: #ffffff;
  --text: #1f2933;
  --muted: #667085;
  --border: #d8dee8;
  --primary: #1565c0;
  --primary-dark: #0f4f99;
  --success-bg: #ecfdf3;
  --success: #067647;
  --danger-bg: #fff0f0;
  --danger: #b42318;
}

* {
  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;
}

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

.brand {
  color: var(--text);
  font-size: 18px;
  font-weight: 700;
  text-decoration: none;
}

.nav {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
}

.nav a {
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
  padding: 8px 10px;
  border-radius: 6px;
}

.nav a:hover {
  color: var(--text);
  background: #eef2f7;
}

.shell {
  width: min(1080px, calc(100% - 32px));
  margin: 32px auto;
}

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

.narrow {
  width: min(440px, 100%);
  margin: 56px auto;
}

.heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 24px;
  margin-bottom: 20px;
}

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

h1 {
  margin-bottom: 8px;
  font-size: 30px;
  line-height: 1.2;
}

h2 {
  margin-bottom: 10px;
  font-size: 20px;
}

p {
  color: var(--muted);
  line-height: 1.55;
}

.form {
  display: grid;
  gap: 16px;
  margin-top: 22px;
}

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

input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  color: var(--text);
  font: inherit;
  background: #fff;
}

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

select {
  min-height: 44px;
}

textarea {
  min-height: 280px;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 13px;
  line-height: 1.5;
}

input:focus,
select:focus,
textarea:focus {
  outline: 3px solid rgba(21, 101, 192, 0.16);
  border-color: var(--primary);
}

.button {
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 9px 14px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

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

.primary:hover {
  background: var(--primary-dark);
}

.ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}

.danger {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: #ffcdca;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.actions a {
  display: inline-flex;
  align-items: center;
  color: inherit;
  text-decoration: none;
}

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

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

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

.stat {
  min-height: 112px;
  display: grid;
  align-content: space-between;
  gap: 18px;
  padding: 18px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.stat span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

.stat strong {
  font-size: 20px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.alert {
  margin: 18px 0 0;
  padding: 12px;
  border-radius: 6px;
  font-size: 14px;
}

.alert.error {
  color: var(--danger);
  background: var(--danger-bg);
  border: 1px solid #ffcdca;
}

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

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

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

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

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

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

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

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 4px 8px;
  border-radius: 999px;
  color: var(--muted);
  background: #eef2f7;
  font-size: 12px;
  font-weight: 800;
}

.badge.ok {
  color: var(--success);
  background: var(--success-bg);
}

.badge.warning {
  color: #b54708;
  background: #fffaeb;
}

.badge.danger {
  color: var(--danger);
  background: var(--danger-bg);
}

td small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

@media (max-width: 760px) {
  .topbar {
    height: auto;
    flex-wrap: wrap;
    padding: 0 16px;
    padding-top: 12px;
    padding-bottom: 12px;
  }

  .nav {
    order: 3;
    width: 100%;
    overflow-x: auto;
    margin-left: 0;
  }

  .shell {
    margin: 20px auto;
  }

  .narrow {
    margin: 24px auto;
  }

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

  .grid.two,
  .split {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 26px;
  }
}
