/* BookLoop UI aligned to the blue system screenshots */
:root {
  color-scheme: light;
  --bg: #f4f7fb;
  --panel: #ffffff;
  --panel-2: #f7faff;
  --ink: #172033;
  --muted: #667085;
  --line: #d9e4f2;
  --brand: #1677ff;
  --brand-strong: #0958d9;
  --brand-dark: #0f3f8f;
  --accent: #722ed1;
  --warn: #d48806;
  --danger: #cf1322;
  --success: #389e0d;
  --blue-soft: #eaf4ff;
  --green-soft: #edf9e8;
  --red-soft: #fff1f0;
  --amber-soft: #fff7e6;
  --shadow: 0 12px 28px rgba(25, 62, 112, .08);
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
}
button, input, select, textarea { font: inherit; }
button {
  min-height: 34px;
  border: 0;
  border-radius: 4px;
  background: var(--brand);
  color: #fff;
  cursor: pointer;
  padding: 7px 14px;
}
button:hover:not(:disabled) { background: var(--brand-strong); }
button:disabled { opacity: .56; cursor: not-allowed; }
button.secondary { background: #eef5ff; color: var(--brand-strong); }
button.secondary:hover:not(:disabled) { background: #dbeaff; }
button.danger { background: var(--danger); }
button.success { background: var(--success); }
button.warning { background: var(--warn); }
button.wide { width: 100%; }
.icon-button {
  width: 34px; height: 34px; border-radius: 50%; padding: 0;
  background: #eef5ff; color: var(--ink); font-size: 22px;
}
input, select, textarea {
  width: 100%; min-height: 36px;
  border: 1px solid #cdd9ea; border-radius: 4px;
  background: #fff; color: var(--ink); padding: 7px 10px;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--brand); outline: 2px solid rgba(22,119,255,.12); }
label { display: grid; gap: 6px; color: #24344d; font-size: 13px; font-weight: 700; }
h1,h2,h3,p { margin: 0; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 260px minmax(0, 1fr); }
.sidebar {
  background: #fff;
  border-right: 1px solid var(--line);
  box-shadow: 6px 0 22px rgba(15, 63, 143, .05);
  padding: 0 14px 18px;
}
.brand-block {
  height: 64px;
  margin: 0 -14px 14px;
  padding: 0 16px;
  display: grid;
  grid-template-columns: 42px minmax(0,1fr);
  align-items: center;
  gap: 10px;
  background: linear-gradient(90deg, #096dd9, #1677ff);
  color: #fff;
}
.brand-mark {
  width: 36px; height: 36px; border-radius: 8px;
  display: grid; place-items: center;
  background: rgba(255,255,255,.18);
  font-size: 21px; font-weight: 900;
}
.brand-block h1 { font-size: 17px; line-height: 1.25; color: #fff; }
.brand-block p { margin-top: 2px; color: rgba(255,255,255,.78); font-size: 12px; }
.login-card, .site-note, .stat, .view, .record-row, .book-card, .book-dialog {
  border: 1px solid var(--line); background: #fff; box-shadow: var(--shadow);
}
.login-card { display: grid; gap: 12px; border-radius: 6px; padding: 14px; }
.panel-title, .topbar, .section-head, .price-row, .record-row, .mini-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.panel-title h2 { font-size: 17px; }
.role-chip, .badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 22px; border-radius: 999px; background: #edf2f7;
  color: #344054; font-size: 12px; font-weight: 700; padding: 2px 8px; white-space: nowrap;
}
.role-chip.admin, .badge.admin { background: var(--blue-soft); color: var(--brand-strong); }
.action-row, .form-actions, .top-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.register-box { border-top: 1px solid var(--line); padding-top: 10px; }
summary { cursor: pointer; font-weight: 800; }
.register-box label { margin-top: 9px; }
.site-note { display: grid; gap: 6px; border-radius: 6px; padding: 13px; margin-top: 14px; }
.site-note strong { color: var(--brand-strong); font-size: 17px; }
.site-note p, .section-head p, .meta, .desc { color: var(--muted); line-height: 1.6; }

.main-stage { min-width: 0; padding: 0 18px 22px; }
.topbar {
  min-height: 64px;
  margin: 0 -18px 16px;
  padding: 0 22px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  box-shadow: 0 8px 22px rgba(22,119,255,.05);
}
.eyebrow { color: var(--brand); font-size: 12px; font-weight: 900; letter-spacing: 0; text-transform: uppercase; }
.topbar h2 { margin-top: 4px; font-size: 24px; line-height: 1.25; }
.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 12px; margin-bottom: 14px; }
.stat { display: grid; gap: 6px; border-radius: 6px; padding: 13px 14px; }
.stat span { color: var(--muted); font-size: 13px; }
.stat strong { color: var(--brand-dark); font-size: 27px; }
.tabs {
  display: flex; gap: 0; overflow-x: auto;
  border: 1px solid var(--line); border-radius: 6px 6px 0 0;
  background: #fff; padding: 0;
}
.tab {
  flex: 0 0 auto; min-width: 98px; border-radius: 0; background: #fff; color: #2d3b52;
  border-right: 1px solid var(--line);
}
.tab.active, .tab:hover:not(:disabled) { background: var(--brand); color: #fff; }
.view {
  display: none;
  min-height: 560px;
  border-top: 0;
  border-radius: 0 0 6px 6px;
  box-shadow: none;
  padding: 18px;
}
.view.active { display: block; }
.section-head { align-items: flex-start; margin-bottom: 16px; }
.section-head h2 { font-size: 22px; }
.filters { display: grid; grid-template-columns: minmax(180px,1fr) 170px 150px 88px; gap: 10px; align-items: end; margin-bottom: 16px; }
.book-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 13px; }
.book-card { display: grid; gap: 12px; border-radius: 6px; padding: 13px; box-shadow: none; }
.book-cover {
  position: relative; display: grid; place-items: center; min-height: 132px; overflow: hidden;
  border-radius: 5px; border: 1px solid #d5e5ff;
  background: linear-gradient(135deg, #1677ff 0%, #4096ff 48%, #69b1ff 100%);
  color: #fff; text-align: center; padding: 16px; font-size: 17px; font-weight: 900; line-height: 1.45;
}
.book-cover::before { content: ""; position: absolute; left: 16px; top: 14px; width: 8px; height: calc(100% - 28px); border-radius: 99px; background: rgba(255,255,255,.34); }
.book-cover small { display: block; margin-top: 10px; font-size: 12px; color: rgba(255,255,255,.82); }
.book-card h3 { font-size: 17px; line-height: 1.45; }
.desc { min-height: 42px; font-size: 13px; }
.price { color: var(--danger); font-size: 23px; font-weight: 900; }
.badge.ok { background: var(--green-soft); color: var(--success); }
.badge.warn { background: var(--amber-soft); color: var(--warn); }
.badge.bad { background: var(--red-soft); color: var(--danger); }
.card-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px; max-width: 880px; }
.span-2 { grid-column: span 2; }
.record-list { display: grid; gap: 10px; }
.record-row { align-items: center; border-radius: 6px; padding: 12px; box-shadow: none; }
.record-main { min-width: 0; }
.record-title { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-weight: 900; line-height: 1.5; }
.record-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.admin-layout { display: grid; grid-template-columns: minmax(0,1.35fr) minmax(300px,.65fr); gap: 16px; }
.admin-layout h3 { margin-bottom: 10px; font-size: 18px; }
.admin-side { display: grid; align-content: start; gap: 16px; }
.inline-form { display: grid; grid-template-columns: minmax(0,1fr) 76px; gap: 8px; margin-bottom: 10px; }
.mini-list { display: grid; gap: 8px; }
.mini-item { border: 1px solid var(--line); border-radius: 5px; background: #fff; padding: 9px 10px; }
.book-dialog { width: min(760px, calc(100vw - 28px)); border-radius: 8px; color: var(--ink); padding: 18px; }
.book-dialog::backdrop { background: rgba(17,24,39,.46); }
.book-dialog .icon-button { position: absolute; right: 14px; top: 14px; }
.dialog-layout { display: grid; grid-template-columns: 230px minmax(0,1fr); gap: 18px; padding-top: 24px; }
.dialog-layout .book-cover { min-height: 280px; }
.dialog-meta { display: grid; gap: 10px; }
.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 8px; }
.detail-grid div { border: 1px solid var(--line); border-radius: 5px; background: var(--panel-2); padding: 9px 10px; }
.detail-grid span { display: block; color: var(--muted); font-size: 12px; margin-bottom: 3px; }
.toast { position: fixed; right: 22px; bottom: 22px; z-index: 10; max-width: 360px; border-radius: 6px; background: #172033; color: #fff; box-shadow: var(--shadow); padding: 12px 14px; }
.empty { border: 1px dashed var(--line); border-radius: 6px; color: var(--muted); padding: 28px; text-align: center; }
.hidden { display: none !important; }

@media (max-width: 1080px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--line); }
  .brand-block { margin-bottom: 12px; }
}
@media (max-width: 820px) {
  .stats-grid, .filters, .form-grid, .admin-layout, .dialog-layout, .detail-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .record-row, .section-head, .topbar { align-items: flex-start; flex-direction: column; }
  .record-actions { justify-content: flex-start; }
}
@media (max-width: 560px) {
  .main-stage, .sidebar { padding-left: 12px; padding-right: 12px; }
  .card-actions, .action-row, .form-actions, .top-actions { flex-direction: column; }
}
