:root {
  color-scheme: dark;
  --bg: #09070f;
  --surface: #11101a;
  --surface-raised: #171521;
  --surface-hover: #1d192a;
  --line: #2a2539;
  --muted: #858097;
  --text: #f1eff8;
  --purple: #b65cff;
  --purple-strong: #9638ef;
  --purple-soft: #d18cff;
  --green: #63d9aa;
  --red: #ff768e;
  --shadow: 0 18px 55px rgba(0, 0, 0, .28);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 1120px; background: radial-gradient(circle at 80% -20%, #25123b 0, transparent 35rem), var(--bg); color: var(--text); }
button, input { font: inherit; }
button { cursor: pointer; }
.app-shell { width: min(1720px, calc(100vw - 80px)); margin: 0 auto; padding: 30px 0 60px; }
.topbar, .order-heading, .panel-heading, .drawer-heading, .dialog-heading { display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.topbar { padding-bottom: 32px; }
.brand { display: flex; align-items: center; gap: 13px; }
.brand-mark { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; background: var(--purple); color: #1b0929; font-size: 22px; font-weight: 900; box-shadow: 0 0 28px rgba(182, 92, 255, .32); }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 18px; letter-spacing: -.02em; }
h2 { font-size: 27px; letter-spacing: -.04em; }
h3 { font-size: 17px; letter-spacing: -.02em; }
.eyebrow, .section-kicker, .summary-label { color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
.eyebrow { display: block; margin-top: 3px; font-size: 9px; color: var(--purple-soft); }
.top-actions { display: flex; gap: 9px; }
.icon-button, .close-button { border: 1px solid var(--line); background: var(--surface); color: var(--muted); border-radius: 9px; padding: 10px 13px; transition: .18s ease; }
.icon-button { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.icon-button:first-child { font-size: 18px; padding-block: 7px; }
.icon-button:first-child span { font-size: 12px; }
.icon-button:hover:not(:disabled), .close-button:hover { color: var(--text); border-color: var(--purple); background: var(--surface-hover); }
button:disabled { cursor: not-allowed; opacity: .4; }
.panel { border: 1px solid var(--line); background: linear-gradient(145deg, rgba(25, 22, 37, .96), rgba(14, 13, 22, .96)); border-radius: 14px; box-shadow: var(--shadow); }
.search-panel { display: flex; align-items: center; justify-content: space-between; padding: 27px 30px; }
.search-panel h2 { margin-top: 7px; font-size: 22px; }
.order-search { width: 450px; }
label { display: block; color: var(--muted); font-size: 11px; font-weight: 700; }
.search-controls { display: flex; gap: 10px; margin-top: 8px; }
input { outline: none; border: 1px solid var(--line); border-radius: 7px; background: #0c0b13; color: var(--text); padding: 10px 11px; transition: border-color .15s, box-shadow .15s; }
input:focus { border-color: var(--purple); box-shadow: 0 0 0 3px rgba(182, 92, 255, .12); }
.search-controls input { width: 100%; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 38px; border: 1px solid transparent; border-radius: 8px; padding: 9px 14px; color: var(--text); font-size: 12px; font-weight: 800; transition: .18s ease; }
.button-primary { background: linear-gradient(135deg, var(--purple), var(--purple-strong)); color: #190827; box-shadow: 0 8px 24px rgba(150, 56, 239, .21); }
.button-primary:hover { filter: brightness(1.1); transform: translateY(-1px); }
.button-secondary { border-color: #3f2c55; background: #20152c; color: var(--purple-soft); }
.button-secondary:hover { border-color: var(--purple); background: #2c1a40; }
.button-ghost { border-color: var(--line); background: transparent; color: var(--muted); }
.button-ghost:hover { color: var(--text); }
.notice { min-height: 22px; margin: 13px 3px 0; color: var(--muted); font-size: 12px; }
.notice.success { color: var(--green); }
.notice.error { color: var(--red); }
.notice.warning { color: #f6c674; }
.empty-state { display: grid; place-items: center; min-height: 460px; margin-top: 11px; text-align: center; }
.empty-orbit { display: grid; place-items: center; width: 74px; height: 74px; margin-bottom: 22px; border: 1px solid #4c2d6b; border-radius: 50%; color: var(--purple); font-size: 34px; box-shadow: 0 0 0 12px rgba(182, 92, 255, .04), 0 0 50px rgba(182, 92, 255, .18); }
.empty-state h2 { font-size: 20px; }
.empty-state p { margin-top: 9px; color: var(--muted); font-size: 13px; }
.is-hidden { display: none !important; }
.order-content { margin-top: 26px; }
.order-heading { margin-bottom: 21px; }
.order-heading h2 { margin-top: 7px; }
.muted { margin-top: 6px; color: var(--muted); font-size: 12px; }
.summary-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 11px; margin-bottom: 22px; }
.summary-card { min-height: 122px; padding: 19px 20px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.accent-card { border-color: #5f3380; background: linear-gradient(145deg, #271638, #15111e); }
.summary-card strong { display: block; margin-top: 14px; font-size: 25px; letter-spacing: -.04em; }
.summary-edit { display: block; width: 100%; margin-top: 8px; padding: 0; border: 0; background: transparent; font-size: 25px; font-weight: 800; letter-spacing: -.04em; }
.summary-edit:focus { box-shadow: none; }
.summary-hint { display: block; margin-top: 7px; color: var(--muted); font-size: 11px; }
.margin-card { border-color: #3d2b54; }
.markup-edit { display: flex; align-items: baseline; gap: 4px; margin-top: 8px; color: var(--purple-soft); }
.markup-edit input { width: 130px; padding: 0; border: 0; background: transparent; color: inherit; font-size: 25px; font-weight: 800; letter-spacing: -.04em; }
.markup-edit input:focus { box-shadow: none; }
.markup-edit span { font-size: 16px; font-weight: 800; }
.items-panel { overflow: hidden; }
.panel-heading { padding: 21px 23px 18px; }
.panel-actions { display: flex; align-items: center; gap: 9px; }
.panel-heading h3 { margin-top: 6px; }
.plus { font-size: 18px; line-height: 10px; }
.table-scroll { overflow: auto; }
.items-table { width: 100%; border-collapse: collapse; min-width: 1160px; }
th { color: var(--muted); background: #0f0e17; font-size: 10px; font-weight: 800; letter-spacing: .1em; text-align: left; text-transform: uppercase; white-space: nowrap; }
th, td { padding: 12px 11px; border-top: 1px solid var(--line); }
th:first-child, td:first-child { padding-left: 23px; }
th:last-child, td:last-child { padding-right: 23px; }
td { color: #ded9e9; font-size: 12px; vertical-align: middle; }
.name-column { width: 28%; }
.lock-column { width: 86px; }
.action-column { width: 65px; text-align: right; }
.item-input { width: 90px; padding: 7px 8px; border-color: transparent; background: #0e0d15; font-size: 12px; }
.currency-field { text-align: right; }
.item-input:hover { border-color: var(--line); }
.item-input.code-input { width: 125px; }
.item-input.name-input { width: 100%; min-width: 245px; }
.item-input.supplier-input { width: 135px; }
.item-input.qty-input { width: 62px; }
.money-input { text-align: right; }
.markup-input { width: 77px; color: var(--purple-soft); text-align: right; }
.product-name { max-width: 440px; color: var(--text); font-weight: 650; }
.source-badge { display: inline-block; margin-left: 7px; padding: 3px 5px; border-radius: 4px; background: #261b32; color: var(--purple-soft); font-size: 8px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.lock-button, .remove-button { border: 0; background: transparent; color: var(--muted); font-size: 16px; }
.lock-button:hover { color: var(--purple-soft); }
.lock-button.is-locked { color: var(--purple); }
.remove-button { font-size: 19px; color: #6e647d; }
.remove-button:hover { color: var(--red); }
.row-locked td { background: rgba(182, 92, 255, .025); }
.row-locked .product-name { color: #aaa0b9; }
.percentage-panel { position: fixed; z-index: 10; top: 0; right: 0; width: 570px; height: 100vh; padding: 29px 27px; border-left: 1px solid #3c2a50; background: #110e19; box-shadow: -20px 0 80px rgba(0, 0, 0, .42); transform: translateX(105%); transition: transform .25s ease; }
.percentage-panel.is-open { transform: translateX(0); }
.drawer-description { margin: 13px 0 19px; color: var(--muted); font-size: 12px; line-height: 1.5; }
.close-button { padding: 2px 10px; font-size: 25px; line-height: 1.2; }
.percentage-controls { display: flex; flex-wrap: wrap; gap: 8px; }
.percentage-chip { display: flex; align-items: center; gap: 3px; padding: 4px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); }
.percentage-chip input { width: 70px; padding: 5px 6px; border: 0; background: transparent; color: var(--purple-soft); font-size: 12px; }
.percentage-chip button { border: 0; background: transparent; color: var(--muted); font-size: 16px; }
.percentage-chip button:hover { color: var(--red); }
.drawer-actions { display: flex; align-items: center; gap: 15px; margin: 15px 0 20px; }
.text-button { border: 0; background: transparent; color: var(--muted); font-size: 11px; }
.text-button:hover { color: var(--purple-soft); }
.simulation-scroll { max-height: calc(100vh - 230px); overflow: auto; border: 1px solid var(--line); border-radius: 9px; }
.simulation-table { width: max-content; min-width: 100%; border-collapse: collapse; }
.simulation-table th, .simulation-table td { padding: 10px 11px; border-top: 1px solid var(--line); }
.simulation-table th { position: sticky; top: 0; z-index: 1; background: #181321; color: var(--purple-soft); text-align: right; }
.simulation-table th:first-child, .simulation-table td:first-child { position: sticky; left: 0; z-index: 2; padding-left: 13px; background: #15111e; text-align: left; }
.simulation-table td { color: var(--text); text-align: right; white-space: nowrap; }
.simulation-table td:first-child { max-width: 190px; overflow: hidden; text-overflow: ellipsis; }
.drawer-backdrop { position: fixed; z-index: 9; inset: 0; background: rgba(2, 1, 6, .58); opacity: 0; pointer-events: none; transition: opacity .25s; }
.drawer-backdrop.is-visible { opacity: 1; pointer-events: auto; }
.item-dialog { width: 570px; padding: 25px; border: 1px solid #4a3260; border-radius: 14px; background: #16121f; color: var(--text); box-shadow: var(--shadow); }
.item-dialog::backdrop { background: rgba(2, 1, 6, .78); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 25px 0; }
.form-grid label { color: var(--muted); }
.form-grid input { display: block; width: 100%; margin-top: 7px; }
.wide-field { grid-column: 1 / -1; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 9px; }

@media (max-width: 1250px) {
  .app-shell { width: calc(100vw - 40px); }
  .summary-grid { grid-template-columns: repeat(2, 1fr); }
}
