:root {
  color-scheme: light;
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  --bg: #f5f7f6;
  --panel: #ffffff;
  --line: #dde4e0;
  --text: #1f2a28;
  --muted: #66736f;
  --primary: #2f6f5e;
  --primary-dark: #235647;
  --danger: #b9473f;
  --warn-bg: #fff7e7;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

.topbar {
  min-height: 88px;
  padding: 18px 28px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

h1, h2, p { margin: 0; }
h1 { font-size: 22px; font-weight: 700; }
h2 { font-size: 18px; }
.topbar p, .muted, #detailSubtitle { color: var(--muted); font-size: 13px; margin-top: 6px; }

.operator,
.profile-menu-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}

.profile-menu-wrap {
  position: relative;
  justify-self: end;
}

.profile-menu-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  background: #fff;
}

.profile-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 150px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.14);
  z-index: 30;
}

.profile-menu button {
  width: 100%;
  justify-content: flex-start;
  border: 0;
  background: transparent;
}

.profile-menu button:hover {
  background: #f3f6f4;
}

.current-user-name {
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
}

.profile-section {
  margin-bottom: 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.profile-section h3 {
  margin: 0 0 12px;
  font-size: 16px;
}

.profile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.profile-field span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
}

.profile-field strong {
  font-size: 14px;
}

.temp-password-box {
  margin-top: 10px;
  padding: 12px;
  border: 1px solid #f2c36b;
  border-radius: 8px;
  background: #fff8e8;
  font-size: 16px;
  font-weight: 700;
}

.ai-status-card {
  min-width: 230px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #f8faf9;
  display: grid;
  gap: 4px;
  font-size: 13px;
}

.ai-status-card strong { font-size: 14px; }
.ai-status-card span.ok { color: var(--primary); font-weight: 700; }
.ai-status-card span.fail { color: var(--danger); font-weight: 700; }
.ai-status-card small { color: var(--muted); line-height: 1.4; }
.ai-status-card button {
  min-height: 28px;
  padding: 4px 8px;
  justify-self: start;
}

.danger-link {
  color: var(--danger);
  border-color: #f3c4bd;
  background: #fff7f5;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(180px, 1fr));
  gap: 10px;
}

.settings-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #f8faf9;
}

.settings-card strong { display: block; margin-bottom: 8px; }
.settings-card div { margin-top: 5px; color: #43504c; }

.page { padding: 22px 28px 34px; }

.smart-entry {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  margin-bottom: 18px;
}

.smart-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.smart-head p {
  color: var(--muted);
  font-size: 13px;
  margin-top: 6px;
}

.smart-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.smart-tabs button {
  min-height: 32px;
  padding: 5px 10px;
  font-size: 13px;
}

.smart-tabs button.active {
  background: #eef5f1;
  color: var(--primary);
  border-color: #b9d2c8;
}

.smart-tabs button:disabled {
  color: #9aa6a2;
  background: #f6f8f7;
  cursor: not-allowed;
}

.library-quick-card {
  min-width: 280px;
  max-width: 380px;
  border: 1px solid #cfe0d8;
  border-radius: 8px;
  background: #f8fbfa;
  padding: 12px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
}

.library-quick-card strong {
  display: block;
  font-size: 16px;
  margin-bottom: 5px;
}

.library-quick-card p {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.library-layout {
  display: grid;
  grid-template-columns: 250px 1fr;
  gap: 16px;
}

.library-sidebar,
.library-main,
.library-admin {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
}

.library-category {
  width: 100%;
  margin-bottom: 8px;
  justify-content: space-between;
}

.library-category.active {
  border-color: var(--primary);
  color: var(--primary);
  background: #eef5f1;
}

.library-files {
  display: grid;
  gap: 10px;
}

.library-file {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
}

.library-file-title {
  font-weight: 700;
  margin-bottom: 5px;
}

.library-file-meta {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.library-admin {
  margin-top: 14px;
}

.library-admin h3 {
  margin: 0 0 10px;
  font-size: 15px;
}

#smartInput {
  width: 100%;
  min-height: 238px;
  line-height: 1.6;
  font-size: 15px;
}

.smart-image-drop {
  margin-top: 12px;
  border: 1px dashed #abc2b8;
  background: #f8fbfa;
  border-radius: 8px;
  padding: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.smart-image-drop.dragover {
  border-color: var(--primary);
  background: #eef5f1;
}

.smart-image-drop input { display: none; }
.smart-image-drop p {
  color: var(--muted);
  font-size: 13px;
  margin-top: 5px;
}

.smart-image-preview {
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fff;
}

.smart-image-preview img {
  width: 96px;
  height: 72px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--line);
}

.smart-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.smart-result {
  margin-top: 16px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.smart-result-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.smart-result-table {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.smart-result-table table {
  min-width: 1780px;
}

.smart-result-table input,
.smart-result-table select {
  width: 100%;
  min-width: 120px;
}

.smart-result-table .address-input {
  min-width: 280px;
}

.smart-result-table .basis-input {
  min-width: 260px;
}

.confidence {
  min-width: 70px;
  font-weight: 700;
  color: var(--primary);
}

.stats {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.stat span { display: block; color: var(--muted); font-size: 13px; }
.stat strong { display: block; margin-top: 8px; font-size: 24px; }

.toolbar {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 16px;
}

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

.actions { margin-top: 12px; }

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

input, select, textarea {
  border: 1px solid #c9d4cf;
  border-radius: 6px;
  padding: 9px 10px;
  background: #fff;
  color: var(--text);
  min-height: 38px;
}

textarea { resize: vertical; }
#searchInput { min-width: 330px; flex: 1; }

button, .filebtn {
  border: 1px solid #c7d1cc;
  background: #fff;
  color: var(--text);
  border-radius: 6px;
  min-height: 38px;
  padding: 8px 13px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
}

button:hover, .filebtn:hover { border-color: var(--primary); color: var(--primary); }
button.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
button.primary:hover { background: var(--primary-dark); color: #fff; }
button.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.filebtn input { display: none; }

.tablewrap {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: auto;
}

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

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

th {
  background: #f0f4f2;
  color: #43504c;
  font-weight: 700;
  position: sticky;
  top: 0;
}

td.address {
  max-width: 330px;
  color: #394642;
}

.check { width: 42px; text-align: center; }
.rowactions { display: flex; gap: 6px; flex-wrap: wrap; }
.rowactions button { min-height: 32px; padding: 5px 8px; font-size: 13px; }
.needs-sales { color: #c0392b; font-weight: 700; }
.tablewrap.compact table, .sales-table { min-width: 980px; }
.sales-toolbar { display: flex; justify-content: flex-end; margin-bottom: 12px; }

.badge {
  display: inline-flex;
  min-width: 58px;
  justify-content: center;
  border-radius: 999px;
  padding: 4px 9px;
  background: #eef5f1;
  color: #2f6f5e;
  font-size: 13px;
}
.badge.todo { background: #eef0f2; color: #5b6470; }
.badge.talking { background: #e8f1ff; color: #1d4f91; }
.badge.sampled { background: #fff4db; color: #80601b; }
.badge.shelved { background: #e8f6ef; color: #246b4b; }
.badge.paused { background: #fff4db; color: #80601b; }
.badge.stopped { background: #fbe9e7; color: #9b3b34; }

.empty {
  display: none;
  padding: 42px;
  text-align: center;
  color: var(--muted);
}

.modal {
  border: 0;
  padding: 0;
  background: transparent;
}
.modal::backdrop { background: rgba(20, 30, 28, 0.42); }
.modalbox {
  width: min(720px, calc(100vw - 28px));
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 18px 60px rgba(18, 31, 28, 0.25);
  padding: 20px;
}
.modalbox.large { width: min(920px, calc(100vw - 28px)); }
.modalbox.xlarge { width: min(1480px, calc(100vw - 28px)); }
.modalbox.loading-modal {
  width: min(560px, calc(100vw - 28px));
}
.loading-content {
  display: grid;
  grid-template-columns: 46px 1fr;
  gap: 16px;
  align-items: start;
}
.loading-content h2 {
  margin-bottom: 8px;
}
.loading-content p {
  color: #43504c;
  font-size: 14px;
  line-height: 1.7;
}
.loading-spinner {
  width: 42px;
  height: 42px;
  border: 4px solid #e4ece8;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
.filebtn.disabled {
  color: #9aa6a2;
  background: #f6f8f7;
  cursor: not-allowed;
  pointer-events: none;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
.modalhead, .drawerhead {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 16px;
}
.iconbtn {
  width: 34px;
  min-height: 34px;
  padding: 0;
  font-size: 20px;
  line-height: 1;
}

.formgrid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.formgrid label {
  display: grid;
  gap: 7px;
  color: #4b5753;
  font-size: 13px;
}
.formgrid .wide { grid-column: 1 / -1; }

.monthly-warning {
  border: 1px solid #d04437;
  background: #fff4f2;
  color: #7a231d;
  padding: 12px 14px;
  border-radius: 8px;
  line-height: 1.6;
}

.monthly-warning strong {
  display: block;
  margin-bottom: 4px;
}

.monthly-warning p { margin: 0; }

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

.proof-preview img {
  width: 92px;
  height: 92px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--border);
}

.proof-preview .proof-item {
  display: grid;
  gap: 6px;
  justify-items: center;
  font-size: 12px;
  color: var(--muted);
}
.modalactions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

.notice {
  margin-top: 14px;
  border: 1px solid #efd28f;
  background: var(--warn-bg);
  border-radius: 8px;
  padding: 12px;
  color: #6f5317;
  font-size: 13px;
}

.feedback-alert {
  border: 1px solid #efd28f;
  background: var(--warn-bg);
  border-radius: 8px;
  padding: 12px 14px;
  color: #6f5317;
}

.feedback-float {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 40;
  min-height: 44px;
  padding: 0 18px;
  border: 0;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  box-shadow: 0 12px 28px rgba(28, 69, 58, 0.24);
}

.feedback-badge {
  display: inline-flex;
  min-width: 20px;
  height: 20px;
  align-items: center;
  justify-content: center;
  margin-left: 8px;
  border-radius: 999px;
  background: #c94038;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}

.feedback-list {
  margin-top: 18px;
  display: grid;
  gap: 10px;
  max-height: 34vh;
  overflow: auto;
}

.feedback-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

.feedback-item-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.feedback-meta {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}

.feedback-detail-grid {
  display: grid;
  gap: 12px;
}

.feedback-screenshots {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
}

.feedback-screenshots img {
  width: 100%;
  max-height: 220px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8faf9;
}

.reportbody {
  max-height: 62vh;
  overflow: auto;
  display: grid;
  gap: 12px;
  font-size: 14px;
}

.report-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 10px;
}

.report-summary div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #f8faf9;
}

.duplicate-report {
  border: 1px solid #efd28f;
  background: var(--warn-bg);
  border-radius: 8px;
  padding: 12px;
}

.duplicate-report strong { display: block; margin-bottom: 6px; }
.duplicate-report ul { margin: 8px 0 0; padding-left: 20px; }

.report-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.mini-table {
  min-width: 920px;
  margin-top: 10px;
  background: #fff;
}

.mini-table th,
.mini-table td {
  font-size: 13px;
  padding: 8px;
}

.base-data-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(360px, 1fr));
  gap: 16px;
}

.base-add-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 8px 0;
}

.base-add-row input,
.base-add-row select,
.mini-table input,
.mini-table select {
  width: 100%;
  min-width: 110px;
}

.inline-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.inline-actions button {
  min-height: 30px;
  padding: 5px 8px;
}

.hidden { display: none !important; }

.drawer {
  position: fixed;
  right: 0;
  top: 0;
  height: 100vh;
  width: min(620px, 100vw);
  background: #fff;
  border-left: 1px solid var(--line);
  box-shadow: -16px 0 48px rgba(24, 38, 34, 0.18);
  transform: translateX(105%);
  transition: transform .18s ease;
  z-index: 10;
  padding: 20px;
  overflow: auto;
}
.drawer.open { transform: translateX(0); }
.drawerbody { display: grid; gap: 18px; }
.info-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.info {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}
.info span { color: var(--muted); display: block; font-size: 12px; margin-bottom: 6px; }
.panel-title { font-weight: 700; margin-bottom: 10px; }
.timeline { display: grid; gap: 10px; }
.timeline-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  font-size: 13px;
}
.timeline-item strong { display: block; margin-bottom: 6px; }
.jsonline { color: var(--muted); word-break: break-word; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: #1f2a28;
  color: #fff;
  border-radius: 8px;
  padding: 11px 16px;
  box-shadow: 0 10px 36px rgba(20, 30, 28, 0.25);
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease;
  max-width: min(720px, calc(100vw - 32px));
}
.toast.show { opacity: 1; }

@media (max-width: 920px) {
  .topbar { align-items: flex-start; flex-direction: column; }
  .smart-head, .smart-result-head { flex-direction: column; }
  .smart-image-drop, .smart-image-preview { align-items: flex-start; flex-direction: column; }
  .smart-tabs { justify-content: flex-start; }
  #smartInput { min-height: 220px; }
  .stats { grid-template-columns: repeat(2, minmax(130px, 1fr)); }
  .base-data-grid { grid-template-columns: 1fr; }
  #searchInput { min-width: 100%; }
  .formgrid, .info-grid { grid-template-columns: 1fr; }
}
