:root {
  color-scheme: light;
  --canvas: #fafafa;
  --paper: #fff;
  --soft: #f6f6f6;
  --ink: #191919;
  --muted: #626262;
  --line: #e1e1e1;
  --line-strong: #cfcfcf;
  --accent: #0865e8;
  --accent-hover: #0756c8;
  --accent-soft: #edf4ff;
  --danger: #af3029;
  --success: #24633d;
  --brand: #ef6825;
  --radius: 9px;
  --control: 7px;
  --header: 58px;
  --rail-width: clamp(216px, 17.65vw, 260px);
  font: 15px/1.5 Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-synthesis: none;
}
*, *::before, *::after { box-sizing: border-box; }
body { min-width: 0; margin: 0; background: var(--canvas); color: var(--ink); -webkit-font-smoothing: antialiased; }
[hidden], .hidden { display: none !important; }
img { max-width: 100%; }
h1, h2, h3, h4, p, dl, dd { margin: 0; }
h3 { font-size: 1rem; font-weight: 620; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
button, summary, input[type=file], label.upload, label.btn { cursor: pointer; }
button { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
button:disabled, input:disabled, select:disabled, textarea:disabled { cursor: not-allowed; opacity: .52; }
:where(button, a, summary, input, select, textarea, [tabindex="0"]):focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input, select, textarea { min-width: 0; }
input::placeholder, textarea::placeholder { color: #777; opacity: 1; }
input[type=checkbox], input[type=radio] { accent-color: var(--accent); }
.bc-icon { flex: 0 0 auto; vertical-align: middle; }
::selection { background: #d9e9ff; }

.shell { display: grid; grid-template-columns: var(--rail-width) minmax(0, 1fr); min-height: 100dvh; }
.rail {
  position: sticky; top: 0; height: 100vh; height: 100dvh; min-width: 0; display: flex;
  flex-direction: column; align-self: start; border-right: 1px solid var(--line); background: var(--canvas);
}
.rail-head, .topbar, .login-header {
  min-height: var(--header); display: flex; align-items: center; border-bottom: 1px solid var(--line);
}
.rail-head { padding: 0 18px; flex-shrink: 0; justify-content: space-between; }
.brand, .login-brand { display: inline-flex; align-items: center; gap: 13px; color: var(--ink); font-weight: 650; text-decoration: none; }
.brand:hover, .login-brand:hover { text-decoration: none; }
.brand-mark { color: var(--brand); display: inline-grid; place-items: center; }
.brand-mark svg { width: 28px; height: 28px; }
.brand { font-size: 16px; }
.side-tools { padding: 15px 14px 16px; border-bottom: 1px solid var(--line); }
.quick-search {
  width: 100%; min-height: 35px; display: flex; align-items: center; gap: 9px; padding: 6px 10px; text-align: left;
  border: 1px solid var(--line); border-radius: var(--control); background: white; color: var(--muted); font-size: 14px;
}
.quick-search:hover, .head-action:hover, .rail-control:hover { background: #f0f0f0; }
.quick-search kbd { margin-left: auto; font: inherit; color: #757575; font-size: 12px; }
.nav { display: grid; align-content: start; gap: 12px; padding: 18px 14px; overflow-y: auto; }
.nav-group { min-width: 0; }
.nav-group > summary {
  display: flex; align-items: center; gap: 12px; padding: 8px 10px; min-height: 36px;
  border-radius: var(--control); list-style: none; font-size: 14px; font-weight: 590; user-select: none;
}
.nav-group summary::-webkit-details-marker, .category-panel summary::-webkit-details-marker,
.order-group > summary::-webkit-details-marker { display: none; }
.nav-group > summary:hover { background: #f0f0f0; }
.nav-group > summary .bc-icon { color: #737373; }
.nav-group > summary .bc-icon:last-child { margin-left: auto; }
.nav-group[open] > summary .bc-icon:last-child { transform: rotate(90deg); }
.nav-children { border-left: 1px solid var(--line); margin: 3px 0 0 17px; padding-left: 8px; display: grid; gap: 2px; }
.nav-link { display: block; min-height: 35px; padding: 7px 11px; border-radius: 6px; color: #3f3f3f; font-size: 14px; line-height: 1.5; }
.nav-link:hover, .nav-link[aria-current=page] { background: #efefef; color: var(--ink); text-decoration: none; }
.nav-link[aria-current=page] { font-weight: 620; }
.rail-bottom { margin-top: auto; padding: 8px 14px; border-top: 1px solid var(--line); }
.rail-control, .head-action {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; background: transparent;
  border: 0; border-radius: 6px; min-height: 34px; padding: 5px 8px; font-size: 13px; color: #454545;
}
.rail-control .bc-icon, .head-action .bc-icon { color: #717171; }
.workspace { min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 5; justify-content: space-between; gap: 12px; padding: 0 clamp(14px, 1.65vw, 26px);
  background: var(--canvas);
}
.top-context, .top-tools, .breadcrumbs { display: flex; align-items: center; gap: 12px; min-width: 0; }
.breadcrumbs { gap: 9px; font-size: 14px; white-space: nowrap; }
.breadcrumbs > a { color: #575757; }
.breadcrumbs .bc-icon { color: #8a8a8a; }
.breadcrumbs > span { color: var(--ink); font-weight: 550; }
.top-tools { gap: 8px; }
.top-tools > button + button { margin-left: 2px; }
.topbar #open-nav, .rail .mobile-only, .drawer-shade { display: none; }
.shell.rail-hidden { grid-template-columns: minmax(0, 1fr); }
.rail-hidden .rail { display: none; }
.rail-hidden .topbar #open-nav { display: inline-flex; }
main#content { min-width: 0; max-width: 1620px; margin: 0 auto; padding: clamp(26px, 2.4vw, 38px) clamp(22px, 2.2vw, 38px) 48px; }
.surface { min-width: 0; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 18px; margin-bottom: 26px; }
.page-title, .page-head h1, .surface > h1 {
  font-size: clamp(26px, 2.1vw, 32px); font-weight: 650; letter-spacing: -.025em; line-height: 1.3; overflow-wrap: anywhere;
}
.section-title { font-size: 1.06rem; font-weight: 620; line-height: 1.4; }
.meta, .muted, small { color: var(--muted); }
.meta, .small, small { font-size: .85rem; }
.money, .numeric, .big-total, [data-line-total] { font-variant-numeric: tabular-nums; }
.actions, .row, .spread, .chips, .toolbar { display: flex; min-width: 0; flex-wrap: wrap; align-items: center; gap: 8px; }
.actions { justify-content: flex-end; }
.spread { justify-content: space-between; }
.stack { min-width: 0; display: grid; align-content: start; gap: 16px; }
.tight { gap: 4px; }
.form-grid, .grid2, .grid3 { min-width: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 18px; }
.grid3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.full { grid-column: 1 / -1; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 37px; max-width: 100%;
  padding: 7px 13px; border: 1px solid var(--line-strong); border-radius: var(--control); background: var(--paper);
  color: var(--ink); font-size: 14px; font-weight: 530; line-height: 1.35; text-align: center; white-space: nowrap;
  box-shadow: 0 1px 1px #00000008; text-decoration: none;
}
.btn:hover { border-color: #b8b8b8; background: #f5f5f5; text-decoration: none; }
.btn.primary { background: var(--accent); color: white; border-color: #065ace; box-shadow: inset 0 1px #ffffff25, 0 1px 1px #00000012; }
.btn.primary:hover { background: var(--accent-hover); }
.btn.tonal { background: white; }
.btn.ghost { background: transparent; box-shadow: none; border-color: transparent; }
.btn.ghost:hover { background: #efefef; }
.btn.icon { padding: 5px; min-height: 32px; width: 32px; border-color: transparent; box-shadow: none; background: transparent; color: #595959; }
.btn.icon:hover { background: #ededed; }
.btn.danger { color: var(--danger); }
.chip, .tag {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 30px;
  padding: 4px 10px; border: 1px solid var(--line); border-radius: 6px; background: white; color: #3f3f3f; font-size: 13px;
}
.chip:hover { background: var(--soft); }
.chip.active, .chip[aria-pressed=true], .chip:has(input:checked) { color: #084ca9; border-color: #9bbaf0; background: var(--accent-soft); }
.chip input { margin: 0; }
.tag { min-height: 22px; padding: 1px 7px; background: var(--soft); font-size: 12px; }
.field { min-width: 0; display: grid; align-content: start; gap: 6px; }
.field > span:first-child, .field-label { font-size: 13px; color: #484848; font-weight: 550; }
.field :is(input, select, textarea), .control, .table-wrap :is(input, select, textarea) {
  min-width: 0; width: 100%; min-height: 37px; padding: 7px 10px; border: 1px solid var(--line-strong);
  border-radius: var(--control); background: white; color: var(--ink); font-size: 14px; line-height: 1.45;
}
.field textarea, textarea.control { min-height: 74px; resize: vertical; }
.field :is(input, select, textarea):focus, .control:focus, .table-wrap :is(input, select, textarea):focus {
  outline: 2px solid var(--accent); outline-offset: -1px;
}
.searchbox {
  display: flex; align-items: center; gap: 8px; min-width: 0; min-height: 38px; padding: 0 11px;
  border: 1px solid var(--line); border-radius: var(--control); background: white; color: #747474;
}
.searchbox:focus-within { outline: 2px solid var(--accent); outline-offset: -1px; }
.searchbox input { width: 100%; min-height: 36px; padding: 4px 0; outline: 0; border: 0; background: transparent; color: var(--ink); }
.searchbox input:focus-visible { outline: 0; }

.panel, .table-wrap, .order-group, .cost-box { min-width: 0; border: 1px solid var(--line); border-radius: var(--radius); background: white; }
.panel { overflow: hidden; }
.panel-head, .category-panel > summary {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 38px;
  padding: 8px 15px; border-bottom: 1px solid var(--line); background: #f7f7f7; color: var(--muted); font-size: 14px;
}
.panel-head h2, .panel-head h3 { color: var(--ink); font-size: 14px; font-weight: 600; }
.panel-head .btn { min-height: 28px; padding: 3px 8px; font-size: 13px; }
.panel-body { min-width: 0; padding: 16px; }
.table-scroll, .table-wrap { width: 100%; overflow-x: auto; overscroll-behavior-inline: contain; }
table { border-collapse: collapse; width: 100%; text-align: left; font-size: 14px; }
th, td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; text-align: left; }
thead th { position: relative; color: #333; background: white; font-weight: 560; font-size: 13px; white-space: nowrap; }
thead th + th::before { content: ""; position: absolute; top: 28%; bottom: 28%; left: 0; border-left: 1px solid var(--line); }
tbody tr:last-child > :is(td,th) { border-bottom: 0; }
tbody tr[data-record] { cursor: pointer; }
tbody tr:hover > :is(td,th) { background: #fafafa; }
tbody th { font-weight: 550; white-space: nowrap; }
th.numeric, td.numeric, .numeric input { text-align: right; white-space: nowrap; }
.table-wrap input[type=number] { width: 88px; min-height: 32px; padding: 5px 7px; font-variant-numeric: tabular-nums; text-align: right; }
.empty { min-height: 145px; display: grid; place-content: center; justify-items: center; gap: 9px; padding: 24px 16px; color: var(--muted); text-align: center; }
.empty > .bc-icon { color: #858585; }
.empty strong { color: #484848; font-weight: 530; }
.compact { min-height: 64px; padding: 14px; }
.notice { border: 1px solid #c6dcfc; border-radius: 6px; padding: 10px 12px; background: #f5f9ff; color: #24476c; font-size: 14px; }
.notice.error { border-color: #f2c7c4; background: #fff6f5; color: #962e27; }
.notice.success { color: var(--success); }
.toast { position: fixed; z-index: 40; right: 16px; bottom: max(16px, env(safe-area-inset-bottom)); max-width: calc(100vw - 32px); padding: 10px 16px; border-radius: 7px; background: #262626; color: white; }
.toast.bad { background: #8f302b; }

.native-modal {
  width: min(540px, calc(100% - 32px)); max-width: 100%; max-height: calc(100dvh - 52px);
  margin: auto; padding: 0; border: 1px solid #cecece; border-radius: 11px; background: white; color: var(--ink);
  box-shadow: 0 14px 54px #0003;
}
.native-modal[open] { display: flex; flex-direction: column; }
.native-modal.wide { width: min(840px, calc(100% - 32px)); }
.native-modal::backdrop { background: rgb(20 20 20 / 36%); }
.dialog-head, .dialog-foot { display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; gap: 10px; padding: 12px 18px; }
.dialog-head { border-bottom: 1px solid var(--line); background: #fafafa; }
.dialog-head h2 { font-size: 18px; font-weight: 630; }
.dialog-body { min-height: 0; min-width: 0; padding: 18px; overflow: auto; }
.dialog-foot { justify-content: flex-end; flex-wrap: wrap; border-top: 1px solid var(--line); }
.quick-results { display: grid; }
.quick-result { display: flex; align-items: center; gap: 11px; padding: 9px 4px; border-bottom: 1px solid var(--line); color: var(--ink); }
.quick-result:hover { background: #f6f6f6; text-decoration: none; }
.quick-result:last-child { border-bottom: 0; }
.quick-result small { display: block; }
.quick-result > svg:last-child { margin-left: auto; color: #888; }
.qr-box { display: grid; justify-items: center; gap: 8px; }
.account-qr { display: block; width: 190px; height: 190px; }
.login-page { min-height: 100dvh; display: grid; grid-template-rows: var(--header) 1fr; }
.login-header { padding: 0 24px; }
.login-card { align-self: start; justify-self: center; width: min(410px, calc(100% - 32px)); margin: clamp(52px, 12vh, 130px) 0;
  display: grid; gap: 19px; padding: 26px; background: white; border: 1px solid var(--line); border-radius: 10px; }
.login-card h1 { font-size: 24px; letter-spacing: -.025em; font-weight: 650; }
.login-card .primary { margin-top: 3px; }
.loading { color: var(--muted); }

@media (min-width: 960px) {
  .form-grid:has(> :nth-child(3):last-child) { grid-template-columns: repeat(3, minmax(0,1fr)); }
}
@media (max-width: 800px) {
  :root { --header: 53px; }
  .shell { display: block; }
  .rail {
    position: fixed; z-index: 15; left: 0; width: min(285px, calc(100vw - 46px));
    transform: translateX(-102%); visibility: hidden;
  }
  .drawer-open .rail { transform: none; visibility: visible; }
  .drawer-open .drawer-shade { display: block; position: fixed; inset: 0; z-index: 14; border: 0; background: #0005; }
  .drawer-active { overflow: hidden; }
  .rail .mobile-only, .topbar #open-nav { display: inline-flex; }
  .rail-bottom { display: none; }
  .topbar { padding-inline: 12px; gap: 6px; }
  .top-context, .top-tools { gap: 5px; }
  main#content { padding: 22px 16px 36px; }
  .page-head { gap: 10px; margin-bottom: 19px; }
  .page-title, .page-head h1, .surface > h1 { font-size: 25px; }
  .quick-search, .nav-link, .nav-group > summary { min-height: 40px; }
  .head-action { min-height: 36px; }
  .form-grid, .grid2, .grid3 { gap: 12px; }
}
@media (max-width: 560px) {
  .top-tools .head-action { width: 36px; height: 36px; padding: 6px; }
  .top-tools .head-action > span { display: none; }
  .form-grid, .grid2, .grid3 { grid-template-columns: minmax(0,1fr); }
  .actions { justify-content: flex-start; }
  .btn { min-height: 37px; padding-inline: 10px; font-size: 13px; }
  .btn.icon { min-height: 34px; }
  .field :is(input,select,textarea), .control, .table-wrap :is(input,select,textarea), .searchbox input { font-size: 16px; }
  th, td { padding: 9px 10px; }
  .dialog-body, .dialog-head, .dialog-foot { padding: 13px; }
  .native-modal, .native-modal.wide { width: calc(100% - 18px); max-height: calc(100dvh - 20px); }
  .panel-body { padding: 12px; }
}

#content { overflow-x: clip; }
.page { min-width: 0; }
.view-glyph { display: inline-grid; flex: 0 0 16px; width: 16px; height: 16px; place-items: center; }
.view-glyph > svg { grid-area: 1 / 1; }
#view-switch[data-view="list"] .view-glyph > :last-child { opacity: 0; transform: rotate(-12deg) scale(.72); }
#view-switch[data-view="grid"] .view-glyph > :first-child { opacity: 0; transform: rotate(12deg) scale(.72); }
.native-modal:not([open]), .native-modal:not([open])::backdrop { pointer-events: none; }

@keyframes content-appear {
  from { opacity: .25; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}
@keyframes dialog-appear {
  from { opacity: 0; transform: translateY(var(--dialog-offset)) scale(.98); }
  to { opacity: 1; transform: none; }
}
@keyframes backdrop-appear {
  from { opacity: 0; }
  to { opacity: 1; }
}

@media (prefers-reduced-motion: no-preference) {
  :root {
    --motion-ease: cubic-bezier(.2,.78,.22,1);
    --motion-settle: cubic-bezier(.22,1.28,.36,1);
    --dialog-offset: 9px;
  }
  .btn, .chip, .quick-search, .head-action, .rail-control {
    transition: transform 210ms var(--motion-settle), background-color 130ms ease,
      border-color 130ms ease, color 130ms ease;
  }
  :is(.btn, .chip, .quick-search, .head-action, .rail-control):not(:disabled):is(:active, [data-pressed]) {
    transform: scale(.972); transition: transform 65ms ease-out, background-color 65ms ease-out;
  }
  :is(.btn.icon, .head-action):not(:disabled):is(:active, [data-pressed]) { transform: scale(.94); }
  .nav-link { transition: background-color 145ms ease, color 120ms ease; }
  .view-glyph > svg { transition: transform 205ms var(--motion-settle), opacity 135ms ease; }
  .nav-group > summary > svg:last-child, .category-panel > summary > svg, .order-group > summary::after {
    transition: transform 195ms var(--motion-ease);
  }
  .login-card, .view-reveal { animation: content-appear 180ms var(--motion-ease) backwards; }
  .native-modal[open] { animation: dialog-appear 205ms var(--motion-ease) backwards; }
  .native-modal[open]::backdrop { animation: backdrop-appear 155ms ease-out backwards; }

  @supports (overlay: auto) and (transition-behavior: allow-discrete) {
    .native-modal {
      opacity: 0; transform: translateY(var(--dialog-offset)) scale(.98);
      transition: opacity 145ms ease, transform 145ms var(--motion-ease),
        display 145ms allow-discrete, overlay 145ms allow-discrete;
    }
    .native-modal[open] {
      animation: none; opacity: 1; transform: none;
      transition-duration: 170ms, 205ms, 205ms, 205ms;
    }
    .native-modal::backdrop {
      opacity: 0;
      transition: opacity 145ms ease, display 145ms allow-discrete, overlay 145ms allow-discrete;
    }
    .native-modal[open]::backdrop { animation: none; opacity: 1; }
    @starting-style {
      .native-modal[open] { opacity: 0; transform: translateY(var(--dialog-offset)) scale(.98); }
      .native-modal[open]::backdrop { opacity: 0; }
    }
  }
}
@media (min-width: 801px) and (prefers-reduced-motion: no-preference) {
  .shell[data-nav-motion="sidebar"] { transition: grid-template-columns 205ms var(--motion-ease); }
  .shell.rail-hidden { grid-template-columns: 0px minmax(0,1fr); }
  .rail { width: var(--rail-width); }
  .shell[data-nav-motion="sidebar"] .rail { transition: transform 205ms var(--motion-ease), visibility 0s; }
  .shell.rail-hidden .rail {
    display: flex; visibility: hidden; transform: translateX(-100%);
  }
  .shell.rail-hidden[data-nav-motion="sidebar"] .rail { transition-delay: 0s, 205ms; }
}
@media (max-width: 800px) and (prefers-reduced-motion: no-preference) {
  :root { --dialog-offset: 16px; }
  .shell[data-nav-motion="drawer"] .rail { transition: transform 245ms var(--motion-ease), visibility 0s linear 245ms; }
  .shell.drawer-open[data-nav-motion="drawer"] .rail { transition-delay: 0s; }
  .drawer-shade {
    display: block; position: fixed; inset: 0; z-index: 14; background: #0005; border: 0;
    opacity: 0; visibility: hidden; pointer-events: none;
  }
  .shell[data-nav-motion="drawer"] .drawer-shade { transition: opacity 180ms ease, visibility 0s linear 180ms; }
  .drawer-open .drawer-shade { opacity: 1; visibility: visible; pointer-events: auto; }
  .shell.drawer-open[data-nav-motion="drawer"] .drawer-shade { transition-delay: 0s; }
}
