:root {
  color-scheme: light;
  --paper: #f6f7f2;
  --card: #fff;
  --ink: #192b23;
  --muted: #586c60;
  --line: #e0e7df;
  --forest: #142e27;
  --leaf: #216548;
  --leaf-dark: #174933;
  --lime: #deedba;
  --mono: 'Cascadia Mono', Consolas, monospace;
  font-family: 'Microsoft YaHei UI', 'PingFang SC', 'Noto Sans CJK SC', system-ui, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); color: var(--ink); font-size: 14px; }
button, input, select { font: inherit; }
button, a, select { -webkit-tap-highlight-color: transparent; }
a { color: var(--leaf); text-decoration: none; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .62; }
:focus-visible { outline: 3px solid #70ac87; outline-offset: 3px; }
[hidden] { display: none !important; }
h1, h2, p { margin: 0; }
.boot { display: grid; min-height: 100vh; place-items: center; color: var(--muted); }
.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 40px; padding: 0 15px; border: 1px solid #d7e1d7; border-radius: 9px; background: white;
  color: var(--ink); font-weight: 650; white-space: nowrap; transition: background .16s, border-color .16s;
}
.button:hover { background: #f1f6ef; border-color: #b7cabc; }
.button.primary { color: #fff; background: var(--leaf); border-color: var(--leaf); }
.button.primary:hover { background: var(--leaf-dark); }
.button.danger { color: white; background: #a8322b; border-color: #a8322b; }
.button.danger:hover { background: #872720; }
.button.small { min-height: 33px; padding: 0 10px; font-size: 13px; }
.text-button { border: 0; background: transparent; color: var(--leaf); padding: 6px 2px; font-weight: 700; }
.text-button:hover { text-decoration: underline; text-underline-offset: 4px; }
.warning-button { color: #a8322b; }
.app { min-height: 100vh; display: grid; grid-template-columns: 232px minmax(0, 1fr); }
.sidebar {
  height: 100dvh; position: sticky; top: 0; display: flex; flex-direction: column;
  background: var(--forest); color: #f0f6ee; padding: 28px 16px 17px;
}
.brand { display: flex; gap: 12px; align-items: center; padding: 0 8px; }
.brand-mark {
  width: 39px; height: 39px; border-radius: 13px; background: var(--lime); color: #263f2d;
  display: grid; place-items: center; font-weight: 900; font-size: 24px; flex: 0 0 auto;
}
.brand-name { font-weight: 730; font-size: 16px; letter-spacing: .04em; }
.navigation { margin-top: 33px; flex: 1; overflow: auto; scrollbar-width: thin; }
.group { margin-bottom: 21px; }
.group-label { color: #a6bdb0; font-size: 11px; font-weight: 650; letter-spacing: .16em; margin: 0 11px 8px; }
.nav-link {
  display: flex; gap: 11px; align-items: center; min-height: 42px; padding: 0 10px; margin-bottom: 3px;
  color: #dae7dd; border: 1px solid transparent; border-radius: 8px;
}
.nav-link:hover { background: #244238; }
.nav-link[aria-current="page"] { background: #355044; border-color: #567160; color: #f6ffdf; font-weight: 750; }
.nav-icon { font: 18px/1 system-ui, sans-serif; width: 20px; text-align: center; color: #b8d1be; }
.nav-link[aria-current="page"] .nav-icon { color: var(--lime); }
.side-company { border-top: 1px solid #3c594e; color: #c0d0c4; font-size: 11px; padding: 14px 9px 0; line-height: 1.8; overflow-wrap: anywhere; }
.workspace { min-width: 0; }
.topbar {
  height: 68px; padding: 0 32px; border-bottom: 1px solid var(--line); background: #fbfcf8;
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 15px; }
.today { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 13px; }
.topbar-title { font-size: 13px; color: var(--muted); font-weight: 700; }
.menu-toggle { display: none; }
.account-menu { position: relative; }
.account-menu summary { display: flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 650; list-style: none; }
.account-menu summary::-webkit-details-marker { display: none; }
.avatar { width: 30px; height: 30px; line-height: 30px; border-radius: 50%; text-align: center; background: #e3eddc; color: var(--leaf-dark); }
.popover {
  position: absolute; top: calc(100% + 10px); right: 0; z-index: 2; background: white; min-width: 145px; padding: 6px;
  border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 34px #142e2720;
}
.popover button { width: 100%; text-align: left; border: 0; background: white; border-radius: 6px; padding: 9px; color: var(--ink); }
.popover button:hover { background: var(--paper); }
.main { max-width: 1600px; margin: 0 auto; padding: 33px 32px 50px; }
.heading { display: flex; justify-content: space-between; align-items: center; gap: 18px; margin-bottom: 24px; }
.heading h1 { font-size: clamp(25px, 3vw, 34px); letter-spacing: -.045em; line-height: 1.2; }
.subheading { color: var(--muted); margin-top: 9px; font-size: 13px; line-height: 1.65; }
.actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.stats { display: grid; grid-template-columns: 1.12fr repeat(2, 1fr); gap: 14px; margin-bottom: 20px; }
.inventory-stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat { padding: 19px 20px; min-width: 0; background: white; border: 1px solid var(--line); border-radius: 12px; }
.stat.feature { background: #244c3d; border-color: #244c3d; color: #f0f7e9; }
.stat-label { color: var(--muted); font-size: 12px; font-weight: 650; }
.feature .stat-label { color: #e0ecdc; }
.stat-value { font-size: clamp(17px, 2.3vw, 29px); font-weight: 700; margin: 8px 0 5px; letter-spacing: -.06em; overflow-wrap: anywhere; }
.stat-caption { font-size: 12px; color: var(--muted); }
.feature .stat-caption { color: #d0e3cf; }
.order-summary h2 { display: flex; align-items: baseline; flex-wrap: wrap; gap: 8px; margin: 0 0 9px; font-size: 14px; }
.order-summary h2 span { color: var(--muted); font-size: 12px; font-weight: 400; }
.bill-controls { display: flex; gap: 9px; align-items: end; flex-wrap: wrap; }
.bill-controls .error { flex-basis: 100%; }
.bill-preview { border: 1px solid #dfd8f2; border-radius: 9px; overflow: hidden; }
.bill-preview h3 { margin: 0; padding: 13px 15px; text-align: center; overflow-wrap: anywhere; }
.bill-preview th { background: #7866d4; color: white; position: sticky; top: 0; }
.bill-preview .bill-total { background: #f0ebfc; font-weight: 750; color: #302660; }
.bill-preview .table-wrap { max-height: 45dvh; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.toolbar { padding: 14px 16px; display: flex; align-items: end; flex-wrap: wrap; gap: 9px; border-bottom: 1px solid var(--line); }
.toolbar label { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.toolbar label span { font-size: 11px; color: var(--muted); font-weight: 650; }
.toolbar .search { flex: 0 1 248px; }
.field { display: flex; flex-direction: column; gap: 7px; min-width: 0; color: var(--ink); font-size: 13px; font-weight: 650; }
input, select {
  height: 40px; min-width: 0; padding: 0 10px; color: var(--ink); background: #fcfdfa;
  border: 1px solid #d8e2d8; border-radius: 8px; width: 100%;
}
input::placeholder { color: #687c6e; font-weight: 400; }
input[readonly] { background: #eef3ee; color: #53665a; }
.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; white-space: nowrap; }
th, td { padding: 13px 15px; border-bottom: 1px solid #e9eee8; }
th { color: #4d6657; font-weight: 750; font-size: 12px; background: #f8faf6; }
td { height: 52px; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafcf8; }
td.wrap { white-space: normal; overflow-wrap: anywhere; min-width: 135px; max-width: 300px; }
.num { font-variant-numeric: tabular-nums; text-align: right; }
.id { font-family: var(--mono); color: #516c5c; }
.strong { font-weight: 750; }
.muted { color: var(--muted); }
.pill { display: inline-block; font-size: 12px; border-radius: 20px; background: #eaf2e7; color: #285e43; padding: 4px 9px; }
.pill.inactive { background: #f0efea; color: #64594e; }
.price-grid { max-height: clamp(250px, 62dvh, 690px); }
.price-grid table { border-collapse: separate; border-spacing: 0; }
.price-grid th, .price-grid td { border-right: 1px solid #e9eee8; }
.price-grid tr > :last-child { border-right: 0; }
.price-grid thead th {
  position: sticky; top: 0; z-index: 2; min-width: 120px; max-width: 205px;
  padding: 12px 14px; text-align: center; white-space: normal; overflow-wrap: anywhere;
}
.price-grid tr > :first-child {
  position: sticky; left: 0; z-index: 1; min-width: 132px; max-width: 195px;
  padding-left: 14px; text-align: left; white-space: normal; overflow-wrap: anywhere;
}
.price-grid thead tr > :first-child { z-index: 3; background: #edf3eb; }
.price-grid thead th span { font-weight: 500; }
.price-grid thead tr > :first-child span { display: block; margin-top: 3px; }
.price-grid tbody th { background: #f8faf6; color: var(--ink); }
.price-grid tbody tr:nth-child(even) th { background: #f3f6f1; }
.price-grid tbody td { padding: 0; text-align: center; }
.price-grid tbody tr:last-child th { border-bottom: 0; }
.price-grid td.price-locked { color: var(--muted); font-variant-numeric: tabular-nums; }
.price-inactive { display: inline-block; padding: 1px 5px; border-radius: 4px; background: #edece6; color: #64594e; font-size: 11px; }
.price-cell {
  width: 100%; min-height: 50px; padding: 8px 12px; border: 0; background: transparent;
  color: var(--leaf-dark); font-weight: 700; font-variant-numeric: tabular-nums;
}
.price-cell.unpriced { color: var(--muted); font-size: 12px; font-weight: 500; }
.price-cell.historical { color: var(--muted); }
.price-cell:hover { background: #e9f3e8; }
.price-cell:focus-visible { outline-offset: -3px; background: #e9f3e8; }
.void-row { background: #fcfaf6; color: #776a62; }
.page-footer { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 13px 16px; border-top: 1px solid var(--line); }
.empty { padding: 48px 18px; text-align: center; }
.empty h2 { font-size: 15px; margin-bottom: 6px; }
.empty p { color: var(--muted); line-height: 1.7; }
.empty .button { margin-top: 14px; }
.table-error { padding: 22px; }
.error { background: #fff0ec; border: 1px solid #f0ccc3; padding: 9px 11px; color: #8f291e; border-radius: 8px; line-height: 1.65; }
.similar-note { background: #fff6df; border: 1px solid #f0deb0; padding: 9px 11px; color: #644507; border-radius: 8px; line-height: 1.65; }
.similar-orders .table-wrap { max-height: min(45dvh, 390px); border: 1px solid var(--line); border-radius: 8px; }
.similar-orders th { position: sticky; top: 0; }
dialog {
  color: var(--ink); border: 1px solid #cbd8ce; border-radius: 15px; padding: 0; width: min(540px, calc(100% - 26px));
  max-height: calc(100dvh - 30px); box-shadow: 0 24px 90px #0c261f55; overscroll-behavior: contain;
}
dialog.wide { width: min(920px, calc(100% - 26px)); }
dialog.price-dialog { width: min(690px, calc(100% - 26px)); }
.price-history { border: 1px solid var(--line); border-radius: 8px; }
.price-history summary { cursor: pointer; padding: 11px 13px; font-weight: 700; color: var(--leaf-dark); }
.price-history .table-wrap { max-height: min(34dvh, 270px); border-top: 1px solid var(--line); }
.price-history th { position: sticky; top: 0; }
.price-history th, .price-history td { padding: 9px 11px; }
.price-history td { height: 39px; }
.price-history-message { padding: 0 13px 11px; }
.price-history-pages { padding: 8px 11px; border-top: 1px solid var(--line); display: flex; align-items: center; gap: 8px; }
dialog::backdrop { background: #0b211bb0; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.dialog-head h2 { font-size: 19px; }
.close { width: 36px; height: 36px; border-radius: 8px; border: 0; background: #edf3ec; color: var(--ink); font-size: 22px; }
.close:hover { background: #dceadd; }
.dialog-body { padding: 19px 20px; display: grid; gap: 13px; }
.dialog-foot { display: flex; justify-content: flex-end; align-items: center; flex-wrap: wrap; gap: 8px; padding: 13px 20px; border-top: 1px solid var(--line); background: #fafbf8; }
.columns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.order-lines { min-width: 670px; }
.line-grid { display: grid; grid-template-columns: 1.2fr .65fr .67fr .68fr 1fr 36px; gap: 7px; align-items: center; padding: 5px 0; }
.line-grid span { min-width: 0; }
.line-labels { color: var(--muted); font-weight: 700; font-size: 12px; }
.line-caption { display: none; }
.line-total { font-size: 13px; overflow-wrap: anywhere; }
.line-remove { width: 36px; height: 36px; background: white; border: 1px solid var(--line); border-radius: 8px; color: var(--muted); font-size: 17px; }
.line-remove:hover { color: #a8322b; border-color: #d5a49d; }
.line-remove:disabled { opacity: .4; cursor: default; }
.order-footer { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 9px; }
.detail-meta { display: flex; gap: 11px 24px; flex-wrap: wrap; color: var(--muted); font-size: 13px; }
.detail-meta b { color: var(--ink); }
.detail-table { border: 1px solid var(--line); border-radius: 8px; }
.delivery-preview { width: 100%; height: auto; display: block; border: 1px solid #d7dfd6; }
.login { min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); }
.login-cover {
  background: radial-gradient(ellipse at 26% 80%, #426b46 0, transparent 58%),
    repeating-linear-gradient(148deg, transparent 0 69px, #a9cc901a 70px 71px), #183729;
  color: #f2f8e8; display: flex; flex-direction: column; justify-content: space-between; padding: clamp(30px, 6vw, 90px);
}
.cover-text { font-size: clamp(29px, 4.2vw, 56px); font-weight: 650; max-width: 12em; line-height: 1.38; letter-spacing: -.04em; }
.login-side { display: grid; place-items: center; padding: 35px 24px; }
.login-form { width: min(355px, 100%); display: grid; gap: 17px; }
.login-form h1 { font-size: 29px; letter-spacing: -.04em; }
.login-form .button { min-height: 44px; }
#toast {
  display: none; position: fixed; bottom: 23px; right: 23px; z-index: 10; max-width: calc(100vw - 46px);
  padding: 11px 17px; border-radius: 9px; background: var(--forest); color: #fff; box-shadow: 0 8px 22px #142e2738;
}
#toast.visible { display: block; }
.mobile-shade { display: none; }
@media (max-width: 960px) and (min-width: 761px) {
  .app { grid-template-columns: 193px minmax(0, 1fr); }
  .main, .topbar { padding-left: 19px; padding-right: 19px; }
}
@media (max-width: 760px) {
  .app { display: block; }
  .sidebar {
    position: fixed; left: 0; bottom: 0; width: 232px; z-index: 4; visibility: hidden; transform: translateX(-102%); transition: transform .2s ease;
  }
  .sidebar-open .sidebar { visibility: visible; transform: translateX(0); }
  .sidebar-open .mobile-shade { display: block; position: fixed; inset: 0; z-index: 3; background: #122d2566; border: 0; }
  .menu-toggle { display: inline-flex; }
  .topbar { height: 58px; padding: 0 14px; }
  .topbar-left, .topbar-right { gap: 8px; }
  .today { display: none; }
  .main { padding: 22px 13px 30px; }
  .heading { align-items: start; flex-direction: column; margin-bottom: 15px; gap: 10px; }
  .stats { gap: 7px; margin-bottom: 13px; }
  .inventory-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat { padding: 10px 8px; }
  .stat-value { font-size: 16px; }
  th, td { padding: 9px 11px; }
  .toolbar { padding: 10px; }
  .toolbar .search { flex: 1 1 165px; }
  .page-footer { padding: 9px 10px; }
  .order-lines { min-width: 0; }
  .line-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 36px; margin-bottom: 10px; padding: 8px; border: 1px solid var(--line); border-radius: 8px; }
  .line-labels { display: none; }
  .line-caption { display: block; margin: 0 0 4px; color: var(--muted); font-size: 11px; }
  .line-product-field { grid-column: 1 / 3; }
  .line-remove { grid-area: 1 / 3; align-self: end; }
  .line-amount-field { grid-column: 1; }
  .line-note-field { grid-column: 2 / 4; }
  .login { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .login-cover { padding: 23px; gap: 26px; }
  .cover-text { font-size: 23px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}
