:root {
  --bg: #f2f6f8;
  --panel: #ffffff;
  --ink: #112332;
  --muted: #5e6f7e;
  --line: #d4dde5;
  --brand: #0f766e;
  --brand-strong: #0b5e58;
  --danger: #b42318;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 5% 0%, #d9f2ea 0, transparent 45%),
    radial-gradient(circle at 90% 100%, #d8ebfa 0, transparent 40%),
    var(--bg);
  font-family: "Source Han Sans SC", "Noto Sans SC", sans-serif;
}

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

.layout {
  width: min(1280px, 94vw);
  margin: 20px auto;
  display: grid;
  gap: 18px;
}

.layout.single {
  width: min(760px, 94vw);
}

.topbar {
  width: min(1280px, 94vw);
  margin: 16px auto 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

h1,
h2 {
  margin: 0 0 12px;
}

p {
  margin: 6px 0;
}

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

.tip {
  margin-top: 10px;
  font-size: 13px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 10px 24px rgba(12, 27, 41, 0.06);
  padding: 18px;
}

.login-card {
  width: min(420px, 94vw);
}

.stack {
  display: grid;
  gap: 10px;
}

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

.lunar-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px;
}

label {
  display: grid;
  gap: 6px;
  font-size: 14px;
}

input,
select,
button,
a.mini,
a.ghost {
  border-radius: 8px;
  border: 1px solid var(--line);
  font-size: 14px;
}

input,
select {
  padding: 9px 10px;
  background: #fff;
}

button,
a.mini,
a.ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  cursor: pointer;
  text-decoration: none;
  color: #fff;
  background: var(--brand);
}

button:hover,
a.mini:hover {
  background: var(--brand-strong);
}

button.ghost,
a.ghost {
  color: var(--ink);
  background: #fff;
}

.danger {
  background: var(--danger);
}

.danger:hover {
  background: #8f1c13;
}

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

.actions-bar {
  display: flex;
  gap: 10px;
}

.notice {
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 10px;
  font-size: 14px;
}

.notice.success {
  background: #def7ec;
  border: 1px solid #84e1bc;
}

.notice.error {
  background: #fde8e8;
  border: 1px solid #f8b4b4;
}

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

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

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

th {
  background: #f6fafc;
  font-weight: 600;
}

.pill {
  border-radius: 99px;
  padding: 2px 10px;
  font-size: 12px;
  line-height: 1.8;
}

.pill.on {
  background: #ecfdf3;
  border: 1px solid #84e1bc;
}

.pill.off {
  background: #f3f4f6;
  border: 1px solid #d1d5db;
}

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

.actions form {
  margin: 0;
}

.mini {
  padding: 5px 8px;
  font-size: 12px;
}

.checkbox {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.hidden {
  display: none;
}

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

@media (max-width: 900px) {
  .layout {
    margin: 14px auto;
    gap: 12px;
  }

  .card {
    padding: 14px;
    border-radius: 12px;
  }

  .topbar {
    display: grid;
    justify-content: stretch;
    margin-top: 12px;
    gap: 8px;
  }

  .topbar form {
    justify-self: start;
  }

  .topbar button {
    min-height: 36px;
  }

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

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

  .actions-bar {
    flex-direction: column;
  }

  .actions-bar > * {
    width: 100%;
  }

  .table-wrap {
    overflow: visible;
  }

  table {
    min-width: 0;
    border-collapse: separate;
    border-spacing: 0;
  }

  thead {
    display: none;
  }

  tbody {
    display: grid;
    gap: 10px;
  }

  tbody tr {
    display: block;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 6px 10px;
  }

  tbody td {
    display: grid;
    grid-template-columns: 82px 1fr;
    gap: 8px;
    align-items: start;
    border-bottom: 1px dashed #dbe5ed;
    padding: 8px 0;
    font-size: 13px;
  }

  tbody td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 12px;
    line-height: 1.4;
  }

  tbody td:last-child {
    border-bottom: 0;
  }

  td.actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    padding-top: 10px;
  }

  td.actions::before {
    content: none;
  }

  td.empty {
    display: block;
    border-bottom: 0;
    text-align: center;
    padding: 10px 0;
  }

  td.empty::before {
    content: none;
  }
}
