:root {
  color-scheme: light;
  --bg: #f6f7f4;
  --panel: #ffffff;
  --panel-soft: #eef3ee;
  --ink: #17211c;
  --muted: #637067;
  --line: #d9dfd8;
  --accent: #176b5b;
  --accent-dark: #0f4d42;
  --warn: #a15c1a;
  --danger: #a53c3c;
  --shadow: 0 18px 45px rgba(23, 33, 28, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

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

button {
  border: 0;
  cursor: pointer;
}

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

.loading {
  align-content: center;
  gap: 14px;
  color: var(--muted);
}

.mark {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  letter-spacing: 0;
}

.auth-card {
  width: min(440px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 28px;
}

.auth-card h1,
.page-title h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.15;
  letter-spacing: 0;
}

.auth-card p,
.page-title p,
.empty p {
  color: var(--muted);
  margin: 8px 0 0;
}

.field {
  display: grid;
  gap: 7px;
  margin-top: 18px;
}

.field label {
  font-size: 13px;
  color: var(--muted);
  font-weight: 700;
}

.field input,
.field select,
.field textarea,
.search input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px 12px;
  color: var(--ink);
  background: #fff;
}

.field input,
.field select,
.search input {
  min-height: 42px;
}

.field textarea {
  min-height: 76px;
  resize: vertical;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.field input:focus,
.field select:focus,
.field textarea:focus,
.search input:focus {
  outline: 3px solid rgba(23, 107, 91, 0.18);
  border-color: var(--accent);
}

.primary,
.secondary,
.nav-button,
.signout {
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 9px 13px;
  font-weight: 750;
}

.primary {
  width: 100%;
  margin-top: 22px;
  color: #fff;
  background: var(--accent);
}

.primary.inline {
  width: auto;
  margin-top: 0;
}

.primary:hover,
.nav-button.active {
  background: var(--accent-dark);
}

.secondary {
  background: #eaf1ed;
  border-color: #c3d1c8;
  color: var(--accent-dark);
}

.secondary:hover {
  background: #dce8e2;
  border-color: var(--accent);
}

.auth-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
}

.auth-actions.stacked {
  justify-content: stretch;
}

.auth-actions.stacked button {
  flex: 1;
}

.message {
  min-height: 22px;
  margin: 14px 0 0;
  color: var(--danger);
}

.message.ok {
  color: var(--accent-dark);
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 244px minmax(0, 1fr);
}

.sidebar {
  min-height: 100vh;
  padding: 20px 16px;
  background: #1b2720;
  color: #eef4ef;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  font-weight: 800;
}

.brand small {
  display: block;
  color: #aebbb2;
  font-weight: 650;
}

.nav {
  display: grid;
  gap: 7px;
}

.user-chip {
  display: grid;
  gap: 4px;
  padding: 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
}

.user-chip strong {
  font-size: 13px;
}

.user-chip span {
  color: #aebbb2;
  font-size: 12px;
  text-transform: capitalize;
}

.nav-button,
.signout {
  text-align: left;
  color: #eef4ef;
  background: transparent;
  border-color: transparent;
}

.nav-button:hover,
.signout:hover {
  background: rgba(255, 255, 255, 0.09);
}

.auth-status-card {
  display: grid;
  gap: 16px;
}

.status-panel {
  display: grid;
  gap: 6px;
  padding: 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel-soft);
}

.status-panel.pending {
  border-color: #d8c48a;
  background: #faf4df;
}

.status-panel.rejected {
  border-color: #d8a6a6;
  background: #fdeeee;
}

.status-panel span {
  color: var(--muted);
}

.filter-inline {
  display: grid;
  gap: 6px;
}

.filters-inline {
  display: flex;
  gap: 12px;
  align-items: end;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  text-transform: capitalize;
}

.status-pill.pending {
  background: #faf4df;
  color: #8a6317;
}

.status-pill.approved {
  background: #e5f4ec;
  color: #176b5b;
}

.status-pill.rejected {
  background: #fdeeee;
  color: #a53c3c;
}

.actions-cell {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.signout {
  margin-top: auto;
}

.content {
  padding: 28px;
  min-width: 0;
}

.topbar,
.summary-grid,
.toolbar {
  display: flex;
  gap: 14px;
}

.topbar {
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 22px;
}

.toolbar {
  display: grid;
  align-items: start;
  margin: 18px 0;
}

.toolbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  flex-wrap: wrap;
}

.po-filter-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  gap: 10px;
  width: 100%;
}

.compact-field {
  margin-top: 0;
}

.compact-field input,
.compact-field select {
  min-height: 38px;
}

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

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  margin-bottom: 20px;
}

.metric,
.data-panel,
.empty {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.metric {
  padding: 16px;
}

.metric span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 27px;
  line-height: 1;
}

.field-reference {
  display: grid;
  gap: 3px;
  margin-top: 8px;
  border: 1px solid #c3d1c8;
  border-radius: 7px;
  background: #eaf1ed;
  padding: 9px 10px;
  color: var(--accent-dark);
  font-size: 13px;
}

.field-reference strong {
  color: var(--ink);
}

.oa-po-summary-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(120px, 0.55fr) minmax(0, 1fr) auto;
  align-items: end;
  gap: 0 12px;
  margin-top: 12px;
}

.oa-header-grid {
  align-items: start;
}

.po-picker-table-wrap {
  max-height: min(520px, 64vh);
  overflow: auto;
}

.inline-edit-cell {
  background: #f8faf7;
  padding: 0;
}

.inline-edit-cell .po-line-form {
  border: 0;
  border-radius: 0;
  margin: 0;
}

.data-panel {
  overflow: hidden;
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 780px;
}

th,
td {
  text-align: left;
  border-bottom: 1px solid var(--line);
  padding: 12px 14px;
  vertical-align: top;
  font-size: 14px;
}

.note-cell {
  display: block;
  max-width: 360px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.date-col {
  min-width: 118px;
  white-space: nowrap;
}

th {
  background: var(--panel-soft);
  color: #364239;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
}

.sort-header {
  appearance: none;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font: inherit;
  font-weight: 800;
  letter-spacing: 0;
  padding: 0;
  text-align: left;
  text-transform: uppercase;
}

.sort-header:hover,
.sort-header.active {
  color: var(--accent);
}

tr:hover td {
  background: #fafbf8;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 9px;
  background: #e9f1ee;
  color: var(--accent-dark);
  font-weight: 750;
  font-size: 12px;
}

.empty {
  padding: 28px;
}

.edit-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
  margin: 0 0 18px;
}

.edit-panel h2 {
  margin: 0;
  font-size: 20px;
  letter-spacing: 0;
}

.edit-panel p {
  margin: 6px 0 0;
  color: var(--muted);
}

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

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

.form-grid-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

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

.span-3 {
  grid-column: span 3;
}

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

.po-form-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  flex-wrap: wrap;
}

.po-general-grid {
  display: grid;
  grid-template-columns: minmax(190px, 1.35fr) minmax(90px, 0.55fr) minmax(120px, 0.7fr) minmax(110px, 0.55fr);
  gap: 0 14px;
}

.form-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfcfa;
}

.section-title {
  margin-bottom: 8px;
  font-weight: 800;
}

.po-two-column {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr);
  gap: 14px;
}

.radio-row {
  display: flex;
  gap: 22px;
  flex-wrap: wrap;
  margin: 4px 0 12px;
}

.radio-row label {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  color: var(--ink);
}

.with-note-button {
  grid-template-columns: minmax(0, 1fr);
  align-items: end;
}

.with-note-button label {
  grid-column: 1 / -1;
}

.with-note-button input,
.with-note-button textarea,
.with-note-button select {
  grid-column: 1;
}

.note-button {
  display: none;
  grid-column: 2;
  width: 34px;
  min-height: 34px;
  padding: 0;
  text-align: center;
}

.tall-textarea {
  min-height: 110px;
}

.extra-tall-textarea {
  min-height: 340px;
}

.po-workspace {
  display: grid;
  gap: 14px;
}

.workspace-head,
.po-detail-head {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
}

.workspace-head {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  justify-content: flex-start;
}

.workspace-head h2,
.po-detail-head h2 {
  margin: 0;
  font-size: 20px;
}

.workspace-head p,
.po-detail-head p {
  margin: 4px 0 0;
  color: var(--muted);
}

.workspace-tabs {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--line);
}

.workspace-tabs button {
  min-height: 40px;
  padding: 8px 14px;
  background: transparent;
  color: var(--muted);
  border-radius: 7px 7px 0 0;
  font-weight: 800;
}

.workspace-tabs button.active {
  color: #fff;
  background: var(--accent);
}

.workspace-panel {
  display: none;
}

.workspace-panel.active {
  display: block;
}

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

.po-line-form {
  display: grid;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
  padding: 14px;
}

.po-line-form h3 {
  margin: 0;
  font-size: 18px;
}

.po-line-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.po-line-main,
.po-line-side {
  display: grid;
  gap: 14px;
}

.po-line-side {
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
}

.po-line-product-grid {
  display: grid;
  grid-template-columns: minmax(110px, 0.55fr) minmax(150px, 0.75fr) minmax(150px, 0.75fr) minmax(170px, 0.9fr) minmax(180px, 0.9fr) minmax(260px, 1.8fr);
  gap: 0 12px;
  align-items: start;
}

.product-notes-field {
  grid-column: span 2;
}

.combo-manual-field {
  align-content: start;
}

.combo-manual-field input {
  margin-top: 8px;
}

.is-hidden {
  display: none !important;
}

.thickness-selector-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(110px, 1fr));
  gap: 10px;
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  margin: 0;
  appearance: none;
}

input[type="number"] {
  appearance: textfield;
  -moz-appearance: textfield;
}

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

.total-convert-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 32px;
  gap: 5px;
}

.total-convert-field button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--accent-dark);
  font-weight: 900;
}

.total-convert-field button:hover {
  background: var(--panel-soft);
  border-color: var(--accent);
}

.pricing-grid {
  display: grid;
  grid-template-columns: minmax(170px, 0.85fr) minmax(260px, 1.3fr) minmax(190px, 0.85fr);
  gap: 14px;
}

.pricing-column {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px 12px;
  background: #fff;
}

.fill-prices-button {
  width: 100%;
  margin-top: 12px;
  background: var(--panel-soft);
}

.compact-modal {
  width: min(560px, 100%);
}

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

.pricing-results {
  display: grid;
  align-content: start;
  gap: 0;
}

.pricing-results .field {
  margin-top: 12px;
}

.pricing-results input[readonly],
.spec-grid input[readonly] {
  background: #d8ddd7;
  font-weight: 800;
}

.final-price-field input {
  font-size: 18px;
  color: #08110c;
}

.po-total-box {
  position: sticky;
  top: 0;
  z-index: 12;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 12px;
  background: #e6f0ea;
  border-color: #9db7aa;
  box-shadow: 0 12px 28px rgba(15, 77, 66, 0.14);
}

.po-total-box .section-title {
  grid-column: 1 / -1;
}

.invoice-floating-summary {
  position: sticky;
  top: 0;
  z-index: 11;
  display: grid;
  grid-template-columns: minmax(180px, 0.7fr) minmax(0, 2.3fr);
  gap: 12px;
  align-items: stretch;
  padding: 12px;
  border: 1px solid #9fb8ad;
  border-radius: 8px;
  background: #e2eee8;
  box-shadow: 0 12px 28px rgba(15, 77, 66, 0.13);
}

.invoice-total-main {
  display: grid;
  align-content: center;
  gap: 4px;
  padding: 10px 12px;
  border: 1px solid #c0d0c7;
  border-radius: 7px;
  background: #f8fbf8;
}

.invoice-total-main span,
.invoice-qty-grid span,
.invoice-qty-grid small,
.field small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.invoice-total-main strong {
  font-size: 22px;
}

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

.invoice-qty-grid > div {
  display: grid;
  align-content: center;
  gap: 3px;
  min-height: 64px;
  padding: 8px 10px;
  border: 1px solid #c0d0c7;
  border-radius: 7px;
  background: #f8fbf8;
}

.invoice-qty-grid strong {
  font-size: 15px;
}

.invoice-form-layout {
  display: grid;
  gap: 14px;
  margin-top: 14px;
}

.invoice-locked-grid {
  display: grid;
  grid-template-columns: minmax(170px, 1fr) minmax(110px, 0.6fr) minmax(130px, 0.75fr) minmax(150px, 0.9fr) auto;
  gap: 10px;
  align-items: end;
}

.invoice-status-row {
  display: flex;
  gap: 18px;
  align-items: center;
  flex-wrap: wrap;
}

.invoice-basics-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.invoice-basic-card {
  display: grid;
  gap: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.checkbox-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 30px;
  color: var(--ink);
  font-weight: 700;
}

.checkbox-row input {
  width: 16px;
  height: 16px;
  min-height: auto;
  accent-color: var(--accent);
}

.invoice-stage-grid {
  display: grid;
  grid-template-columns: minmax(180px, 0.45fr) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.stage-dates {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
}

.stage-options {
  display: grid;
  gap: 8px;
}

.stage-partial-row,
.stage-bl-row {
  display: grid;
  grid-template-columns: max-content minmax(150px, 220px);
  gap: 12px;
  align-items: end;
}

.field-with-button {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.line-panel-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.line-source-balance {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.column-filter-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: 6px 10px;
  margin: 12px 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.compact-checkbox {
  min-height: 24px;
  font-size: 12px;
}

.compact-review-table {
  font-size: 12px;
}

.floating-po-notes {
  position: fixed;
  right: 18px;
  top: 92px;
  z-index: 35;
  width: min(460px, calc(100vw - 36px));
  max-height: calc(100vh - 120px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7fbf8;
  box-shadow: 0 18px 38px rgba(15, 52, 43, 0.22);
}

.floating-po-notes-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: move;
  user-select: none;
}

.floating-po-notes-body {
  max-height: 65vh;
  overflow: auto;
  display: grid;
  gap: 8px;
}

.po-note-section {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  line-height: 1.45;
}

.po-note-section input {
  margin-top: 4px;
}

.po-note-section strong,
.po-note-section small {
  display: block;
}

.po-note-section small {
  margin-top: 4px;
  white-space: pre-wrap;
  color: var(--ink);
}

.po-note-section.confirmed {
  background: #eef1ed;
  color: var(--muted);
}

.po-note-section.confirmed small {
  color: var(--muted);
}

.hidden-field {
  display: none !important;
}

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

.ocean-overview-grid {
  display: grid;
  grid-template-columns: minmax(150px, 0.8fr) minmax(150px, 0.8fr) minmax(150px, 0.8fr);
  gap: 0 14px;
  align-items: start;
}

.ocean-sub-box {
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

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

.ocean-related-grid > :nth-child(2) {
  grid-column: span 2;
}

.ocean-charge-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.ocean-charge-box,
.ocean-total-box,
.ocean-dap-box {
  display: grid;
  gap: 0 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.ocean-charge-box,
.ocean-total-box {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.ocean-total-box,
.ocean-dap-box {
  margin-top: 12px;
}

.ocean-dap-box {
  grid-template-columns: minmax(160px, 260px);
}

.invoice-shipping-section .form-grid {
  grid-template-columns: 1fr;
}

.invoice-shipping-section textarea,
.invoice-note-section textarea {
  min-height: 126px;
}

.tolerances-section {
  display: grid;
  gap: 0;
}

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

.po-line-summary {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.po-lines-table {
  min-width: 1180px;
}

.po-lines-table td {
  white-space: normal;
}

.compact-empty {
  padding: 18px;
}

.field input:disabled,
.field textarea:disabled,
.field input[readonly],
.field textarea[readonly] {
  background: #d4d7d2;
  color: #5d665f;
}

.locked-input,
.field input.locked-input {
  background: #d4d7d2;
  border-color: #aab5ad;
  color: #14221b;
  font-weight: 800;
  cursor: not-allowed;
}

.tight {
  margin-top: 8px;
}

.note-popup {
  position: absolute;
  z-index: 20;
  width: min(380px, calc(100vw - 24px));
  max-height: 280px;
  overflow: auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 6px;
}

.note-popup button {
  width: 100%;
  display: grid;
  gap: 4px;
  text-align: left;
  background: transparent;
  border-radius: 6px;
  padding: 9px;
  color: var(--ink);
}

.note-popup button:hover {
  background: var(--panel-soft);
}

.note-popup span,
.note-popup-empty,
.default-note-row small,
.address-picker-column p {
  color: var(--muted);
}

.note-popup span {
  white-space: pre-wrap;
  max-height: 96px;
  overflow: hidden;
}

.note-popup-empty {
  padding: 10px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(23, 33, 28, 0.35);
}

.modal-panel {
  width: min(980px, 100%);
  max-height: min(760px, 92vh);
  overflow: hidden;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.modal-head,
.modal-actions {
  padding: 14px;
  display: flex;
  gap: 10px;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--line);
}

.modal-head h3,
.address-picker-column h4 {
  margin: 0;
}

.modal-body {
  overflow: auto;
  padding: 14px;
}

.modal-actions {
  justify-content: flex-end;
  border-top: 1px solid var(--line);
  border-bottom: 0;
}

.defaults-list {
  display: grid;
  gap: 8px;
}

.default-note-row {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.default-note-row small {
  display: block;
  margin-top: 4px;
  white-space: pre-wrap;
}

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

.address-picker-column {
  display: grid;
  align-content: start;
  gap: 8px;
}

.address-picker-column button {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  text-align: left;
  white-space: pre-wrap;
}

.address-picker-column button:hover {
  border-color: var(--accent);
  background: var(--panel-soft);
}

.action-menu {
  position: relative;
}

.action-menu summary {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 6px 10px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: #fff;
  color: var(--accent);
  font-weight: 800;
  list-style: none;
}

.action-menu summary::-webkit-details-marker {
  display: none;
}

.action-menu div {
  position: absolute;
  right: 0;
  z-index: 12;
  display: grid;
  gap: 4px;
  min-width: 190px;
  margin-top: 6px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.action-menu button {
  justify-content: flex-start;
  min-height: 34px;
  border: 0;
  background: #fff;
  color: var(--text);
  text-align: left;
}

.action-menu button:hover {
  background: var(--panel-soft);
}

.po-export-preview {
  display: grid;
  gap: 12px;
}

.po-export-toolbar {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.po-export-sheet {
  max-width: 960px;
  margin: 0 auto;
  padding: 22px;
  border: 1px solid #8f9891;
  background: #fff;
  color: #101513;
  font-size: 13px;
}

.po-export-title {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  font-size: 18px;
  font-weight: 900;
}

.po-export-qty {
  margin-top: 10px;
  font-weight: 800;
}

.po-export-box,
.po-export-item {
  margin-top: 10px;
  padding: 10px;
  border: 1px solid #333;
}

.po-export-box h4 {
  margin: 0 0 8px;
  font-size: 14px;
}

.po-export-box-grid {
  display: grid;
  gap: 10px;
}

.po-export-row,
.po-export-item-head {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  margin-top: 6px;
}

.po-export-row.no-label {
  grid-template-columns: 1fr;
}

.po-export-row:not(.no-label) > :first-child,
.po-export-item-head > :first-child {
  font-weight: 800;
}

.po-export-product {
  font-weight: 800;
}

.po-export-reset {
  color: #101513;
}

.po-export-red {
  color: #b52318;
  font-weight: 900;
}

.po-export-red-only {
  color: #b52318;
  font-weight: 400;
}

.po-export-pricing {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0;
}

.po-export-pricing span {
  padding: 4px 7px;
  border: 1px solid #bfc8c0;
  border-radius: 6px;
  background: #f7faf8;
}

.inline-select {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
}

.inline-select select {
  min-height: 34px;
  padding: 5px 32px 5px 10px;
}

.po-items-review {
  display: grid;
  gap: 14px;
}

.review-table-wrap {
  max-height: none;
}

.review-table {
  min-width: 1320px;
  font-size: 12px;
}

.review-table th {
  white-space: nowrap;
}

.review-table td {
  vertical-align: top;
  white-space: pre-wrap;
}

.review-total-row td {
  border-top: 2px solid #333;
  font-weight: 900;
}

.review-details-block {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

.review-details-block h4 {
  margin: 0 0 8px;
}

.review-details-block div {
  white-space: pre-wrap;
  padding: 7px 0;
  border-top: 1px solid #eef2ee;
}

.review-details-block div:first-of-type {
  border-top: 0;
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 16px;
}

.compact {
  min-height: 32px;
  padding: 6px 10px;
}

.error-banner {
  margin: 0 0 18px;
  border: 1px solid #e2b9a0;
  background: #fff6ef;
  color: var(--warn);
  border-radius: 8px;
  padding: 12px 14px;
}

@media print {
  body > *:not(.modal-backdrop) {
    display: none !important;
  }

  .modal-backdrop {
    position: static;
    display: block;
    padding: 0;
    background: #fff;
  }

  .modal-panel {
    width: 100%;
    max-height: none;
    border: 0;
    box-shadow: none;
  }

  .modal-head,
  .modal-actions,
  .po-export-toolbar {
    display: none !important;
  }

  .modal-body {
    overflow: visible;
    padding: 0;
  }

  .po-export-sheet {
    max-width: none;
    border: 0;
    padding: 0;
  }
}

@media (max-width: 880px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-height: auto;
  }

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

  .topbar,
  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }

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

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

  .form-grid-3,
  .form-grid-4,
  .po-general-grid,
  .po-two-column,
  .po-line-layout,
  .po-line-side,
  .po-line-product-grid,
  .thickness-selector-grid,
  .spec-grid,
  .pricing-grid,
  .tolerance-grid,
  .address-picker,
  .invoice-floating-summary,
  .invoice-qty-grid,
  .invoice-locked-grid,
  .invoice-basics-cards,
  .invoice-stage-grid,
  .stage-dates,
  .stage-partial-row,
  .stage-bl-row,
  .checklist-grid,
  .ocean-overview-grid,
  .ocean-related-grid,
  .ocean-charge-grid,
  .ocean-charge-box,
  .ocean-total-box,
  .ocean-dap-box {
    grid-template-columns: 1fr;
  }

  .ocean-related-grid > :nth-child(2) {
    grid-column: span 1;
  }

  .span-2,
  .span-3 {
    grid-column: span 1;
  }

  .product-notes-field {
    grid-column: span 1;
  }
}

@media (max-width: 520px) {
  .content {
    padding: 18px;
  }

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

  .po-filter-grid {
    grid-template-columns: 1fr;
  }
}

.progress-list-panel {
  margin-top: 14px;
}

.progress-modal-backdrop {
  z-index: 42;
  align-items: start;
}

.progress-modal-window {
  width: min(1240px, 100%);
  max-height: calc(100vh - 44px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid #a9b7ad;
  border-radius: 8px;
  background: #f8faf7;
  box-shadow: 0 24px 70px rgba(23, 33, 28, 0.22);
}

.progress-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: #ffffff;
}

.progress-modal-header strong,
.progress-modal-header span {
  display: block;
}

.progress-modal-header span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 13px;
}

.progress-modal-body {
  overflow: auto;
  padding: 14px;
}

.selected-row {
  background: #edf5f1;
}

.progress-pill {
  display: inline-flex;
  max-width: 360px;
  min-height: 28px;
  align-items: center;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 800;
}

.progress-pill.done {
  background: #dcefe6;
  color: #176044;
}

.progress-pill.pending {
  background: #fff2dd;
  color: #8b4d12;
}

.progress-pill-stack {
  display: grid;
  gap: 6px;
  justify-items: start;
}

.progress-pill-balance {
  background: #e8f0ff;
  color: #1f4f94;
}

.progress-detail {
  margin-top: 18px;
  display: grid;
  gap: 16px;
}

.progress-detail-heading {
  position: sticky;
  top: 0;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 16px;
  border: 1px solid #b8c8bf;
  border-radius: 8px;
  background: #f0f6f2;
}

.progress-detail-heading h2 {
  margin: 0;
  font-size: 22px;
}

.progress-detail-heading p {
  margin: 5px 0 0;
  color: var(--muted);
}

.progress-controls input[type="date"] {
  font-size: 12px;
}

.progress-next-line {
  font-weight: 800;
  color: #8b4d12 !important;
}

.progress-next-line.done {
  color: #176044 !important;
}

.progress-flow {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(310px, 1fr));
  gap: 14px;
  align-items: start;
}

.progress-email-modal-backdrop {
  z-index: 43;
  background: rgba(19, 29, 24, 0.32);
}

.progress-email-modal-panel {
  width: min(920px, calc(100vw - 40px));
  max-height: calc(100vh - 64px);
  overflow: auto;
}

.progress-email-preview-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.progress-email-preview-title strong,
.progress-email-preview-title span {
  display: block;
}

.progress-email-preview-title span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

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

.progress-email-field {
  display: grid;
  gap: 6px;
}

.progress-email-field-wide {
  grid-column: 1 / -1;
}

.progress-email-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.progress-email-field input,
.progress-email-field textarea {
  width: 100%;
  border: 1px solid #c6d1c8;
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  box-sizing: border-box;
}

.progress-email-field input {
  min-height: 42px;
}

.progress-email-field textarea {
  min-height: 220px;
  resize: vertical;
}

.progress-email-actions {
  display: flex;
  justify-content: flex-start;
}

.progress-email-field input {
  min-height: 42px;
}

.progress-email-field textarea {
  min-height: 120px;
  resize: vertical;
}

.progress-section {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  max-height: calc(100vh - 250px);
  min-height: 260px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-left-width: 7px;
  border-radius: 8px;
  background: #fff;
}

.progress-section-po {
  border-left-color: #176b5b;
}

.progress-section-oa {
  border-left-color: #486f9f;
}

.progress-section-invoice {
  border-left-color: #8d6428;
}

.progress-section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}

.progress-section-title h3 {
  margin: 0;
  font-size: 14px;
}

.progress-section-title h3 strong {
  font-weight: 900;
}

.progress-section-title span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.progress-steps {
  display: grid;
  align-content: start;
  gap: 10px;
  min-height: 0;
  overflow: auto;
  padding: 10px;
}

.progress-step {
  display: block;
  min-height: 190px;
  padding: 10px;
  overflow: visible;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #eef6f2;
}

.progress-step:last-child {
  border-bottom: 1px solid var(--line);
}

.progress-step-main {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  min-width: 0;
}

.progress-dot {
  width: 12px;
  height: 12px;
  margin-top: 4px;
  border-radius: 50%;
  border: 2px solid #9aa69e;
  background: #fff;
}

.progress-step.done .progress-dot {
  border-color: #176044;
  background: #176044;
}

.progress-step.done {
  border-color: #a8d5b1;
  background: #d8f1d0;
}

.progress-step.pending .progress-dot {
  border-color: #268ba0;
  background: #d7f3fb;
}

.progress-step.pending {
  border-color: #8ad4e4;
  background: #d7f3fb;
}

.progress-step.na .progress-dot {
  border-color: #9aa69e;
  background: #dce1dc;
}

.progress-step.na {
  border-color: #c7cec8;
  background: #eef0ed;
}

.progress-step strong,
.progress-step small,
.progress-step em {
  display: block;
  overflow-wrap: anywhere;
}

.progress-step strong {
  font-size: 13px;
  line-height: 1.25;
}

.progress-step-email-row {
  margin-top: 10px;
  display: flex;
  justify-content: flex-end;
}

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

.progress-step small {
  margin-top: 3px;
  font-size: 12px;
  color: var(--muted);
}

.progress-step em {
  margin-top: 5px;
  color: #8b4d12;
  font-style: normal;
  font-size: 11px;
  font-weight: 750;
}

.progress-step.done strong {
  color: #176044;
}

.progress-step.na strong {
  color: #5d6760;
}

.progress-controls {
  display: grid;
  gap: 7px;
  margin-top: 10px;
}

.progress-controls input {
  min-height: 32px;
  width: 130px;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 6px 8px;
}

.progress-button-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(64px, 1fr));
  gap: 6px;
}

.progress-button-row-2 {
  grid-template-columns: repeat(2, minmax(86px, 1fr));
  max-width: 220px;
}

.progress-button-row button {
  min-height: 32px;
  padding: 5px 8px;
  font-size: 12px;
}

.progress-invoice-switcher {
  display: grid;
  grid-template-columns: auto minmax(220px, 360px) auto;
  gap: 10px;
  align-items: center;
  padding: 12px 14px;
  border: 1px solid #c7d6cc;
  border-radius: 8px;
  background: #ffffff;
}

.progress-invoice-switcher-head {
  display: grid;
  gap: 4px;
}

.progress-invoice-switcher label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.progress-invoice-switcher select {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px 10px;
}

.progress-invoice-switcher span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.progress-invoice-next {
  max-width: 320px;
}

.progress-status-filter {
  grid-column: span 1;
}

.progress-filter-toggle {
  min-height: 38px;
}

.progress-filter-panel {
  margin-top: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.progress-filter-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.progress-filter-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 8px;
}

.progress-next-option {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  gap: 8px;
  align-items: start;
  min-height: 36px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f8faf7;
  font-size: 12px;
  font-weight: 750;
}

.progress-next-option input {
  width: 14px;
  height: 14px;
  margin-top: 2px;
}

@media (max-width: 860px) {
  .progress-detail-heading,
  .progress-section-title,
  .progress-step,
  .progress-invoice-switcher,
  .progress-status-filter {
    align-items: start;
    grid-column: span 1;
  }

  .progress-controls {
    justify-content: flex-start;
  }
}
