:root {
  --bg: #f4f7fb;
  --card: #ffffff;
  --ink: #1c2430;
  --muted: #5d6b7c;
  --line: #d9e2ec;
  --blue: #1f6feb;
  --blue-dark: #1657be;
  --danger: #c0362c;
  --ok: #137a45;
  --warn: #9a6700;
  --sidebar: 232px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: var(--bg);
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.app-header {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}
.app-header h1 { margin: 0; font-size: 20px; font-weight: 650; }
.header-actions, .building-switch { display: flex; gap: 12px; align-items: center; }
.layout { display: flex; min-height: calc(100vh - 64px); }
.sidebar {
  width: var(--sidebar);
  background: #fff;
  border-right: 1px solid var(--line);
  padding: 16px 12px;
}
.nav-btn {
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 6px;
  color: var(--ink);
}
.nav-btn.active { background: #e8f1ff; color: var(--blue); font-weight: 650; }
.content { flex: 1; padding: 20px 24px 40px; min-width: 0; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px;
  margin-bottom: 16px;
}
.card h2 { margin: 0 0 14px; font-size: 18px; }
.grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.required::after { content: " *"; color: var(--danger); }
input, select, textarea {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--ink);
  background: #fff;
  width: 100%;
}
.unit-field { display: flex; align-items: center; gap: 8px; }
.unit-field span { color: var(--muted); white-space: nowrap; }
.btn {
  border: 0;
  border-radius: 8px;
  padding: 8px 14px;
  background: var(--blue);
  color: #fff;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.btn.secondary { background: #e8eef6; color: var(--ink); }
.btn.danger { background: #fde8e6; color: var(--danger); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn.loading {
  position: relative;
  pointer-events: none;
}
.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(31, 111, 235, 0.25);
  border-top-color: var(--blue);
  border-radius: 50%;
  display: inline-block;
  animation: spin 0.8s linear infinite;
  flex: 0 0 auto;
}
.spinner.large {
  width: 28px;
  height: 28px;
  border-width: 3px;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
.busy-line {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 10px 0 0;
  color: var(--blue);
  font-size: 13px;
  font-weight: 600;
}
.result-card { position: relative; min-height: 180px; }
.loading-overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: rgba(255, 255, 255, 0.82);
  color: var(--blue);
  font-size: 14px;
  font-weight: 650;
  border-radius: 12px;
}
.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 10px;
  background: #eef2f6;
  font-size: 13px;
}
.badge.DRAFT { background: #fff6df; color: var(--warn); }
.badge.PENDING_PUBLISH { background: #e8f1ff; color: var(--blue); }
.badge.PUBLISHED { background: #e7f6ee; color: var(--ok); }
.badge.PUBLISH_FAILED { background: #fde8e6; color: var(--danger); }
.note { color: var(--muted); font-size: 13px; }
.error { color: var(--danger); font-size: 12px; min-height: 16px; }
.banner {
  padding: 10px 12px;
  border-radius: 8px;
  background: #fff6df;
  color: var(--warn);
  margin-bottom: 12px;
}
.banner.error { background: #fde8e6; color: var(--danger); font-size: 14px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { border-bottom: 1px solid var(--line); padding: 8px; text-align: left; vertical-align: top; }
th { color: var(--muted); font-weight: 600; }
.table-wrap { overflow-x: auto; }
.hidden { display: none; }
details { margin-top: 8px; }
summary { cursor: pointer; font-weight: 650; margin-bottom: 12px; }
.modal {
  position: fixed;
  inset: 0;
  background: rgba(20, 28, 38, 0.35);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 48px 16px;
}
.modal.hidden { display: none; }
.modal-card { width: min(860px, 100%); max-height: calc(100vh - 80px); overflow: auto; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.stat { background: #f8fafc; border-radius: 10px; padding: 12px; }
.stat b { display: block; font-size: 22px; margin-top: 4px; }
.empty { padding: 28px; text-align: center; color: var(--muted); }
@media (max-width: 1366px) {
  .grid, .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sidebar { width: 200px; }
}
@media (max-width: 900px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; display: flex; gap: 6px; overflow-x: auto; }
  .nav-btn { width: auto; white-space: nowrap; }
  .app-header { height: auto; flex-wrap: wrap; gap: 10px; padding: 12px; }
  .grid, .stats, .grid.two, .grid.three { grid-template-columns: 1fr; }
}
