:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --text: #17202a;
  --muted: #617182;
  --line: #d9e1e8;
  --primary: #1f7a5c;
  --primary-dark: #176148;
  --danger: #b42318;
  --warn: #946200;
  --ok: #16734b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

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

a:hover {
  text-decoration: underline;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  min-height: 58px;
  padding: 0 22px;
  background: #ffffff;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 5;
}

.brand {
  color: var(--text);
  font-weight: 700;
  white-space: nowrap;
}

.nav {
  display: flex;
  gap: 4px;
  flex: 1;
  overflow-x: auto;
}

.nav a {
  color: var(--muted);
  padding: 8px 10px;
  border-radius: 6px;
  white-space: nowrap;
}

.nav a.active,
.nav a:hover {
  background: #eaf3ef;
  color: var(--primary-dark);
  text-decoration: none;
}

.logout {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
}

.container {
  max-width: 1180px;
  margin: 0 auto;
  padding: 24px;
}

.section {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 16px;
}

.section.narrow {
  max-width: 760px;
}

.heading-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

h1,
h2,
h3 {
  margin: 0 0 12px;
  line-height: 1.25;
}

h1 {
  font-size: 24px;
}

h2 {
  font-size: 20px;
}

h3 {
  font-size: 16px;
}

.muted {
  color: var(--muted);
  margin: 4px 0 0;
}

.notice,
.error {
  border-radius: 6px;
  padding: 10px 12px;
  margin-bottom: 14px;
}

.notice {
  background: #e9f7ef;
  color: var(--ok);
  border: 1px solid #b9e2ca;
}

.error {
  background: #fff0ed;
  color: var(--danger);
  border: 1px solid #ffc7bd;
}

button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--text);
  font: inherit;
  cursor: pointer;
}

button:hover,
.button:hover {
  background: #f4f6f8;
  text-decoration: none;
}

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

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

.danger {
  border-color: #f2b8b5;
  color: var(--danger);
}

.danger:hover {
  background: #fff0ed;
}

input,
select,
textarea {
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
  background: #ffffff;
}

textarea {
  min-height: 92px;
  resize: vertical;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 14px;
}

label input,
label select,
label textarea {
  color: var(--text);
  font-size: 15px;
}

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

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

.form-grid .wide {
  grid-column: 1 / -1;
}

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

.inline-form,
.filters,
.query-form,
.actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.query-form input,
.filters input {
  flex: 1;
  min-width: 240px;
}

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

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

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

th {
  color: var(--muted);
  font-size: 13px;
  background: #f8fafb;
}

.empty {
  color: var(--muted);
  text-align: center;
  padding: 20px;
}

.badge {
  display: inline-block;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 13px;
}

.badge.active {
  color: var(--ok);
  background: #e9f7ef;
}

.badge.paused {
  color: var(--warn);
  background: #fff6d6;
}

.badge.terminated {
  color: var(--danger);
  background: #fff0ed;
}

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

.row-actions form {
  margin: 0;
}

.row-edit {
  display: grid;
  grid-template-columns: 110px 90px minmax(140px, 1fr) 64px;
  gap: 8px;
  min-width: 430px;
}

.account-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.account-actions form {
  margin: 0;
}

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

.stats div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfcfd;
}

.stats strong {
  display: block;
  font-size: 26px;
}

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

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

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

.login-panel h1 {
  text-align: center;
  margin-bottom: 22px;
}

@media (max-width: 760px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
    padding: 12px 16px;
  }

  .logout {
    width: 100%;
    justify-content: space-between;
  }

  .container {
    padding: 14px;
  }

  .section {
    padding: 16px;
  }

  .heading-row,
  .query-form,
  .inline-form {
    align-items: stretch;
    flex-direction: column;
  }

  .form-grid,
  .stats {
    grid-template-columns: 1fr;
  }

  .actions {
    width: 100%;
  }

  .actions .button {
    flex: 1;
  }

  .row-edit {
    grid-template-columns: 1fr;
    min-width: 220px;
  }

  .account-actions {
    align-items: stretch;
    flex-direction: column;
  }
}
