:root {
  --bg: #f4f6f9;
  --card: #ffffff;
  --ink: #1f2733;
  --muted: #6b7785;
  --line: #dfe4ea;
  --brand: #1f5fa9;
  --brand-ink: #ffffff;
  --ok: #e8f5ec;
  --ok-ink: #1c6b3a;
  --err: #fdeaea;
  --err-ink: #a12525;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.6 "Microsoft YaHei", "PingFang SC", "Helvetica Neue", Arial, sans-serif;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  background: var(--brand);
  color: var(--brand-ink);
  padding: 10px 20px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.brand { font-weight: 600; }
.nav { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; }
.nav a { color: #e8f1fb; }
.link-btn {
  background: none; border: 0; color: #e8f1fb; cursor: pointer;
  font: inherit; padding: 0; text-decoration: underline;
}

.container { max-width: 1200px; margin: 20px auto 40px; padding: 0 20px; }
.centered { display: flex; align-items: flex-start; justify-content: center; padding: 60px 16px; }
.centered .card { width: 100%; }

h1 { font-size: 20px; margin: 0 0 16px; }
h2 { font-size: 15px; margin: 0 0 10px; color: #33414f; }
h3 { font-size: 14px; margin: 14px 0 6px; color: #33414f; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px 18px;
  margin-bottom: 18px;
}
.card.narrow { max-width: 420px; }

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
.two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 14px; }

.stat { text-align: center; }
.stat-value { font-size: 28px; font-weight: 700; color: var(--brand); }
.stat-label { color: var(--muted); }

table { width: 100%; border-collapse: collapse; background: var(--card); }
th, td { border-bottom: 1px solid var(--line); padding: 8px 10px; text-align: left; vertical-align: top; }
thead th { background: #eef2f7; font-weight: 600; }
table.compact th { width: 120px; color: var(--muted); font-weight: 500; background: none; }
.ellipsis { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.actions-cell { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

.tag { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px; background: #eef2f7; }
.tag-received { background: #fff4e0; color: #96590a; }
.tag-confirmed { background: #e7f0fd; color: #1a4f92; }
.tag-processing { background: #e8f1ff; color: #14498a; }
.tag-done { background: var(--ok); color: var(--ok-ink); }
.tag-rejected { background: var(--err); color: var(--err-ink); }
.tag-borrow-on_loan { background: #e8f1ff; color: #14498a; }
.tag-borrow-renewed { background: #fff4e0; color: #96590a; }
.tag-borrow-returned { background: var(--ok); color: var(--ok-ink); }
.tag-borrow-overdue { background: var(--err); color: var(--err-ink); }

.notice { padding: 10px 14px; border-radius: 6px; margin-bottom: 14px; }
.notice.ok { background: var(--ok); color: var(--ok-ink); }
.notice.error { background: var(--err); color: var(--err-ink); }

form label { display: block; margin-bottom: 12px; color: var(--muted); }
input, select, button, textarea {
  font: inherit; padding: 7px 9px; border: 1px solid var(--line);
  border-radius: 6px; background: #fff; color: var(--ink);
}
input, select { width: 100%; }
form label input { margin-top: 4px; }

button { cursor: pointer; }
button.primary { background: var(--brand); border-color: var(--brand); color: #fff; width: 100%; }
button.primary:hover { background: #1a518f; }

.filters, .action-form {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  margin-bottom: 14px;
}
.filters input, .filters select, .action-form input, .action-form select { width: auto; min-width: 150px; }
.filters button, .action-form button { width: auto; }
.inline-form { display: inline; }

.btn {
  display: inline-block; padding: 7px 12px; border: 1px solid var(--line);
  border-radius: 6px; background: #fff; color: var(--brand);
}

.actions { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-start; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: 8px 0; border-bottom: 1px dashed var(--line); }
.timeline .time { color: var(--muted); margin-right: 10px; }
.timeline .who { font-weight: 600; margin-right: 10px; }

.detail {
  background: #f7f9fb; border: 1px solid var(--line); border-radius: 6px;
  padding: 10px; white-space: pre-wrap; word-break: break-word; margin: 0;
  font-family: inherit;
}

.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: Consolas, "Courier New", monospace; }
.crumb { margin: 0 0 8px; }
.footer { text-align: center; color: var(--muted); font-size: 12px; padding: 0 20px 30px; }
.pager { display: flex; gap: 10px; align-items: center; margin-top: 12px; }
