:root {
  color-scheme: light;
  --bg: #f3f6f4;
  --surface: #ffffff;
  --text: #17231c;
  --muted: #66736b;
  --line: #dce5df;
  --green: #17824b;
  --green-dark: #0e6237;
  --green-soft: #e8f6ee;
  --red: #b83232;
  --red-soft: #fff0f0;
  --amber: #95620a;
  --amber-soft: #fff6db;
  --shadow: 0 18px 48px rgba(22, 52, 35, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Microsoft YaHei UI", "PingFang SC", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 10% 0%, #dff3e8 0, transparent 28rem),
    var(--bg);
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 40px;
  padding: 0 18px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  background: #fff;
  cursor: pointer;
  transition: 150ms ease;
}

button:hover {
  transform: translateY(-1px);
  border-color: #adc3b5;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none;
}

button.primary {
  color: #fff;
  border-color: var(--green);
  background: var(--green);
  font-weight: 700;
}

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

.page {
  width: min(1440px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0 60px;
}

.hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 10px 4px 24px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--green);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 8px;
  font-size: clamp(28px, 4vw, 42px);
  letter-spacing: -0.04em;
}

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

.sub,
.section-title p,
.message {
  color: var(--muted);
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 14px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 800;
  white-space: nowrap;
}

.badge-ok {
  color: var(--green-dark);
  background: var(--green-soft);
}

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

.badge-off {
  color: var(--red);
  background: var(--red-soft);
}

.card {
  margin-bottom: 18px;
  padding: 24px;
  border: 1px solid rgba(210, 224, 215, 0.9);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.section-title,
.actions-title,
.row,
.form-grid {
  display: flex;
  align-items: end;
  gap: 14px;
}

.section-title,
.actions-title {
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.section-title p {
  margin-bottom: 0;
  font-size: 14px;
}

label {
  display: flex;
  min-width: 160px;
  flex-direction: column;
  gap: 8px;
  color: #35443b;
  font-size: 14px;
  font-weight: 700;
}

.grow {
  flex: 1;
}

.grow-two {
  flex: 2;
}

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

input:focus,
select:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(23, 130, 75, 0.12);
}

.message {
  min-height: 22px;
  margin: 14px 0 0;
  font-size: 14px;
}

.message.error {
  color: var(--red);
}

.message.success {
  color: var(--green-dark);
}

.created-result {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  margin-top: 18px;
  padding: 16px;
  border: 1px dashed #8fcaa8;
  border-radius: 12px;
  background: var(--green-soft);
}

.created-result code {
  overflow-wrap: anywhere;
  color: var(--green-dark);
  font-size: 18px;
  font-weight: 800;
}

.hidden {
  display: none;
}

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

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

.stat-card {
  display: grid;
  gap: 8px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f8faf9;
}

.stat-card span {
  color: var(--muted);
  font-size: 13px;
}

.stat-card strong {
  color: var(--green-dark);
  font-size: 24px;
}

.config-grid label {
  display: grid;
  gap: 7px;
}

.config-grid textarea {
  width: 100%;
  min-height: 150px;
  resize: vertical;
  font: inherit;
}

.config-actions {
  justify-content: flex-end;
  margin-top: 16px;
}

.update-settings {
  margin-top: 22px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #f8faf9;
}

.subsection-title {
  margin-bottom: 16px;
}

.subsection-title h3 {
  margin: 0 0 6px;
  font-size: 17px;
}

.subsection-title p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

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

.update-grid .span-two {
  grid-column: 1 / -1;
}

.update-grid textarea {
  width: 100%;
  min-height: 110px;
  resize: vertical;
  font: inherit;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

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

th {
  color: var(--muted);
  font-weight: 800;
  background: #f8faf9;
}

td.note-cell {
  min-width: 160px;
  max-width: 260px;
  white-space: normal;
}

.status-on,
.status-off {
  font-weight: 800;
}

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

.status-off {
  color: var(--red);
}

.action-buttons {
  display: flex;
  min-width: 330px;
  flex-wrap: wrap;
  gap: 6px;
}

.action-buttons button {
  min-height: 32px;
  padding: 0 10px;
  border-radius: 8px;
  font-size: 12px;
}

.danger {
  color: var(--red);
  border-color: #efbbbb;
  background: var(--red-soft);
}

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

.event-list {
  display: grid;
  gap: 10px;
}

.event-item {
  display: grid;
  grid-template-columns: 180px 130px minmax(180px, 1fr) 150px;
  gap: 14px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 13px;
}

.event-item strong {
  color: var(--green-dark);
}

@media (max-width: 900px) {
  .page {
    width: min(100% - 20px, 1440px);
    padding-top: 18px;
  }

  .card {
    padding: 18px;
  }

  .form-grid,
  .auth-row,
  .section-title {
    align-items: stretch;
    flex-direction: column;
  }

  .form-grid button,
  .auth-row button {
    width: 100%;
  }

  .event-item {
    grid-template-columns: 1fr;
    gap: 5px;
  }

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

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

  .update-grid .span-two {
    grid-column: auto;
  }
}
