:root {
  --pf-yellow: #f7ef48;
  --pf-orange: #ff8740;
  --ink: #242424;
  --muted: #62666b;
  --line: #e8e6df;
  --line-soft: #f1efe8;
  --page: #faf9f5;
  --white: #fff;
  --focus: 0 0 0 3px rgba(255, 135, 64, .28);
  --sidebar-width: 228px;
}

* { box-sizing: border-box; }
html { font-family: system-ui, "Microsoft YaHei", "PingFang SC", Arial, sans-serif; color: var(--ink); background: var(--page); }
body { margin: 0; min-width: 320px; line-height: 1.55; }
button, input { font: inherit; }
button, a, input, summary { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }
button:focus-visible, a:focus-visible, input:focus-visible, summary:focus-visible { outline: 2px solid #9e5121; outline-offset: 2px; box-shadow: var(--focus); }
button { cursor: pointer; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 7px; font-size: 26px; line-height: 1.3; font-weight: 750; letter-spacing: -.025em; text-wrap: balance; }
h2 { font-size: 17px; line-height: 1.35; }
.muted { color: var(--muted); }
.eyebrow { margin: 0 0 7px; color: #9d4f1b; font-size: 12px; font-weight: 750; }

/* The shell follows the compact, light sidebar used by the PPF store ERP. */
.app-shell { min-height: 100vh; }
.site-sidebar { position: fixed; inset: 0 auto 0 0; z-index: 20; display: flex; width: var(--sidebar-width); flex-direction: column; border-right: 1px solid var(--line); background: var(--white); }
.brand { display: grid; align-content: center; gap: 2px; min-height: 67px; padding: 0 20px; border-bottom: 1px solid var(--line); }
.brand img { display: block; width: 157px; height: auto; }
.brand small { color: var(--muted); font-size: 11px; font-weight: 650; }
.primary-nav { overflow-y: auto; padding: 13px 12px 18px; }
.nav-group + .nav-group { margin-top: 14px; }
.nav-caption { display: block; margin: 0 10px 6px; color: #747779; font-size: 11px; font-weight: 700; }
.primary-nav a { display: flex; align-items: center; min-height: 39px; margin: 2px 0; padding: 8px 12px; border-radius: 10px; color: #494d50; font-size: 13px; font-weight: 650; transition: background-color .16s ease, color .16s ease; }
.primary-nav a:hover { background: #fff9d8; color: var(--ink); }
.primary-nav a.active { background: #1c1c1c; color: var(--pf-yellow); }
.sidebar-foot { display: grid; gap: 2px; margin-top: auto; padding: 15px 21px 18px; border-top: 1px solid var(--line); font-size: 12px; }
.sidebar-foot > span { color: var(--muted); }
.sidebar-foot strong { overflow: hidden; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.logout button { padding: 0; border: 0; background: none; color: #654c3d; font-size: 12px; font-weight: 650; }
.sidebar-foot .logout { margin-top: 8px; }
.logout button:hover { color: #a34c18; text-decoration: underline; }
.app-main { min-width: 0; min-height: 100vh; margin-left: var(--sidebar-width); }
.site-header { position: sticky; top: 0; z-index: 15; display: flex; align-items: center; justify-content: space-between; gap: 20px; height: 67px; padding: 0 30px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.97); }
.topbar-title { display: flex; align-items: center; min-width: 0; gap: 18px; }
.topbar-title img { display: block; width: 112px; height: auto; }
.topbar-title strong { overflow: hidden; font-size: 17px; font-weight: 750; text-overflow: ellipsis; white-space: nowrap; }
.topbar-user { display: flex; align-items: center; min-width: 0; gap: 9px; color: #4d5153; font-size: 12px; font-weight: 650; }
.topbar-user > span:last-child { overflow: hidden; max-width: 150px; text-overflow: ellipsis; white-space: nowrap; }
.user-avatar { display: grid; width: 31px; height: 31px; flex: none; place-items: center; border-radius: 9px; background: #1c1c1c; color: var(--pf-yellow); font-size: 14px; }
.mobile-menu { display: none; }
.page-shell { width: min(100%, 1232px); min-height: calc(100vh - 67px); margin: 0 auto; padding: 34px 30px 70px; }

/* Overview and page entry points */
.intro { display: flex; align-items: center; min-height: 145px; padding: 27px 31px; border: 1px solid var(--line); border-radius: 14px; background: var(--white); }
.intro h1 { margin-bottom: 8px; }
.intro p:last-child { max-width: 65ch; margin: 0; color: var(--muted); font-size: 13px; }
.directory-section { margin-top: 28px; }
.section-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 11px; }
.section-heading h2 { margin: 0; font-size: 16px; font-weight: 750; }
.section-heading span { color: var(--muted); font-size: 12px; }
.directory { overflow: hidden; border: 1px solid var(--line); border-radius: 12px; background: var(--white); }
.directory-item { display: flex; align-items: center; justify-content: space-between; gap: 20px; min-height: 68px; padding: 12px 21px; border-bottom: 1px solid var(--line-soft); transition: background-color .16s ease; }
.directory-item:last-child { border-bottom: 0; }
.directory-item:hover { background: #fffdf0; }
.directory-copy { display: grid; min-width: 0; gap: 2px; }
.directory-copy strong { font-size: 14px; font-weight: 700; }
.directory-copy small { color: var(--muted); font-size: 12px; }
.directory-arrow { color: #704722; font-size: 20px; line-height: 1; }
.page-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 22px; margin-bottom: 23px; }
.page-heading p:last-child { margin-bottom: 0; color: var(--muted); font-size: 13px; }
.back-link { flex: none; margin-top: 8px; color: #72502c; font-size: 13px; font-weight: 650; }
.back-link::before { content: "←"; margin-right: 7px; }
.back-link:hover, .text-link:hover { color: #a6511c; text-decoration: underline; }

/* Shared controls and data views */
.surface { border: 1px solid var(--line); border-radius: 12px; background: var(--white); }
.toolbar { display: flex; align-items: end; gap: 10px; margin-bottom: 16px; padding: 16px 18px; border: 1px solid var(--line); border-radius: 12px; background: var(--white); }
.search-field { display: grid; flex: 1; max-width: 390px; gap: 6px; font-size: 12px; font-weight: 650; }
.search-field input, .login-form input, .quota input, .account-form input { min-height: 40px; padding: 8px 11px; border: 1px solid #c9c7bf; border-radius: 8px; background: var(--white); color: var(--ink); outline: none; }
input::placeholder { color: #63676b; opacity: 1; }
.search-field input:focus, .login-form input:focus, .quota input:focus, .account-form input:focus { border-color: #a5511e; box-shadow: var(--focus); }
.button { display: inline-flex; align-items: center; justify-content: center; min-height: 40px; padding: 0 15px; border: 1px solid transparent; border-radius: 8px; font-size: 13px; font-weight: 700; line-height: 1.2; cursor: pointer; white-space: nowrap; transition: background-color .16s ease, border-color .16s ease; }
.button-primary { background: var(--pf-yellow); color: #1a1a1a; }
.button-primary:hover { background: #e9df31; }
.button-secondary { border-color: #d9d7d0; background: var(--white); color: var(--ink); }
.button-secondary:hover { background: #f7f6f1; border-color: #b9b6ad; }
.button-quiet { background: transparent; color: #774b24; text-decoration: underline; }
.button:disabled { cursor: not-allowed; opacity: .45; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 13px 17px; border-bottom: 1px solid var(--line-soft); text-align: left; vertical-align: middle; }
th { background: #f9f8f4; color: #53575a; font-size: 12px; font-weight: 700; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fffef7; }
.numeric { text-align: right; font-variant-numeric: tabular-nums; }
.strong-number { font-size: 16px; font-weight: 750; }
.product-name { display: block; min-width: 150px; max-width: 320px; font-weight: 650; line-height: 1.45; }
.sku-code { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; font-weight: 450; overflow-wrap: anywhere; }
.sku-form { display: flex; align-items: center; gap: 8px; min-width: 278px; }
.toggle { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 650; white-space: nowrap; }
.toggle input { width: 16px; height: 16px; accent-color: #cbbd00; }
.quota input { width: 70px; min-height: 36px; padding: 5px 8px; text-align: right; font-variant-numeric: tabular-nums; }
.sku-form .button { min-height: 36px; padding: 0 12px; }
.available { flex: none; color: var(--muted); font-size: 11px; white-space: nowrap; }
.pagination { display: flex; align-items: center; gap: 17px; margin-top: 13px; color: var(--muted); font-size: 12px; }
.pagination a, .text-link { color: #8a4c1b; font-weight: 650; }
.status-pill { display: inline-flex; align-items: center; min-height: 25px; padding: 3px 9px; border-radius: 5px; background: #edf4ed; color: #286039; font-size: 11px; font-weight: 700; white-space: nowrap; }
.status-warning { background: #fff0d9; color: #8b4b13; }
.table-note { margin: 12px 2px 0; color: var(--muted); font-size: 12px; line-height: 1.6; }
.empty-state { padding: 44px 22px; color: var(--muted); font-size: 13px; text-align: center; }
.empty-state a { color: #8a4c1b; text-decoration: underline; }
.order-facts { display: flex; flex-wrap: wrap; gap: 14px 36px; margin-bottom: 16px; padding: 18px 20px; }
.order-facts div { display: grid; min-width: 0; gap: 3px; }
.order-facts span { color: var(--muted); font-size: 11px; }
.order-facts strong { font-size: 14px; overflow-wrap: anywhere; }
.notice { display: flex; align-items: center; gap: 16px; margin-bottom: 17px; padding: 14px 18px; border: 1px solid #e8d4a7; border-radius: 10px; background: #fff9e9; color: #65431d; font-size: 13px; }
.notice strong { flex: none; font-size: 13px; }
.notice span { line-height: 1.55; }
.alert { margin-bottom: 18px; padding: 12px 15px; border: 1px solid #e8d4a7; border-radius: 8px; background: #fff9e9; color: #65431d; font-size: 13px; }
.alert-error { border-color: #e0b4b4; background: #fff3f3; color: #852e2e; }

/* Platform connection, then two distinct sync tasks, then history. */
.connection-panel { overflow: hidden; margin-bottom: 17px; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 15px; padding: 17px 20px 14px; }
.panel-heading h2 { margin: 0; font-size: 16px; font-weight: 750; }
.panel-heading p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.connection-summary { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); padding: 0 20px 18px; }
.connection-item { display: grid; gap: 5px; min-width: 0; padding: 12px 14px; border-top: 1px solid var(--line-soft); border-right: 1px solid var(--line-soft); }
.connection-item:first-child { padding-left: 0; }
.connection-item:last-child { padding-right: 0; border-right: 0; }
.connection-item span { color: var(--muted); font-size: 12px; }
.connection-item strong { color: #286039; font-size: 13px; font-weight: 700; }
.connection-item strong.is-pending { color: #90521c; }
.sync-actions { overflow: hidden; }
.sync-actions > .panel-heading { border-bottom: 1px solid var(--line-soft); }
.sync-action { display: flex; align-items: center; justify-content: space-between; gap: 28px; padding: 18px 20px; }
.sync-action + .sync-action { border-top: 1px solid var(--line-soft); }
.sync-copy { min-width: 0; }
.sync-copy h2 { margin: 0 0 4px; font-size: 14px; font-weight: 700; }
.sync-copy p { max-width: 68ch; margin: 0 0 5px; color: var(--muted); font-size: 12px; }
.sync-copy a { font-size: 12px; }
.sync-action form { flex: none; }
.sync-history { margin-top: 27px; }
.sync-history h2 { margin: 0 0 11px; font-size: 16px; font-weight: 750; }
.sync-history td { overflow-wrap: anywhere; }

/* Account pages */
.login-page { display: grid; min-height: 100vh; place-items: center; padding: 24px; }
.login-shell { width: min(100%, 440px); padding: 31px 34px; border: 1px solid var(--line); border-radius: 14px; background: var(--white); }
.login-logo { display: block; width: 220px; max-width: 100%; height: auto; margin-bottom: 28px; }
.login-shell .muted { margin-bottom: 0; font-size: 13px; }
.login-form { display: grid; gap: 16px; margin-top: 26px; }
.login-form label, .account-form label { display: grid; gap: 7px; font-size: 13px; font-weight: 650; }
.login-form .button { margin-top: 4px; }
.demo-login { margin-top: 12px; text-align: center; }
.account-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 15px; color: var(--muted); font-size: 13px; }
.account-form-card { width: min(100%, 570px); padding: 26px 28px; }
.account-hint { margin: 0 0 21px; color: var(--muted); font-size: 13px; }
.account-form { display: grid; gap: 18px; }
.account-form input { width: 100%; }
.account-form small { color: var(--muted); font-size: 12px; font-weight: 450; }
.form-actions { display: flex; align-items: center; gap: 10px; margin-top: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }

@media (max-width: 980px) {
  .site-sidebar { width: 200px; }
  .app-main { margin-left: 200px; }
  .site-header { padding: 0 23px; }
  .page-shell { padding: 27px 23px 55px; }
  .connection-summary { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .connection-item:nth-child(even) { border-right: 0; }
  .connection-item:nth-child(odd) { padding-left: 0; }
  .connection-item:last-child { grid-column: 1 / -1; }
}
@media (max-width: 700px) {
  .site-sidebar, .topbar-user { display: none; }
  .app-main { margin-left: 0; }
  .site-header { height: 59px; padding: 0 17px; }
  .topbar-title { display: grid; gap: 0; }
  .topbar-title img { width: 105px; }
  .topbar-title strong { font-size: 15px; }
  .mobile-menu { position: relative; display: block; flex: none; }
  .mobile-menu summary { display: flex; align-items: center; justify-content: center; min-width: 58px; min-height: 35px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--white); font-size: 12px; font-weight: 700; cursor: pointer; list-style: none; }
  .mobile-menu summary::-webkit-details-marker { display: none; }
  .mobile-menu[open] summary { background: #fff9d8; }
  .mobile-menu-panel { position: absolute; top: calc(100% + 10px); right: 0; z-index: 30; width: min(300px, calc(100vw - 34px)); max-height: calc(100vh - 75px); overflow-y: auto; border: 1px solid var(--line); border-radius: 12px; background: var(--white); box-shadow: 0 8px 16px rgba(20,20,20,.12); }
  .mobile-menu-panel .primary-nav { padding: 10px; }
  .mobile-menu-panel .logout { padding: 11px 20px 16px; border-top: 1px solid var(--line); }
  .page-shell { min-height: calc(100vh - 59px); padding: 22px 17px 45px; }
  .page-heading { flex-direction: column; gap: 8px; }
  .back-link { margin: 0; }
  .sync-action { align-items: stretch; flex-direction: column; gap: 13px; }
  .sync-action form, .sync-action .button { width: 100%; }
  .notice { align-items: flex-start; flex-direction: column; gap: 4px; }
  .toolbar { flex-wrap: wrap; }
  .search-field { max-width: none; min-width: 180px; }
}
@media (max-width: 520px) {
  h1 { font-size: 23px; }
  .intro { min-height: 0; padding: 23px 20px; }
  .directory-section { margin-top: 23px; }
  .directory-item { min-height: 66px; padding: 11px 16px; }
  .directory-copy small { line-height: 1.45; }
  .toolbar .button { width: 100%; }
  .order-facts { gap: 14px 22px; }
  .table-scroll { overflow: visible; border: 0; background: transparent; }
  .table-scroll table, .table-scroll tbody, .table-scroll tr, .table-scroll td { display: block; width: 100%; }
  .table-scroll thead { display: none; }
  .table-scroll tr { overflow: hidden; margin-bottom: 10px; border: 1px solid var(--line); border-radius: 11px; background: var(--white); }
  .table-scroll td { display: flex; align-items: flex-start; justify-content: space-between; gap: 13px; min-width: 0; padding: 10px 14px; border-bottom: 1px solid var(--line-soft); text-align: right; overflow-wrap: anywhere; }
  .table-scroll td:last-child { border-bottom: 0; }
  .table-scroll td:first-child { display: block; padding: 13px 14px; background: #f9f8f4; text-align: left; font-weight: 700; }
  .table-scroll td:not(:first-child)::before { flex: none; content: attr(data-label); color: var(--muted); font-size: 11px; font-weight: 650; text-align: left; }
  .table-scroll .product-name { min-width: 0; }
  .sku-table td:last-child { display: block; text-align: left; }
  .sku-table td:last-child::before { display: block; margin-bottom: 8px; }
  .sku-form { min-width: 0; flex-wrap: wrap; }
  .sku-form .available { flex-basis: 100%; }
  .sync-history .table-scroll td:first-child { display: flex; background: var(--white); font-weight: 450; }
  .sync-history .table-scroll td:first-child::before { flex: none; content: attr(data-label); color: var(--muted); font-size: 11px; font-weight: 650; }
  .login-shell { padding: 27px 22px; }
  .account-form-card { padding: 22px 18px; }
  .account-toolbar { align-items: stretch; flex-direction: column; }
  .account-toolbar .button { align-self: flex-start; }
  .form-actions { flex-wrap: wrap; }
}
@media (prefers-reduced-motion: reduce) {
  .primary-nav a, .directory-item, .button { transition: none; }
}
