:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-soft: #f9fafb;
  --text: #1f2328;
  --muted: #626a73;
  --line: #d9dee5;
  --brand: #c5161d;
  --brand-strong: #9f1118;
  --focus: #1b6fba;
  --success: #176a45;
  --warning: #8a5a00;
  --danger: #a51d2d;
  --radius: 8px;
  --shadow: 0 10px 26px rgba(16, 24, 40, 0.08);
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  display: grid;
  grid-template-columns: 248px 1fr;
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
a.link-button {
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 0 14px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(27, 111, 186, 0.28);
  outline-offset: 2px;
}

.sidebar {
  min-height: 100vh;
  background: #20242b;
  color: #fff;
  padding: 22px 18px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: var(--brand);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 800;
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  color: #cfd5dd;
  margin-top: 3px;
}

nav {
  display: grid;
  gap: 8px;
}

nav button {
  width: 100%;
  justify-content: flex-start;
  background: transparent;
  color: #d8dde5;
  border-color: transparent;
}

nav button.active,
nav button:hover {
  background: #fff;
  color: var(--text);
}

.auth-box,
.operator {
  margin-top: auto;
  display: grid;
  gap: 8px;
  color: #d8dde5;
}

.operator {
  margin-top: 0;
}

.auth-box input,
.operator input {
  width: 100%;
  min-height: 42px;
  border: 1px solid #454b55;
  border-radius: 6px;
  background: #11151b;
  color: #fff;
  padding: 0 10px;
}

.auth-box .dark {
  background: #2f3540;
  color: #fff;
  border-color: #454b55;
}

.auth-box small {
  color: #cfd5dd;
  line-height: 1.4;
}

main {
  min-width: 0;
  padding: 24px;
}

.topbar {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.kicker {
  margin: 0 0 5px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

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

h1 {
  font-size: 26px;
}

h2 {
  font-size: 17px;
}

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

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

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

.secondary {
  background: #fff;
  color: var(--text);
  border-color: var(--line);
}

.secondary:hover {
  border-color: #aab3bf;
}

.danger {
  color: var(--danger);
  border-color: #efb8bf;
  background: #fff6f7;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.metric {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}

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

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 28px;
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(360px, 0.75fr);
  gap: 16px;
  align-items: start;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 16px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.inline-head {
  margin-top: 18px;
}

.panel-head h3 {
  margin: 0;
  font-size: 15px;
}

.panel-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}

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

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

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

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

td {
  font-size: 14px;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  border: 1px solid var(--line);
}

.status.ok {
  color: var(--success);
  background: #edf8f1;
  border-color: #b8dec7;
}

.status.warn {
  color: var(--warning);
  background: #fff7e5;
  border-color: #ead19a;
}

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

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

.compact-filter {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 14px;
}

.muted-text {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

label,
fieldset {
  min-width: 0;
}

label span,
legend {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 10px;
  color: var(--text);
  background: #fff;
}

textarea {
  resize: vertical;
  line-height: 1.5;
}

.full {
  grid-column: 1 / -1;
}

.checkbox-row {
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.checkbox-row input {
  width: 18px;
  min-height: 18px;
}

.checkbox-row span {
  margin: 0;
}

.schedule-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

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

.json-preview {
  min-height: 180px;
  max-height: 420px;
  overflow: auto;
  background: #11151b;
  color: #e6edf3;
  border-radius: 8px;
  padding: 14px;
  line-height: 1.5;
}

.safety-list,
.log-list,
.member-reminders {
  display: grid;
  gap: 10px;
}

.member-reminders {
  margin-bottom: 14px;
}

.list-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--surface-soft);
}

.list-item strong {
  display: block;
  margin-bottom: 5px;
}

.inline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 20;
  background: #11151b;
  color: #fff;
  border-radius: 8px;
  padding: 12px 14px;
  box-shadow: var(--shadow);
}

@media (max-width: 980px) {
  body {
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-height: auto;
  }

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

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

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 640px) {
  main {
    padding: 16px;
  }

  .form-grid,
  .schedule-grid,
  .compact-filter {
    grid-template-columns: 1fr;
  }

  table {
    min-width: 620px;
  }
}
