/* ========== Reset & Base ========== */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #f4f5f7;
  color: #1f2330;
  line-height: 1.5;
  font-size: 15px;
}
a { color: #2563eb; text-decoration: none; }
a:hover { text-decoration: underline; }

/* ========== Layout ========== */
.nav {
  background: #1f2330;
  color: #fff;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.nav a { color: #cfd6e4; }
.nav a:hover { color: #fff; }
.nav .brand { font-weight: 600; }
.nav .spacer { flex: 1; }

.container { max-width: 1200px; margin: 0 auto; padding: 16px; }
.container.narrow { max-width: 520px; }

h1, h2, h3 { margin: 0 0 12px; }
h1 { font-size: 22px; }
h2 { font-size: 18px; }
h3 { font-size: 16px; }

/* ========== Card / Panels ========== */
.card {
  background: #fff;
  border-radius: 8px;
  padding: 16px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
  margin-bottom: 16px;
}

.kpi {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}
.kpi .item {
  background: #fff;
  border-radius: 8px;
  padding: 12px 14px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.kpi .label { color: #6b7280; font-size: 12px; }
.kpi .value { font-size: 22px; font-weight: 600; margin-top: 4px; }

/* ========== Table ========== */
table { width: 100%; border-collapse: collapse; background: #fff; }
th, td { padding: 8px 10px; border-bottom: 1px solid #e5e7eb; text-align: left; vertical-align: top; }
th { background: #f9fafb; font-weight: 600; font-size: 13px; }
tr:hover td { background: #fafbff; }

.table-wrap { overflow-x: auto; }

/* ========== Status pills ========== */
.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; }
.pill-green { background: #d1fae5; color: #065f46; }
.pill-blue  { background: #dbeafe; color: #1e40af; }
.pill-yellow{ background: #fef3c7; color: #92400e; }
.pill-gray  { background: #e5e7eb; color: #374151; }
.pill-red   { background: #fee2e2; color: #991b1b; }
.pill-purple{ background: #ede9fe; color: #5b21b6; }

/* ========== Forms ========== */
label { display: block; font-size: 13px; color: #374151; margin: 8px 0 4px; }
input[type=text], input[type=password], input[type=tel], input[type=date], select, textarea {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  padding: 8px 10px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37,99,235,0.15); }
textarea { min-height: 70px; resize: vertical; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 600px) { .form-row { grid-template-columns: 1fr; } }

.btn {
  display: inline-block;
  padding: 8px 16px;
  background: #2563eb;
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-family: inherit;
  text-decoration: none;
}
.btn:hover { background: #1d4ed8; text-decoration: none; }
.btn.secondary { background: #e5e7eb; color: #1f2330; }
.btn.secondary:hover { background: #d1d5db; }
.btn.danger { background: #dc2626; }
.btn.danger:hover { background: #b91c1c; }
.btn.block { display: block; width: 100%; padding: 12px; }
.btn[disabled] { opacity: 0.6; cursor: not-allowed; }

.error { color: #b91c1c; background: #fee2e2; padding: 8px 12px; border-radius: 6px; margin: 8px 0; }
.info { color: #1e40af; background: #dbeafe; padding: 8px 12px; border-radius: 6px; margin: 8px 0; }
.warn { color: #92400e; background: #fef3c7; padding: 8px 12px; border-radius: 6px; margin: 8px 0; }

/* ========== Item rows for borrow form ========== */
.item-row { display: flex; gap: 8px; align-items: end; margin-bottom: 6px; flex-wrap: wrap; }
.item-row select, .item-row input { margin: 0; }
.item-row select[name="item_type"] { flex: 0 0 120px; min-width: 100px; }
.item-row input[name="item_custom"] { flex: 1; min-width: 120px; }
.item-row input[name="item_qty"] { flex: 0 0 64px; }
.item-row .remove {
  background: #fee2e2; color: #b91c1c; border: none; height: 36px; border-radius: 6px; cursor: pointer;
}
.add-row { background: none; border: 1px dashed #9ca3af; padding: 6px 12px; border-radius: 6px; cursor: pointer; color: #4b5563; }

/* ========== QR block ========== */
.qr-box { text-align: center; }
.qr-box img { width: 220px; height: 220px; border: 1px solid #e5e7eb; padding: 8px; background: #fff; }
.qr-box .url { font-family: ui-monospace, SFMono-Regular, monospace; font-size: 12px; color: #6b7280; word-break: break-all; }

/* ========== Card grid layout (替代表格) ========== */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 12px;
}
.card-grid.small {
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
}
.card-grid.wide {
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
}
@media (max-width: 600px) {
  .card-grid { grid-template-columns: 1fr; }
  .card-grid.small { grid-template-columns: 1fr; }
  .card-grid.wide { grid-template-columns: 1fr; }
}

.card-item {
  background: #fff;
  border-radius: 10px;
  padding: 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: box-shadow 0.15s;
  min-width: 0;
  overflow-wrap: break-word;
  word-break: break-word;
}
.card-item:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.1); }

.card-item .ci-title {
  font-weight: 600;
  font-size: 15px;
  color: #1f2330;
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.card-item .ci-title code {
  overflow-wrap: break-word;
  word-break: break-all;
}
.card-item .ci-meta {
  font-size: 13px;
  color: #6b7280;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  min-width: 0;
}
.card-item .ci-meta span {
  overflow-wrap: break-word;
  word-break: break-all;
  max-width: 100%;
}
.card-item .ci-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
}
.card-item .ci-actions {
  margin-top: auto;
  padding-top: 8px;
  border-top: 1px solid #f0f0f0;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.card-item .ci-code {
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 12px;
  background: #f3f4f6;
  padding: 1px 6px;
  border-radius: 4px;
  color: #374151;
  word-break: break-all;
}

/* ========== Card list layout (compact inline cards) ========== */
.card-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.card-list-item {
  background: #fff;
  border-radius: 8px;
  padding: 10px 14px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  transition: box-shadow 0.15s;
}
.card-list-item:hover { box-shadow: 0 2px 6px rgba(0,0,0,0.08); }
.card-list-item .spacer { flex: 1; }
.card-list-item .cli-label { font-size: 12px; color: #9ca3af; }
.card-list-item .cli-value { font-size: 14px; }

/* ========== Checkmark indicator (替代 ✅ emoji) ========== */
.chk {
  display: inline-block;
  width: 18px; height: 18px;
  border-radius: 50%;
  text-align: center;
  line-height: 18px;
  font-size: 11px;
  font-weight: bold;
}
.chk.ok { background: #d1fae5; color: #065f46; }
.chk.warn { background: #fef3c7; color: #92400e; }
.chk.err { background: #fee2e2; color: #991b1b; }
.chk.info { background: #dbeafe; color: #1e40af; }
.muted { color: #6b7280; }
.center { text-align: center; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.flex { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; }
.mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; }

/* ========== Mobile responsive ========== */
@media (max-width: 600px) {
  .nav { padding: 8px 10px; gap: 6px; font-size: 13px; }
  .nav a { padding: 4px 6px; }
  .container { padding: 10px; }
  h1 { font-size: 18px; }
  .card { padding: 12px; }
  .card-item { padding: 10px; }
  .btn { padding: 6px 12px; font-size: 13px; }
  .kpi { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .kpi .value { font-size: 18px; }
  .card-grid { grid-template-columns: 1fr; }
  .card-grid.small { grid-template-columns: 1fr; }
  .card-grid.wide { grid-template-columns: 1fr; }
  input[type=text], input[type=password], input[type=tel], input[type=date], select, textarea { font-size: 16px; }
}
