:root {
  --bg: #f4f7fb;
  --card: #ffffff;
  --text: #1e293b;
  --muted: #64748b;
  --line: #e2e8f0;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --danger: #dc2626;
  --shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

.app {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: linear-gradient(180deg, #0f172a, #1e3a8a);
  color: #fff;
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
}

.brand-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: rgba(255,255,255,0.15);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 20px;
}

.brand strong { display: block; font-size: 18px; }
.brand span { color: rgba(255,255,255,0.75); font-size: 12px; display: block; }
.save-status {
  font-size: 11px;
  margin-top: 6px;
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(255,255,255,0.12);
}
.login-form .field { display: block; margin-bottom: 14px; }
.login-form .field span {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 6px;
}
.login-form input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 15px;
}
.login-error {
  min-height: 20px;
  margin: 0 0 12px;
  color: var(--danger);
  font-size: 13px;
}
.login-submit { width: 100%; }
.login-modal-panel { max-width: 380px; }

.side-user {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid rgba(255,255,255,0.12);
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 13px;
  color: rgba(255,255,255,0.85);
}
.side-user-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.sync-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  background: #64748b;
}
.sync-dot.ok { background: #4ade80; box-shadow: 0 0 0 3px rgba(74,222,128,0.25); }
.sync-dot.pending { background: #fbbf24; box-shadow: 0 0 0 3px rgba(251,191,36,0.25); }
.sync-dot.err { background: #f87171; box-shadow: 0 0 0 3px rgba(248,113,113,0.25); }
.btn-login,
.btn-logout {
  border: 1px solid rgba(255,255,255,0.25);
  background: transparent;
  color: #fff;
  border-radius: 8px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 13px;
  width: 100%;
}
.btn-login {
  background: rgba(255,255,255,0.18);
  border-color: rgba(255,255,255,0.35);
  font-weight: 600;
}
.btn-login:hover { background: rgba(255,255,255,0.28); }
.btn-logout:hover { background: rgba(255,255,255,0.1); }
.side-login-box { display: flex; flex-direction: column; gap: 8px; }
#sideLoginBox[hidden],
#userBarLoggedIn[hidden],
#btnLogout[hidden] { display: none !important; }
body.auth-logged-in #sideLoginBox { display: none !important; }
body.auth-logged-in #userBarLoggedIn { display: flex !important; }
body.auth-logged-in #btnLogout { display: block !important; }
body:not(.auth-logged-in) #sideLoginBox { display: flex !important; }
body:not(.auth-logged-in) #userBarLoggedIn { display: none !important; }
body:not(.auth-logged-in) #btnLogout { display: none !important; }
.side-login-title {
  margin: 0;
  font-size: 13px;
  color: rgba(255,255,255,0.9);
}
.side-login-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.side-login-form input {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 8px;
  background: rgba(255,255,255,0.1);
  color: #fff;
  font-size: 14px;
}
.side-login-form input::placeholder { color: rgba(255,255,255,0.55); }
.side-login-form .login-error { min-height: 16px; margin: 0; color: #fecaca; font-size: 12px; }
body.logged-out .main,
body.logged-out .sidebar .ledger-panel,
body.logged-out .sidebar .nav,
body.logged-out .sidebar .side-stats {
  opacity: 0.45;
  pointer-events: none;
}
body.logged-out .sidebar .side-user,
body.logged-out .sidebar .brand {
  opacity: 1;
  pointer-events: auto;
}

.settings-title { margin: 0 0 12px; font-size: 16px; }
.password-form { display: grid; gap: 10px; max-width: 420px; }

.ledger-more {
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 8px;
  background: rgba(255,255,255,0.1);
  color: #fff;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  flex-shrink: 0;
}
.ledger-more:hover { background: rgba(255,255,255,0.2); }

.action-menu-panel { max-width: 320px; }
.action-menu-btns { display: flex; flex-direction: column; gap: 8px; }
.action-menu-btns .btn { width: 100%; justify-content: center; }
.action-menu-btns .danger-text { color: var(--danger); }

.img-cell {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
  max-width: 120px;
}
.img-cell .img-thumb { width: 36px; height: 36px; }
.img-count {
  font-size: 11px;
  color: var(--muted);
  background: #f1f5f9;
  padding: 1px 6px;
  border-radius: 999px;
}

.inline-img-gallery {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
  min-width: 80px;
}
.inline-img-gallery .inline-dropzone {
  width: 40px;
  height: 40px;
  min-height: 40px;
}
.inline-img-gallery .inline-dropzone.has-img {
  width: 40px;
  height: 40px;
  padding: 0;
}
.inline-img-gallery .inline-dropzone.has-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.inline-img-gallery .inline-dropzone.add-more {
  border-style: dashed;
  font-size: 18px;
  color: var(--muted);
  display: grid;
  place-items: center;
}

.img-gallery {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}
.img-gallery-item {
  position: relative;
  width: 72px;
  height: 72px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--line);
}
.img-gallery-item img { width: 100%; height: 100%; object-fit: cover; }
.img-gallery-item .img-rm {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 20px;
  height: 20px;
  border: none;
  border-radius: 4px;
  background: rgba(0,0,0,0.55);
  color: #fff;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
}

.ledger-panel {
  background: rgba(255,255,255,0.08);
  border-radius: 14px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 280px;
}
.ledger-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: rgba(255,255,255,0.75);
}
.btn-new-list {
  border: 1px dashed rgba(255,255,255,0.45);
  background: rgba(255,255,255,0.1);
  color: #fff;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
}
.btn-new-list:hover { background: rgba(255,255,255,0.18); }
.ledger-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow: auto;
}
.ledger-item {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255,255,255,0.06);
  border-radius: 10px;
  padding: 4px;
  border: 1px solid transparent;
}
.ledger-item.active {
  background: rgba(255,255,255,0.16);
  border-color: rgba(255,255,255,0.25);
}
.ledger-main {
  flex: 1;
  border: none;
  background: transparent;
  color: #fff;
  text-align: left;
  padding: 8px 10px;
  cursor: pointer;
}
.ledger-main strong {
  display: block;
  font-size: 13px;
  line-height: 1.3;
  word-break: break-all;
}
.ledger-main span {
  display: block;
  font-size: 11px;
  color: rgba(255,255,255,0.7);
  margin-top: 4px;
}
.ledger-actions {
  display: flex;
  gap: 2px;
  padding-right: 4px;
}
.icon-btn {
  width: 26px;
  height: 26px;
  border: none;
  border-radius: 6px;
  background: rgba(255,255,255,0.12);
  color: #fff;
  cursor: pointer;
  font-size: 13px;
}
.icon-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
.icon-btn.danger { color: #fecaca; }

.nav { display: flex; flex-direction: column; gap: 8px; }
.nav-btn {
  border: none;
  background: transparent;
  color: rgba(255,255,255,0.85);
  text-align: left;
  padding: 12px 14px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
}
.nav-btn.active, .nav-btn:hover {
  background: rgba(255,255,255,0.12);
  color: #fff;
}

.side-stats {
  margin-top: auto;
  display: grid;
  gap: 12px;
  background: rgba(255,255,255,0.08);
  border-radius: 14px;
  padding: 16px;
}
.side-stats span { display: block; font-size: 12px; color: rgba(255,255,255,0.7); }
.side-stats strong { font-size: 22px; }

.main { padding: 24px; }
.view { display: none; }
.view.active { display: block; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 18px;
}
.topbar h1 { margin: 0 0 6px; font-size: 28px; }
.topbar p { margin: 0; color: var(--muted); font-size: 14px; }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; }

.btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  padding: 10px 16px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
}
.btn.primary {
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
  color: #fff;
  border: none;
}
.btn.ghost { background: #fff; }
.btn.small { padding: 8px 12px; font-size: 13px; }

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

.batch-edit-filter {
  margin: 0 0 14px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #f8fafc;
  color: var(--muted);
  font-size: 13px;
}
.batch-edit-form .field select,
.batch-edit-form .field input[type="text"] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 14px;
}
.batch-img-dropzone {
  border: 1px dashed #cbd5e1;
  border-radius: 12px;
  padding: 16px;
  text-align: center;
  cursor: pointer;
  background: #f8fafc;
}
.batch-img-dropzone.dragover {
  border-color: var(--primary);
  background: #eff6ff;
}
.batch-img-dropzone p {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 13px;
}
.batch-img-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}
.batch-img-preview .batch-img-item {
  position: relative;
  width: 72px;
  height: 72px;
}
.batch-img-preview img {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
}
.batch-img-preview .batch-img-rm {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 20px;
  height: 20px;
  border: none;
  border-radius: 50%;
  background: var(--danger);
  color: #fff;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
}
#btnBatchEdit:not(:disabled) {
  color: var(--primary);
  border-color: #bfdbfe;
  background: #eff6ff;
}

.filters {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.filter-row {
  display: grid;
  grid-template-columns: 1fr 220px;
  gap: 12px;
}
.filter-row.four {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
.filter-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.filter-summary {
  font-size: 13px;
  color: var(--muted);
}
.filters input, .filters select,
.form-grid input, .form-grid textarea, .form-grid select,
.option-add input, .inline-field input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 12px;
  font-size: 14px;
  background: #f8fafc;
}

.table-wrap { overflow: auto; padding: 0; }
table { width: 100%; border-collapse: collapse; min-width: 1160px; }
th, td {
  padding: 14px 16px;
  border-bottom: 1px solid #f1f5f9;
  text-align: left;
  font-size: 14px;
}
th {
  background: #f8fafc;
  color: var(--muted);
  font-weight: 600;
  position: sticky;
  top: 0;
}
td.name { max-width: 220px; }
td.num { font-weight: 700; color: var(--primary-dark); white-space: nowrap; }
td.empty { text-align: center; color: var(--muted); padding: 40px; }

.inline-row {
  background: #f8fbff;
}
.inline-row td {
  padding: 8px 6px;
  vertical-align: middle;
  border-top: 2px solid #bfdbfe;
}
.cell-input {
  width: 100%;
  min-width: 72px;
  border: 1px solid #dbeafe;
  border-radius: 8px;
  padding: 8px 8px;
  font-size: 13px;
  background: #fff;
}
.cell-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.12);
}
.inline-dropzone {
  min-height: 44px;
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  padding: 4px;
  outline: none;
}
.inline-dropzone:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.12);
}
.dropzone:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.12);
}
.dropzone.paste-target-active {
  border-color: #2563eb;
  background: #eff6ff;
}
.form-label {
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 8px;
  display: block;
}
.inline-dropzone.dragover {
  border-color: var(--primary);
  background: #eff6ff;
}
.inline-dropzone img {
  width: 36px;
  height: 36px;
  object-fit: cover;
  border-radius: 6px;
}
.inline-img-hint {
  font-size: 11px;
  color: #94a3b8;
  text-align: center;
  line-height: 1.3;
}
.inline-img-rm {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 16px;
  height: 16px;
  border: none;
  border-radius: 50%;
  background: #fee2e2;
  color: #dc2626;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}
.paste-target-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 12px 16px;
  border-top: 1px solid #f1f5f9;
  background: #f8fbff;
}
.form-paste-bar {
  border-top: none;
  border-radius: 16px 16px 0 0;
  margin: 0 0 -8px;
  box-shadow: var(--shadow);
}
.form-card {
  border-radius: 0 0 16px 16px;
}
.paste-target-label {
  font-size: 13px;
  color: #475569;
  font-weight: 600;
}
.paste-target-btn {
  border: 1px solid #bfdbfe;
  background: #fff;
  color: #1e40af;
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 13px;
  cursor: pointer;
}
.paste-target-btn.active {
  background: #2563eb;
  color: #fff;
  border-color: #2563eb;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.25);
}
.paste-target-hint {
  font-size: 12px;
  color: #94a3b8;
}
.paste-select-btns {
  display: flex;
  gap: 12px;
}
.paste-select-btns .btn {
  flex: 1;
  padding: 14px 0;
}
.inline-dropzone.paste-target-active {
  border-color: #2563eb;
  background: #eff6ff;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}
.inline-tip {
  font-size: 12px;
  color: #94a3b8;
  padding: 8px 16px 12px;
  border-top: 1px solid #f1f5f9;
}
.pill {
  display: inline-block;
  background: #eff6ff;
  color: #1d4ed8;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
}
.actions { white-space: nowrap; }
.link {
  border: none;
  background: none;
  color: var(--primary);
  cursor: pointer;
  padding: 0 6px 0 0;
}
.link.danger { color: var(--danger); }

.form-card { padding: 22px; }
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.field { display: flex; flex-direction: column; gap: 8px; }
.field.full { grid-column: 1 / -1; }
.field span { font-size: 13px; color: var(--muted); font-weight: 600; }
.mobile-combo-picker { display: none; }
.mobile-image-viewer { display: none; }
.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

.dropzone {
  border: 2px dashed #cbd5e1;
  border-radius: 14px;
  background: #f8fafc;
  padding: 18px;
  text-align: center;
  cursor: pointer;
  transition: 0.2s ease;
}
.dropzone:hover, .dropzone.dragover {
  border-color: var(--primary);
  background: #eff6ff;
}
.dropzone.has-image {
  text-align: left;
}
.drop-hint {
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: var(--muted);
  font-size: 13px;
}
.dropzone.has-image .drop-hint { display: none; }
.drop-hint .pick-img {
  border: none;
  background: none;
  color: var(--primary);
  cursor: pointer;
  padding: 0;
  font-size: 13px;
}
.img-preview {
  min-height: 48px;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  justify-content: center;
}
.dropzone.has-image .img-preview {
  justify-content: flex-start;
  margin-bottom: 0;
}
.img-preview img {
  width: 88px;
  height: 88px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--line);
}
.img-rm {
  border: none;
  background: #fee2e2;
  color: var(--danger);
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
}
.img-thumb {
  border: none;
  background: none;
  padding: 0;
  cursor: pointer;
}
.img-thumb img {
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
}
.no-img { color: #cbd5e1; }
.empty-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 24px 0;
}
.empty-box p { margin: 0; color: var(--muted); }

.settings-card { margin-bottom: 16px; }
.inline-field span { display: block; margin-bottom: 8px; font-weight: 600; }
.option-group {
  background: var(--card);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 14px;
}
.option-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
.option-head h3 { margin: 0; font-size: 16px; }
.option-add { display: flex; gap: 8px; min-width: 280px; }
.option-tags { display: flex; flex-wrap: wrap; gap: 8px; }
.tag-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #eff6ff;
  color: #1e40af;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 13px;
}
.tag-item button {
  border: none;
  background: transparent;
  color: #64748b;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
}
.muted { color: var(--muted); font-size: 13px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(20px);
  background: rgba(15,23,42,0.92);
  color: #fff;
  padding: 12px 18px;
  border-radius: 10px;
  opacity: 0;
  pointer-events: none;
  transition: 0.2s ease;
  z-index: 100;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.data-retry {
  display: none;
  margin: 0 0 16px;
  padding: 14px 16px;
  border-radius: 12px;
  background: #fff7ed;
  border: 1px solid #fdba74;
  color: #9a3412;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.data-retry.show { display: flex; }
.data-retry-text { margin: 0; font-size: 14px; }
.ledger-empty { padding: 8px 4px; font-size: 13px; }
body.app-booting .main { opacity: 0.55; pointer-events: none; }
body.app-ready .main { opacity: 1; pointer-events: auto; }

.modal {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.55);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
#actionMenuModal,
#loginModal {
  z-index: 1100;
}
.modal.show { display: flex; }
.modal-panel {
  position: relative;
  background: #fff;
  border-radius: 14px;
  padding: 12px;
  max-width: 90vw;
  max-height: 90vh;
}
.modal-panel img { max-width: 80vw; max-height: 80vh; display: block; }
.modal-panel button#imageModalClose {
  position: absolute;
  top: 6px;
  right: 8px;
  border: none;
  background: transparent;
  font-size: 28px;
  cursor: pointer;
}
.form-modal {
  width: min(460px, 92vw);
  padding: 24px;
}
.form-modal h3 { margin: 0 0 8px; }
.modal-sub {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 14px;
}

@media (max-width: 960px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: sticky; top: 0; z-index: 5; }
  .side-stats { display: none; }
  .form-grid, .filter-row, .filter-row.four { grid-template-columns: 1fr; }
  .option-head { flex-direction: column; align-items: stretch; }
  .option-add { min-width: 0; }
}

@media (max-width: 720px) {
  body {
    background: #eef3f8;
    -webkit-text-size-adjust: 100%;
  }

  body.image-viewer-open {
    overflow: hidden;
  }

  .mobile-image-viewer {
    position: fixed;
    inset: 0;
    z-index: 3000;
    display: grid;
    grid-template-rows: auto 1fr auto;
    background: #050816;
    color: #fff;
  }

  .mobile-image-viewer[hidden] {
    display: none;
  }

  .mobile-image-head {
    min-height: 58px;
    padding: max(12px, env(safe-area-inset-top)) 14px 10px;
    display: grid;
    grid-template-columns: 92px 1fr 92px;
    align-items: center;
  }

  .mobile-image-head button {
    min-height: 40px;
    border: 1px solid rgba(255,255,255,0.22);
    border-radius: 999px;
    background: rgba(255,255,255,0.12);
    color: #fff;
    font-size: 15px;
  }

  .mobile-image-head span {
    text-align: center;
    color: rgba(255,255,255,0.78);
    font-size: 14px;
  }

  .mobile-image-stage {
    min-height: 0;
    display: grid;
    place-items: center;
    padding: 8px;
  }

  .mobile-image-stage img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
  }

  .mobile-image-actions {
    padding: 12px 14px max(16px, env(safe-area-inset-bottom));
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .mobile-image-actions button {
    min-height: 48px;
    border: 1px solid rgba(255,255,255,0.22);
    border-radius: 14px;
    background: rgba(255,255,255,0.12);
    color: #fff;
    font-size: 16px;
  }

  .mobile-image-actions button:disabled {
    opacity: 0.35;
  }

  .app {
    display: block;
    min-height: 100vh;
  }

  body:not(.mobile-page-view) .main {
    display: none;
  }

  body:not(.mobile-page-view) {
    min-height: 100svh;
    background: linear-gradient(180deg, #0f172a 0%, #243c8b 100%);
  }

  body:not(.mobile-page-view) .app {
    min-height: 100svh;
  }

  body:not(.mobile-page-view) .sidebar {
    position: static;
    min-height: 100svh;
    border-radius: 0;
    padding: max(18px, env(safe-area-inset-top)) 14px max(18px, env(safe-area-inset-bottom));
    display: flex;
    justify-content: flex-start;
  }

  body.mobile-page-view .sidebar,
  body.mobile-form-view .sidebar {
    display: none;
  }

  body.mobile-page-view .main,
  body.mobile-form-view .main {
    padding-top: 10px;
  }

  body.mobile-form-view .topbar {
    padding: 2px 2px 0;
  }

  .mobile-home-btn {
    display: none;
  }

  body.mobile-page-view .mobile-home-btn {
    display: inline-flex;
    min-height: 40px;
    align-items: center;
    justify-content: center;
    margin: 0 0 10px;
    padding: 8px 12px;
    border: 1px solid #bfdbfe;
    border-radius: 999px;
    background: #eff6ff;
    color: #1e40af;
    font-size: 14px;
    font-weight: 700;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 20;
    padding: 10px 10px 12px;
    gap: 10px;
    border-radius: 0 0 16px 16px;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.16);
  }

  body:not(.mobile-page-view) .brand {
    margin-top: 4px;
  }

  body:not(.mobile-page-view) .brand-icon {
    width: 56px;
    height: 56px;
    border-radius: 16px;
    font-size: 28px;
  }

  body:not(.mobile-page-view) .brand strong {
    font-size: 25px;
    line-height: 1.15;
  }

  body:not(.mobile-page-view) .brand span {
    font-size: 15px;
    margin-top: 4px;
  }

  .brand {
    gap: 9px;
  }

  .brand-icon {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    font-size: 16px;
  }

  .brand strong {
    font-size: 16px;
  }

  .brand span {
    font-size: 11px;
  }

  .ledger-panel {
    max-height: 118px;
    overflow: auto;
    padding: 10px;
    border-radius: 12px;
  }

  body:not(.mobile-page-view) .ledger-panel {
    max-height: none;
    overflow: visible;
    padding: 16px;
    border-radius: 18px;
    background: rgba(255,255,255,0.1);
  }

  .ledger-head {
    gap: 8px;
    font-size: 13px;
  }

  body:not(.mobile-page-view) .ledger-head {
    font-size: 18px;
    margin-bottom: 14px;
  }

  .btn-new-list {
    min-height: 34px;
    padding: 7px 10px;
  }

  body:not(.mobile-page-view) .btn-new-list {
    min-height: 48px;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 16px;
  }

  .ledger-list {
    gap: 6px;
  }

  .ledger-item {
    border-radius: 10px;
  }

  body:not(.mobile-page-view) .ledger-item {
    min-height: 94px;
    border-radius: 18px;
    padding: 8px;
    background: rgba(255,255,255,0.14);
  }

  .ledger-main {
    min-height: 38px;
    padding: 8px 10px;
  }

  body:not(.mobile-page-view) .ledger-main {
    min-height: 76px;
    padding: 14px 16px;
  }

  body:not(.mobile-page-view) .ledger-main strong {
    font-size: 19px;
  }

  body:not(.mobile-page-view) .ledger-main span {
    font-size: 16px;
    margin-top: 8px;
  }

  body:not(.mobile-page-view) .ledger-more {
    width: 48px;
    height: 48px;
    border-radius: 16px;
    font-size: 24px;
  }

  .nav {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }

  body:not(.mobile-page-view) .nav {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .nav-btn {
    min-height: 42px;
    padding: 8px 6px;
    text-align: center;
    font-size: 13px;
    border-radius: 12px;
    background: rgba(255,255,255,0.08);
  }

  body:not(.mobile-page-view) .nav-btn {
    min-height: 58px;
    text-align: left;
    padding: 14px 18px;
    font-size: 18px;
    border-radius: 18px;
    background: rgba(255,255,255,0.12);
  }

  .side-user {
    margin-top: 0;
    padding-top: 8px;
  }

  body:not(.mobile-page-view) .side-user {
    margin-top: auto;
    padding-top: 16px;
    gap: 12px;
  }

  body:not(.mobile-page-view) .side-user-row {
    font-size: 18px;
  }

  .side-login-form {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .side-login-form input,
  .btn-login,
  .btn-logout {
    min-height: 42px;
    font-size: 15px;
  }

  body:not(.mobile-page-view) .side-login-form input,
  body:not(.mobile-page-view) .btn-login,
  body:not(.mobile-page-view) .btn-logout {
    min-height: 56px;
    border-radius: 16px;
    font-size: 18px;
  }

  .main {
    padding: 12px 10px 28px;
  }

  .topbar {
    display: block;
    margin-bottom: 12px;
  }

  .topbar h1 {
    font-size: 22px;
    line-height: 1.2;
    margin-bottom: 4px;
  }

  .topbar p {
    font-size: 13px;
    line-height: 1.45;
  }

  .toolbar {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 12px;
  }

  .toolbar .btn,
  .btn {
    min-height: 44px;
    padding: 10px 12px;
    border-radius: 12px;
    font-size: 15px;
  }

  .toolbar #btnAdd {
    grid-column: 1 / -1;
  }

  .card {
    border-radius: 12px;
    padding: 12px;
    margin-bottom: 12px;
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.06);
  }

  .filters {
    gap: 10px;
  }

  .filter-row,
  .filter-row.four {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .filters input,
  .filters select,
  .mobile-combo-picker,
  .form-grid input,
  .form-grid textarea,
  .form-grid select,
  .option-add input,
  .inline-field input {
    min-height: 44px;
    padding: 10px 12px;
    border-radius: 12px;
    font-size: 16px;
  }

  .mobile-combo-picker {
    display: block;
    background: #eff6ff;
    border-color: #bfdbfe;
    color: #1e40af;
    font-weight: 700;
  }

  .filter-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .filter-summary {
    grid-column: 1 / -1;
  }

  .filter-actions .btn {
    width: 100%;
  }

  .table-wrap {
    margin-left: 0;
    margin-right: 0;
    border-radius: 12px;
    overflow: visible;
    padding: 0;
    background: transparent;
    box-shadow: none;
  }

  .table-wrap::before {
    content: "账单已按手机屏幕整理";
    display: block;
    padding: 8px 2px 10px;
    color: #64748b;
    font-size: 12px;
  }

  table,
  thead,
  tbody,
  tr,
  td {
    display: block;
    width: 100%;
  }

  table {
    min-width: 0;
    border-collapse: separate;
    border-spacing: 0;
  }

  thead {
    display: none;
  }

  #recordTable tbody {
    display: grid;
    gap: 10px;
  }

  #recordTable tbody tr {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.06);
    overflow: hidden;
  }

  #recordTable tbody tr:not(.inline-row) td {
    display: grid;
    grid-template-columns: 84px minmax(0, 1fr);
    gap: 10px;
    align-items: start;
    padding: 9px 12px;
    border-bottom: 1px solid #f1f5f9;
    font-size: 14px;
    word-break: break-word;
  }

  #recordTable tbody tr:not(.inline-row) td::before {
    color: #64748b;
    font-size: 12px;
    font-weight: 600;
  }

  #recordTable tbody tr:not(.inline-row) td:nth-child(1)::before { content: "日期"; }
  #recordTable tbody tr:not(.inline-row) td:nth-child(2)::before { content: "商品"; }
  #recordTable tbody tr:not(.inline-row) td:nth-child(3)::before { content: "金额"; }
  #recordTable tbody tr:not(.inline-row) td:nth-child(4)::before { content: "单位"; }
  #recordTable tbody tr:not(.inline-row) td:nth-child(5)::before { content: "分类"; }
  #recordTable tbody tr:not(.inline-row) td:nth-child(6)::before { content: "账款"; }
  #recordTable tbody tr:not(.inline-row) td:nth-child(7)::before { content: "支付"; }
  #recordTable tbody tr:not(.inline-row) td:nth-child(8)::before { content: "沟通图"; }
  #recordTable tbody tr:not(.inline-row) td:nth-child(9)::before { content: "支付图"; }
  #recordTable tbody tr:not(.inline-row) td:nth-child(10)::before { content: "操作"; }

  #recordTable tbody tr:not(.inline-row) td:last-child {
    border-bottom: 0;
  }

  td.name {
    max-width: none;
    font-weight: 700;
    color: #0f172a;
  }

  td.num {
    color: var(--primary-dark);
    white-space: normal;
  }

  .inline-row {
    display: none !important;
  }

  .cell-input {
    min-height: 42px;
    padding: 8px 8px;
    border-radius: 10px;
    font-size: 15px;
  }

  .inline-dropzone {
    min-width: 68px;
    min-height: 52px;
    border-radius: 10px;
  }

  .inline-dropzone img {
    width: 42px;
    height: 42px;
  }

  .inline-img-hint {
    font-size: 12px;
  }

  .inline-img-rm {
    width: 22px;
    height: 22px;
    font-size: 14px;
  }

  .paste-target-bar {
    padding: 10px;
    gap: 8px;
    border-radius: 12px;
    margin-top: 10px;
  }

  .paste-target-label,
  .paste-target-hint {
    flex-basis: 100%;
  }

  .paste-target-btn {
    min-height: 38px;
    padding: 8px 14px;
    font-size: 14px;
  }

  .inline-tip {
    padding: 8px 10px 10px;
    font-size: 12px;
  }

  .img-cell {
    max-width: none;
  }

  .actions {
    display: flex !important;
    gap: 8px;
    white-space: normal;
  }

  .actions::before {
    padding-top: 9px;
  }

  .actions .link {
    display: inline-flex;
    min-height: 34px;
    align-items: center;
    justify-content: center;
    padding: 0 12px;
    border-radius: 999px;
    background: #eff6ff;
  }

  .form-paste-bar {
    border-radius: 12px 12px 0 0;
  }

  .form-card {
    padding: 14px;
    border-radius: 0 0 12px 12px;
  }

  .form-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    position: sticky;
    bottom: 0;
    z-index: 10;
    background: linear-gradient(180deg, rgba(255,255,255,0), #fff 22%);
    padding-top: 14px;
  }

  .dropzone {
    padding: 14px;
    border-radius: 12px;
  }

  .img-preview img {
    width: 72px;
    height: 72px;
  }

  .option-head {
    gap: 10px;
  }

  .option-add {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .option-group {
    border-radius: 12px;
    padding: 14px;
  }

  .modal {
    align-items: flex-end;
  }

  .form-modal,
  .batch-edit-panel {
    width: 100vw;
    max-width: 100vw;
    border-radius: 18px 18px 0 0;
    padding: 18px;
    max-height: 88vh;
    overflow: auto;
  }

  .modal-panel img {
    max-width: 92vw;
    max-height: 78vh;
  }

  .toast {
    width: calc(100vw - 24px);
    bottom: 14px;
    text-align: center;
  }
}
