:root {
  --ink: #3c2f34;
  --muted: #8a7480;
  --faint: #b7a3ab;
  --line: #f0e3e7;
  --line-soft: #f7eef1;
  --paper: #f7f2f4;
  --card: #fff;
  --accent: #c45c78;
  --accent-dark: #a84664;
  --accent-soft: #fff1f4;
  --ok: #3d8b66;
  --err: #c44b5a;
  --shadow: 0 1px 2px rgba(90, 40, 55, .04), 0 6px 18px rgba(120, 60, 80, .05);
  --radius: 8px;
  --box: 168px;
  --box-h: 32px;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; overflow: hidden; }
body {
  color: var(--ink);
  background: var(--paper);
  font: 14px/1.5 "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-dark); }
button, input, select, textarea { font: inherit; color: inherit; }

.shell { display: flex; height: 100%; min-width: 0; overflow: hidden; }
.side {
  width: 188px;
  flex: none;
  height: 100%;
  background: #fff;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.brand { padding: 14px 14px 10px; }
.brand strong {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
}
.brand strong::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: linear-gradient(135deg, #f4a8bb, #c45c78);
  box-shadow: 0 0 0 3px #fff1f4;
  flex: none;
}
.brand span { display: block; margin: 4px 0 0 17px; color: var(--faint); font-size: 11px; }
.side nav { display: flex; flex-direction: column; padding: 4px 8px 12px; gap: 2px; overflow-y: auto; overflow-x: hidden; }
.side nav a {
  color: #5c4a52;
  padding: 7px 10px;
  border-radius: 8px;
  font-size: 14px;
}
.side nav a.on { color: var(--accent-dark); background: var(--accent-soft); font-weight: 600; }
.side nav a:hover { color: var(--accent); background: #fff7f8; }

.main { flex: 1; min-width: 0; height: 100%; display: flex; flex-direction: column; overflow: hidden; background: var(--paper); }
.top {
  flex: none;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: rgba(255, 255, 255, .92);
  border-bottom: 1px solid var(--line);
}
.top h1 { margin: 0; font-size: 16px; font-weight: 600; color: var(--ink); }
.who { display: flex; gap: 10px; align-items: center; color: var(--muted); font-size: 13px; }
.who em { font-style: normal; color: var(--faint); }
.who a { color: #6d5862; padding: 3px 8px; border-radius: 999px; background: #fff; border: 1px solid var(--line); }
.who a:hover { color: var(--accent); border-color: #f0c9d3; background: var(--accent-soft); }
.content { flex: 1; min-width: 0; min-height: 0; overflow-x: hidden; overflow-y: auto; padding: 14px 18px 20px; }
.content > * { max-width: 100%; margin-left: 0; margin-right: 0; }

.msg { padding: 7px 12px; margin: 0 0 10px; background: #f3faf6; color: var(--ok); border: 1px solid #d7efe3; border-radius: 8px; font-size: 12px; }
.msg.err { background: #fff4f5; color: var(--err); border-color: #f6d4d8; }

.toolbar {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
  margin: 0 0 8px;
  padding: 6px 8px;
  min-height: 38px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.toolbar form, .search { display: flex; gap: 6px; align-items: center; margin: 0; }
.toolbar a:not(.btn) {
  display: inline-flex;
  align-items: center;
  height: var(--box-h);
  padding: 0 10px;
  background: #fff7f8;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: #5c4a52;
  font-size: 13px;
}
.toolbar a:not(.btn):hover, .toolbar a.on:not(.btn) { color: var(--accent-dark); border-color: #f0c9d3; background: var(--accent-soft); }

.btn, button.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: var(--box-h);
  padding: 0 12px;
  background: linear-gradient(180deg, #d36d88, #c45c78);
  color: #fff;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  line-height: 1;
  font-size: 13px;
  box-shadow: 0 1px 0 rgba(255, 255, 255, .35) inset;
}
.btn:hover, button.btn:hover { background: var(--accent-dark); color: #fff; text-decoration: none; }
.btn.ghost, button.ghost { background: #fff; color: #5c4a52; border: 1px solid var(--line); box-shadow: none; }
.btn.ghost:hover, button.ghost:hover { color: var(--accent); border-color: #f0c9d3; background: var(--accent-soft); }
.btn.small, button.small { height: 28px; padding: 0 10px; font-size: 13px; }
a.btn { text-decoration: none; }
form.inline { display: inline-flex; align-items: center; margin: 0 6px 10px 0; vertical-align: middle; }
form.inline button { width: auto; }
.content > form:not(.inline) { margin: 0 0 8px; }
.content > a.btn { margin: 0 6px 8px 0; }

.table-wrap { width: 100%; max-width: 100%; overflow-x: auto; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); margin: 0 0 8px; }
.table-wrap:has(+ .pager) { margin-bottom: 0; border-bottom: 0; border-radius: var(--radius) var(--radius) 0 0; }
.grid { width: 100%; border-collapse: collapse; background: #fff; font-size: 13px; }
.grid th, .grid td { border-bottom: 1px solid var(--line-soft); padding: 8px 10px; text-align: left; vertical-align: middle; word-break: break-word; font-variant-numeric: tabular-nums; }
.grid thead th { background: #fbf7f8; color: #8a7480; font-weight: 500; font-size: 13px; white-space: nowrap; }
.grid tbody th { width: 108px; background: #fbf7f8; color: #8a7480; font-weight: 400; white-space: nowrap; }
.grid tbody tr:last-child td, .grid tbody tr:last-child th { border-bottom: 0; }
.grid tbody tr:hover td { background: #fff8f9; }
.grid input, .grid select { width: 64px; height: 28px; padding: 0 6px; border: 1px solid #eadde1; border-radius: 6px; background: #fff; }
.grid input + input { margin-left: 4px; }
.grid input[name^="abnormal"] { width: 120px; }
.grid input[type="checkbox"] { width: 14px; height: 14px; padding: 0; }
.grid td a { color: var(--accent); white-space: nowrap; }
.kv tbody { display: grid; grid-template-columns: 1fr 1fr; }
.kv tr { display: grid; grid-template-columns: 108px minmax(0, 1fr); min-height: 36px; border-bottom: 1px solid var(--line-soft); border-right: 1px solid var(--line-soft); }
.kv tr:nth-child(2n) { border-right: 0; }
.kv tr:last-child:nth-child(odd) { grid-column: 1 / -1; border-right: 0; }
.kv th, .kv td { display: flex; align-items: center; border: 0; min-width: 0; }
.kv tbody tr:hover td { background: transparent; }

.pager {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 8px;
  padding: 6px 8px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.table-wrap:has(+ .pager) + .pager { margin-top: 0; border-top: 1px solid var(--line-soft); border-radius: 0 0 var(--radius) var(--radius); }
.pager-sum { margin-right: auto; color: var(--faint); font-size: 13px; }
.pager .num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  height: 30px;
  padding: 0 10px;
  border: 1px solid #f0e3e7;
  border-radius: 8px;
  background: #fff;
  color: #8a7480;
  font-size: 13px;
  line-height: 1;
  text-decoration: none;
}
.pager a.num:hover { color: var(--accent); border-color: #f0c9d3; background: var(--accent-soft); }
.pager .num.current { background: var(--accent); border-color: var(--accent); color: #fff; }
.pager .num.disabled { color: #cbbbc2; border-color: #f3eaed; background: #fff; cursor: default; }
.pager .gap { color: #cbbbc2; min-width: 16px; text-align: center; font-size: 12px; }

.form {
  display: grid;
  grid-template-columns: repeat(auto-fill, var(--box));
  gap: 8px 10px;
  align-items: start;
  justify-content: start;
  width: 100%;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 10px 0;
  margin: 0;
}
.field { display: flex; flex-direction: column; gap: 3px; width: var(--box); min-width: 0; }
.field.wide, .actions { grid-column: 1 / -1; width: 100%; }
.field span { min-height: 18px; line-height: 18px; color: #7d6872; font-size: 13px; }
.field input, .field select, .field textarea, .login-card input, .toolbar input, .toolbar select, .search input {
  width: 100%;
  height: var(--box-h);
  color: var(--ink);
  border: 1px solid #eadde1;
  background: #fff;
  padding: 0 8px;
  border-radius: 6px;
  outline: none;
  font-size: 13px;
}
.toolbar input, .toolbar select, .search input { width: var(--box); }
.field.wide textarea, .field.wide input[type="file"] { width: calc(var(--box) * 2 + 10px); max-width: 100%; }
.field textarea { height: auto; min-height: 72px; padding: 8px 10px; resize: vertical; }
.field input[type="file"] { height: auto; padding: 4px 6px; }
.field input:focus, .field select:focus, .field textarea:focus, .toolbar input:focus, .toolbar select:focus, .search input:focus, .login-card input:focus, .grid input:focus, .grid select:focus {
  border-color: #e7a8b8;
  box-shadow: 0 0 0 3px rgba(196, 92, 120, .12);
}
input[type="checkbox"] { width: 14px; height: 14px; padding: 0; accent-color: #c45c78; }
.actions {
  display: flex;
  gap: 6px;
  align-items: center;
  margin: 2px -10px 0;
  padding: 8px 10px;
  border-top: 1px solid var(--line-soft);
  background: #fcf8f9;
  border-radius: 0 0 var(--radius) var(--radius);
}

.badge { display: inline-block; padding: 0 8px; background: #f7f1f3; color: #6d5862; font-size: 12px; line-height: 20px; border-radius: 999px; }
.badge.b-ok { color: #2f7a56; background: #eef8f3; }
.badge.b-wait { color: #b45374; background: #fff1f4; }
.badge.b-bad { color: #c44b5a; background: #fff1f2; }
.muted, .note { color: var(--muted); }
.note { font-size: 13px; }

.cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin: 0 0 8px; align-items: stretch; }
.card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 64px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 10px;
  font-size: 13px;
  color: var(--muted);
}
.content > .card { margin: 0 0 8px; }
.card b { display: block; font-size: 20px; font-weight: 600; margin-top: 4px; color: var(--ink); }
.card p, .card .note { margin: 4px 0 0; padding: 0; background: transparent; border: 0; }
.section {
  margin: 0 0 8px;
  padding: 10px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.section > h2 { margin: 0 0 8px; }
.section .form { margin-bottom: 8px; }
.records { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.record { padding: 8px 10px; background: #fbf7f8; border-radius: 8px; }
.record strong { display: block; margin-bottom: 4px; font-size: 13px; }
.record p { margin: 0; color: var(--muted); }
.bars { display: flex; align-items: flex-end; justify-content: flex-start; gap: 18px; height: 168px; padding: 4px 4px 0; }
.bar { flex: 1; max-width: 72px; min-width: 0; height: 100%; display: flex; flex-direction: column; align-items: center; }
.bar-num { flex: none; height: 18px; font-size: 13px; font-weight: 600; color: var(--ink); }
.bar-track { flex: 1; width: 28px; display: flex; align-items: flex-end; background: #f6e8ec; border-radius: 8px 8px 3px 3px; overflow: hidden; }
.bar-fill { width: 100%; height: 0; background: linear-gradient(180deg, #e7a0b4, #c45c78); border-radius: 8px 8px 0 0; }
.bar-name { flex: none; margin-top: 6px; max-width: 100%; font-size: 12px; line-height: 1.3; text-align: center; color: var(--muted); word-break: break-all; }
.section .pager { margin: 6px 0 0; border: 0; padding: 6px 0 0; border-top: 1px solid var(--line-soft); border-radius: 0; }
h2, h3 { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: 8px 0 6px; padding: 0; font-weight: 600; color: var(--ink); background: none; border: 0; }
h2 { font-size: 15px; }
h3 { font-size: 14px; }
h2 .badge, h3 .badge { flex: none; }
.content > h2:first-child, .content > .toolbar + h2, .content > .cards + h2, .content > .msg + h2 { margin-top: 0; }
p { margin: 0 0 8px; font-size: 13px; line-height: 1.5; }
.content > .note {
  margin: 0 0 8px;
  padding: 6px 8px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.todo { margin: 0; padding: 0; list-style: none; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.section .todo { border: 0; border-radius: 0; }
.todo li { padding: 8px 10px; border-bottom: 1px solid var(--line-soft); font-size: 13px; }
.todo li:last-child { border-bottom: 0; }
.checks { display: flex; flex-wrap: wrap; gap: 4px 12px; }
.checks label { display: flex; gap: 4px; align-items: center; color: #5c4a52; font-size: 13px; }
.checks input { width: 14px; height: 14px; }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; align-items: start; margin: 0 0 8px; }
.split > div { min-width: 0; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; }
.split h2:first-child { margin-top: 0; }
.split .form { border: 0; padding: 0; background: transparent; }
.split .actions { margin: 6px 0 0; padding: 0; border: 0; background: transparent; border-radius: 0; }
form > p { margin: 6px 0 0; }

.ai-dock { position: fixed; right: 22px; bottom: 22px; z-index: 30; }
.chat {
  display: none;
  position: absolute;
  right: 0;
  bottom: 78px;
  width: 340px;
  height: 480px;
  max-height: calc(100vh - 120px);
  flex-direction: column;
  background: #fffdfd;
  border: 1px solid #f3e4e8;
  border-radius: 18px;
  box-shadow: 0 16px 40px rgba(120, 60, 80, .16);
  overflow: hidden;
}
.ai-dock.open .chat { display: flex; }
.ai-fab {
  width: 68px;
  height: 68px;
  padding: 0;
  border: 3px solid #fff;
  border-radius: 50%;
  background: #f8d5de;
  box-shadow: 0 8px 22px rgba(120, 60, 80, .22);
  cursor: pointer;
  overflow: hidden;
}
.ai-fab img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ai-fab:hover { transform: translateY(-2px); }
.ai-dock.open .ai-fab { box-shadow: 0 0 0 4px #fff1f4, 0 8px 22px rgba(120, 60, 80, .22); }
.chat-head {
  flex: none;
  height: 52px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}
.chat-avatar { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; }
.chat-head strong { font-size: 15px; }
.chat-tools { margin-left: auto; display: flex; gap: 6px; }
.chat-head button {
  height: 26px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
}
.chat-head button:hover { color: var(--accent); border-color: #f0c9d3; }
.chat-log {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
}
.chat-empty { margin: auto 12px; text-align: center; color: var(--faint); font-size: 13px; line-height: 1.6; }
.bubble { max-width: 88%; padding: 8px 10px; font-size: 13px; line-height: 1.55; white-space: pre-wrap; word-break: break-word; }
.bubble.user { align-self: flex-end; color: #fff; background: linear-gradient(180deg, #d36d88, #c45c78); border-radius: 14px 14px 4px 14px; }
.bubble.assistant { align-self: flex-start; color: var(--ink); background: #f8eef1; border-radius: 14px 14px 14px 4px; }
.chat-form { flex: none; display: flex; gap: 6px; align-items: flex-end; padding: 8px; border-top: 1px solid var(--line); }
.chat-form textarea {
  flex: 1;
  width: auto;
  height: 54px;
  min-height: 54px;
  resize: none;
  border: 1px solid #eadde1;
  border-radius: 10px;
  padding: 8px;
  font: inherit;
  font-size: 13px;
  outline: none;
  background: #fff;
}
.chat-form textarea:focus { border-color: #e7a8b8; box-shadow: 0 0 0 3px rgba(196, 92, 120, .12); }
.chat-form .btn { flex: none; }
.chat-log::-webkit-scrollbar { width: 6px; }
.chat-log::-webkit-scrollbar-thumb { background: #e7d3da; border-radius: 99px; }

.guest {
  min-height: 100%;
  height: 100%;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(520px 280px at 18% 12%, rgba(244, 168, 187, .45), transparent 70%),
    radial-gradient(480px 260px at 86% 88%, rgba(214, 186, 214, .4), transparent 70%),
    #f7f2f4;
}
.login-card {
  width: 320px;
  max-width: calc(100% - 28px);
  background: #fff;
  padding: 26px 24px 20px;
  border: 1px solid #f3e6ea;
  border-radius: 16px;
  box-shadow: 0 16px 40px rgba(120, 60, 80, .08);
}
.login-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  margin-bottom: 10px;
  border-radius: 10px;
  background: linear-gradient(160deg, #f7c2d0, #c45c78);
  color: #fff;
  font-size: 11px;
  letter-spacing: .5px;
  font-weight: 600;
}
.login-card h1 { margin: 0 0 4px; font-size: 18px; font-weight: 600; }
.login-card .form { width: 100%; border: 0; padding: 10px 0 0; background: transparent; box-shadow: none; grid-template-columns: 1fr; margin: 0; }
.login-card .field { width: 100%; }
.login-card .field input { height: 32px; }
.login-card .actions { margin: 8px 0 0; padding: 0; border: 0; background: transparent; }
.login-card .actions button { width: 100%; height: 32px; font-size: 13px; }

.content::-webkit-scrollbar, .side nav::-webkit-scrollbar, .table-wrap::-webkit-scrollbar { width: 6px; height: 6px; }
.content::-webkit-scrollbar-thumb, .side nav::-webkit-scrollbar-thumb, .table-wrap::-webkit-scrollbar-thumb { background: #e7d3da; border-radius: 99px; }
.content::-webkit-scrollbar-track, .side nav::-webkit-scrollbar-track, .table-wrap::-webkit-scrollbar-track { background: transparent; }

@media (max-width: 980px) {
  html, body { height: auto; overflow: auto; }
  .shell { display: block; height: auto; overflow: visible; }
  .chat { width: min(340px, calc(100vw - 32px)); height: min(480px, calc(100vh - 120px)); }
  .side { width: auto; height: auto; overflow: visible; }
  .side nav { flex-direction: row; overflow-x: auto; }
  .main { height: auto; overflow: visible; }
  .content { overflow: visible; }
  .cards, .form, .split, .kv tbody { grid-template-columns: 1fr; }
  .form { width: 100%; }
  .kv tr { border-right: 0; }
  .top { height: auto; padding: 10px 12px; gap: 6px; align-items: flex-start; flex-direction: column; }
}
