:root {
  color-scheme: light;
  --ink: #1d252c;
  --muted: #42515e;
  --line: #d9e0e6;
  --panel: #ffffff;
  --bg: #f5f7f9;
  --accent: #e74030;
  --accent-dark: #bf281c;
  --warn: #fff4d6;
  --danger: #ffe2e2;
  --short: #fff0f0;
  --ok: #e9f7ef;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

/* Puffy is a playful, local-only companion, not an inventory adviser. */
.puffy-assistant { --puffy-olive: #909f24; --puffy-lime: #c1d054; --puffy-soft: #d9e1ae; --puffy-ink: #29320f; position: fixed; right: 0; bottom: 38px; z-index: 25; color: var(--puffy-ink); font-family: ui-rounded, "Trebuchet MS", system-ui, sans-serif; }
.puffy-assistant[hidden], .puffy-chat[hidden], .puffy-typing[hidden] { display: none; }
.puffy-tab { width: 58px; min-height: 72px; padding: 5px 6px 6px; flex-direction: column; gap: 0; border: 2px solid var(--puffy-olive); border-right: 0; border-radius: 20px 0 0 20px; background: #f6f8e9; color: var(--puffy-ink); box-shadow: -3px 3px 10px #343d1517; font-size: 11px; font-weight: 800; }
.puffy-tab img { width: 44px; height: 44px; object-fit: contain; transition: transform 220ms ease; transform-origin: center; }
.puffy-tab:hover, .puffy-tab:focus-visible { background: #fff; }
.puffy-tab:hover img, .puffy-tab:focus-visible img { transform: rotate(-12deg) scale(1.05); }
.puffy-assistant button:focus-visible, .puffy-assistant textarea:focus-visible { outline: 3px solid var(--puffy-ink); outline-offset: 3px; }
.puffy-chat { position: fixed; right: 70px; bottom: 38px; width: 350px; max-width: calc(100% - 86px); height: 460px; max-height: calc(100dvh - 76px); display: flex; flex-direction: column; overflow: hidden; background: #fcfdf5; border: 3px solid var(--puffy-olive); border-radius: 25px 25px 9px 25px; box-shadow: 5px 6px 0 #909f2433, 0 10px 35px #343d152b; }
.puffy-header { display: flex; flex: 0 0 auto; align-items: center; gap: 9px; padding: 13px 12px; background: #f6f8e9; border-bottom: 2px solid var(--puffy-olive); }
.puffy-header > img { width: 54px; height: 54px; object-fit: contain; }
.puffy-header > div { flex: 1; min-width: 0; }
.puffy-header h2 { margin: 0; color: var(--puffy-ink); font-size: 23px; line-height: 1.2; letter-spacing: -0.5px; }
.puffy-close { width: 30px; min-height: 30px; flex: 0 0 30px; padding: 0; border-radius: 50%; background: transparent; color: var(--puffy-ink); font-size: 25px; }
.puffy-close:hover { background: var(--puffy-soft); }
.puffy-messages { min-height: 0; flex: 1 1 auto; overflow-y: auto; overscroll-behavior: contain; padding: 14px; display: flex; flex-direction: column; gap: 11px; scrollbar-width: thin; scrollbar-color: var(--puffy-olive) transparent; }
.puffy-message { display: flex; flex: 0 0 auto; }
.puffy-message-user { justify-content: flex-end; }
.puffy-bubble { max-width: 91%; padding: 9px 12px; border: 1px solid var(--puffy-soft); border-radius: 17px 17px 17px 4px; background: var(--puffy-soft); overflow-wrap: anywhere; }
.puffy-message-user .puffy-bubble { border-color: var(--puffy-lime); border-radius: 17px 17px 4px 17px; background: #fff; }
.puffy-speaker { display: block; font-weight: 800; font-size: 11px; color: var(--puffy-ink); }
.puffy-bubble p { margin: 4px 0 0; white-space: pre-wrap; font-size: 14px; line-height: 1.5; color: var(--puffy-ink); }
.puffy-typing { display: flex; align-items: center; gap: 7px; flex: 0 0 auto; padding: 0 14px 9px; font-size: 11px; font-weight: 600; }
.puffy-dots { display: inline-flex; gap: 3px; }
.puffy-dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--puffy-olive); animation: puffy-bubble 900ms ease-in-out infinite alternate; }
.puffy-dots i:nth-child(2) { animation-delay: 150ms; }
.puffy-dots i:nth-child(3) { animation-delay: 300ms; }
.puffy-compose { flex: 0 0 auto; padding: 10px 12px 0; border-top: 1px solid var(--puffy-soft); }
.puffy-compose > label { display: block; color: var(--puffy-ink); margin-bottom: 5px; font-size: 11px; font-weight: 800; }
.puffy-compose > div { display: flex; align-items: stretch; gap: 7px; }
.puffy-compose textarea { min-height: 58px; max-height: 90px; resize: none; flex: 1; padding: 8px 10px; border: 2px solid var(--puffy-soft); border-radius: 14px; font-size: 13px; color: var(--puffy-ink); }
.puffy-compose textarea::placeholder { color: #515d23; }
.puffy-compose button { align-self: center; min-height: 38px; padding: 7px 10px; border-radius: 13px; background: var(--puffy-lime); color: var(--puffy-ink); gap: 3px; }
.puffy-compose button:hover { background: var(--puffy-olive); }
.puffy-compose button:disabled { background: var(--puffy-soft); color: #515d23; }
.puffy-disclaimer { flex: 0 0 auto; padding: 8px 12px 10px; margin: 0; color: #515d23; font-size: 10px; line-height: 1.4; text-align: center; }
.menu-open .puffy-assistant { visibility: hidden; }
.puffy-preference { flex: 0 0 auto; margin: 0; padding: 0 12px 10px; text-align: center; }
.puffy-preference button { background: var(--puffy-soft); color: var(--puffy-ink); }
.puffy-setting { display: flex; align-items: center; gap: 12px; margin: 0; }
.puffy-setting h2 { margin: 0; }
.puffy-setting input[type="checkbox"] { width: auto; flex: 0 0 auto; }
.puffy-setting button { flex: 0 0 auto; }
@keyframes puffy-bubble { to { transform: translateY(-4px); } }
@media (max-width: 900px) {
  .puffy-chat { max-height: calc(100dvh - 106px); }
}
@media (max-width: 600px) {
  .puffy-assistant { bottom: 24px; }
  .puffy-chat { right: 10px; bottom: 108px; width: 350px; max-width: calc(100% - 20px); max-height: calc(100dvh - 176px); }
}
@media (max-height: 440px) {
  .puffy-assistant { bottom: 12px; }
  .puffy-chat { bottom: 12px; right: 70px; max-width: calc(100% - 80px); max-height: calc(100dvh - 24px); }
  .puffy-header { padding: 7px 10px; }
  .puffy-header > img { width: 38px; height: 38px; }
}
@media (max-height: 440px) and (max-width: 900px) {
  .puffy-chat { max-height: calc(100dvh - 80px); }
}
@media (prefers-reduced-motion: reduce) {
  .puffy-tab img { transition: none; }
  .puffy-tab:hover img, .puffy-tab:focus-visible img { transform: none; }
  .puffy-dots i { animation: none; }
}
@media print { .puffy-assistant { display: none !important; } }

.table-scroll { max-width: 100%; overflow-x: auto; }
.table-scroll table { min-width: 640px; }
.table-scroll td input, .table-scroll td select { max-width: 100%; }
.supplier-editor { min-width: 1080px; }
.supplier-entry {
  padding: 10px 0;
}
.supplier-entry + .supplier-entry { margin-top: 12px; padding-top: 16px; border-top: 2px solid #526571; }
.supplier-entry .line {
  padding: 4px 0;
}
.supplier-editor .supplier-primary {
  grid-template-columns: minmax(180px, 1.35fr) minmax(150px, 1fr) minmax(125px, 1fr) 140px 110px;
}
.supplier-editor .supplier-secondary { grid-template-columns: minmax(240px, 1.5fr) 110px 110px minmax(200px, 1fr) 92px 40px; }
.supplier-editor .supplier-delete { width: 40px; height: 40px; min-height: 40px; padding: 0; background: var(--accent); color: #fff; font-size: 24px; }
.supplier-editor .supplier-delete:hover { background: var(--accent-dark); }
.supplier-entry .line-head { padding-top: 5px; }
.supplier-currency { font-weight: 700; }
.bom-import-upload { max-width: 760px; }
.bom-import-rows { display: grid; gap: 14px; margin: 18px 0; }
.bom-import-row { border: 1px solid var(--line); border-radius: 8px; padding: 14px; }
.bom-import-row.invalid { background: var(--danger); }
.bom-import-row-head { display: grid; grid-template-columns: 92px minmax(0, 1fr) auto; gap: 12px; align-items: center; }
.bom-actions { padding: 8px 0 0 104px; }
.bom-actions p { margin: 8px 0; }
.bom-errors { color: #8f1b13; margin: 10px 0 0 104px; }
.supplier-resolution label { margin-top: 8px; max-width: 520px; }
.supplier-match-options { margin-top: 10px; border: 1px solid var(--line); border-radius: 6px; padding: 10px; }
.supplier-match-options label { max-width: none; text-transform: none; }
.bom-import-row-head > label.check,
.supplier-match-options label.check { display: flex; flex-direction: row; align-items: center; gap: 8px; }
.bom-import-row-head > label.check { white-space: nowrap; }
.bom-import-row-head > label.check input,
.supplier-match-options label.check input { flex: 0 0 auto; width: auto; margin: 0; }
.update-existing { margin: 10px 0; }
.compact-table { margin: 8px 0; }
.compact-table th, .compact-table td { padding: 6px 8px; }
.item-detail-stack { display: block; margin-bottom: 18px; }
.cost-line { grid-template-columns: minmax(130px, 2fr) 80px 100px minmax(120px, 2fr) 44px; }
.stocktake-table td { font-size: 16px; color: var(--ink); }
.stocktake-table input { min-width: 90px; }
.generate-po-form .split { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.generate-po-form .generate-po { margin-left: auto; }
.nav { overflow-y: auto; }
.supplier-url,
.bom-item-field { display: grid; grid-template-columns: minmax(0, 1fr) 28px; gap: 5px; align-items: center; }
.external-link-button {
  width: 28px;
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #e4e8eb;
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 800;
  line-height: 1;
}
.external-link-button:hover { background: #d2d8dd; }
.bom-item-link[hidden] { display: none; }
.tracking-form { display: flex; align-items: end; gap: 8px; flex-wrap: wrap; margin: 12px 0; }
.tracking-form label { flex: 1 1 320px; }
.order-status-form { display: flex; align-items: end; gap: 8px; }
.order-status-form select { min-width: 140px; }
.order-title-row { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px 20px; margin-bottom: 14px; }
.order-title-row .order-company, .order-title-row .order-meta { margin: 0; }
.order-details { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 18px; max-width: 960px; }
.order-details > p { margin: 0; font-size: 14px; }
.order-details .tracking-form { grid-column: 1 / -1; margin: 0 0 8px; max-width: 680px; }
.order-controls { display: flex; align-items: end; gap: 8px; flex-wrap: wrap; padding: 12px 0; margin: 12px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.order-controls form { margin: 0; }
.order-controls .form.inline { gap: 8px; }
.order-controls .form.inline > input { width: 180px; }
.order-support-layout { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.order-support-layout > .panel { min-width: 0; }
.order-history-panel .history-note-form { grid-template-columns: minmax(0, 1fr); align-items: start; }
.order-history-panel .history-note-form button { justify-self: start; }
.order-support-layout input[type="file"] { min-width: 0; max-width: 100%; }
.form.assembly-create-form { display: grid; grid-template-columns: minmax(0, 560px) 120px auto; align-items: end; justify-content: start; }
.assembly-create-form > button { align-self: end; }
.order-line-notes { margin-top: 5px; white-space: normal; font-size: 13px; }
.document-heading { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; margin-bottom: 14px; }
.document-heading h2 { margin: 0; }
.document-status { margin: 0 0 14px; }
.inventory-document { padding: 14px; }
.inventory-document .document-heading { margin-bottom: 8px; }
.document-metadata { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 20px; padding-bottom: 10px; border-bottom: 1px solid var(--line); font-size: 13px; }
.document-created-by, .document-creator { display: inline-flex; align-items: center; gap: 7px; min-width: 0; }
.document-creator > span:last-child { overflow-wrap: anywhere; }
.document-created-by { flex-wrap: wrap; }
.document-metadata time { color: var(--ink); }
.document-route { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 16px; padding: 8px 12px; margin-bottom: 10px; background: #f2f6f7; border: 1px solid var(--line); border-radius: 6px; font-size: 14px; overflow-wrap: anywhere; }
.document-route strong { margin-right: 5px; }
.document-notes { display: flex; align-items: baseline; gap: 12px; font-size: 14px; margin-bottom: 10px; }
.document-notes > p { margin: 0; overflow-wrap: anywhere; min-width: 0; }
.inventory-document th, .inventory-document td, .inventory-document-list th, .inventory-document-list td { padding: 7px 8px; }
.inventory-document table th:not(:first-child), .inventory-document table td:not(:first-child) { text-align: right; width: 120px; }
.inventory-document .form { gap: 10px; }
.inventory-document-list .document-creator { max-width: 200px; }
.item-summary-heading h2 { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 0 0 12px; min-width: 0; overflow-wrap: anywhere; }
.item-summary-name { font-weight: 500; }
.item-summary-bar { display: flex; align-items: center; flex-wrap: wrap; gap: 12px 24px; }
.item-summary-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; min-width: 0; }
.item-clone-form, .item-clone-form label { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.item-clone-form { margin: 0; }
.item-archive-form { margin: 0; }
.item-clone-form input { width: 150px; }
.item-eol-control { white-space: nowrap; margin: 0; height: 34px; box-sizing: border-box; padding: 0 10px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.item-basics > .item-eol-control { align-self: end; }
.wo-flags { display: flex; gap: 8px; margin: 0; }
.actions.assembly-quantity-controls { align-items: flex-end; }
.repair-form .repair-markup { max-width: 200px; }
.wo-markup { max-width: 200px; }
.wo-markup-form { margin: 14px 0; }
.wo-parts-section { margin-top: 20px; padding: 16px; background: #f5f7fa; border: 1px solid var(--line); border-radius: 8px; }
.wo-parts-section[hidden] { display: none; }
.wo-parts-heading th { background: #f5f7fa; padding-top: 16px; }
.repair-parts-table input { max-width: 110px; }
.order-items-table .repair-indent { padding-left: 30px; }
.wo-line.repair-wo-line { grid-template-columns: minmax(180px, 2fr) 70px 70px 90px minmax(100px, 1fr) minmax(120px, 1fr) 48px 38px; }
@media (max-width: 1100px) { .wo-line.repair-wo-line { grid-template-columns: minmax(0,2fr) 60px 55px 80px minmax(0,1fr) minmax(0,1fr) 40px 34px; } }
@media (max-width: 700px) { .wo-line.repair-wo-line { grid-template-columns: 1fr; } }
@media print {
  .repair-print-sheet { break-after: page; page-break-after: always; }
  .repair-print-sheet:last-child { break-after: auto; page-break-after: auto; }
}
.item-summary-metrics { display: flex; justify-content: end; flex-wrap: wrap; gap: 8px; margin-left: auto; }
.item-summary-metrics > div { display: grid; gap: 4px; text-align: right; padding: 8px 12px; min-width: 120px; border: 1px solid var(--line); border-radius: 8px; background: #f7f9fa; }
.item-summary-metrics span { font-size: 12px; font-weight: 600; }
.item-summary-metrics strong { font-size: 20px; }
.bom-version-footer { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 14px; border-top: 1px solid var(--line); padding-top: 12px; margin-top: 14px; }
.bom-version-badge { background: #e7eef1; color: #294653; padding: 6px 10px; border-radius: 6px; font-size: 13px; font-weight: 700; }
.bom-version-meta { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; font-size: 13px; min-width: 0; overflow-wrap: anywhere; }
.bom-version-footer > a { margin-left: auto; }
.mobile-nav-bar, .menu-close, .nav-backdrop { display: none; }
.button.dashboard-order-button { border-radius: 999px; background: #842735; color: #fff; padding: 7px 16px; }
.button.dashboard-order-button:hover { background: #651d28; }
main:has(> .dashboard-footer) { display: flex; flex-direction: column; }
.dashboard-footer { margin-top: auto; padding-top: 16px; text-align: right; }
.dashboard-footer a { color: #59656d; font-size: 12px; }
.dashboard-footer a:hover { color: var(--ink); text-decoration: underline; }
.git-log-table td { vertical-align: top; }
.git-log-table td:first-child { width: 170px; }
.git-log-message { white-space: pre-wrap; overflow-wrap: anywhere; }
.git-log-panel > .git-log-count { grid-column: 1; grid-row: 2; margin: 0 0 12px; padding: 0; text-align: left; font-size: 13px; }
.server-filtered.git-log-panel > .pagination-top { justify-self: end; }
.git-log-panel > .pagination:not(.pagination-top) { justify-content: flex-end; }
.author-attribution { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; font-size: 13px; margin-bottom: 12px; }
.line.transfer-line { grid-template-columns: minmax(0, 560px) 120px 34px; align-items: end; margin-bottom: 10px; }
.transfer-line > button { padding: 0; }
.assembly-product-picker { position: relative; min-width: 0; }
.assembly-product-picker .suggestions { top: 100%; left: 0; width: 100%; }
@media (max-width: 700px) {
  .order-support-layout, .order-details { grid-template-columns: minmax(0, 1fr); }
  .form.assembly-create-form { grid-template-columns: minmax(0, 1fr); }
  .assembly-create-form > button { justify-self: start; }
  .line.transfer-line { grid-template-columns: minmax(0, 1fr) 90px 34px; }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  min-height: 100vh;
}

a {
  color: var(--accent-dark);
  text-decoration: none;
}

.nav {
  position: sticky;
  top: 0;
  height: 100vh;
  background: #23313a;
  color: #fff;
  padding: 0;
  display: flex;
  flex-direction: column;
}

.brand {
  display: grid;
  gap: 8px;
  margin: 4px 10px 20px;
}

.brand img {
  display: block;
  width: 100%;
  max-width: 200px;
  height: auto;
}

.brand span {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0;
}

.nav a {
  display: block;
  color: #d8e4e8;
  padding: 5px 12px;
  border-radius: 0;
  margin: 2px 0;
  font-weight: 400;
}

.nav a.active,
.nav a:hover {
  background: #38505c;
  color: #fff;
}

.nav a.active {
  font-weight: 800;
}

.nav-account {
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  margin-top: auto;
  padding-top: 8px;
}

.nav-account form {
  padding: 5px 12px;
}

.nav-user {
  display: flex !important;
  align-items: center;
  gap: 9px;
}

.nav-user span:last-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-account button {
  width: 100%;
}

main {
  padding: 24px;
  min-width: 0;
}

.auth-page {
  display: block;
}

.auth-main {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.panel.auth-panel {
  width: min(420px, 100%);
  background: #444;
  border-color: #555;
  color: #fff;
}

.auth-panel label {
  color: #ccc;
}

.auth-panel .login-button {
  width: 100%;
  justify-self: stretch;
  background: var(--accent);
  color: #fff;
  font-size: inherit;
  font-weight: 800;
  padding: 10px 14px;
  min-height: 39px;
}

.auth-panel .login-button:hover {
  background: var(--accent-dark);
}

.auth-title {
  color: #fff;
  font-size: 42px;
  font-weight: 200;
  letter-spacing: 0;
  text-align: center;
  margin-bottom: 16px;
}

.auth-logo {
  display: block;
  width: min(260px, 100%);
  height: auto;
  margin: 0 auto 24px;
}

.danger-message {
  background: var(--danger);
  border: 1px solid #f4b4b4;
  color: #8a1f1f;
  padding: 10px 12px;
  margin: 0 0 14px;
}

.danger-message.inline-message {
  display: inline-block;
  padding: 3px 6px;
  margin: 0;
}

.cogs-total {
  font-size: 28px;
}

.top {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}
.page-heading, .page-heading-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; min-width: 0; }
.page-heading { flex: 1; }
.page-heading h1 { overflow-wrap: anywhere; }

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.2;
}

h1 {
  font-size: 28px;
}

h2 {
  font-size: 18px;
  margin-bottom: 14px;
}

h3 {
  font-size: 15px;
  margin: 18px 0 10px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 18px;
  box-shadow: 0 3px 14px rgba(20, 30, 40, 0.04);
}

.panel.danger {
  background: var(--danger);
}

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

.columns.wide {
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 0.8fr);
}

.columns > *,
.columns.wide > * {
  min-width: 0;
}

.stack {
  display: grid;
  gap: 18px;
  align-content: start;
}

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

.metrics div {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.metrics span {
  color: var(--muted);
  display: block;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 8px;
}

.metrics strong {
  font-size: 28px;
}

.form {
  display: grid;
  gap: 10px;
}
.form > button { justify-self: start; }
.form > label, .form > textarea, .form > .order-party-picker { max-width: 680px; }
.form-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; width: 100%; max-width: 760px; align-items: start; }
.form-field-wide, .form-fields > fieldset { grid-column: 1 / -1; }
.detail-form-panel { max-width: 800px; }
.item-basics { padding: 14px; border: 1px solid var(--line); border-radius: 10px; background: #fbfcfd; }
.item-details-layout { display: grid; grid-template-columns: minmax(0, 760px); gap: 20px; align-items: start; min-width: 0; }
.item-details-layout.has-photo { grid-template-columns: minmax(0, 760px) minmax(180px, 400px); }
.item-detail-photo { padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
.item-detail-photo .item-image-trigger { width: 100%; margin: 0; }
.item-detail-photo .item-image { width: 100%; max-width: 100%; max-height: 400px; margin: 0; border: 0; }
.item-detail-stack > .panel { padding: 0; background: transparent; border: 0; box-shadow: none; }
.item-detail-stack > .panel > .split { max-width: 760px; }
.item-detail-stack .item-basics { background: var(--panel); box-shadow: 0 3px 14px rgba(20, 30, 40, 0.04); }
.item-detail-stack .item-components { padding: 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); box-shadow: 0 3px 14px rgba(20, 30, 40, 0.04); }
.item-components { margin-top: 8px; min-width: 0; }
.item-components > h3:first-child { margin-top: 0; }
.order-fields { max-width: 960px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.order-fields > label:has(textarea) { grid-column: span 2; }
.order-fields > .check { align-self: center; }
.assembly-work-order-picker { max-width: 760px; }
.form.inline > label { flex: 0 1 280px; }
.metrics { grid-template-columns: repeat(auto-fit, minmax(180px, 260px)); }

.form > *,
.line > * {
  min-width: 0;
}

.form.inline {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
}

.form.compact {
  gap: 10px;
}

label {
  display: grid;
  gap: 5px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  text-transform: none;
}

input,
select,
textarea,
button,
.button {
  font: inherit;
  border-radius: 6px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  padding: 7px 10px;
  font-size: 14px;
  font-weight: 400;
  min-width: 0;
}

textarea {
  min-height: 82px;
  resize: vertical;
}

button,
.button {
  border: 0;
  background: #334b58;
  color: #fff;
  font-weight: 600;
  font-size: 13px;
  padding: 7px 11px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
}

button:hover,
.button:hover {
  background: #233844;
}

button:disabled {
  background: #c8d0d5;
  color: #59656d;
  cursor: not-allowed;
}

button.secondary,
.button.secondary {
  background: #e6ecef;
  color: var(--ink);
}

button.secondary:hover,
.button.secondary:hover {
  background: #d5e0e5;
}

button.danger-button {
  background: #b42318;
}

button.danger-button:hover {
  background: #8f1b13;
}

.delete-assembly-form {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.linked-assemblies {
  min-width: 150px;
  line-height: 1.8;
}

.button.small {
  padding: 6px 9px;
  min-height: 0;
  font-size: 13px;
}

button.small {
  padding: 6px 9px;
  min-height: 0;
  font-size: 13px;
}

.toolbar,
.actions,
.split {
  display: flex;
  gap: 12px;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.actions {
  justify-content: flex-start;
  margin-top: 14px;
  flex-wrap: wrap;
}

.toolbar.product-actions {
  justify-content: flex-start;
  flex-wrap: wrap;
}

.actions.no-margin {
  margin: 0;
}

.quick-search {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0;
  position: relative;
  width: min(360px, 100%);
  flex: 0 1 360px;
}
.quick-search input { border-radius: 6px 0 0 6px; }
.quick-search button { border-radius: 0 6px 6px 0; padding-inline: 10px; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid #326f85; outline-offset: 1px; }
button:focus-visible, .button:focus-visible { outline: 2px solid #326f85; outline-offset: 3px; }
.server-filtered { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 16px; align-items: center; }
.server-filtered > * { grid-column: 1 / -1; min-width: 0; }
.server-filtered > .list-filter, .server-filtered > .po-list-filter-row { grid-column: 1; grid-row: 2; margin: 0 0 12px; }
.server-filtered > .pagination-top { grid-column: 2; grid-row: 2; justify-self: end; margin: 0 0 12px; font-size: 13px; white-space: nowrap; }
.server-filtered > h2 { grid-row: 1; }
.server-filtered > .list-actions { grid-row: 1; margin-bottom: 12px; }
.server-filtered > .po-status-filters { grid-row: 3; }
.server-filtered > table, .server-filtered > .table-scroll { grid-row: 4; }
.server-filtered > .pagination:not(.pagination-top) { grid-row: 5; font-size: 13px; }

.list-filter {
  display: grid;
  grid-template-columns: auto minmax(180px, 360px);
  align-items: center;
  justify-content: start;
  gap: 10px;
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 13px;
}

.list-filter input {
  width: min(360px, 100%);
}

.po-list-filter-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.po-list-filter-row .list-filter {
  margin: 0;
}

.po-selected-summary {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 38px;
  padding: 7px 11px;
  border: 1px solid var(--line);
  background: #f8fafb;
  color: var(--muted);
  font-size: 13px;
}

.po-selected-summary[hidden] {
  display: none;
}

.po-selected-summary strong {
  color: var(--ink);
  font-size: 14px;
}

.po-bulk-approve-form { margin: 0; }
.po-bulk-approve-form button[hidden] { display: none; }

.po-status-filters {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.po-status-filters .button.active {
  background: var(--accent);
  color: #fff;
}

.po-select-column {
  width: 42px;
  text-align: center;
}

.po-select-column input {
  width: 18px;
  height: 18px;
  margin: 0;
  vertical-align: middle;
}

.server-filtered.filter-loading table,
.server-filtered.filter-loading .list-row,
.server-filtered.filter-loading .pagination {
  opacity: 0.55;
}

.order-party-picker {
  position: relative;
  max-width: 620px;
}

.suggestions.party-suggestions {
  top: calc(100% + 4px);
  right: 0;
  max-height: 320px;
  overflow-y: auto;
}

.assembly-work-order-picker {
  position: relative;
  max-width: 820px;
}

.suggestions.assembly-work-order-suggestions {
  top: calc(100% + 4px);
  right: 0;
  max-height: 320px;
  overflow-y: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th,
td {
  padding: 9px 8px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
}

button.sort-button,
a.sort-button {
  min-height: 24px;
  margin: -4px 0;
  padding: 4px 2px;
  border-radius: 3px;
  background: transparent;
  color: inherit;
  font-size: inherit;
  font-weight: inherit;
  line-height: 1.2;
  text-align: left;
  text-transform: inherit;
  white-space: nowrap;
}

button.sort-button:hover,
a.sort-button:hover {
  background: #edf1f3;
  color: var(--ink);
}

button.sort-button:focus-visible,
a.sort-button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.sort-indicator {
  display: inline-block;
  width: 13px;
  margin-left: 5px;
  color: var(--muted);
  font-size: 10px;
  text-align: center;
}

tr.short,
.wo-line.short,
.warning {
  background: var(--short);
}

tr.total {
  background: #fff;
  font-weight: 800;
}

.muted {
  color: var(--muted);
}

.stock-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border: 1px solid var(--line);
  background: #f8fafb;
  padding: 14px 16px;
  margin-bottom: 14px;
}

.stock-banner span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.stock-banner strong {
  font-size: 32px;
}

.subline {
  display: block;
  color: var(--muted);
  margin-top: 2px;
}

.item-thumbnail {
  display: block;
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  overflow: hidden;
  background: #fff;
  border: 1px solid var(--line);
}

.item-thumbnail img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.item-list-table .item-thumbnail {
  position: relative;
  overflow: visible;
}

.item-list-table .item-thumbnail img {
  position: relative;
  z-index: 1;
  transition: width 120ms ease, height 120ms ease, box-shadow 120ms ease;
}

.item-list-table .item-thumbnail:hover img {
  position: absolute;
  top: 0;
  left: 0;
  width: 256px;
  height: 256px;
  max-width: none;
  z-index: 20;
  background: #fff;
  box-shadow: 0 8px 24px rgba(20, 30, 40, 0.28);
  object-fit: contain;
}

.item-thumbnail-link {
  display: inline-block;
}

.item-thumbnail-link .item-thumbnail {
  border: 0;
}

.image-column {
  width: 60px;
}

.badge {
  display: inline-flex;
  align-items: center;
  background: #f0f1f3;
  color: #444;
  border: 1px solid var(--line);
  font-size: 11px;
  font-weight: 800;
  padding: 2px 6px;
  margin-left: 6px;
}

.supplier-order-group {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.availability-row {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) repeat(4, minmax(90px, auto));
  align-items: center;
  gap: 10px;
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
}

.availability-row.short {
  background: var(--short);
}

.availability-row span,
.availability-row strong {
  min-width: 0;
}

.generate-po-form {
  display: grid;
  gap: 10px;
}

.generate-po-form .split {
  margin-bottom: 0;
}

.po-total-row {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 16px;
  padding: 10px 8px 0;
  font-weight: 800;
}

.supplier-order-group[hidden],
.no-po-required[hidden],
.alternate-suppliers[hidden] {
  display: none;
}

.list-row,
.result {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
}

.archive-entry[hidden],
.archive-expand[hidden] {
  display: none;
}

.archive-expand {
  margin-top: 12px;
}

.action-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
}

.action-row > a,
.action-row span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.action-row button,
.action-row .button {
  max-width: 100%;
  white-space: normal;
}

.dashboard-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.dashboard-panel {
  --dashboard-accent: #be4836;
  --dashboard-tint: #fff0eb;
  display: flex;
  flex-direction: column;
  min-width: 0;
  margin: 0;
  padding: 14px;
  border-radius: 12px;
  border-top: 3px solid var(--dashboard-accent);
  box-shadow: 0 3px 14px rgba(20, 30, 40, 0.04);
}
.dashboard-stage-1, .dashboard-stage-2 { --dashboard-accent: #846133; --dashboard-tint: #fbf4e8; }
.dashboard-stage-3 { --dashboard-accent: #326f85; --dashboard-tint: #eaf5f8; }
.dashboard-stage-4 { --dashboard-accent: #536989; --dashboard-tint: #edf1f8; }
.dashboard-stage-5 { --dashboard-accent: #54765a; --dashboard-tint: #edf5ee; }
.dashboard-card-heading { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; }
.dashboard-card-heading > div { min-width: 0; }
.dashboard-icon { display: grid; place-items: center; flex: 0 0 36px; height: 36px; border-radius: 10px; background: var(--dashboard-tint); color: var(--dashboard-accent); }
.dashboard-icon svg { width: 20px; height: 20px; }
.dashboard-category { margin: 0 0 4px; color: var(--dashboard-accent); font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.08em; }
.dashboard-card-heading h2 { font-size: 17px; line-height: 1.35; margin: 0; }
.dashboard-card-heading h2 a { color: var(--ink); text-decoration: none; }
.dashboard-card-heading h2 a:hover { color: var(--dashboard-accent); text-decoration: underline; }
.dashboard-card-items { flex: 1; min-height: 0; }
.dashboard-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 4px; border-radius: 6px; color: var(--ink); text-decoration: none; }
.dashboard-item + .dashboard-item { border-top: 1px solid var(--line); }
.dashboard-item:hover { background: var(--dashboard-tint); }
.dashboard-item > span:first-child { min-width: 0; overflow-wrap: anywhere; }
.dashboard-item strong { display: block; font-size: 14px; }
.dashboard-item small { display: block; color: var(--muted); margin-top: 3px; font-size: 12px; }
.dashboard-item-inline > span:first-child { display: flex; align-items: baseline; gap: 10px; }
.dashboard-item-inline strong { flex-shrink: 0; }
.dashboard-item-inline small { font-size: 14px; font-weight: 400; margin-top: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dashboard-item-arrow { color: var(--dashboard-accent); font-size: 24px; }
.dashboard-empty { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 13px; padding: 8px 4px; margin: 0; }
.dashboard-empty > span { color: #54765a; }
.dashboard-panel .dashboard-more { display: flex; justify-content: space-between; gap: 10px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); font-size: 13px; font-weight: 700; color: var(--dashboard-accent); text-decoration: none; }
.dashboard-panel .dashboard-more:hover { text-decoration: underline; }
.dashboard-panel a:focus-visible { outline: 2px solid var(--dashboard-accent); outline-offset: 3px; }
@media (max-width: 1100px) { .dashboard-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 700px) { .dashboard-grid { grid-template-columns: 1fr; gap: 12px; } .dashboard-panel { padding: 12px; } }

.pagination {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 14px;
}

.pagination-top {
  margin: 0 0 14px;
}

.product-category-selector {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 18px;
  margin: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
}

.product-category-selector legend {
  padding: 0 5px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.product-category-selector label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin: 0;
}

.product-category-selector input {
  width: auto;
  margin: 0;
}

.list-row span,
.result span {
  display: grid;
  gap: 2px;
}

.list-row em,
.result b {
  color: var(--muted);
  font-style: normal;
  font-size: 13px;
  text-align: right;
}

.order-company {
  margin: 5px 0;
  font-size: 20px;
  font-weight: 800;
}

.order-meta {
  margin: 0;
  color: var(--muted);
}

.status-history-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 180px minmax(0, 1fr);
}

.status-history-row b {
  text-align: left;
}

.status-history-row em {
  justify-self: end;
}

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

.history-feed {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 420px;
  padding: 14px;
  overflow-y: auto;
  border: 1px solid var(--line);
  background: #f7f9fa;
  scroll-behavior: smooth;
}

.history-entry {
  flex-shrink: 0;
  max-width: min(680px, 88%);
  padding: 9px 12px;
}

.history-note {
  border-left: 3px solid var(--accent);
  border-radius: 4px;
  background: #fff;
}

.history-status {
  align-self: center;
  padding: 3px 10px;
  text-align: center;
}

.history-status .history-message {
  font-weight: 500;
}

.history-message {
  line-height: 1.45;
}

.history-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.history-status .history-meta {
  justify-content: center;
}

.order-history-panel .history-event {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 100%;
  white-space: nowrap;
  overflow-x: auto;
  text-align: left;
}

.history-event .history-message,
.history-event .history-meta {
  flex: 0 0 auto;
}

.history-event .history-meta {
  margin-top: 0;
}

.user-avatar {
  --avatar-colour: #53606c;
  display: inline-flex;
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: 50%;
  background: var(--avatar-colour);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
}

.user-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.user-avatar.small {
  width: 30px;
  height: 30px;
  flex-basis: 30px;
  font-size: 11px;
}

.user-avatar.tiny {
  width: 22px;
  height: 22px;
  flex-basis: 22px;
  font-size: 9px;
}

.user-avatar.large {
  width: 88px;
  height: 88px;
  flex-basis: 88px;
  font-size: 26px;
}

.profile-form {
  grid-template-columns: auto repeat(2, minmax(160px, 1fr));
  align-items: end;
}

.profile-avatar {
  grid-row: span 2;
  align-self: center;
}

.user-cell {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 220px;
}

.user-cell span:last-child {
  display: grid;
  gap: 2px;
}

.user-cell small {
  color: var(--muted);
  font-size: 12px;
}

.history-note-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 10px;
}

.history-note-form textarea {
  min-height: 74px;
}

.print-page {
  display: block;
  min-height: 100vh;
  background: #e9edf0;
}

.print-sheet {
  width: min(900px, calc(100% - 32px));
  min-height: 1120px;
  margin: 24px auto;
  padding: 48px 64px;
  background: #fff;
  box-shadow: 0 4px 24px rgba(20, 30, 40, 0.14);
}

.print-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-bottom: 30px;
}

.print-document-header {
  display: flex;
  justify-content: space-between;
  gap: 32px;
  align-items: start;
  padding-bottom: 24px;
  border-bottom: 3px solid var(--ink);
}

.print-brand {
  display: block;
  width: 220px;
  max-width: 45%;
  height: auto;
}

.print-title {
  text-align: right;
}

.print-title span,
.print-details span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.print-title h1 {
  margin: 3px 0;
  font-size: 27px;
}

.print-details {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px 40px;
  padding: 24px 0;
}

.print-details strong {
  display: block;
  margin-top: 3px;
  font-size: 15px;
}

.print-detail-wide {
  grid-column: 1 / -1;
}

.order-delivery-address {
  line-height: 1.5;
}

.print-lines th,
.print-lines td {
  padding: 10px 8px;
  vertical-align: top;
}

.print-lines small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
}

.print-check-column {
  width: 38px;
  text-align: center;
}

.print-checkbox {
  width: 18px;
  height: 18px;
  margin: 1px 0 0;
  padding: 0;
  accent-color: var(--ink);
  cursor: pointer;
}

.numeric {
  text-align: right;
  white-space: nowrap;
}

.print-notes {
  margin-top: 32px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.print-notes p {
  white-space: normal;
}
.repair-print-sheet .print-document-header { gap: 20px; padding-bottom: 12px; border-bottom-width: 2px; }
.repair-print-sheet .print-brand { width: 175px; }
.repair-print-sheet .print-title h1 { font-size: 24px; }
.repair-print-sheet .print-details { gap: 9px 24px; padding: 12px 0; }
.repair-print-sheet .print-details strong { font-size: 14px; margin-top: 2px; }
.repair-print-sheet > h2 { font-size: 17px; margin: 10px 0 8px; }
.repair-print-sheet .print-notes { margin-top: 14px; padding-top: 10px; }
.repair-print-sheet .print-notes h2 { font-size: 17px; margin: 0 0 8px; }
.repair-print-sheet .print-note-lines span { min-height: 24px; }
.repair-print-sheet .print-notes[hidden], .repair-print-sheet .print-note-lines span[hidden] { display: none; }
.print-note { break-inside: avoid; }
.print-note .author-attribution { margin-bottom: 4px; }

.print-note-lines {
  display: grid;
  gap: 0;
  margin-top: 8px;
}

.print-note-lines span {
  display: block;
  min-height: 32px;
  border-bottom: 1px solid var(--line);
}

.print-footer {
  display: flex;
  justify-content: space-between;
  margin-top: 50px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
}

@media screen and (max-width: 700px) {
  .print-sheet {
    width: 100%;
    min-height: 100vh;
    margin: 0;
    padding: 24px 16px;
    overflow-x: auto;
    box-shadow: none;
  }

  .print-document-header {
    gap: 16px;
  }

  .print-details {
    grid-template-columns: 1fr;
  }
}

@media print {
  @page { size: A4 portrait; margin: 12mm 20mm; }
  .print-page { background: #fff; }
  .print-sheet { width: auto; min-height: 0; margin: 0; padding: 0; box-shadow: none; }
  .print-sheet.repair-print-sheet { width: 170mm; }
  .print-actions { display: none; }
  .print-lines tr { break-inside: avoid; }
  .print-page .user-avatar { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  .print-footer { position: fixed; right: 0; bottom: 0; left: 0; }
}

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

.result {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.line-editor {
  display: grid;
  gap: 8px;
}

.line {
  display: grid;
  grid-template-columns: minmax(200px, 1.5fr) repeat(4, minmax(100px, 1fr));
  gap: 8px;
  align-items: center;
}

.supplier-lines .line {
  grid-template-columns: minmax(180px, 1.3fr) minmax(110px, 1fr) 90px 90px 86px minmax(120px, 1fr);
}

.bom-lines .line,
.cost-lines .line {
  grid-template-columns: minmax(220px, 1.5fr) 120px minmax(160px, 1fr);
}

.line-head,
.po-head,
.wo-head,
.bom-head {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.check {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
  text-transform: none;
  font-size: 13px;
}

.check input {
  width: auto;
  flex: 0 0 auto;
  margin: 0;
}

.family-options { display: grid; gap: 10px; }
.family-member-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 14px; }
.family-member-filters .list-filter { margin: 0; }
.family-options label.check { display: flex; align-items: center; gap: 8px; text-transform: none; font-size: 14px; }
.family-members input[type="checkbox"] { width: auto; }
.family-members input[type="number"] { min-width: 85px; max-width: 130px; }
.family-variant-selectors, .family-member-mapping { display: flex; flex-wrap: wrap; gap: 12px; margin: 12px 0; }
.family-variant-selectors label { flex: 1; min-width: 180px; }
.family-variant-preview { padding: 14px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); }
.family-variant-order { display: grid; gap: 12px; }
.family-cart-qty { max-width: 110px; }
.family-cart-message { color: var(--accent-dark); }

/* Compact desktop workspace, scoped to the family Order Form. */
.family-order-switch { padding: 12px 16px; }
.family-order-switch .form { gap: 10px; }
.family-order-switch select { min-width: 250px; }
.family-order-form { grid-template-columns: minmax(240px, 300px) minmax(0, 1fr); align-items: start; gap: 16px; }
.family-order-form .panel { margin: 0; padding: 16px; min-width: 0; }
.family-order-form h2 { font-size: 20px; margin: 0 0 12px; }
.family-order-form h3 { font-size: 15px; margin: 0 0 12px; }
.family-order-sidebar { grid-column: 1; grid-row: 1 / span 2; display: grid; gap: 16px; min-width: 0; }
.family-order-overview p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
.family-order-form .family-order-overview .family-image { max-width: 100%; max-height: 200px; }
.family-order-customer { display: grid; gap: 12px; }
.family-order-form .family-variant-order { grid-column: 2; display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.family-order-variant, .family-order-instructions { display: grid; gap: 12px; }
.family-order-form .family-variant-selectors { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin: 0; }
.family-order-form .family-variant-selectors label { min-width: 0; }
.family-order-form .family-variant-preview { padding: 12px; font-size: 13px; line-height: 1.5; }
.family-order-hint { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.family-order-form .family-options { gap: 12px; }
.family-order-form .family-options label.check { font-size: 13px; font-weight: 600; align-items: start; }
.family-order-form .family-options input { flex: 0 0 auto; margin-top: 3px; }
.family-order-add { align-items: end; gap: 10px; }
.family-order-add .family-variant-qty, .family-order-add .family-accessory-qty { max-width: 95px; }
.family-order-cart { grid-column: 1 / -1; }
.family-order-cart .family-order-hint { margin-bottom: 10px; }
.family-order-cart .family-cart-message:empty { display: none; }
.family-order-cart th, .family-order-cart td { padding: 8px; font-size: 13px; }
.family-order-cart th { font-size: 11px; }
.family-order-cart table { margin-bottom: 0; }
.family-order-cart .family-cart-qty { width: 85px; max-width: 100%; }
.family-cart-product { display: flex; align-items: center; gap: 10px; }
.family-cart-product .item-thumbnail { flex: 0 0 48px; }
.family-cart-product small { display: block; color: var(--muted); line-height: 1.4; }
.family-order-products, .family-order-submit { grid-column: 2; }
.family-order-submit { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 16px; }
.family-order-submit textarea { min-height: 62px; }
@media (max-width: 1100px) {
  .family-order-form { grid-template-columns: minmax(0, 1fr); }
  .family-order-sidebar { grid-column: 1; grid-row: auto; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .family-order-form .family-variant-order, .family-order-products, .family-order-submit { grid-column: 1; }
}
@media (max-width: 700px) {
  .item-details-layout.has-photo { grid-template-columns: minmax(0, 1fr); }
  .family-order-sidebar, .family-order-form .family-variant-order, .family-order-submit { grid-template-columns: minmax(0, 1fr); }
  .family-order-switch select { min-width: 0; }
  .family-order-switch label { flex: 1; }
  .family-order-submit button { justify-content: center; }
}

.po-line {
  display: grid;
  grid-template-columns: minmax(180px, 2fr) minmax(100px, 1fr) 85px 100px 85px 95px 48px 38px;
  gap: 8px;
  margin-bottom: 8px;
  position: relative;
}
.po-line-gst, .po-line-total { align-self: center; }
.po-no-gst .po-line-gst { display: none; }
.po-no-gst .po-line { grid-template-columns: minmax(180px, 2fr) minmax(100px, 1fr) 85px 100px 95px 48px 38px; }
.po-edit-totals { display: flex; justify-content: flex-end; gap: 24px; flex-wrap: wrap; padding-top: 12px; border-top: 1px solid var(--line); }
.po-edit-totals strong { margin-left: 8px; }

.wo-line {
  display: grid;
  grid-template-columns: minmax(240px, 2fr) 90px 90px 120px minmax(150px, 1fr) 48px 38px;
  gap: 8px;
  margin-bottom: 8px;
  position: relative;
}

.line-rd { align-self: center; justify-content: center; }

.wo-stock {
  align-self: center;
  color: var(--muted);
  padding: 0 8px;
}

.bom-line {
  display: grid;
  grid-template-columns: minmax(240px, 2fr) 120px minmax(160px, 1fr) 38px;
  gap: 8px;
  margin-bottom: 8px;
  position: relative;
}

.stock-adjust-line {
  display: grid;
  grid-template-columns: minmax(260px, 2fr) 150px 130px 38px;
  gap: 8px;
  margin-bottom: 8px;
  position: relative;
}

.stock-adjust-line.adjustment-with-availability {
  grid-template-columns: minmax(220px, 2fr) 90px 90px 130px 120px 38px;
}

.adjustment-stock,
.adjustment-available {
  align-self: center;
  color: var(--muted);
  padding: 0 8px;
}

.detail-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 0 0 18px;
}

.detail-list div {
  border-bottom: 1px solid var(--line);
  padding: 8px 0;
}

.detail-list dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.detail-list dd {
  margin: 5px 0 0;
}

.item-image {
  display: block;
  width: auto;
  max-width: min(100%, 220px);
  height: auto;
  max-height: 180px;
  margin: 0 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  object-fit: contain;
  background: #fff;
}

.item-image-trigger {
  display: block;
  width: fit-content;
  min-height: 0;
  margin-bottom: 14px;
  padding: 0;
  background: transparent;
}

.item-image-trigger:hover {
  background: transparent;
}

.item-image-trigger .item-image {
  margin: 0;
  cursor: pointer;
}

.item-image.family-image { max-width: min(100%, 480px); max-height: 360px; }

.item-image-dialog {
  box-sizing: border-box;
  width: 94vw;
  height: 94vh;
  max-width: 94vw;
  max-height: 94vh;
  padding: 40px 18px 18px;
  border: 0;
  background: #fff;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.45);
}

.item-image-dialog::backdrop {
  background: rgba(0, 0, 0, 0.78);
}

.item-image-dialog > img {
  display: block;
  width: 100%;
  height: 100%;
  max-height: calc(94vh - 58px);
  object-fit: contain;
  cursor: pointer;
}

.item-image-dialog .item-image-close {
  position: absolute;
  top: 6px;
  right: 8px;
  width: 32px;
  height: 32px;
  min-height: 0;
  padding: 0;
  border-radius: 50%;
  font-size: 24px;
  line-height: 1;
}

.suggestions {
  position: absolute;
  left: 0;
  right: 280px;
  top: 41px;
  z-index: 5;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: 0 10px 24px rgba(20, 30, 40, 0.12);
  overflow: hidden;
}

.top-suggestions {
  left: 0;
  right: 74px;
  max-height: min(70vh, 560px);
  overflow-x: hidden;
  overflow-y: auto;
}

.suggestions button {
  display: block;
  width: 100%;
  background: #fff;
  color: var(--ink);
  border-radius: 0;
  text-align: left;
  justify-content: flex-start;
  font-weight: 400;
}

.suggestions button span {
  margin-left: auto;
  color: var(--muted);
}

.assembly-product-picker {
  align-items: end;
  position: relative;
}

.assembly-product-picker label {
  position: relative;
  flex: 1 1 420px;
}

.assembly-product-suggestions {
  top: calc(100% + 4px);
  right: 0;
}

.alternate-suppliers {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 7px;
}

.alternate-suppliers > span {
  color: var(--muted);
  font-size: 12px;
}

.top-suggestions button {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 56px;
  padding: 6px 8px;
}

.top-suggestions button .item-thumbnail,
.top-suggestions button .top-suggestion-text {
  margin-left: 0;
}

.top-suggestion-text {
  display: grid;
  gap: 2px;
  min-width: 0;
  color: #000;
}

.top-suggestion-text strong {
  font-weight: 500;
}

.top-suggestion-text small {
  color: #000;
  font-size: 14px;
}

.result-copy {
  flex: 1;
  min-width: 0;
}

.result-copy strong {
  font-weight: 500;
}

.result b {
  font-weight: 400;
}

.suggestions button:hover {
  background: #fff1ef;
}

.chart {
  height: 160px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  margin: 10px 0 14px;
}

.chart svg {
  display: block;
  width: 100%;
  height: 100%;
}

.stocktake-row {
  display: grid;
  grid-template-columns: minmax(230px, 1fr) 130px minmax(220px, 0.8fr) 90px;
}

.stocktake-row span strong {
  display: block;
  color: var(--ink);
  margin-top: 4px;
}

.stocktake-counted {
  display: grid;
  grid-template-columns: minmax(230px, 1fr) 95px 95px 120px 90px;
}

.stocktake-counted strong {
  color: var(--ink);
  font-size: 15px;
}

.stocktake-head {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  padding: 8px;
  text-transform: uppercase;
}

.adjust-check {
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
  text-transform: none;
}

.inline-form {
  margin-top: 12px;
}

.user-role-form {
  display: grid;
  grid-template-columns: minmax(110px, 1fr) minmax(110px, 1fr) auto auto;
  align-items: center;
  gap: 8px;
  margin-top: 0;
  white-space: nowrap;
}

.user-role-form select {
  width: auto;
  min-width: 100px;
}

.user-role-form input {
  min-width: 110px;
}

.bom-summary {
  margin-top: 12px;
  overflow-x: auto;
}

@media (max-width: 1200px) {
  .server-filtered > .item-list-table {
    display: block;
    max-width: 100%;
    overflow-x: auto;
  }

  .columns.wide {
    grid-template-columns: 1fr;
  }

  .supplier-editor { min-width: 720px; }
  .wo-line { grid-template-columns: minmax(0, 2fr) 80px 70px 90px minmax(0, 1fr) 40px 34px; gap: 8px; }
  .po-line { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) 70px 80px 70px 80px 40px 34px; gap: 8px; }
  .po-no-gst .po-line { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) 70px 80px 80px 40px 34px; }
}

@media (max-width: 900px) {
  body {
    grid-template-columns: 1fr;
  }

  .nav {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(280px, 85vw);
    height: 100dvh;
    z-index: 50;
    display: none;
    flex-direction: column;
    box-shadow: 8px 0 28px rgba(0, 0, 0, 0.25);
  }
  .mobile-nav-bar { display: flex; align-items: center; justify-content: space-between; background: #23313a; padding: 8px 16px; height: 56px; box-sizing: border-box; position: sticky; top: 0; z-index: 30; }
  .mobile-nav-bar > img { width: 160px; max-width: 65vw; max-height: 38px; object-fit: contain; }
  .menu-toggle, .menu-close { background: transparent; color: #fff; width: 40px; height: 40px; padding: 0; }
  .menu-close { display: flex; align-self: end; margin: 6px 8px 0; font-size: 28px; }
  .menu-open { overflow: hidden; }
  .menu-open .nav { display: flex; }
  .menu-open .nav-backdrop { display: block; position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, 0.45); border-radius: 0; width: 100%; height: 100%; padding: 0; }
  .nav .brand { width: auto; }
  body { display: block; }

  main {
    padding: 16px;
  }

  .top,
  .columns,
  .columns.wide,
  .metrics,
  .grid.three {
    grid-template-columns: 1fr;
    display: grid;
  }

  .detail-list {
    grid-template-columns: 1fr;
  }

  .quick-search,
  .history-note-form,
  .profile-form,
  .user-role-form,
  .line,
  .po-line,
  .wo-line,
  .bom-line,
  .stock-adjust-line,
  .stock-adjust-line.adjustment-with-availability,
  .action-row,
  .stocktake-row {
    grid-template-columns: 1fr;
  }
  .po-no-gst .po-line { grid-template-columns: 1fr; }

  .profile-avatar {
    grid-row: auto;
  }

  .suggestions {
    right: 0;
  }

  h1, h2, h3, .list-row { overflow-wrap: anywhere; }
  .panel, .top, .top > * { min-width: 0; max-width: 100%; }
  .panel table { display: block; max-width: 100%; overflow-x: auto; }
  .table-scroll table { display: table; }
  .toolbar, .split { flex-wrap: wrap; }
  .po-head, .wo-head, .bom-head { display: none; }
  .quick-search { grid-template-columns: minmax(0, 1fr) auto; width: min(360px, 100%); }
  .page-heading { align-items: center; }
  .server-filtered { grid-template-columns: minmax(0, 1fr); }
  .server-filtered > * { grid-column: 1 !important; grid-row: auto !important; }
  .server-filtered > .pagination-top { justify-self: start; white-space: normal; flex-wrap: wrap; }
}
@media (max-width: 700px) {
  .form-fields, .order-fields { grid-template-columns: minmax(0, 1fr); }
  .form-field-wide, .form-fields > fieldset, .order-fields > label:has(textarea) { grid-column: 1; }
  .form.inline > label { flex: 1 1 200px; }
  .item-basics { padding: 12px; }
}
.quantity-stepper {
  display: inline-block;
  position: relative;
  min-width: 0;
  width: 100%;
}
.quantity-stepper input[type="number"] {
  width: 100%;
  padding-right: 28px;
  appearance: textfield;
  -moz-appearance: textfield;
}
.quantity-stepper input::-webkit-inner-spin-button,
.quantity-stepper input::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.quantity-stepper .quantity-step {
  position: absolute;
  right: 1px;
  width: 24px;
  height: 48%;
  min-height: 0;
  padding: 0;
  margin: 0;
  border: 0;
  border-radius: 3px;
  background: #e8edf0;
  color: #37434d;
  line-height: 1;
}
.quantity-stepper .quantity-step:hover { background: #d9e0e6; }
.quantity-stepper .quantity-up { top: 1px; }
.quantity-stepper .quantity-down { bottom: 1px; }
.family-cart-lines .quantity-stepper { width: 85px; }

.files-table td { vertical-align: top; }
.files-table td:first-child { min-width: 180px; max-width: 360px; overflow-wrap: anywhere; }
.files-table td:nth-child(6) { min-width: 150px; overflow-wrap: anywhere; }
.file-delete-form { margin: 0; }

.auth-panel .keep-logged-in { display: flex; flex-direction: row; align-items: center; gap: 8px; text-transform: none; }
.auth-panel .keep-logged-in input { width: auto; margin: 0; }
