:root {
  --bg: #f6f3ec;
  --ink: #26231e;
  --muted: #756f66;
  --red: #b42318;
  --green: #13795b;
  --card: #fffdf8;
  --line: #e2d8c8;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at 20% 0%, #fff8dd, var(--bg) 42%, #eee5d8);
}

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

.phone { width: min(100%, 430px); }
.panel, .desk, .config {
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: 0 18px 50px rgba(54, 38, 19, .12);
  border-radius: 18px;
}

.panel { padding: 24px; }
.brand {
  font-size: 13px;
  color: var(--red);
  font-weight: 800;
  letter-spacing: .08em;
}
h1 { margin: 8px 0 8px; font-size: 30px; }
.muted { color: var(--muted); line-height: 1.6; }
.table-line {
  margin: 18px 0;
  padding: 12px 14px;
  border-radius: 12px;
  background: #f4ecdf;
}

.compass {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
button, .link-btn {
  border: 1px solid #cdbb9f;
  background: linear-gradient(#fff7e8, #ead9bb);
  color: var(--ink);
  border-radius: 12px;
  min-height: 48px;
  padding: 0 16px;
  font-size: 18px;
  font-weight: 800;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
button.active {
  border-color: var(--red);
  background: linear-gradient(#d94735, #a61f16);
  color: white;
}
.center {
  display: grid;
  place-items: center;
  min-height: 58px;
  border: 2px dashed #c8ad81;
  border-radius: 14px;
  color: #8a6a3f;
  font-weight: 900;
}
.quick {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 10px;
}
textarea {
  width: 100%;
  min-height: 78px;
  margin: 16px 0 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  font: inherit;
  resize: vertical;
}
.primary {
  width: 100%;
  color: white;
  border: 0;
  background: linear-gradient(#168b68, #0f654c);
}
.primary:disabled { opacity: .45; cursor: not-allowed; }
.result { margin-top: 12px; min-height: 24px; font-weight: 800; color: var(--green); }

.desk {
  width: min(960px, calc(100vw - 32px));
  margin: 22px auto;
  padding: 22px;
}
.desk-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}
.desk-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.desk-actions .link-btn {
  min-height: 42px;
  font-size: 15px;
}
.link-btn.ok {
  color: white;
  border-color: #0f654c;
  background: linear-gradient(#168b68, #0f654c);
}
.link-btn.danger {
  color: white;
  border-color: #8f1d13;
  background: linear-gradient(#cf3a2b, #9d2118);
}
.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 18px;
}
.stats div {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  background: #fbf4e8;
}
.stats b { display: block; font-size: 28px; }
.stats span { color: var(--muted); }
.alerts {
  display: grid;
  gap: 12px;
}
.alert-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-left: 8px solid var(--red);
  border-radius: 16px;
  background: white;
}
.alert-card.done {
  opacity: .58;
  border-left-color: var(--green);
}
.alert-title {
  font-size: 24px;
  font-weight: 900;
}
.alert-meta {
  margin-top: 8px;
  color: var(--muted);
}
.resolve {
  min-width: 112px;
  background: linear-gradient(#fff7e8, #ead9bb);
}
.alarm-banner {
  position: fixed;
  z-index: 20;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(120px);
  min-width: min(680px, calc(100vw - 28px));
  padding: 18px 24px;
  border-radius: 18px;
  color: white;
  background: linear-gradient(135deg, #d92d20, #7a120c);
  box-shadow: 0 18px 60px rgba(120, 18, 12, .38);
  text-align: center;
  font-size: 24px;
  font-weight: 900;
  opacity: 0;
  transition: transform .22s ease, opacity .22s ease;
}
.alarm-banner.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
body.alarm-active {
  animation: alarmPulse 1s infinite;
}
body.alarm-active .desk {
  border-color: #d92d20;
  box-shadow: 0 0 0 6px rgba(217, 45, 32, .16), 0 18px 50px rgba(54, 38, 19, .18);
}
body.alarm-active .stats div:first-child {
  background: #fff1ee;
  border-color: #d92d20;
}
body.alarm-active .stats div:first-child b {
  color: #b42318;
}

@keyframes alarmPulse {
  0%, 100% { background: radial-gradient(circle at 20% 0%, #fff8dd, var(--bg) 42%, #eee5d8); }
  50% { background: radial-gradient(circle at 20% 0%, #fff0e8, #ffe4dc 42%, #f4c7bc); }
}

.print-wrap {
  width: min(1100px, calc(100vw - 32px));
  margin: 24px auto;
}
.config {
  padding: 16px;
  margin-bottom: 18px;
}
.config label {
  display: block;
  font-weight: 900;
  margin-bottom: 8px;
}
.qr-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}
.qr-card {
  break-inside: avoid;
  padding: 18px;
  border: 2px solid #252018;
  border-radius: 14px;
  background: white;
  text-align: center;
}
.qr-card h2 { margin: 0 0 8px; font-size: 28px; }
.qr {
  width: 160px;
  height: 160px;
  margin: 0 auto 10px;
  display: grid;
  place-items: center;
  border: 1px solid #222;
  background: white;
}
.qr img { width: 150px; height: 150px; }
.url { font-size: 11px; word-break: break-all; color: var(--muted); }

@media print {
  body { background: white; }
  .no-print { display: none !important; }
  .print-wrap { width: auto; margin: 0; }
  .qr-grid { grid-template-columns: repeat(3, 1fr); gap: 10px; }
  .qr-card { box-shadow: none; }
}

@media (max-width: 640px) {
  h1 { font-size: 26px; }
  .stats { grid-template-columns: 1fr; }
  .alert-card { grid-template-columns: 1fr; }
}
