:root {
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', 'Microsoft YaHei', sans-serif;
  font-size: 14px;
  font-weight: 400;
  line-height: 1.55;
  color: #1e293b;
  color-scheme: light;
  background: #f8fafc;
  --ink: #1e293b;
  --paper: #f8fafc;
  --card: #fff;
  --blue: #3b82f6;
  --muted: #64748b;
  --border: #e4e4e7;
  --sidebar-width: 240px;
  --card-shadow: 0 1px 2px #0f172a0f;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; overflow: hidden; }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled, input:disabled, select:disabled { opacity: .5; cursor: default; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 3px; }
a { color: #2563eb; }
svg { display: block; }

.app-sidebar { position: fixed; inset: 0 auto 0 0; z-index: 40; width: var(--sidebar-width); padding: 24px 16px; display: flex; flex-direction: column; background: var(--ink); color: #ffffffb3; box-shadow: 0 0 0 1px #0f172a0f; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 600; white-space: nowrap; }
.brand-icon { flex: 0 0 32px; height: 32px; display: grid; place-items: center; border-radius: 8px; color: #fff; background: #ffffff1a; }
.nav-caption { margin: 32px 12px 12px; font-size: 12px; color: #ffffff80; letter-spacing: .04em; }
.navigation { display: grid; gap: 8px; }
.navigation a { display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 10px 12px; border-radius: 8px; color: #ffffffb3; text-decoration: none; font-size: 14px; font-weight: 500; transition: background 150ms, color 150ms; }
.navigation svg { width: 18px; height: 18px; flex: 0 0 18px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.navigation a:hover { background: #ffffff0f; color: #fff; }
.navigation a[aria-current='page'] { background: #ffffff1a; color: #fff; }
.sidebar-note { margin: auto 0 0; padding: 24px 12px 0; border-top: 1px solid #ffffff14; font-size: 12px; color: #ffffff80; line-height: 1.8; }
.topbar { position: fixed; inset: 0 0 auto var(--sidebar-width); height: 56px; padding: 0 24px; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 16px; background: #fff; border-bottom: 1px solid var(--border); font-size: 13px; }
.toolbar-location { display: flex; align-items: center; gap: 12px; color: var(--muted); }
.toolbar-location strong { color: var(--ink); font-weight: 500; }
.breadcrumb-divider { margin: 0 12px; color: #94a3b8; }
.local-status { display: flex; align-items: center; gap: 8px; white-space: nowrap; color: var(--muted); font-size: 12px; }
.local-status > span { width: 6px; height: 6px; border-radius: 50%; background: #10b981; }
.user-toolbar { display: flex; gap: 12px; align-items: center; font-size: 12px; }
#user-name { max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.login-page { display: grid; place-items: center; min-height: 100dvh; padding: 24px; overflow: auto; }
.login-card { width: min(100%, 440px); }
.login-card .brand-icon { background: var(--ink); width: 40px; height: 40px; margin-bottom: 24px; }
.login-card h1 { font-size: 24px; }
.login-card .hint { overflow-wrap: anywhere; }
.admin-login-form { margin-top: 24px; }
.admin-login-form label { display: block; margin-top: 16px; }
.admin-login-form .button { margin-top: 20px; }
.login-divider { display: flex; gap: 12px; align-items: center; margin: 24px 0 16px; color: var(--muted); font-size: 12px; }
.login-divider::before, .login-divider::after { content: ''; height: 1px; background: var(--border); flex: 1; }
.people-intro, .people-heading, .people-pagination { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.people-intro .button { flex-shrink: 0; }
.people-sync-info { margin-bottom: 16px; }
.people-layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 16px; align-items: start; }
.department-card { padding: 20px 12px; }
.department-card h2 { margin: 0 12px 16px; font-size: 16px; }
.department-list { display: grid; gap: 4px; max-height: 60vh; overflow: auto; }
.department-entry { min-width: 0; }
.department-row { display: flex; align-items: center; min-width: 0; border-radius: 6px; }
.department-row:hover { background: #f1f5f9; }
.department-row[data-selected='true'] { background: #eff6ff; }
.department-button { flex: 1; min-width: 0; text-align: left; border: 0; border-radius: 6px; background: transparent; color: var(--muted); padding: 9px 8px; overflow-wrap: anywhere; }
.department-button[aria-pressed='true'] { color: #2563eb; }
.department-toggle, .department-toggle-spacer { flex: 0 0 24px; width: 24px; height: 28px; }
.department-toggle { display: grid; place-items: center; padding: 0; border: 0; border-radius: 4px; background: transparent; color: var(--muted); font-size: 22px; line-height: 1; transition: transform 150ms; }
.department-toggle:hover { background: #dbeafe; color: #2563eb; }
.department-toggle[aria-expanded='true'] { transform: rotate(90deg); }
.people-filters { display: flex; gap: 12px; margin: 20px 0 12px; }
.people-filters input { flex: 1; }
.people-filters select { width: 160px; }
.people-role-hint { margin-bottom: 16px; }
.table-scroll { overflow-x: auto; }
.people-table { width: 100%; min-width: 560px; }
.people-table th, .people-table td { padding: 8px; text-align: left; vertical-align: middle; }
.people-table th { white-space: nowrap; }
.people-table th:first-child { width: 112px; }
.people-table th:nth-child(2) { width: 140px; }
.people-table th:nth-child(3) { width: 64px; }
.people-table th:nth-child(4) { width: 156px; }
.people-table th:nth-child(5) { width: 76px; }
.people-table td:first-child, .people-table td:nth-child(2) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.people-table td:nth-child(3), .people-table td:nth-child(5) { white-space: nowrap; }
.people-table select { display: block; width: 100%; min-width: 0; max-width: 100%; height: 32px; padding: 5px 8px; }
.people-table .button { min-width: 56px; min-height: 32px; padding: 5px 10px; white-space: nowrap; }
.people-pagination { margin-top: 20px; }
.people-pagination > div { display: flex; gap: 8px; }
.password-card { margin-top: 20px; }
.password-card summary { cursor: pointer; font-weight: 500; }
.password-card form { max-width: 360px; }
.password-card label { display: block; margin-top: 16px; }
.password-card .button { margin-top: 16px; }
@media (max-width: 900px) {
  .people-layout { grid-template-columns: minmax(0, 1fr); }
  .department-list { max-height: 180px; }
}
@media (max-width: 600px) {
  .people-intro { align-items: flex-start; flex-direction: column; }
  .people-pagination { flex-wrap: wrap; }
}
.menu-toggle { display: none; width: 32px; height: 32px; padding: 0; border: 1px solid var(--border); border-radius: 8px; color: var(--ink); background: #fff; }
.nav-backdrop { position: fixed; inset: 0; z-index: 30; padding: 0; border: 0; background: #0f172a66; }

main { position: fixed; inset: 56px 0 0 var(--sidebar-width); padding: 32px 24px 48px; overflow: auto; }
main > * { max-width: 1200px; margin-left: auto; margin-right: auto; }
.intro { margin-bottom: 24px; }
.eyebrow { margin: 0 0 8px; color: var(--muted); font-size: 12px; font-weight: 500; letter-spacing: .04em; }
h1 { margin: 0 0 8px; font-size: 28px; font-weight: 600; line-height: 1.2; letter-spacing: -.01em; }
h2 { margin: 0; font-size: 20px; font-weight: 600; line-height: 1.3; }
p { margin: 0; }
.intro p:last-child { color: var(--muted); }
.layout { display: grid; grid-template-columns: minmax(260px, 300px) minmax(0, 1fr); gap: 16px; align-items: start; }
.side { display: grid; gap: 16px; min-width: 0; }
.card { min-width: 0; padding: 24px; border: 1px solid var(--border); border-radius: 12px; background: var(--card); box-shadow: var(--card-shadow); }
.section-title { display: flex; align-items: center; gap: 10px; margin-bottom: 20px; }
.step { flex-shrink: 0; display: grid; place-items: center; width: 24px; height: 24px; border-radius: 6px; color: #2563eb; background: #3b82f61a; font-size: 12px; font-weight: 500; }
label, .account-heading { font-size: 13px; font-weight: 500; }
input[type='text'], input[type='password'], input[type='number'], select { width: 100%; min-width: 0; height: 36px; padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; color: var(--ink); background: #fff; font-size: 13px; transition: border-color 150ms, box-shadow 150ms; }
input::placeholder { color: #94a3b8; }
input:focus, select:focus { border-color: var(--blue); box-shadow: 0 0 0 2px #3b82f633; outline: none; }
label + input, label + select { margin-top: 8px; }
.match-label, #login label[for='password'] { display: block; margin-top: 16px; }
.agreement { display: flex; gap: 8px; align-items: flex-start; margin-top: 16px; color: var(--muted); font-size: 12px; font-weight: 400; line-height: 1.6; }
input[type='checkbox'] { flex: 0 0 16px; width: 16px; height: 16px; margin: 2px 0 0; accent-color: var(--blue); cursor: pointer; }
.cookie-option { margin-top: 16px; color: #2563eb; font-size: 13px; }
.cookie-option summary { cursor: pointer; }
.cookie-option form { margin-top: 16px; }
.hint { color: var(--muted); font-size: 12px; line-height: 1.6; }
input + .hint { margin-top: 8px; }
.button { display: inline-block; min-height: 36px; padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; color: var(--ink); background: #fff; box-shadow: var(--card-shadow); font-size: 13px; font-weight: 500; text-align: center; transition: background 150ms, border-color 150ms; }
.button:hover:not(:disabled) { background: #f1f5f9; }
.button:active:not(:disabled) { background: #e2e8f0; }
.primary { color: #fff; border-color: var(--ink); background: var(--ink); }
.primary:hover:not(:disabled) { background: #334155; }
.secondary { color: #475569; }
.full { width: 100%; margin-top: 16px; }
.link-button { display: block; text-align: center; text-decoration: none; }
.account-heading, .results-heading, .review-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.account-heading { margin: 16px 0 12px; }
.text-button { padding: 4px 0; border: 0; background: none; color: #2563eb; font-size: 12px; font-weight: 500; }
.text-button:hover:not(:disabled) { text-decoration: underline; }
.account-picker { position: relative; margin-top: 8px; }
.account-trigger { display: flex; justify-content: space-between; align-items: center; gap: 8px; width: 100%; min-height: 36px; padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; color: var(--ink); background: #fff; text-align: left; font-size: 13px; }
.account-trigger::after { content: '⌄'; color: var(--muted); }
.account-trigger[aria-expanded='true'] { border-color: var(--blue); }
.account-trigger[aria-expanded='true']::after { content: '⌃'; }
.account-dropdown { position: absolute; top: calc(100% + 8px); left: 0; z-index: 10; width: max(100%, 300px); max-width: calc(100vw - var(--sidebar-width) - 64px); padding: 12px; border: 1px solid var(--border); border-radius: 8px; background: #fff; box-shadow: 0 8px 20px #0f172a14; }
.account-dropdown .account-heading { margin: 0 0 12px; }
.account-dropdown .account-options { max-height: min(280px, 40vh); }
.selection-hint { margin-top: 8px; overflow-wrap: anywhere; }
.account-options { display: grid; gap: 4px; max-height: 280px; overflow: auto; }
.account-option { display: flex; align-items: start; gap: 8px; padding: 8px; border-radius: 6px; background: #fff; cursor: pointer; overflow-wrap: anywhere; }
.account-option:hover { background: #f8fafc; }
.account-option small, td small { display: block; color: var(--muted); font-size: 12px; line-height: 1.55; margin-top: 4px; font-weight: 400; }
.badge { display: inline-block; padding: 4px 8px; border-radius: 6px; color: #2563eb; background: #3b82f61a; font-size: 12px; white-space: nowrap; }
.badge[data-available='false'] { color: #9f3a38; background: #fff1f2; }
.result-card { min-height: 360px; }
.results-heading .section-title { margin-bottom: 0; }
.results-hint { margin: 12px 0 16px; }
.message { margin-top: 12px; padding: 12px; border: 1px solid var(--border); border-radius: 8px; background: #f8fafc; color: #475569; font-size: 13px; line-height: 1.6; white-space: pre-line; overflow-wrap: anywhere; }
.message[data-tone='error'] { color: #9f3a38; border-color: #fecdd3; }
.message[data-tone='success'] { color: #047857; border-color: #a7f3d0; }
.empty { display: grid; justify-items: center; align-content: center; text-align: center; min-height: 240px; gap: 12px; padding: 24px; border: 1px dashed var(--border); border-radius: 8px; background: #f8fafc; }
.empty strong { font-weight: 500; }
.empty p { color: var(--muted); font-size: 13px; }
.empty-icon { display: grid; place-items: center; width: 40px; height: 40px; color: #94a3b8; }
.empty-icon svg { width: 28px; }
.table-wrap { margin-top: 16px; overflow-x: auto; }
table { width: 100%; min-width: 560px; text-align: left; border-collapse: collapse; table-layout: fixed; font-size: 13px; }
th, td { padding: 12px 8px; border-bottom: 1px solid var(--border); overflow-wrap: anywhere; vertical-align: top; }
th { color: #475569; background: #f8fafc; font-weight: 500; }
th:first-child { width: 32%; }
th:nth-child(2) { width: 32%; }
th:nth-child(3) { width: 16%; }
td:nth-child(3) { font-weight: 500; font-variant-numeric: tabular-nums; }
.batch-stock { display: flex; align-items: end; justify-content: space-between; flex-wrap: wrap; gap: 16px; padding: 16px; margin-top: 16px; border: 1px solid var(--border); border-radius: 8px; background: #f8fafc; }
.batch-stock label { display: block; }
.batch-stock input { max-width: 168px; }
.batch-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 16px; }
.editable { color: #047857; }
.account-list { display: grid; gap: 16px; margin-top: 16px; }
.account-card { min-width: 0; padding: 16px; border: 1px solid var(--border); border-radius: 8px; background: #fff; }
.account-card h3 { margin: 0; font-size: 16px; font-weight: 500; overflow-wrap: anywhere; }
.account-shops { list-style: none; margin: 12px 0 0; padding: 0; }
.account-shops li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--border); font-size: 13px; overflow-wrap: anywhere; }
.account-shops small { display: block; margin-top: 4px; color: var(--muted); font-size: 12px; }
dialog { width: min(520px, calc(100vw - 32px)); padding: 0; border: 1px solid var(--border); border-radius: 12px; color: inherit; background: #fff; box-shadow: 0 8px 20px #0f172a14; }
dialog::backdrop { background: #0f172a66; }
.review-body { padding: 24px; }
.review-body .hint { margin-top: 12px; }
#review-rows { padding-left: 24px; max-height: 45vh; overflow: auto; font-size: 13px; line-height: 1.6; overflow-wrap: anywhere; }
#review-rows li + li { margin-top: 8px; }
.review-actions { justify-content: flex-end; margin-top: 16px; }

.inventory-page main { padding-left: 16px; padding-right: 16px; }
.inventory-page main > * { max-width: none; margin-left: 0; margin-right: 0; }
.inventory-page .layout { grid-template-columns: 236px minmax(0, 1fr); gap: 12px; }
.inventory-page .side .card, .inventory-page .result-card { padding: 16px; }
.inventory-page table { min-width: 820px; font-size: 12px; }
.inventory-page th, .inventory-page td { padding: 8px; line-height: 1.35; vertical-align: middle; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.inventory-page td small { margin-top: 3px; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; }
.inventory-page th:first-child { width: 22%; }
.inventory-page th:nth-child(2) { width: 21%; }
.inventory-page th:nth-child(3) { width: 23%; }
.inventory-page th:nth-child(4) { width: 7%; }
.inventory-page th:nth-child(5) { width: 14%; }
.inventory-page th:nth-child(6) { width: 13%; }
.inventory-page td:nth-child(3) { font-weight: 400; }
.inventory-page td:nth-child(4) { font-variant-numeric: tabular-nums; font-weight: 500; }
.pagination, .page-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pagination { justify-content: space-between; margin-top: 16px; }
.pagination label { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.pagination select { width: 68px; height: 32px; padding: 4px 8px; margin: 0; }
.page-actions .button { min-height: 32px; padding: 6px 10px; font-size: 12px; }
.authorization-layout { grid-template-columns: 260px minmax(0, 1fr); }
.authorization-browser { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 16px; min-width: 0; align-items: start; }
.account-panel { padding: 16px; }
.account-panel h2 { font-size: 16px; }
.account-panel .empty { min-height: 160px; padding: 12px; }
.account-panel .account-list { gap: 8px; margin-top: 12px; }
.account-select { display: block; width: 100%; padding: 12px; border: 1px solid var(--border); border-radius: 8px; text-align: left; background: #fff; color: var(--ink); }
.account-select > span { display: block; overflow-wrap: anywhere; font-weight: 500; }
.account-select > small { display: block; margin-top: 4px; color: var(--muted); }
.account-select:hover { background: #f8fafc; }
.account-select[aria-pressed='true'] { background: #eff6ff; border-color: #93c5fd; color: #1d4ed8; }
.shop-detail-panel { min-width: 0; min-height: 360px; }
.shop-detail-panel h2 { overflow-wrap: anywhere; }

@media (max-width: 1200px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .side { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
  .inventory-page .side { grid-template-columns: minmax(0, 1fr); }
  .authorization-layout { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 900px) {
  .inventory-page .layout { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 1023px) and (min-width: 768px) {
  :root { --sidebar-width: 64px; }
  .app-sidebar { padding: 16px 8px; }
  .brand { justify-content: center; }
  .brand-name, .nav-caption, .navigation a span, .sidebar-note { display: none; }
  .navigation { margin-top: 24px; }
  .navigation a { justify-content: center; }
}
@media (max-width: 767px) {
  :root { --sidebar-width: 0px; }
  .app-sidebar { width: 240px; transform: translateX(-100%); transition: transform 150ms ease; }
  .nav-open .app-sidebar { transform: translateX(0); }
  .menu-toggle { display: inline-block; }
  .side { grid-template-columns: minmax(0, 1fr); }
  main { padding: 24px 16px; }
  .topbar { padding: 0 16px; }
  .local-status { font-size: 12px; }
  h1 { font-size: 24px; }
  .account-dropdown { max-width: calc(100vw - 64px); }
  .authorization-browser { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 480px) {
  .card { padding: 16px; }
  .account-shops li { flex-wrap: wrap; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
