:root {
  --page: #f8f6f1;
  --surface: #fffdfa;
  --stroke: #e9e1d4;
  --focus-ring: #9e722d;
  --ink: #241f18;
  --muted: #675f53;
  --gold-deep: #704d19;
  --line: var(--stroke);
}
body { background: var(--page); }
a:focus-visible, button:focus-visible, summary:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}
#workspace { grid-template-columns: 208px minmax(0,1fr); }
.sidebar .brand { padding: 18px 17px 13px; }
.sidebar nav { margin-top: 8px; }
.sidebar nav button { padding: 11px 12px; }
.topbar { min-height: 53px; padding-block: 7px; gap: 8px; }
.topbar .breadcrumb { font-weight: 650; }
.content { padding: 16px clamp(15px,2vw,27px) 22px; }
.page-heading { align-items: center; flex-direction: row; gap: 10px; margin-bottom: 11px; }
.page-heading h1 { font-size: clamp(1.32rem,2.35vw,1.9rem); margin-bottom: 3px; }
.page-heading p { font-size: .82rem; }
#stock-actions,#custom-actions,.page-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.action-menu { position: relative; font-size: .84rem; }
.action-menu > summary, .custom-filter-details > summary {
  cursor: pointer;
  color: var(--gold-deep);
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 6px;
  padding: 6px 9px;
  white-space: nowrap;
}
.action-primary > summary { background: #eed397; color: #302419; border-color: #c8a566; font-weight: 650; }
.action-menu[open] { z-index: 20; }
.action-menu-panel {
  position: absolute;
  z-index: 20;
  display: grid;
  gap: 4px;
  inset-block-start: calc(100% + 4px);
  inset-inline-end: 0;
  min-width: 155px;
  width: max-content;
  max-width: min(240px,calc(100vw - 32px));
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 7px;
  box-shadow: 0 6px 18px #30201018;
  padding: 6px;
}
.action-menu-panel button { text-align: start; }
.action-primary .action-menu-panel { inset-inline: 0 auto; }
.row-actions { display: flex; align-items: center; }
.row-action-trigger {
  display: inline-flex;
  gap: 7px;
  align-items: center;
  min-height: 32px;
  padding: 5px 9px;
  border-color: var(--line);
  color: var(--gold-deep);
  white-space: nowrap;
}
.row-actions:has(.row-action-panel:popover-open) .row-action-trigger {
  background: #f7e9cc;
  border-color: #c9a76b;
}
.row-action-trigger span { font-size: .72em; }
.row-action-panel:popover-open {
  position: fixed;
  inset: auto;
  display: grid;
  gap: 2px;
  width: max-content;
  min-width: min(166px,calc(100vw - 16px));
  max-width: calc(100vw - 16px);
  max-height: min(360px,calc(100dvh - 16px));
  overflow: auto;
  margin: 0;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  box-shadow: 0 6px 20px #30201025;
  visibility: hidden;
}
.row-action-panel[data-positioned] { visibility: visible; }
.row-action-panel button {
  min-height: 34px;
  padding: 6px 9px;
  border: 0;
  border-radius: 4px;
  text-align: start;
  white-space: normal;
}
.row-action-panel [data-stock-remove] { color: #87361f; }
.category-tabs { margin-bottom: 8px; }
.category-tabs button { padding-block: 6px; }
.filter-panel,.list-panel { background: var(--surface); }
.filter-panel { padding: 9px 12px; margin-bottom: 10px; }
#custom-views { padding: 0; border: 0; margin: 0 0 7px; gap: 5px; }
#custom-views button, .stock-facet-line button { padding: 5px 8px; }
#filters.compact-stock-form, #filters.custom-filter-form { gap: 6px; }
.custom-filter-details,.custom-filter-details[open] > summary { width: max-content; }
.custom-filter-details[open] { flex: 1 1 100%; }
.custom-filter-details > div { margin-top: 6px; }
#filters .field { gap: 3px; }
#filters .field input,#filters .field select,#stock-sort .field select { min-height: 32px; padding: 5px 8px; }
.filter-panel button:not(.link), .list-heading button, .page-actions button { padding-block: 6px; }
.stock-weight-picker [data-apply-weight] { margin-top: 7px; }
#active-filters { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 7px; }
.active-filter-tag { display: inline-flex; align-items: center; gap: 5px; padding: 3px 7px; background: #f1eadc; font-size: .75rem; max-width: 100%; }
.active-filter-tag > :nth-child(2) { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.active-filter-tag > :last-child { font-size: 1.05em; }
.list-heading { justify-content: flex-start; gap: 10px; padding: 7px 12px; min-height: 38px; }
.list-heading #count { margin-inline-start: auto; white-space: nowrap; }
#stock-sort .field { flex-direction: row; align-items: center; gap: 5px; min-width: 0; }
#stock-sort select { width: auto; max-width: 170px; }
.list-foot { padding-block: 8px; }
.table-scroll { overflow: auto; max-height: max(360px,calc(100svh - 230px)); }
.table-scroll table { border-collapse: separate; border-spacing: 0; }
.table-scroll th { position: sticky; top: 0; z-index: 2; background: #f2ece2; }
.table-scroll th,.table-scroll td { padding: 5px 9px; line-height: 1.3; }
.table-scroll td { font-size: .84rem; }
.table-scroll td[data-col=action]:has(.row-actions) { width: 1%; }
.table-scroll .actions { gap: 5px 8px; }
.table-scroll .link { padding-block: 2px; }
.table-scroll :is(th,td)[data-col=identity],
#workspace[data-page=goods] .table-scroll td:is([data-col=code],[data-col=certificate]) {
  position: sticky; left: 0; background: var(--surface); z-index: 1;
}
.table-scroll th[data-col=identity] { background: #f2ece2; z-index: 3; }
#workspace[data-page=goods] .table-scroll th:first-child { left: 0; z-index: 3; }
.table-scroll tr:hover td[data-col=identity] { background: #f8f2e8; }
.order-identity { display: flex; align-items: center; gap: 7px; min-width: 175px; }
.order-identity > div { min-width: 0; overflow-wrap: anywhere; }
.order-identity-number { display: flex; align-items: center; gap: 4px; color: var(--gold-deep); white-space: nowrap; }
.order-identity-number .link { font-size: .77rem; }
.order-buyer { font-weight: 650; margin-inline-end: 6px; }
.order-type { font-size: .74rem; color: var(--muted); }
.copy-number { border: 0; padding: 1px 3px; background: transparent; color: var(--gold-deep); }
.order-track { overflow-wrap: anywhere; }
.order-meta { font-size: .73rem; margin-inline-start: 0; }
.order-issue-summary { margin-top: 2px; }
.status[data-tone=waiting], [data-show-unclassified] { background: #f9ead0; border-color: #ebd4a9; color: #624211; }
[data-live-review][data-tone=waiting] { background: #f9ead0; border-color: #ebd4a9; color: #624211; }
.status[data-tone=done], .issue-stage[data-issue-stage=resolved] { background: #e8f1e9; border-color: #d4e4d6; color: #345139; }
.status[data-tone=progress] { background: #ebefef; border-color: #dce5e4; color: #3f5555; }
.status[data-tone=attention] { background: #f8e9e4; border-color: #efd6cb; color: #87361f; }
[data-tone=attention]:not(.status) { color: #87361f; }
[data-tone=waiting].live-metric { color: #694616; }
.mobile-label { display: none; }
dialog.record-drawer[open] {
  display: grid; grid-template-rows: auto minmax(0,1fr) auto;
  position: fixed; inset: 0 0 0 auto; margin: 0;
  height: 100dvh; max-height: none; width: min(100%,620px); max-width: 100%;
  border-radius: 0; box-shadow: -6px 0 22px #1a120d27;
}
dialog.record-drawer .dialog-body { max-height: none; min-height: 0; overflow-y: auto; padding: 13px 16px; }
dialog.record-drawer .detail-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
dialog.record-drawer::backdrop { background: #231b123c; }
dialog.quick-record-dialog { width: min(100vw - 24px,480px); }
.quick-record-form .field { min-width: 0; }
dialog > header > [data-language-switch] { margin-inline-start: auto; }
.record-tabs { position: sticky; top: -13px; display: flex; flex-wrap: wrap; gap: 5px; z-index: 1; padding: 8px 0; background: #fff; border-bottom: 1px solid var(--line); }
.record-tabs [aria-selected=true] { background: #f4e5cb; border-color: #ccb082; }
.record-lead { display: flex; flex-wrap: wrap; gap: 10px 25px; padding: 9px 11px; background: #f6efe4; border: 1px solid var(--line); border-radius: 6px; }
.record-lead > div { display: grid; gap: 4px; }
.record-lead > div > span:first-child { color: var(--muted); font-size: .76rem; }
.record-lead button { padding: 0; text-align: start; }

#live-dashboard { min-width: 0; grid-template-columns: minmax(0,1fr); gap: 9px; }
.live-context { display: flex; align-items: center; justify-content: space-between; gap: 6px; flex-wrap: wrap; }
.live-workarea { display: grid; grid-template-columns: minmax(0,1.08fr) minmax(0,1fr); align-items: start; gap: 11px; }
.live-panel,.live-scroll,.live-metric,.live-toolbar > * { min-width: 0; }
.live-toolbar .field { min-width: 0; max-width: 100%; }
.live-toolbar select { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.live-metrics { grid-template-columns: repeat(4,minmax(0,1fr)); gap: 7px; }
@media(max-width:650px) { .live-metrics { grid-template-columns:repeat(2,minmax(0,1fr)); } }
.live-panel-head { padding: 8px 10px; }
.live-panel .live-candidate { margin: 0 10px 8px; padding: 6px 8px; }
.live-scroll th,.live-scroll td { padding: 5px 6px; font-size: .76rem; }
.live-scroll table { width: 100%; }
.live-scroll th { white-space: normal; }
.live-feed .live-scroll { max-height: max(300px,calc(100svh - 290px)); overflow: auto; }
.live-feed .live-scroll th { position: sticky; top: 0; z-index: 1; }
.live-link-goods { display: block; margin-inline-start: auto; }

@media(max-width: 980px) {
  .live-workarea { grid-template-columns: minmax(0,1fr); }
}
@media(max-width: 790px) {
  #workspace { grid-template-columns: minmax(0,1fr); }
  .sidebar .brand { padding: 6px 12px; }
  .sidebar-logo { width: 110px; }
  .sidebar nav { margin: 0; padding-inline: 6px; gap: 1px; }
  .sidebar nav button { min-width: 0; padding: 7px 4px; margin: 0; text-align: center; font-size: .75rem; overflow-wrap: anywhere; }
  .topbar { min-height: 36px; padding: 4px 10px; }
  .topbar .breadcrumb { display: none; }
  .workspace-tools { margin-inline-start: auto; gap: 7px; }
  .workspace-tools .language-switch { margin: 0; }
  .workspace-tools .translation-status { max-width: 120px; }
  .content { padding: 9px; }
  .page-heading { margin-bottom: 8px; }
  .page-heading:has(#order-actions:not([hidden])), .page-heading:has(#stock-actions:not([hidden])) {
    flex-direction: row; align-items: center;
  }
  .page-heading h1 { font-size: 1.36rem; margin: 0; }
  .page-heading p { display: none; }
  .page-actions { justify-content: end; gap: 4px; }
  .page-actions button,.page-actions summary { font-size: .75rem; padding: 5px 7px; }
  .filter-panel { padding: 8px; margin-bottom: 7px; }
  #custom-views { gap: 4px; }
  .filter-panel button:not(.link),.filter-panel summary { font-size: .76rem; padding: 5px 6px; }
  #filters .field { min-width: 0; }
  #filters .order-main-filters .filter-actions { gap: 3px; }
  #filters.custom-filter-form .field:first-child { flex: 1 1 145px; }
  .list-heading { padding: 5px 8px; flex-wrap: wrap; gap: 4px 7px; }
  .list-heading #count { margin-inline-start: auto; }
  .list-panel { background: transparent; border: 0; box-shadow: none; min-width: 0; }
  .table-scroll { display: block; max-height: none; overflow: visible; }
  .table-scroll table,.table-scroll tbody { display: block; width: 100%; min-width: 0; }
  .table-scroll thead,.live-scroll thead {
    position: absolute; inline-size: 1px; block-size: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip-path: inset(50%); white-space: nowrap;
  }
  .table-scroll tr { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 5px 8px;
    border: 1px solid var(--line); border-radius: 8px; margin-block: 5px; padding: 8px; background: var(--surface); }
  .table-scroll td,.table-scroll td[data-col=identity],#workspace[data-page=goods] .table-scroll td:is([data-col=code],[data-col=certificate]) {
    display: block; min-width: 0; position: static; padding: 0; border: 0; background: transparent; overflow-wrap: anywhere; white-space: normal;
  }
  .table-scroll td:is(.empty,[data-col=action]) { grid-column: 1/-1; }
  .table-scroll .empty { padding: 12px 8px; }
  .mobile-label { display: block; color: var(--muted); font-size: .68rem; margin-bottom: 1px; font-weight: 450; }
  [data-page=orders] .table-scroll td[data-col=identity] { grid-column: 1/-1; order: -3; border-bottom: 1px solid var(--line); padding-bottom: 4px; }
  [data-page=orders] .table-scroll td[data-col=platform] { order: -2; }
  [data-page=orders] .table-scroll td[data-col=notes] { order: -1; }
  [data-page=orders] .table-scroll td[data-col=fulfillment] { grid-column: 1/-1; }
  [data-page=orders] .table-scroll td[data-col=select] { grid-column: 1/-1; }
  .table-scroll td[data-col=action] { border-top: 1px solid var(--line); padding-top: 3px; }
  .table-scroll td[data-col=action] .actions { justify-content: end; }
  .table-scroll td[data-col=action]:has(.row-actions) { width: auto; }
  .table-scroll td[data-col=action] .row-actions { justify-content: end; }
  .row-action-panel button { min-height: 40px; }
  [data-page=goods] .table-scroll tr { grid-template-columns: repeat(3,minmax(0,1fr)); }
  [data-page=goods] .table-scroll td:is([data-col=code],[data-col=certificate]) { grid-column: span 2; order: -6; }
  [data-page=goods] .table-scroll td[data-col=priceUsd] { order: -5; }
  [data-page=goods] .table-scroll td:is([data-col=totalWeight],[data-col=weight],[data-col=centerSpec]) { order: -4; }
  [data-page=goods] .table-scroll td:is([data-col=code],[data-col=certificate],[data-col=priceUsd]) { font-weight: 650; }
  [data-page=customs] .table-scroll td:is([data-col=identity],[data-col=customer]) { order: -4; }
  [data-page=customs] .table-scroll td:is([data-col=due],[data-col=next]) { order: -3; }
  [data-page=customs] .table-scroll td[data-col=style] { grid-column: 1/-1; }
  .live-toolbar { gap: 5px; }
  .live-toolbar .field { width: 100%; }
  .live-sync { margin-inline-start: 0; }
  .live-metric { padding: 6px 7px; }
  .live-metric span { font-size: .7rem; }
  .live-metric strong { font-size: 1.12rem; }
  .live-workarea { gap: 8px; }
  .live-scroll,.live-feed .live-scroll { overflow: visible; max-height: none; }
  .live-scroll table,.live-scroll tbody { display: block; min-width: 0; }
  .live-scroll tr { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 5px; padding: 6px; margin: 5px 8px;
    border: 1px solid var(--line); border-radius: 6px; }
  .live-scroll tr:first-child { margin-top: 0; }
  .live-scroll table td,.live-scroll table td:not(:first-child) { border: 0; padding: 0; text-align: start; overflow-wrap: anywhere; white-space: normal; }
  .live-scroll td:first-child { grid-column: 1/-1; font-weight: 650; }
  .live-feed .live-scroll td:nth-child(2) { grid-column: span 2; }
  .live-link-goods { margin-inline-start: 0; }
  .live-scroll td.empty { grid-column: 1/-1; }
}
@media(max-width: 460px) {
  .login-brand { padding: 11px 20px; }
  .login-brand-inner { max-width: 190px; }
  .login-brand p,.brand-rule { display: none; }
  .login-panel { padding: 24px 17px; align-items: start; }
  .login-card form { gap: 12px; }
  .auth-title { margin-bottom: 14px; }
  .record-drawer .detail-grid { gap: 6px 9px; }
}
