:root {
  color-scheme: light;
  --paper: #f6f5f1;
  --rail-bg: #eeede8;
  --surface: #fcfcfa;
  --table-head: #f1f1ed;
  --ink: #232623;
  --muted: #555c56;
  --stroke: #dedfd8;
  --control: #858b83;
  --brand: #71432d;
  --brand-deep: #58321e;
  --brand-tint: #ebe4da;
  --hover: #eff0ec;
  --focus: #466272;
  --rail: 212px;
  font: 14px/1.6 "Avenir Next", "PingFang SC", "Microsoft YaHei", sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--paper); color: var(--ink); }
a, button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .55; }
a { color: inherit; text-decoration: none; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
.sr, .skip:not(:focus) { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.skip:focus { position: fixed; z-index: 4; inset: 8px auto auto 8px; padding: 8px; background: var(--surface); }

.rail {
  position: fixed; inset: 0 auto 0 0; width: var(--rail);
  display: flex; flex-direction: column; padding: 32px 18px 20px;
  background: var(--rail-bg); border-right: 1px solid var(--stroke);
}
.brand { display: flex; align-items: center; gap: 11px; margin: 0 5px 52px; color: var(--brand); }
.brand img { width: 38px; height: 38px; }
.brand strong { display: block; font-size: 20px; line-height: 1.15; font-weight: 700; letter-spacing: .08em; }
.brand small { display: block; margin-top: 4px; color: var(--muted); font-size: 10px; letter-spacing: .1em; }
.workspace { margin: 0 12px 9px; color: var(--muted); font-size: 10px; letter-spacing: .14em; }
.rail nav { display: grid; gap: 5px; }
.rail nav a {
  display: flex; align-items: center; gap: 10px; min-height: 45px;
  padding: 8px 11px; border-left: 2px solid transparent; border-radius: 4px;
}
.rail nav a span { width: 17px; color: var(--muted); font-size: 17px; line-height: 1; text-align: center; }
.rail nav a:hover { background: #e6e7e0; }
.rail nav a[aria-current="page"] { background: var(--brand-tint); color: var(--brand); border-left-color: var(--brand); font-weight: 650; }
.rail nav a[aria-current="page"] span { color: var(--brand); }
.railfoot { margin-top: auto; border-top: 1px solid var(--stroke); padding: 14px 4px 0; color: var(--muted); font-size: 11px; }
.railfoot i, .demo-label i { display: inline-block; background: #5c6661; width: 6px; height: 6px; border-radius: 50%; }
.railfoot i { margin-inline-end: 4px; }
.railfoot small { float: right; font-size: 9px; letter-spacing: .08em; }

main { margin-left: var(--rail); min-width: 0; min-height: 100dvh; }
.top {
  min-height: 58px; display: flex; align-items: center; justify-content: space-between; gap: 6px;
  padding: 0 clamp(22px, 4.2vw, 58px); border-bottom: 1px solid var(--stroke);
  background: var(--surface); color: var(--muted); font-size: 12px;
}
.top b { font-weight: 600; color: var(--ink); }
.top > div:first-child span { padding: 0 4px; }
.preview-tools { display: flex; align-items: center; gap: 9px; }
.demo-label { display: inline-flex; align-items: center; gap: 6px; padding: 3px 7px; border: 1px solid #c5cbc3; border-radius: 4px; font-size: 11px; white-space: nowrap; }
.content { padding: 28px clamp(22px, 4.2vw, 58px) 24px; max-width: 1430px; }
.heading { display: flex; align-items: end; justify-content: space-between; gap: 15px; margin: 0 0 22px; }
.eyebrow { margin: 0 0 5px; font-size: 10px; font-weight: 650; line-height: 1.4; letter-spacing: .16em; color: var(--muted); }
.heading h1 { margin: 0; font-size: 34px; font-weight: 550; line-height: 1.36; letter-spacing: -.055em; }
.subtitle { margin: 5px 0 0; color: var(--muted); font-size: 13px; }

button { padding: 6px 10px; border: 1px solid transparent; border-radius: 5px; background: transparent; color: inherit; }
.primary, .secondary { min-height: 40px; padding: 7px 13px; white-space: nowrap; font-weight: 600; }
.primary { background: var(--brand); color: #fff; }
.primary:hover { background: var(--brand-deep); }
.secondary { border-color: var(--control); background: var(--surface); color: var(--ink); }
.secondary:hover, .quiet:hover, .row-open:hover { background: var(--hover); }
.quiet { color: var(--muted); }
.ledger { background: var(--surface); border: 1px solid var(--stroke); border-radius: 7px; overflow: hidden; }
.toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 9px; padding: 13px 17px; }
.search {
  min-width: 0; width: min(302px, 100%); display: flex; align-items: center; gap: 8px;
  padding: 0 9px; border: 1px solid var(--control); border-radius: 5px; color: var(--muted);
}
.search > span { font-size: 19px; }
.search input { min-width: 0; width: 100%; min-height: 37px; border: 0; outline: none; background: transparent; }
.search:focus-within { outline: 2px solid var(--focus); outline-offset: 2px; }
.filters { display: flex; gap: 8px; }
.count { margin-left: auto; color: var(--muted); font-size: 12px; white-space: nowrap; font-variant-numeric: tabular-nums; }
input, select, textarea { color: var(--ink); }
input::placeholder, textarea::placeholder { color: #5b635c; }
select { min-height: 39px; border: 1px solid var(--control); border-radius: 5px; padding: 5px 8px; background: var(--surface); }

.table-wrap { overflow-x: auto; }
.table-wrap:focus-visible { outline-offset: -2px; }
table { width: 100%; border-collapse: collapse; min-width: 740px; text-align: left; font-size: 13px; }
table[data-kind="suppliers"] { min-width: 960px; }
th {
  padding: 9px 15px; border-block: 1px solid var(--stroke); background: var(--table-head);
  color: #454d46; font-size: 11px; font-weight: 650; letter-spacing: .04em; white-space: nowrap;
}
td { min-height: 52px; padding: 10px 15px; vertical-align: middle; border-bottom: 1px solid var(--stroke); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td, tbody tr:focus-within td { background: #f5f6f2; }
th:first-child, td:first-child { padding-left: 17px; }
.actions-cell { width: 44px; padding-left: 0; padding-right: 12px; }
body[data-mode="live"] .actions-cell { width: 96px; }
th:has(> .sort-header) { padding: 0; }
.sort-header {
  display: flex; width: 100%; min-height: 34px; align-items: center; gap: 4px;
  padding: 6px 15px; border: 0; text-align: left; letter-spacing: inherit;
}
.sort-header:hover { text-decoration: underline; }
.sort-header:focus-visible { outline-offset: -2px; }
.sort-indicator { color: var(--muted); }
.sort-indicator::after { content: '↕'; }
th[aria-sort] .sort-indicator { color: var(--brand); }
th[aria-sort="ascending"] .sort-indicator::after { content: '↑'; }
th[aria-sort="descending"] .sort-indicator::after { content: '↓'; }
.row-title { display: block; padding: 0; border: 0; text-align: left; font-weight: 650; }
.row-title:hover { text-decoration: underline; text-underline-offset: 3px; }
.row-id { display: block; margin-top: 1px; color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.english, .website { color: #434a44; overflow-wrap: anywhere; }
.website-link, .product-title { text-decoration: underline; text-underline-offset: 3px; }
.relation { min-width: 45px; min-height: 31px; padding: 2px 7px; background: #eff0ec; color: #3d4840; white-space: nowrap; font-variant-numeric: tabular-nums; font-size: 12px; }
.relation:hover { background: #e0e4dd; }
.row-open { min-width: 33px; min-height: 34px; padding: 2px 6px; color: var(--muted); font-size: 19px; line-height: 1; }
.row-actions { display: flex; align-items: center; gap: 4px; }
.row-delete { min-height: 34px; padding: 2px 6px; color: #823c36; white-space: nowrap; }
.row-delete:hover:not(:disabled) { background: #f6ebe9; }
.remark-cell { width: 27%; min-width: 176px; }
.assignee-cell { min-width: 118px; }
.status-cell { min-width: 89px; }
.inline-control { display: block; width: 100%; }
:is(.assignee-cell, .status-cell) select { font-weight: 650; }
:is(.assignee-cell, .status-cell) option { background: var(--surface); color: var(--ink); }
.remark-cell textarea {
  field-sizing: content; min-height: 49px; max-height: 12rem; padding: 6px 8px;
  border: 1px solid var(--control); border-radius: 5px; overflow-wrap: anywhere;
  background: var(--surface); resize: vertical;
}
.inline-feedback { margin: 4px 0 0; font-size: 12px; overflow-wrap: anywhere; }
.inline-feedback:empty { margin: 0; }
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 7px; border-radius: 4px; color: #3f483f; font-size: 11px; font-weight: 650; white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.neutral { background: #eceeea; }
.badge.neutral::before { display: none; }
.stage-0 { background: #ebece9; color: #444d47; }
.stage-1 { background: #e5edf3; color: #33536a; }
.stage-2 { background: #f3ead9; color: #684920; }
.stage-3 { background: #eee8f0; color: #624769; }
.stage-4 { background: #e5eee6; color: #375840; }
.assignee-0 { background: #e8e3f4; color: #51416f; }
.assignee-1 { background: #dfece8; color: #254f43; }
.assignee-2 { background: #f6e8d7; color: #654522; }
.empty { padding: 37px 15px; color: var(--muted); text-align: center; }
.list-foot { display: flex; flex-wrap: wrap; gap: 4px 12px; justify-content: space-between; margin-top: 14px; color: var(--muted); font-size: 11px; }
.list-foot > div { letter-spacing: .1em; }
.list-foot > div span { margin-inline: 3px; }
.list-foot p { margin: 0; }

#drawer {
  position: fixed; inset: 0 0 0 auto; width: min(100%, 530px); height: 100dvh; max-width: none; max-height: none;
  margin: 0; padding: 0; border: 0; border-left: 1px solid var(--stroke);
  background: var(--surface); color: var(--ink); box-shadow: -15px 0 42px #242d2430;
}
#drawer[open] { display: flex; flex-direction: column; }
dialog:modal { overscroll-behavior: contain; }
dialog::backdrop { background: #232a2661; overflow: hidden; overscroll-behavior: contain; }
.dhead { display: flex; align-items: start; justify-content: space-between; gap: 10px; padding: 24px 23px 17px; border-bottom: 1px solid var(--stroke); background: var(--paper); }
.dhead h1 { margin: 0; font-size: 23px; font-weight: 550; line-height: 1.36; overflow-wrap: anywhere; }
.dhead p:last-child { margin: 4px 0 0; color: var(--muted); overflow-wrap: anywhere; }
.icon { width: 39px; height: 39px; border-color: var(--control); background: var(--surface); color: var(--ink); font-size: 23px; line-height: 1; flex: none; }
.icon:hover { background: var(--hover); }
.dtabs { display: flex; flex-wrap: wrap; gap: 4px; padding: 3px 22px 0; border-bottom: 1px solid var(--stroke); }
.tab { min-height: 43px; padding-inline: 12px; border-radius: 0; border-bottom: 2px solid transparent; color: var(--muted); white-space: nowrap; }
.tab:hover { background: var(--hover); }
.tab[aria-pressed="true"] { border-bottom-color: var(--brand); color: var(--brand); font-weight: 650; }
.pane { flex: 1; min-height: 0; padding: 22px 23px; overflow-y: auto; overscroll-behavior: contain; }
.pane h2 { margin: 0 0 13px; font-size: 16px; font-weight: 650; }
.pane-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.pane-heading h2 { margin: 0; }
.pane dl { display: grid; grid-template-columns: 88px 1fr; margin: 12px 0; }
.pane dt, .pane dd { margin: 0; padding: 10px 3px; border-bottom: 1px solid var(--stroke); overflow-wrap: anywhere; }
.pane dt, .muted, .hint { color: var(--muted); }
.pane dd { white-space: pre-wrap; }
.related-list { display: grid; gap: 7px; margin-bottom: 15px; }
.related, .product { padding: 9px 11px; border: 1px solid var(--stroke); border-radius: 5px; background: #f5f5f0; text-align: left; }
.related:hover { background: var(--hover); }
.related small, .product small, .product strong { display: block; }
.related small, .product small { color: var(--muted); font-size: 11px; }
.product { display: flex; align-items: flex-start; gap: 9px; }
.product-copy { min-width: 0; }
.product-title { display: block; font-weight: 650; }
.product-image {
  flex: 0 0 56px; height: 56px; display: grid; place-items: center;
  border-radius: 4px; overflow: hidden; background: var(--table-head); color: var(--muted); font-size: 10px;
}
.product-image img { width: 100%; height: 100%; object-fit: contain; }
.product .quiet { margin: 3px 0 0 -7px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 11px; }
.form-grid.single { grid-template-columns: 1fr; }
.form-grid .wide { grid-column: 1 / -1; }
.form-grid label, .assignment label { min-width: 0; font-weight: 650; }
.form-grid :is(input, textarea, select), .assignment input {
  display: block; width: 100%; min-height: 40px; margin-top: 5px; padding: 7px 9px;
  border: 1px solid var(--control); border-radius: 5px; background: var(--surface); font-weight: 400;
}
.form-grid textarea { resize: vertical; }
.actions { display: flex; justify-content: end; gap: 7px; margin-top: 18px; }
.error { color: #823c36; font-size: 12px; }
.hint { font-size: 12px; }
.assignment { margin-top: 8px; padding: 11px; border: 1px solid var(--stroke); border-radius: 5px; background: #f5f5f1; }
.relation-row, .picker-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 8px; }
.relation-row .related, .relation-row .product, .picker-info { min-width: 0; overflow-wrap: anywhere; }
.unlink { min-height: 36px; font-size: 12px; }
.picker-results { display: grid; gap: 4px; max-height: 265px; overflow: auto; overscroll-behavior: contain; }
.picker-row { padding: 6px 4px; border-bottom: 1px solid var(--stroke); }
.picker-info small { display: block; color: var(--muted); font-size: 12px; }
.picker-info .owner { font-weight: 650; }
#toast:not(:empty) {
  position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%);
  border-radius: 5px; padding: 8px 12px; background: #2a322c; color: #fff; font-size: 12px;
}
@media (min-width: 790px) {
  .content { padding-top: 34px; }
}
@media (max-width: 789px) {
  .rail { position: sticky; inset: 0 0 auto; z-index: 2; width: 100%; padding: 9px 14px 8px; gap: 6px; border-right: 0; border-bottom: 1px solid var(--stroke); }
  .brand { margin: 0; }
  .brand img { width: 32px; height: 32px; }
  .brand strong { font-size: 17px; }
  .brand small { font-size: 9px; margin-top: 2px; }
  .workspace, .railfoot { display: none; }
  .rail nav { grid-template-columns: 1fr 1fr; }
  .rail nav a { min-height: 38px; padding: 4px 8px; }
  main { margin-left: 0; }
  .top { min-height: 45px; padding: 0 13px; }
  .content { padding: 17px 13px 20px; }
  .heading { align-items: end; gap: 6px; margin-bottom: 13px; }
  .heading h1 { font-size: 27px; }
  .heading .primary { min-height: 38px; padding-inline: 8px; }
  .subtitle { font-size: 12px; }
  .toolbar { gap: 7px; padding: 9px 11px; }
  .search { width: 100%; }
  .dhead { padding: 16px 15px 13px; }
  .dtabs { padding-inline: 12px; }
  .pane { padding: 15px; }
}
@media (max-width: 420px) {
  .picker-row { gap: 5px; }
  .picker-row button, .unlink { padding-inline: 6px; font-size: 11px; }
}
@media (prefers-reduced-motion: no-preference) {
  #drawer[open] { animation: arrive .14s ease-out; }
  @keyframes arrive { from { transform: translateX(12px); opacity: .85; } to { transform: none; opacity: 1; } }
}
@media (max-width: 520px) {
  #grid :is(th, td):first-child { position: sticky; left: 0; z-index: 1; max-width: 132px; box-shadow: 1px 0 0 var(--stroke); }
  #grid td:first-child { background: var(--surface); }
  #grid tr:is(:hover, :focus-within) td:first-child { background: #f5f6f2; }
}
