:root {
  color-scheme: light;
  --bg: #f4f7f6;
  --panel: #ffffff;
  --line: #d8e1de;
  --text: #15231f;
  --muted: #64736e;
  --brand: #0f766e;
  --brand-2: #b45309;
  --danger: #b91c1c;
  --ok: #15803d;
  --shadow: 0 8px 22px rgba(14, 35, 30, .08);
}
* { box-sizing: border-box; }
html { background: var(--bg) !important; color: var(--text) !important; }
body { margin: 0; font-family: Inter, "PingFang SC", "Microsoft YaHei", Arial, sans-serif; background: var(--bg) !important; color: var(--text) !important; -webkit-text-size-adjust: 100%; }
button, input, select, textarea { font: inherit; }
button { border: 0; border-radius: 6px; padding: 9px 13px; background: var(--brand); color: #fff; cursor: pointer; }
button.secondary { background: #e8efed; color: var(--text); }
button.danger { background: var(--danger); }
button.ghost { background: transparent; color: var(--brand); padding: 4px 0; }
button:disabled { opacity: .5; cursor: not-allowed; }
.app { min-height: 100vh; }
.topbar { height: 60px; display: flex; align-items: center; justify-content: space-between; padding: 0 24px; background: #12362f; color: #fff; }
.brand { font-weight: 800; font-size: 18px; }
.user { display: flex; align-items: center; gap: 10px; color: rgba(255,255,255,.82); font-size: 13px; }
.layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); min-height: calc(100vh - 60px); }
.nav { padding: 20px 12px; border-right: 1px solid var(--line); background: #fff !important; }
.nav button { width: 100%; text-align: left; margin-bottom: 8px; background: transparent; color: var(--text); }
.nav button.active { background: #dff3ef; color: #075e57; }
.main { padding: 22px; }
.head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 18px; }
h1 { margin: 0; font-size: 24px; }
h2 { margin: 0 0 12px; font-size: 18px; }
.sub { color: var(--muted); font-size: 13px; }
.panel { background: var(--panel) !important; color: var(--text) !important; border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); padding: 16px; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar input, .toolbar select { min-width: 170px; }
input, select, textarea { width: 100%; border: 1px solid var(--line); border-radius: 6px; padding: 9px 10px; background: #fff !important; color: var(--text) !important; }
textarea { min-height: 84px; resize: vertical; }
table { width: 100%; border-collapse: collapse; background: #fff !important; color: var(--text) !important; }
th, td { padding: 11px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; font-size: 14px; }
th { color: var(--muted); font-size: 12px; font-weight: 800; background: #f8fbfa; }
.tag { display: inline-flex; align-items: center; min-height: 24px; border-radius: 999px; padding: 3px 9px; font-size: 12px; font-weight: 700; background: #eef2f1; color: #33413d; white-space: nowrap; }
.tag.ok { background: #dcfce7; color: #166534; }
.tag.warn { background: #fef3c7; color: #92400e; }
.tag.bad { background: #fee2e2; color: #991b1b; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.field label { display: block; margin-bottom: 5px; color: var(--muted); font-size: 12px; font-weight: 800; }
.field.full { grid-column: 1 / -1; }
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.32); display: grid; place-items: center; padding: 16px; z-index: 20; }
.modal { width: min(760px, 100%); max-height: calc(100vh - 32px); overflow: auto; background: #fff !important; color: var(--text) !important; border-radius: 8px; padding: 18px; box-shadow: 0 20px 60px rgba(0,0,0,.22); }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }
.cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.metric { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 14px; }
.metric strong { display: block; font-size: 26px; margin-top: 5px; }
.detail { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; }
.photos { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.photos img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); }
.label-preview { width: 100%; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.message { margin-bottom: 12px; padding: 10px 12px; border-radius: 6px; background: #dff3ef; color: #075e57; }
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login .panel { width: min(460px, 100%); }
.scan-page { max-width: 1020px; margin: 0 auto; padding: 22px; }
@media (max-width: 820px) {
  .layout { grid-template-columns: 1fr; }
  .nav { display: flex; overflow: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: 10px; }
  .nav button { width: auto; white-space: nowrap; margin: 0 8px 0 0; }
  .main { padding: 14px; }
  .head, .detail { display: block; }
  .grid, .cards, .photos { grid-template-columns: 1fr; }
  .topbar { padding: 0 14px; }
  table { min-width: 760px; }
  .panel.table-wrap { overflow-x: auto; }
}
