:root {
  --brand: #0B6E99;
  --accent: #1FA2A0;
  --bg: #F5F8FA;
  --surface: #fff;
  --text: #1A2332;
  --muted: #6B7A90;
  --border: #E6EEF3;
  --danger: #C23B3B;
  --success: #2F9B6A;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: var(--bg);
}
.hidden { display: none !important; }
.muted { color: var(--muted); }

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: linear-gradient(160deg, #0B6E99 0%, #1FA2A0 45%, #F5F8FA 45%);
}
.login-card {
  width: min(420px, 92vw);
  background: var(--surface);
  border-radius: 16px;
  padding: 32px;
  box-shadow: 0 16px 40px rgba(11, 110, 153, 0.12);
}
.login-card h1 { margin: 0; color: var(--brand); letter-spacing: 2px; }
.login-card .sub { color: var(--muted); margin: 8px 0 24px; }
.login-card label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 6px; }
.login-card input, .toolbar input, .toolbar select, .panel input, .panel textarea, .panel select {
  width: 100%;
  border: 1px solid var(--border);
  background: #F7FAFC;
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 14px;
}
.login-card button, .toolbar button, .panel button, .side .logout {
  margin-top: 18px;
  width: 100%;
  border: 0;
  border-radius: 10px;
  padding: 12px;
  background: linear-gradient(135deg, var(--brand), var(--accent));
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}
.hint { font-size: 12px; color: var(--muted); margin-top: 14px; }

#appView { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.side {
  background: linear-gradient(180deg, #0B6E99, #0E7F9C);
  color: #fff;
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
}
.brand { font-size: 22px; font-weight: 700; margin-bottom: 28px; letter-spacing: 2px; }
.side nav { display: flex; flex-direction: column; gap: 8px; flex: 1; }
.side .nav {
  border: 0;
  background: transparent;
  color: rgba(255,255,255,.85);
  text-align: left;
  padding: 12px 14px;
  border-radius: 10px;
  cursor: pointer;
}
.side .nav.active, .side .nav:hover { background: rgba(255,255,255,.14); color: #fff; }
.side .logout { margin-top: auto; background: rgba(255,255,255,.16); }

main { padding: 28px; }
.top { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 20px; }
.top h2 { margin: 0; }

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 20px;
}
.stat {
  background: var(--surface);
  border-radius: 14px;
  padding: 18px;
}
.stat .n { font-size: 28px; font-weight: 700; color: var(--brand); }
.stat .l { color: var(--muted); font-size: 13px; margin-top: 6px; }

.panel {
  background: var(--surface);
  border-radius: 14px;
  padding: 20px;
  margin-top: 16px;
}
.bars { display: flex; align-items: flex-end; gap: 12px; height: 160px; padding-top: 10px; }
.bar-col { flex: 1; text-align: center; }
.bar {
  background: linear-gradient(180deg, var(--accent), var(--brand));
  border-radius: 8px 8px 4px 4px;
  margin: 0 auto 8px;
  width: 70%;
  min-height: 4px;
}
.bar-col span { font-size: 12px; color: var(--muted); }

.toolbar {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.toolbar input, .toolbar select { width: auto; min-width: 160px; }
.toolbar button { width: auto; margin-top: 0; padding: 10px 16px; }
.toolbar button.ghost {
  background: #EAF4F8;
  color: var(--brand);
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border-radius: 14px;
  overflow: hidden;
}
th, td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--border); font-size: 14px; }
th { background: #F0F6F9; color: var(--muted); font-weight: 600; }
.chip {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  background: #EAF4F8;
  color: var(--brand);
  font-size: 12px;
}
.chip.ok { background: #E8F7EF; color: var(--success); }
.chip.warn { background: #FFF6E5; color: #D4920A; }
.chip.bad { background: #FDECEC; color: var(--danger); }
.linkbtn {
  border: 0;
  background: transparent;
  color: var(--brand);
  cursor: pointer;
  padding: 0 6px;
}
.panel label { display: block; margin: 10px 0 6px; color: var(--muted); font-size: 13px; }
.panel textarea { font-family: ui-monospace, Consolas, monospace; font-size: 12px; }
.nav-badge {
  display: inline-block;
  min-width: 18px;
  padding: 0 6px;
  margin-left: 4px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  line-height: 18px;
  text-align: center;
}
.msg-list { display: grid; gap: 10px; }
.msg-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  cursor: pointer;
}
.msg-item.unread { border-left: 4px solid var(--accent); }
.msg-title { font-weight: 600; }
.msg-body { color: var(--muted); margin-top: 6px; font-size: 13px; }
.msg-time { color: var(--muted); margin-top: 8px; font-size: 12px; }
.tip-panel p { margin: 8px 0; line-height: 1.6; font-size: 13px; }
.tip-panel code, .login-card code {
  font-size: 12px;
  background: #f0f4f7;
  padding: 2px 6px;
  border-radius: 4px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 16px;
}
.form-grid .span2 { grid-column: span 2; }
.btn-row { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.btn-row.wrap { flex-wrap: wrap; }
.btn-row button { width: auto; margin-top: 0; padding: 10px 16px; }
.btn-row button.ghost, button.ghost {
  background: #EAF4F8;
  color: var(--brand);
}
.btn-row button.danger { background: var(--danger); }
.pager {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
}
.pager button { width: auto; margin-top: 0; padding: 8px 14px; }
.subhead { margin: 28px 0 12px; font-size: 16px; }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: 12px; word-break: break-all; }
.tiny { margin-top: 4px; color: var(--muted); }
.ops { white-space: nowrap; }

.drawer-mask {
  position: fixed; inset: 0;
  background: rgba(16, 32, 48, 0.35);
  z-index: 40;
}
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: min(640px, 96vw);
  background: var(--surface);
  z-index: 50;
  box-shadow: -12px 0 40px rgba(0,0,0,.12);
  display: flex;
  flex-direction: column;
}
.drawer-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.drawer-head h3 { margin: 0; }
.drawer-head button { width: auto; margin: 0; padding: 8px 14px; }
.drawer-body { padding: 20px; overflow: auto; flex: 1; }
.drawer-body h4 { margin: 20px 0 10px; font-size: 14px; color: var(--muted); }
.kv-box { display: grid; gap: 8px; }
.kv {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 10px 12px; background: #F7FAFC; border-radius: 8px; font-size: 13px;
}
.kv span { color: var(--muted); }
.kv b { font-weight: 600; text-align: right; word-break: break-all; }
.log-box { display: grid; gap: 8px; }
.log-item {
  font-size: 13px; padding: 10px 12px;
  border-left: 3px solid var(--accent); background: #F7FAFC; border-radius: 0 8px 8px 0;
}
.log-item span { color: var(--muted); margin-right: 8px; }
.log-item em { display: block; margin-top: 4px; color: var(--muted); font-style: normal; }

.detail-sec { margin-bottom: 8px; }
.detail-sec > h4 {
  margin: 18px 0 10px;
  font-size: 14px;
  color: var(--muted);
  font-weight: 600;
}
.panel-soft {
  background: #F7FAFC;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
}
.form-fields {
  display: grid;
  gap: 12px;
}
.field-block label {
  display: block;
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 13px;
}
.field-block input,
.field-block textarea,
.field-block select {
  width: 100%;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
}
.remark-editor {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 0 0 10px 10px;
  min-height: 180px;
}
.remark-editor .ql-editor {
  min-height: 160px;
  font-size: 14px;
  line-height: 1.6;
}
.ql-toolbar.ql-snow {
  border-radius: 10px 10px 0 0;
  border-color: var(--border);
  background: #F7FAFC;
}
.ql-container.ql-snow {
  border-color: var(--border);
  border-radius: 0 0 10px 10px;
}
.rich-view {
  background: #F7FAFC;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 14px;
  line-height: 1.65;
  word-break: break-word;
}
.rich-view p { margin: 0 0 8px; }
.rich-view ul, .rich-view ol { margin: 0 0 8px; padding-left: 1.4em; }
.rich-view a { color: var(--brand); }

@media (max-width: 900px) {
  #appView { grid-template-columns: 1fr; }
  .side { flex-direction: row; flex-wrap: wrap; gap: 8px; align-items: center; }
  .side nav { flex-direction: row; flex-wrap: wrap; }
  .stats { grid-template-columns: 1fr 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span2 { grid-column: span 1; }
}
