/* ===== Reset & Base ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: 'Avenir Next', 'Helvetica Neue', Arial, sans-serif;
  background: #fff;
  color: #333;
  display: flex;
  min-height: 100vh;
}
a { text-decoration: none; color: inherit; }

/* ===== Sidebar ===== */
.sidebar {
  width: 230px;
  background: linear-gradient(180deg, #c62828 0%, #a51c1c 100%);
  color: #fff;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  z-index: 100;
}
.sidebar-brand {
  padding: 28px 24px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.15);
  display: flex;
  align-items: center;
  gap: 14px;
}
.sidebar-brand .brand-logo {
  width: 42px;
  height: 42px;
  background: #fff;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 900;
  color: #c62828;
  flex-shrink: 0;
}
.sidebar-brand h2 {
  font-size: 20px;
  font-weight: 900;
  letter-spacing: 1px;
  margin: 0;
}
.sidebar-brand p {
  display: none;
}
.sidebar-nav {
  flex: 1;
  padding: 16px 0;
  overflow-y: auto;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 24px;
  font-size: 12px;
  font-weight: 500;
  color: rgba(255,255,255,0.85);
  cursor: pointer;
  transition: all 0.15s;
  border-left: none;
}
.nav-item:hover {
  background: rgba(255,255,255,0.1);
  color: #fff;
}
.nav-item.active {
  background: rgba(255,255,255,0.15);
  color: #fff;
  font-weight: 700;
}
.nav-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.8;
}
.nav-item.active .nav-icon {
  opacity: 1;
}
.nav-label {
  flex: 1;
}
.nav-badge {
  background: rgba(255,255,255,0.2);
  color: rgba(255,255,255,0.9);
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 10px;
  min-width: 20px;
  text-align: center;
  flex-shrink: 0;
}
.nav-item.active .nav-badge {
  background: rgba(255,255,255,0.3);
  color: #fff;
}
.nav-group { margin: 3px 0; }
.nav-group-toggle,
.nav-subitem {
  width: 100%;
  border: 0;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.nav-group-toggle {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 11px 12px;
  border-radius: 9px;
  color: rgba(255,255,255,.86);
  background: transparent;
  font-size: 12px;
  font-weight: 800;
}
.nav-group-toggle:hover,
.nav-group.open .nav-group-toggle { color: #fff; background: rgba(255,255,255,.1); }
.nav-group.has-active .nav-group-toggle { color: #fff; }
.nav-chevron { margin-left: auto; font-size: 17px; line-height: 1; transition: transform .18s ease; }
.nav-group.open .nav-chevron { transform: rotate(180deg); }
.nav-group-links { display: none; padding: 4px 0 7px 30px; }
.nav-group.open .nav-group-links { display: block; }
.nav-subitem {
  min-height: 34px;
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 2px 0;
  padding: 7px 8px 7px 13px;
  border-radius: 7px;
  color: rgba(255,255,255,.7);
  background: transparent;
  font-size: 11px;
  font-weight: 650;
}
.nav-subitem::before { content: ''; width: 4px; height: 4px; flex: 0 0 auto; border-radius: 50%; background: currentColor; opacity: .65; }
.nav-subitem > span:first-child { flex: 1; }
.nav-subitem:hover { color: #fff; background: rgba(255,255,255,.08); }
.nav-subitem.active { color: var(--archive-red); background: #fff; font-weight: 900; box-shadow: 0 6px 16px rgba(50,8,11,.14); }
.nav-subitem.active::before { opacity: 1; }
.nav-subitem .nav-badge { font-size: 9px; padding: 1px 6px; }
.nav-subitem.active .nav-badge { color: #fff; background: var(--archive-red); }
.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,0.15);
  display: flex;
  align-items: center;
  gap: 12px;
}

.mobile-topbar,
.mobile-bottom-nav,
.mobile-nav-sheet {
  display: none;
}
.sidebar-footer .user-avatar {
  width: 38px;
  height: 38px;
  background: #fff;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 900;
  color: #c62828;
  flex-shrink: 0;
}
.sidebar-footer .user-info {
  flex: 1;
  min-width: 0;
}
.sidebar-footer .user-name {
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  line-height: 1.3;
}
.sidebar-footer .user-handle {
  font-size: 11px;
  color: rgba(255,255,255,0.6);
  line-height: 1.3;
}
.sidebar-footer .btn-logout {
  font-size: 13px;
  color: rgba(255,255,255,0.7);
  cursor: pointer;
  background: none;
  border: none;
  padding: 6px 10px;
  transition: color 0.15s;
  white-space: nowrap;
}
.sidebar-footer .btn-logout:hover {
  color: #fff;
}

/* ===== Main Content ===== */
.main {
  margin-left: 230px;
  flex: 1;
  min-width: 0;
  background: #fff;
  background-image:
    linear-gradient(rgba(0,0,0,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,0,0,0.03) 1px, transparent 1px);
  background-size: 28px 28px;
  padding: 32px 40px;
}
.page-header {
  margin-bottom: 28px;
}
.page-eyebrow {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: #c62828;
  margin-bottom: 8px;
}
.page-title {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -1.5px;
  color: #222;
  -webkit-text-stroke: 1px #222;
  color: transparent;
}

/* ===== Stat Row (Dashboard) ===== */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0;
  border: 1px solid #e0e0e0;
  margin-bottom: 32px;
}
.stat-cell {
  padding: 20px 16px;
  border-right: 1px solid #e0e0e0;
  border-bottom: 1px solid #e0e0e0;
  cursor: pointer;
  transition: background 0.15s;
}
.stat-cell:hover {
  background: #f8f8f8;
}
.stat-cell .stat-label {
  font-size: 12px;
  color: #666;
  margin-bottom: 6px;
  font-weight: 500;
}
.stat-cell .stat-number {
  font-size: 36px;
  font-weight: 700;
  letter-spacing: -1px;
  color: #222;
  line-height: 1.1;
}
.stat-cell .stat-unit {
  font-size: 12px;
  color: #999;
  margin-top: 4px;
}
.stat-cell.stat-total {
  background: #c62828;
  border-color: #c62828;
}
.stat-cell.stat-total .stat-label,
.stat-cell.stat-total .stat-number,
.stat-cell.stat-total .stat-unit {
  color: #fff;
}

/* ===== Dashboard Search ===== */
.dashboard-search {
  display: flex;
  gap: 12px;
  margin-bottom: 28px;
}
.search-input {
  flex: 1;
  padding: 12px 16px;
  font-size: 15px;
  border: 2px solid #e0e0e0;
  outline: none;
  transition: border-color 0.2s;
}
.search-input:focus {
  border-color: #c62828;
}
.search-input::placeholder {
  color: #bbb;
}
.search-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  font-size: 14px;
  color: #666;
}
.search-empty {
  text-align: center;
  padding: 60px 20px;
  color: #999;
}
.search-empty-icon {
  font-size: 48px;
  margin-bottom: 16px;
}
.search-empty p {
  font-size: 15px;
  margin-bottom: 20px;
}

/* ===== Stat Cards (legacy) ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}
.stat-card {
  background: #fff;
  border: 1px solid #e0e0e0;
  padding: 20px;
  transition: all 0.2s;
  cursor: pointer;
}
.stat-card:hover {
  transform: translateY(-2px);
  border-bottom: 3px solid #c62828;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}
.stat-card .label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #999;
  margin-bottom: 8px;
}
.stat-card .value {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -1px;
  color: #222;
}
.stat-card .arrow {
  float: right;
  color: #c62828;
  font-size: 18px;
}
.stat-card .icon {
  float: left;
  font-size: 22px;
  line-height: 1;
}
.stat-card.total-card {
  background: #c62828;
  border-color: #c62828;
}
.stat-card.total-card .label,
.stat-card.total-card .value {
  color: #fff;
}

/* ===== Item Grid ===== */
.item-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}
.item-card {
  background: #fff;
  border: 1px solid #e0e0e0;
  overflow: hidden;
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
}
.item-card:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,0.1);
}
/* 大图区域 */
.item-card .card-image {
  width: 100%;
  aspect-ratio: 4/3;
  background: #f5f5f5;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.item-card .card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.item-card .card-image .no-image {
  color: #ccc;
  font-size: 13px;
}
/* 卡片内容 */
.item-card .card-body {
  padding: 16px;
  flex: 1;
  display: flex;
  flex-direction: column;
}
.item-card .card-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
}
.item-card .card-item-no {
  font-size: 16px;
  font-weight: 700;
  color: #c62828;
  letter-spacing: -0.3px;
}
.item-card .card-category {
  font-size: 12px;
  color: #999;
}
.item-card .card-name {
  font-size: 15px;
  font-weight: 700;
  color: #222;
  margin-bottom: 8px;
  line-height: 1.4;
}
.item-card .card-meta {
  font-size: 12px;
  color: #999;
  line-height: 1.6;
  flex: 1;
}
.item-card .card-actions {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid #f0f0f0;
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  border: none;
  border-radius: 0;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-primary {
  background: #c62828;
  color: #fff;
}
.btn-primary:hover { background: #a51c1c; }
.btn-outline {
  background: transparent;
  color: #666;
  border: 1px solid #ddd;
}
.btn-outline:hover { border-color: #c62828; color: #c62828; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-danger { background: #d32f2f; color: #fff; }
.btn-danger:hover { background: #b71c1c; }

/* ===== Forms ===== */
.section-label {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #c62828;
  margin: 18px 0 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid #eee;
}
.form-group {
  margin-bottom: 16px;
}
.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: #666;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.form-control {
  width: 100%;
  padding: 10px 12px;
  font-size: 14px;
  border: 1px solid #ddd;
  border-radius: 0;
  background: #fff;
  transition: border-color 0.15s;
}
.form-control:focus {
  outline: none;
  border-color: #c62828;
}
select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23666' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}
textarea.form-control {
  min-height: 80px;
  resize: vertical;
}

/* ===== Modal ===== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  align-items: center;
  justify-content: center;
}
.modal-overlay.show { display: flex; }
.modal {
  background: #fff;
  width: 90%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 28px;
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}
.modal-header h3 {
  font-size: 18px;
  font-weight: 700;
}
.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: #999;
}

/* ===== Detail Modal (4WD style) ===== */
.detail-photos {
  margin-bottom: 20px;
}
.detail-photos img {
  width: 100%;
  max-height: 400px;
  object-fit: contain;
  border: 1px solid #eee;
}
.detail-photos .no-photo {
  color: #ccc;
  font-size: 14px;
  text-align: center;
  padding: 40px 0;
}
.detail-name {
  font-size: 22px;
  font-weight: 700;
  color: #222;
  margin-bottom: 16px;
  line-height: 1.3;
}
.detail-desc {
  font-size: 14px;
  color: #555;
  line-height: 1.8;
  margin-bottom: 24px;
  white-space: pre-wrap;
}
.detail-section-title {
  font-size: 16px;
  font-weight: 700;
  color: #222;
  margin-bottom: 10px;
}
.detail-specs {
  font-size: 14px;
  color: #333;
  line-height: 2;
  margin-bottom: 24px;
}
.detail-specs .spec-item {
  display: inline;
  margin-right: 16px;
}
.detail-specs .spec-star {
  color: #c62828;
  margin-right: 4px;
}
.detail-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 16px;
  border-top: 1px solid #eee;
}
.detail-tag {
  display: inline-block;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  color: #555;
  background: #f5f5f5;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
}
.detail-actions {
  margin-top: 20px;
  display: flex;
  gap: 12px;
}

/* ===== Pagination ===== */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 24px;
}
.pagination button {
  padding: 6px 12px;
  border: 1px solid #ddd;
  background: #fff;
  cursor: pointer;
  font-size: 13px;
}
.pagination button.active {
  background: #c62828;
  color: #fff;
  border-color: #c62828;
}
.pagination button:disabled {
  opacity: 0.4;
  cursor: default;
}
.pagination-host { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 10px; }
.pagination-host .pagination { margin-top: 0; }
.pagination-host-top { min-height: 58px; margin: 0 0 16px; padding: 9px 14px; border: 1px solid var(--archive-line); border-radius: 14px; background: rgba(255,255,255,.82); scroll-margin-top: 18px; }
.pagination-host-bottom { min-height: 64px; margin-top: 18px; padding: 11px 14px; border: 1px solid var(--archive-line); border-radius: 14px; background: rgba(255,255,255,.9); box-shadow: 0 10px 28px rgba(64,40,27,.07); }
.pagination-summary { color: #786f68; font-size: 11px; font-weight: 800; white-space: nowrap; }
.pagination-host .pagination button { min-width: 38px; min-height: 38px; padding: 7px 10px; border-radius: 9px; font-weight: 800; }

/* ===== Toast ===== */
.toast {
  position: fixed;
  bottom: -60px;
  left: 50%;
  transform: translateX(-50%);
  background: #333;
  color: #fff;
  padding: 12px 24px;
  font-size: 14px;
  z-index: 300;
  transition: bottom 0.3s;
}
.toast.show { bottom: 30px; }

/* ===== Toolbar ===== */
.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}
.toolbar .filter-group {
  display: flex;
  gap: 8px;
  align-items: center;
}
.toolbar .filter-group select,
.toolbar .filter-group input {
  padding: 7px 10px;
  font-size: 13px;
  border: 1px solid #ddd;
  border-radius: 0;
}
.publisher-filter { min-width: 180px; display: flex; align-items: center; gap: 8px; }
.tin-search { display: flex; align-items: center; gap: 8px; }
.tin-search input { width: min(380px, 42vw); min-width: 260px; height: 40px; }
.tin-search .btn { height: 40px; white-space: nowrap; }
.tin-toolbar { display: grid; grid-template-columns: auto 150px 132px 190px minmax(280px, 1fr); align-items: center; gap: 10px; padding: 14px 16px; border: 1px solid var(--archive-line); border-radius: 16px; background: rgba(255,255,255,.72); box-shadow: 0 10px 30px rgba(64,40,27,.06); }
.tin-toolbar .publisher-filter { grid-column: 4; grid-row: 1; min-width: 190px; }
.tin-toolbar .filter-group { display: contents; }
.tin-toolbar .tin-search { grid-column: 5; grid-row: 1; min-width: 260px; }
.tin-toolbar .tin-search input { flex: 1 1 auto; width: auto; min-width: 0; padding: 0 16px; background: #fff; }
.tin-toolbar .tin-search .btn { flex: 0 0 auto; min-width: 72px; }
.tin-toolbar #filter-category { grid-column: 2; grid-row: 1; width: 150px; height: 40px; background: #fff; }
.tin-toolbar #filter-era { grid-column: 3; grid-row: 1; width: 132px; height: 40px; background: #fff; }
.tin-toolbar > .btn { grid-column: 1; grid-row: 1; min-width: 86px; height: 40px; white-space: nowrap; }
.publisher-filter label { color: var(--archive-muted); font-size: 11px; font-weight: 900; white-space: nowrap; }
.publisher-filter select { min-width: 130px; height: 36px; padding: 0 10px; }
.publisher-chip { display: block; padding: 0 13px 10px; color: #9a918a; font-size: 10px; font-weight: 800; }
.detail-publisher { margin: -8px 0 13px; color: #8b8178; font-size: 11px; font-weight: 800; }

/* ===== Login Page ===== */
.login-page {
  display: flex;
  min-height: 100vh;
}
.login-left {
  flex: 0 0 42%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  background:
    linear-gradient(115deg, rgba(166, 30, 30, 0.95), rgba(140, 20, 20, 0.85) 42%, rgba(100, 15, 15, 0.75)),
    url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.03'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}
.login-right {
  flex: 1;
  display: flex;
  align-items: center;
  padding: 60px 80px;
  background: #fafafa;
  overflow-y: auto;
}
.login-right-inner {
  width: 100%;
  font-family: 'SimSun', '宋体', 'Noto Serif SC', 'Source Han Serif SC', serif;
}
.login-right-inner h2 {
  font-size: 28px;
  font-weight: 700;
  color: #222;
  letter-spacing: 0.5px;
  margin-bottom: 28px;
  line-height: 1.3;
  font-family: 'SimSun', '宋体', 'Noto Serif SC', 'Source Han Serif SC', serif;
}
.login-right-inner p {
  font-size: 15px;
  color: #444;
  line-height: 2;
  margin-bottom: 18px;
  text-indent: 2em;
  text-align: justify;
  font-family: 'SimSun', '宋体', 'Noto Serif SC', 'Source Han Serif SC', serif;
}
.login-box {
  width: 100%;
  max-width: 420px;
  padding: 48px 44px;
  background: #fff;
  box-shadow: 0 30px 100px rgba(0, 0, 0, 0.35);
}
.brand-mark {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 24px;
}
.brand-icon {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  background: #c62828;
  border-radius: 10px;
  font-size: 24px;
}
.brand-mark b {
  font-size: 20px;
  font-weight: 900;
  letter-spacing: 0.02em;
  color: #222;
}
.eyebrow {
  margin: 0 0 14px;
  color: #c62828;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}
.login-box h1 {
  margin: 0 0 16px;
  font-size: 44px;
  line-height: 1.05;
  letter-spacing: -0.04em;
  color: #222;
}
.login-box h1 em {
  font-style: normal;
  color: transparent;
  -webkit-text-stroke: 1.2px #c62828;
}
.login-box .subtitle {
  font-size: 14px;
  color: #666;
  line-height: 1.65;
  margin-bottom: 28px;
}
.login-tabs {
  display: flex;
  margin-bottom: 24px;
  border-bottom: 2px solid #eee;
}
.login-tab {
  flex: 1;
  text-align: center;
  padding: 12px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  color: #999;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.2s;
}
.login-tab.active {
  color: #c62828;
  border-bottom-color: #c62828;
}
.login-box form {
  display: grid;
  gap: 0;
}
.login-box label {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 11px;
  font-weight: 700;
  color: #666;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 16px;
}
.login-box input {
  width: 100%;
  padding: 12px 14px;
  font-size: 14px;
  border: 1px solid #ddd;
  border-radius: 0;
  background: #fff;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.login-box input:focus {
  outline: none;
  border-color: #c62828;
  box-shadow: 0 0 0 3px rgba(198, 40, 40, 0.1);
}
.form-error {
  min-height: 20px;
  color: #c62828;
  font-size: 12px;
  margin: 0 0 12px;
}
.btn.wide {
  width: 100%;
  margin-top: 8px;
  padding: 14px 20px;
  font-size: 13px;
}

/* ===== Profile ===== */
.profile-card {
  max-width: 480px;
  background: #fff;
  border: 1px solid #e0e0e0;
  padding: 28px;
}

/* ===== Empty State ===== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: #999;
}
.empty-state .icon { font-size: 48px; margin-bottom: 12px; }
.empty-state p { font-size: 14px; }

/* ===== Hamburger Menu Button ===== */
.hamburger {
  display: none;
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 150;
  width: 40px;
  height: 40px;
  background: #c62828;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
.hamburger span {
  display: block;
  width: 20px;
  height: 2px;
  background: #fff;
  border-radius: 1px;
  transition: all 0.2s;
}
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 99;
}

/* ===== Responsive ===== */

/* iPad portrait (768-1024) */
@media (max-width: 1024px) {
  .item-grid {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  }
  .main {
    padding: 24px 24px;
  }
}

/* Tablet & mobile (< 768px): sidebar becomes drawer */
@media (max-width: 768px) {
  .hamburger { display: none; }
  .sidebar {
    display: none;
  }
  .sidebar-overlay.show { display: none; }
  .main {
    margin-left: 0;
    padding: 24px 16px 96px;
  }
  .page-title {
    font-size: 24px;
  }
  .item-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
  }
  .item-card .card-body {
    padding: 12px;
  }
  .item-card .card-name {
    font-size: 14px;
  }
  .item-card .card-meta {
    font-size: 11px;
  }
  .item-card .card-actions {
    padding: 8px 12px;
  }
  .stats-row {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  }
  .stat-cell {
    padding: 14px 10px;
  }
  .stat-cell .stat-number {
    font-size: 28px;
  }
  .modal-overlay {
    align-items: flex-start;
    padding: 16px;
    overflow-y: auto;
  }
  .modal {
    width: 95%;
    max-width: none;
    padding: 20px;
    padding-bottom: 32px;
    max-height: none;
    overflow-y: visible;
    margin: auto 0;
  }
  .detail-name {
    font-size: 18px;
  }
  /* Detail photos: 2 per row on mobile */
  .detail-photos {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  .detail-photos img {
    width: 100%;
    max-height: 200px;
  }
  /* Toolbar: stack vertically on mobile */
  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }
  .toolbar .filter-group {
    flex-wrap: wrap;
  }
  .tin-search { width: 100%; }
  .tin-search input { width: 100%; min-width: 0; }
  .tin-search .btn { width: auto; padding: 10px 18px; }
  .toolbar .filter-group select,
  .toolbar .filter-group input {
    flex: 1;
    min-width: 120px;
    font-size: 14px;
    padding: 10px 12px;
  }
  .toolbar .btn {
    width: 100%;
    padding: 12px;
  }
  /* Profile card full width */
  .profile-card {
    max-width: none;
  }
  /* Touch-friendly button sizes */
  .btn-sm {
    padding: 8px 14px;
    font-size: 13px;
  }
  .card-actions .btn {
    min-height: 36px;
  }
  .login-page {
    flex-direction: column;
  }
  .login-left {
    flex: none;
    padding: 24px 16px;
  }
  .login-right {
    padding: 30px 20px;
  }
  .login-right-inner {
    width: 100%;
  }
  .login-right-inner h2 {
    font-size: 20px;
  }
  .login-right-inner p {
    font-size: 14px;
    line-height: 1.8;
  }
  .login-box {
    padding: 28px 20px;
  }
  .login-box h1 {
    font-size: 32px;
  }
  .brand-icon {
    width: 38px;
    height: 38px;
    font-size: 20px;
  }
  .brand-mark b {
    font-size: 16px;
  }
  /* Dashboard search responsive */
  .dashboard-search {
    flex-direction: column;
    gap: 8px;
  }
  .search-input {
    font-size: 16px; /* prevent iOS zoom */
    padding: 12px 14px;
  }
  .dashboard-search .btn {
    width: 100%;
    padding: 12px;
  }
}

/* Small phone (< 480px) */
@media (max-width: 480px) {
  .main {
    padding: 56px 12px 16px;
  }
  .item-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .stats-row {
    grid-template-columns: repeat(2, 1fr);
  }
  .stat-cell .stat-number {
    font-size: 24px;
  }
  .stat-cell .stat-label {
    font-size: 11px;
  }
  .modal {
    width: 100%;
    max-height: none;
    overflow-y: visible;
    padding: 16px;
    padding-bottom: 28px;
  }
  .login-box h1 {
    font-size: 26px;
  }
  .page-title {
    font-size: 20px;
  }
  /* Collapse inline 2-col grids in modals */
  .modal form [style*="grid-template-columns"] {
    grid-template-columns: 1fr !important;
  }
  .toolbar .filter-group {
    flex-direction: column;
  }
  .toolbar .filter-group select,
  .toolbar .filter-group input {
    min-width: 0;
    width: 100%;
  }
  .publisher-filter { width: 100%; min-width: 0; justify-content: space-between; }
  .publisher-filter select { flex: 1; min-width: 0; }
  .detail-actions {
    flex-direction: column;
  }
  .detail-actions .btn {
    width: 100%;
    padding: 12px;
  }
  /* Detail photos: still 2 per row, smaller on small phones */
  .detail-photos img {
    max-height: 150px;
  }
}

/* ===== User management ===== */
.user-management-page { max-width: 1500px; }
.user-management-shell {
  overflow: hidden;
  border: 1px solid var(--archive-line);
  border-radius: 18px;
  background: rgba(255,253,249,.94);
  box-shadow: var(--archive-shadow);
}
.user-management-head {
  min-height: 92px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 20px 24px;
  border-bottom: 1px solid var(--archive-line);
}
.user-management-head h2 { color: var(--archive-ink); font-size: 19px; }
.user-management-head p { margin-top: 5px; color: var(--archive-muted); font-size: 12px; }
.user-list { padding: 0 24px 24px; }
.user-loading { padding: 48px 20px 24px; color: var(--archive-muted); text-align: center; }
.user-row {
  min-height: 92px;
  display: grid;
  grid-template-columns: minmax(190px, 1.35fr) minmax(110px, .7fr) minmax(90px, .55fr) minmax(100px, .65fr) minmax(235px, auto);
  align-items: center;
  gap: 18px;
  padding: 17px 0;
  border-bottom: 1px solid var(--archive-line);
}
.user-row:last-child { border-bottom: 0; }
.user-row.is-disabled { opacity: .68; }
.user-account { min-width: 0; display: flex; align-items: center; gap: 12px; }
.user-list-avatar {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: var(--archive-red);
  font-size: 16px;
  font-weight: 900;
}
.user-account b { display: block; overflow: hidden; color: var(--archive-ink); font-size: 14px; text-overflow: ellipsis; }
.user-account small, .user-row-cell small { display: block; margin-top: 3px; color: var(--archive-muted); font-size: 10px; }
.user-row-cell > b { color: var(--archive-ink); font-size: 15px; }
.user-role, .user-status {
  display: inline-flex;
  align-items: center;
  min-height: 27px;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
}
.user-role { color: #6e6259; background: #eee9e3; }
.user-role.is-admin { color: #8c5a18; background: #f5e5c9; }
.user-status.is-enabled { color: #267146; background: #e3f2e8; }
.user-status.is-disabled { color: #8f3838; background: #f5dddd; }
.user-row-actions { display: flex; justify-content: flex-end; gap: 8px; }
.user-row-actions .btn { white-space: nowrap; }
.user-row-actions .btn:disabled { cursor: not-allowed; opacity: .5; background: #eee9e3; color: #796f67; }
.user-password-modal {
  position: fixed;
  inset: 0;
  z-index: 420;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(33,22,18,.58);
  backdrop-filter: blur(8px);
}
.user-password-modal.show { display: flex; }
.user-password-dialog {
  width: min(460px, 100%);
  padding: 25px;
  border: 1px solid var(--archive-line);
  border-radius: 18px;
  background: var(--archive-card);
  box-shadow: 0 30px 90px rgba(28,15,12,.3);
}
.user-password-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 15px; }
.user-password-head small { color: var(--archive-red); font-size: 9px; font-weight: 900; letter-spacing: .15em; }
.user-password-head h2 { margin-top: 4px; color: var(--archive-ink); font-size: 21px; }
.user-password-close { width: 38px; height: 38px; border: 1px solid var(--archive-line); border-radius: 50%; background: #fff; color: #766c65; font-size: 24px; }
.user-password-target { margin-bottom: 20px; padding: 11px 13px; color: var(--archive-muted); border-radius: 9px; background: #f2eee9; font-size: 12px; }
.user-password-target b { color: var(--archive-ink); }
.user-password-note { margin: 2px 0 20px; color: var(--archive-muted); font-size: 11px; line-height: 1.65; }
.user-password-actions { display: flex; justify-content: flex-end; gap: 9px; }

/* ===== Numbering rules ===== */
.numbering-page { max-width: 1550px; }
.numbering-shell { overflow: hidden; border: 1px solid var(--archive-line); border-radius: 18px; background: rgba(255,253,249,.94); box-shadow: var(--archive-shadow); }
.numbering-toolbar { min-height: 92px; display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; padding: 18px 22px; border-bottom: 1px solid var(--archive-line); }
.numbering-toolbar label { display: block; margin-bottom: 6px; color: var(--archive-muted); font-size: 10px; font-weight: 900; }
.numbering-toolbar select { min-width: 220px; }
.numbering-help { display: flex; align-items: center; gap: 14px; margin: 18px 22px 0; padding: 13px 15px; color: #756b64; border-left: 3px solid var(--archive-red); background: #f4efe9; font-size: 11px; line-height: 1.6; }
.numbering-help b { color: var(--archive-red); white-space: nowrap; }
.numbering-help strong { color: var(--archive-ink); }
.numbering-list { padding: 4px 22px 22px; }
.numbering-row { min-height: 92px; display: grid; grid-template-columns: minmax(190px, 1.3fr) minmax(150px, .9fr) 80px 90px 100px minmax(160px, auto); align-items: center; gap: 16px; padding: 16px 0; border-bottom: 1px solid var(--archive-line); }
.numbering-row:last-child { border-bottom: 0; }
.numbering-row.is-disabled { opacity: .62; }
.numbering-identity { min-width: 0; display: flex; align-items: center; gap: 12px; }
.numbering-identity > span { min-width: 52px; height: 42px; display: grid; place-items: center; padding: 0 8px; color: #fff; border-radius: 9px; background: var(--archive-red); font-size: 13px; font-weight: 900; letter-spacing: .05em; }
.numbering-identity b, .numbering-cell b { display: block; color: var(--archive-ink); font-size: 13px; }
.numbering-identity small, .numbering-cell small { display: block; margin-top: 4px; color: var(--archive-muted); font-size: 9px; }
.numbering-actions { display: flex; justify-content: flex-end; gap: 7px; }
.numbering-dialog { width: min(560px, 100%); }
.numbering-preview-box { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin: 2px 0 15px; padding: 14px 15px; border: 1px solid rgba(201,31,39,.2); border-radius: 10px; background: #fff7f1; }
.numbering-preview-box span { color: var(--archive-muted); font-size: 10px; font-weight: 800; }
.numbering-preview-box b { color: var(--archive-red); font-size: 21px; letter-spacing: .05em; }
.numbering-fields { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.numbering-preview { display: block; margin-top: 6px; color: var(--archive-muted); font-size: 10px; line-height: 1.5; }
input[readonly].form-control { color: #746a63; background: #f1ede8; }

@media (max-width: 900px) {
  .user-list { padding: 0 16px 16px; }
  .user-row { grid-template-columns: minmax(170px, 1.2fr) minmax(90px, .65fr) minmax(90px, .6fr) minmax(220px, auto); }
  .user-row-cell[data-label="资料"] { display: none; }
  .numbering-row { grid-template-columns: minmax(170px, 1.2fr) minmax(140px, .9fr) 80px 90px minmax(160px, auto); }
  .numbering-cell[data-label="位数"] { display: none; }
}

@media (max-width: 768px) {
  .user-management-page { padding-top: 22px; }
  .user-management-shell { border-radius: 14px; }
  .user-management-head { min-height: 74px; padding: 15px; }
  .user-management-head h2 { font-size: 17px; }
  .user-management-head p { line-height: 1.5; }
  .user-list { display: grid; gap: 10px; padding: 10px; }
  .user-row {
    min-height: 0;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px 8px;
    padding: 15px;
    border: 1px solid var(--archive-line);
    border-radius: 12px;
    background: #fff;
  }
  .user-account { grid-column: 1 / -1; padding-bottom: 11px; border-bottom: 1px solid var(--archive-line); }
  .user-row-cell { min-width: 0; }
  .user-row-cell::before { content: attr(data-label); display: block; margin-bottom: 6px; color: var(--archive-muted); font-size: 9px; font-weight: 800; }
  .user-row-cell[data-label="资料"] { display: block; }
  .user-row-actions { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; padding-top: 2px; }
  .user-row-actions .btn { width: 100%; min-height: 42px; }
  .user-password-modal { align-items: flex-end; padding: 0; }
  .user-password-dialog { width: 100%; padding: 22px 18px calc(20px + env(safe-area-inset-bottom)); border-radius: 20px 20px 0 0; }
  .user-password-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .user-password-actions .btn { width: 100%; min-height: 44px; }
  .numbering-page { padding-top: 22px; }
  .numbering-shell { border-radius: 14px; }
  .numbering-toolbar { min-height: 0; align-items: stretch; padding: 12px; }
  .numbering-toolbar > div { flex: 1; min-width: 0; }
  .numbering-toolbar select { width: 100%; min-width: 0; }
  .numbering-toolbar .btn { align-self: flex-end; min-height: 42px; }
  .numbering-help { align-items: flex-start; margin: 10px; }
  .numbering-list { display: grid; gap: 10px; padding: 0 10px 10px; }
  .numbering-row { min-height: 0; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 8px; padding: 14px; border: 1px solid var(--archive-line); border-radius: 12px; background: #fff; }
  .numbering-identity { grid-column: 1 / -1; padding-bottom: 11px; border-bottom: 1px solid var(--archive-line); }
  .numbering-cell { min-width: 0; }
  .numbering-cell::before { content: attr(data-label); display: block; margin-bottom: 5px; color: var(--archive-muted); font-size: 9px; font-weight: 800; }
  .numbering-cell[data-label="位数"] { display: block; }
  .numbering-actions { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; }
  .numbering-actions .btn { width: 100%; min-height: 42px; }
  .numbering-fields { grid-template-columns: 1fr; }
}

/* ===== Compact mobile editor & separated photo upload ===== */
.photo-upload-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.upload-field { padding: 14px; border: 1px dashed #d5cbc1; border-radius: 10px; background: #faf7f2; }
.upload-field label { display: flex; flex-direction: row; justify-content: space-between; align-items: center; }
.upload-field label span { color: #9b9188; font-size: 9px; font-weight: 500; letter-spacing: 0; text-transform: none; }
.upload-field small { display: block; margin-top: 7px; color: #9b9188; font-size: 9px; line-height: 1.45; }
.existing-photo-note { margin: -2px 0 12px; padding: 9px 11px; color: #736960; font-size: 10px; line-height: 1.5; border-radius: 8px; background: #eee8e1; }
.photo-manager { grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 10px; margin: 0 0 14px; }
.photo-manager-item { min-width: 0; padding: 7px; border: 1px solid var(--archive-line); border-radius: 10px; background: #fffdf9; }
.photo-manager-item.is-main { border-color: rgba(201,31,39,.45); box-shadow: inset 0 0 0 1px rgba(201,31,39,.12); }
.photo-manager-thumb { width: 100%; aspect-ratio: 3 / 4; display: block; padding: 0; overflow: hidden; border: 0; border-radius: 8px; background: #eee8e1; cursor: zoom-in; }
.photo-manager-thumb img { width: 100%; height: 100%; display: block; object-fit: cover; }
.photo-manager-meta { display: flex; justify-content: space-between; align-items: center; gap: 6px; margin-top: 7px; }
.photo-manager-meta span { color: var(--archive-ink); font-size: 11px; font-weight: 800; }
.photo-manager-meta small { color: var(--archive-muted); font-size: 9px; white-space: nowrap; }
.photo-manager-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 7px; }
.photo-manager-actions button { min-height: 28px; border: 1px solid var(--archive-line); border-radius: 7px; background: #fff; color: var(--archive-red); font-size: 10px; font-weight: 800; }
.photo-manager-actions button:only-child { grid-column: 1 / -1; color: #8f847b; }
archive-base-fields { display: block; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.era-fields { display: grid; grid-template-columns: .85fr 1.15fr; gap: 10px; }
.required-mark { margin-left: auto; color: var(--archive-red); font-size: 8px; font-weight: 700; letter-spacing: 0; text-transform: none; }
.attachment-field { margin-top: 10px; }
.detail-attachments { margin-top: 24px; }
.detail-attachments h4 { margin-top: 0; }
.detail-attachments a { display: flex; justify-content: space-between; align-items: center; padding: 10px 11px; color: #5f5750; font-size: 11px; border: 1px solid var(--archive-line); border-radius: 8px; background: #fff; }
.detail-attachments a + a { margin-top: 7px; }
.detail-attachments a b { color: var(--archive-red); font-size: 10px; }

@media (max-width: 768px) {
  .modal-overlay { z-index: 260; }
  #modal { align-items: center; padding: 10px; overflow: hidden; }
  #modal .modal { width: 100%; max-height: calc(100dvh - 20px); margin: 0; padding: 0; display: flex; flex-direction: column; overflow: hidden; }
  #modal .modal-header { flex: 0 0 auto; margin: 0; padding: 13px 16px; border-bottom: 1px solid var(--archive-line); background: #fff; }
  #modal .modal-header h3 { font-size: 16px; }
  #modal form { min-height: 0; padding: 8px 14px calc(92px + env(safe-area-inset-bottom)); overflow-y: auto; overscroll-behavior: contain; }
  #modal .section-label { margin: 10px 0 7px; padding-bottom: 5px; }
  #modal .form-group { margin-bottom: 9px; }
  #modal .form-group label { margin-bottom: 4px; font-size: 10px; }
  #modal .form-control { padding: 8px 10px; font-size: 13px; }
  #modal textarea.form-control { min-height: 54px; }
  #modal form > .btn-primary:last-child { position: sticky; z-index: 20; bottom: calc(8px + env(safe-area-inset-bottom)); min-height: 50px; margin: 10px -2px 0; box-shadow: 0 -14px 26px rgba(255,255,255,.96), 0 8px 20px rgba(117,25,31,.22); }
  .photo-upload-fields { grid-template-columns: 1fr; gap: 8px; }
  .badge-upload-fields { grid-template-columns: 1fr 1fr; }
  .upload-field { padding: 10px; }
  .upload-field .form-control { padding: 6px; }
  .photo-manager { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .photo-manager-item { padding: 6px; }
  .photo-manager-meta { display: block; margin-top: 5px; }
  .photo-manager-meta small { display: none; }
  .photo-manager-actions { grid-template-columns: 1fr; gap: 5px; }
  .photo-manager-actions button { min-height: 26px; font-size: 9px; }
  .era-fields { grid-template-columns: 1fr 1fr; gap: 8px; }
}

@media (min-width: 380px) and (max-width: 768px) {
  #modal form [style*="grid-template-columns"] { grid-template-columns: 1fr 1fr !important; gap: 9px !important; }
}

@media (max-width: 379px) {
  #modal form [style*="grid-template-columns"] { grid-template-columns: 1fr !important; }
  #modal .form-row, #modal .era-fields, #modal .badge-upload-fields { grid-template-columns: 1fr; }
}

/* ===== 2026 Visual Refresh ===== */
:root {
  --archive-red: #c91f27;
  --archive-red-dark: #a8161d;
  --archive-ink: #211d1a;
  --archive-muted: #746c65;
  --archive-paper: #f6f3ee;
  --archive-card: #fffdf9;
  --archive-line: #e5ded5;
  --archive-gold: #c29a62;
  --archive-shadow: 0 18px 55px rgba(64, 40, 27, .08);
}

body { color: var(--archive-ink); background: var(--archive-paper); }
.main {
  background:
    linear-gradient(rgba(158,128,96,.12) 1px, transparent 1px),
    linear-gradient(90deg, rgba(158,128,96,.12) 1px, transparent 1px),
    linear-gradient(rgba(211,34,42,.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(211,34,42,.08) 1px, transparent 1px),
    var(--archive-paper);
  background-size: 32px 32px, 32px 32px, 160px 160px, 160px 160px;
}
.main {
  max-width: none;
  background: var(--archive-paper);
  background-image:
    linear-gradient(rgba(158,128,96,.12) 1px, transparent 1px),
    linear-gradient(90deg, rgba(158,128,96,.12) 1px, transparent 1px),
    linear-gradient(rgba(211,34,42,.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(211,34,42,.08) 1px, transparent 1px),
    radial-gradient(circle at 78% 0, rgba(211, 34, 42, .075), transparent 28%);
  background-size: 32px 32px, 32px 32px, 160px 160px, 160px 160px, auto;
  padding: 42px clamp(24px, 4vw, 64px) 64px;
}
.sidebar {
  width: 244px;
  background: var(--archive-red);
  box-shadow: 10px 0 35px rgba(75, 15, 19, .12);
}
.main { margin-left: 244px; }
.sidebar-brand { padding: 28px 22px 24px; }
.sidebar-brand .brand-logo { border-radius: 12px; box-shadow: 0 8px 22px rgba(50, 8, 11, .25); }
.sidebar-brand .brand-logo { padding: 0; overflow: hidden; background: transparent; }
.sidebar-brand .brand-logo img { display: block; width: 100%; height: 100%; object-fit: cover; }
.sidebar-brand .brand-title { min-width: 0; }
.sidebar-brand h2 { color: #fff; font-size: 14px; line-height: 1.45; letter-spacing: .04em; white-space: normal; }
.sidebar-brand small { display: block; margin-top: 4px; color: rgba(255,255,255,.48); font-size: 8px; letter-spacing: .18em; }
.sidebar-nav { padding: 16px 12px; }
.nav-item { margin: 2px 0; padding: 11px 12px; border-radius: 9px; }
.nav-item.active { background: #fff; color: var(--archive-red); box-shadow: 0 8px 20px rgba(50, 8, 11, .18); }
.nav-item.active .nav-badge { color: #fff; background: var(--archive-red); }
.sidebar-footer { margin: 0 12px; padding: 18px 8px 0; }
.sidebar-footer .user-avatar { border-radius: 50%; }
.install-app { margin: 8px 12px 4px; padding: 10px 11px; display: flex; align-items: center; gap: 9px; color: rgba(255,255,255,.72); border: 1px solid rgba(255,255,255,.16); border-radius: 9px; background: rgba(255,255,255,.06); font-size: 10px; font-weight: 700; }
.install-app:hover, .install-app.ready { color: #fff; border-color: rgba(255,255,255,.34); background: rgba(255,255,255,.11); }
.install-app > span:first-child { width: 16px; height: 16px; }
.install-app > span:first-child svg { width: 100%; height: 100%; }
.install-app b { margin-left: auto; color: #d7ad78; font-size: 16px; }
@media (display-mode: standalone) { .install-app { display: none; } }

/* ===== Dashboard visual search trial ===== */
.search-control .btn-visual-search {
  min-width: 154px;
  border: 0;
  border-left: 1px solid #eadfd6;
  color: var(--archive-red);
  background: #fff7f2;
  font-weight: 900;
  white-space: nowrap;
}
.search-control .btn-visual-search:hover { background: #f7e7dc; }
.search-control .btn-visual-search:disabled { color: #9b928b; cursor: wait; }
.visual-score {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 3px 8px;
  border-radius: 999px;
  color: #fff;
  background: var(--archive-red);
  font-size: 10px;
  font-weight: 900;
  white-space: nowrap;
}
.visual-search-header span { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.visual-search-header small { color: #9b928b; font-size: 11px; font-weight: 500; }
.visual-search-loading {
  min-height: 180px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: #716760;
  background: rgba(255,255,255,.72);
  border: 1px solid #e1d8cf;
}
.visual-search-loading span {
  width: 30px;
  height: 30px;
  border: 3px solid #eadfd6;
  border-top-color: var(--archive-red);
  border-radius: 50%;
  animation: visual-search-spin .8s linear infinite;
}
.visual-search-loading small { color: #9b928b; }
@keyframes visual-search-spin { to { transform: rotate(360deg); } }

@media (max-width: 768px) {
  .search-control .btn-visual-search,
  .search-control .btn-primary {
    flex: 1 1 calc(50% - 5px);
    width: calc(50% - 5px);
    min-width: 0;
  }
  .search-control .btn-visual-search { margin-right: 10px; border-left: 0; }
  .visual-search-header { align-items: flex-start; gap: 10px; }
  .visual-search-header .btn { flex: 0 0 auto; }
}
.btn { border-radius: 9px; }
.btn-primary { background: var(--archive-red); box-shadow: 0 8px 18px rgba(169,35,42,.16); }
.btn-primary:hover { background: var(--archive-red-dark); transform: translateY(-1px); }
.item-card, .profile-card, .modal { border-color: var(--archive-line); border-radius: 14px; box-shadow: var(--archive-shadow); }
.form-control, .toolbar .filter-group select, .toolbar .filter-group input { border-radius: 9px; border-color: var(--archive-line); }

/* Login */
.login-page {
  position: relative;
  isolation: isolate;
  width: 100%;
  min-height: 100vh;
  background: #c91f27;
  overflow-x: hidden;
  overflow-y: auto;
}
.login-page::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(rgba(255,255,255,.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.06) 1px, transparent 1px),
    linear-gradient(rgba(255,255,255,.1) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.1) 1px, transparent 1px);
  background-size: 32px 32px, 32px 32px, 160px 160px, 160px 160px;
}
.login-left { order: 2; flex: 0 0 min(43%, 590px); padding: clamp(28px, 5vw, 76px); background: transparent; }
.login-right { position: relative; order: 1; flex: 1; padding: clamp(48px, 7vw, 110px); background: transparent; overflow: visible; }
.login-right::after {
  content: '';
  position: absolute;
  right: clamp(36px, 8vw, 130px);
  top: clamp(34px, 8vh, 86px);
  width: 18px;
  height: 18px;
  border-radius: 4px;
  background: rgba(255,255,255,.2);
  box-shadow:
    -34px 0 rgba(255,255,255,.12),
    34px 0 rgba(255,255,255,.12),
    0 34px rgba(255,255,255,.12),
    0 68px rgba(255,255,255,.18);
  pointer-events: none;
}
.login-right-inner { max-width: 700px; color: #fff; text-shadow: 0 2px 20px rgba(0,0,0,.28); font-family: inherit; }
.login-right-inner .archive-kicker { margin: 0 0 18px; color: #e3c397; font: 800 11px/1.4 'Avenir Next', sans-serif; letter-spacing: .16em; text-indent: 0; }
.login-right-inner h2 { margin: 0 0 22px; color: #fff; font-family: 'Songti SC','SimSun',serif; font-size: clamp(28px, 2.7vw, 40px); font-weight: 700; letter-spacing: -.025em; line-height: 1.25; }
.login-right-inner p { max-width: 680px; margin: 0 0 12px; color: rgba(255,255,255,.84); font-family: 'Songti SC','SimSun',serif; font-size: 13px; line-height: 1.85; text-align: justify; text-indent: 2em; }
.archive-features { display: flex; gap: 12px; flex-wrap: wrap; margin: 30px 0; }
.archive-features span { display: flex; flex-direction: column; min-width: 130px; padding: 13px 16px; color: rgba(255,255,255,.72); font-size: 11px; border: 1px solid rgba(255,255,255,.24); border-radius: 10px; backdrop-filter: blur(8px); background: rgba(33,12,11,.22); }
.archive-features b { color: #fff; font-size: 21px; line-height: 1.25; }
.login-right blockquote { margin: 28px 0 0; padding-left: 18px; border-left: 2px solid var(--archive-gold); color: rgba(255,255,255,.78); font-family: 'Songti SC','SimSun',serif; font-size: 15px; }
.login-box { max-width: 430px; padding: 38px; border: 1px solid rgba(255,255,255,.65); border-radius: 20px; background: rgba(255,253,249,.94); box-shadow: 0 35px 90px rgba(15,4,4,.42); backdrop-filter: blur(18px); }
.brand-mark { align-items: center; margin-bottom: 30px; }
.brand-mark > div { display: flex; flex-direction: column; gap: 3px; }
.brand-mark b { font-size: 15px; }
.brand-mark small { color: #9b8d84; font-size: 8px; letter-spacing: .16em; }
.brand-icon { width: 46px; height: 46px; display: block; overflow: hidden; border-radius: 13px; background: #fff; box-shadow: 0 9px 20px rgba(169,35,42,.16); }
.brand-icon img { display: block; width: 100%; height: 100%; object-fit: cover; }
.login-box h1 { margin-bottom: 10px; color: var(--archive-ink); font-size: 34px; }
.login-box .subtitle { margin-bottom: 22px; color: var(--archive-muted); }
.login-tabs { padding: 4px; border: 0; border-radius: 10px; background: #eee9e3; }
.login-tab { padding: 9px; border: 0; border-radius: 7px; margin: 0; }
.login-tab.active { color: var(--archive-red); border: 0; background: #fff; box-shadow: 0 3px 10px rgba(46,31,22,.08); }
.login-box label { color: #5e554e; text-transform: none; }
.login-box input { padding: 13px 14px; border-color: #ddd5cc; border-radius: 9px; background: rgba(255,255,255,.82); }
.login-box .btn.wide { padding: 14px; }

/* Dashboard */
.dashboard-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; }
.dashboard-head .page-header { margin-bottom: 28px; }
.page-title { color: var(--archive-ink); -webkit-text-stroke: 0; font-size: clamp(32px, 3vw, 46px); font-weight: 800; }
.page-intro { margin-top: 10px; color: var(--archive-muted); font-size: 14px; }
.dashboard-date { padding: 9px 13px; color: var(--archive-muted); font-size: 12px; border: 1px solid var(--archive-line); border-radius: 999px; background: rgba(255,255,255,.7); }
.dashboard-hero { display: grid; grid-template-columns: minmax(280px, .9fr) minmax(420px, 1.1fr); grid-template-rows: minmax(170px, 1fr) auto; grid-template-areas: "copy covers" "copy search"; column-gap: clamp(28px, 5vw, 72px); row-gap: 24px; align-items: end; min-height: 420px; padding: clamp(38px, 6vw, 72px); border: 1px solid rgba(201,31,39,.18); border-radius: 0; color: #fff; background: var(--archive-red); box-shadow: 0 24px 70px rgba(64,40,27,.14); overflow: hidden; position: relative; }
.dashboard-hero::before { content: ''; position: absolute; inset: 0; background:
  linear-gradient(rgba(255,255,255,.055) 1px, transparent 1px),
  linear-gradient(90deg, rgba(255,255,255,.055) 1px, transparent 1px);
  background-size: 32px 32px;
}
.dashboard-hero::after {
  content: '';
  position: absolute;
  right: clamp(42px, 7vw, 108px);
  top: clamp(34px, 7vw, 82px);
  width: 20px;
  height: 20px;
  border-radius: 4px;
  background: rgba(255,255,255,.22);
  box-shadow:
    -40px 0 rgba(255,255,255,.11),
    40px 0 rgba(255,255,255,.11),
    0 40px rgba(255,255,255,.12),
    0 80px rgba(255,255,255,.18);
}
.hero-copy, .dashboard-search, .hero-toy-covers { position: relative; z-index: 1; }
.hero-copy { grid-area: copy; align-self: center; }
.hero-toy-covers { grid-area: covers; align-self: stretch; min-width: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; overflow: hidden; }
.hero-cover, .hero-cover-placeholder { min-width: 0; height: 100%; overflow: hidden; border: 1px solid rgba(255,255,255,.32); background: rgba(255,253,249,.96); }
.hero-cover { display: block; padding: 0; cursor: pointer; box-shadow: 0 15px 32px rgba(50,8,11,.2); }
.hero-cover img { display: block; width: 100%; height: 100%; object-fit: contain; object-position: center; }
.hero-cover-placeholder { opacity: .18; }
.dashboard-search { grid-area: search; }
.hero-label { color: #e0bc8d; font-size: 10px; font-weight: 900; letter-spacing: .2em; }
.hero-copy h1 { max-width: 760px; margin: 18px 0 18px; color: #fff; font-size: clamp(40px, 5.2vw, 82px); line-height: 1.02; font-weight: 900; letter-spacing: 0; }
.hero-total { display: flex; align-items: baseline; gap: 12px; margin: 9px 0; }
.hero-total b { font-size: clamp(54px, 6vw, 88px); line-height: 1; letter-spacing: -.055em; }
.hero-total span { color: rgba(255,255,255,.68); font-size: 12px; }
.hero-copy p { max-width: 480px; color: rgba(255,255,255,.72); font-size: 14px; line-height: 1.8; }
.dashboard-search { display: block; margin: 0; padding: 0; border: 0; border-radius: 0; background: transparent; backdrop-filter: none; }
.dashboard-search label { display: block; margin-bottom: 12px; color: rgba(255,255,255,.76); font-size: 11px; font-weight: 800; letter-spacing: .12em; }
.search-control { display: flex; align-items: stretch; min-height: 66px; padding-left: 18px; border: 1px solid rgba(255,255,255,.22); border-radius: 0; background: #fff; overflow: hidden; box-shadow: 0 18px 45px rgba(0,0,0,.16); }
.search-control svg { align-self: center; flex: 0 0 auto; width: 18px; height: 18px; fill: none; stroke: #9a918b; stroke-width: 1.8; }
.search-input { min-width: 0; padding: 0 14px; border: 0; font-size: 15px; }
.search-input:focus { border: 0; }
.search-control .btn { align-self: stretch; min-width: 128px; border-radius: 0; box-shadow: none; white-space: nowrap; }
.dashboard-section-head { display: flex; justify-content: space-between; align-items: flex-end; margin: 42px 0 14px; padding-bottom: 14px; border-bottom: 1px solid rgba(211,34,42,.14); }
.dashboard-section-head span, .panel-head span, .quick-card > span { color: var(--archive-red); font-size: 9px; font-weight: 800; letter-spacing: .17em; }
.dashboard-section-head h2, .panel-head h3, .quick-card h3 { margin-top: 5px; font-size: 22px; }
.dashboard-section-head p { color: var(--archive-muted); font-size: 12px; }
.dashboard-section-head p b { color: var(--archive-red); font-size: 18px; }
.stats-row { grid-template-columns: repeat(4, minmax(150px, 1fr)); gap: 0; border: 1px solid #d7cfc5; margin: 0; background: #fff; }
.stat-cell { position: relative; min-height: 138px; padding: 22px; border: 0; border-right: 1px solid #d7cfc5; border-bottom: 1px solid #d7cfc5; border-radius: 0; background: rgba(255,253,249,.94); box-shadow: none; transition: background .18s, color .18s; }
.stat-cell:nth-child(4n) { border-right: 0; }
.stat-cell:hover { z-index: 1; transform: none; border-color: #d7cfc5; background: var(--archive-red); box-shadow: none; }
.stat-icon { margin-bottom: 18px; color: var(--archive-red); font-size: 10px; font-weight: 900; letter-spacing: .16em; filter: none; }
.stat-cell .stat-label { margin-bottom: 5px; color: var(--archive-muted); font-size: 12px; }
.stat-value { display: flex; align-items: baseline; gap: 5px; }
.stat-cell .stat-number { color: var(--archive-red); font-size: 44px; line-height: 1; font-weight: 900; }
.stat-cell .stat-unit { margin: 0; color: #9b928b; }
.stat-arrow { position: absolute; right: 18px; top: 18px; color: #b9b0a8; transition: color .18s, transform .18s; }
.stat-cell:hover .stat-icon, .stat-cell:hover .stat-label, .stat-cell:hover .stat-number, .stat-cell:hover .stat-unit, .stat-cell:hover .stat-arrow { color: #fff; }
.stat-cell:hover .stat-arrow { transform: translate(2px,-2px); }
.dashboard-bottom { display: grid; grid-template-columns: 1.5fr .75fr; gap: 16px; margin-top: 16px; }
.distribution-card, .quick-card { padding: 25px; border: 1px solid var(--archive-line); border-radius: 16px; background: var(--archive-card); box-shadow: 0 8px 26px rgba(64,40,27,.045); }
.panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 21px; }
.panel-head b { padding: 6px 10px; color: var(--archive-red); font-size: 10px; border-radius: 999px; background: rgba(169,35,42,.08); }
.distribution-row { display: grid; grid-template-columns: 85px 1fr 26px; align-items: center; gap: 12px; padding: 9px 0; color: var(--archive-muted); font-size: 12px; }
.distribution-row i { height: 7px; border-radius: 999px; background: #eee8e1; overflow: hidden; }
.distribution-row em { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--archive-red), #cc6e56); }
.distribution-row b { color: var(--archive-ink); text-align: right; }
.quick-card { color: #fff; background: #24201d; border-color: #24201d; }
.quick-card > span { color: #d7ad78; }
.quick-card h3 { margin-bottom: 8px; }
.quick-card p { margin-bottom: 18px; color: rgba(255,255,255,.56); font-size: 12px; line-height: 1.6; }
.quick-card a { display: flex; justify-content: space-between; padding: 12px 0; color: rgba(255,255,255,.82); font-size: 12px; border-top: 1px solid rgba(255,255,255,.11); }
.quick-card a:hover { color: #fff; }
.quick-card a b { color: #d7ad78; }

/* Collection cards: image on the left, archive information on the right */
.item-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; }
.item-card { min-height: 0; display: grid; grid-template-columns: 1fr; grid-template-rows: auto 1fr auto; position: relative; background: var(--archive-card); overflow: hidden; }
.item-card .card-image { grid-row: auto; width: 100%; height: auto; min-height: 0; aspect-ratio: 4 / 3; background: #f4f0ea; }
.item-card .card-image img { height: 100%; object-fit: contain; transition: transform .35s ease; }
.item-card .card-image img { cursor: pointer; }
.detail-photos img { cursor: zoom-in; }
.item-card:hover .card-image img { transform: scale(1.035); }
.item-card .card-body { min-width: 0; display: flex; flex-direction: column; padding: 12px 13px 8px; }
.item-card .card-header { align-items: center; gap: 8px; margin-bottom: 8px; }
.item-card .card-item-no { overflow: hidden; color: var(--archive-red); font-size: 10px; font-weight: 900; letter-spacing: .08em; text-overflow: ellipsis; white-space: nowrap; }
.item-card .card-category { max-width: 48%; padding: 4px 7px; overflow: hidden; color: #675e57; font-size: 9px; border-radius: 999px; background: #eee8e1; text-overflow: ellipsis; white-space: nowrap; }
.item-card .card-name { margin-bottom: 8px; color: var(--archive-ink); font-size: 16px; font-weight: 800; line-height: 1.25; }
.item-card .card-meta { display: grid; grid-template-columns: 1fr; gap: 4px; }
.item-card .meta-line { display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: 6px; align-items: baseline; min-width: 0; }
.item-card .meta-line b { color: #9f968f; font-size: 10px; font-weight: 800; }
.item-card .meta-line em { overflow: hidden; color: #4c453f; font-size: 10px; font-style: normal; line-height: 1.35; text-overflow: ellipsis; white-space: nowrap; }
.item-card .card-view { display: flex; justify-content: space-between; align-items: center; margin-top: auto; padding-top: 8px; color: var(--archive-red); font-size: 10px; font-weight: 800; }
.item-card .card-view b { font-size: 14px; transition: transform .18s; }
.item-card:hover .card-view b { transform: translateX(3px); }
.item-card .card-actions { grid-column: auto; justify-content: flex-end; padding: 0 13px 10px; border: 0; }
.item-card .card-actions .btn { color: #756c65; border-color: #ddd6ce; background: transparent; }
.item-card .card-actions .btn.card-view-btn { color: #fff; border-color: var(--archive-red); background: var(--archive-red); }
.item-card .card-actions .card-view-btn:hover { color: #fff; border-color: var(--archive-red-dark); background: var(--archive-red-dark); }
.item-card .card-actions .btn:hover { color: var(--archive-red); border-color: var(--archive-red); }
.item-card .card-actions .btn-danger { color: #9e3b3b; border: 1px solid transparent; }

/* Archive detail viewer */
#detail-modal { padding: 28px; }
#detail-modal .modal { width: min(1180px, 96vw); max-width: 1180px; max-height: 94vh; padding: 0; overflow: hidden; background: var(--archive-card); }
#detail-modal .modal-header { height: 64px; margin: 0; padding: 0 24px; border-bottom: 1px solid var(--archive-line); }
#detail-modal .modal-header h3 { color: #756b64; font-size: 12px; font-weight: 700; letter-spacing: .08em; }
#detail-modal .modal-close { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 50%; background: #f0ebe5; color: #554d46; line-height: 1; }
#detail-modal .modal-close:hover { background: var(--archive-red); color: #fff; }
#detail-content { max-height: calc(90vh - 130px); overflow-y: auto; background: #f3efe9; }
.archive-detail-layout { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(360px, .7fr); min-height: 540px; }
.archive-detail-media { min-width: 0; padding: 24px; background:
  linear-gradient(rgba(158,128,96,.12) 1px, transparent 1px),
  linear-gradient(90deg, rgba(158,128,96,.12) 1px, transparent 1px),
  #ebe5dc;
  background-size: 28px 28px;
}
.detail-gallery { position: sticky; top: 0; display: grid; gap: 12px; }
.detail-main-photo { position: relative; min-height: 0; aspect-ratio: 4 / 3; display: grid; place-items: center; overflow: hidden; border-radius: 18px; background: #fffaf4; box-shadow: 0 18px 45px rgba(64,40,27,.12); }
.detail-main-photo img { width: 100%; height: 100%; max-height: none; object-fit: contain; cursor: zoom-in; }
.detail-photo-strip { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; }
.detail-thumb-photo { position: relative; aspect-ratio: 4 / 3; overflow: hidden; border-radius: 12px; background: #fffaf4; box-shadow: 0 8px 22px rgba(64,40,27,.08); }
.detail-thumb-photo { border: 2px solid transparent; transition: border-color .15s, transform .15s; }
.detail-thumb-photo:hover { transform: translateY(-2px); }
.detail-thumb-photo.is-active { border-color: var(--archive-red); }
.detail-thumb-photo img { width: 100%; height: 100%; object-fit: contain; cursor: zoom-in; }
.detail-thumb-photo span { position: absolute; right: 6px; top: 6px; min-width: 18px; height: 18px; display: grid; place-items: center; color: #fff; font-size: 9px; font-weight: 900; border-radius: 999px; background: rgba(33,29,26,.62); }
.archive-detail-media .detail-photos { position: relative; height: 100%; margin: 0; }
.archive-detail-media .no-photo { min-height: 470px; display: grid; place-items: center; border: 1px dashed #cfc5ba; border-radius: 18px; color: #a79d94; background: rgba(255,255,255,.45); }
.photo-count { position: absolute; z-index: 1; top: 12px; left: 12px; padding: 6px 9px; color: #fff; font-size: 9px; border-radius: 999px; background: rgba(35,29,25,.72); backdrop-filter: blur(6px); }
.archive-detail-info { min-width: 0; padding: 34px 38px 30px; overflow: hidden; background: var(--archive-card); }
.detail-summary { padding: 0 0 20px; border-bottom: 1px solid var(--archive-line); }
.detail-kicker { margin-bottom: 12px; color: var(--archive-red); font-size: 9px; font-weight: 900; letter-spacing: .18em; }
.archive-detail-info .detail-name { margin: 0 0 18px; color: var(--archive-ink); font: 800 34px/1.18 'Songti SC','SimSun',serif; letter-spacing: -.025em; }
.archive-detail-info .detail-tags { gap: 7px; padding: 0; border: 0; margin: 0; }
.archive-detail-info .detail-tag { padding: 5px 10px; color: #756b64; border: 1px solid #e3dbd1; border-radius: 999px; background: #fffaf4; font-size: 10px; }
.detail-highlights { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0; margin-top: 18px; border: 1px solid var(--archive-line); border-radius: 16px; overflow: hidden; background: #fffaf4; }
.detail-highlight { min-width: 0; padding: 14px 15px; border-right: 1px solid var(--archive-line); border-bottom: 1px solid var(--archive-line); }
.detail-highlight:nth-child(2n) { border-right: 0; }
.detail-highlight:nth-last-child(-n+2) { border-bottom: 0; }
.detail-highlight small { display: block; margin-bottom: 5px; color: #9a918a; font-size: 9px; font-weight: 900; letter-spacing: .05em; }
.detail-highlight b { display: block; overflow: hidden; color: var(--archive-red); font-size: 15px; font-weight: 900; line-height: 1.35; text-overflow: ellipsis; white-space: nowrap; }
.detail-panel { margin-top: 18px; padding: 0; border: 0; border-radius: 0; background: transparent; }
.detail-panel h4 { display: flex; align-items: center; gap: 8px; margin: 0 0 10px; color: var(--archive-ink); font-size: 12px; font-weight: 900; letter-spacing: .04em; }
.detail-panel h4::before { content: ''; width: 6px; height: 6px; border-radius: 2px; background: var(--archive-red); }
.archive-detail-info .detail-specs { display: block; margin: 0; border-top: 1px solid var(--archive-line); line-height: 1.4; }
.archive-detail-info .spec-item { min-width: 0; display: grid; grid-template-columns: 92px minmax(0, 1fr); gap: 14px; align-items: baseline; margin: 0; padding: 11px 0; border-bottom: 1px solid var(--archive-line); background: transparent; }
.archive-detail-info .spec-item small { display: block; margin: 0; color: #9a918a; font-size: 10px; font-weight: 900; }
.archive-detail-info .spec-item b { display: block; overflow-wrap: anywhere; color: #403934; font-size: 13px; font-weight: 700; line-height: 1.55; }
.detail-query { width: 100%; padding: 0; border: 0; background: transparent; text-align: left; cursor: pointer; }
.detail-query:hover b { color: var(--archive-red); text-decoration: underline; text-underline-offset: 3px; }
.archive-detail-info .detail-desc { margin: 0; padding: 14px 15px; color: #625a54; font-size: 12px; line-height: 1.75; border-left: 3px solid var(--archive-gold); border-radius: 0 12px 12px 0; background: #f3efe9; }
.detail-source { margin-top: 16px; }
.detail-source a { display: inline-flex; align-items: center; min-height: 34px; padding: 7px 11px; color: var(--archive-red); border: 1px solid rgba(201,31,39,.25); border-radius: 8px; background: #fff9f3; font-size: 11px; font-weight: 800; text-decoration: none; }
.detail-source a:hover { color: #fff; background: var(--archive-red); }
.standalone-detail-page { max-width: 1440px; margin-right: auto; }
.standalone-detail-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 16px; }
.standalone-detail-head > span { color: #8e847b; font-size: 11px; font-weight: 900; letter-spacing: .1em; }
.detail-back-link { display: inline-flex; align-items: center; min-height: 40px; padding: 0 14px; color: var(--archive-red); border: 1px solid rgba(201,31,39,.22); border-radius: 10px; background: #fff; font-size: 12px; font-weight: 900; }
.detail-back-link:hover { color: #fff; background: var(--archive-red); }
.standalone-detail-shell { overflow: hidden; border: 1px solid var(--archive-line); border-radius: 20px; background: var(--archive-card); box-shadow: 0 18px 55px rgba(64,40,27,.09); }
.standalone-detail-shell .archive-detail-layout { min-height: 0; }
.standalone-detail-shell .detail-gallery { position: static; }
.standalone-detail-shell .detail-thumb-photo { padding: 0; cursor: pointer; }
.standalone-detail-shell .detail-loading, .standalone-detail-shell .detail-error { min-height: 360px; display: grid; place-items: center; padding: 30px; color: #8d837a; font-size: 14px; text-align: center; }
#detail-modal .detail-actions { position: sticky; bottom: 0; z-index: 2; min-height: 66px; justify-content: flex-end; align-items: center; margin: 0; padding: 12px 24px; border-top: 1px solid var(--archive-line); background: rgba(255,253,249,.96); backdrop-filter: blur(12px); }
#detail-modal .detail-actions .btn-outline { order: -1; margin-right: auto; }
.image-preview { position: fixed; inset: 0; z-index: 500; display: none; align-items: center; justify-content: center; padding: clamp(14px, 3vw, 34px); background: rgba(20, 14, 12, .9); backdrop-filter: blur(10px); }
.image-preview.show { display: flex; }
.image-preview img { max-width: 100%; max-height: 100%; object-fit: contain; box-shadow: 0 24px 80px rgba(0,0,0,.38); }
.image-preview-close { position: fixed; top: max(14px, env(safe-area-inset-top)); right: 14px; min-width: 58px; min-height: 38px; padding: 0 14px; border: 1px solid rgba(255,255,255,.28); background: rgba(255,255,255,.12); color: #fff; font-size: 13px; font-weight: 800; }
.preview-open { overflow: hidden; }

@media (max-width: 1100px) {
  .login-right { padding: 50px; }
  .login-right-inner h2 { font-size: 30px; }
  .archive-features span { min-width: 110px; }
  .dashboard-hero { grid-template-columns: 1fr; grid-template-rows: auto minmax(170px, 220px) auto; grid-template-areas: "copy" "covers" "search"; }
  .stats-row { grid-template-columns: repeat(3, 1fr); }
  .stat-cell:nth-child(4n) { border-right: 1px solid #d7cfc5; }
  .stat-cell:nth-child(3n) { border-right: 0; }
  .item-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .tin-toolbar { display: grid; grid-template-columns: auto minmax(110px, 1fr) minmax(110px, 1fr) minmax(150px, 1fr); }
  .tin-toolbar > .btn { grid-column: 1; grid-row: 1; margin: 0; }
  .tin-toolbar #filter-category { grid-column: 2; grid-row: 1; width: 100%; }
  .tin-toolbar #filter-era { grid-column: 3; grid-row: 1; width: 100%; }
  .tin-toolbar .publisher-filter { grid-column: 4; grid-row: 1; }
  .tin-toolbar .filter-group { display: contents; }
  .tin-toolbar .tin-search { grid-column: 1 / -1; grid-row: 2; }
}

@media (max-width: 768px) {
  body.archive-app-page { padding-top: calc(36px + env(safe-area-inset-top)); }
  .main { margin-left: 0; padding: 18px 16px 96px; }
  .item-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tin-toolbar { grid-template-columns: repeat(3, minmax(0, 1fr)); padding: 12px; border-radius: 14px; }
  .tin-toolbar > .btn { grid-column: 1 / -1; grid-row: 1; width: 100%; }
  .tin-toolbar .publisher-filter { grid-column: 3; grid-row: 2; width: auto; min-width: 0; }
  .tin-toolbar .publisher-filter label { display: none; }
  .tin-toolbar .filter-group { display: contents; }
  .tin-toolbar #filter-category { grid-column: 1; grid-row: 2; width: 100%; }
  .tin-toolbar #filter-era { grid-column: 2; grid-row: 2; width: 100%; }
  .tin-toolbar .tin-search { grid-column: 1 / -1; grid-row: 3; min-width: 0; }
  .tin-toolbar .tin-search input { min-width: 0; }
  .standalone-detail-head > span { display: none; }
  .standalone-detail-shell { border-radius: 15px; }
  .login-page { display: flex; flex-direction: column; min-height: 100dvh; overflow-y: auto; padding-top: env(safe-area-inset-top); }
  .login-page::before { background: transparent; }
  .login-right { flex: 0 0 auto; min-height: 32dvh; padding: max(72px, calc(48px + env(safe-area-inset-top))) 24px 22px; }
  .login-right-inner h2 { font-size: 27px; }
  .login-right-inner p { display: block; font-size: 12px; line-height: 1.75; }
  .archive-features, .login-right blockquote { display: none; }
  .login-left { flex: 1 0 auto; display: flex; align-items: flex-start; justify-content: center; padding: 10px 16px calc(32px + env(safe-area-inset-bottom)); }
  .login-box { max-width: 520px; margin: 0 auto; padding: 28px 22px; }
  .dashboard-head { display: block; }
  .dashboard-date { display: inline-flex; margin-bottom: 20px; }
  .dashboard-hero { min-height: 0; grid-template-rows: auto auto auto; padding: 30px 20px; gap: 22px; align-items: stretch; }
  .hero-toy-covers { width: 100%; min-height: 0; max-height: none; aspect-ratio: 4 / 1; align-self: start; gap: 7px; }
  .hero-cover img { object-fit: cover; }
  .hero-copy h1 { font-size: 38px; }
  .hero-total b { font-size: 58px; }
  .dashboard-search { align-self: end; }
  .search-control { flex-wrap: wrap; min-height: 0; padding: 0; background: transparent; border: 0; box-shadow: none; }
  .search-control svg { display: none; }
  .search-control .search-input { flex: 0 0 100%; min-height: 58px; padding: 0 16px; border-radius: 0; background: #fff; font-size: 17px; }
  .search-control .btn { width: 100%; min-height: 52px; margin-top: 10px; padding: 14px; border-radius: 0; font-size: 15px; }
  .mobile-topbar { position: fixed; left: 0; right: 0; top: 0; z-index: 230; min-height: calc(36px + env(safe-area-inset-top)); display: flex; align-items: flex-end; justify-content: space-between; gap: 8px; padding: calc(4px + env(safe-area-inset-top)) 10px 4px; border-bottom: 1px solid rgba(201,31,39,.12); background: rgba(255,253,249,.96); box-shadow: 0 4px 14px rgba(64,40,27,.07); backdrop-filter: blur(16px); }
  .mobile-topbar-brand { min-width: 0; display: flex; align-items: center; gap: 7px; color: var(--archive-ink); font-size: 13px; font-weight: 900; }
  .mobile-topbar-brand img { width: 22px; height: 22px; border-radius: 7px; flex: 0 0 auto; }
  .mobile-topbar-brand span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .mobile-topbar-home { flex: 0 0 auto; min-width: 46px; height: 26px; border: 1px solid rgba(201,31,39,.2); border-radius: 999px; color: var(--archive-red); background: rgba(201,31,39,.07); font-size: 11px; font-weight: 900; }
  .main > .page-header { display: none; }
  .dashboard-head .page-header { display: block; }
  .mobile-bottom-nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 210; display: grid; grid-template-columns: repeat(var(--mobile-nav-count, 5), minmax(0, 1fr)); padding: 8px 6px max(8px, env(safe-area-inset-bottom)); border-top: 1px solid rgba(201,31,39,.14); background: rgba(255,253,249,.96); box-shadow: 0 -10px 28px rgba(64,40,27,.12); backdrop-filter: blur(14px); }
  .mobile-nav-btn { min-width: 0; height: 54px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: 0 2px; border: 0; border-radius: 0; color: #746c65; background: transparent; font-size: 10px; font-weight: 800; white-space: nowrap; }
  .mobile-nav-btn b { display: block; width: 100%; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; line-height: 1.15; text-align: center; }
  html[lang="en"] .mobile-nav-btn b { font-size: 9px; letter-spacing: -.02em; }
  .mobile-nav-btn span { width: 20px; height: 20px; }
  .mobile-nav-btn svg { width: 100%; height: 100%; }
  .mobile-nav-btn.active { color: var(--archive-red); background: rgba(201,31,39,.08); }
  .mobile-nav-sheet { position: fixed; left: 10px; right: 10px; bottom: calc(78px + env(safe-area-inset-bottom)); z-index: 211; display: none; padding: 14px; border: 1px solid rgba(201,31,39,.16); background: rgba(255,253,249,.98); box-shadow: 0 18px 45px rgba(64,40,27,.18); backdrop-filter: blur(16px); }
  .mobile-nav-sheet.show { display: block; }
  .mobile-nav-sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; color: var(--archive-ink); font-size: 14px; }
  .mobile-nav-sheet-head button { border: 0; background: transparent; color: var(--archive-red); font-size: 12px; font-weight: 800; }
  .mobile-nav-links { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .mobile-nav-links a, .mobile-nav-links button { min-height: 44px; display: flex; align-items: center; padding: 0 12px; border: 1px solid var(--archive-line); background: #fff; color: var(--archive-ink); font-size: 13px; font-weight: 700; text-align: left; }
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .stat-cell:nth-child(3n) { border-right: 1px solid #d7cfc5; }
  .stat-cell:nth-child(2n) { border-right: 0; }
  .stat-cell { min-height: 132px; }
  #modal { padding-top: calc(44px + env(safe-area-inset-top)); }
  #modal .modal { max-height: calc(100dvh - 62px - env(safe-area-inset-top)); }
  #detail-modal { align-items: flex-start; padding: calc(44px + env(safe-area-inset-top)) 10px 10px; }
  #detail-modal .modal { width: 100%; max-height: calc(100dvh - 54px - env(safe-area-inset-top)); border-radius: 18px 18px 0 0; }
  #detail-modal .modal-header { height: 56px; padding: 0 14px; }
  #detail-modal .modal-close { width: 42px; height: 42px; }
  #detail-content { max-height: calc(100dvh - 180px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); }
  .archive-detail-layout { grid-template-columns: 1fr; min-height: 0; }
  .archive-detail-media { padding: 12px; }
  .detail-gallery { position: static; gap: 9px; }
  .detail-main-photo { min-height: 0; aspect-ratio: 4 / 3; border-radius: 15px; }
  .detail-main-photo img { max-height: none; }
  .detail-photo-strip { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; scroll-snap-type: x mandatory; }
  .detail-thumb-photo { flex: 0 0 72px; scroll-snap-align: start; border-radius: 10px; }
  .archive-detail-media .no-photo { min-height: 240px; border-radius: 15px; }
  .archive-detail-info { padding: 22px 16px 24px; }
  .detail-summary { padding-bottom: 15px; }
  .archive-detail-info .detail-name { margin-bottom: 13px; font-size: 26px; }
  .detail-highlights { grid-template-columns: 1fr; margin-top: 14px; border-radius: 13px; }
  .detail-highlight { padding: 12px 13px; border-right: 0; }
  .detail-highlight:nth-last-child(-n+2) { border-bottom: 1px solid var(--archive-line); }
  .detail-highlight:last-child { border-bottom: 0; }
  .detail-highlight b { font-size: 14px; white-space: normal; }
  .detail-panel { margin-top: 15px; }
  .archive-detail-info .detail-specs { display: block; }
  .archive-detail-info .spec-item { grid-template-columns: 78px minmax(0, 1fr); gap: 10px; padding: 10px 0; }
  .archive-detail-info .spec-item b { font-size: 12px; }
  #detail-modal .detail-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); }
  #detail-modal .detail-actions .btn { width: 100%; min-height: 42px; padding: 10px 8px; }
  #detail-modal .detail-actions .btn-outline { order: 3; grid-column: 1 / -1; margin-right: 0; }
}

@media (max-width: 480px) {
  .login-right { min-height: 30dvh; padding-top: max(70px, calc(44px + env(safe-area-inset-top))); padding-bottom: 18px; }
  .login-right-inner h2 { font-size: 24px; }
  .login-right-inner p { font-size: 11px; line-height: 1.62; }
  .login-left { padding-top: 8px; }
  .login-box { width: 100%; padding: 24px 20px; }
  .archive-kicker { font-size: 8px !important; }
  .brand-mark b { font-size: 13px; }
  .stats-row { gap: 8px; }
  .stat-cell { min-height: 122px; padding: 15px; }
  .stat-icon { margin-bottom: 12px; }
  .stat-cell .stat-number { font-size: 27px; }
  .dashboard-section-head p { display: none; }
  .item-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .item-card { grid-template-columns: 1fr; grid-template-rows: auto 1fr auto; }
  .item-card .card-image { min-height: 0; aspect-ratio: 4 / 3; }
  .item-card .card-body { padding: 9px 9px 7px; }
  .item-card .card-header { margin-bottom: 5px; }
  .item-card .card-item-no { font-size: 9px; }
  .item-card .card-category { max-width: 52%; padding: 3px 5px; font-size: 8px; }
  .item-card .card-name { display: -webkit-box; min-height: 30px; margin-bottom: 6px; overflow: hidden; font-size: 12px; line-height: 1.25; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
  .item-card .card-view { display: none; }
  .item-card .card-meta { grid-template-columns: 1fr; gap: 5px; }
  .item-card .meta-line { grid-template-columns: 36px minmax(0, 1fr); gap: 5px; }
  .item-card .meta-line:nth-child(n+2) { display: none; }
  .item-card .meta-line b, .item-card .meta-line em { font-size: 10px; }
  .item-card .card-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 0 8px 9px; }
  .item-card .card-actions .btn { min-height: 30px; padding: 5px 0; font-size: 10px; }
  .item-card .card-actions .btn-danger { display: none; }
  .item-card .publisher-chip { display: none; }
  .toolbar { gap: 8px; margin-bottom: 12px; padding: 10px; border: 1px solid var(--archive-line); border-radius: 12px; background: rgba(255,255,255,.82); }
  .toolbar .publisher-filter { width: 100%; min-width: 0; }
  .toolbar .publisher-filter label { display: none; }
  .toolbar .publisher-filter select { width: 100%; min-width: 0; }
  .toolbar .filter-group { width: 100%; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .toolbar .filter-group > * { min-width: 0; width: 100%; }
  .toolbar .filter-group > *:only-child { grid-column: 1 / -1; }
  .tin-toolbar .filter-group { display: contents; }
  .toolbar .filter-group select, .toolbar .filter-group input { min-height: 36px; padding: 7px 9px; font-size: 12px; }
  .toolbar > .btn { min-height: 36px; padding: 8px 12px; font-size: 12px; }
  .tin-toolbar { gap: 7px; padding: 8px; }
  .tin-toolbar { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .tin-toolbar > .btn { grid-column: 1 / -1; grid-row: 1; width: 100%; min-height: 38px; padding: 8px 10px; }
  .tin-toolbar #filter-category { grid-column: 1; grid-row: 2; width: 100%; }
  .tin-toolbar #filter-era { grid-column: 2; grid-row: 2; width: 100%; }
  .tin-toolbar .publisher-filter { grid-column: 3; grid-row: 2; width: 100%; }
  .tin-toolbar .tin-search { grid-column: 1 / -1; grid-row: 3; }
  .tin-toolbar .publisher-filter select { height: 34px; font-size: 12px; }
  .tin-toolbar .tin-search { gap: 5px; }
  .tin-toolbar .tin-search input { height: 36px; padding: 0 10px; font-size: 12px; }
  .tin-toolbar .tin-search .btn { width: auto; min-width: 58px; height: 36px; padding: 6px 10px; font-size: 12px; }
  .tin-toolbar #filter-category { height: 36px; font-size: 12px; }
  .tin-toolbar #filter-era { height: 36px; font-size: 12px; }
  .pagination { flex-wrap: wrap; gap: 3px; margin-top: 10px; }
  .pagination button { min-width: 30px; min-height: 30px; padding: 4px 6px; font-size: 11px; }
  .pagination-host { gap: 4px; }
  .pagination-host-top { min-height: 0; margin-bottom: 10px; padding: 6px 7px; border-radius: 10px; }
  .pagination-host-bottom { min-height: 0; margin-top: 12px; padding: 7px; border-radius: 10px; }
  .pagination-summary { display: none; }
  .pagination-host .pagination { gap: 3px; }
  .pagination-host .pagination button { min-width: 28px; min-height: 28px; padding: 3px 5px; border-radius: 7px; font-size: 10px; }
  .pagination.pagination-mobile { width: 100%; display: grid; grid-template-columns: minmax(92px, 1fr) auto minmax(92px, 1fr); gap: 8px; margin-top: 0; }
  .pagination.pagination-mobile button, .pagination-host .pagination.pagination-mobile button { min-width: 0; min-height: 42px; padding: 9px 12px; border-radius: 9px; font-size: 13px; }
  .pagination-mobile-status { align-self: center; color: #756c65; font-size: 11px; font-weight: 900; white-space: nowrap; }
  .archive-detail-info .detail-specs { grid-template-columns: 1fr; }
  #detail-modal .detail-actions { flex-wrap: wrap; }
}

/* Keep the two dashboard search actions side by side on phones. */
@media (max-width: 768px) {
  .dashboard-search .search-control .btn-visual-search,
  .dashboard-search .search-control .btn-primary {
    flex: 1 1 calc(50% - 5px);
    width: calc(50% - 5px);
    min-width: 0;
  }
  .dashboard-search .search-control .btn-visual-search { margin-right: 10px; }
}

/* Managed search vocabulary */
.vocabulary-page { padding-bottom: 48px; }
.vocabulary-shell { padding: 24px; border: 1px solid var(--archive-line); border-radius: 20px; background: rgba(255,255,255,.88); box-shadow: 0 16px 42px rgba(72,43,31,.07); }
.vocabulary-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.vocabulary-type-tabs { display: flex; flex-wrap: wrap; gap: 8px; }
.vocabulary-type-tabs button { min-height: 40px; padding: 8px 17px; border: 1px solid var(--archive-line); border-radius: 999px; background: #fff; color: #655b54; font-size: 13px; font-weight: 800; cursor: pointer; }
.vocabulary-type-tabs button.active { border-color: var(--archive-red); background: var(--archive-red); color: #fff; box-shadow: 0 8px 18px rgba(206,31,38,.18); }
.vocabulary-example { display: flex; align-items: center; gap: 12px; margin: 20px 0 14px; padding: 14px 16px; border: 1px solid #eadcd3; border-radius: 13px; background: #fff9f5; color: #756a63; font-size: 13px; }
.vocabulary-example b { color: var(--archive-ink); }
.vocabulary-example code { padding: 5px 9px; border-radius: 7px; background: #251f1b; color: #fff; font-size: 12px; }
.vocabulary-example strong { color: var(--archive-red); }
.vocabulary-list { border-top: 1px solid var(--archive-line); }
.vocabulary-row { display: grid; grid-template-columns: minmax(170px,.75fr) minmax(280px,2fr) auto auto; align-items: center; gap: 18px; padding: 17px 4px; border-bottom: 1px solid var(--archive-line); }
.vocabulary-row.is-disabled { opacity: .62; }
.vocabulary-standard { min-width: 0; }
.vocabulary-standard small { display: block; margin-bottom: 4px; color: #a29891; font-size: 10px; font-weight: 900; letter-spacing: .12em; }
.vocabulary-standard b { display: block; overflow-wrap: anywhere; color: var(--archive-ink); font-size: 16px; }
.vocabulary-standard > span { display: inline-block; margin-top: 6px; padding: 3px 7px; border-radius: 999px; background: #f4ede8; color: #786e67; font-size: 10px; font-weight: 800; }
.vocabulary-aliases { display: flex; flex-wrap: wrap; gap: 6px; min-width: 0; }
.vocabulary-aliases span { max-width: 100%; padding: 5px 8px; overflow-wrap: anywhere; border: 1px solid #eadfd8; border-radius: 7px; background: #fff; color: #685e57; font-size: 11px; }
.vocabulary-aliases em { color: #aaa09a; font-size: 12px; }
.vocabulary-actions { display: flex; gap: 7px; }
.vocabulary-dialog { width: min(660px, calc(100vw - 32px)); }
.vocabulary-dialog textarea { min-height: 150px; resize: vertical; line-height: 1.65; }
.vocabulary-enabled { display: flex; align-items: center; align-self: end; gap: 9px; min-height: 44px; margin-bottom: 16px; color: #5f554f; font-size: 13px; font-weight: 800; cursor: pointer; }
.vocabulary-enabled input { width: 18px; height: 18px; accent-color: var(--archive-red); }

@media (max-width: 900px) {
  .vocabulary-row { grid-template-columns: minmax(140px,.8fr) minmax(220px,2fr) auto; }
  .vocabulary-state { display: none; }
}

@media (max-width: 768px) {
  .vocabulary-page { padding-bottom: 24px; }
  .vocabulary-shell { padding: 12px; border-radius: 14px; }
  .vocabulary-toolbar { align-items: stretch; flex-direction: column-reverse; gap: 11px; }
  .vocabulary-toolbar > .btn { width: 100%; min-height: 42px; }
  .vocabulary-type-tabs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
  .vocabulary-type-tabs button { min-height: 36px; padding: 6px 4px; font-size: 11px; }
  .vocabulary-example { display: grid; grid-template-columns: auto 1fr; gap: 7px 9px; margin: 13px 0 8px; padding: 11px; font-size: 11px; }
  .vocabulary-example code { justify-self: start; font-size: 10px; }
  .vocabulary-example span { grid-column: 1 / -1; line-height: 1.55; }
  .vocabulary-row { grid-template-columns: 1fr auto; gap: 10px; padding: 14px 2px; }
  .vocabulary-standard b { font-size: 15px; }
  .vocabulary-aliases { grid-column: 1 / -1; }
  .vocabulary-aliases span { font-size: 10px; }
  .vocabulary-actions { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; }
  .vocabulary-actions .btn { width: 100%; min-height: 36px; }
  .vocabulary-dialog { max-height: calc(100dvh - 20px); overflow-y: auto; }
  .vocabulary-dialog .form-row { grid-template-columns: 1fr; gap: 0; }
  .vocabulary-enabled { margin: 2px 0 13px; }
}

/* Mobile infinite paging */
.pagination-mobile-loader,
.pagination-mobile-end { display: none; }

@media (max-width: 768px) {
  .pagination-host:has(.pagination-mobile-loader),
  .pagination-host:has(.pagination-mobile-end) { min-height: 0; padding: 0; border: 0; background: transparent; box-shadow: none; }
  .pagination-host:has(.pagination-mobile-loader) .pagination-summary,
  .pagination-host:has(.pagination-mobile-end) .pagination-summary { display: none; }
  .pagination-mobile-loader { width: 100%; min-height: 76px; display: flex; align-items: center; justify-content: center; gap: 10px; color: #887e76; font-size: 12px; font-weight: 800; }
  .pagination-mobile-loader i { width: 22px; height: 22px; display: block; border: 3px solid #e1d8d0; border-top-color: var(--archive-red); border-radius: 50%; animation: mobile-page-spin .75s linear infinite; opacity: 0; }
  .pagination-mobile-loader.is-loading i { opacity: 1; }
  .pagination-mobile-loader.is-loading span { color: var(--archive-red); }
  .pagination-mobile-loader.is-loading span::before { content: '正在加载更多…'; }
  .pagination-mobile-loader.is-loading span { font-size: 0; }
  .pagination-mobile-loader.is-loading span::before { font-size: 12px; }
  .pagination-mobile-end { width: 100%; padding: 24px 0 12px; color: #a49a93; text-align: center; font-size: 11px; font-weight: 800; }
  @keyframes mobile-page-spin { to { transform: rotate(360deg); } }
}

/* Compact, search-first dashboard on phones */
@media (max-width: 768px) {
  .archive-home-hero.dashboard-hero { display: block; min-height: 0; margin: 0; padding: 12px; border: 0; background: var(--archive-red); box-shadow: 0 8px 22px rgba(80,23,27,.12); overflow: visible; }
  .archive-home-hero.dashboard-hero::before,
  .archive-home-hero.dashboard-hero::after,
  .archive-home-hero .hero-copy,
  .archive-home-hero .hero-toy-covers { display: none !important; }
  .archive-home-hero .dashboard-search { display: block; }
  .archive-home-hero .dashboard-search > label { display: none; }
  .archive-home-hero .search-control { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
  .archive-home-hero .search-control .search-input { grid-column: 1 / -1; min-height: 46px; padding: 0 13px; border-radius: 7px; font-size: 15px; }
  .archive-home-hero .search-control .btn,
  .archive-home-hero .search-control .btn-visual-search,
  .archive-home-hero .search-control .btn-primary { width: 100%; min-width: 0; min-height: 40px; margin: 0; padding: 8px 6px; border-radius: 7px; font-size: 12px; }
  .archive-home-hero .search-control .btn-visual-search { border-color: rgba(255,255,255,.72); color: #fff; background: rgba(255,255,255,.12); }
  .archive-home-hero .search-control .btn-primary { color: var(--archive-red); background: #fff; }
  .dashboard-section-head { align-items: center; margin: 15px 0 8px; padding-bottom: 8px; }
  .dashboard-section-head span { display: none; }
  .dashboard-section-head h2 { margin: 0; font-size: 17px; }
  .dashboard-section-head p { display: block; font-size: 10px; }
  .dashboard-section-head p b { font-size: 16px; }
  .stats-row { gap: 0; }
  .stat-cell { min-height: 94px; padding: 12px 13px; }
  .stat-icon { margin-bottom: 7px; font-size: 9px; }
  .stat-cell .stat-label { margin-bottom: 3px; font-size: 11px; }
  .stat-cell .stat-number { font-size: 29px; }
  .stat-cell .stat-unit { font-size: 10px; }
  .stat-arrow { right: 11px; top: 10px; font-size: 11px; }
}

/* ===== Loan management ===== */
.loan-page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; }
.loan-stat-grid { display: grid; grid-template-columns: repeat(5, minmax(120px, 1fr)); gap: 10px; margin-bottom: 18px; }
.loan-stat-card { min-height: 86px; display: flex; align-items: flex-end; justify-content: space-between; padding: 16px; border: 1px solid var(--archive-line); border-radius: 13px; background: rgba(255,255,255,.86); color: var(--archive-muted); cursor: pointer; }
.loan-stat-card span { font-size: 16px; font-weight: 900; }
.loan-stat-card b { color: var(--archive-red); font-size: 42px; line-height: .9; font-weight: 900; }
.loan-stat-card.active { border-color: var(--archive-red); color: #fff; background: var(--archive-red); }
.loan-stat-card.active b { color: #fff; }
.loan-shell, .loan-form-section, .loan-detail-hero, .loan-detail-grid, .loan-detail-items { border: 1px solid var(--archive-line); border-radius: 17px; background: rgba(255,255,255,.9); box-shadow: 0 12px 34px rgba(64,40,27,.055); }
.loan-shell { padding: 18px; }
.loan-toolbar { display: grid; grid-template-columns: minmax(0,1fr) 170px; gap: 10px; margin-bottom: 14px; }
.loan-search, .loan-toy-search { display: flex; gap: 8px; }
.loan-search .form-control, .loan-toy-search .form-control { min-width: 0; }
.loan-toolbar .form-control, .loan-toolbar .btn { height: 42px; min-height: 42px; padding-top: 7px; padding-bottom: 7px; }
.loan-toolbar .btn, .loan-toy-search .btn { min-width: 76px; white-space: nowrap; word-break: keep-all; }
.loan-list .empty-state { padding: 30px 16px; }
.loan-list .empty-state .icon { margin-bottom: 7px; font-size: 30px; }
.loan-shell .pagination-host-bottom:empty { display: none; }
.loan-list { border-top: 1px solid var(--archive-line); }
.loan-row { display: grid; grid-template-columns: minmax(175px,1.15fr) minmax(170px,1fr) minmax(170px,1fr) 120px 105px; align-items: center; gap: 16px; padding: 18px 8px; border-bottom: 1px solid var(--archive-line); cursor: pointer; transition: background .15s; }
.loan-row:hover { background: #fff9f5; }
.loan-row-main { min-width: 0; }
.loan-row-main small, .loan-row-cell small, .loan-detail-grid small, .loan-detail-item small { display: block; margin-bottom: 5px; color: #9a9089; font-size: 9px; font-weight: 900; letter-spacing: .08em; }
.loan-row-main > b { display: block; margin-bottom: 7px; color: var(--archive-ink); font-size: 15px; }
.loan-row-cell { min-width: 0; }
.loan-row-cell b, .loan-row-cell span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.loan-row-cell b { color: var(--archive-ink); font-size: 13px; }
.loan-row-cell span { margin-top: 4px; color: var(--archive-muted); font-size: 11px; }
.loan-row-action { color: var(--archive-red); font-size: 11px; font-weight: 900; text-align: right; }
.loan-status { display: inline-flex; width: fit-content; padding: 4px 8px; border-radius: 999px; font-size: 10px; font-weight: 900; }
.loan-status-active { color: #995f09; background: #fff0ca; }
.loan-status-partial { color: #8a4f0b; background: #ffe2bc; }
.loan-status-overdue { color: #fff; background: #bd2028; }
.loan-status-returned { color: #217144; background: #dff3e8; }
.loan-status-cancelled { color: #756c65; background: #e9e5e1; }

.loan-form-section { margin-bottom: 16px; padding: 24px; }
.loan-section-title { display: flex; align-items: flex-start; gap: 13px; margin-bottom: 20px; }
.loan-section-title > span { min-width: 36px; height: 28px; display: grid; place-items: center; border-radius: 6px; color: #fff; background: var(--archive-red); font-size: 10px; font-weight: 900; }
.loan-section-title h2 { margin-bottom: 4px; font-size: 19px; }
.loan-section-title p { color: var(--archive-muted); font-size: 11px; line-height: 1.5; }
.loan-section-title > b { margin-left: auto; padding: 6px 10px; border-radius: 999px; color: var(--archive-red); background: rgba(201,31,39,.08); font-size: 11px; }
.loan-form-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 0 16px; }
.loan-toy-picker { padding: 14px; border: 1px solid #e5ded5; border-radius: 12px; background: #f9f6f2; }
.loan-search-results { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 7px; max-height: 390px; margin-top: 10px; overflow-y: auto; }
.loan-search-results.is-empty { display: block; max-height: none; }
.loan-search-prompt { padding: 14px 12px; color: #8d837c; border: 1px dashed #d9d0c8; border-radius: 8px; background: rgba(255,255,255,.62); text-align: center; font-size: 11px; }
.loan-search-toy { min-width: 0; display: grid; grid-template-columns: 58px minmax(0,1fr) 18px; align-items: center; gap: 7px; padding: 6px; border: 1px solid var(--archive-line); border-radius: 9px; background: #fff; text-align: left; cursor: pointer; }
.loan-search-toy:hover { border-color: var(--archive-red); }
.loan-search-photo { width: 58px; height: 46px; display: grid; place-items: center; overflow: hidden; border-radius: 6px; background: #eee9e3; color: #aaa; font-size: 9px; }
.loan-search-photo img { width: 100%; height: 100%; object-fit: contain; }
.loan-search-toy b, .loan-search-toy small, .loan-search-toy em { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.loan-search-toy b { color: var(--archive-ink); font-size: 12px; }
.loan-search-toy small { margin-top: 5px; color: var(--archive-red); font-size: 9px; }
.loan-search-toy em { margin-top: 3px; color: var(--archive-muted); font-size: 9px; font-style: normal; }
.loan-search-toy i { color: var(--archive-red); font-size: 18px; font-style: normal; }
.loan-selected-list { margin-top: 14px; }
.loan-selected-empty, .loan-edit-lock { padding: 22px; color: #948a83; border: 1px dashed #d9d0c8; border-radius: 10px; text-align: center; font-size: 12px; }
.loan-edit-lock { border-style: solid; color: #7b5d2b; background: #fff7df; }
.loan-selected-row { position: relative; display: grid; grid-template-columns: minmax(260px,1.15fr) 160px minmax(260px,1fr) 62px; align-items: start; gap: 14px; padding: 15px 0; border-bottom: 1px solid var(--archive-line); }
.loan-selected-identity { display: flex; gap: 10px; padding-top: 6px; }
.loan-selected-identity > span { width: 27px; height: 27px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 50%; color: #fff; background: var(--archive-red); font-size: 10px; font-weight: 900; }
.loan-selected-identity b, .loan-selected-identity small { display: block; }
.loan-selected-identity b { margin-bottom: 5px; font-size: 14px; }
.loan-selected-identity small { color: var(--archive-muted); font-size: 10px; }
.loan-remove-toy { align-self: center; padding: 7px; border: 0; color: var(--archive-red); background: transparent; font-size: 11px; font-weight: 900; cursor: pointer; }
.loan-form-submit { position: sticky; bottom: 16px; z-index: 20; display: flex; justify-content: flex-end; gap: 9px; padding: 12px; border: 1px solid var(--archive-line); border-radius: 13px; background: rgba(255,253,249,.94); box-shadow: 0 12px 34px rgba(64,40,27,.15); backdrop-filter: blur(14px); }

.loan-detail-hero { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 24px; }
.loan-detail-hero h2 { margin: 12px 0 5px; font-size: 28px; }
.loan-detail-hero p { color: var(--archive-muted); font-size: 13px; }
.loan-detail-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.loan-detail-grid { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 0; margin-top: 14px; overflow: hidden; }
.loan-detail-grid > div { min-height: 82px; padding: 17px; border-right: 1px solid var(--archive-line); border-bottom: 1px solid var(--archive-line); }
.loan-detail-grid > div:nth-child(4n) { border-right: 0; }
.loan-detail-grid b { color: var(--archive-ink); font-size: 13px; overflow-wrap: anywhere; }
.loan-detail-grid .loan-detail-wide { grid-column: span 2; }
.loan-detail-items { margin-top: 14px; padding: 24px; }
.loan-detail-item { display: grid; grid-template-columns: 38px 108px minmax(220px,1.2fr) minmax(190px,1fr) minmax(190px,1fr); gap: 15px; padding: 17px 0; border-top: 1px solid var(--archive-line); }
.loan-detail-item.is-returned { opacity: .72; }
.loan-detail-item-no { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 8px; color: #fff; background: var(--archive-red); font-size: 10px; font-weight: 900; }
.loan-detail-item-photo { width: 108px; height: 82px; display: grid; place-items: center; overflow: hidden; border: 1px solid var(--archive-line); border-radius: 9px; background: #f2ede7; color: #aaa; font-size: 10px; }
.loan-detail-item-photo img { width: 100%; height: 100%; object-fit: contain; cursor: zoom-in; }
.loan-detail-item-name b, .loan-detail-item-name span, .loan-detail-item-name small { display: block; }
.loan-detail-item-name b { margin-bottom: 5px; font-size: 14px; }
.loan-detail-item-name span { color: var(--archive-red); font-size: 10px; }
.loan-detail-item-name small { margin-top: 5px; }
.loan-detail-item p { margin-top: 5px; color: var(--archive-muted); font-size: 11px; line-height: 1.5; }
.loan-returned-mark { color: #217144; }
.loan-not-returned-mark { color: #bd2028; }
.loan-return-dialog { width: min(820px,calc(100vw - 30px)); max-height: calc(100dvh - 30px); overflow-y: auto; }
.loan-return-list { border-top: 1px solid var(--archive-line); }
.loan-return-row { display: grid; grid-template-columns: minmax(220px,1fr) 170px minmax(240px,1fr); gap: 13px; padding: 14px 4px; border-bottom: 1px solid var(--archive-line); opacity: .55; }
.loan-return-row.selected { opacity: 1; background: #fffaf6; }
.loan-return-check { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.loan-return-check input { width: 20px; height: 20px; accent-color: var(--archive-red); }
.loan-return-check b, .loan-return-check small { display: block; }
.loan-return-check small { margin-top: 5px; color: var(--archive-red); font-size: 10px; }

/* Formal A4 loan order */
.loan-print-body { display: block; min-height: 100vh; padding: 28px; color: #181818; background: #e8e5e1; }
.loan-print-tools { position: sticky; top: 12px; z-index: 10; max-width: 210mm; display: flex; justify-content: flex-end; gap: 8px; margin: 0 auto 12px; }
.loan-print-tools button { padding: 10px 16px; border: 1px solid #ccc; border-radius: 7px; background: #fff; cursor: pointer; }
.loan-print-tools .primary { border-color: #b51920; color: #fff; background: #b51920; }
.loan-print-sheet { width: 210mm; min-height: 297mm; margin: 0 auto; padding: 16mm 15mm 13mm; background: #fff; box-shadow: 0 16px 50px rgba(0,0,0,.14); }
.loan-print-header { display: flex; align-items: flex-start; justify-content: space-between; padding-bottom: 8mm; border-bottom: 2px solid #b51920; }
.loan-print-brand { display: flex; align-items: center; gap: 10px; }
.loan-print-brand img { width: 17mm; height: 17mm; }
.loan-print-brand b, .loan-print-brand span { display: block; }
.loan-print-brand b { font-size: 15px; }
.loan-print-brand span { margin-top: 4px; color: #777; font-size: 7px; letter-spacing: .08em; }
.loan-print-title { text-align: right; }
.loan-print-title h1 { color: #b51920; font-size: 29px; letter-spacing: .14em; }
.loan-print-title p { margin-top: 3px; color: #777; font-size: 8px; letter-spacing: .2em; }
.loan-print-number { display: flex; justify-content: space-between; padding: 5mm 0 3mm; font-size: 10px; }
.loan-print-number b { color: #b51920; }
.loan-print-info { display: grid; grid-template-columns: repeat(2,1fr); border-top: 1px solid #555; border-left: 1px solid #555; }
.loan-print-info > div { display: grid; grid-template-columns: 27mm 1fr; min-height: 10mm; align-items: center; border-right: 1px solid #555; border-bottom: 1px solid #555; font-size: 9px; }
.loan-print-info span { align-self: stretch; display: flex; align-items: center; padding: 2mm 3mm; border-right: 1px solid #777; background: #f2f2f2; }
.loan-print-info b { padding: 2mm 3mm; font-weight: 600; }
.loan-print-table { width: 100%; margin-top: 6mm; border-collapse: collapse; table-layout: fixed; font-size: 8px; }
.loan-print-table th, .loan-print-table td { padding: 2.5mm 2mm; border: 1px solid #555; vertical-align: top; overflow-wrap: anywhere; line-height: 1.45; }
.loan-print-table th { background: #eee; font-weight: 700; }
.loan-print-table th:nth-child(1) { width: 8mm; }.loan-print-table th:nth-child(2) { width: 22mm; }.loan-print-table th:nth-child(3) { width: 27mm; }.loan-print-table th:nth-child(4) { width: 29mm; }.loan-print-table th:nth-child(5) { width: 27mm; }.loan-print-table th:nth-child(6) { width: 34mm; }
.loan-print-photo { padding: 1.5mm !important; text-align: center; color: #888; }
.loan-print-photo img { display: block; width: 19mm; height: 15mm; margin: 0 auto; object-fit: contain; }
.loan-print-notes { margin-top: 6mm; padding: 4mm; border: 1px solid #555; font-size: 8px; line-height: 1.7; }
.loan-print-notes > b { color: #b51920; font-size: 10px; }.loan-print-notes p { min-height: 8mm; padding: 2mm 0; border-bottom: 1px dashed #aaa; }.loan-print-notes ol { margin: 2mm 0 0 5mm; }
.loan-print-signatures { display: grid; grid-template-columns: repeat(3,1fr); gap: 5mm; margin-top: 8mm; }
.loan-print-signatures > div { min-height: 28mm; padding: 3mm; border: 1px solid #777; font-size: 8px; }
.loan-print-signatures span, .loan-print-signatures b, .loan-print-signatures small { display: block; }.loan-print-signatures b { min-height: 12mm; padding-top: 4mm; font-size: 11px; }.loan-print-signatures small { color: #555; }
.loan-print-footer { display: flex; justify-content: space-between; margin-top: 8mm; padding-top: 3mm; border-top: 1px solid #aaa; color: #777; font-size: 7px; }

@media (max-width: 900px) {
  .loan-search-results { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .loan-selected-row { grid-template-columns: minmax(220px,1fr) 150px minmax(220px,1fr); }
  .loan-remove-toy { grid-column: 1 / -1; justify-self: end; }
  .loan-detail-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .loan-detail-grid > div:nth-child(4n) { border-right: 1px solid var(--archive-line); }
  .loan-detail-grid > div:nth-child(2n) { border-right: 0; }
}

@media (max-width: 768px) {
  .loan-page-head { align-items: stretch; flex-direction: column; gap: 10px; }
  .loan-page-head > .btn { width: 100%; }
  .loan-stat-grid { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; margin-bottom: 12px; overflow: visible; }
  .loan-stat-card { min-width: 0; min-height: 72px; align-items: center; flex-direction: row; padding: 12px 14px; }
  .loan-stat-card:first-child { grid-column: 1 / -1; }
  .loan-stat-card span { min-width: 0; font-size: 12px; line-height: 1.25; }.loan-stat-card b { flex: 0 0 auto; font-size: 30px; }
  .loan-shell { padding: 10px; border-radius: 13px; }
  .loan-toolbar { grid-template-columns: 1fr; gap: 7px; }
  .loan-search .btn { padding-left: 12px; padding-right: 12px; }
  .loan-row { grid-template-columns: 1fr 105px; gap: 10px; padding: 14px 4px; }
  .loan-row-main { grid-column: 1; }.loan-row-cell { grid-column: 1 / -1; display: grid; grid-template-columns: 86px 1fr; align-items: center; gap: 8px; }
  .loan-row-cell small { margin: 0; }.loan-row-cell b, .loan-row-cell span { margin: 0; }
  .loan-row-action { grid-column: 2; grid-row: 1; align-self: center; }
  .loan-form-section { padding: 15px 12px; border-radius: 13px; }
  .loan-section-title { gap: 9px; margin-bottom: 14px; }.loan-section-title h2 { font-size: 16px; }.loan-section-title p { font-size: 10px; }
  .loan-section-title > b { white-space: nowrap; }
  .loan-form-grid { grid-template-columns: 1fr; gap: 0; }
  .loan-toy-picker { padding: 9px; }
  .loan-toy-search { display: grid; grid-template-columns: 1fr auto; }
  .loan-search-results { grid-template-columns: 1fr; max-height: 330px; }
  .loan-search-toy { grid-template-columns: 56px minmax(0,1fr) 18px; }.loan-search-photo { width: 56px; height: 44px; }
  .loan-selected-row { grid-template-columns: 1fr; gap: 4px; padding: 14px 0; }
  .loan-selected-identity { margin-bottom: 7px; }.loan-remove-toy { grid-column: 1; justify-self: end; }
  .loan-form-submit { bottom: calc(76px + env(safe-area-inset-bottom)); display: grid; grid-template-columns: .7fr 1.3fr; padding: 8px; }
  .loan-detail-hero { align-items: stretch; flex-direction: column; padding: 16px; }.loan-detail-hero h2 { font-size: 23px; }
  .loan-detail-actions { display: grid; grid-template-columns: 1fr 1fr; }.loan-detail-actions .btn { width: 100%; padding-left: 6px; padding-right: 6px; font-size: 10px; }
  .loan-detail-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }.loan-detail-grid > div { min-height: 72px; padding: 12px; }.loan-detail-grid .loan-detail-wide { grid-column: 1 / -1; }
  .loan-detail-items { padding: 15px 12px; }
  .loan-detail-item { grid-template-columns: 34px 82px minmax(0,1fr); gap: 9px; }.loan-detail-item-photo { width: 82px; height: 64px; }.loan-detail-item > div:nth-child(n+4) { grid-column: 2 / -1; }.loan-detail-item-name { grid-column: 3; }
  .loan-return-dialog { width: calc(100vw - 16px); max-height: calc(100dvh - 16px); padding-left: 14px; padding-right: 14px; }
  .loan-return-row { grid-template-columns: 1fr; gap: 6px; }
  .loan-print-body { padding: 8px; overflow-x: auto; }.loan-print-tools, .loan-print-sheet { min-width: 210mm; }
}

@media print {
  @page { size: A4 portrait; margin: 0; }
  .loan-print-body { padding: 0; background: #fff; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .loan-print-tools { display: none !important; }
  .loan-print-sheet { width: 210mm; min-height: 297mm; margin: 0; box-shadow: none; page-break-after: always; }
  .loan-print-table tr, .loan-print-info, .loan-print-signatures { break-inside: avoid; }
}

/* ===== Chinese / English interface switch ===== */
.archive-language-switch {
  appearance: none;
  border: 1px solid rgba(201,31,39,.24);
  border-radius: 999px;
  color: var(--archive-red, #c91f27);
  background: rgba(255,255,255,.94);
  font: 800 11px/1 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  cursor: pointer;
  white-space: nowrap;
}
.archive-language-sidebar {
  width: calc(100% - 24px);
  min-height: 34px;
  margin: 4px 12px 0;
  padding: 7px 11px;
  display: flex;
  align-items: center;
  gap: 9px;
  border-color: rgba(255,255,255,.18);
  border-radius: 9px;
  color: rgba(255,255,255,.82);
  background: rgba(255,255,255,.07);
}
.archive-language-sidebar span { min-width: 24px; font-size: 12px; }
.archive-language-sidebar b { font-size: 10px; }
.archive-language-sidebar:hover { color: #fff; background: rgba(255,255,255,.12); }
.mobile-language-switch { flex: 0 0 auto; min-width: 42px; height: 26px; padding: 0 9px; }
.archive-language-floating {
  position: fixed;
  z-index: 500;
  top: max(14px, env(safe-area-inset-top));
  right: 14px;
  min-width: 48px;
  height: 34px;
  padding: 0 12px;
  box-shadow: 0 6px 22px rgba(64,40,27,.14);
}
@media (max-width: 768px) {
  .mobile-topbar-brand { flex: 1 1 auto; }
  .mobile-language-switch { margin-left: auto; }
  .archive-language-floating { top: max(9px, env(safe-area-inset-top)); right: 9px; }
}
@media print { .archive-language-switch { display: none !important; } }

/* ===== Lightweight archive knowledge graph ===== */
.knowledge-graph-page { max-width: 1560px; }
.graph-page-head { margin-bottom: 20px; }
.graph-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; padding: 12px; border: 1px solid var(--archive-line); border-radius: 16px; background: rgba(255,255,255,.88); }
.graph-type-tabs { display: flex; gap: 6px; padding: 4px; border-radius: 12px; background: #f1ebe4; }
.graph-type-tabs button { min-width: 105px; min-height: 38px; padding: 0 16px; border: 0; border-radius: 9px; color: #756b63; background: transparent; font-size: 12px; font-weight: 900; cursor: pointer; }
.graph-type-tabs button.active { color: #fff; background: var(--archive-red); box-shadow: 0 6px 14px rgba(201,31,39,.2); }
.graph-search { flex: 1; max-width: 560px; display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.graph-search .form-control { min-width: 0; }
.graph-shell { min-height: 440px; padding: 24px; border: 1px solid var(--archive-line); border-radius: 18px; background: rgba(255,255,255,.88); box-shadow: 0 16px 44px rgba(64,40,27,.07); }
.graph-overview-head, .graph-items-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.graph-overview-head small { color: var(--archive-red); font-size: 9px; font-weight: 900; letter-spacing: .14em; }
.graph-overview-head h2, .graph-items-head h2 { margin-top: 4px; font-size: 24px; }
.graph-summary, .graph-items-head p { color: #81766e; font-size: 11px; font-weight: 700; }
.graph-node-grid { display: grid; grid-template-columns: repeat(5,minmax(0,1fr)); gap: 10px; }
.graph-data-node { min-width: 0; }
.graph-overview-node, .graph-related-node { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px; border: 1px solid var(--archive-line); border-radius: 13px; color: var(--archive-ink); background: #fff; text-align: left; cursor: pointer; transition: border-color .18s, transform .18s, box-shadow .18s; }
.graph-overview-node:hover, .graph-related-node:hover { transform: translateY(-2px); border-color: rgba(201,31,39,.45); box-shadow: 0 10px 24px rgba(64,40,27,.09); }
.graph-overview-node b, .graph-related-node b { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.graph-overview-node span, .graph-related-node span { flex: 0 0 auto; padding: 4px 7px; border-radius: 999px; color: var(--archive-red); background: rgba(201,31,39,.08); font-size: 9px; font-weight: 900; }
.graph-empty { min-height: 280px; display: grid; place-items: center; color: #92877f; }
.graph-explore-head { margin-bottom: 14px; }
.graph-network { position: relative; padding: 12px 10px 28px; border-radius: 17px; background: linear-gradient(135deg, rgba(201,31,39,.045), rgba(213,172,119,.08)); overflow: hidden; }
.graph-root-wrap { display: flex; justify-content: center; }
.graph-root-node { width: min(100%, 360px); min-height: 112px; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 18px; border: 2px solid var(--archive-red); border-radius: 18px; color: #fff; background: var(--archive-red); box-shadow: 0 15px 34px rgba(201,31,39,.2); text-align: center; }
.graph-root-node small { margin-bottom: 7px; font-size: 9px; letter-spacing: .16em; opacity: .75; }
.graph-root-node b { max-width: 100%; font-size: 21px; line-height: 1.3; overflow-wrap: anywhere; }
.graph-root-node span { margin-top: 7px; font-size: 10px; opacity: .82; }
.graph-trunk { width: 2px; height: 32px; margin: 0 auto; background: rgba(201,31,39,.38); }
.graph-relation-title { margin-bottom: 12px; color: #71675f; font-size: 11px; letter-spacing: .08em; text-align: center; }
.graph-related-nodes { position: relative; display: flex; flex-wrap: wrap; justify-content: center; gap: 9px; }
.graph-related-nodes::before { content: ""; position: absolute; left: 8%; right: 8%; top: -13px; height: 1px; background: rgba(201,31,39,.22); }
.graph-related-node { min-width: 150px; max-width: 250px; }
.graph-muted { color: #aaa; }
.graph-items-head { margin-top: 28px; padding-top: 20px; border-top: 1px solid var(--archive-line); }
.graph-toy-grid { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 12px; }
.graph-toy-card { min-width: 0; display: grid; grid-template-columns: 100px minmax(0,1fr); gap: 12px; padding: 10px; border: 1px solid var(--archive-line); border-radius: 14px; background: #fff; cursor: pointer; }
.graph-toy-photo { width: 100px; height: 76px; display: grid; place-items: center; overflow: hidden; border-radius: 9px; color: #aaa; background: #f3efe9; font-size: 8px; }
.graph-toy-photo img { width: 100%; height: 100%; object-fit: contain; }
.graph-toy-copy { min-width: 0; display: flex; flex-direction: column; justify-content: center; }
.graph-toy-copy small { color: var(--archive-red); font-size: 8px; font-weight: 900; letter-spacing: .06em; }
.graph-toy-copy b { margin-top: 5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.graph-toy-copy p { margin-top: 5px; overflow: hidden; color: #81766e; font-size: 9px; line-height: 1.35; text-overflow: ellipsis; white-space: nowrap; }

@media (max-width: 1180px) {
  .graph-node-grid { grid-template-columns: repeat(3,minmax(0,1fr)); }
  .graph-toy-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
}
@media (max-width: 768px) {
  .knowledge-graph-page { padding-left: 10px; padding-right: 10px; }
  .graph-toolbar { align-items: stretch; flex-direction: column; gap: 9px; margin-bottom: 10px; padding: 9px; border-radius: 13px; }
  .graph-type-tabs { display: grid; grid-template-columns: 1fr 1fr; }
  .graph-type-tabs button { min-width: 0; }
  .graph-search { max-width: none; }
  .graph-search .btn { min-width: 62px; padding-left: 9px; padding-right: 9px; }
  .graph-shell { min-height: 360px; padding: 12px; border-radius: 14px; }
  .graph-overview-head { align-items: flex-start; flex-direction: column; gap: 5px; margin-bottom: 12px; }
  .graph-overview-head h2, .graph-items-head h2 { font-size: 19px; }
  .graph-node-grid { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 7px; }
  .graph-overview-node { min-height: 54px; padding: 10px; }
  .graph-overview-node b { font-size: 11px; }
  .graph-root-node { min-height: 96px; }
  .graph-root-node b { font-size: 18px; }
  .graph-related-nodes { gap: 7px; }
  .graph-related-node { min-width: calc(50% - 4px); max-width: calc(50% - 4px); padding: 10px; }
  .graph-related-node b { font-size: 10px; }
  .graph-items-head { align-items: flex-start; margin-top: 20px; padding-top: 15px; }
  .graph-items-head p { max-width: 48%; text-align: right; }
  .graph-toy-grid { grid-template-columns: 1fr; gap: 8px; }
  .graph-toy-card { grid-template-columns: 92px minmax(0,1fr); padding: 8px; }
  .graph-toy-photo { width: 92px; height: 70px; }
}
