:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-soft: #f9fafb;
  --text: #1f2937;
  --muted: #6b7280;
  --line: #dfe3e8;
  --primary: #1f6feb;
  --primary-dark: #1756b8;
  --success: #168a4a;
  --warning: #b45309;
  --danger: #b42318;
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "OPPO Sans", "OPlus Sans 3.0", "HarmonyOS Sans SC", "PingFang SC", "Microsoft YaHei UI", "Microsoft YaHei", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  letter-spacing: 0;
}

body.modal-open {
  overflow: hidden;
}

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

button {
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0 14px;
  cursor: pointer;
  white-space: nowrap;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  min-height: 38px;
  padding: 8px 10px;
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(31, 111, 235, 0.12);
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.password-control {
  position: relative;
  display: block;
}

.password-control input {
  padding-right: 44px;
}

.password-toggle {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  display: inline-grid;
  place-items: center;
  width: 32px;
  min-height: 32px;
  padding: 0;
  border-color: transparent;
  background: transparent;
  color: var(--muted);
}

.password-toggle:hover {
  background: #eef4ff;
  color: var(--primary-dark);
}

.password-toggle svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.password-toggle.is-visible .password-eye-slash {
  display: none;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 34px;
  line-height: 1.15;
}

h2 {
  font-size: 26px;
  line-height: 1.2;
}

h3 {
  font-size: 17px;
  line-height: 1.3;
}

.count-text {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  margin-left: 6px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

.master-table {
  min-width: 420px;
}

.master-table th:last-child,
.master-table td:last-child {
  width: 78px;
  text-align: right;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 10px 12px;
  text-align: left;
  vertical-align: middle;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

td {
  background: var(--surface);
}

.hidden {
  display: none !important;
}

.primary {
  background: var(--primary);
  color: white;
}

.primary:hover {
  background: var(--primary-dark);
}

.secondary {
  background: #eef4ff;
  border-color: #c9dafb;
  color: var(--primary-dark);
}

.ghost {
  background: var(--surface);
  border-color: var(--line);
  color: var(--text);
}

.danger {
  background: #fff5f5;
  border-color: #fecaca;
  color: var(--danger);
}

.danger:hover {
  background: #fee2e2;
}

.message {
  color: var(--muted);
  font-size: 13px;
}

.message.error {
  color: var(--danger);
}

.message.ok {
  color: var(--success);
}

.eyebrow {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px 18px;
  background:
    radial-gradient(circle at 50% 0%, rgba(31, 111, 235, 0.08), transparent 34%),
    linear-gradient(180deg, #ffffff 0%, #f6f9ff 100%);
}

.login-stage {
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 24px;
  width: min(520px, 100%);
  padding: 34px 28px 28px;
  border: 1px solid rgba(224, 231, 242, 0.88);
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow:
    0 24px 70px rgba(15, 23, 42, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(16px);
}

.login-hero {
  display: grid;
  justify-items: center;
  gap: 14px;
  text-align: center;
}

.login-hero h1 {
  position: relative;
  font-size: clamp(54px, 7vw, 76px);
  line-height: 1.05;
  color: #1e2734;
  font-family: "Noto Sans SC", "Source Han Sans SC", "HarmonyOS Sans SC", "OPPO Sans", "OPlus Sans 3.0", "PingFang SC", "Microsoft YaHei UI", "Microsoft YaHei", sans-serif;
  font-weight: 900;
  -webkit-text-stroke: 0.7px rgba(15, 23, 42, 0.12);
  text-shadow:
    0 1px 0 rgba(255, 255, 255, 0.95),
    0 3px 0 rgba(15, 23, 42, 0.08),
    0 14px 26px rgba(15, 23, 42, 0.14);
  animation: titleFloat 6.6s ease-in-out infinite;
}

.login-hero h1::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 58%;
  z-index: -1;
  width: 118%;
  height: 62%;
  border-radius: 999px;
  background: radial-gradient(circle, rgba(31, 111, 235, 0.12), transparent 72%);
  filter: blur(20px);
  transform: translate(-50%, -50%);
}

.login-subtitle {
  color: #2f7df4;
  font-size: 18px;
  font-weight: 800;
}

.login-box {
  width: 100%;
  display: grid;
  gap: 14px;
}

.login-box label {
  color: #566172;
  font-size: 14px;
  font-weight: 800;
  gap: 8px;
}

.login-box input {
  min-height: 52px;
  border-color: #e2e8f0;
  border-radius: 14px;
  padding: 12px 15px;
  color: #1f2937;
  font-size: 16px;
  background: #ffffff;
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.03);
}

.login-box input::placeholder {
  color: #b8c1cc;
}

.login-box input:focus {
  border-color: #5b9cff;
  box-shadow: 0 0 0 4px rgba(47, 125, 244, 0.13);
}

.login-box button {
  min-height: 52px;
  border-radius: 14px;
  font-size: 17px;
  font-weight: 800;
}

.login-box .primary {
  background: linear-gradient(180deg, #2f87ff 0%, #1268ec 100%);
  box-shadow: 0 10px 20px rgba(18, 104, 236, 0.18);
}

.login-box .primary:hover {
  background: linear-gradient(180deg, #267cf0 0%, #0f5fd8 100%);
}

.login-box .secondary {
  background: #f3f7ff;
  border-color: #cfe0ff;
  color: #1668df;
}

.login-box .ghost {
  background: #ffffff;
  border-color: #e2e8f0;
}

.auth-form-title {
  display: grid;
  gap: 6px;
  text-align: center;
}

@keyframes titleFloat {
  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-6px);
  }
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 18px;
  padding: 20px;
  background: #ffffff;
  border-right: 1px solid var(--line);
}

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

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

#userBadge,
.badge {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 24px;
  border-radius: 999px;
  background: #eef2f7;
  color: #475569;
  padding: 2px 9px;
  font-size: 12px;
}

.badge.closed {
  background: #fff4e6;
  color: var(--warning);
}

.badge.open {
  background: #ecfdf3;
  color: var(--success);
}

.nav-tabs {
  display: grid;
  align-content: start;
  gap: 8px;
}

.nav-tabs button {
  width: 100%;
  justify-content: flex-start;
  text-align: left;
  background: transparent;
  color: var(--text);
}

.nav-tabs button.active {
  background: #e9f1ff;
  color: var(--primary-dark);
  font-weight: 700;
}

.main {
  min-width: 0;
  padding: 22px;
}

.panel {
  display: none;
}

.panel.active {
  display: grid;
  gap: 18px;
}

.panel-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  justify-content: flex-end;
  gap: 10px;
}

.filters input,
.filters select {
  width: 170px;
}

.inline-field {
  width: 180px;
}

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

.kpi {
  display: grid;
  gap: 8px;
  min-height: 96px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.review-kpi {
  width: 100%;
  text-align: left;
  cursor: pointer;
  font: inherit;
  color: inherit;
}

.review-kpi:hover {
  border-color: #93c5fd;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
  transform: translateY(-1px);
}

.review-kpi.is-active {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.review-kpi:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.25);
  outline-offset: 2px;
}

.kpi span {
  color: var(--muted);
  font-size: 13px;
}

.kpi strong {
  font-size: 24px;
  line-height: 1.1;
}

.section-block {
  display: grid;
  gap: 12px;
}

.photo-entry {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  gap: 12px;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 16px;
}

.photo-entry-copy {
  display: grid;
  gap: 5px;
}

.photo-entry-copy p,
.photo-preview span {
  color: var(--muted);
  font-size: 13px;
}

.photo-entry-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(96px, auto));
  justify-content: end;
  gap: 10px;
}

.photo-picker,
.photo-direct-button {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0 14px;
  background: var(--primary);
  color: white;
  font-size: 15px;
  cursor: pointer;
}

.photo-direct-button.secondary {
  background: #eef4ff;
  border-color: #c9dafb;
  color: var(--primary-dark);
}

.ocr-provider-button {
  min-width: 76px;
  font-weight: 700;
  display: grid;
  place-items: center;
  gap: 1px;
  min-height: 44px;
  padding: 5px 10px;
}

.ocr-provider-panel {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: auto repeat(2, minmax(76px, 1fr));
  align-items: center;
  gap: 8px;
  border: 1px solid #dbe5f4;
  border-radius: 8px;
  background: #f8fbff;
  padding: 8px;
}

.ocr-provider-title {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.ocr-code {
  font-size: 16px;
  line-height: 1.1;
}

.ocr-provider-button small {
  color: var(--primary-dark);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.1;
}

.ocr-provider-button.is-loading {
  color: var(--primary-dark);
  background: #eef4ff;
  border-color: #bdd2fb;
}

.photo-picker input,
.photo-direct-button input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.photo-preview {
  grid-column: 1 / -1;
  display: grid;
  gap: 10px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
}

.photo-preview-main {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 12px;
}

.photo-preview.compact-thumbs {
  display: block;
  background: #eef4ff;
  border-color: #c9dafb;
}

.photo-preview.compact-thumbs .photo-preview-main {
  display: none;
}

.photo-preview.is-clickable {
  cursor: zoom-in;
}

.photo-preview.is-clickable:hover {
  border-color: #bdd2fb;
  background: #f3f7ff;
}

.photo-preview:focus-visible {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(31, 111, 235, 0.12);
}

.photo-preview img {
  width: 86px;
  height: 64px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #fff;
}

.photo-preview-main div {
  display: grid;
  gap: 4px;
}

.photo-preview-zoom {
  color: var(--primary-dark) !important;
  font-weight: 700;
}

.photo-preview:not(.is-clickable) .photo-preview-zoom {
  display: none;
}

#salesPanel .panel-head {
  align-items: end;
}

#salesPanel .filters {
  display: grid;
  grid-template-columns: minmax(180px, 220px) minmax(180px, 220px) minmax(240px, 320px) auto;
  width: min(100%, 980px);
  justify-self: end;
}

#salesPanel .filters input,
#salesPanel .filters select,
#salesPanel .filters button {
  width: 100%;
  min-width: 0;
}

#salesPanel .photo-entry {
  grid-template-columns: minmax(280px, 1fr) auto;
  align-items: center;
  width: 100%;
  max-width: 1280px;
}

#salesPanel .photo-entry-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(112px, auto));
}

#saleForm {
  grid-template-columns: repeat(4, minmax(210px, 1fr));
  width: 100%;
  max-width: 1280px;
}

#saleForm label {
  min-width: 0;
}

#saleForm .sale-reason-field {
  grid-column: span 2;
}

.photo-preview-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 0;
}

.photo-preview-strip button {
  position: relative;
  flex: 0 0 auto;
  width: 78px;
  height: 62px;
  min-height: 0;
  border: 2px solid transparent;
  border-radius: 8px;
  padding: 0;
  overflow: hidden;
  background: #fff;
}

.photo-preview-strip button.active {
  border-color: var(--primary);
}

.photo-preview-strip img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-preview-strip span {
  position: absolute;
  right: 3px;
  bottom: 3px;
  min-width: 18px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.78);
  color: white;
  font-size: 11px;
  line-height: 18px;
}

.photo-draft-list {
  grid-column: 1 / -1;
  display: grid;
  gap: 10px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.photo-draft-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}

.photo-draft-head strong {
  color: var(--text);
  font-size: 16px;
}

.photo-draft-list > button {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  min-height: 78px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  padding: 8px;
  text-align: left;
}

.photo-draft-list > button.active {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(31, 111, 235, 0.12);
}

.photo-draft-list > button.saved {
  border-color: #b7e4c7;
  background: #f0fdf4;
}

.photo-draft-list > button.needs-review {
  border-color: #fed7aa;
  background: #fffbeb;
}

.photo-draft-list img {
  width: 72px;
  height: 56px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
  cursor: zoom-in;
}

.photo-draft-list img:hover {
  border-color: var(--primary);
}

.photo-draft-list span {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.photo-draft-list small {
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.photo-link {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  border: 1px solid #c9dafb;
  border-radius: 8px;
  background: #eef4ff;
  color: var(--primary-dark);
  padding: 0 12px;
  text-decoration: none;
}

.icon-button {
  width: 38px;
  min-width: 38px;
  padding: 0;
  font-size: 22px;
  line-height: 1;
}

.photo-sheet,
.photo-viewer {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
}

.photo-sheet {
  align-items: end;
  padding: 16px;
}

.photo-sheet-backdrop,
.photo-viewer-backdrop {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  border-radius: 0;
  padding: 0;
  background: rgba(15, 23, 42, 0.42);
}

.photo-sheet-panel,
.photo-viewer-panel {
  position: relative;
  z-index: 1;
}

.photo-sheet-panel {
  width: min(520px, 100%);
  margin: 0 auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.24);
  padding: 16px;
}

.photo-sheet-head,
.photo-viewer-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.photo-sheet-head div {
  display: grid;
  gap: 4px;
}

.photo-sheet-head strong,
.photo-viewer-head strong {
  font-size: 18px;
}

.photo-sheet-head span {
  color: var(--muted);
  font-size: 13px;
}

.photo-source-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.photo-source-card {
  position: relative;
  display: inline-grid;
  place-items: center;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-soft);
  color: var(--text);
  min-height: 64px;
  padding: 12px 8px;
  text-align: center;
  cursor: pointer;
}

.photo-source-card:hover {
  border-color: #bdd2fb;
  background: #f3f7ff;
}

.photo-source-card span {
  font-size: 16px;
  font-weight: 800;
}

.photo-source-card small {
  color: var(--muted);
  font-size: 13px;
}

.photo-source-card input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.photo-viewer {
  place-items: center;
  padding: 18px;
}

.photo-viewer-backdrop {
  background: rgba(2, 6, 23, 0.86);
}

.photo-viewer-panel {
  width: min(1100px, 100%);
  max-height: calc(100vh - 36px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 10px;
}

.photo-viewer-head {
  color: white;
  align-items: center;
}

.photo-viewer-head .ghost {
  border-color: rgba(255, 255, 255, 0.36);
  background: rgba(255, 255, 255, 0.12);
  color: white;
}

.photo-viewer-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.photo-viewer-actions span {
  min-width: 44px;
  text-align: center;
  color: rgba(255, 255, 255, 0.82);
}

#salePhotoViewerImg {
  max-width: 100%;
  max-height: calc(100vh - 156px);
  object-fit: contain;
  transform: none;
  rotate: 0deg;
  image-orientation: none;
  border-radius: 10px;
  background: white;
  box-shadow: 0 18px 70px rgba(0, 0, 0, 0.32);
}

.photo-viewer-thumbs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 0;
}

.photo-viewer-thumbs button {
  flex: 0 0 auto;
  width: 68px;
  height: 52px;
  min-height: 0;
  border: 2px solid transparent;
  border-radius: 8px;
  padding: 0;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.14);
}

.photo-viewer-thumbs button.active {
  border-color: #93c5fd;
}

.photo-viewer-thumbs img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.has-master-suggestions {
  position: relative;
}

.master-suggestions {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 80;
  display: grid;
  gap: 6px;
  max-height: 260px;
  overflow-y: auto;
  border: 1px solid #c9dafb;
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 6px;
}

.master-suggestions button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  min-height: 38px;
  border: 0;
  background: transparent;
  color: var(--text);
  padding: 8px;
  text-align: left;
}

.master-suggestions button:hover {
  background: #eef4ff;
}

.master-suggestions span {
  color: var(--muted);
  font-size: 12px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.wide {
  grid-column: 1 / -1;
}

.form-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.form-actions-secondary {
  padding-top: 6px;
}

.reset-sale-button {
  min-width: 180px;
}

.table-wrap {
  width: 100%;
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.table-wrap.compact {
  max-height: 460px;
}

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

.receivables-stack,
.reconcile-stack {
  grid-template-columns: 1fr;
}

.month-close {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.month-close input {
  width: 220px;
}

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

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

.master-form {
  grid-template-columns: repeat(2, minmax(140px, 1fr));
}

#masterPanel .master-split {
  grid-template-columns: repeat(2, minmax(320px, 560px));
  align-items: start;
  justify-content: start;
}

#masterPanel .master-column {
  max-width: 560px;
  grid-auto-rows: auto;
  align-items: stretch;
}

#masterPanel .form-grid {
  gap: 12px;
  padding: 14px;
}

#masterPanel .master-form {
  align-content: start;
}

#masterPanel .master-search {
  min-height: 56px;
}

.import-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.import-details {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
}

.import-details summary {
  cursor: pointer;
  color: var(--text);
  font-weight: 700;
}

.empty-note {
  color: var(--muted);
  font-size: 13px;
}

.section-note {
  margin: -4px 0 12px;
  color: var(--muted);
  font-size: 13px;
}

.dashboard-issues {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.issue-link {
  display: grid;
  grid-template-columns: auto minmax(180px, 1fr) minmax(240px, 2fr);
  gap: 10px;
  align-items: center;
  min-height: 48px;
  border-color: var(--line);
  background: var(--surface);
  color: var(--text);
  text-align: left;
}

.issue-link small {
  color: var(--muted);
}

.import-details .table-wrap {
  margin-top: 10px;
}

.master-search {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.import-detail-table {
  min-width: 620px;
}

.import-detail-table th:first-child,
.import-detail-table td:first-child {
  width: 64px;
}

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

.status.ok {
  background: #ecfdf3;
  color: var(--success);
}

.status.warn {
  background: #fff7ed;
  color: var(--warning);
}

.status.muted {
  background: #eef2f7;
  color: var(--muted);
}

.status.error {
  background: #fff5f5;
  color: var(--danger);
}

.status.review-pending {
  background: #fff7ed;
  color: var(--warning);
}

.status.review-confirmed {
  background: #ecfdf3;
  color: var(--success);
}

.status.review-excluded {
  background: #eef2f7;
  color: var(--muted);
}

.review-list {
  display: grid;
  gap: 12px;
}

.review-card {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 14px;
}

.review-card.is-focused {
  border-color: #93c5fd;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.review-card-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.review-card-head strong {
  font-size: 16px;
}

.review-card-head small {
  color: var(--muted);
}

.review-explanation {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.review-explanation.attention {
  color: #b91c1c;
  font-weight: 700;
}

.review-records {
  display: grid;
  gap: 8px;
}

.review-record {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid #edf1f7;
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 10px;
}

.review-record div {
  display: grid;
  gap: 3px;
}

.review-record span,
.review-record small {
  color: var(--muted);
}

.review-record .review-issue-text {
  color: var(--danger);
  font-weight: 700;
}

.danger-text {
  color: var(--danger);
}

.account-status {
  font-weight: 700;
}

.account-status.inactive {
  color: var(--danger);
}

.allocation-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 110px 120px;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: var(--surface-soft);
}

.allocation-row input {
  min-width: 0;
}

.row-actions {
  display: flex;
  gap: 8px;
}

.row-actions button {
  min-height: 32px;
  padding: 0 10px;
}

.row-actions .photo-link {
  min-height: 32px;
}

.num {
  font-variant-numeric: tabular-nums;
}

.positive {
  color: var(--success);
}

.negative,
.danger {
  color: var(--danger);
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(420px, calc(100vw - 36px));
  border-radius: 8px;
  background: #111827;
  color: white;
  padding: 12px 14px;
  box-shadow: var(--shadow);
  z-index: 10;
}

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

  .sidebar {
    position: static;
    height: auto;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto auto;
    align-items: start;
    gap: 12px;
    padding: 14px;
  }

  .brand {
    grid-column: 1;
    grid-row: 1;
  }

  #logoutBtn {
    grid-column: 2;
    grid-row: 1;
    justify-self: end;
    align-self: start;
    width: auto;
    min-height: 34px;
    padding: 0 12px;
  }

  .nav-tabs {
    grid-column: 1 / -1;
    grid-row: 2;
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 4px;
  }

  .nav-tabs button {
    width: auto;
    text-align: center;
  }

  .main {
    padding: 14px;
  }

  .panel-head {
    display: grid;
    align-items: start;
  }

  .filters {
    justify-content: stretch;
  }

  .filters input,
  .filters select,
  .filters button,
  .inline-field {
    width: 100%;
  }

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

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

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

  .issue-link {
    grid-template-columns: 1fr;
  }

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

  .photo-entry-actions {
    justify-content: stretch;
  }

  .photo-entry-actions button,
  .photo-picker,
  .photo-direct-button {
    width: 100%;
  }

  #salesPanel .filters {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
    justify-self: stretch;
  }

  #salesPanel .photo-entry-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #salesPanel .ocr-provider-panel {
    grid-template-columns: 1fr 1fr;
  }

  #salesPanel .ocr-provider-title {
    grid-column: 1 / -1;
  }

  #saleForm {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #saleForm .sale-reason-field {
    grid-column: span 1;
  }

  #masterPanel .master-split {
    grid-template-columns: 1fr;
  }

  #masterPanel .master-column {
    max-width: none;
    grid-template-rows: none;
  }
}

@media (max-width: 560px) {
  h1 {
    font-size: 28px;
  }

  h2 {
    font-size: 22px;
  }

  .login-stage {
    gap: 22px;
    padding: 28px 18px 22px;
    border-radius: 24px;
  }

  .login-box {
    width: 100%;
  }

  .login-hero h1 {
    font-size: 54px;
  }

  .login-subtitle {
    font-size: 14px;
  }

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

  #salesPanel .panel-head,
  #salesPanel .photo-entry {
    grid-template-columns: 1fr;
  }

  #salesPanel .photo-entry-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #salesPanel .filters {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  #salesPanel .filters > *,
  #saleForm > label,
  #saleForm input,
  #saleForm select,
  #saleForm textarea {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    min-inline-size: 0;
  }

  #salesPanel .filters input[type="month"],
  #saleForm input[type="date"] {
    -webkit-appearance: none;
    appearance: none;
  }

  #refreshSalesBtn.mobile-query-button span {
    display: none;
  }

  #refreshSalesBtn.mobile-query-button::after {
    content: "查询";
  }

  #saleForm {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    padding: 14px;
  }

  #saleForm .sale-reason-field {
    grid-column: span 1;
  }

  #salesPanel .photo-entry {
    padding: 16px;
  }

  #salesPanel .photo-entry-actions button,
  #salesPanel .photo-entry-actions .photo-direct-button,
  #salesPanel .filters button,
  #saleForm .form-actions button {
    width: 100%;
    justify-content: center;
  }

  .allocation-row {
    grid-template-columns: 1fr;
  }

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

  .form-actions button,
  .month-close button,
  .import-row button {
    width: 100%;
    justify-content: center;
  }

  .import-row {
    grid-template-columns: 1fr;
  }

  .master-search {
    grid-template-columns: 1fr;
  }
}
