:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #17202a;
  --muted: #667085;
  --line: #d9dee7;
  --brand: #0f766e;
  --brand-strong: #0b5f59;
  --soft: #e6f4f1;
  --warn: #b45309;
  --danger: #b42318;
  --ok: #16803c;
  --shadow: 0 10px 30px rgba(15, 23, 42, .08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
}

.hidden { display: none !important; }

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

button {
  border: 0;
  border-radius: 8px;
  padding: 10px 14px;
  cursor: pointer;
  white-space: nowrap;
}

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

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

.ghost {
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 24px;
  background: rgba(255, 255, 255, .94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--brand);
  font-weight: 700;
}

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

h1 {
  margin-bottom: 0;
  font-size: 24px;
}

h2 { font-size: 18px; }
h3 { font-size: 16px; }

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

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

.login-card {
  width: min(420px, 100%);
  padding: 28px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.login-card label {
  display: grid;
  gap: 8px;
  margin: 14px 0;
  color: var(--muted);
}

.login-card input,
.login-card select {
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
}

.login-card button {
  width: 100%;
  margin-top: 8px;
}

.error {
  min-height: 22px;
  margin: 12px 0 0;
  color: var(--danger);
}

.user-pill {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 10px;
  border-radius: 999px;
  color: var(--brand-strong);
  background: var(--soft);
  font-size: 13px;
  font-weight: 700;
}

main {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 20px;
}

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

.stat {
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.stat b {
  display: block;
  margin-top: 6px;
  font-size: 28px;
}

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

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin: 16px 0;
}

.search {
  flex: 1 1 280px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  min-height: 42px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.search span {
  color: var(--muted);
  font-size: 14px;
}

.search input {
  width: 100%;
  border: 0;
  outline: 0;
}

select, input, textarea {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

select {
  min-height: 42px;
  padding: 0 12px;
}

.layout {
  display: grid;
  grid-template-columns: 420px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.panel, .detail {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

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

.panel-head h2 { margin: 0; }
.panel-head span { color: var(--muted); }

.customer-list {
  max-height: calc(100vh - 220px);
  min-height: 560px;
  overflow: auto;
}

.building-group {
  border-bottom: 1px solid var(--line);
}

.building-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 12px 16px;
  border-radius: 0;
  background: #f8fafc;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  font-weight: 700;
}

.customer {
  display: grid;
  gap: 6px;
  width: 100%;
  padding: 14px 16px;
  text-align: left;
  background: #fff;
  border-radius: 0;
  border-bottom: 1px solid var(--line);
}

.customer.active {
  background: var(--soft);
  border-left: 4px solid var(--brand);
}

.customer-title {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-weight: 700;
}

.customer-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.badge {
  display: inline-flex;
  align-items: center;
  width: max-content;
  min-height: 24px;
  padding: 2px 8px;
  border-radius: 999px;
  color: var(--brand-strong);
  background: var(--soft);
  font-size: 12px;
  font-weight: 700;
}

.badge.warn { color: var(--warn); background: #fff3e0; }
.badge.danger { color: var(--danger); background: #fee4e2; }
.badge.ok { color: var(--ok); background: #e8f5ec; }

.detail {
  min-height: 560px;
  padding: 18px;
}

.empty {
  display: grid;
  place-items: center;
  min-height: 420px;
  color: var(--muted);
}

.empty.small {
  min-height: 180px;
}

.detail-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 16px;
}

.detail-head h2 {
  margin-bottom: 6px;
  font-size: 24px;
}

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

.info {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.info span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
}

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

.step {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.step h3 { margin-bottom: 12px; }

.field {
  display: grid;
  gap: 6px;
  margin-bottom: 10px;
}

.field label {
  color: var(--muted);
  font-size: 13px;
}

.field input, .field select, .field textarea {
  width: 100%;
  padding: 10px;
}

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

.quick button {
  background: var(--soft);
  color: var(--brand-strong);
}

.quick button.danger {
  background: #fee4e2;
  color: var(--danger);
}

.timeline {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.timeline ul {
  margin: 0;
  padding-left: 18px;
}

.timeline li {
  margin-bottom: 8px;
  color: var(--muted);
}

dialog {
  width: min(720px, calc(100% - 24px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  box-shadow: var(--shadow);
}

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

.modal { padding: 18px; }

.modal-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.icon-btn {
  width: 36px;
  height: 36px;
  padding: 0;
  font-size: 24px;
  background: #fff;
  border: 1px solid var(--line);
}

.hint {
  color: var(--muted);
  line-height: 1.6;
}

.modal input, .modal textarea {
  width: 100%;
  margin-top: 10px;
  padding: 10px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 12px;
}

@media (max-width: 980px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .layout { grid-template-columns: 1fr; }
  .customer-list { max-height: 620px; min-height: 360px; }
  .workflow { grid-template-columns: 1fr; }
  .info-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 620px) {
  .topbar {
    position: static;
    align-items: stretch;
    flex-direction: column;
    padding: 16px;
  }

  .top-actions { width: 100%; }
  .top-actions button { flex: 1; }
  main { padding: 12px; }
  .stats { grid-template-columns: 1fr; }
  .toolbar > select, .toolbar > button { flex: 1 1 160px; }
  .detail-head { flex-direction: column; }
  .info-grid { grid-template-columns: 1fr; }
}
