:root {
  color-scheme: light;
  --ink: #172033; --muted: #64748b; --line: #dce4ed; --soft-line: #e9eef4;
  --surface: #fff; --canvas: #f4f7fa; --navy: #16395f; --navy-dark: #0f2a48;
  --blue: #2e6eaa; --blue-soft: #eaf3fb; --green: #176b52; --green-soft: #eaf7f2;
  --red: #a33a3a; --red-soft: #fff0f0; --amber: #8a5a12; --amber-soft: #fff7e6;
  --shadow: 0 12px 34px rgba(24, 50, 76, .08); --radius: 18px;
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; background: var(--canvas); color: var(--ink); font-family: Inter, "Noto Sans HK", "PingFang HK", "Microsoft JhengHei", system-ui, sans-serif; line-height: 1.55; }
body:not(.authenticated) .protected-content { display: none !important; }
body.authenticated #auth-screen { display: none; }
button, input, textarea, select { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
.site-header { position: sticky; top: 0; z-index: 20; border-bottom: 1px solid rgba(220,228,237,.9); background: rgba(255,255,255,.94); backdrop-filter: blur(14px); }
.header-inner, .page-shell, .action-inner { width: min(1180px, calc(100% - 40px)); margin: 0 auto; }
.header-inner { min-height: 72px; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.brand { display: inline-flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; }
.brand img { width: 42px; height: 42px; object-fit: contain; }
.brand span { display: grid; }
.brand strong { font-size: .98rem; letter-spacing: .01em; }
.brand small { color: var(--muted); font-size: .72rem; }
.draft-state { color: var(--muted); font-size: .78rem; }
.header-actions { display: flex; align-items: center; gap: 14px; }
.header-actions > div { display: grid; justify-items: end; }
.signed-in-user { color: var(--navy); font-size: .73rem; font-weight: 750; }
.logout-button { padding: 7px 11px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--muted); cursor: pointer; font-size: .72rem; font-weight: 750; }
.logout-button:hover { border-color: #afbdca; color: var(--navy); }
.auth-screen { min-height: 100vh; display: grid; place-items: center; padding: 30px 18px; background: radial-gradient(circle at 50% 0%, #fff 0, #f4f7fa 52%, #e9eff4 100%); }
.login-card { width: min(100%, 470px); padding: 34px; border: 1px solid var(--soft-line); border-radius: 20px; background: #fff; box-shadow: 0 24px 70px rgba(24,50,76,.12); }
.login-brand { display: flex; align-items: center; gap: 13px; padding-bottom: 25px; border-bottom: 1px solid var(--soft-line); }
.login-brand img { width: 48px; height: 48px; object-fit: contain; }
.login-brand span { display: grid; }
.login-brand small { color: var(--muted); font-size: .72rem; }
.login-brand strong { color: var(--navy-dark); font-size: 1.02rem; }
.login-copy { padding: 34px 0 26px; }
.login-copy h1 { margin: 0; color: var(--navy-dark); font-size: 1.75rem; line-height: 1.25; letter-spacing: -.025em; }
.login-copy > p:last-child { margin: 13px 0 0; color: var(--muted); font-size: .86rem; }
.login-copy > p:last-child strong { color: var(--navy); }
.auth-loading { min-height: 46px; display: flex; align-items: center; justify-content: center; gap: 10px; border: 1px solid var(--line); border-radius: 9px; color: var(--muted); font-size: .82rem; }
.spinner { width: 16px; height: 16px; border: 2px solid #d8e2eb; border-top-color: var(--blue); border-radius: 50%; animation: spin .75s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.google-login-area { min-height: 46px; }
#google-login-button { min-height: 44px; display: flex; justify-content: center; }
.login-status { min-height: 20px; margin: 9px 0 0; color: var(--red); font-size: .76rem; text-align: center; }
.login-security { margin-top: 23px; padding-top: 18px; border-top: 1px solid var(--soft-line); color: var(--muted); font-size: .72rem; text-align: center; }
.page-shell { padding: 42px 0 120px; }
.hero { display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: end; gap: 48px; margin-bottom: 30px; padding: 18px 4px 8px; }
.eyebrow, .section-kicker { margin: 0 0 7px; color: var(--blue); font-size: .72rem; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
.hero h1 { max-width: 720px; margin: 0; color: var(--navy-dark); font-size: clamp(2rem,5vw,3.45rem); line-height: 1.12; letter-spacing: -.045em; }
.hero > div > p:last-child { max-width: 700px; margin: 18px 0 0; color: var(--muted); font-size: 1rem; }
.steps { display: flex; gap: 12px; margin: 0; padding: 0; list-style: none; }
.steps li { display: grid; justify-items: center; gap: 7px; min-width: 78px; color: var(--muted); font-size: .72rem; white-space: nowrap; }
.steps span { width: 32px; height: 32px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 50%; background: var(--surface); color: var(--navy); font-weight: 800; }
.panel { margin-bottom: 20px; padding: 28px; border: 1px solid var(--soft-line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; margin-bottom: 22px; }
.section-heading h2 { margin: 0; color: var(--navy-dark); font-size: 1.3rem; line-height: 1.3; }
.section-heading p:last-child { max-width: 720px; margin: 7px 0 0; color: var(--muted); font-size: .86rem; }
.drop-zone { min-height: 180px; display: grid; place-items: center; align-content: center; gap: 7px; padding: 28px; border: 1.5px dashed #9fb8cf; border-radius: 14px; background: #f8fbfd; cursor: pointer; text-align: center; transition: 160ms ease; }
.drop-zone:hover, .drop-zone.drag-over { border-color: var(--blue); background: var(--blue-soft); }
.drop-zone input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.drop-zone strong { color: var(--navy); font-size: .94rem; }
.drop-zone small { color: var(--muted); font-size: .76rem; }
.upload-mark { width: 46px; height: 46px; display: grid; place-items: center; border-radius: 12px; background: var(--blue-soft); color: var(--blue); }
.upload-mark svg { width: 25px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; }
.upload-list { display: grid; gap: 9px; margin-top: 14px; }
.upload-list:empty { margin-top: 0; }
.privacy-note { margin: 9px 2px 0; color: var(--muted); font-size: .72rem; }
.upload-row { display: grid; grid-template-columns: 44px minmax(0,1fr) auto auto; align-items: center; gap: 12px; padding: 11px 13px; border: 1px solid var(--soft-line); border-radius: 12px; background: #fbfcfe; }
.file-type { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 9px; background: var(--blue-soft); color: var(--blue); font-size: .65rem; font-weight: 900; }
.file-info { min-width: 0; display: grid; }
.file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .84rem; }
.file-message { color: var(--muted); font-size: .74rem; }
.file-status { color: var(--amber); font-size: .75rem; font-weight: 700; }
.upload-row.done .file-status { color: var(--green); }
.upload-row.error .file-status { color: var(--red); }
.button, .icon-button { border: 0; border-radius: 10px; cursor: pointer; font-weight: 750; transition: 140ms ease; }
.button { min-height: 42px; padding: 9px 17px; font-size: .84rem; }
.button:hover, .icon-button:hover { transform: translateY(-1px); }
.button:disabled { cursor: not-allowed; opacity: .45; transform: none; }
.button-primary { background: var(--navy); color: #fff; box-shadow: 0 8px 18px rgba(22,57,95,.2); }
.button-primary:hover { background: var(--navy-dark); }
.button-secondary { border: 1px solid var(--line); background: #fff; color: var(--navy); }
.button-secondary:hover { border-color: #afbdca; background: #f7f9fb; }
.button-quiet { background: transparent; color: var(--muted); }
.icon-button { padding: 6px 8px; background: transparent; color: var(--muted); font-size: .72rem; }
.icon-button:hover { background: var(--red-soft); color: var(--red); }
.notice { margin-bottom: 18px; padding: 12px 16px; border: 1px solid #bdd7ec; border-radius: 12px; background: var(--blue-soft); color: var(--navy); font-size: .84rem; }
.notice.error { border-color: #edc3c3; background: var(--red-soft); color: var(--red); }
.notice.success { border-color: #b9dfd1; background: var(--green-soft); color: var(--green); }
.count-pill { flex: 0 0 auto; padding: 5px 10px; border-radius: 999px; background: var(--blue-soft); color: var(--blue); font-size: .74rem; font-weight: 800; }
.empty-state { min-height: 150px; display: grid; place-items: center; align-content: center; gap: 5px; border: 1px dashed var(--line); border-radius: 13px; color: var(--muted); text-align: center; }
.empty-state strong { color: var(--ink); font-size: .9rem; }
.empty-state span { font-size: .79rem; }
.empty-state.compact { min-height: 110px; }
.table-scroll { width: 100%; overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
.data-table { width: 100%; border-collapse: collapse; background: #fff; font-size: .79rem; }
.data-table th, .data-table td { border-right: 1px solid var(--soft-line); border-bottom: 1px solid var(--soft-line); vertical-align: top; }
.data-table tr:last-child > * { border-bottom: 0; }
.data-table tr > *:last-child { border-right: 0; }
.data-table th { padding: 11px 12px; background: #f6f8fb; color: #42526a; font-size: .72rem; font-weight: 800; text-align: left; white-space: nowrap; }
.data-table input, .data-table textarea, .data-table select { width: 100%; min-height: 40px; padding: 9px 11px; border: 1px solid transparent; border-radius: 7px; outline: 0; background: transparent; color: var(--ink); font-size: .79rem; }
.data-table textarea { min-width: 140px; resize: vertical; }
.data-table input:hover, .data-table textarea:hover, .data-table select:hover { background: #f8fafc; }
.data-table input:focus, .data-table textarea:focus, .data-table select:focus { border-color: #9dc2e2; background: #fff; box-shadow: 0 0 0 3px rgba(46,110,170,.1); }
.comparison-table { min-width: 760px; table-layout: fixed; }
.comparison-table th:first-child { width: 150px; position: sticky; left: 0; z-index: 2; }
.comparison-table td:first-child { position: sticky; left: 0; z-index: 1; padding: 11px 12px; background: #fbfcfe; color: #42526a; font-weight: 750; }
.comparison-table .supplier-heading { min-width: 225px; padding: 10px; background: #f3f7fb; }
.supplier-heading-inner { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.supplier-heading-inner input { min-width: 140px; font-weight: 800; }
.comparison-table td.lowest { background: var(--blue-soft); }
.comparison-table td.lowest input { color: var(--navy); font-weight: 900; }
.item-table { min-width: 1120px; }
.item-table .narrow { width: 86px; }
.item-table .action-column { width: 58px; }
.item-table td { padding: 3px; }
.item-table td:last-child { padding: 7px 5px; text-align: center; }
.review-note { display: grid; grid-template-columns: auto 1fr; gap: 18px; padding: 20px 24px; border: 1px solid #ead9b8; border-radius: 14px; background: var(--amber-soft); color: #6c4c1d; }
.review-note strong { white-space: nowrap; font-size: .86rem; }
.review-note p { margin: 0; font-size: .8rem; }
.action-bar { position: fixed; inset: auto 0 0; z-index: 15; border-top: 1px solid var(--line); background: rgba(255,255,255,.96); box-shadow: 0 -12px 32px rgba(24,50,76,.08); backdrop-filter: blur(14px); }
.action-inner { min-height: 76px; display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.action-group { display: flex; gap: 10px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
@media (max-width: 800px) {
  .header-inner, .page-shell, .action-inner { width: min(100% - 24px,1180px); }
  .draft-state { display: none; } .page-shell { padding-top: 22px; }
  .header-actions > div { display: none; }
  .hero { grid-template-columns: 1fr; gap: 24px; } .hero h1 { font-size: 2.2rem; }
  .steps { justify-content: space-between; }
  .panel { padding: 20px 16px; border-radius: 14px; }
  .section-heading { display: grid; gap: 14px; } .section-heading .button { justify-self: start; }
  .upload-row { grid-template-columns: 42px minmax(0,1fr) auto; }
  .upload-row .file-status { grid-column: 2/3; }
  .upload-row .remove-upload { grid-column: 3; grid-row: 1/3; }
  .review-note { grid-template-columns: 1fr; gap: 6px; } .review-note strong { white-space: normal; }
}
@media (max-width: 520px) {
  .brand small { display: none; } .hero h1 { font-size: 1.9rem; } .steps li { min-width: 68px; }
  .drop-zone { min-height: 160px; padding: 20px 12px; } .action-inner { min-height: 70px; }
  .action-group { margin-left: auto; } .button { padding-inline: 12px; } #reset-all { display: none; }
  .login-card { padding: 26px 22px; } .login-copy h1 { font-size: 1.5rem; }
}
@media print {
  @page { size: A4 landscape; margin: 12mm; }
  body { background: #fff; color: #000; }
  .site-header, .hero, .upload-panel, .action-bar, .button, .icon-button, .notice, .section-kicker, .review-note { display: none !important; }
  .page-shell { width: 100%; padding: 0; }
  .panel { break-inside: avoid; margin: 0 0 12mm; padding: 0; border: 0; box-shadow: none; }
  .section-heading { margin-bottom: 10px; } .section-heading p, .count-pill { display: none; }
  .table-scroll { overflow: visible; border-color: #888; }
  .data-table { min-width: 0; font-size: 8pt; table-layout: auto; }
  .data-table th, .data-table td { border-color: #aaa; }
  .data-table input, .data-table textarea, .data-table select { min-height: 0; padding: 4px; font-size: 8pt; }
  .comparison-table th:first-child, .comparison-table td:first-child { position: static; }
}
