:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --line: #dfe5ec;
  --text: #202932;
  --muted: #657384;
  --primary: #2563eb;
  --success: #138a48;
  --danger: #c24135;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 248px 1fr;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
}

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

body.locked .sidebar,
body.locked .workspace {
  display: none;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  border-radius: 6px;
  padding: 9px 14px;
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  font-weight: 700;
}

.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  border-radius: 6px;
  padding: 9px 14px;
  text-decoration: none;
  font-weight: 700;
}

.ghost {
  background: #eef2f7;
  color: var(--text);
}

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

.danger-light {
  background: #fee2e2;
  color: var(--danger);
}

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: none;
  place-items: center;
  padding: 20px;
  background: linear-gradient(135deg, #17202a 0%, #223449 55%, #f4f6f8 55%, #f4f6f8 100%);
}

body.locked .login-screen {
  display: grid;
}

.login-card {
  width: min(420px, 100%);
  display: grid;
  gap: 14px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 24px 80px rgba(15, 23, 42, 0.22);
}

.login-card .mark {
  margin-bottom: 4px;
}

.login-card h1 {
  color: var(--text);
  font-size: 24px;
}

.login-card p {
  color: var(--muted);
}

.login-error {
  min-height: 20px;
  color: var(--danger);
  font-size: 13px;
  font-weight: 700;
}

.logout {
  white-space: nowrap;
}

.sidebar {
  min-height: 100vh;
  padding: 22px 16px;
  background: #17202a;
  color: #fff;
}

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

.mark {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: #f1bd55;
  color: #432110;
  display: grid;
  place-items: center;
  font-weight: 900;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 18px;
}

.brand p {
  margin-top: 4px;
  color: #a8b3c2;
  font-size: 13px;
}

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

.nav {
  width: 100%;
  text-align: left;
  background: transparent;
  color: #cbd5e1;
}

.nav.active,
.nav:hover {
  background: #243241;
  color: #fff;
}

.workspace {
  padding: 24px;
  min-width: 0;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
}

.eyebrow {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

h2 {
  margin-top: 4px;
  font-size: 26px;
}

.status {
  padding: 8px 12px;
  border-radius: 999px;
  background: #eef2f7;
  color: var(--muted);
  font-weight: 800;
}

.status.online {
  background: #dcfce7;
  color: var(--success);
}

.view {
  display: none;
}

.view.active {
  display: grid;
  gap: 18px;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 14px;
}

.metric,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 26px rgba(18, 31, 43, 0.04);
}

.metric {
  padding: 18px;
}

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

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

.panel {
  overflow: hidden;
}

.panel.narrow {
  max-width: 720px;
}

.panel-head {
  min-height: 58px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

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

table {
  width: 100%;
  border-collapse: collapse;
}

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

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

.pill {
  display: inline-flex;
  padding: 4px 8px;
  border-radius: 999px;
  background: #eef2f7;
  color: var(--muted);
  font-weight: 800;
  font-size: 12px;
}

.pill.on,
.pill.done {
  background: #dcfce7;
  color: var(--success);
}

.pill.off,
.pill.cancel {
  background: #fee2e2;
  color: var(--danger);
}

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

.row-actions button {
  padding: 7px 10px;
}

.row-actions select {
  min-width: 116px;
}

.log-list {
  padding: 8px 16px 16px;
}

.log-item {
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
}

.log-item:last-child {
  border-bottom: 0;
}

.log-item strong {
  display: block;
}

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

.form-grid,
dialog form {
  display: grid;
  gap: 14px;
  padding: 18px;
}

#categoryForm {
  padding: 16px;
}

.category-editor {
  display: grid;
  gap: 10px;
}

.category-row {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) minmax(160px, 1.3fr) auto;
  align-items: end;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.form-actions {
  margin-top: 14px;
}

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

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

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 12px;
  padding: 16px;
}

.settings-grid div {
  display: grid;
  gap: 6px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.settings-grid span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.settings-grid strong {
  overflow-wrap: anywhere;
}

.danger-zone {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  padding: 16px;
}

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

  .sidebar {
    min-height: auto;
  }

  .metrics,
  .settings-grid,
  .category-row {
    grid-template-columns: 1fr;
  }
}

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

dialog {
  width: min(520px, calc(100vw - 32px));
  border: 0;
  border-radius: 8px;
  box-shadow: 0 24px 80px rgba(15, 23, 42, 0.28);
}

dialog::backdrop {
  background: rgba(15, 23, 42, 0.32);
}

menu {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 0;
  margin: 4px 0 0;
}

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

  .sidebar {
    min-height: auto;
  }

  nav,
  .metrics,
  .settings-grid {
    grid-template-columns: 1fr;
  }
}
