:root {
  color-scheme: light;
  --ink: #1c3028;
  --muted: #58675f;
  --hairline: #cdd5cd;
  --cream: #fff;
  --paper: #fff;
  --green: #224d3f;
  --error: #963e30;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  --serif: Georgia, "Songti SC", "STSong", "Noto Serif CJK SC", serif;
  background: var(--cream);
  color: var(--ink);
  font: 16px/1.55 var(--sans);
}
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; }
[hidden] { display: none !important; }
a { color: var(--green); }
button, input, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .62; }
:focus-visible { outline: 3px solid #5c916e; outline-offset: 3px; }
.mast { border-bottom: 1px solid var(--hairline); background: var(--paper); }
.mast-inner, .page { width: min(1100px, calc(100% - 64px)); margin: 0 auto; }
.mast-inner, .brand, .page-heading, .user-tools, .section-bar, .record-heading, .form-actions, .auth-actions {
  display: flex; align-items: center;
}
.mast-inner { justify-content: space-between; min-height: 72px; gap: 16px; }
.brand { gap: 9px; color: #0e1713; text-decoration: none; }
.brand img { display: block; border-radius: 7px; }
.brand span { font-weight: 720; font-size: 18px; line-height: 1.08; }
.brand small { display: block; margin-top: 4px; font: 650 9px/1 var(--sans); letter-spacing: .16em; }
.header-link,.back-link,.text-link { font-size: 14px; text-underline-offset: 4px; }
.header-link { text-decoration: none; padding: 9px 0; }
.header-link:hover,.text-button:hover { text-decoration: underline; text-underline-offset: 4px; }
.page { padding: clamp(24px,4vw,54px) 0 64px; }
.page-heading { justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
h1, h2, p { margin: 0; }
h1, h2 { overflow-wrap: anywhere; }
h1 { font: 600 clamp(31px,4.1vw,52px)/1.15 var(--serif); letter-spacing: -.025em; }
h2 { font: 600 23px/1.3 var(--serif); }
.intro, .muted, .buyer-meta, #boot-status, .user-tools { color: var(--muted); }
.intro { margin-top: 9px; }
.user-tools { gap: 14px; font-size: 14px; overflow-wrap: anywhere; }
.text-button { border: 0; background: transparent; color: var(--green); padding: 7px 2px; font-size: 14px; }
.light-button,.primary { display: inline-flex; align-items: center; justify-content: center; min-height: 43px; border-radius: 5px; padding: 9px 16px; font-weight: 600; font-size: 15px; line-height: 1.4; text-decoration: none; }
.light-button { border: 1px solid #adbbb0; color: var(--green); background: var(--paper); }
.light-button:hover { background: #edf1e9; }
.primary { color: #fffef8; background: var(--green); border: 1px solid var(--green); }
.primary:hover { background: #153e30; }
.is-withdraw { border-color: #c3b0a1; color: #793f2b; background: transparent; }
.is-withdraw:hover { background: #f4ebe3; }
.auth-sheet { max-width: 490px; padding: clamp(19px,3.5vw,32px); border: 1px solid var(--hairline); background: var(--paper); border-radius: 7px; }
.auth-steps { margin-top: 20px; }
#admin-login input + label { margin-top: 16px; }
label { display: block; color: var(--ink); font-size: 15px; font-weight: 600; }
input, textarea {
  display: block; width: 100%; margin-top: 6px; min-height: 44px; border: 1px solid #afbbb1;
  border-radius: 4px; padding: 9px 11px; color: var(--ink); background: var(--paper); font-weight: 400;
}
input, textarea { font-size: 16px; }
textarea { resize: vertical; }
input:focus, textarea:focus { border-color: var(--green); }
label small { display: block; margin-top: 5px; color: var(--muted); font-size: 13px; font-weight: 400; }
input[autocomplete="one-time-code"] { font-variant-numeric: tabular-nums; letter-spacing: .26em; }
.auth-actions, .form-actions { flex-wrap: wrap; gap: 9px 14px; margin-top: 16px; }
.auth-to { margin-bottom: 12px; overflow-wrap: anywhere; }
.form-notice { color: var(--green); font-size: 14px; overflow-wrap: anywhere; }
.form-notice:not(:empty) { margin-top: 10px; }
.form-notice[data-error="true"],#boot-status[data-error="true"],#index-status[data-error="true"] { color: var(--error); }
#reload-page { margin-top: 12px; }
.workspace { display: grid; grid-template-columns: minmax(240px,.8fr) minmax(390px,1.65fr); gap: clamp(26px,4vw,60px); align-items: start; border-top: 2px solid var(--ink); padding-top: 24px; }
.section-bar, .record-heading { justify-content: space-between; gap: 12px; }
.add-button { font-size: 14px; min-height: 38px; padding: 5px 11px; }
#index-status { font-size: 14px; margin: 12px 0; }
.supplier-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--hairline); max-height: 64vh; overflow: auto; }
.supplier-list:empty { display: none; }
.supplier-list li { border-bottom: 1px solid var(--hairline); }
.supplier-list button { display: grid; width: 100%; text-align: start; border: 0; background: transparent; gap: 2px; padding: 11px 9px; color: var(--ink); }
.supplier-list button[aria-current="true"] { background: #e8eee5; box-shadow: inset 3px 0 var(--green); }
.supplier-list strong, .supplier-list small { overflow-wrap: anywhere; }
.supplier-list small, .state { color: var(--muted); font-size: 13px; }
.record-heading { min-height: 38px; margin-bottom: 16px; }
.field-guide { color: var(--muted); font-size: 14px; margin-bottom: 16px; }
.fields { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 14px 20px; }
.fields .wide { grid-column: 1/-1; }
.buyer-page { max-width: 650px; }
.buyer-page #buyer-content { border: 1px solid var(--hairline); background: var(--paper); border-radius: 8px; }
.buyer-supplier,.buyer-verify { padding: clamp(21px,4vw,35px); }
.buyer-supplier { border-bottom: 1px solid var(--hairline); background: #eff3eb; border-radius: 7px 7px 0 0; }
.eyebrow { color: var(--green); font-size: 14px; font-weight: 600; margin-bottom: 10px; }
.buyer-supplier h1 { font-size: clamp(29px,4.4vw,43px); }
.buyer-meta,.buyer-products { margin-top: 8px; overflow-wrap: anywhere; }
.buyer-products { white-space: pre-line; }
.back-link { display: inline-block; margin-top: 20px; }
@media(max-width:740px) {
  .mast-inner,.page { width: calc(100% - 32px); }
  .mast-inner { min-height: 61px; }
  .workspace { grid-template-columns: 1fr; gap: 26px; padding-top: 16px; }
  .supplier-list { max-height: 200px; }
  .record { border-top: 1px solid var(--hairline); padding-top: 16px; }
}
@media(max-width:480px) { .fields { grid-template-columns: minmax(0,1fr); } .page-heading { margin-bottom: 18px; } }

.staff-photos {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 168px), 1fr));
  gap: 16px;
  margin: 20px 0;
  padding: 14px 0 0;
  border: 0;
  border-top: 1px solid var(--hairline);
}
.staff-photos legend { padding: 0 10px 0 0; font-weight: 600; }
.staff-photos input[type=file] { min-width: 0; font-size: 13px; }
.staff-photos img { display: block; width: 100%; max-height: 120px; object-fit: contain; object-position: left center; margin-top: 8px; }

.procurement-settings { border-top: 1px solid var(--hairline); padding: 12px 0; margin-bottom: 16px; }
.procurement-settings summary { width: fit-content; cursor: pointer; font-weight: 650; color: var(--green); padding: 4px 0; }
.procurement-settings .settings-content { margin: 12px 0 8px; max-width: 560px; }
.buyer-search { display: flex; align-items: stretch; gap: 8px; margin-top: 6px; }
.buyer-search input { margin: 0; min-width: 0; }
.buyer-search button { white-space: nowrap; }
#buyer-number-form { margin-top: 20px; }
#buyer-number-form label { margin-top: 12px; }

#support-qr-settings { margin-bottom: 0; scroll-margin-top: 12px; }
.qr-previews { display: flex; flex-wrap: wrap; gap: 16px 30px; margin-bottom: 16px; }
.qr-previews figure { margin: 0; }
.qr-previews figcaption, #qr-hint { font-size: 14px; color: var(--muted); }
.qr-previews img {
  display: block; object-fit: contain; width: auto; height: auto;
  max-width: min(190px, 100%); max-height: 190px; margin-top: 6px; background: #fff;
}
#qr-empty { font-size: 14px; margin-top: 5px; }
#qr-file { max-width: 100%; }
#qr-hint { margin-top: 5px; }

@media (max-width: 680px) {
  body:not([data-page=admin]) :is(.auth-sheet,#buyer-content) { border-radius: 18px; }
  body:not([data-page=admin]) :is(.light-button,.primary,input,textarea) { border-radius: 12px; }
}
