/* 序管家 · 暖纸与琥珀色管理后台 */

:root {
  --canvas: #F3F0E8;
  --paper: #FBF7EE;
  --paper-strong: #FFFDF7;
  --ink: #17232B;
  --ink-soft: #2C3B45;
  --amber: #E08A2E;
  --amber-deep: #B96A18;
  --line: #E5DED0;
  --line-strong: #D6CBB8;
  --muted: #7A7365;
  --danger: #A63C27;
  --success: #4F7A52;
  --warning: #9A6B1F;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.55;
}

a { color: var(--ink); text-decoration: none; }
a:hover { color: var(--amber-deep); }

h1, h2, h3, p, ul, figure { margin: 0; }
ul { padding: 0; list-style: none; }

.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.strong { font-weight: 600; }

/* ---------- 布局 ---------- */

.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 232px;
  flex: 0 0 232px;
  background: var(--ink);
  color: #EDE6D8;
  display: flex;
  flex-direction: column;
  padding: 22px 16px 18px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px 22px; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--amber); color: #241506;
  font-weight: 700; font-size: 19px;
  box-shadow: 0 1px 0 rgba(255, 255, 255, .18) inset;
}
.brand-name { font-size: 15px; font-weight: 650; letter-spacing: .04em; color: #F5EFE2; }
.brand-sub { font-size: 11px; color: #A9A08E; letter-spacing: .08em; }

.nav { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.nav-group-title {
  margin: 18px 10px 6px;
  font-size: 11px;
  letter-spacing: .14em;
  color: #8E8676;
}
.nav-item {
  display: block;
  padding: 9px 12px;
  border-radius: 8px;
  color: #D9D2C4;
  border-left: 3px solid transparent;
  font-size: 14px;
}
.nav-item:hover { background: rgba(255, 255, 255, .06); color: #FFF8EA; }
.nav-item.active {
  background: rgba(224, 138, 46, .14);
  border-left-color: var(--amber);
  color: #FFD7A6;
}

.sidebar-foot { border-top: 1px solid rgba(255, 255, 255, .1); padding-top: 14px; }
.who { display: flex; align-items: baseline; justify-content: space-between; padding: 0 8px 10px; }
.who-name { color: #F1EADA; font-weight: 600; }
.who-role { color: #A9A08E; font-size: 12px; }

.sidebar .btn-ghost {
  color: #D9D2C4;
  border-color: rgba(255, 255, 255, .18);
  background: transparent;
}
.sidebar .btn-ghost:hover { background: rgba(255, 255, 255, .08); color: #FFF8EA; }

.main {
  flex: 1;
  min-width: 0;
  padding: 26px 34px 60px;
  max-width: 1400px;
}

/* ---------- 页头 ---------- */

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}
.page-title { font-size: 24px; font-weight: 650; letter-spacing: -.01em; }
.page-sub { color: var(--muted); margin-top: 4px; }
.page-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.back-link { display: inline-block; font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.back-link:hover { color: var(--amber-deep); }

/* ---------- 卡片与网格 ---------- */

.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
  margin-bottom: 18px;
  overflow: hidden;
}

.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 15px 18px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #FCF9F1, var(--paper));
}
.card-title { font-size: 15px; font-weight: 650; letter-spacing: .01em; }
.card-note { font-size: 12px; color: var(--muted); }
.card-body { padding: 18px; }
.card-text { color: var(--ink-soft); margin-bottom: 14px; }
.card-divider { height: 1px; background: var(--line); margin: 0 18px; }
.card-body + .card-body { border-top: 1px dashed var(--line); }

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

.stat-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.stat {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 15px 16px 13px;
  position: relative;
  overflow: hidden;
}
.stat::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--amber);
  opacity: .75;
}
.stat-label { font-size: 12px; color: var(--muted); letter-spacing: .04em; }
.stat-value { font-family: var(--mono); font-size: 27px; font-weight: 600; margin: 3px 0 1px; }
.stat-hint { font-size: 11px; color: #9A9284; }

/* ---------- 表格 ---------- */

.table-wrap { overflow-x: auto; }
.card > .table-wrap:first-child { border-radius: 12px; }
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .05em;
  color: var(--muted);
  padding: 11px 14px;
  background: #F4EFE4;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.table td {
  padding: 11px 14px;
  border-bottom: 1px solid #EEE7DA;
  vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: #F6F1E6; }
.col-check { width: 38px; }
.col-actions { width: 1%; white-space: nowrap; }
.row-actions { display: flex; gap: 6px; align-items: center; justify-content: flex-end; }
.row-actions form { display: inline; }
.inline-form { display: inline; margin: 0; }

.empty { padding: 26px 10px; text-align: center; color: var(--muted); }

.count {
  display: inline-block;
  min-width: 26px;
  padding: 1px 8px;
  border-radius: 999px;
  background: #EFE8D9;
  border: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 12px;
  text-align: center;
}

/* ---------- 徽标 ---------- */

.chip {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  line-height: 1.5;
  border: 1px solid transparent;
  white-space: nowrap;
}
.chip-amber { background: #FBEDD8; border-color: #F0D2A5; color: #8A5410; }
.chip-green { background: #EAF1E7; border-color: #CFE0C8; color: #3E6440; }
.chip-muted { background: #EFEBE1; border-color: #DDD5C5; color: #6F6759; }
.chip-danger { background: #FBE7E1; border-color: #EFC8BC; color: var(--danger); }

/* ---------- 表单 ---------- */

.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field-label { font-size: 12px; color: var(--muted); letter-spacing: .03em; }
.field-wide { grid-column: 1 / -1; }

.input, .select, .textarea {
  width: 100%;
  min-height: 36px;
  padding: 8px 11px;
  background: var(--paper-strong);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  color: var(--ink);
  font-family: inherit;
  font-size: 14px;
  outline: none;
}
.textarea { resize: vertical; min-height: 64px; }
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--amber);
  box-shadow: 0 0 0 3px rgba(224, 138, 46, .14);
}
.input::placeholder, .textarea::placeholder { color: #A9A192; }
.input-narrow { max-width: 150px; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 16px;
}
.form-actions {
  grid-column: 1 / -1;
  display: flex;
  gap: 10px;
  align-items: center;
  padding-top: 2px;
}
.form-divider {
  grid-column: 1 / -1;
  font-size: 12px;
  color: var(--muted);
  border-top: 1px dashed var(--line);
  padding-top: 10px;
}

.toolbar, .filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 16px;
}
.toolbar .input { max-width: 320px; }
.filter-bar .input { max-width: 240px; }
.filter-bar .select { max-width: 260px; }
.check { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-soft); white-space: nowrap; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 36px;
  padding: 7px 15px;
  border-radius: 8px;
  border: 1px solid var(--line-strong);
  background: var(--paper-strong);
  color: var(--ink);
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
  transition: background .12s ease, border-color .12s ease, transform .05s ease;
}
.btn:hover { background: #F6F1E6; border-color: #C9BCA5; color: var(--ink); }
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--amber);
  border-color: #C97A23;
  color: #241506;
  font-weight: 600;
}
.btn-primary:hover { background: #E7963F; border-color: #C97A23; color: #241506; }
.btn-danger { background: #F8E4DE; border-color: #E3B4A6; color: var(--danger); }
.btn-danger:hover { background: #F3D6CD; color: var(--danger); }
.btn-ghost { background: transparent; }
.btn-sm { min-height: 29px; padding: 3px 10px; font-size: 13px; border-radius: 7px; }
.btn-block { width: 100%; }
.bulk-bar { display: flex; justify-content: flex-end; padding: 12px 2px 4px; }

.upload-form { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.upload-form .input { max-width: 360px; }

/* ---------- flash ---------- */

.flash {
  border-radius: 10px;
  padding: 11px 15px;
  margin-bottom: 16px;
  border: 1px solid;
  font-size: 14px;
}
.flash-success { background: #EDF3E9; border-color: #CFE0C8; color: #3E6440; }
.flash-error { background: #FBE8E2; border-color: #EFC8BC; color: var(--danger); }
.flash-warning { background: #FBF1DC; border-color: #EBD3A4; color: var(--warning); }

/* ---------- 详情 ---------- */

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 22px;
}
.detail-item { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.detail-wide { grid-column: 1 / -1; }
.detail-label { font-size: 12px; color: var(--muted); }
.detail-value { color: var(--ink); overflow-wrap: anywhere; }

.activity { padding: 6px 18px 14px; }
.activity li { padding: 10px 0; border-bottom: 1px dashed var(--line); }
.activity li:last-child { border-bottom: none; }
.activity-top { display: flex; justify-content: space-between; gap: 12px; }
.activity-action { font-weight: 600; }
.activity-time { font-size: 12px; color: var(--muted); }
.activity-meta { font-size: 12px; color: var(--muted); }

/* ---------- 照片 ---------- */

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: 12px;
}
.photo-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: var(--paper-strong);
}
.photo-link { display: block; aspect-ratio: 4 / 3; background: #EDE7D9; }
.photo-thumb { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-link:hover .photo-thumb { opacity: .9; }
.photo-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 10px;
  font-size: 11px;
  color: var(--muted);
  border-top: 1px solid var(--line);
}

/* ---------- 审计与 JSON ---------- */

.audit-list { display: flex; flex-direction: column; gap: 8px; }
.audit-item { border: 1px solid var(--line); border-radius: 8px; background: var(--paper-strong); }
.audit-item summary {
  cursor: pointer;
  padding: 9px 12px;
  display: flex;
  gap: 12px;
  align-items: baseline;
  flex-wrap: wrap;
  font-size: 13px;
}
.audit-item summary::marker { color: var(--amber); }
.audit-action { font-weight: 600; }
.json-box {
  margin: 0;
  padding: 12px;
  border-top: 1px solid var(--line);
  background: #F7F2E7;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: 320px;
  overflow: auto;
  color: var(--ink-soft);
}

/* ---------- 分页 ---------- */

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 6px 0 20px;
  flex-wrap: wrap;
}
.page-btn {
  padding: 6px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--paper);
  font-size: 13px;
}
.page-btn:hover { border-color: var(--amber); color: var(--amber-deep); }
.page-btn.disabled { color: #B7AF9F; border-color: var(--line); background: transparent; pointer-events: none; }
.page-info { color: var(--muted); font-size: 13px; }

/* ---------- 创建区 / 折叠 ---------- */

.create-card summary { cursor: pointer; list-style: none; }
.create-card summary::-webkit-details-marker { display: none; }
.create-card summary::after {
  content: "展开";
  font-size: 12px;
  color: var(--amber-deep);
}
.create-card[open] summary::after { content: "收起"; }
.create-card summary .card-title { display: inline-block; }

details.card { margin-bottom: 18px; }
details.card > summary.card-head { border-bottom: none; }
details.card[open] > summary.card-head { border-bottom: 1px solid var(--line); }

/* ---------- 危险区 ---------- */

.danger-zone { border-color: #E7C4B8; }
.danger-zone .card-head { background: #FBF0EA; border-bottom-color: #EBD3C8; }
.danger-row { display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.danger-text { color: var(--danger); font-size: 13px; }

/* ---------- 标签页 ---------- */

.tabs { display: flex; gap: 4px; margin-bottom: 16px; border-bottom: 1px solid var(--line); }
.tab {
  padding: 8px 16px;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  font-size: 14px;
}
.tab:hover { color: var(--ink); }
.tab.active { color: var(--amber-deep); border-bottom-color: var(--amber); font-weight: 600; }

/* ---------- 导入结果 ---------- */

.result-card { border-color: #EBD3A4; }
.error-list { padding-left: 18px; list-style: disc; color: var(--danger); font-size: 13px; }
.error-list li { margin: 3px 0; }
.tip { color: var(--muted); font-size: 12px; margin-top: 10px; }

/* ---------- 登录页 ---------- */

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(circle at 18% 12%, rgba(224, 138, 46, .12), transparent 42%),
    radial-gradient(circle at 82% 88%, rgba(23, 35, 43, .10), transparent 45%),
    var(--canvas);
}
.login-card {
  width: 100%;
  max-width: 390px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 30px 28px 26px;
  box-shadow: 0 14px 40px rgba(23, 35, 43, .08);
}
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.login-brand .brand-name { color: var(--ink); }
.login-brand .brand-sub { color: var(--muted); }
.login-lead { color: var(--ink-soft); margin-bottom: 18px; }
.login-tip { color: var(--muted); font-size: 12px; margin-top: 18px; }
.stack { display: flex; flex-direction: column; gap: 14px; }

/* ---------- 弹窗 ---------- */

dialog.modal {
  width: min(560px, calc(100vw - 32px));
  max-height: 90vh;
  margin: auto;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 24px 60px rgba(23, 35, 43, .28);
  overflow: auto;
}
dialog.modal::backdrop {
  background: rgba(23, 35, 43, .45);
  backdrop-filter: blur(2px);
}
.modal-form { margin: 0; }
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 15px 18px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #FCF9F1, var(--paper));
}
.modal-title { font-size: 16px; font-weight: 650; letter-spacing: .01em; }
.modal-x {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
  padding: 2px 8px;
  border-radius: 7px;
  cursor: pointer;
}
.modal-x:hover { background: #EFE8D9; color: var(--ink); }
.modal-body { padding: 18px; }
.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 2px 18px 18px;
}
.modal-note { color: var(--muted); font-size: 12px; }
.modal-wide { width: min(680px, calc(100vw - 32px)); }
.action-stack { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.action-stack .btn { min-width: 150px; }

/* ---------- 响应式 ---------- */

@media (max-width: 1120px) {
  .stat-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; flex: none; height: auto; position: static; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .nav-group-title { width: 100%; }
  .nav-item { border-left: none; border-bottom: 3px solid transparent; }
  .nav-item.active { border-left: none; border-bottom-color: var(--amber); }
  .sidebar-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
  .sidebar-foot form { width: auto; }
  .main { padding: 20px 18px 44px; }
  .grid-2, .form-grid, .detail-grid { grid-template-columns: minmax(0, 1fr); }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .danger-row { flex-direction: column; align-items: flex-start; }
}
