:root {
  color-scheme: light;
  --ink: #17201c;
  --muted: #69736e;
  --line: #dfe5e1;
  --soft: #f4f7f5;
  --paper: #ffffff;
  --green: #116b4b;
  --green-dark: #0b5139;
  --green-soft: #eaf5f0;
  --gold: #b7791f;
  --danger: #ba3030;
  --shadow: 0 14px 40px rgba(28, 48, 39, 0.08);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  background: #eef2ef;
  color: var(--ink);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  letter-spacing: 0;
}
button, input, textarea { font: inherit; }
button { cursor: pointer; }
svg { width: 20px; height: 20px; stroke-width: 1.8; }

.topbar {
  height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 max(24px, calc((100vw - 1180px) / 2));
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; }
.brand-mark { width: 40px; height: 40px; display: grid; place-items: center; background: var(--green); color: white; border-radius: 6px; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 17px; }
.brand small { margin-top: 2px; color: #8a948f; font-size: 9px; font-weight: 700; }
.secure-badge { display: flex; align-items: center; gap: 7px; color: var(--green); font-size: 13px; font-weight: 600; }
.secure-badge svg { width: 17px; }

main { max-width: 1180px; margin: 0 auto; padding: 48px 24px 80px; }
.page-heading { display: flex; justify-content: space-between; align-items: flex-end; gap: 32px; margin-bottom: 32px; }
.eyebrow { margin: 0 0 9px; color: var(--gold); font-size: 11px; font-weight: 800; }
.page-heading h1 { margin: 0; font-size: clamp(28px, 3vw, 38px); line-height: 1.2; }
.page-heading > div > p:last-child { margin: 10px 0 0; color: var(--muted); font-size: 14px; }
.progress { width: 210px; flex: 0 0 auto; }
.progress-label { display: flex; justify-content: flex-end; gap: 5px; margin-bottom: 9px; color: var(--muted); font-size: 12px; }
.progress-label b { color: var(--green); }
.progress-track { height: 5px; display: block; overflow: hidden; background: #d9e0dc; border-radius: 4px; }
.progress-track span { height: 100%; width: 0; display: block; background: var(--green); transition: width .25s ease; }

.layout { display: grid; grid-template-columns: minmax(0, 1fr) 310px; gap: 22px; align-items: start; }
.form-panel, .summary-panel { background: var(--paper); border: 1px solid var(--line); box-shadow: var(--shadow); border-radius: 8px; }
.form-panel { padding: 2px 36px 30px; }
.smart-import { display: grid; grid-template-columns: 42px 1fr auto; gap: 14px; align-items: center; margin: 0 -36px; padding: 20px 36px; background: #edf6f2; border-bottom: 1px solid #cfe1d9; border-radius: 8px 8px 0 0; }
.smart-import-icon { width: 42px; height: 42px; display: grid; place-items: center; background: var(--green); color: white; border-radius: 6px; }
.smart-import h2 { margin: 0; font-size: 14px; }
.smart-import p { margin: 4px 0 0; color: var(--muted); font-size: 11px; }
.smart-import button { height: 38px; display: inline-flex; align-items: center; gap: 7px; padding: 0 15px; border: 1px solid var(--green); border-radius: 5px; background: white; color: var(--green); font-size: 12px; font-weight: 700; }
.smart-import button:hover { background: var(--green); color: white; }
.smart-import button svg { width: 15px; }
.form-section { padding: 32px 0 34px; border-bottom: 1px solid var(--line); }
.section-title { display: flex; gap: 13px; align-items: flex-start; margin-bottom: 24px; }
.section-title > span { width: 31px; height: 31px; display: grid; place-items: center; flex: 0 0 auto; background: var(--green-soft); color: var(--green); border-radius: 5px; font-size: 12px; font-weight: 800; }
.section-title h2 { margin: 0; font-size: 17px; line-height: 1.4; }
.section-title p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
em { color: var(--danger); font-style: normal; }

.invoice-type-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.type-option { min-height: 91px; position: relative; display: flex; align-items: center; gap: 13px; padding: 17px; border: 1px solid var(--line); border-radius: 6px; cursor: pointer; transition: border-color .18s, background .18s, box-shadow .18s; }
.type-option:hover { border-color: #9eb9ad; }
.type-option.active { border-color: var(--green); background: #fbfdfc; box-shadow: inset 0 0 0 1px var(--green); }
.type-option input { position: absolute; opacity: 0; pointer-events: none; }
.type-icon { width: 39px; height: 39px; display: grid; place-items: center; flex: 0 0 auto; background: var(--soft); color: #64736c; border-radius: 5px; }
.active .type-icon { background: var(--green-soft); color: var(--green); }
.type-copy { min-width: 0; padding-right: 20px; }
.type-copy strong, .type-copy small { display: block; }
.type-copy strong { font-size: 14px; }
.type-copy small { margin-top: 6px; color: var(--muted); font-size: 11px; line-height: 1.5; }
.check-icon { position: absolute; top: 12px; right: 12px; width: 17px; color: var(--green); opacity: 0; }
.active .check-icon { opacity: 1; }

.fields-grid, .special-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 19px 16px; }
.special-fields { grid-column: 1 / -1; }
.field { min-width: 0; display: block; }
.field.full { grid-column: 1 / -1; }
.field > span:first-child { display: block; margin-bottom: 8px; color: #37413c; font-size: 13px; font-weight: 600; }
.field > span small { color: #89918d; font-weight: 400; }
.input-shell { height: 45px; display: flex; align-items: center; gap: 10px; padding: 0 13px; background: var(--paper); border: 1px solid #ccd5d0; border-radius: 5px; transition: border-color .18s, box-shadow .18s; }
.input-shell:focus-within, textarea:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(17, 107, 75, .1); outline: none; }
.input-shell svg { width: 17px; color: #7d8983; flex: 0 0 auto; }
.input-shell input { min-width: 0; flex: 1; border: 0; outline: 0; color: var(--ink); background: transparent; }
input::placeholder, textarea::placeholder { color: #a5ada9; }
.phone-shell > span { padding-right: 10px; border-right: 1px solid var(--line); color: #47514c; font-size: 13px; }
textarea { width: 100%; min-height: 92px; resize: vertical; padding: 12px 14px 26px; border: 1px solid #ccd5d0; border-radius: 5px; color: var(--ink); line-height: 1.6; }
.field:has(textarea) { position: relative; }
.counter { position: absolute; right: 11px; bottom: 8px; color: #969e9a; font-size: 11px; }
.counter b { font-weight: 400; }
.error-text { min-height: 16px; display: block; padding-top: 4px; color: var(--danger); font-size: 11px; }
.field.invalid .input-shell, .field.invalid textarea { border-color: var(--danger); }

.consent-row { padding: 24px 0 8px; }
.consent-row label { display: flex; align-items: flex-start; gap: 8px; color: #515b56; font-size: 12px; cursor: pointer; }
.consent-row input { margin: 1px 0 0; accent-color: var(--green); }
.form-actions { display: flex; justify-content: flex-end; gap: 11px; }
.form-actions button, .dialog-content button { height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 0 20px; border-radius: 5px; border: 1px solid transparent; font-weight: 700; font-size: 13px; }
.secondary-button { background: white; border-color: #cbd4cf !important; color: #49534e; }
.primary-button, .dialog-content button { min-width: 145px; background: var(--green); color: white; }
.primary-button:hover, .dialog-content button:hover { background: var(--green-dark); }
.primary-button:disabled { cursor: wait; opacity: .68; }
.primary-button[aria-busy="true"] svg { animation: submit-spin .8s linear infinite; }
.form-actions svg { width: 16px; }
@keyframes submit-spin { to { transform: rotate(360deg); } }

.summary-panel { position: sticky; top: 22px; overflow: hidden; }
.summary-heading { display: flex; gap: 12px; align-items: center; padding: 24px; background: #173e31; color: white; }
.summary-heading > span { width: 39px; height: 39px; display: grid; place-items: center; border: 1px solid rgba(255,255,255,.28); border-radius: 5px; }
.summary-heading p { margin: 0 0 3px; color: #9dc5b5; font-size: 9px; font-weight: 800; }
.summary-heading h2 { margin: 0; font-size: 17px; }
.summary-list { margin: 0; padding: 8px 24px; }
.summary-list div { padding: 16px 0; border-bottom: 1px solid var(--line); }
.summary-list dt { margin-bottom: 7px; color: #8a948f; font-size: 11px; }
.summary-list dd { margin: 0; overflow-wrap: anywhere; color: #313b36; font-size: 13px; font-weight: 650; line-height: 1.45; }
.summary-note { display: flex; gap: 10px; margin: 16px 24px 20px; padding: 13px; background: #fff8e9; border-left: 3px solid #d29a3a; color: #71531f; }
.summary-note svg { width: 16px; flex: 0 0 auto; }
.summary-note p { margin: 0; }
.summary-note strong, .summary-note span { display: block; }
.summary-note strong { font-size: 11px; }
.summary-note span { margin-top: 4px; font-size: 10px; line-height: 1.5; }
.service-line { display: flex; gap: 11px; align-items: flex-start; padding: 20px 24px; background: var(--soft); border-top: 1px solid var(--line); }
.service-line svg { width: 18px; color: var(--green); }
.service-line p { margin: 0; }
.service-line span, .service-line strong, .service-line small { display: block; }
.service-line span { color: var(--muted); font-size: 10px; }
.service-line strong { margin: 2px 0; font-size: 14px; }
.service-line small { color: #929a96; font-size: 9px; }

.toast { position: fixed; left: 50%; bottom: 28px; z-index: 20; display: flex; align-items: center; gap: 8px; padding: 12px 17px; background: #17251f; color: white; border-radius: 5px; font-size: 13px; opacity: 0; transform: translate(-50%, 16px); pointer-events: none; transition: .22s ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast svg { width: 17px; color: #6ed4aa; }
.success-dialog { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; padding: 20px; background: rgba(12, 24, 18, .55); }
.success-dialog[hidden] { display: none; }
.dialog-content { width: min(420px, 100%); padding: 38px 34px 30px; text-align: center; background: white; border-radius: 8px; box-shadow: 0 24px 70px rgba(0,0,0,.22); }
.success-icon { width: 58px; height: 58px; display: grid; place-items: center; margin: 0 auto 19px; background: var(--green-soft); color: var(--green); border-radius: 50%; }
.success-icon svg { width: 28px; height: 28px; stroke-width: 2.5; }
.dialog-content h2 { margin: 0; font-size: 21px; }
.dialog-content p { margin: 12px 0 24px; color: var(--muted); font-size: 13px; line-height: 1.7; }

.import-dialog { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 24px; background: rgba(12, 24, 18, .58); }
.import-dialog-panel { width: min(680px, 100%); max-height: calc(100vh - 48px); overflow-y: auto; padding: 26px; background: white; border-radius: 8px; box-shadow: 0 24px 70px rgba(0,0,0,.25); }
.import-dialog-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; }
.import-dialog-header p { margin: 0 0 4px; color: var(--gold); font-size: 9px; font-weight: 800; }
.import-dialog-header h2 { margin: 0; font-size: 21px; }
.icon-button { width: 36px; height: 36px; display: grid; place-items: center; padding: 0; border: 1px solid var(--line); border-radius: 5px; background: white; color: #56615b; }
.icon-button:hover { background: var(--soft); }
.privacy-tip { display: flex; align-items: center; gap: 8px; margin: 18px 0; padding: 10px 12px; background: var(--green-soft); color: var(--green-dark); font-size: 11px; }
.privacy-tip svg { width: 15px; }
.paste-field > span { display: block; margin-bottom: 8px; color: #37413c; font-size: 12px; font-weight: 700; }
.paste-field textarea { min-height: 176px; padding: 13px 14px; font-size: 12px; line-height: 1.65; }
.recognition-toolbar { min-height: 42px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.recognition-toolbar > span { color: var(--muted); font-size: 11px; }
.recognition-toolbar > span.success { color: var(--green); font-weight: 700; }
.recognition-toolbar > span.warning { color: var(--gold); font-weight: 700; }
.recognition-toolbar button { display: inline-flex; align-items: center; gap: 6px; padding: 6px 0; border: 0; background: transparent; color: var(--green); font-size: 11px; font-weight: 700; }
.recognition-toolbar svg { width: 14px; }
.recognition-results { min-height: 104px; max-height: 220px; overflow-y: auto; border: 1px solid var(--line); border-radius: 5px; }
.recognition-empty { min-height: 102px; display: grid; place-items: center; align-content: center; gap: 7px; color: #9aa39e; }
.recognition-empty svg { width: 22px; }
.recognition-empty p { margin: 0; font-size: 11px; }
.recognized-item { display: grid; grid-template-columns: 116px minmax(0, 1fr) 18px; gap: 12px; align-items: center; min-height: 43px; padding: 8px 13px; border-bottom: 1px solid var(--line); }
.recognized-item:last-child { border-bottom: 0; }
.recognized-item span { color: var(--muted); font-size: 11px; }
.recognized-item strong { min-width: 0; overflow-wrap: anywhere; font-size: 12px; }
.recognized-item svg { width: 16px; color: var(--green); }
.import-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.import-actions button { height: 42px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 0 18px; border-radius: 5px; font-size: 12px; font-weight: 700; }
.import-actions .secondary-button { border: 1px solid #cbd4cf; }
.import-actions .primary-button { border: 0; }
.import-actions button:disabled { cursor: not-allowed; opacity: .45; }
.import-actions svg { width: 15px; }

@media (max-width: 880px) {
  .layout { grid-template-columns: 1fr; }
  .summary-panel { position: static; }
  .summary-list { display: grid; grid-template-columns: 1fr 1fr; gap: 0 20px; }
}
@media (max-width: 640px) {
  .topbar { height: 66px; padding: 0 18px; }
  .secure-badge { font-size: 0; }
  main { padding: 32px 14px 48px; }
  .page-heading { display: block; margin-bottom: 24px; }
  .progress { width: 100%; margin-top: 22px; }
  .progress-label { justify-content: flex-start; }
  .form-panel { padding: 1px 18px 22px; }
  .smart-import { grid-template-columns: 38px 1fr; margin: 0 -18px; padding: 17px 18px; }
  .smart-import-icon { width: 38px; height: 38px; }
  .smart-import button { grid-column: 1 / -1; width: 100%; justify-content: center; }
  .form-section { padding: 26px 0 28px; }
  .invoice-type-switch, .fields-grid, .special-fields { grid-template-columns: 1fr; }
  .special-fields, .field.full { grid-column: auto; }
  .type-option { min-height: 82px; }
  .form-actions { display: grid; grid-template-columns: 1fr 1.2fr; }
  .form-actions button { padding: 0 10px; }
  .summary-list { grid-template-columns: 1fr; }
  .import-dialog { padding: 0; align-items: end; }
  .import-dialog-panel { max-height: 92vh; padding: 22px 18px; border-radius: 8px 8px 0 0; }
  .recognized-item { grid-template-columns: 88px minmax(0, 1fr) 18px; }
  .import-actions { display: grid; grid-template-columns: .8fr 1.4fr; }
  .import-actions button { padding: 0 10px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
