:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --sidebar: #10243c;
  --sidebar-strong: #0a1829;
  --text: #1f2937;
  --muted: #64748b;
  --line: #dbe3ee;
  --line-strong: #c7d2e2;
  --blue: #1d5fd1;
  --blue-soft: #eaf1ff;
  --emerald: #059669;
  --emerald-soft: #dcfce7;
  --red: #dc2626;
  --red-soft: #fee2e2;
  --amber: #d97706;
  --amber-soft: #fef3c7;
  --shadow: 0 14px 40px rgba(15, 23, 42, 0.08);
  --radius: 8px;
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
}

#app {
  min-height: 100vh;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(135deg, #f5f7fb 0%, #eef5f8 100%);
}

.login-panel {
  width: min(420px, 100%);
  display: grid;
  gap: 22px;
  padding: 28px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.login-kicker {
  color: var(--blue);
  font-weight: 750;
  margin-bottom: 8px;
}

.login-panel h1 {
  margin: 0;
  font-size: 26px;
  letter-spacing: 0;
}

.login-panel p {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.7;
}

.login-form {
  display: grid;
  gap: 14px;
}

.login-btn {
  width: 100%;
  margin-top: 4px;
}

.app-shell {
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: var(--sidebar);
  color: #dbeafe;
  display: flex;
  flex-direction: column;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.brand {
  padding: 22px 20px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.system-title {
  color: #ffffff;
  font-size: 19px;
  font-weight: 700;
  margin-bottom: 6px;
}

.account-line {
  color: #b7c8dd;
  font-size: 12px;
}

.nav {
  padding: 14px 10px;
  display: grid;
  gap: 4px;
}

.nav-btn {
  height: 42px;
  display: grid;
  grid-template-columns: 22px 1fr;
  align-items: center;
  gap: 10px;
  width: 100%;
  border-radius: 6px;
  color: #cfe0f5;
  background: transparent;
  text-align: left;
  padding: 0 12px;
  cursor: pointer;
}

.nav-btn:hover {
  background: rgba(255, 255, 255, 0.08);
}

.nav-btn.active {
  background: var(--blue);
  color: #ffffff;
}

.nav-icon,
.btn-icon {
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.workspace {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: 70px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 22px;
}

.page-title {
  font-size: 23px;
  font-weight: 750;
  color: #111827;
}

.top-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  color: var(--muted);
  font-size: 13px;
}

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  background: var(--blue);
  color: white;
  display: grid;
  place-items: center;
  font-weight: 700;
}

.toolbar {
  min-height: 66px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.toolbar-left,
.toolbar-right,
.button-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.search {
  position: relative;
  width: 350px;
}

.search input {
  width: 100%;
  height: 38px;
  padding: 0 38px 0 12px;
  border-radius: 6px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  outline: none;
}

.search input:focus,
.field input:focus,
.field textarea:focus,
.field select:focus,
.select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(29, 95, 209, 0.12);
}

.search svg {
  position: absolute;
  right: 12px;
  top: 10px;
  color: var(--muted);
}

.select,
.field input,
.field textarea,
.field select {
  height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #ffffff;
  color: var(--text);
  padding: 0 12px;
  outline: none;
}

.field textarea {
  min-height: 84px;
  padding: 10px 12px;
  resize: vertical;
}

.btn {
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border-radius: 6px;
  padding: 0 13px;
  background: #ffffff;
  color: #243244;
  border: 1px solid var(--line-strong);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}

.btn:hover {
  border-color: #9fb1ca;
  background: #f8fbff;
}

.btn:disabled {
  opacity: 0.48;
  cursor: not-allowed;
}

.btn.primary {
  background: var(--blue);
  border-color: var(--blue);
  color: #ffffff;
}

.btn.primary:hover {
  background: #164fb0;
}

.btn.danger {
  color: var(--red);
  border-color: #f3b4b4;
  background: #fffafa;
}

.btn.ghost {
  background: transparent;
}

.btn.small {
  height: 30px;
  padding: 0 9px;
  font-size: 12px;
}

.btn.icon-only {
  width: 38px;
  padding: 0;
}

.content {
  flex: 1;
  min-height: 0;
  padding: 14px 18px 20px;
}

.ledger-grid {
  display: grid;
  grid-template-columns: minmax(540px, 1fr) minmax(340px, 400px);
  gap: 14px;
  align-items: stretch;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.table-panel {
  min-width: 0;
  overflow: hidden;
}

.panel-head {
  height: 48px;
  padding: 0 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}

.panel-title {
  font-weight: 700;
}

.muted {
  color: var(--muted);
}

.table-wrap {
  overflow: auto;
  max-height: calc(100vh - 240px);
}

table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

th,
td {
  height: 42px;
  border-bottom: 1px solid #edf1f6;
  padding: 0 12px;
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f8fafc;
  color: #334155;
  font-size: 12px;
  font-weight: 700;
}

tr {
  cursor: pointer;
}

tr:hover td {
  background: #f7fbff;
}

tr.selected td {
  background: var(--blue-soft);
}

.checkbox-cell {
  width: 42px;
}

.status {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 650;
}

.status.ok {
  color: var(--emerald);
  background: var(--emerald-soft);
}

.status.warn {
  color: var(--amber);
  background: var(--amber-soft);
}

.status.bad {
  color: var(--red);
  background: var(--red-soft);
}

.status.gray {
  color: #475569;
  background: #e2e8f0;
}

.detail-panel {
  min-width: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 164px);
}

.detail-scroll {
  overflow: auto;
  padding: 14px;
}

.merchant-heading {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.merchant-name {
  font-size: 19px;
  font-weight: 760;
  line-height: 1.35;
}

.merchant-code {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--line);
  margin: 6px 0 14px;
}

.tab {
  height: 36px;
  padding: 0 10px;
  background: transparent;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  cursor: pointer;
}

.tab.active {
  color: var(--blue);
  border-bottom-color: var(--blue);
  font-weight: 700;
}

.info-grid {
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr);
  gap: 10px 12px;
  align-items: start;
}

.info-label {
  color: var(--muted);
  font-size: 12px;
}

.info-value {
  min-width: 0;
  overflow-wrap: anywhere;
}

.section-line {
  border-top: 1px solid var(--line);
  margin: 16px 0;
}

.photo-section {
  display: grid;
  gap: 14px;
}

.photo-category-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

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

.detail-panel .photo-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.photo-tile {
  border-radius: 6px;
  overflow: hidden;
  background: #eef2f7;
  border: 1px solid var(--line);
}

.photo-tile-image {
  aspect-ratio: 4 / 3;
  background: #eef2f7;
}

.photo-tile-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.photo-tile-actions {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 6px;
  align-items: center;
  padding: 7px 8px;
  background: #ffffff;
  color: var(--muted);
  font-size: 12px;
  border-top: 1px solid var(--line);
}

.photo-tile-actions button {
  height: 26px;
  border-radius: 5px;
  background: #f8fafc;
  color: #243244;
  border: 1px solid var(--line-strong);
  padding: 0 7px;
  cursor: pointer;
  font-size: 12px;
}

.empty-box {
  border: 1px dashed var(--line-strong);
  border-radius: 6px;
  min-height: 92px;
  display: grid;
  place-items: center;
  color: var(--muted);
  background: #fbfdff;
  text-align: center;
  padding: 12px;
}

.timeline {
  display: grid;
  gap: 12px;
}

.timeline-item {
  display: grid;
  grid-template-columns: 10px 1fr;
  gap: 10px;
}

.dot {
  width: 8px;
  height: 8px;
  margin-top: 6px;
  border-radius: 999px;
  background: var(--blue);
}

.timeline-main {
  min-width: 0;
}

.timeline-title {
  font-weight: 650;
}

.timeline-time {
  color: var(--muted);
  font-size: 12px;
  margin-top: 3px;
}

.map-placeholder,
.map-canvas {
  height: 100%;
  min-height: 330px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #eef5f8;
  touch-action: none;
  overscroll-behavior: contain;
}

.map-placeholder {
  display: grid;
  place-items: center;
  color: #475569;
  padding: 18px;
  text-align: center;
}

.map-canvas.picking {
  cursor: crosshair;
}

.map-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 14px;
}

.content-map {
  flex: 0 0 var(--map-content-height, calc(100vh - 70px));
  height: calc(100vh - 70px);
  height: calc(100dvh - 70px);
  height: var(--map-content-height, calc(100vh - 70px));
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.map-dashboard {
  flex: 1 1 auto;
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  width: 100%;
}

.map-dashboard .stat-row {
  flex: 0 0 auto;
}

.map-dashboard .map-grid {
  flex: 1 1 auto;
  min-height: 0;
  align-items: stretch;
}

.map-panel {
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.map-panel .map-filterbar {
  flex: 0 0 auto;
}

.map-panel .map-placeholder,
.map-panel .map-canvas {
  flex: 1 1 auto;
  height: auto;
  min-height: 260px;
}

.map-filterbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.map-filterbar .select {
  width: 150px;
}

.map-search {
  flex: 1 1 300px;
  width: auto;
  min-width: 240px;
}

.map-filter-count {
  margin-left: auto;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.map-side,
.route-side {
  display: grid;
  gap: 14px;
}

.map-side {
  min-height: 0;
  grid-template-rows: auto minmax(0, 1fr) minmax(110px, 0.7fr);
}

.map-side .panel {
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.map-side .detail-scroll {
  flex: 1 1 auto;
  min-height: 0;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.field {
  display: grid;
  gap: 6px;
}

.field.full {
  grid-column: 1 / -1;
}

.form-grid.single {
  grid-template-columns: 1fr;
}

.field label {
  color: #475569;
  font-size: 12px;
  font-weight: 650;
}

.field input,
.field select,
.field textarea {
  width: 100%;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.42);
  display: grid;
  place-items: center;
  z-index: 20;
  padding: 24px;
}

.modal {
  width: min(920px, 100%);
  max-height: calc(100vh - 48px);
  background: #ffffff;
  border-radius: var(--radius);
  box-shadow: 0 30px 90px rgba(15, 23, 42, 0.28);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal.small-modal {
  width: min(560px, 100%);
}

.modal-head,
.modal-foot {
  min-height: 58px;
  padding: 0 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}

.modal-foot {
  justify-content: flex-end;
  border-top: 1px solid var(--line);
  border-bottom: 0;
  gap: 10px;
}

.modal-title {
  font-size: 18px;
  font-weight: 750;
}

.modal-body {
  overflow: auto;
  padding: 18px;
}

.close-btn {
  width: 34px;
  height: 34px;
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
}

.close-btn:hover {
  background: #f1f5f9;
}

.list {
  display: grid;
  gap: 8px;
}

.list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 42px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
}

.list-row.as-button {
  width: 100%;
  border: 1px solid var(--line);
  text-align: left;
  cursor: pointer;
}

.list-row.as-button:hover {
  border-color: #9fb1ca;
  background: #f8fbff;
}

.list-main {
  min-width: 0;
}

.list-title {
  font-weight: 650;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.list-meta {
  color: var(--muted);
  font-size: 12px;
  margin-top: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.route-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 14px;
}

.route-order {
  counter-reset: stop;
}

.route-stop {
  counter-increment: stop;
  display: grid;
  grid-template-columns: 32px 1fr;
  gap: 10px;
  align-items: start;
}

.route-stop::before {
  content: counter(stop);
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--blue-soft);
  color: var(--blue);
  font-weight: 750;
}

.route-stop.destination-stop::before {
  content: "终";
  background: #fee2e2;
  color: var(--red);
}

.destination-field {
  position: relative;
}

.destination-suggestions {
  margin-top: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  overflow: hidden;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.08);
}

.destination-suggestion {
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: #ffffff;
  padding: 10px 12px;
  display: grid;
  gap: 4px;
  text-align: left;
  cursor: pointer;
}

.destination-suggestion:last-child {
  border-bottom: 0;
}

.destination-suggestion:hover {
  background: #f8fafc;
}

.destination-suggestion-title {
  font-size: 13px;
  font-weight: 750;
  color: var(--text);
}

.destination-suggestion-meta,
.destination-suggestion-note {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
}

.destination-suggestion-note {
  padding: 10px 12px;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.gallery-card {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.gallery-card img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: #eef2f7;
}

.gallery-card-body {
  padding: 10px;
}

.photo-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.photo-search {
  width: min(420px, 100%);
}

.merchant-photo-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.merchant-photo-card {
  display: grid;
  grid-template-rows: auto 1fr;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  color: var(--text);
  overflow: hidden;
  text-align: left;
  cursor: pointer;
}

.merchant-photo-card:hover {
  border-color: #9fb1ca;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
}

.merchant-photo-cover {
  aspect-ratio: 4 / 3;
  background: #eef2f7;
  border-bottom: 1px solid var(--line);
}

.merchant-photo-cover img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.merchant-photo-icon {
  height: 100%;
  display: grid;
  place-items: center;
  color: #94a3b8;
}

.merchant-photo-svg {
  width: 42px;
  height: 42px;
}

.merchant-photo-body {
  display: grid;
  gap: 5px;
  padding: 11px 12px 13px;
}

.merchant-photo-title {
  font-weight: 750;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.merchant-photo-meta {
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.photo-detail-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 16px;
  align-items: start;
  margin-bottom: 16px;
}

.photo-upload-box {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f8fafc;
}

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

.photo-manage-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: #ffffff;
}

.photo-manage-card img {
  width: 100%;
  aspect-ratio: 4 / 3;
  display: block;
  object-fit: cover;
  background: #eef2f7;
}

.photo-manage-body {
  display: grid;
  gap: 8px;
  padding: 10px;
}

.photo-manage-actions {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  gap: 8px;
  align-items: center;
}

.photo-manage-actions.single-action {
  grid-template-columns: 1fr;
}

.mobile-upload-grid {
  display: grid;
  grid-template-columns: 380px minmax(0, 1fr);
  gap: 14px;
}

.mobile-search-body {
  padding: 14px;
  display: grid;
  gap: 12px;
}

.mobile-search {
  width: 100%;
}

.mobile-merchant-list {
  display: grid;
  gap: 8px;
  max-height: calc(100vh - 250px);
  overflow: auto;
}

.mobile-merchant-row {
  width: 100%;
  min-height: 54px;
  display: grid;
  gap: 4px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.mobile-merchant-row.active,
.mobile-merchant-row:hover {
  border-color: var(--blue);
  background: var(--blue-soft);
}

.mobile-merchant-row span,
.mobile-merchant-row small {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mobile-merchant-row span {
  font-weight: 750;
}

.mobile-merchant-row small {
  color: var(--muted);
}

.mobile-selected-card {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f8fafc;
  margin-bottom: 14px;
}

.mobile-category-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.mobile-category {
  height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #ffffff;
  color: var(--text);
  cursor: pointer;
}

.mobile-category.active {
  border-color: var(--blue);
  background: var(--blue);
  color: #ffffff;
  font-weight: 750;
}

.mobile-upload-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.mobile-photo-strip {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
}

.mobile-photo-strip img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #eef2f7;
}

.users-table-wrap {
  max-height: calc(100vh - 180px);
}

.trash-toolbar {
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.trash-toolbar label,
.trash-check {
  display: flex;
  align-items: center;
  gap: 8px;
}

.trash-check span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
}

.trash-photo-card img {
  filter: saturate(0.82);
}

.backup-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 14px;
}

.hint {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.stat-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.stat {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
}

.stat-value {
  font-size: 22px;
  font-weight: 780;
}

.stat-label {
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
}

.hidden-input {
  display: none;
}

#toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  display: grid;
  gap: 8px;
  z-index: 50;
}

.toast {
  min-width: 260px;
  max-width: 560px;
  padding: 12px 14px;
  border-radius: 8px;
  background: #10243c;
  color: #ffffff;
  box-shadow: 0 16px 50px rgba(15, 23, 42, 0.22);
  line-height: 1.45;
  white-space: pre-line;
}

.toast.error {
  background: #991b1b;
}

.toast.success {
  background: #065f46;
}

.toast.warn {
  background: #92400e;
}

.empty-state {
  min-height: 260px;
  display: grid;
  place-items: center;
  color: var(--muted);
  text-align: center;
  padding: 24px;
}

.pill-line {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.pill {
  height: 26px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0 9px;
  background: #eef2f7;
  color: #475569;
  font-size: 12px;
}

.map-edit-form {
  display: grid;
  gap: 12px;
}

.compact-heading {
  margin-bottom: 0;
}

.map-pick-note {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
  color: var(--muted);
  padding: 9px 10px;
  font-size: 12px;
  line-height: 1.5;
}

.map-pick-note.active {
  border-color: #f59e0b;
  background: #fffbeb;
  color: #92400e;
}

.map-edit-actions {
  align-items: stretch;
}

.map-edit-actions .btn {
  flex: 1;
}

.map-info-button {
  display: grid;
  gap: 3px;
  min-width: 170px;
  max-width: 260px;
  padding: 8px 10px;
  border: 0;
  border-radius: 6px;
  background: #ffffff;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.14);
}

.map-info-button strong,
.map-info-button span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.map-info-button span {
  color: var(--muted);
  font-size: 12px;
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .brand {
    padding: 14px 16px 10px;
  }

  .nav {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding: 10px;
  }

  .nav-btn {
    width: auto;
    min-width: max-content;
    grid-template-columns: 18px auto;
    padding: 0 10px;
  }

  .topbar {
    height: auto;
    min-height: 58px;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    flex-direction: column;
  }

  .top-meta {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 8px;
  }

  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .toolbar-left,
  .toolbar-right,
  .button-row {
    width: 100%;
  }

  .search,
  .photo-search {
    width: 100%;
  }

  .content {
    padding: 10px;
  }

  .ledger-grid,
  .map-grid,
  .route-grid,
  .backup-grid,
  .mobile-upload-grid,
  .photo-detail-head {
    grid-template-columns: 1fr;
  }

  .content-map {
    flex: 1 1 auto;
    height: auto;
    overflow: visible;
    display: block;
  }

  .map-dashboard {
    height: auto;
    display: block;
  }

  .map-dashboard .map-grid {
    min-height: 0;
  }

  .map-panel,
  .map-side .panel {
    overflow: visible;
  }

  .map-panel .map-placeholder,
  .map-panel .map-canvas {
    flex: none;
    height: min(56vh, 420px);
    min-height: 300px;
  }

  .map-side {
    grid-template-rows: none;
  }

  .map-side .detail-scroll {
    max-height: none;
  }

  .stat-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .detail-panel {
    max-height: none;
  }

  .table-wrap {
    max-height: none;
  }

  .merchant-photo-grid,
  .photo-manage-grid,
  .gallery-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .mobile-merchant-list {
    max-height: 330px;
  }
}

@media (max-width: 620px) {
  .page-title {
    font-size: 20px;
  }

  .system-title {
    font-size: 17px;
  }

  .panel-head {
    height: auto;
    min-height: 48px;
    align-items: flex-start;
    gap: 10px;
    padding: 12px;
    flex-direction: column;
  }

  .form-grid,
  .mobile-category-row,
  .mobile-upload-actions,
  .stat-row {
    grid-template-columns: 1fr;
  }

  .photo-grid,
  .detail-panel .photo-grid,
  .merchant-photo-grid,
  .photo-manage-grid {
    grid-template-columns: 1fr;
  }

  .mobile-photo-strip {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .modal-backdrop {
    padding: 10px;
  }

  .modal {
    max-height: calc(100vh - 20px);
  }

  .btn {
    min-height: 38px;
  }

  #toast {
    left: 10px;
    right: 10px;
    bottom: 10px;
  }

  .toast {
    min-width: 0;
    max-width: none;
  }
}

.map-label {
  height: 24px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0 9px;
  background: var(--blue);
  color: #ffffff;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.pending-label {
  background: var(--amber);
}

@media (max-width: 1260px) {
  body {
    min-width: 980px;
  }

  .ledger-grid,
  .map-grid,
  .route-grid,
  .backup-grid {
    grid-template-columns: 1fr;
  }

  .detail-panel {
    max-height: none;
  }
}

@media (max-width: 800px) {
  body {
    min-width: 0;
    font-size: 13px;
  }

  .app-shell {
    display: block;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .brand {
    padding: 14px 14px 10px;
  }

  .system-title {
    font-size: 17px;
  }

  .nav {
    display: flex;
    overflow-x: auto;
    padding: 8px;
  }

  .nav-btn {
    min-width: 120px;
    height: 38px;
  }

  .topbar {
    height: auto;
    min-height: 62px;
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
    padding: 12px 14px;
  }

  .page-title {
    font-size: 21px;
  }

  .top-meta {
    flex-wrap: wrap;
    gap: 8px;
  }

  .toolbar {
    align-items: stretch;
    flex-direction: column;
    padding: 12px;
  }

  .toolbar-left,
  .toolbar-right {
    width: 100%;
  }

  .search {
    width: 100%;
  }

  .select,
  .btn {
    max-width: 100%;
  }

  .content {
    padding: 12px;
  }

  .stat-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .ledger-grid,
  .map-grid,
  .route-grid,
  .backup-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .table-wrap {
    max-height: none;
  }

  table {
    min-width: 780px;
  }

  .detail-panel {
    max-height: none;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .photo-grid,
  .gallery-grid,
  .merchant-photo-grid,
  .photo-manage-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .photo-detail-head {
    grid-template-columns: 1fr;
  }

  .photo-manage-actions {
    grid-template-columns: 1fr;
  }

  .modal-backdrop {
    padding: 10px;
  }
}
