:root {
  --page: #f7f7f5;
  --surface: #ffffff;
  --border: #e3e2dd;
  --text: #23231f;
  --muted: #74736d;
  --accent: #185fa5;
  --accent-soft: #e6f1fb;
  --success: #0f6e56;
  --warning: #854f0b;
  --radius: 12px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--page);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.6;
}

button, input { font: inherit; }

.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 20px;
}

.login-card {
  width: 100%;
  max-width: 1040px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 36px;
}

.brand-mark { font-size: 22px; font-weight: 500; letter-spacing: 0.5px; }
.brand-small { font-size: 15px; font-weight: 500; }
.login-subtitle { margin: 6px 0 28px; color: var(--muted); }

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

.login-block {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  background: #fdfdfc;
  display: flex;
  flex-direction: column;
}

.login-block h2 { margin: 0 0 4px; font-size: 16px; font-weight: 500; }
.block-desc { margin: 0 0 16px; font-size: 12px; color: var(--muted); }

.qr-box {
  height: 218px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  overflow: hidden;
}

.qr-box svg { width: 196px; height: 196px; }
.qr-placeholder { color: var(--muted); font-size: 12px; text-align: center; padding: 0 20px; }

.block-actions { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.block-status { margin: 10px 0 0; font-size: 12px; color: var(--muted); min-height: 20px; }

.btn {
  border-radius: 8px;
  border: 1px solid var(--accent);
  padding: 8px 14px;
  cursor: pointer;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
}
.btn:hover { opacity: 0.88; }
.btn-ghost { background: transparent; color: var(--accent); }
.btn-wide { width: 100%; margin-top: 14px; }
.btn-small { padding: 5px 10px; font-size: 12px; }

.field { display: block; margin-bottom: 12px; }
.field span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.field input {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  outline: none;
}
.field input:focus { border-color: var(--accent); }

.demo-hint { margin: 12px 0 0; font-size: 12px; color: var(--muted); }
.notice { margin-top: 20px; padding: 10px 12px; border-radius: 8px; background: #fcebeb; color: #a32d2d; font-size: 13px; }

.topbar {
  height: 60px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
}
.topbar-right { display: flex; align-items: center; gap: 14px; color: var(--muted); }
.main { max-width: 1040px; margin: 0 auto; padding: 24px 20px 48px; }

.tabs { display: flex; gap: 8px; margin-bottom: 20px; }
.tab {
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  padding: 7px 14px;
  border-radius: 8px;
  cursor: pointer;
}
.tab.active { background: var(--accent-soft); color: var(--accent); border-color: #b5d4f4; }

.hero { margin-bottom: 20px; }
.hero h1 { margin: 0 0 6px; font-size: 20px; font-weight: 500; }
.hero p { margin: 0; color: var(--muted); }

.card-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.app-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}
.app-card-head { display: flex; align-items: center; justify-content: space-between; }
.app-card h3 { margin: 0; font-size: 15px; font-weight: 500; }
.badge { font-size: 11px; border-radius: 20px; padding: 2px 8px; background: #f1efe8; color: var(--muted); }
.badge.on { background: #e1f5ee; color: var(--success); }
.badge.off { background: #faeeda; color: var(--warning); }
.app-card p { color: var(--muted); font-size: 12px; margin: 10px 0 14px; }

.panel {
  margin-top: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}
.panel h3 { margin: 0 0 12px; font-size: 15px; font-weight: 500; }
.metric-row { display: flex; gap: 12px; flex-wrap: wrap; }
.metric { border: 1px solid var(--border); border-radius: 8px; padding: 12px 16px; min-width: 130px; }
.metric span { display: block; font-size: 12px; color: var(--muted); }
.metric strong { display: block; font-size: 18px; font-weight: 500; margin-top: 4px; }

.config-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.config-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.config-card h3 { margin: 0 0 2px; font-size: 15px; font-weight: 500; }
.config-card .config-hint { margin: 0 0 14px; color: var(--muted); font-size: 12px; }
.config-card .credential-hint { margin: -6px 0 14px; padding: 8px 10px; border-radius: 8px; background: var(--accent-soft); color: var(--accent); line-height: 1.5; }
.config-card .btn { margin-top: 4px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  background: #23231f;
  color: #fff;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 13px;
  z-index: 10;
}

@media (max-width: 860px) {
  .login-grid, .card-grid, .config-list { grid-template-columns: 1fr; }
  .login-card { padding: 24px 18px; }
  .topbar { padding: 0 18px; }
  .inline-form { grid-template-columns: 1fr; }
}

.admin-login-card { max-width: 440px; }
.admin-login-form { margin-top: 22px; }
.link { color: var(--accent); text-decoration: none; font-size: 13px; }
.link:hover { text-decoration: underline; }

.inline-form { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)) auto; gap: 10px; align-items: end; }
.inline-form select {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
}
.inline-form .btn { height: 38px; }

.user-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.log-row { display: grid; grid-template-columns: 170px 130px 1fr; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 12px; }
.log-row:last-child { border-bottom: none; }
.log-row .log-at { color: var(--muted); }
.log-row .log-type { color: var(--accent); }
.info-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }

.list-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; gap: 12px; flex-wrap: wrap; }
.list-head h3 { margin: 0; font-size: 15px; font-weight: 500; }
.filter-group { display: flex; gap: 6px; }
.chip { border: 1px solid var(--border); background: #fff; color: var(--muted); border-radius: 20px; padding: 4px 12px; cursor: pointer; font-size: 12px; }
.chip.active { background: var(--accent-soft); color: var(--accent); border-color: #b5d4f4; }
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.data-table th, .data-table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.data-table th { color: var(--muted); font-weight: 500; background: #fafaf8; }
.data-table tr:last-child td { border-bottom: none; }

/* 日期与快捷入口 */
.date-panel {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin-bottom: 18px;
}
.date-main { font-size: 17px; font-weight: 500; }
.date-sub { color: var(--muted); font-size: 13px; }
.shortcut-panel { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }
.shortcut-title { font-size: 13px; color: var(--muted); }
.shortcut-btn {
  border: 1px solid #b5d4f4;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 20px;
  padding: 6px 14px;
  cursor: pointer;
  font-size: 13px;
}

/* 内容展示 */
.content-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.content-card {
  display: flex;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  cursor: pointer;
}
.content-card:hover { border-color: #b5d4f4; }
.content-cover { width: 96px; height: 72px; object-fit: cover; border-radius: 8px; flex: none; background: #f1efe8; }
.content-card-body { min-width: 0; }
.content-card h3 { margin: 0 0 4px; font-size: 15px; font-weight: 500; }
.content-meta { margin: 0 0 6px; color: var(--muted); font-size: 12px; }
.content-preview { margin: 0; color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.content-rich { line-height: 1.8; }
.content-rich img { max-width: 100%; height: auto; border-radius: 8px; }
.content-media-image { max-width: 100%; height: auto; border-radius: 8px; display: block; }
.content-media-pdf { width: 100%; height: 720px; border: 1px solid var(--border); border-radius: 8px; }
.attachment-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.attachment-list > strong { width: 100%; font-size: 13px; font-weight: 500; }
.attachment-link, .attachment-chip a {
  display: inline-block;
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--accent);
  text-decoration: none;
  font-size: 12px;
  word-break: break-all;
}

/* 后台编辑器 */
.content-form { margin-bottom: 16px; }
.editor-block { margin-bottom: 16px; }
.field-label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.editor-toolbar { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.editor-toolbar button {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  border-radius: 6px;
  padding: 5px 10px;
  cursor: pointer;
  font-size: 12px;
}
.editor-toolbar button:hover { border-color: var(--accent); color: var(--accent); }
.rich-editor {
  min-height: 220px;
  max-height: 520px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  padding: 12px 14px;
  line-height: 1.8;
}
.rich-editor:empty:before { content: attr(data-placeholder); color: #aaa; }
.rich-editor img { max-width: 100%; height: auto; }
.rich-editor h2 { font-size: 19px; }
.checkbox-field { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.attachment-chip { display: inline-flex; align-items: center; gap: 4px; }
.attachment-chip button {
  border: none;
  background: #f1efe8;
  color: var(--muted);
  border-radius: 50%;
  width: 18px;
  height: 18px;
  line-height: 16px;
  cursor: pointer;
  padding: 0;
}

.callback-box {
  margin: 0 0 14px;
  padding: 10px 12px;
  border: 1px dashed #b5d4f4;
  border-radius: 8px;
  background: var(--accent-soft);
}
.callback-caption { font-size: 12px; color: var(--accent); margin-bottom: 6px; }
.callback-value {
  display: block;
  font-family: Consolas, Monaco, monospace;
  font-size: 12px;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 8px;
  word-break: break-all;
  margin-bottom: 8px;
}
.callback-warning {
  margin: -4px 0 14px;
  padding: 8px 10px;
  border-radius: 8px;
  background: #fff4e5;
  color: #a15c00;
  font-size: 12px;
  line-height: 1.5;
}
.block-status.has-warning { color: #a15c00; line-height: 1.5; }

/* 扫码弹窗：给官方授权页足够空间，避免二维码被挤压裁切 */
body.modal-open { overflow: hidden; }
.modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal[hidden] { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(20, 20, 18, .55); }
.modal-dialog {
  position: relative;
  z-index: 1;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 18px 60px rgba(0, 0, 0, .25);
  padding: 18px 22px 16px;
  max-width: 100%;
  max-height: calc(100vh - 40px);
  display: flex;
  flex-direction: column;
}
.modal-close {
  position: absolute;
  top: 10px;
  right: 14px;
  border: none;
  background: transparent;
  font-size: 24px;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
  padding: 2px 8px;
}
.modal-close:hover { color: var(--text); }
.modal-qr { width: 460px; }
.modal-qr-title { font-size: 16px; font-weight: 500; text-align: center; margin: 0 34px 12px 0; }
.modal-qr-body {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: auto;
}
.qr-modal-frame {
  display: block;
  width: 420px;
  height: 520px;
  max-width: 100%;
  border: 0;
}
.modal-qr-status { margin: 10px 0 0; font-size: 12px; color: var(--muted); text-align: center; line-height: 1.5; }
.modal-qr-status.has-warning { color: #a15c00; }

@media (max-width: 520px) {
  .modal-qr { width: 100%; }
  .qr-modal-frame { width: 100%; height: 70vh; }
}

@media (max-width: 860px) {
  .content-list { grid-template-columns: 1fr; }
  .content-media-pdf { height: 480px; }
}
