:root {
  color-scheme: light;
  --ink: #1d2528;
  --muted: #667277;
  --line: #d9e2de;
  --paper: #f6f7f3;
  --panel: #ffffff;
  --accent: #0d6b5d;
  --accent-strong: #094f45;
  --ember: #b9472c;
  --sun: #d7a43f;
  --shadow: 0 16px 40px rgba(29, 37, 40, 0.09);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  overflow-x: auto;
  color: var(--ink);
  background: var(--paper);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.login-shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(13, 107, 93, 0.12), transparent 36%),
    linear-gradient(315deg, rgba(185, 71, 44, 0.12), transparent 34%),
    var(--paper);
}

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

.brand-mark,
.brand-logo {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 8px;
  color: #fff;
  background: var(--accent);
}

.brand-logo {
  overflow: hidden;
  border: 1px solid var(--line);
  color: var(--ink);
  background: #fff;
}

.brand-logo img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
}

.login-logo {
  width: 78px;
  height: 78px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.login-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
}

.sidebar-logo {
  width: 48px;
  height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.eyebrow {
  margin: 22px 0 8px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
}

h1,
h2,
p {
  margin-top: 0;
}

.login-panel h1 {
  margin-bottom: 28px;
  font-size: 30px;
  line-height: 1.18;
}

.login-form {
  display: grid;
  gap: 16px;
}

.login-form label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
}

.login-form input {
  width: 100%;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  color: var(--ink);
  background: #fbfcfa;
}

.login-form button,
.module-actions button,
.form-actions button {
  height: 44px;
  border: 0;
  border-radius: 6px;
  color: #fff;
  background: var(--accent);
  font-weight: 700;
}

.login-form button:disabled,
.module-actions button:disabled,
.form-actions button:disabled {
  cursor: default;
  opacity: 0.55;
}

.form-error {
  margin: 0;
  color: var(--ember);
  font-size: 14px;
}

.form-success {
  margin: 0;
  color: var(--accent-strong);
  font-size: 14px;
  font-weight: 700;
}

.admin-shell {
  display: grid;
  min-height: 100vh;
  width: 100%;
  max-width: 100vw;
  grid-template-columns: 260px minmax(0, 1fr);
  overflow: hidden;
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  min-width: 0;
  max-width: 100%;
  height: 100vh;
  flex-direction: column;
  gap: 22px;
  border-right: 1px solid var(--line);
  padding: 22px 18px;
  background: #fff;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar-brand strong,
.sidebar-brand span {
  display: block;
}

.sidebar-brand span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

nav {
  display: grid;
  min-width: 0;
  gap: 8px;
  overflow: auto;
  padding-right: 2px;
}

nav section {
  display: grid;
  gap: 6px;
}

nav p {
  margin: 0 0 3px;
  padding: 0 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

nav button {
  width: 100%;
  min-height: 36px;
  border: 0;
  border-radius: 6px;
  padding: 0 10px;
  color: var(--ink);
  background: transparent;
  text-align: left;
}

.nav-group-toggle {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 12px;
  color: #4c5b61;
  background: #f4f7f5;
  font-weight: 800;
}

.nav-group-toggle small {
  display: inline-grid;
  min-width: 24px;
  height: 22px;
  place-items: center;
  border-radius: 999px;
  color: var(--muted);
  background: #e6ece9;
  font-size: 12px;
}

.nav-chevron {
  color: #7c898e;
  transform: rotate(-90deg);
  transition: transform 0.16s ease;
}

.nav-group.expanded .nav-chevron {
  transform: rotate(0deg);
}

.nav-group.active-group > .nav-group-toggle,
.nav-group-toggle:hover {
  color: var(--accent-strong);
  background: #eaf3ef;
}

.nav-group-items {
  display: grid;
  gap: 4px;
  padding: 0 0 6px 10px;
}

.nav-group.collapsed .nav-group-items {
  display: none;
}

.nav-page {
  position: relative;
  padding-left: 20px;
  font-size: 15px;
}

.nav-page::before {
  position: absolute;
  top: 50%;
  left: 8px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #c5cfca;
  content: "";
  transform: translateY(-50%);
}

.nav-page.active::before,
.nav-page:hover::before {
  background: var(--accent);
}

nav button.active,
.nav-page:hover {
  color: var(--accent-strong);
  background: #eaf3ef;
  font-weight: 700;
}

.workspace {
  min-width: 0;
  max-width: 100%;
  overflow: auto;
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

.topbar .eyebrow {
  margin-top: 0;
}

.topbar h1 {
  margin-bottom: 0;
  font-size: 28px;
}

.user-box {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
}

.icon-button {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: #fff;
}

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

.metric,
.panel,
.module-page,
.empty-state {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 10px 24px rgba(29, 37, 40, 0.04);
}

.metric {
  display: flex;
  min-height: 126px;
  gap: 14px;
  padding: 18px;
}

.metric-icon {
  display: grid;
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 8px;
  color: var(--accent);
  background: #eaf3ef;
}

.metric span,
.metric p,
.panel-title span,
.muted {
  color: var(--muted);
}

.metric span {
  font-size: 13px;
}

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

.metric p {
  margin: 8px 0 0;
  font-size: 12px;
}

.panel {
  grid-column: span 2;
  overflow: hidden;
}

.warnings {
  grid-column: 1 / -1;
  grid-row: auto;
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding: 16px 18px;
}

.panel-title h2 {
  margin: 0;
  font-size: 17px;
}

.warning-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: start;
  gap: 14px;
  padding: 14px;
}

.warning-group {
  display: grid;
  gap: 8px;
}

.warning-group-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--ink);
}

.warning-group-title span {
  color: var(--muted);
  font-size: 12px;
}

.warning-row {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  border: 1px solid #efd4ca;
  border-radius: 8px;
  padding: 10px;
  color: var(--ember);
  background: #fff7f3;
}

.warning-row strong,
.warning-row span {
  display: block;
}

.warning-row span {
  margin-top: 2px;
  color: #8a695e;
  font-size: 12px;
}

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

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

th {
  color: var(--muted);
  font-weight: 700;
  background: #fbfcfa;
}

[data-edit-record] {
  cursor: pointer;
}

[data-edit-record]:hover td {
  background: #eef7f2;
}

.table-input {
  width: 120px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  color: var(--ink);
  background: #fff;
}

.table-action {
  height: 34px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  padding: 0 12px;
  color: var(--accent-strong);
  background: #eef7f2;
  font-weight: 700;
  cursor: pointer;
}

tr:last-child td {
  border-bottom: 0;
}

.summary-group-row td {
  background: #eef7f2;
  color: var(--accent-strong);
  font-weight: 800;
}

.summary-metrics {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  gap: 10px;
  margin: 0 0 16px;
}

.summary-metrics article {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px;
  background: #fbfdfc;
}

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

.summary-metrics strong {
  display: block;
  color: var(--text);
  font-size: 20px;
  line-height: 1.2;
}

.module-page,
.empty-state {
  padding: 24px;
}

.data-layout {
  display: grid;
  grid-template-columns: minmax(360px, 0.85fr) minmax(0, 1.25fr);
  gap: 16px;
  align-items: start;
}

.backend-module-view {
  display: grid;
  gap: 16px;
}

.backend-module-view .data-layout {
  display: block;
}

.backend-module-view form.data-form,
.backend-module-view .data-layout > .data-form:not(.report-filter-panel) {
  display: none;
}

.backend-module-view .data-layout > .table-panel,
.backend-module-view > .table-panel,
.backend-module-view .module-audit-panel {
  width: 100%;
}

.data-layout > *,
.dashboard-grid > *,
.summary-grid > *,
.report-group-grid > *,
.role-grid > * {
  min-width: 0;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.report-filter-panel {
  margin-bottom: 16px;
}

.report-filter-grid {
  grid-template-columns: repeat(6, minmax(120px, 1fr));
}

.report-actions {
  justify-content: flex-start;
  border-top: 1px solid var(--border);
}

.report-actions button + button {
  background: #eef7f2;
  color: var(--accent-strong);
}

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

.report-group-panel {
  overflow-x: auto;
}

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

.role-card {
  display: grid;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 14px;
  background: #fbfdfc;
}

.role-card.active {
  border-color: var(--accent);
  background: #eef7f2;
}

.role-card div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.role-card strong {
  color: var(--ink);
  font-size: 16px;
}

.role-card span,
.role-card p,
.role-card small {
  color: var(--muted);
  line-height: 1.55;
}

.role-card p {
  margin: 0;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 6px;
  padding: 0 8px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.status-badge.normal {
  color: var(--accent-strong);
  background: #e8f2ee;
}

.status-badge.success {
  color: var(--accent-strong);
  background: #e8f2ee;
}

.status-badge.warning {
  color: var(--ember);
  background: #fff0ea;
}

.status-badge.void {
  color: var(--ember);
  background: #fff0ea;
}

.table-action-button {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #eef7f2;
  color: var(--accent-strong);
  font-weight: 800;
  padding: 8px 10px;
  cursor: pointer;
  white-space: nowrap;
}

.expanded-edit-row td {
  background: #fbfdfb;
}

.inline-edit-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: #fff;
}

.inline-edit-panel h3 {
  margin: 0 0 14px;
  font-size: 18px;
}

.inline-edit-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(160px, 1fr));
  gap: 14px;
}

.inline-edit-form .form-wide {
  grid-column: 1 / -1;
}

.readonly-summary {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: #f8fbf9;
}

.readonly-summary h3 {
  margin: 0 0 12px;
  font-size: 18px;
}

.section-label {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--accent-strong);
  font-weight: 800;
}

.section-label::after {
  content: "";
  height: 1px;
  flex: 1;
  background: var(--line);
}

.data-form,
.table-panel {
  grid-column: auto;
}

.table-panel {
  max-width: 100%;
  max-height: calc(100vh - 184px);
  overflow: auto;
  scrollbar-gutter: stable;
}

.record-filter-bar {
  padding: 0 18px 14px;
  min-width: max-content;
  background: #fff;
}

.record-filter-bar label {
  display: grid;
  grid-template-columns: auto minmax(260px, 520px);
  align-items: center;
  gap: 12px;
  width: min(100%, 660px);
}

.record-filter-bar span {
  color: var(--accent-strong);
  font-size: 14px;
  font-weight: 800;
  white-space: nowrap;
}

.record-filter-bar input {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 14px;
  background: #fff;
}

.record-filter-bar input:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 2px rgba(13, 107, 93, 0.12);
}

.filter-bar {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 14px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.filter-bar label {
  display: grid;
  gap: 8px;
}

.filter-bar span {
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

.filter-bar input,
.filter-bar select {
  min-height: 44px;
}

.compact-actions {
  align-self: end;
  border-top: 0;
  padding: 0;
}

.compact-actions button {
  min-width: 96px;
}

.table-panel table {
  width: max-content;
  min-width: 100%;
}

.table-panel th {
  position: sticky;
  top: 0;
  z-index: 2;
  white-space: nowrap;
}

.table-panel th:first-child,
.table-panel td:first-child {
  position: sticky;
  left: 0;
  z-index: 1;
  min-width: 156px;
  max-width: 240px;
  background: #fff;
  box-shadow: 1px 0 0 var(--line);
}

.table-panel th:first-child {
  z-index: 3;
  background: #fbfcfa;
}

.table-panel td {
  max-width: 220px;
  overflow-wrap: anywhere;
}

.table-panel tr.selected-row td,
.table-panel tr.selected-row td:first-child {
  background: #eaf3ef;
}

.key-columns-two th:first-child,
.key-columns-two td:first-child {
  width: 156px;
  min-width: 156px;
  max-width: 156px;
}

.key-columns-two th:nth-child(2),
.key-columns-two td:nth-child(2) {
  position: sticky;
  left: 156px;
  z-index: 1;
  min-width: 220px;
  max-width: 280px;
  background: #fff;
  box-shadow: 1px 0 0 var(--line);
}

.key-columns-two th:nth-child(2) {
  z-index: 3;
  background: #fbfcfa;
}

.table-panel .selection-cell {
  min-width: 52px;
  width: 52px;
  max-width: 52px;
  padding: 0;
  text-align: center;
}

.selection-cell input {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--accent);
}

.price-quote-table .quote-name-cell {
  position: sticky;
  left: 52px;
  z-index: 1;
  min-width: 220px;
  background: #fff;
  box-shadow: 1px 0 0 var(--line);
}

.price-quote-table th.quote-name-cell {
  z-index: 3;
  background: #fbfcfa;
}

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

.sales-order-entry {
  width: 100%;
}

.fulfillment-section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 18px 10px;
  border-top: 1px solid var(--line);
}

.fulfillment-section-title:first-of-type {
  border-top: 0;
}

.fulfillment-section-title h3 {
  margin: 0;
  font-size: 18px;
}

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

.fulfillment-card {
  display: grid;
  gap: 14px;
  border-bottom: 1px solid var(--line);
  padding: 16px 18px 20px;
}

.fulfillment-card:last-child {
  border-bottom: 0;
}

.inner-title {
  margin: -16px -18px 0;
}

.fulfillment-products {
  overflow-x: auto;
}

.detail-cell {
  min-width: 280px;
}

.detail-cell div + div {
  margin-top: 6px;
}

.invoice-order-list {
  display: grid;
  gap: 8px;
  max-height: 300px;
  overflow: auto;
}

.invoice-order-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  border: 1px solid var(--line);
  padding: 10px 12px;
}

.invoice-order-option input {
  width: 18px;
  height: 18px;
  margin-top: 2px;
  accent-color: var(--accent);
}

.invoice-order-option span,
.invoice-order-option small {
  display: block;
}

.invoice-order-option small {
  margin-top: 4px;
  color: var(--muted);
}

.invoice-detail-table table {
  min-width: 1040px;
}

.invoice-total-row td {
  font-weight: 800;
  background: #eef7f2;
}

.fulfillment-grid {
  padding: 0;
}

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

.form-grid label {
  display: grid;
  gap: 7px;
  min-width: 0;
  color: var(--muted);
  font-size: 13px;
}

.form-grid .full-row {
  grid-column: 1 / -1;
}

.field-block {
  display: grid;
  gap: 7px;
  min-width: 0;
  color: var(--muted);
  font-size: 13px;
}

.form-grid input,
.form-grid select {
  width: 100%;
  min-width: 0;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  color: var(--ink);
  background: #fbfcfa;
}

.form-grid select {
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position:
    calc(100% - 16px) 17px,
    calc(100% - 11px) 17px;
  background-repeat: no-repeat;
  background-size: 5px 5px;
  padding-right: 32px;
}

.form-grid select.multi-select {
  height: auto;
  min-height: 180px;
  padding: 8px 10px;
  appearance: auto;
  background-image: none;
}

.form-grid small {
  color: var(--muted);
  line-height: 1.5;
}

.flavor-picker {
  position: relative;
}

.flavor-picker-control {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 40px;
  gap: 8px;
  align-items: end;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px;
  background: #fbfcfa;
}

.flavor-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
}

.flavor-chips button,
.flavor-options button {
  border: 0;
  border-radius: 6px;
  padding: 7px 10px;
  color: var(--ink);
  background: #f5ead7;
  font-weight: 700;
}

.flavor-chips button span {
  margin-left: 5px;
  color: var(--muted);
}

.flavor-placeholder {
  padding: 7px 2px;
  color: var(--muted);
}

.flavor-toggle {
  width: 36px;
  height: 32px;
  border: 0;
  border-radius: 6px;
  color: var(--accent-strong);
  background: #e8f5ef;
  font-size: 22px;
  line-height: 1;
}

.flavor-dropdown {
  display: none;
  margin-top: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fff;
  box-shadow: var(--shadow);
}

.flavor-dropdown.open {
  display: block;
}

.flavor-dropdown input {
  width: 100%;
  height: 40px;
  margin-bottom: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  color: var(--ink);
  background: #fbfcfa;
}

.flavor-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-height: 220px;
  overflow: auto;
}

.flavor-options button.selected {
  color: #fff;
  background: var(--accent);
}

.flavor-add-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 40px;
  gap: 8px;
  margin-top: 10px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.flavor-add-row input {
  margin-bottom: 0;
}

.flavor-add-row button {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 6px;
  color: #fff;
  background: var(--accent);
  font-size: 22px;
  font-weight: 800;
}

.inline-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  color: var(--ink);
}

.inline-checkbox input {
  width: 16px;
  height: 16px;
  min-width: 16px;
  padding: 0;
}

.form-wide {
  grid-column: 1 / -1;
}

.form-section {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--accent-strong);
  font-size: 13px;
}

.form-section::after {
  content: "";
  height: 1px;
  flex: 1;
  background: var(--line);
}

.profile-summary {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfa;
  padding: 12px;
}

.profile-summary .muted {
  margin: 0;
}

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

.profile-summary-grid div {
  min-width: 0;
}

.profile-summary-grid dt {
  color: var(--muted);
  font-size: 12px;
}

.profile-summary-grid dd {
  margin: 3px 0 0;
  color: var(--ink);
  font-size: 13px;
  overflow-wrap: anywhere;
}

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

.plan-items {
  display: grid;
  gap: 10px;
  overflow-x: auto;
}

.plan-item-row {
  display: grid;
  grid-template-columns: minmax(150px, 1.5fr) minmax(90px, 0.75fr) minmax(120px, 1fr);
  gap: 10px;
  align-items: end;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfa;
}

.progressive-detail-row[hidden] {
  display: none;
}

.add-detail-button {
  justify-self: start;
  width: auto;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--accent-strong);
  background: #e8f5ef;
  font-size: 15px;
  font-weight: 800;
}

.add-detail-button:hover {
  border-color: var(--accent);
  background: #dceee6;
}

.sales-product-row {
  grid-template-columns: minmax(260px, 1.7fr) minmax(150px, 0.9fr) minmax(130px, 0.8fr) minmax(140px, 0.8fr) minmax(180px, 1fr);
  min-width: 920px;
}

.sales-shipping-row {
  grid-template-columns: minmax(240px, 1.3fr) minmax(140px, 0.7fr) minmax(220px, 1fr);
  min-width: 720px;
}

.quantity-stepper {
  display: grid;
  grid-template-columns: 34px minmax(54px, 1fr) 34px;
  gap: 6px;
}

.quantity-stepper button {
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--accent-strong);
  background: #e8f5ef;
  font-weight: 800;
}

.quantity-stepper input {
  text-align: center;
}

.plan-item-list {
  display: grid;
  gap: 4px;
  min-width: 180px;
}

.plan-item-list span {
  overflow-wrap: anywhere;
}

.data-form .form-error,
.data-form .form-success {
  padding: 0 18px;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  border-top: 1px solid var(--line);
  padding: 14px 18px;
}

.form-actions button {
  min-width: 150px;
  padding: 0 18px;
}

.form-actions .secondary-button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
}

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

.modal-card {
  width: min(720px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(36, 31, 28, 0.24);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  padding: 18px;
}

.modal-header h2 {
  margin: 0 0 4px;
  font-size: 20px;
}

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

.modal-close {
  width: 34px;
  min-width: 34px;
  height: 34px;
  border-radius: 50%;
  padding: 0;
  font-size: 22px;
  line-height: 1;
}

.modal-form-grid {
  padding: 18px;
}

.inner-empty {
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 9px;
  font-size: 12px;
  font-weight: 700;
}

.status.ok {
  color: var(--accent-strong);
  background: #eaf3ef;
}

.status.warn {
  color: var(--ember);
  background: #fff0ea;
}

.module-header {
  max-width: 680px;
}

.module-header h2 {
  margin-bottom: 8px;
  font-size: 24px;
}

.module-header p:last-child {
  color: var(--muted);
  line-height: 1.7;
}

.module-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 24px;
}

.module-actions button {
  min-width: 112px;
  padding: 0 16px;
}

.cost-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 18px 16px;
}

.cost-tabs button {
  height: 34px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.cost-tabs button.active {
  border-color: rgba(14, 95, 83, 0.25);
  background: #e8f2ee;
  color: var(--accent);
}

.loading-bar {
  height: 3px;
  margin: -10px 0 16px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--sun), var(--ember));
}

.quote-strategy-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
}

.quote-strategy-toolbar label {
  display: flex;
  align-items: center;
  gap: 8px;
}

.quote-strategy-group + .quote-strategy-group {
  border-top: 8px solid var(--surface-soft);
}

.quote-strategy-group .panel-title {
  background: var(--surface-soft);
}

.quote-strategy-group h3 {
  margin: 0;
  font-size: 18px;
}

.action-feedback {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 16px 24px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  background: var(--surface-soft);
}

.action-feedback.success strong {
  color: var(--accent);
}

.action-feedback.error {
  border-color: #e9b7ab;
  background: #fff5f2;
}

.action-feedback.error strong {
  color: #b94730;
}

@media (max-width: 1120px) {
  .dashboard-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

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

  .sidebar {
    position: sticky;
    height: auto;
    z-index: 2;
    gap: 12px;
    overflow: hidden;
    padding: 14px;
  }

  nav {
    display: grid;
    width: 100%;
    min-width: 0;
    gap: 8px;
    max-height: 52vh;
    overflow: auto;
    padding-bottom: 4px;
  }

  nav section {
    display: grid;
    flex: initial;
    gap: 6px;
  }

  nav p {
    display: none;
  }

  nav button {
    width: 100%;
    white-space: normal;
  }

  .workspace {
    padding: 18px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

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

  .data-layout,
  .summary-grid,
  .summary-metrics,
  .report-filter-grid,
  .report-group-grid,
  .role-grid,
  .form-grid,
  .plan-item-row {
    grid-template-columns: 1fr;
  }

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

  .panel,
  .warnings {
    grid-column: span 1;
  }
}

@media (max-width: 520px) {
  .login-panel {
    padding: 24px;
  }

  nav {
    grid-template-columns: 1fr;
  }

  .table-panel table {
    width: max-content;
    min-width: 100%;
  }
}
.attachment-actions {
  display: flex;
  gap: 12px;
  white-space: nowrap;
}

.attachment-actions a {
  color: #087568;
  font-weight: 600;
  text-decoration: none;
}

.attachment-actions a:hover {
  text-decoration: underline;
}

.attachment-upload-field input[type="file"] {
  padding: 0;
  overflow: hidden;
}

.attachment-upload-field input[type="file"]::file-selector-button {
  min-height: 52px;
  margin: 0 16px 0 0;
  padding: 0 20px;
  border: 0;
  border-right: 1px solid var(--line);
  background: #eef5f2;
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.attachment-upload-field input[type="file"]::file-selector-button:hover {
  background: #e2eee9;
}

.missing-attachment-form {
  display: inline-flex;
}

.missing-attachment-picker {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #eef5f2;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
}

.missing-attachment-picker:hover {
  background: #e2eee9;
}

.missing-attachment-picker input[type="file"] {
  display: none;
}
