:root {
  color-scheme: light;
  --ink: #46433c;
  --muted: #918b80;
  --line: #e8e3d9;
  --surface: #fefdfa;
  --canvas: #f5f3ee;
  --brand: #6f938a;
  --brand-dark: #5f8378;
  --accent: #b98b7a;
  --accent-soft: #efe2db;
  --nav: #4a5350;
  --focus: #6f938a;
  font-family: Inter, "Noto Sans SC", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 1024px; background: var(--canvas); color: var(--ink); -webkit-font-smoothing: antialiased; }
a { color: inherit; }
.topbar { position: sticky; top: 0; z-index: 30; min-height: 56px; background: var(--nav); color: white; border-bottom: 1px solid rgba(255,255,255,.06); }
.topbar-inner { width: min(1360px, calc(100% - 48px)); min-height: 56px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; }
.brand { display: flex; align-items: center; gap: 9px; color: white; font-size: .95rem; font-weight: 750; text-decoration: none; letter-spacing: -.01em; }
.brand-mark { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 7px; background: var(--accent); color: var(--nav); font-family: Georgia, serif; font-weight: 800; transition: transform .2s ease; }
.brand:hover .brand-mark { transform: rotate(-6deg); }
.brand-muted { color: rgba(255,255,255,.42); font-weight: 650; }
nav { display: flex; align-items: center; gap: 4px; }
nav a, .nav-button { position: relative; color: rgba(255,255,255,.58); font: inherit; font-size: .86rem; text-decoration: none; background: none; border: 0; border-radius: 6px; padding: 7px 12px; cursor: pointer; }
nav a:hover, .nav-button:hover { color: white; text-decoration: underline; text-underline-offset: 5px; }
nav a.active { color: white; }
nav a.active::after { content: ""; position: absolute; left: 12px; right: 12px; bottom: -11px; height: 2px; border-radius: 2px; background: var(--accent); }
.inline-form { display: inline; margin: 0; }
.page-shell { width: min(1360px, calc(100% - 48px)); margin: 0 auto; padding: 40px 0 72px; }
.page-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; margin-bottom: 30px; }
.page-heading h1 { font-family: Georgia, "Noto Serif SC", serif; font-size: clamp(2.35rem, 3.5vw, 3.15rem); font-weight: 650; line-height: 1.06; margin: 8px 0 10px; letter-spacing: -.025em; }
.page-heading p { margin: 0; color: var(--muted); font-size: 1.05rem; }
.eyebrow { display: flex; align-items: center; gap: 8px; text-transform: uppercase; letter-spacing: .16em; font-size: .72rem; font-weight: 800; color: var(--accent); }
.eyebrow::before { content: ""; width: 24px; height: 1px; background: currentColor; }
.role-chip, .status { display: inline-flex; border-radius: 999px; padding: 7px 11px; font-size: .75rem; font-weight: 800; letter-spacing: .03em; }
.role-chip { background: #e8edf1; color: #35414d; }
.available-soon { background: #fff2cc; color: #765600; }
.existing { background: #e7eef6; color: #244b73; }
.card-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 22px; }
.system-card, .placeholder-panel, .login-panel { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 1px 2px rgba(42, 38, 32, .04); }
.system-card { min-height: 290px; padding: 26px; display: flex; flex-direction: column; }
.primary-card { border-top: 4px solid var(--brand); }
.card-topline { min-height: 31px; }
.system-card h2 { font-size: 1.35rem; margin: 17px 0 9px; }
.system-card p { color: var(--muted); line-height: 1.55; margin: 0 0 26px; }
.card-action { margin-top: auto; display: inline-flex; width: fit-content; border-radius: 8px; padding: 11px 15px; background: var(--brand); color: white; text-decoration: none; font-weight: 750; }
.card-action:hover { background: var(--brand-dark); }
.card-action.secondary { background: #243746; }
.not-configured { margin-top: auto; color: var(--muted); font-weight: 700; }
.placeholder-panel { padding: 30px; max-width: 820px; }
.placeholder-panel h2 { margin-top: 0; }
.placeholder-panel p { color: var(--muted); line-height: 1.65; }
.login-panel { width: 430px; margin: 6vh auto 0; padding: 34px; }
.login-panel h1 { margin: 6px 0; font-size: 2.2rem; }
.muted { color: var(--muted); }
.stack-form { display: grid; gap: 18px; margin-top: 26px; }
.stack-form label { display: grid; gap: 7px; font-size: .9rem; font-weight: 750; }
input { width: 100%; border: 1px solid #b8c2cc; border-radius: 8px; padding: 12px; font: inherit; background: white; }
.file-picker { position: relative; display: flex; align-items: center; min-height: 48px; border: 1px solid #b8c2cc; border-radius: 8px; background: white; overflow: hidden; }
.file-input-native { position: absolute; width: 1px; height: 1px; padding: 0; opacity: 0; pointer-events: none; }
.file-picker-button { align-self: stretch; display: inline-flex; align-items: center; padding: 0 16px; background: #e8edf1; border-right: 1px solid #b8c2cc; cursor: pointer; font-weight: 750; }
.file-picker-button:hover { background: #dce4ea; }
.file-picker-name { min-width: 0; padding: 0 14px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-input-native:focus-visible + .file-picker-button { outline: 3px solid rgba(23, 105, 170, .28); outline-offset: -3px; }
input:focus, button:focus-visible, a:focus-visible { outline: 3px solid rgba(23, 105, 170, .28); outline-offset: 2px; }
.primary-button { border: 0; border-radius: 12px; padding: 14px 18px; background: var(--brand); color: white; font: inherit; font-weight: 800; cursor: pointer; box-shadow: 0 8px 18px -10px rgba(95,131,120,.75); transition: background .2s ease, transform .2s ease, box-shadow .2s ease; }
.primary-button:hover { background: var(--brand-dark); }
.alert { margin-top: 20px; border-left: 4px solid var(--brand); background: #fff0f0; padding: 12px 14px; color: #751515; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 1px 2px rgba(42, 38, 32, .04); padding: 28px; }
.panel h2 { margin: 0 0 18px; font-family: Georgia, "Noto Serif SC", serif; font-size: 1.55rem; font-weight: 650; }
.workflow-grid, .result-summary-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-bottom: 24px; }
.summary-list { display: grid; grid-template-columns: minmax(150px, .7fr) 1.3fr; gap: 10px 18px; margin: 0; }
.summary-list dt { color: var(--muted); font-weight: 700; }
.summary-list dd { margin: 0; overflow-wrap: anywhere; }
.source-ok { background: #dfe8df; color: #6d8b74; }
.source-error, .failed { background: #ffe2e2; color: #861d1d; }
.inline-alert { margin: 18px 0 0; border-left: 4px solid var(--brand); padding: 10px 12px; background: #fff0f0; color: #751515; }
.primary-button:disabled { background: #9ca6af; cursor: not-allowed; }
.processing-status { margin: 0; color: var(--muted); font-weight: 750; }
.history-panel, .result-section { margin-top: 24px; }
.section-heading { display: flex; align-items: center; justify-content: space-between; }
.section-heading span { color: var(--muted); font-size: .9rem; }
.history-table, .result-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.history-table th, .history-table td, .result-table th, .result-table td { padding: 13px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.history-table th, .result-table th { color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; }
.history-table tbody tr, .result-table tbody tr { transition: background .18s ease; }
.history-table tbody tr:hover, .result-table tbody tr:hover { background: #f7f3ea; }
.job-status { display: inline-flex; border-radius: 999px; padding: 6px 10px; font-size: .75rem; font-weight: 800; }
.job-status.success { background: #dff4e5; color: #196332; }
.job-status.manual_review { background: #f0e7d3; color: #9a8149; }
.job-status.processing { background: #e4edf7; color: #244b73; }
.download-row { margin: 24px 0; }
.button-link { display: inline-block; text-decoration: none; }
.secondary-button { border: 1px solid #80909e; border-radius: 8px; padding: 12px 16px; background: white; color: #243746; font-weight: 800; }
.result-hero { display: flex; align-items: flex-start; justify-content: space-between; gap: 28px; margin-bottom: 18px; }
.result-hero h1 { margin: 5px 0 7px; font-size: clamp(2rem, 3vw, 2.75rem); line-height: 1.08; }
.result-hero p { margin: 0; color: var(--muted); font-size: 1.05rem; }
.result-status-block { display: grid; justify-items: end; gap: 8px; padding-top: 4px; }
.result-status-block strong { color: #745500; font-size: .9rem; }
.result-actions { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.preview-panel { padding: 20px; }
.preview-panel .section-heading { margin-bottom: 14px; }
.preview-panel h2 { margin: 3px 0 0; }
.pdf-preview { display: block; width: 100%; height: max(650px, 72vh); border: 1px solid #aeb8c2; border-radius: 8px; background: #e6eaee; }
.result-disclosure { margin-top: 20px; padding: 0; overflow: visible; }
.result-disclosure > summary { display: flex; align-items: center; justify-content: space-between; gap: 24px; min-height: 84px; padding: 18px 26px; cursor: pointer; list-style: none; }
.result-disclosure > summary::-webkit-details-marker { display: none; }
.result-disclosure > summary span:first-child { display: grid; gap: 5px; }
.result-disclosure > summary strong { font-size: 1.18rem; }
.result-disclosure > summary small { color: var(--muted); font-size: .88rem; }
.disclosure-action { color: #174f78; font-weight: 800; white-space: nowrap; }
.result-disclosure[open] > summary { position: sticky; top: 56px; z-index: 20; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); box-shadow: 0 8px 18px rgba(22, 34, 46, .14); }
.result-disclosure[open] .disclosure-action { font-size: 0; }
.result-disclosure[open] .disclosure-action::after { content: "收起"; font-size: .9rem; }
.disclosure-content { border-top: 1px solid var(--line); border-radius: 0 0 14px 14px; padding: 6px 26px 26px; background: var(--surface); }
.processing-metadata { max-width: 760px; padding: 22px 0; }
.detail-section { margin-top: 24px; }
.detail-section h3 { display: flex; align-items: center; gap: 9px; margin-bottom: 10px; }
.detail-section h3 span { border-radius: 999px; padding: 4px 8px; background: #e8edf1; color: var(--muted); font-size: .72rem; }
.manual-panel { border-left: 5px solid #d18b00; }
.manual-item { padding: 18px 0; border-top: 1px solid var(--line); }
.manual-item:first-of-type { border-top: 0; }
.manual-item h3 { margin: 0 0 14px; }
.manual-item h4 { margin: 0 0 14px; font-size: 1.05rem; }
.manual-review-group + .manual-review-group { margin-top: 30px; }
.manual-review-group .review-category { --category-color: #9b5747; --category-bg: #f6e8e3; width: fit-content; margin-bottom: 14px; border-radius: 9px; padding: 8px 11px; background: var(--category-bg); color: var(--category-color); font-weight: 800; }
.manual-review-group .review-category span { background: rgba(255,255,255,.72); color: currentColor; }
.review-category-multiple_prefix, .review-category-multiple_exact { --category-color: #315f8c !important; --category-bg: #e5eef8 !important; }
.review-category-notes { --category-color: #76518d !important; --category-bg: #f0e6f5 !important; }
.review-category-carton { --category-color: #39734f !important; --category-bg: #e2f0e6 !important; }
.review-category-price_zero { --category-color: #a43d38 !important; --category-bg: #f8e2df !important; }
.review-category-price_blank { --category-color: #9a641d !important; --category-bg: #f8ecd8 !important; }
.review-category-discount { --category-color: #286d70 !important; --category-bg: #dff0ef !important; }
.review-category-customer { --category-color: #755a24 !important; --category-bg: #f3ead5 !important; }
.note-row { padding: 12px 0; border-top: 1px solid var(--line); }
.note-row p { margin: 5px 0 0; }
.failure-panel { max-width: 760px; border-left: 5px solid var(--brand); }
.back-link { margin-top: 28px; }
.text-link, .back-link a { color: #174f78; font-weight: 750; }

.heading-with-mascot { display: flex; align-items: flex-start; gap: 18px; }
.mascot-avatar { display: grid; place-items: center; flex: 0 0 auto; width: 82px; height: 82px; overflow: hidden; border-radius: 20px; background: var(--accent-soft); }
.mascot-avatar img { width: 76px; height: 76px; object-fit: contain; transform: translateY(14px) scale(1.7); transform-origin: center; }
.mascot-avatar.compact { width: 68px; height: 68px; border-radius: 17px; }
.mascot-avatar.compact img { width: 62px; height: 62px; transform: translateY(12px) scale(1.7); }
.page-heading strong { color: var(--ink); }
.workflow-grid .panel { position: relative; overflow: hidden; min-height: 270px; }
.workflow-grid .panel::after { content: ""; position: absolute; z-index: 0; width: 130px; height: 130px; right: -45px; top: -45px; border-radius: 50%; background: var(--accent-soft); filter: blur(25px); opacity: .55; pointer-events: none; }
.workflow-grid .source-panel::after { background: #dfe8df; }
.workflow-grid .panel > * { position: relative; z-index: 1; }
.source-state-dot { display: inline-block; width: 7px; height: 7px; margin-right: 7px; border-radius: 50%; background: #6d8b74; }
.mono-value { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .82rem; }
.rule-count { color: var(--brand); font-family: Georgia, serif; font-size: 1.25rem; font-weight: 700; }
.upload-panel .primary-button { width: 100%; }
.file-picker { border-color: var(--line); border-radius: 12px; }
.file-picker-button { background: #f0ebdf; border-right-color: var(--line); }
.history-panel { margin-top: 24px; }
.history-panel .section-heading { align-items: flex-end; }
.history-panel h2 { margin-bottom: 0; }
.history-table a { color: var(--brand-dark); font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-weight: 700; text-underline-offset: 4px; }
.mascot-helper { position: fixed; z-index: 25; right: 18px; bottom: 10px; display: grid; justify-items: end; gap: 8px; pointer-events: none; }
.floating-koala { position: relative; width: 116px; height: 116px; padding: 0; overflow: visible; border: 0; background: transparent; cursor: pointer; pointer-events: auto; filter: drop-shadow(0 10px 12px rgba(70,67,60,.16)); animation: mascot-float 3.4s ease-in-out infinite; }
.floating-koala img { width: 100%; height: 100%; object-fit: contain; }
.mascot-message { position: relative; width: min(300px, calc(100vw - 36px)); padding: 14px 38px 14px 16px; border: 1px solid var(--line); border-radius: 16px 16px 4px 16px; background: var(--surface); box-shadow: 0 10px 30px rgba(70,67,60,.16); pointer-events: auto; animation: mascot-message-in .28s ease-out; }
.mascot-message strong, .mascot-message span { display: block; }
.mascot-message-title { margin-bottom: 4px; color: var(--brand-dark); font-size: .86rem; }
.mascot-message-text { color: var(--ink); font-size: .9rem; line-height: 1.45; }
.mascot-message-close { position: absolute; top: 7px; right: 8px; width: 28px; height: 28px; border: 0; border-radius: 50%; background: transparent; color: var(--muted); font-size: 1.25rem; cursor: pointer; }
.mascot-message-close:hover { background: var(--canvas); color: var(--ink); }
.mascot-alert-dot { position: absolute; top: 9px; right: 9px; width: 14px; height: 14px; border: 3px solid var(--surface); border-radius: 50%; background: #e26755; animation: mascot-pulse 1.4s ease-out infinite; }
.mascot-helper[data-mascot-state="processing"] .floating-koala { animation: mascot-working 1.25s ease-in-out infinite; }
.mascot-helper[data-mascot-state="complete"] .floating-koala { animation: mascot-celebrate .72s ease-in-out 3, mascot-float 3.4s 2.2s ease-in-out infinite; }
.mascot-helper[data-mascot-state="review"] .floating-koala { animation: mascot-review 1.1s ease-in-out 4, mascot-float 3.4s 4.4s ease-in-out infinite; }
.mascot-helper[data-mascot-state="failed"] .floating-koala { animation: mascot-failed 2.2s ease-in-out infinite; filter: grayscale(.18) drop-shadow(0 8px 10px rgba(70,67,60,.12)); }
@keyframes mascot-float { 0%, 100% { transform: translateY(0) rotate(-1deg); } 50% { transform: translateY(-8px) rotate(1deg); } }
@keyframes mascot-working { 0%, 100% { transform: translateY(0) rotate(-2deg); } 50% { transform: translateY(-5px) rotate(3deg) scale(1.025); } }
@keyframes mascot-celebrate { 0%, 100% { transform: translateY(0) scale(1); } 45% { transform: translateY(-15px) rotate(-4deg) scale(1.06); } 70% { transform: translateY(-5px) rotate(4deg); } }
@keyframes mascot-review { 0%, 100% { transform: translateX(0) rotate(0); } 30% { transform: translateX(-5px) rotate(-3deg); } 70% { transform: translateX(5px) rotate(3deg); } }
@keyframes mascot-failed { 0%, 100% { transform: translateY(5px) rotate(-2deg) scale(.98); } 50% { transform: translateY(8px) rotate(1deg) scale(.97); } }
@keyframes mascot-message-in { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes mascot-pulse { 0% { box-shadow: 0 0 0 0 rgba(226,103,85,.5); } 100% { box-shadow: 0 0 0 10px rgba(226,103,85,0); } }
.result-hero h1 { font-family: Georgia, "Noto Serif SC", serif; color: var(--ink); }
.result-status-block .job-status { padding: 8px 12px; }
.secondary-button { border-color: #c9c2b6; border-radius: 12px; color: var(--nav); }
.preview-panel, .result-disclosure { box-shadow: 0 1px 2px rgba(42,38,32,.04); }
.pdf-preview { border-color: var(--line); }
.result-disclosure[open] > summary { background: var(--surface); box-shadow: 0 8px 18px rgba(70,67,60,.12); }
.manual-panel { border-left-color: var(--accent); }
.detail-section h3 span { background: #ece8df; color: var(--muted); }

@media (prefers-reduced-motion: reduce) {
  .floating-koala, .mascot-message, .mascot-alert-dot { animation: none !important; }
  * { scroll-behavior: auto !important; }
}

@media (max-width: 1100px) {
  .card-grid { gap: 14px; }
  .system-card { padding: 21px; }
  .pdf-preview { height: max(580px, 68vh); }
  .floating-koala { width: 96px; height: 96px; }
}
