* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --primary-light: #eef2ff;
  --accent: #8b5cf6;
  --danger: #ef4444;
  --danger-light: #fef2f2;
  --text: #18181b;
  --muted: #71717a;
  --bg: #f4f4f6;
  --page-bg: #f4f4f6;
  --card: #fff;
  --border: #e4e4e7;
  --shadow-sm: 0 1px 2px rgba(24,24,27,0.05), 0 1px 3px rgba(24,24,27,0.06);
  --shadow-md: 0 8px 24px rgba(24,24,27,0.08);
  --shadow-lg: 0 20px 50px rgba(24,24,27,0.14);
}

html, body {
  height: 100%;
  background: var(--page-bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; border: none; background: none; }
input { font: inherit; }

.app {
  max-width: 600px;
  min-height: 100vh;
  margin: 0 auto;
  background: var(--bg);
  padding-bottom: 84px;
  position: relative;
}

.header {
  background: linear-gradient(120deg, var(--primary), var(--accent));
  color: #fff;
  padding: 16px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.2px;
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: 0 4px 14px rgba(79,70,229,0.18);
}
.header .side { min-width: 48px; font-weight: 500; font-size: 13px; }
.header .side.right { display: flex; justify-content: flex-end; }
.header button.link {
  color: #fff;
  opacity: 0.92;
  background: rgba(255,255,255,0.16);
  padding: 6px 12px;
  border-radius: 999px;
  transition: opacity 0.15s, background 0.15s;
}
.header button.link:hover { opacity: 1; background: rgba(255,255,255,0.26); }
.header button.link.danger { color: #fff; background: rgba(239,68,68,0.35); }

.content { padding: 16px; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 18px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
}

.section-title {
  font-size: 15px;
  font-weight: 700;
  margin: 8px 2px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--text);
}

.btn {
  padding: 10px 16px;
  border-radius: 12px;
  font-size: 13.5px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  transition: transform 0.08s ease, box-shadow 0.15s ease, opacity 0.15s ease, background 0.15s ease;
}
.btn-primary { background: linear-gradient(120deg, var(--primary), var(--accent)); color: #fff; box-shadow: 0 4px 14px rgba(99,102,241,0.32); }
.btn-primary:disabled { opacity: 0.55; box-shadow: none; }
.btn-outline { background: #fff; color: var(--primary); border: 1px solid var(--border); }
.btn-outline:hover { border-color: var(--primary); background: var(--primary-light); }
.btn-danger-outline { background: #fff; color: var(--danger); border: 1px solid #fecaca; }
.btn-danger-outline:hover { background: var(--danger-light); }
.btn-block { display: flex; width: 100%; justify-content: center; }
.btn-sm { padding: 7px 12px; font-size: 12px; border-radius: 9px; }
@media (hover: hover) {
  .btn:hover { transform: translateY(-1px); }
  .btn-primary:hover { box-shadow: 0 6px 18px rgba(99,102,241,0.4); }
}
.btn:active { transform: translateY(0); }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.field input {
  width: 100%;
  padding: 11px 13px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  font-size: 14px;
  background: #fafafa;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.field input:focus { outline: none; border-color: var(--primary); background: #fff; box-shadow: 0 0 0 4px rgba(99,102,241,0.12); }
.field input:disabled { background: var(--bg); color: var(--muted); font-weight: 700; }
.field-hint { font-size: 12px; color: var(--muted); margin-top: 6px; }

.tabbar {
  position: fixed;
  bottom: 14px; left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 28px); max-width: 420px;
  background: rgba(255,255,255,0.88);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(228,228,231,0.8);
  border-radius: 999px;
  display: flex;
  padding: 6px;
  gap: 4px;
  z-index: 20;
  box-shadow: var(--shadow-lg);
}
.tabbar .tab {
  flex: 1;
  text-align: center;
  padding: 9px 0;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
  border-radius: 999px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  transition: color 0.15s ease, background 0.15s ease;
}
.tabbar .tab .icon { font-size: 18px; line-height: 1; }
.tabbar .tab.active { color: var(--primary-dark); background: var(--primary-light); }

.lang-switch {
  flex: none;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 0 4px 0 8px;
  margin-left: 2px;
  border-left: 1px solid var(--border);
}
.lang-switch button {
  font-size: 10.5px;
  font-weight: 700;
  padding: 5px 7px;
  border-radius: 999px;
  color: var(--muted);
}
.lang-switch button.active { background: var(--primary-light); color: var(--primary-dark); }

.gb-row {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 15px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.15s ease, transform 0.1s ease, border-color 0.15s ease;
}
.gb-row .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); display: inline-block; margin-right: 7px; }
.gb-row .title { font-weight: 700; font-size: 14.5px; margin-bottom: 4px; }
.gb-row .meta { color: var(--muted); font-size: 12px; }
.gb-row .count { font-weight: 700; color: var(--primary-dark); font-size: 13px; }
@media (hover: hover) {
  .gb-row:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); border-color: #ddd6fe; }
}

.profile-head { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; font-weight: 700; font-size: 15.5px; }
.profile-grid { display: flex; gap: 10px; margin-bottom: 16px; }
.profile-stat { flex: 1; background: var(--primary-light); border-radius: 14px; padding: 12px; text-align: center; }
.profile-stat .label { font-size: 11px; color: var(--primary-dark); opacity: 0.75; margin-bottom: 4px; font-weight: 600; }
.profile-stat .value { font-size: 19px; font-weight: 800; color: var(--primary-dark); }
.profile-stat .value.danger { color: var(--danger); }
.profile-actions { display: flex; gap: 8px; }
.profile-actions .btn { flex: 1; justify-content: center; }

.nav-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 15px;
  margin-bottom: 12px;
  transition: box-shadow 0.15s ease;
}
@media (hover: hover) { .nav-card:hover { box-shadow: var(--shadow-md); } }
.nav-card .emoji { font-size: 22px; width: 42px; height: 42px; background: var(--primary-light); border-radius: 13px; display: flex; align-items: center; justify-content: center; }
.nav-card .body { flex: 1; }
.nav-card .title { font-weight: 700; margin-bottom: 2px; font-size: 13.5px; }
.nav-card .desc { font-size: 12px; color: var(--muted); }
.nav-card .chevron { color: #d4d4d8; }

.admin-tag { display: inline-block; background: linear-gradient(120deg, var(--primary), var(--accent)); color: #fff; font-size: 10.5px; padding: 3px 9px; border-radius: 999px; font-weight: 700; letter-spacing: 0.3px; }

.item-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 14px;
  margin-bottom: 10px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
}
.item-card:not(.admin) { display: flex; align-items: center; gap: 12px; }
@media (hover: hover) {
  .item-card:hover { box-shadow: var(--shadow-md); border-color: #ddd6fe; }
}
.item-top { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 12px; }
.item-img {
  width: 64px; height: 64px;
  object-fit: cover;
  border-radius: 13px;
  background: var(--bg);
  flex-shrink: 0;
  cursor: pointer;
  border: 1px solid var(--border);
}
.item-body { flex: 1; min-width: 0; }
.item-row { display: flex; justify-content: space-between; gap: 8px; font-size: 12.5px; margin-bottom: 4px; }
.item-row .label { color: var(--muted); }
.item-row .value { font-weight: 700; text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.ratio-badge {
  flex-shrink: 0;
  min-width: 58px;
  text-align: center;
  font-size: 12px;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-radius: 12px;
  padding: 7px 5px;
  line-height: 1.45;
}
.ratio-badge.empty { color: var(--muted); background: var(--bg); font-weight: 500; border: 1px dashed var(--border); }

.admin-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.admin-grid .field { margin-bottom: 10px; }
.admin-grid .field input { padding: 9px 11px; font-size: 13px; }
.admin-actions { display: flex; gap: 8px; }
.admin-actions .btn { flex: 1; justify-content: center; }

.img-preview-mask {
  align-items: center;
  justify-content: center;
  padding: 20px;
  cursor: zoom-out;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.img-preview-mask img {
  max-width: 100%;
  max-height: 85vh;
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

.empty-state { text-align: center; color: var(--muted); padding: 56px 0; font-size: 13px; }

.item-row .value.rmb { color: var(--primary-dark); }

.item-row .value.value-with-copy {
  overflow: visible;
  text-overflow: clip;
  white-space: normal;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  justify-content: flex-end;
}
.value-with-copy .code-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.copy-btn {
  flex-shrink: 0;
  font-size: 11px;
  line-height: 1;
  padding: 3px 6px;
  border-radius: 6px;
  background: var(--primary-light);
  color: var(--primary-dark);
  transition: transform 0.08s ease, background 0.15s ease;
}
.copy-btn:active { transform: scale(0.92); }
@media (hover: hover) { .copy-btn:hover { background: #ddd6fe; } }

.stats-table-wrap { overflow-x: auto; border-radius: 14px; box-shadow: var(--shadow-sm); }
.stats-table { width: 100%; border-collapse: collapse; background: var(--card); font-size: 13px; }
.stats-table th, .stats-table td {
  padding: 10px 14px;
  text-align: left;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
}
.stats-table th {
  background: var(--bg);
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.stats-table tbody tr:last-child td { border-bottom: none; }
.stats-table td:nth-child(3), .stats-table td:nth-child(4) { font-weight: 600; }
.stats-table td:nth-child(4) { color: var(--primary-dark); }

.card.history-batch-card { max-width: none; }
.history-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.history-item:last-of-type { border-bottom: none; }
.history-item-body { flex: 1; min-width: 0; }
.history-code {
  font-size: 12.5px;
  font-weight: 700;
  margin-bottom: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.history-price-form { display: flex; gap: 6px; }
.history-price-form input {
  flex: 1;
  min-width: 0;
  padding: 7px 9px;
  font-size: 12.5px;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.history-price-form input:focus { outline: none; border-color: var(--primary); }
.history-total {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
  font-size: 13px;
  font-weight: 700;
  color: var(--primary-dark);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.toast {
  position: fixed;
  left: 50%; bottom: 100px;
  transform: translateX(-50%);
  background: rgba(24,24,27,0.92);
  color: #fff;
  padding: 11px 20px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  z-index: 100;
  max-width: 80%;
  text-align: center;
}
.toast.show { opacity: 1; }

.modal-mask {
  position: fixed; inset: 0;
  background: rgba(24,24,27,0.45);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  display: flex; align-items: flex-end; justify-content: center;
  z-index: 50;
}
.modal-mask .sheet {
  background: #fff;
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
  border-radius: 22px 22px 0 0;
  padding: 22px;
  box-shadow: 0 -12px 40px rgba(0,0,0,0.18);
}
.modal-mask .sheet h3 { margin-bottom: 16px; font-size: 16.5px; font-weight: 800; }
.modal-actions { display: flex; gap: 10px; margin-top: 8px; }
.modal-actions .btn { flex: 1; justify-content: center; }

/* ---------- Desktop: use the space like a real web app, top nav instead of floating tab ---------- */
@media (min-width: 720px) {
  :root { --page-bg: #eef0fb; }

  body {
    background:
      radial-gradient(circle at 10% 0%, rgba(99,102,241,0.10), transparent 40%),
      radial-gradient(circle at 95% 100%, rgba(139,92,246,0.08), transparent 45%),
      var(--page-bg);
  }

  .app {
    max-width: 920px;
    min-height: calc(100vh - 32px);
    margin: 16px auto;
    border-radius: 24px;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    padding-bottom: 0;
  }

  .header { border-radius: 0; padding: 18px 28px; order: 0; }
  .content { padding: 24px 28px 32px; order: 2; flex: 1; }

  /* Tab bar becomes an in-flow secondary nav pinned right under the header */
  .tabbar {
    position: static;
    order: 1;
    width: 100%; max-width: none;
    transform: none;
    background: #fff;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border: none;
    border-bottom: 1px solid var(--border);
    border-radius: 0;
    box-shadow: none;
    padding: 0 24px;
    justify-content: flex-start;
    gap: 28px;
  }
  .tabbar .tab {
    flex: none;
    flex-direction: row;
    gap: 6px;
    padding: 14px 2px;
    border-radius: 0;
    border-bottom: 2px solid transparent;
  }
  .tabbar .tab.active { background: none; border-bottom-color: var(--primary); }
  .tabbar .lang-switch { margin-left: auto; border-left: none; }
  .tabbar .tab .icon { font-size: 15px; }

  /* Narrow, readable forms/cards stay centered instead of stretching edge to edge */
  .card, .nav-card {
    max-width: 480px;
    margin-left: auto;
    margin-right: auto;
  }

  /* Lists of simple rows/cards fan out into columns to fill the wider content area */
  #batch-list, .item-list-user {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 12px;
    align-items: start;
  }
  #batch-list .gb-row, .item-list-user .item-card { margin-bottom: 0; }

  .modal-mask { align-items: center; }
  .modal-mask .sheet {
    max-width: 400px;
    border-radius: 20px;
    margin: 0 16px;
  }

  .toast { bottom: 50%; }
}

@media (min-width: 1100px) {
  .app { max-width: 1080px; }
}
