:root {
  --bg: #eef3f2;
  --panel: #ffffff;
  --panel-soft: #f7faf9;
  --text: #1f2d33;
  --muted: #697b80;
  --border: #d8e2df;
  --border-strong: #bfd0cb;
  --primary: #0d6f6d;
  --primary-soft: #e2f1ef;
  --info: #2563eb;
  --success: #1f8f5f;
  --warning: #c5871a;
  --danger: #d24d45;
  --queued: #7d8b90;
  --shadow: 0 12px 32px rgba(20, 45, 54, 0.08);
  --sidebar-width: 220px;
  --topbar-height: 64px;
  --radius: 18px;
  --radius-sm: 12px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  height: 100%;
  overflow: hidden;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at top left, rgba(13, 111, 109, 0.08), transparent 28%),
    linear-gradient(180deg, #edf3f2 0%, #f5f8f7 100%);
  color: var(--text);
  font-family: "Aptos", "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

body.drawer-open {
  overflow: hidden;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

input,
select,
textarea {
  min-height: 40px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  color: var(--text);
  padding: 0 12px;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(13, 111, 109, 0.08);
}

textarea {
  min-height: 120px;
  padding: 12px;
  resize: vertical;
  line-height: 1.55;
}

.mono,
.code-preview {
  font-family: "Cascadia Code", "SFMono-Regular", "Consolas", monospace;
}

.eyebrow,
.sidebar-link small,
.sidebar-label,
.metric-label,
.panel-head p,
.table-subline,
.pager-summary,
.loading-block,
.empty-inline,
.empty-state p {
  color: var(--muted);
}

.app-shell {
  display: flex;
  height: 100vh;
}

.sidebar {
  width: var(--sidebar-width);
  flex: 0 0 var(--sidebar-width);
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 18px 16px;
  background: rgba(255, 255, 255, 0.78);
  border-right: 1px solid var(--border);
  backdrop-filter: blur(16px);
}

.brand-block,
.sidebar-footer,
.topbar,
.panel,
.metric-card,
.toast,
.app-drawer {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.8);
  box-shadow: var(--shadow);
}

.brand-block,
.sidebar-footer,
.topbar,
.panel,
.metric-card,
.app-drawer {
  border-radius: var(--radius);
}

.brand-block {
  padding: 18px;
}

.brand-kicker,
.eyebrow {
  display: block;
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.brand-block h1,
.topbar h2 {
  margin: 8px 0 6px;
  font-family: "Iowan Old Style", "Palatino Linotype", "Songti SC", serif;
}

.brand-block h1 {
  font-size: 28px;
  line-height: 1.05;
}

.brand-block p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.sidebar-nav {
  display: grid;
  gap: 6px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  padding: 12px 14px;
  border-radius: 14px;
  color: var(--muted);
  transition: background 0.16s ease, transform 0.16s ease;
}

.sidebar-link span {
  color: var(--text);
  font-weight: 700;
}

.sidebar-link:hover,
.sidebar-link.is-active {
  background: linear-gradient(135deg, rgba(13, 111, 109, 0.16), rgba(255, 255, 255, 0.78));
  color: var(--primary);
  transform: translateX(2px);
}

.sidebar-footer {
  margin-top: auto;
  padding: 14px;
  display: grid;
  gap: 12px;
}

.sidebar-footer strong {
  display: block;
  margin-top: 4px;
  font-size: 14px;
  line-height: 1.45;
}

.app-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px 18px;
  overflow: hidden;
}

.topbar {
  min-height: var(--topbar-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 16px;
}

.topbar h2 {
  font-size: 26px;
  line-height: 1.1;
}

.topbar-actions,
.panel-actions,
.pager-controls,
.drawer-actions,
.action-grid {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.topbar-actions {
  justify-content: flex-end;
  flex-wrap: nowrap;
  min-width: 0;
  overflow: hidden;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 14px;
  border: 1px solid var(--border);
  padding: 8px 10px;
  background: #fff;
  font-size: 12px;
  min-width: 0;
  white-space: nowrap;
}

.status-pill span:first-child,
.status-pill small,
.status-chip .chip-label,
.status-chip .chip-meta {
  color: var(--muted);
}

.status-pill strong,
.status-chip .chip-value {
  font-size: 13px;
  line-height: 1.3;
  white-space: nowrap;
}

.status-pill small {
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
}

.status-pill-compact {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.status-pill-detail {
  min-width: 0;
}

.status-chip {
  flex: 0 1 auto;
}

.status-chip .chip-label,
.status-chip .chip-value,
.status-chip .chip-meta,
.status-chip .status-badge {
  white-space: nowrap;
}

.topbar-actions .ghost-button,
.topbar-actions .action-button {
  flex: 0 0 auto;
  white-space: nowrap;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 56px;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  background: #eef2f3;
  color: var(--queued);
}

.status-badge[data-state="success"] {
  background: rgba(31, 143, 95, 0.14);
  color: var(--success);
}

.status-badge[data-state="running"],
.status-badge[data-state="info"] {
  background: rgba(37, 99, 235, 0.12);
  color: var(--info);
}

.status-badge[data-state="partial_success"],
.status-badge[data-state="warning"] {
  background: rgba(197, 135, 26, 0.15);
  color: var(--warning);
}

.status-badge[data-state="failed"],
.status-badge[data-state="danger"] {
  background: rgba(210, 77, 69, 0.13);
  color: var(--danger);
}

.status-badge[data-state="queued"] {
  background: rgba(125, 139, 144, 0.14);
  color: var(--queued);
}

.action-button,
.ghost-button,
.table-link,
.drawer-close {
  border: 1px solid transparent;
  border-radius: 12px;
  min-height: 38px;
  padding: 0 14px;
  background: transparent;
  color: var(--text);
}

.action-button {
  background: var(--primary);
  color: #fff;
}

.action-button:disabled,
.ghost-button:disabled {
  cursor: default;
  opacity: 0.55;
}

.ghost-button {
  border-color: var(--border);
  background: #fff;
}

.table-link {
  min-height: auto;
  padding: 0;
  color: var(--primary);
}

.drawer-close {
  min-width: 40px;
  font-size: 24px;
}

.toast-root {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 40;
  display: grid;
  gap: 10px;
  width: min(360px, calc(100vw - 32px));
}

.toast {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 10px;
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 13px;
  border: 1px solid rgba(125, 139, 144, 0.2);
  background: rgba(255, 255, 255, 0.96);
}

.toast-success {
  border-color: rgba(31, 143, 95, 0.2);
}

.toast-info {
  border-color: rgba(37, 99, 235, 0.18);
}

.toast-warning {
  border-color: rgba(197, 135, 26, 0.2);
}

.toast-danger,
.toast-error {
  border-color: rgba(210, 77, 69, 0.2);
}

.toast-copy {
  min-width: 0;
  line-height: 1.45;
}

.toast-close {
  min-width: 28px;
  min-height: 28px;
  border: 0;
  border-radius: 999px;
  background: rgba(17, 27, 34, 0.06);
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  padding: 0;
}

.page-frame {
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.workspace-layout,
.screen-layout,
.detail-layout {
  height: 100%;
  min-height: 0;
}

.workspace-layout {
  display: grid;
  grid-template-rows: auto minmax(180px, 220px) minmax(0, 1fr);
  gap: 14px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.metric-card {
  padding: 14px 16px;
  display: grid;
  gap: 6px;
}

.metric-card strong {
  font-size: 22px;
  line-height: 1;
}

.metric-card.accent {
  background: linear-gradient(135deg, rgba(13, 111, 109, 0.9), rgba(23, 131, 127, 0.84));
  color: #fff;
}

.metric-card.accent small,
.metric-card.accent .metric-label {
  color: rgba(255, 255, 255, 0.78);
}

.workspace-lists,
.detail-columns,
.drawer-split {
  display: grid;
  gap: 14px;
  min-height: 0;
}

.workspace-lists {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.workspace-progress-panel {
  min-height: 0;
  max-height: 220px;
  overflow: auto;
}

.workspace-progress-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  min-height: 0;
}

.panel {
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 16px;
}

.panel-head,
.drawer-section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.workspace-progress-strip {
  display: flex;
  align-items: stretch;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.panel-head h3,
.drawer-section h3,
.detail-card h4 {
  margin: 0;
  font-size: 16px;
}

.panel-head p,
.drawer-section-head p {
  margin: 4px 0 0;
  font-size: 13px;
}

.progress-panel,
.list-panel,
.detail-panel {
  height: 100%;
}

.progress-stack {
  display: grid;
  gap: 10px;
}

.progress-row,
.progress-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.progress-track {
  height: 10px;
  border-radius: 999px;
  background: #e9f0ef;
  overflow: hidden;
}

.progress-track.secondary {
  background: #edf0f9;
}

.progress-bar {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--primary), #3cb8b1);
}

.summary-grid,
.detail-list,
.run-current-grid {
  display: grid;
  gap: 12px;
}

.summary-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 12px;
}

.summary-grid.compact {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.summary-grid div,
.detail-list div,
.run-current-grid div,
.drawer-note div {
  display: grid;
  gap: 4px;
}

.summary-grid dt,
.detail-list dt,
.run-current-grid span,
.drawer-note span {
  font-size: 12px;
  color: var(--muted);
}

.summary-grid dd,
.detail-list dd,
.drawer-note strong {
  margin: 0;
  font-size: 14px;
  line-height: 1.45;
}

.error-inline,
.inline-message {
  margin-top: 12px;
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 13px;
  background: #f7f9f8;
}

.inline-message.success {
  background: rgba(31, 143, 95, 0.1);
}

.inline-message.warning,
.error-inline {
  background: rgba(197, 135, 26, 0.12);
}

.workspace-progress-error {
  margin-top: 0;
}

.screen-layout {
  display: grid;
  gap: 14px;
}

.products-layout {
  grid-template-columns: minmax(0, 1fr);
}

.products-panel {
  min-height: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.products-panel--flat {
  padding: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
}

.products-board {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--border);
  border-radius: 18px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.runs-layout {
  grid-template-rows: auto minmax(0, 1fr);
}

.logs-layout,
.detail-layout {
  grid-template-rows: minmax(0, 1fr);
}

.detail-layout {
  grid-template-rows: auto minmax(0, 1fr);
}

.detail-columns,
.drawer-split {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.tree-scroll,
.table-scroll,
.list-scroll,
.drawer-body {
  min-height: 0;
  overflow: auto;
}

.tree-scroll,
.table-scroll,
.list-scroll {
  flex: 1;
}

.product-table-scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
}

.table-scroll.short {
  max-height: 320px;
}

.loading-block,
.empty-state {
  display: grid;
  place-items: center;
  min-height: 140px;
  text-align: center;
}

.empty-state h3 {
  margin: 0 0 8px;
  font-size: 18px;
}

.tree-level {
  list-style: none;
  padding: 0;
  margin: 0;
  min-width: max-content;
}

.tree-node {
  margin-bottom: 2px;
}

.tree-children {
  margin-left: 14px;
  padding-left: 10px;
  border-left: 1px solid rgba(28, 126, 145, 0.12);
}

.tree-node-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 6px;
  align-items: center;
  padding-left: calc(var(--depth, 0) * 14px);
}

.tree-button,
.tree-toggle,
.tree-meta-button {
  border: 1px solid transparent;
  background: transparent;
}

.tree-toggle {
  width: 28px;
  min-width: 28px;
  min-height: 28px;
  border-radius: 10px;
  color: var(--muted);
}

.tree-toggle.is-empty {
  visibility: hidden;
}

.tree-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  border-radius: 12px;
  text-align: left;
  white-space: nowrap;
}

.tree-text-group {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.tree-text {
  display: block;
  white-space: nowrap;
  overflow: visible;
  text-overflow: clip;
}

.tree-path {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tree-node-row.is-active .tree-button,
.tree-toggle:hover,
.tree-button:hover {
  background: var(--primary-soft);
}

.tree-meta-button {
  color: var(--muted);
  min-width: 34px;
  min-height: 34px;
  border-radius: 10px;
}

.tree-count {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  font-size: 12px;
  white-space: nowrap;
}

.tree-count strong {
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
}

.mini-toolbar {
  display: grid;
  grid-template-columns: auto minmax(320px, 1.1fr) minmax(420px, 1.6fr) auto auto auto auto auto;
  gap: 10px;
  margin-bottom: 0;
}

.products-toolbar {
  align-items: center;
  padding: 8px 12px;
  border: 0;
  border-radius: 0;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: none;
}

.products-toolbar input,
.products-toolbar select,
.products-toolbar .ghost-button,
.products-toolbar .filter-pill,
.products-toolbar .toolbar-path,
.products-toolbar .toolbar-stat {
  min-height: 38px;
}

.toolbar-path {
  min-height: 40px;
  display: flex;
  align-items: center;
  min-width: 0;
  max-width: 280px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel-soft);
  color: var(--text);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.toolbar-stat {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  min-width: 0;
  padding: 0 12px;
  border-radius: 12px;
  background: rgba(13, 111, 109, 0.08);
  color: var(--text);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.products-toolbar [name="q"] {
  width: 100%;
}

.toolbar-menu {
  position: relative;
}

.toolbar-menu-trigger {
  min-width: 94px;
}

.toolbar-menu-popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 6;
  display: grid;
  min-width: 148px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: var(--shadow);
}

.toolbar-menu-item {
  display: flex;
  align-items: center;
  min-height: 36px;
  padding: 0 10px;
  border-radius: 10px;
  color: var(--text);
  text-decoration: none;
}

.toolbar-menu-item:hover {
  background: var(--panel-soft);
}

.filter-pill {
  position: relative;
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  cursor: pointer;
}

.filter-pill input {
  position: absolute;
  inset: 0;
  opacity: 0;
  margin: 0;
}

.filter-pill span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
}

.filter-pill span::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: currentColor;
  opacity: 0.35;
}

.filter-pill input:checked + span {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.filter-pill input:checked + span::before {
  opacity: 1;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 13px;
}

.product-table-wrap {
  min-width: 0;
  overflow: auto;
}

.product-table {
  width: 100%;
  min-width: 1510px;
}

.product-table col.col-code {
  width: 130px;
}

.product-table col.col-name {
  width: 360px;
}

.product-table col.col-category {
  width: 260px;
}

.product-table col.col-unit {
  width: 70px;
}

.product-table col.col-qty {
  width: 80px;
}

.product-table col.col-price {
  width: 110px;
}

.product-table col.col-min-price {
  width: 110px;
}

.product-table col.col-cost {
  width: 110px;
}

.product-table col.col-margin {
  width: 90px;
}

.product-table col.col-time {
  width: 170px;
}

.product-table col.col-action {
  width: 80px;
}

.data-table th,
.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid #edf2f1;
  vertical-align: middle;
  line-height: 1.45;
}

.product-table th,
.product-table td {
  white-space: nowrap;
  padding-left: 12px;
  padding-right: 12px;
  vertical-align: middle;
  box-sizing: border-box;
  overflow: hidden;
}

.product-table .cell-text,
.product-table .cell-main,
.product-table .cell-sub,
.product-table .category-path,
.product-table .truncate-cell,
.product-table .table-link {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.product-table th.cell-code,
.product-table td.cell-code,
.product-table th.cell-name,
.product-table td.cell-name,
.product-table th.cell-category,
.product-table td.cell-category {
  text-align: left;
}

.product-table th.cell-unit,
.product-table td.cell-unit,
.product-table th.cell-qty,
.product-table td.cell-qty,
.product-table th.cell-time,
.product-table td.cell-time,
.product-table th.cell-action,
.product-table td.cell-action {
  text-align: center;
}

.product-table th.cell-price,
.product-table td.cell-price,
.product-table th.cell-min-price,
.product-table td.cell-min-price,
.product-table th.cell-cost,
.product-table td.cell-cost,
.product-table th.cell-margin,
.product-table td.cell-margin {
  text-align: right;
}

.data-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--panel-soft);
  text-align: left;
  font-size: 12px;
  color: var(--muted);
}

.product-table tbody tr:nth-child(odd) {
  background: #ffffff;
}

.product-table tbody tr:nth-child(even) {
  background: #f3faf9;
}

.product-table tbody tr:hover {
  background: #e7f5f2;
}

.data-table.dense th,
.data-table.dense td {
  padding-top: 8px;
  padding-bottom: 8px;
}

.col-wide {
  width: 26%;
}

.numeric {
  text-align: right;
}

.numeric-center {
  text-align: center;
}

.action-cell {
  text-align: center;
}

.truncate-cell {
  max-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.table-subline {
  margin-top: 4px;
  font-size: 12px;
}

.cell-text {
  min-width: 0;
}

.cell-main,
.cell-sub {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cell-main {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  white-space: nowrap;
  margin-left: 0;
  padding-left: 0;
}

.cell-sub {
  margin-top: 4px;
  margin-left: 0;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  padding-left: 0;
}

.data-state-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  flex: 0 0 auto;
}

.data-state-badge.is-updated {
  background: #dff7ec;
  color: #047857;
}

.data-state-badge.is-old {
  background: #eef2f3;
  color: #7a8b91;
}

.product-row.is-updated td:first-child {
  box-shadow: inset 3px 0 0 #10b981;
}

.product-table .cell-time.is-updated {
  font-weight: 700;
  color: #0b766e;
}

.loading-block.compact {
  min-height: 84px;
}

.row-error td {
  background: rgba(210, 77, 69, 0.05);
}

.pagination-bar {
  margin-top: 0;
  padding: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.pagination-btn.is-current {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  font-weight: 700;
  pointer-events: none;
}

.pagination-btn[disabled],
.pagination-btn.is-disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.runs-summary-panel {
  padding: 10px 14px;
}

.runs-summary-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.summary-chip {
  display: grid;
  gap: 2px;
  min-width: 92px;
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--panel-soft);
}

.summary-chip span {
  font-size: 12px;
  color: var(--muted);
}

.summary-chip strong {
  font-size: 13px;
  line-height: 1.3;
}

.summary-chip-wide {
  min-width: 240px;
  flex: 1 1 240px;
}

.compact-button {
  min-height: 34px;
  padding: 0 12px;
}

.category-panel-backdrop {
  position: fixed;
  inset: 0;
  z-index: 14;
  background: rgba(17, 27, 34, 0.16);
}

.category-panel {
  position: fixed;
  top: 12px;
  left: 12px;
  bottom: 12px;
  width: min(520px, 38vw);
  min-width: 440px;
  max-width: calc(100vw - 24px);
  z-index: 15;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.8);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.category-panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.category-panel-head h3 {
  margin: 0;
  font-size: 16px;
}

.category-panel-head p {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.category-panel-tools {
  display: grid;
  gap: 10px;
}

.drawer-note.single {
  grid-template-columns: 1fr;
}

.panel-mini {
  color: var(--muted);
  font-size: 12px;
}

.tree-node-row.is-root .tree-button {
  color: var(--muted);
}

.app-drawer {
  position: fixed;
  top: 16px;
  right: 16px;
  bottom: 16px;
  width: min(78vw, 1480px);
  min-width: 960px;
  z-index: 30;
  display: flex;
  flex-direction: column;
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(17, 27, 34, 0.36);
}

.drawer-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}

.drawer-body {
  padding: 18px;
}

.drawer-loading {
  display: grid;
  place-items: center;
  min-height: 140px;
}

.drawer-section {
  display: grid;
  gap: 16px;
}

.drawer-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.detail-card {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  background: #fff;
}

.detail-card h4 {
  margin-bottom: 12px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.form-grid label {
  display: grid;
  gap: 6px;
}

.form-grid .span-2 {
  grid-column: span 2;
}

.drawer-note {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 12px;
  border-radius: 14px;
  background: var(--panel-soft);
}

.product-detail {
  gap: 14px;
}

.product-detail-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: start;
  margin-bottom: 0;
}

.product-title-block {
  min-width: 0;
}

.product-title {
  margin: 0;
  font-size: 26px;
  line-height: 1.18;
  letter-spacing: -0.01em;
}

.product-subtitle {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.product-header-badges {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.product-badge {
  min-width: 0;
  padding-inline: 12px;
}

.product-badge-accent {
  background: rgba(13, 111, 109, 0.13);
  color: var(--primary);
}

.product-summary-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, auto)) minmax(180px, 1fr);
  gap: 0;
  align-items: stretch;
  padding: 8px 10px;
  border: 1px solid rgba(191, 208, 203, 0.9);
  border-radius: 16px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(245, 249, 248, 0.95)),
    radial-gradient(circle at top left, rgba(13, 111, 109, 0.06), transparent 42%);
}

.summary-metric {
  display: grid;
  gap: 4px;
  min-width: 0;
  padding: 4px 14px;
  border-right: 1px solid rgba(216, 226, 223, 0.9);
}

.summary-metric:last-child {
  border-right: 0;
}

.summary-metric-wide {
  justify-self: stretch;
}

.metric-value {
  font-size: 15px;
  line-height: 1.2;
}

.product-detail-body {
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(0, 1.8fr);
  gap: 16px;
  min-height: 0;
}

.detail-panel {
  min-width: 0;
  padding: 15px 16px;
  border-radius: 18px;
  border: 1px solid rgba(191, 208, 203, 0.9);
  background: rgba(255, 255, 255, 0.84);
}

.detail-panel-main {
  display: grid;
  gap: 14px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(247, 250, 249, 0.94)),
    radial-gradient(circle at top right, rgba(13, 111, 109, 0.06), transparent 38%);
}

.detail-panel-meta {
  display: grid;
  gap: 14px;
}

.detail-block {
  display: grid;
  gap: 10px;
}

.detail-panel-title {
  margin: 0;
  font-size: 13px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.detail-kv-list {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  column-gap: 12px;
  row-gap: 8px;
  align-items: start;
  margin: 0;
}

.detail-kv-list.compact {
  grid-template-columns: 96px minmax(0, 1fr);
}

.detail-kv-list dt,
.detail-kv-list dd {
  margin: 0;
  min-width: 0;
}

.detail-kv-list dt {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.detail-kv-list dd {
  font-size: 14px;
  line-height: 1.45;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.price-matrix {
  gap: 14px;
}

.price-matrix-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
}

.price-matrix-kicker,
.price-secondary-head span {
  font-size: 12px;
  color: var(--muted);
}

.price-primary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.price-secondary-block {
  display: grid;
  gap: 10px;
  padding-top: 2px;
}

.price-secondary-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.price-secondary-head h5 {
  margin: 0;
  font-size: 13px;
  color: var(--text);
}

.price-secondary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.price-item {
  display: grid;
  gap: 8px;
  min-width: 0;
  padding: 12px 12px 10px;
  border-radius: 14px;
  border: 1px solid rgba(216, 226, 223, 0.95);
  background: rgba(247, 250, 249, 0.92);
}

.price-item.compact {
  padding: 10px 10px 8px;
  gap: 6px;
}

.price-item.is-primary {
  background: linear-gradient(180deg, rgba(13, 111, 109, 0.1), rgba(247, 250, 249, 0.98));
  border-color: rgba(13, 111, 109, 0.16);
}

.price-item.is-accent {
  background: linear-gradient(180deg, rgba(37, 99, 235, 0.09), rgba(247, 250, 249, 0.98));
  border-color: rgba(37, 99, 235, 0.12);
}

.price-item.is-zero {
  opacity: 0.72;
}

.price-label {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.price-value {
  font-size: 20px;
  line-height: 1;
  font-weight: 700;
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.price-item.compact .price-value {
  font-size: 16px;
}

.detail-side-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.raw-json-panel {
  border: 1px solid rgba(216, 226, 223, 0.9);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.82);
  overflow: hidden;
}

.raw-json-panel summary {
  cursor: pointer;
  padding: 12px 14px;
  font-size: 13px;
  color: var(--muted);
  list-style: none;
}

.raw-json-panel summary::-webkit-details-marker {
  display: none;
}

.raw-json-panel[open] summary {
  border-bottom: 1px solid var(--border);
}

.raw-json-panel .code-preview {
  margin: 0;
  max-height: 320px;
}

.raw-details summary {
  cursor: pointer;
  color: var(--primary);
}

.code-preview {
  margin: 12px 0 0;
  padding: 12px;
  border-radius: 12px;
  background: #0f1720;
  color: #e7eef3;
  overflow: auto;
  font-size: 12px;
  line-height: 1.5;
}

.manual-search-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(360px, 0.65fr);
  gap: 14px;
  overflow: auto;
}

.manual-search-panel,
.manual-order-panel {
  min-height: 100%;
  gap: 16px;
}

.manual-search-head h3,
.manual-order-head h3 {
  margin: 6px 0 4px;
  font-size: 20px;
}

.manual-panel-kicker {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
}

.manual-search-head p,
.manual-search-summary,
.manual-order-head p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.manual-order-head,
.manual-order-actions {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.manual-order-clear {
  flex: 0 0 auto;
}

.manual-order-head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.manual-order-count {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.manual-search-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.manual-search-input {
  min-height: 52px;
  font-size: 17px;
}

.manual-search-results {
  display: grid;
  gap: 10px;
}

.manual-search-empty {
  display: grid;
  min-height: 180px;
  place-items: center;
  border: 1px dashed var(--border-strong);
  border-radius: 14px;
  color: var(--muted);
  background: var(--panel-soft);
}

.manual-result-card {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) 74px 110px minmax(118px, auto);
  align-items: center;
  gap: 12px;
  padding: 13px 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fff;
}

.manual-result-card.is-best-match {
  border-color: rgba(13, 111, 109, 0.35);
  box-shadow: 0 8px 24px rgba(13, 111, 109, 0.08);
}

.manual-result-rank {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 700;
  font-size: 13px;
}

.manual-result-main {
  min-width: 0;
}

.manual-result-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.manual-result-title-row h4 {
  margin: 0;
  overflow: hidden;
  font-size: 15px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.manual-match-badge,
.manual-keyword-list span {
  display: inline-flex;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 11px;
  white-space: nowrap;
}

.manual-match-badge {
  padding: 4px 8px;
  font-weight: 700;
}

.manual-result-meta,
.manual-keyword-list {
  display: flex;
  align-items: center;
  gap: 6px 10px;
  flex-wrap: wrap;
}

.manual-result-meta {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}

.manual-keyword-list {
  margin-top: 7px;
}

.manual-keyword-list span {
  padding: 3px 7px;
}

.manual-result-stock,
.manual-result-price {
  display: grid;
  gap: 4px;
}

.manual-result-stock span,
.manual-result-price span {
  color: var(--muted);
  font-size: 11px;
}

.manual-result-stock strong,
.manual-result-price strong {
  font-size: 16px;
}

.manual-suggested-price {
  color: var(--success);
  font-size: 12px;
  font-style: normal;
  font-weight: 800;
  white-space: nowrap;
}

.manual-result-stock.is-in-stock strong {
  color: var(--success);
}

.manual-result-stock.is-out-of-stock strong {
  color: var(--danger);
}

.manual-result-actions {
  display: grid;
  gap: 8px;
}

.manual-result-add {
  white-space: nowrap;
}

.manual-order-items {
  display: grid;
  gap: 10px;
}

.manual-order-empty {
  display: grid;
  min-height: 130px;
  place-items: center;
  border: 1px dashed var(--border-strong);
  border-radius: 14px;
  color: var(--muted);
  background: var(--panel-soft);
  text-align: center;
  padding: 16px;
}

.manual-order-form,
.manual-order-section,
.manual-order-item {
  display: grid;
  gap: 12px;
}

.manual-order-section h4 {
  margin: 0;
  font-size: 15px;
}

.manual-order-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.manual-order-grid label,
.manual-order-special {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.manual-order-grid input,
.manual-order-special input {
  width: 100%;
}

.manual-order-grid span,
.manual-order-special span,
.manual-radio-group legend {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.manual-order-span {
  grid-column: 1 / -1;
}

.manual-order-item {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fff;
}

.manual-order-item-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.manual-order-item-head strong {
  display: block;
  font-size: 14px;
  line-height: 1.45;
}

.manual-order-item-head p {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 9px;
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.manual-radio-group {
  display: flex;
  align-items: center;
  gap: 10px 14px;
  flex-wrap: wrap;
  margin: 0;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel-soft);
}

.manual-radio-group legend {
  padding: 0 4px;
}

.manual-radio-group label,
.manual-specific-line {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.manual-radio-group input[type="radio"] {
  min-height: auto;
  width: 16px;
  height: 16px;
  padding: 0;
  accent-color: var(--primary);
}

.manual-specific-line input[type="number"] {
  width: 92px;
  min-height: 34px;
}

.manual-order-profit-line {
  display: flex;
  justify-content: flex-end;
  gap: 8px 14px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 13px;
}

.manual-order-profit-line strong {
  color: var(--primary);
}

.manual-order-output {
  width: 100%;
  min-height: 190px;
  white-space: pre-wrap;
}

.manual-profit-panel {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(13, 111, 109, 0.18);
  border-radius: 14px;
  background: var(--primary-soft);
  color: var(--text);
  font-size: 13px;
}

.manual-profit-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.manual-profit-title span {
  color: var(--muted);
  font-weight: 700;
}

.manual-profit-title strong {
  color: var(--primary);
  font-size: 20px;
}

.manual-profit-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
}

.manual-profit-grid div {
  display: grid;
  gap: 3px;
  padding: 8px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.68);
}

.manual-profit-grid dt {
  color: var(--muted);
  font-size: 11px;
}

.manual-profit-grid dd {
  margin: 0;
  font-weight: 800;
}

.manual-profit-panel p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.manual-order-actions {
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
}

@media (max-width: 1200px) {
  .metric-grid,
  .workspace-progress-grid,
  .workspace-lists,
  .products-layout,
  .detail-columns,
  .drawer-grid,
  .drawer-split {
    grid-template-columns: 1fr;
  }

  .app-drawer {
    min-width: 0;
    width: 92vw;
    right: 12px;
    left: 12px;
  }

  .mini-toolbar {
    grid-template-columns: 1fr;
  }

  .category-panel {
    min-width: 0;
    width: calc(100vw - 24px);
  }

  .product-summary-strip,
  .product-detail-body,
  .price-primary-grid,
  .price-secondary-grid,
  .detail-side-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  html,
  body {
    height: auto;
    min-height: 100%;
    overflow: auto;
  }

  body.drawer-open {
    overflow: hidden;
  }

  .app-shell {
    display: block;
    height: auto;
    min-height: 100vh;
  }

  .sidebar {
    width: 100%;
    padding: 10px;
    gap: 8px;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .brand-block {
    padding: 10px 12px;
  }

  .brand-block h1 {
    margin: 0;
    font-size: 21px;
  }

  .brand-kicker,
  .brand-block p,
  .sidebar-footer {
    display: none;
  }

  .sidebar-nav {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 4px;
  }

  .sidebar-link {
    justify-content: center;
    padding: 10px 6px;
    font-size: 14px;
    text-align: center;
  }

  .sidebar-link:hover,
  .sidebar-link.is-active {
    transform: none;
  }

  .app-main {
    min-height: 0;
    padding: 10px 10px calc(16px + env(safe-area-inset-bottom));
    gap: 10px;
    overflow: visible;
  }

  .topbar {
    min-height: 0;
    align-items: stretch;
    flex-direction: column;
    gap: 8px;
    padding: 10px 12px;
  }

  .topbar h2 {
    margin: 4px 0 0;
    font-size: 22px;
  }

  .topbar-actions {
    justify-content: flex-start;
    flex-wrap: wrap;
    overflow: visible;
  }

  .status-pill-detail {
    display: none;
  }

  .page-frame,
  .workspace-layout,
  .screen-layout,
  .detail-layout {
    height: auto;
    overflow: visible;
  }

  .workspace-layout {
    grid-template-rows: auto;
  }

  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .workspace-progress-panel {
    max-height: none;
  }

  .panel {
    padding: 12px;
  }

  .panel-head {
    flex-direction: column;
  }

  .summary-grid,
  .summary-grid.compact {
    grid-template-columns: 1fr;
  }

  .products-toolbar {
    align-items: stretch;
  }

  .products-toolbar input,
  .products-toolbar select,
  .products-toolbar .ghost-button,
  .products-toolbar .filter-pill,
  .products-toolbar .toolbar-path,
  .products-toolbar .toolbar-stat {
    width: 100%;
    max-width: none;
  }

  .app-drawer {
    top: 8px;
    right: 8px;
    bottom: 8px;
    left: 8px;
    width: auto;
    max-width: none;
  }

  .toast-root {
    right: 10px;
    bottom: calc(10px + env(safe-area-inset-bottom));
    width: calc(100vw - 20px);
  }

  .manual-search-form {
    grid-template-columns: 1fr;
  }

  .manual-search-layout {
    grid-template-columns: 1fr;
  }

  .manual-search-layout.has-order-items .manual-order-panel {
    order: -1;
  }

  .manual-order-panel {
    scroll-margin-top: max(10px, env(safe-area-inset-top));
  }

  .manual-search-panel,
  .manual-order-panel {
    gap: 14px;
  }

  .manual-result-card {
    grid-template-columns: 30px minmax(0, 1fr) auto;
    align-items: start;
    gap: 9px;
  }

  .manual-result-title-row {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .manual-result-title-row h4 {
    overflow: visible;
    white-space: normal;
  }

  .manual-result-rank {
    grid-row: span 2;
  }

  .manual-result-stock,
  .manual-result-price {
    display: flex;
    align-items: baseline;
    gap: 6px;
  }

  .manual-result-stock {
    grid-column: 2;
  }

  .manual-result-price {
    grid-column: 2;
  }

  .manual-result-detail {
    grid-column: 3;
  }

  .manual-result-actions {
    grid-column: 3;
    grid-row: 1 / span 3;
    align-self: center;
  }

  .manual-result-actions .ghost-button,
  .manual-result-actions .action-button {
    width: 100%;
    padding: 0 10px;
    font-size: 13px;
  }

  .manual-order-actions,
  .manual-order-item-head {
    align-items: stretch;
    flex-direction: column;
  }

  .manual-order-head {
    align-items: flex-start;
  }

  .manual-order-head-actions {
    align-items: center;
  }

  .manual-order-clear {
    min-height: 44px;
  }

  .manual-order-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .manual-profit-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .manual-order-grid input,
  .manual-order-special input,
  .manual-search-input {
    min-height: 46px;
    font-size: 16px;
  }

  .manual-order-output {
    min-height: 150px;
  }

  .manual-order-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .manual-order-actions .action-button,
  .manual-order-actions .ghost-button {
    width: 100%;
    min-height: 48px;
  }

  .manual-order-profit-line {
    justify-content: flex-start;
  }
}
