:root {
  color-scheme: light;
  --ink: #1f2726;
  --muted: #6b7470;
  --line: #dde3df;
  --paper: #fbfaf7;
  --panel: #ffffff;
  --wine: #8e1e3f;
  --forest: #293e44;
  --gold: #c39a52;
  --sage: #5c7c6e;
  --blue: #376276;
  --danger: #b74435;
  --shadow: 0 20px 60px rgba(31, 39, 38, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  background: var(--paper);
  color: var(--ink);
}

button, input, select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled,
input:disabled,
select:disabled,
textarea:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.login-gate {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  background: #f5f4ef;
  padding: 24px;
}

.login-card {
  width: min(100%, 380px);
  display: grid;
  gap: 14px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.login-card img {
  width: 168px;
  justify-self: center;
}

.login-card h1 {
  text-align: center;
  font-size: 22px;
}

.login-card label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.login-card input {
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--ink);
}

.login-card p {
  min-height: 18px;
  color: var(--red);
  font-size: 13px;
}

.muted-text {
  color: var(--muted);
  font-size: 13px;
}

.table-select {
  min-width: 92px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 0 8px;
}

.order-status-select,
.order-status-option {
  font-weight: 700;
}

.order-status-select[data-status="待发货"],
.order-status-option[data-status="待发货"] {
  border-color: #d99a9a;
  background: #f7d6d6;
  color: #8c2020;
}

.order-status-select[data-status="已发货"],
.order-status-option[data-status="已发货"] {
  border-color: #e4aa66;
  background: #f9dfbf;
  color: #8a4a08;
}

.order-status-select[data-status="已开票"],
.order-status-option[data-status="已开票"] {
  border-color: #ddc45c;
  background: #f8edaa;
  color: #6f5a00;
}

.order-status-select[data-status="已回款"],
.order-status-option[data-status="已回款"] {
  border-color: #7eb791;
  background: #d9eddf;
  color: #21633a;
}

.checkline {
  display: flex !important;
  grid-template-columns: none !important;
  align-items: center;
  gap: 10px !important;
}

.checkline input {
  width: 16px;
  height: 16px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(25, 35, 33, 0.42);
}

.modal-card {
  width: min(100%, 720px);
  display: grid;
  gap: 16px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.sales-order-confirm-card,
.modal-with-actions {
  grid-template-rows: minmax(0, 1fr) auto;
  max-height: calc(100dvh - 48px);
  overflow: hidden;
}

.modal-body-scroll {
  min-height: 0;
  display: grid;
  gap: 16px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.form-actions.modal-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 0;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  background: #fff;
}

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

.password-modal-card {
  width: min(100%, 420px);
}

.password-modal-card .entry-form {
  grid-template-columns: 1fr;
}

.password-modal-card .form-actions {
  margin-top: 0;
}

.form-message {
  min-height: 20px;
  margin: 0;
  color: var(--wine) !important;
  font-size: 13px;
}

.account-password-time {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  white-space: nowrap;
}

.form-actions.compact-modal-actions {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

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

.modal-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.confirm-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfaf7;
  font-size: 13px;
}

.confirm-summary span {
  color: var(--muted);
}

.confirm-summary strong {
  display: block;
  color: var(--ink);
  font-size: 14px;
}

.confirm-table {
  width: 100%;
  border-collapse: collapse;
}

.confirm-table th,
.confirm-table td {
  border-bottom: 1px solid var(--line);
  padding: 8px;
  font-size: 13px;
  text-align: left;
}

.confirm-table th {
  background: #f3f3f0;
  font-weight: 800;
}

.confirm-table td:nth-child(n+2),
.confirm-table th:nth-child(n+2) {
  text-align: right;
}

.confirm-table tfoot td {
  font-weight: 800;
}

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

.auth-pending .app-shell,
.auth-locked .app-shell {
  display: none;
}

.sidebar {
  background: #192321;
  color: #f9f3ea;
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  aspect-ratio: 1 / 1;
  padding: 0;
  border-radius: 8px;
  background: transparent;
  overflow: hidden;
}

.brand-logo {
  display: block;
  width: 100%;
  height: 100%;
  max-height: none;
  object-fit: contain;
}

.sidebar-footer span,
.eyebrow,
.metric span,
.metric em {
  color: rgba(255, 255, 255, 0.68);
  font-size: 12px;
}

.nav {
  display: grid;
  gap: 6px;
  flex: 1 1 auto;
  min-height: 0;
  align-content: start;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.28) transparent;
}

.nav::-webkit-scrollbar {
  width: 6px;
}

.nav::-webkit-scrollbar-thumb {
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.28);
}

.nav-item {
  height: 42px;
  border: 0;
  border-radius: 8px;
  text-align: left;
  padding: 0 14px;
  background: transparent;
  color: rgba(255, 255, 255, 0.74);
}

.nav-group {
  display: grid;
  gap: 4px;
}

.nav-parent {
  position: relative;
  width: 100%;
  font-weight: 800;
}

.nav-parent::after {
  content: "›";
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  transition: transform 0.16s ease;
}

.nav-group.is-open .nav-parent::after {
  transform: translateY(-50%) rotate(90deg);
}

.nav-children {
  display: none;
  gap: 4px;
  padding-left: 10px;
}

.nav-group.is-open .nav-children {
  display: grid;
}

.nav-child {
  height: 36px;
  padding-left: 18px;
  font-size: 13px;
}

.nav-item.active,
.nav-item:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.nav-item.todo-nav-item.has-todos,
.nav-item.todo-nav-item.has-todos:hover,
.nav-item.todo-nav-item.has-todos.active {
  background: #d97706;
  color: #fff;
  font-weight: 800;
}

.nav-item.todo-nav-item.has-todos:hover,
.nav-item.todo-nav-item.has-todos.active {
  background: #b45309;
}

.nav-group:has(.nav-child.active) > .nav-parent {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.sidebar-footer {
  margin-top: auto;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
}

.sidebar-footer strong {
  display: block;
  margin-top: 6px;
}

.workspace {
  padding: 28px;
  overflow: hidden;
}

.topbar {
  display: flex;
  justify-content: flex-start;
  flex-wrap: wrap;
  gap: 20px;
  align-items: flex-start;
  margin-bottom: 24px;
}

.eyebrow {
  color: var(--wine);
  margin: 0 0 4px;
  font-weight: 700;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(26px, 3vw, 38px);
  letter-spacing: 0;
}

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

.topbar-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: flex-start;
}

.search {
  min-width: 280px;
  height: 42px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

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

.search input {
  border: 0;
  outline: 0;
  width: 100%;
  min-width: 0;
}

.primary-action,
.ghost-action,
.chip,
.segmented button {
  border: 0;
  border-radius: 8px;
  height: 42px;
  padding: 0 16px;
  white-space: nowrap;
}

.primary-action {
  color: white;
  background: var(--wine);
}

.primary-action:hover {
  background: #771833;
}

.primary-action.small {
  height: 36px;
}

.ghost-action {
  background: #eef3ef;
  color: var(--forest);
}

.table-action {
  height: 32px;
  padding: 0 12px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

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

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

.stats-range-panel {
  margin-bottom: 18px;
}

.stats-range-form {
  grid-template-columns: repeat(2, minmax(0, 220px));
}

.receivable-summary {
  margin-top: 18px;
}

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

.metric {
  padding: 18px;
  display: grid;
  gap: 8px;
}

.metric span,
.metric em {
  color: var(--muted);
  font-style: normal;
}

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

.sales-trend-summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  padding: 4px 0 14px;
  border-bottom: 1px solid var(--line);
}

.sales-trend-total {
  display: grid;
  align-content: start;
  gap: 6px;
  min-width: 0;
}

.sales-trend-total span,
.sales-trend-total em {
  color: var(--muted);
  font-style: normal;
}

.sales-trend-total em {
  font-size: 12px;
  line-height: 1.5;
  overflow-wrap: anywhere;
  white-space: normal;
}

.sales-trend-total strong {
  font-size: 28px;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.dashboard-accounting-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  margin-top: 4px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.dashboard-accounting-summary span {
  display: inline-flex;
  gap: 6px;
  align-items: baseline;
  font-size: 12px;
}

.dashboard-accounting-summary b {
  color: var(--ink);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.dashboard-salesperson-breakdown {
  display: grid;
  gap: 8px;
  min-width: 0;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.dashboard-salesperson-title {
  color: var(--ink) !important;
  font-size: 12px;
  font-weight: 800;
}

.dashboard-salesperson-rows {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px 18px;
}

.dashboard-salesperson-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 2px 8px;
  min-width: 0;
}

.dashboard-salesperson-row span {
  overflow: hidden;
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dashboard-salesperson-row b {
  min-width: 0;
  font-size: 13px;
  text-align: right;
  white-space: nowrap;
}

.dashboard-salesperson-row small {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 11px;
}

.dashboard-salesperson-empty {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.dashboard-grid,
.section-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(280px, 0.75fr);
  gap: 18px;
}

.dashboard-side-column {
  display: grid;
  align-content: start;
  gap: 18px;
  min-width: 0;
}

.dashboard-side-column .panel {
  overflow: hidden;
}

.dashboard-side-column .alert-list {
  max-height: 340px;
  padding-right: 4px;
  overflow-y: auto;
}

.dashboard-grid {
  align-items: start;
}

.panel {
  padding: 18px;
  min-width: 0;
}

.panel.wide {
  grid-column: span 1;
}

#wines .section-grid {
  grid-template-columns: minmax(0, 1fr);
}

#wines .panel.wide {
  grid-column: 1 / -1;
}

#permissions .section-grid {
  grid-template-columns: minmax(0, 1fr);
}

.my-account-panel {
  max-width: 760px;
}

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

#myAccountForm .form-actions,
#myAccountForm .form-status {
  grid-column: 1 / -1;
}

#myAccountForm input[readonly] {
  background: #f2f3f1;
  color: var(--muted);
}

.account-session-actions {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.account-session-actions h3 {
  margin: 0 0 12px;
  font-size: 15px;
}

.account-session-actions .form-actions {
  justify-content: flex-start;
}

#permissions .panel.wide {
  grid-column: 1 / -1;
  overflow-x: auto;
}

#permissions #userForm {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: start;
}

#permissions .permission-editor,
#permissions #userForm .checkline,
#permissions #userForm .form-actions {
  grid-column: 1 / -1;
}

#permissions #userForm .checkline {
  justify-self: start;
}

#permissions #userForm .checkline input {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
}

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

#permissions table {
  min-width: 920px;
  table-layout: fixed;
}

#permissions th:nth-child(1),
#permissions td:nth-child(1) {
  width: 9%;
}

#permissions th:nth-child(2),
#permissions td:nth-child(2),
#permissions th:nth-child(3),
#permissions td:nth-child(3),
#permissions th:nth-child(4),
#permissions td:nth-child(4) {
  width: 9%;
}

#permissions th:nth-child(5),
#permissions td:nth-child(5) {
  width: 36%;
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.55;
}

#permissions th:nth-child(6),
#permissions td:nth-child(6) {
  width: 12%;
}

#permissions th:nth-child(7),
#permissions td:nth-child(7),
#permissions th:nth-child(8),
#permissions td:nth-child(8) {
  width: 8%;
}

.panel-head {
  min-height: 40px;
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-head h2 {
  flex: 0 0 100%;
}

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

.inline-field {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

select,
.entry-form input,
.entry-form select,
.entry-form textarea,
.logistics-input {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 0 10px;
  color: var(--ink);
}

select,
.entry-form input,
.entry-form select,
.logistics-input {
  height: 40px;
}

.entry-form textarea {
  min-height: 96px;
  padding: 10px;
  resize: vertical;
}

.entry-form input,
.entry-form select,
.entry-form textarea {
  width: 100%;
  min-width: 0;
  max-width: 100%;
}

.logistics-input {
  width: 116px;
  text-align: right;
}

.logistics-readonly {
  display: inline-block;
  min-width: 88px;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.sales-order-logistics-info {
  min-width: 132px;
  max-width: 220px;
  white-space: normal;
  overflow-wrap: anywhere;
}

.sales-order-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

table {
  width: 100%;
  border-collapse: collapse;
}

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

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

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

.empty-state {
  color: var(--muted);
  text-align: center;
  padding: 28px 10px;
}

.sales-line-chart {
  height: 286px;
  padding-top: 8px;
}

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

.sales-line-chart .grid-line {
  stroke: #e9e5df;
  stroke-width: 1;
}

.sales-line-chart .trend-area {
  fill: rgba(142, 30, 63, 0.1);
}

.sales-line-chart .trend-line {
  fill: none;
  stroke: var(--wine);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 3;
}

.sales-line-chart .trend-point {
  fill: #fff;
  stroke: var(--wine);
  stroke-width: 2;
}

.sales-line-chart .axis-label,
.sales-line-chart .value-label {
  fill: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.sales-line-chart .empty-state {
  height: 100%;
  display: grid;
  place-items: center;
}

.alert-list,
.task-list,
.entry-form,
.report-bars {
  display: grid;
  gap: 12px;
}

.entry-form {
  min-width: 0;
}

.alert-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid #ead9d5;
  border-radius: 8px;
  background: #fff8f6;
}

.alert-item strong,
.alert-item span {
  min-width: 0;
}

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

.status-pill {
  display: inline-flex;
  align-items: center;
  height: 28px;
  border-radius: 999px;
  padding: 0 10px;
  background: #eef3ef;
  color: var(--forest);
  font-size: 12px;
  font-weight: 700;
}

.status-pill.warn {
  background: #fff0e8;
  color: var(--danger);
}

.status-pill.ok {
  background: #e9f4ed;
  color: #32714d;
}

.wine-type-pill.red {
  background: #8e1e3f;
  color: #fff;
}

.wine-type-pill.white {
  background: #fff4bf;
  color: #705b00;
}

.wine-type-pill.rose {
  background: #ffd9dd;
  color: #9b2c3c;
}

.wine-type-pill.sparkling,
.wine-type-pill.default {
  background: #eef3ef;
  color: var(--forest);
}

.table-number-input {
  width: 82px;
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 8px;
  color: var(--ink);
  font: inherit;
}

.table-number-input:focus {
  border-color: var(--gold);
  outline: 2px solid rgba(195, 145, 63, 0.16);
}

.wine-actions {
  min-width: 220px;
}

.wine-move-actions {
  display: inline-flex;
  flex-direction: column;
  gap: 4px;
  vertical-align: top;
}

.table-action:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.danger-action {
  color: var(--danger);
}

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

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

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

.form-status {
  min-height: 20px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.form-status.success {
  color: #32714d;
}

.form-status.error {
  color: var(--danger);
}

.permission-editor {
  margin: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.permission-editor legend {
  padding: 0 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

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

.permission-option {
  display: flex !important;
  grid-template-columns: none !important;
  align-items: center;
  gap: 8px !important;
  color: var(--ink) !important;
}

.permission-option input {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
}

.permission-option span {
  min-width: 0;
  font-size: 13px;
  line-height: 1.35;
}

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

.shipping-reminder {
  display: grid;
  gap: 6px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fafbf9;
}

.shipping-reminder strong {
  font-size: 13px;
}

.shipping-reminder span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.shipping-reminder.has-note {
  border-color: #e1c88f;
  background: #fff9ea;
}

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

.line-editor-head,
.outbound-line {
  display: grid;
  gap: 10px;
}

.line-editor-head {
  grid-template-columns: 1fr;
  align-items: start;
  justify-items: start;
  color: var(--muted);
  font-size: 13px;
}

.line-editor-head span {
  font-weight: 700;
}

.outbound-lines {
  display: grid;
  gap: 10px;
}

.outbound-line {
  grid-template-columns: minmax(0, 1.4fr) 82px 104px auto;
  align-items: end;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fafbf9;
}

.task-list label {
  grid-template-columns: 18px 1fr;
  align-items: center;
  color: var(--ink);
}

.dashboard-pending-task {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px 0;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.dashboard-pending-task:last-child {
  border-bottom: 0;
}

.dashboard-pending-task > span {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.dashboard-pending-task strong,
.dashboard-pending-task small {
  overflow-wrap: anywhere;
}

.dashboard-pending-task small {
  color: var(--muted);
}

.dashboard-pending-task b {
  color: var(--wine);
  font-size: 13px;
}

.dashboard-pending-task:hover strong,
.dashboard-pending-task:focus-visible strong {
  color: var(--wine);
}

.dashboard-pending-empty {
  padding: 12px 0;
  color: var(--muted);
  font-size: 13px;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.chip {
  height: 34px;
  color: var(--forest);
  background: #eef3ef;
}

.chip.active {
  color: #fff;
  background: var(--forest);
}

.wine-card-preview {
  display: grid;
  gap: 10px;
}

.wine-card-preview img {
  width: 88px;
  height: 88px;
  border-radius: 16px;
}

.wine-card-preview strong {
  font-size: 20px;
}

.wine-card-preview span,
.wine-card-preview p {
  color: var(--muted);
}

.segmented {
  display: inline-flex;
  padding: 4px;
  border-radius: 8px;
  background: #eef3ef;
}

.segmented button {
  height: 32px;
  background: transparent;
  color: var(--muted);
}

.segmented button.active {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 6px 18px rgba(31, 39, 38, 0.08);
}

.sales-order-filter {
  margin-top: 10px;
}

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

.customer-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  display: grid;
  gap: 9px;
  background: #fff;
}

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

.customer-card strong {
  font-size: 18px;
}

.customer-card span,
.rank-list span {
  color: var(--muted);
  font-size: 13px;
}

.customer-card .customer-order-gap {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 0 10px;
  background: #fff0e3;
  color: #b45309;
  font-size: 12px;
  font-weight: 800;
}

.report-row {
  display: grid;
  grid-template-columns: 90px 1fr 86px;
  align-items: center;
  gap: 12px;
}

.report-row .track {
  height: 12px;
  border-radius: 999px;
  background: #edf0ed;
  overflow: hidden;
}

.report-row .fill {
  display: block;
  height: 100%;
  width: var(--w);
  background: var(--blue);
}

.salesperson-report-bars {
  display: grid;
  gap: 14px;
}

.salesperson-report-row {
  grid-template-columns: minmax(72px, 110px) minmax(48px, 1fr) minmax(110px, 142px);
}

.salesperson-report-value {
  display: grid;
  gap: 2px;
  justify-items: end;
  color: var(--ink) !important;
  text-align: right;
}

.salesperson-report-value small {
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

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

.reports-summary-panel,
.reports-structure-panel,
.reports-wine-panel {
  grid-column: 1 / -1;
}

.reports-summary-panel .panel-head {
  align-items: flex-start;
}

.reports-summary-panel .panel-head > div {
  flex: 1 1 420px;
  min-width: 0;
}

.reports-summary-panel .panel-head select {
  flex: 0 0 150px;
}

.reports-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.reports-summary > div {
  min-width: 0;
  padding: 15px 16px;
  border-left: 1px solid var(--line);
}

.reports-summary > div:first-child {
  border-left: 0;
}

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

.reports-summary strong {
  display: block;
  color: var(--ink);
  font-size: clamp(17px, 2vw, 23px);
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.reports-table-panel,
.reports-structure-panel {
  min-width: 0;
}

.commission-layout {
  display: grid;
  gap: 18px;
}

.commission-head {
  align-items: flex-start;
}

.commission-head > div:first-child {
  flex: 1 1 280px;
  min-width: 0;
}

.commission-controls {
  display: flex;
  flex: 0 1 620px;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-start;
}

.commission-controls label {
  display: grid;
  flex: 1 1 150px;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.commission-controls select,
.commission-controls input {
  width: 100%;
  min-width: 0;
}

.commission-summary > div:last-child strong,
.commission-table td:last-child strong {
  color: #b45309;
}

.commission-table-panel,
.commission-detail-panel {
  min-width: 0;
  overflow-x: auto;
}

.commission-table {
  min-width: 1080px;
}

.commission-selection-actions {
  margin-top: 10px;
}

.commission-record-check {
  width: 18px;
  height: 18px;
  accent-color: #b45309;
}

.report-table {
  width: 100%;
  min-width: 620px;
  table-layout: auto;
}

.report-table th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.wine-cost-table {
  width: 100%;
}

.wine-cost-table input {
  width: 96px;
}

.wine-cost-summary {
  margin-bottom: 14px;
}

.price-system-panel {
  padding: 16px;
}

.price-system-head {
  margin-bottom: 10px;
}

.price-system-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.price-system-actions .primary-action {
  min-height: 36px;
  padding: 7px 12px;
}

.price-system-table-wrap {
  width: 100%;
  max-height: calc(100vh - 210px);
  overflow: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.price-system-table {
  width: 100%;
  min-width: 1120px;
  table-layout: fixed;
  border: 0;
}

.price-system-table th,
.price-system-table td {
  padding: 7px 8px;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  line-height: 1.25;
  vertical-align: middle;
}

.price-system-table th {
  position: sticky;
  top: 0;
  z-index: 3;
  color: var(--muted);
  background: #fafbf9;
  box-shadow: inset 0 -1px 0 var(--line);
  font-size: 11px;
  white-space: normal;
}

.price-system-table tbody tr:last-child td {
  border-bottom: 0;
}

.price-system-table th:nth-child(1),
.price-system-table td:nth-child(1) {
  width: 126px;
}

.price-system-table th:nth-child(2),
.price-system-table td:nth-child(2) {
  width: 220px;
}

.price-system-table th:nth-child(3),
.price-system-table td:nth-child(3) {
  width: 58px;
}

.price-system-table th:nth-child(4),
.price-system-table td:nth-child(4) {
  width: 72px;
}

.price-system-table th:nth-child(n + 5),
.price-system-table td:nth-child(n + 5) {
  width: 128px;
}

.price-system-table .price-system-name {
  overflow-wrap: anywhere;
}

.price-system-table input {
  width: 100%;
  min-width: 0;
  height: 32px;
  padding: 5px 7px;
  font-size: 12px;
}

.report-table td {
  vertical-align: middle;
}

.report-table tbody tr:hover {
  background: #f7f9fb;
}

.report-table td strong {
  white-space: nowrap;
}

.report-rank {
  display: inline-grid;
  width: 25px;
  height: 25px;
  place-items: center;
  border-radius: 6px;
  background: #fff0e3;
  color: #b45309;
  font-size: 12px;
  font-weight: 900;
}

.reports-structure-panel .report-bars {
  display: grid;
  gap: 13px;
  margin-bottom: 18px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.reports-structure-panel .report-row {
  grid-template-columns: minmax(88px, 130px) minmax(120px, 1fr) minmax(150px, auto);
}

.reports-structure-panel .report-row b {
  text-align: right;
  white-space: nowrap;
}

.is-filtered-out {
  display: none !important;
}

.rank-list {
  padding-left: 22px;
  display: grid;
  gap: 14px;
}

.rank-list li {
  padding-left: 6px;
}

.print-toolbar {
  margin-bottom: 18px;
}

.print-controls {
  box-shadow: none;
}

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

.delivery-form label:nth-child(5),
.delivery-form label:nth-child(6) {
  grid-column: span 1;
}

.delivery-form .quotation-note-field {
  grid-column: 1 / -1;
}

.quotation-note-field textarea {
  min-height: 68px;
}

.document-note {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.cancel-confirm-reminder {
  color: var(--danger);
  font-weight: 700;
}

.delivery-note-page {
  width: min(100%, 880px);
  min-height: 620px;
  margin: 0 auto;
  padding: 34px 42px;
  background: #fff;
  border: 1px solid #c9c9c9;
  color: #111;
  box-shadow: var(--shadow);
}

.a4-preview-frame {
  --a4-preview-width: 794px;
  --a4-preview-height: 1123px;
  --a4-preview-scale: 1;
  width: min(100%, 560px);
  height: calc(var(--a4-preview-height) * var(--a4-preview-scale));
  margin: 0;
  overflow: hidden;
}

.a4-preview-frame .delivery-note-page {
  width: var(--a4-preview-width);
  min-height: var(--a4-preview-height);
  margin: 0;
  transform: scale(var(--a4-preview-scale));
  transform-origin: top left;
}

.delivery-letterhead {
  display: grid;
  justify-items: start;
  gap: 5px;
  margin-bottom: 16px;
}

.delivery-letterhead img {
  width: 168px;
  height: auto;
  object-fit: contain;
}

.delivery-note-page h2 {
  margin-bottom: 0;
  font-size: 13px;
  font-weight: 800;
}

.delivery-meta {
  display: grid;
  grid-template-columns: 86px 1fr;
  gap: 4px 10px;
  margin-bottom: 14px;
  font-size: 12px;
}

.delivery-meta span {
  font-weight: 800;
}

.delivery-meta strong {
  min-height: 14px;
  font-weight: 500;
}

.delivery-table {
  border-collapse: collapse;
  table-layout: fixed;
}

.delivery-table th,
.delivery-table td {
  border: 1px solid #111;
  padding: 4px 5px;
  color: #111;
  font-size: 11px;
  line-height: 1.15;
  white-space: normal;
}

.delivery-table th {
  background: #111;
  color: #fff;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
  text-align: center;
}

.delivery-table tfoot td {
  font-weight: 800;
  background: #f3f3f0;
  border-bottom: 1px solid #111;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

.delivery-table tfoot td:first-child {
  text-align: right;
}

.delivery-table .en-head th {
  font-weight: 800;
  padding: 4px 5px;
}

.delivery-table th:nth-child(1),
.delivery-table td:nth-child(1) {
  width: 118px;
}

.delivery-table th:nth-child(2),
.delivery-table td:nth-child(2) {
  width: auto;
}

.delivery-table th:nth-child(3),
.delivery-table td:nth-child(3),
.delivery-table th:nth-child(4),
.delivery-table td:nth-child(4),
.delivery-table th:nth-child(5),
.delivery-table td:nth-child(5) {
  width: 76px;
  text-align: right;
}

.delivery-footer {
  display: grid;
  grid-template-columns: 80px 1fr;
  gap: 12px;
  margin-top: 42px;
  font-size: 13px;
}

.delivery-footer strong {
  border-bottom: 1px solid #111;
  min-height: 20px;
}

.quotation-editor {
  margin-top: 16px;
}

.line-editor-footer {
  display: flex;
  justify-content: flex-start;
  margin-top: 8px;
}

.quotation-line {
  grid-template-columns: auto minmax(0, 1fr) minmax(64px, 72px) repeat(2, minmax(82px, 100px));
  justify-items: start;
  gap: 8px;
  padding: 8px;
  font-size: 12px;
}

.quotation-line label {
  gap: 5px;
  font-size: 12px;
  width: 100%;
  min-width: 0;
}

.quotation-line select,
.quotation-line input {
  width: 100%;
  min-width: 0;
  height: 34px;
  font-size: 12px;
}

.quotation-line input[readonly] {
  background: #f2f3f1;
  color: #4f5752;
  cursor: default;
}

.quotation-line .table-action {
  height: 30px;
  padding: 0 9px;
  font-size: 12px;
}

.channel-quotation-line {
  grid-template-columns: auto minmax(0, 1fr) minmax(64px, 72px) repeat(4, minmax(76px, 94px));
}

.channel-quotation-table {
  table-layout: fixed;
  font-size: 9px;
}

.channel-quotation-table th,
.channel-quotation-table td {
  padding: 4px 3px;
  overflow-wrap: anywhere;
}

.channel-quotation-table {
  border-bottom: 1px solid #111;
}

.channel-quotation-table tbody tr:last-child td {
  border-bottom: 1px solid #111 !important;
}

.channel-quotation-table th:nth-child(1) { width: 12%; }
.channel-quotation-table th:nth-child(2) { width: 25%; }
.channel-quotation-table th:nth-child(3) { width: 7%; }
.channel-quotation-table th:nth-child(4) { width: 8%; }
.channel-quotation-table th:nth-child(5) { width: 7%; }
.channel-quotation-table th:nth-child(6) { width: 11%; }
.channel-quotation-table th:nth-child(7) { width: 11%; }
.channel-quotation-table th:nth-child(8) { width: 11%; }
.channel-quotation-table th:nth-child(9) { width: 8%; }

.quotation-title {
  display: grid;
  justify-items: start;
  gap: 2px;
  margin: 0 0 10px;
  padding-bottom: 0;
}

.quotation-title h2 {
  font-size: 24px;
  line-height: 1.05;
}

.quotation-title span {
  color: #555;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.quotation-order-meta {
  margin-top: -6px;
}

.quotation-table tfoot td {
  border: 1px solid #111;
  padding: 5px;
  font-size: 13px;
  font-weight: 800;
  text-align: right;
}

.quotation-table th:nth-child(6),
.quotation-table td:nth-child(6),
.quotation-table th:nth-child(7),
.quotation-table td:nth-child(7) {
  width: 86px;
  text-align: right;
}

.invoice-meta {
  grid-template-columns: 86px 1fr;
}

.invoice-table th:nth-child(5),
.invoice-table td:nth-child(5),
.invoice-table th:nth-child(6),
.invoice-table td:nth-child(6),
.invoice-table th:nth-child(7),
.invoice-table td:nth-child(7) {
  text-align: right;
}

.combined-invoice-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 0.72fr);
  gap: 18px;
  align-items: start;
}

.combined-invoice-controls {
  min-width: 0;
}

.combined-invoice-filter {
  grid-template-columns: minmax(220px, 1fr) minmax(160px, 0.5fr) minmax(220px, 0.8fr);
  margin-bottom: 14px;
}

.combined-invoice-filter .invoice-shipping-toggle {
  display: flex;
  align-items: center;
  align-self: end;
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
}

.combined-invoice-filter .invoice-shipping-toggle input {
  width: 18px;
  height: 18px;
  margin: 0 8px 0 0;
  accent-color: var(--wine);
}

.combined-invoice-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 22px;
  padding: 12px 0;
  color: var(--muted);
  font-size: 13px;
}

.combined-invoice-summary strong {
  margin-left: 4px;
  color: var(--ink);
  font-size: 16px;
}

.combined-invoice-actions {
  justify-content: flex-start;
}

.combined-invoice-preview-frame {
  width: 100%;
  margin: 0;
}

.combined-invoice-document {
  transform-origin: top left;
}

.combined-invoice-history-panel {
  margin-top: 18px;
}

.combined-invoice-orders-table input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--wine);
}

.combined-invoice-table {
  font-size: 10px;
}

.combined-invoice-table th,
.combined-invoice-table td {
  padding: 4px;
}

.sales-order-detail-meta {
  grid-template-columns: 90px 1fr 90px 1fr;
}

.sales-order-detail-table th:nth-child(5),
.sales-order-detail-table td:nth-child(5),
.sales-order-detail-table th:nth-child(6),
.sales-order-detail-table td:nth-child(6),
.sales-order-detail-table th:nth-child(7),
.sales-order-detail-table td:nth-child(7),
.sales-order-detail-table th:nth-child(8),
.sales-order-detail-table td:nth-child(8) {
  text-align: right;
}

.return-line {
  display: grid;
  grid-template-columns: minmax(180px, 2fr) minmax(100px, 1fr) repeat(4, minmax(82px, 1fr));
  gap: 8px;
  align-items: end;
  padding: 10px;
  border-bottom: 1px solid var(--line);
}

.return-line:last-child {
  border-bottom: 0;
}

.return-line label {
  display: grid;
  gap: 5px;
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.return-line input {
  width: 100%;
  min-width: 0;
  height: 36px;
}

.return-line input[readonly] {
  background: #f2f3f1;
  color: var(--ink);
}

.return-note-meta {
  grid-template-columns: 90px minmax(0, 1fr) 90px minmax(0, 1fr);
}

.return-note-table th:nth-child(5),
.return-note-table td:nth-child(5),
.return-note-table th:nth-child(6),
.return-note-table td:nth-child(6),
.return-note-table th:nth-child(7),
.return-note-table td:nth-child(7) {
  text-align: right;
}

.return-history {
  margin-top: 18px;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  min-width: 220px;
  max-width: min(360px, calc(100vw - 48px));
  padding: 14px 16px;
  background: var(--forest);
  color: #fff;
  border-radius: 8px;
  box-shadow: var(--shadow);
  transform: translateY(24px);
  opacity: 0;
  pointer-events: none;
  transition: .22s ease;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

@media (max-width: 980px) {
  .combined-invoice-workspace {
    grid-template-columns: 1fr;
  }

  .combined-invoice-preview-frame {
    max-width: 680px;
  }
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    padding: 16px;
    gap: 16px;
  }

  .brand {
    width: 84px;
    align-self: center;
  }

  .nav {
    grid-template-columns: 1fr;
    max-height: min(62vh, 520px);
  }

  .nav-item {
    width: 100%;
    text-align: left;
    padding: 0 14px;
  }

  .nav-children {
    padding-left: 0;
  }

  .sidebar-footer {
    display: none;
  }

  .topbar {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .topbar-actions,
  .panel-controls,
  .form-actions {
    flex-wrap: wrap;
  }

  .panel-head {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .panel-controls {
    width: 100%;
  }

  .panel-controls select,
  .panel-controls input,
  .form-actions button {
    flex: 1 1 150px;
    min-width: 0;
  }

  .panel {
    overflow-x: auto;
  }

  .metric-grid,
  .customer-grid,
  .stats-range-form,
  .delivery-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .outbound-line {
    grid-template-columns: minmax(0, 1fr) 96px 120px;
  }

  .outbound-line button {
    grid-column: 1 / -1;
  }

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

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

@media (max-width: 680px) {
  .combined-invoice-filter {
    grid-template-columns: 1fr;
  }

  #combined-invoice .combined-invoice-orders-table,
  #combined-invoice .combined-invoice-history-table {
    display: block;
    width: 100%;
    min-width: 0;
    overflow: visible;
    white-space: normal;
  }

  #combined-invoice .combined-invoice-orders-table thead,
  #combined-invoice .combined-invoice-history-table thead {
    display: none;
  }

  #combined-invoice .combined-invoice-orders-table tbody,
  #combined-invoice .combined-invoice-history-table tbody {
    display: grid;
    gap: 10px;
  }

  #combined-invoice .combined-invoice-orders-table tr,
  #combined-invoice .combined-invoice-history-table tr {
    display: grid;
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    overflow: hidden;
  }

  #combined-invoice .combined-invoice-orders-table td,
  #combined-invoice .combined-invoice-history-table td {
    display: grid;
    grid-template-columns: 92px minmax(0, 1fr);
    gap: 10px;
    align-items: center;
    width: 100%;
    min-width: 0;
    padding: 9px 10px;
    border-bottom: 1px solid var(--line);
    white-space: normal;
    overflow-wrap: anywhere;
  }

  #combined-invoice .combined-invoice-orders-table td::before,
  #combined-invoice .combined-invoice-history-table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
  }

  .combined-invoice-actions {
    grid-template-columns: 1fr;
  }
  body {
    min-width: 0;
  }

  .workspace {
    padding: 14px;
  }

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

  .search {
    width: 100%;
    min-width: 0;
  }

  .metric-grid,
  .customer-grid,
  .stats-range-form,
  .delivery-form,
  .permission-grid,
  .nav {
    grid-template-columns: 1fr;
  }

  #permissions #userForm {
    grid-template-columns: 1fr;
  }

  #myAccountForm {
    grid-template-columns: 1fr;
  }

  #permissions .permission-grid {
    grid-template-columns: 1fr;
  }

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

  .sales-trend-total em {
    white-space: normal;
  }

  .dashboard-salesperson-breakdown {
    padding-top: 10px;
    padding-left: 0;
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .panel {
    padding: 14px;
  }

  .modal-backdrop {
    place-items: center;
    padding: max(10px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
    overflow: hidden;
  }

  .modal-card {
    width: 100%;
    max-height: calc(100dvh - 20px);
    gap: 10px;
    padding: 14px;
  }

  .modal-body-scroll {
    gap: 10px;
    padding-right: 2px;
  }

  .modal-card h2 {
    font-size: 18px;
  }

  .modal-card p {
    font-size: 13px;
    line-height: 1.45;
  }

  .confirm-summary {
    grid-template-columns: 1fr;
    gap: 5px;
    padding: 9px;
    font-size: 12px;
  }

  .confirm-summary strong {
    font-size: 13px;
  }

  .modal-card .confirm-table {
    display: table;
    width: 100%;
    min-width: 0;
    table-layout: fixed;
    overflow: visible;
    white-space: normal;
  }

  .modal-card .confirm-table th,
  .modal-card .confirm-table td {
    padding: 5px 3px;
    font-size: 11px;
    line-height: 1.25;
    overflow-wrap: anywhere;
  }

  .modal-card .confirm-table th:first-child,
  .modal-card .confirm-table td:first-child {
    width: 46%;
  }

  .modal-card .confirm-table th:nth-child(n+2),
  .modal-card .confirm-table td:nth-child(n+2) {
    width: 18%;
  }

  .form-actions.modal-actions {
    display: grid;
    grid-template-columns: 1fr;
    flex-wrap: nowrap;
    gap: 8px;
    padding-top: 10px;
  }

  .modal-actions button {
    width: 100%;
    min-height: 42px;
    flex: none;
  }

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

  .print-toolbar .panel {
    overflow: visible;
  }

  .panel-head h2,
  .panel-controls,
  .panel-controls select,
  .panel-controls input,
  .form-actions,
  .form-actions button,
  .primary-action,
  .ghost-action {
    width: 100%;
    min-width: 0;
  }

  .outbound-line,
  .quotation-line,
  .line-editor-head {
    grid-template-columns: 1fr;
  }

  .quotation-line:not(.channel-quotation-line) {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-items: end;
  }

  .quotation-line:not(.channel-quotation-line) > .table-action,
  .quotation-line:not(.channel-quotation-line) > label:first-of-type {
    grid-column: 1 / -1;
  }

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

  table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
    min-width: 640px;
  }

  .wine-actions {
    min-width: 180px;
  }

  .table-action {
    width: auto;
    padding: 0 8px;
  }

  .sales-line-chart {
    min-width: 560px;
  }

  #sales-orders .sales-orders-table,
  #todos .todo-orders-table {
    display: block;
    width: 100%;
    min-width: 0;
    overflow: visible;
    white-space: normal;
  }

  #sales-orders .sales-orders-table thead,
  #todos .todo-orders-table thead {
    display: none;
  }

  #sales-orders .sales-orders-table tbody,
  #todos .todo-orders-table tbody {
    display: grid;
    gap: 12px;
  }

  #sales-orders .sales-orders-table tr,
  #todos .todo-orders-table tr {
    display: grid;
    width: 100%;
    min-width: 0;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
  }

  #sales-orders .sales-orders-table td,
  #todos .todo-orders-table td {
    display: grid;
    grid-template-columns: 92px minmax(0, 1fr);
    gap: 10px;
    align-items: center;
    width: 100%;
    min-width: 0;
    padding: 9px 10px;
    border-bottom: 1px solid var(--line);
    white-space: normal;
    overflow-wrap: anywhere;
  }

  #sales-orders .sales-orders-table td::before,
  #todos .todo-orders-table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
  }

  #sales-orders .sales-orders-table td:last-child,
  #todos .todo-orders-table td:last-child {
    border-bottom: 0;
  }

  #sales-orders .sales-orders-table .logistics-input,
  #sales-orders .sales-orders-table .table-select {
    width: 100%;
    min-width: 0;
  }

  #sales-orders .sales-order-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }

  #sales-orders .sales-order-actions .table-action {
    width: 100%;
    min-height: 38px;
  }

  #sales-orders .sales-orders-table .empty-state {
    display: block;
    padding: 24px 10px;
    text-align: center;
  }

  #sales-orders .sales-orders-table .empty-state::before {
    content: none;
  }

  #todos .todo-orders-table .table-action {
    width: 100%;
    min-height: 38px;
  }

  #todos .todo-orders-table .empty-state {
    display: block;
    padding: 24px 10px;
    text-align: center;
  }

  #todos .todo-orders-table .empty-state::before {
    content: none;
  }

  #sales-order-detail .print-toolbar .panel-controls {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  #sales-order-detail .print-toolbar .panel-controls button {
    min-height: 42px;
    padding: 0 10px;
    white-space: normal;
  }

  #salesOrderDetailPreviewFrame .sales-order-detail-table {
    display: table;
    width: 100%;
    min-width: 0;
    overflow: visible;
    white-space: normal;
  }

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

  .return-line .return-wine-field {
    grid-column: 1 / -1;
  }

  #returnPreviewFrame .return-note-table {
    display: table;
    width: 100%;
    min-width: 0;
    overflow: visible;
    white-space: normal;
  }

  #returns .return-orders-table {
    display: block;
    width: 100%;
    min-width: 0;
    overflow: visible;
    white-space: normal;
  }

  #returns .return-orders-table thead {
    display: none;
  }

  #returns .return-orders-table tbody {
    display: grid;
    gap: 12px;
  }

  #returns .return-orders-table tr {
    display: grid;
    width: 100%;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
  }

  #returns .return-orders-table td {
    display: grid;
    grid-template-columns: 92px minmax(0, 1fr);
    gap: 10px;
    align-items: center;
    width: 100%;
    min-width: 0;
    padding: 9px 10px;
    border-bottom: 1px solid var(--line);
    white-space: normal;
    overflow-wrap: anywhere;
  }

  #returns .return-orders-table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
  }

  #returns .return-orders-table td:last-child {
    border-bottom: 0;
  }

  #returns .return-orders-table .empty-state {
    display: block;
    padding: 24px 10px;
    text-align: center;
  }

  #returns .return-orders-table .empty-state::before {
    content: none;
  }

  .salesperson-report-row {
    grid-template-columns: minmax(64px, 88px) minmax(36px, 1fr) minmax(102px, 124px);
    gap: 8px;
  }
}

@media (max-width: 1100px) {
  .reports-layout {
    grid-template-columns: 1fr;
  }

  .reports-summary-panel,
  .reports-structure-panel,
  .reports-wine-panel {
    grid-column: auto;
  }

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

  .reports-summary > div:nth-child(4) {
    border-left: 0;
  }
}

@media (max-width: 680px) {
  #price-system .panel {
    padding: 12px;
    overflow-x: hidden;
  }

  #price-system .price-system-head,
  #price-system .price-system-actions {
    align-items: flex-start;
  }

  #price-system .price-system-actions {
    width: 100%;
    justify-content: space-between;
  }

  #price-system .price-system-table-wrap {
    max-height: none;
    overflow: visible;
    border: 0;
  }

  #price-system .price-system-table,
  #price-system .price-system-table tbody,
  #price-system .price-system-table tr,
  #price-system .price-system-table td {
    display: block;
    width: 100%;
    min-width: 0;
  }

  #price-system .price-system-table thead {
    display: none;
  }

  #price-system .price-system-table tbody {
    display: grid;
    gap: 8px;
  }

  #price-system .price-system-table tr {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: #fff;
  }

  #price-system .price-system-table td {
    display: grid;
    gap: 4px;
    padding: 7px 9px;
    border-bottom: 1px solid var(--line);
    font-size: 12px;
  }

  #price-system .price-system-table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 10px;
    font-weight: 800;
  }

  #price-system .price-system-table td:nth-child(1),
  #price-system .price-system-table td:nth-child(2) {
    grid-column: span 2;
  }

  #price-system .price-system-table td:nth-last-child(-n + 2) {
    border-bottom: 0;
  }

  #price-system .price-system-table input {
    height: 34px;
  }

  #wine-costs .panel {
    overflow-x: hidden;
  }

  #wine-costs .wine-cost-table,
  #wine-costs .wine-cost-table tbody,
  #wine-costs .wine-cost-table tr,
  #wine-costs .wine-cost-table td {
    display: block;
    width: 100%;
    min-width: 0;
  }

  #wine-costs .wine-cost-table {
    border: 0;
  }

  #wine-costs .wine-cost-table thead {
    display: none;
  }

  #wine-costs .wine-cost-table tbody {
    display: grid;
    gap: 10px;
  }

  #wine-costs .wine-cost-table tr {
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
  }

  #wine-costs .wine-cost-table td {
    display: grid;
    grid-template-columns: 108px minmax(0, 1fr);
    gap: 10px;
    align-items: center;
    padding: 9px 10px;
    border-bottom: 1px solid var(--line);
    white-space: normal;
    overflow-wrap: anywhere;
    text-align: left;
  }

  #wine-costs .wine-cost-table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
  }

  #wine-costs .wine-cost-table td:last-child {
    border-bottom: 0;
  }

  #wine-costs .wine-cost-table input {
    width: 100%;
    max-width: 150px;
  }

  #wine-costs .wine-cost-table .empty-state {
    display: block;
    padding: 24px 10px;
    text-align: center;
  }

  #wine-costs .wine-cost-table .empty-state::before {
    content: none;
  }

  #reports .panel {
    overflow-x: hidden;
  }

  .reports-layout {
    gap: 12px;
  }

  .reports-summary-panel .panel-head > div,
  .reports-summary-panel .panel-head select {
    flex: 1 1 100%;
    width: 100%;
  }

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

  .reports-summary > div {
    padding: 12px 10px;
    border-bottom: 1px solid var(--line);
  }

  .reports-summary > div:nth-child(odd) {
    border-left: 0;
  }

  .reports-summary > div:nth-child(even) {
    border-left: 1px solid var(--line);
  }

  .reports-summary > div:last-child {
    grid-column: 1 / -1;
    border-bottom: 0;
  }

  .reports-summary strong {
    font-size: 18px;
  }

  #reports .report-table,
  #reports .report-table tbody,
  #reports .report-table tr,
  #reports .report-table td {
    display: block;
    width: 100%;
    min-width: 0;
  }

  #reports .report-table {
    border: 0;
  }

  #reports .report-table thead {
    display: none;
  }

  #reports .report-table tbody {
    display: grid;
    gap: 10px;
  }

  #reports .report-table tr {
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
  }

  #reports .report-table td {
    display: grid;
    grid-template-columns: 94px minmax(0, 1fr);
    gap: 10px;
    align-items: center;
    padding: 9px 10px;
    border-bottom: 1px solid var(--line);
    white-space: normal;
    overflow-wrap: anywhere;
    text-align: left;
  }

  #reports .report-table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
  }

  #reports .report-table td:last-child {
    border-bottom: 0;
  }

  #reports .report-table .empty-state {
    display: block;
    padding: 24px 10px;
    text-align: center;
  }

  #reports .report-table .empty-state::before {
    content: none;
  }

  .reports-structure-panel .report-row {
    grid-template-columns: minmax(80px, 1fr) auto;
    gap: 7px 10px;
  }

  .reports-structure-panel .report-row .track {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .reports-structure-panel .report-row b {
    font-size: 12px;
  }

  .reports-wine-panel .panel-head button {
    width: 100%;
  }

  #commissions .panel {
    overflow-x: hidden;
  }

  .commission-layout {
    gap: 12px;
  }

  .commission-head > div:first-child,
  .commission-controls {
    flex: 1 1 100%;
    width: 100%;
  }

  .commission-controls {
    display: grid;
    grid-template-columns: 1fr;
  }

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

  .commission-summary > div {
    padding: 12px 10px;
    border-bottom: 1px solid var(--line);
  }

  .commission-summary > div:nth-child(odd) {
    border-left: 0;
  }

  .commission-summary > div:nth-child(even) {
    border-left: 1px solid var(--line);
  }

  .commission-summary > div:nth-last-child(-n + 2) {
    border-bottom: 0;
  }

  .commission-summary > div:last-child {
    grid-column: auto;
  }

  #commissions .commission-table,
  #commissions .commission-table tbody,
  #commissions .commission-table tr,
  #commissions .commission-table td {
    display: block;
    width: 100%;
    min-width: 0;
  }

  #commissions .commission-table {
    border: 0;
  }

  #commissions .commission-table thead {
    display: none;
  }

  #commissions .commission-table tbody {
    display: grid;
    gap: 10px;
  }

  #commissions .commission-table tr {
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
  }

  #commissions .commission-table td {
    display: grid;
    grid-template-columns: 94px minmax(0, 1fr);
    gap: 10px;
    align-items: center;
    padding: 9px 10px;
    border-bottom: 1px solid var(--line);
    white-space: normal;
    overflow-wrap: anywhere;
    text-align: left;
  }

  #commissions .commission-table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
  }

  #commissions .commission-table td:last-child {
    border-bottom: 0;
  }

  #commissions .commission-table .empty-state {
    display: block;
    padding: 24px 10px;
    text-align: center;
  }

  #commissions .commission-table .empty-state::before {
    content: none;
  }
}

@media print {
  @page {
    size: A4;
    margin: 0;
  }

  html,
  body {
    width: 210mm;
    margin: 0 !important;
    background: #fff;
  }

  .sidebar,
  .topbar,
  .print-toolbar,
  .toast,
  .modal-backdrop {
    display: none !important;
  }

  .app-shell,
  .workspace,
  .view,
  #delivery-note,
  #quotation,
  #channel-quotation,
  #invoice-note,
  #combined-invoice,
  #returns,
  #sales-order-detail {
    display: block !important;
    width: 100% !important;
    min-height: 0;
    padding: 0 !important;
    overflow: visible !important;
  }

  body:not([data-print-view="quotation"]):not([data-print-view="channel-quotation"]):not([data-print-view="invoice-note"]):not([data-print-view="combined-invoice"]):not([data-print-view="sales-order-detail"]):not([data-print-view="returns"]) .view:not(#delivery-note) {
    display: none !important;
  }

  body[data-print-view="quotation"] .view:not(#quotation) {
    display: none !important;
  }

  body[data-print-view="channel-quotation"] .view:not(#channel-quotation) {
    display: none !important;
  }

  body[data-print-view="invoice-note"] .view:not(#invoice-note) {
    display: none !important;
  }

  body[data-print-view="combined-invoice"] .view:not(#combined-invoice) {
    display: none !important;
  }

  body[data-print-view="combined-invoice"] #combined-invoice > :not(.combined-invoice-workspace),
  body[data-print-view="combined-invoice"] .combined-invoice-controls {
    display: none !important;
  }

  body[data-print-view="combined-invoice"] .combined-invoice-workspace {
    display: block !important;
  }

  body[data-print-view="combined-invoice"] .combined-invoice-preview-frame {
    width: auto !important;
    max-width: none !important;
  }

  body[data-print-view="sales-order-detail"] .view:not(#sales-order-detail) {
    display: none !important;
  }

  body[data-print-view="returns"] .view:not(#returns) {
    display: none !important;
  }

  body[data-print-view="delivery-note"] .view:not(#delivery-note) {
    display: none !important;
  }

  body[data-print-view="returns"] .return-history {
    display: none !important;
  }

  .a4-preview-frame {
    width: auto !important;
    height: auto !important;
    margin: 0 !important;
    overflow: visible !important;
    break-after: avoid-page;
    page-break-after: avoid;
  }

  .a4-preview-frame .delivery-note-page {
    transform: none !important;
  }

  .delivery-note-page {
    width: 100% !important;
    max-width: none !important;
    min-height: auto;
    margin: 0 !important;
    padding: 10mm 12mm !important;
    border: 0;
    box-shadow: none;
    font-size: 10px !important;
    break-after: avoid-page;
    page-break-after: avoid;
  }

  .delivery-letterhead {
    gap: 2mm;
    margin-bottom: 4mm;
  }

  .delivery-letterhead img {
    width: 38mm !important;
  }

  .delivery-note-page h2 {
    font-size: 10px !important;
  }

  .quotation-title {
    gap: 1mm;
    margin-bottom: 4mm;
  }

  .quotation-title h2 {
    font-size: 18px !important;
    line-height: 1 !important;
  }

  .quotation-title span {
    font-size: 9px !important;
  }

  .delivery-meta {
    grid-template-columns: 24mm 1fr !important;
    gap: 1.2mm 3mm !important;
    margin-bottom: 3mm !important;
    font-size: 9px !important;
  }

  .sales-order-detail-meta {
    grid-template-columns: 24mm minmax(0, 1fr) 24mm minmax(0, 1fr) !important;
  }

  .return-note-meta {
    grid-template-columns: 24mm minmax(0, 1fr) 24mm minmax(0, 1fr) !important;
  }

  .delivery-meta strong {
    min-height: 9px !important;
  }

  table,
  .delivery-table {
    display: table !important;
    width: 100% !important;
    min-width: 0 !important;
    overflow: visible !important;
    white-space: normal !important;
    table-layout: fixed;
  }

  th,
  td,
  .delivery-table th,
  .delivery-table td {
    padding: 2px 3px !important;
    font-size: 8.5px !important;
    line-height: 1.12 !important;
  }

  .delivery-table th {
    background: #111 !important;
    color: #fff !important;
  }

  .delivery-table .en-head th {
    padding: 2px 3px !important;
  }

  .quotation-table tfoot td {
    padding: 3px !important;
    font-size: 9px !important;
  }

  .delivery-footer {
    grid-template-columns: 20mm 1fr !important;
    gap: 3mm !important;
    margin-top: 8mm !important;
    font-size: 9px !important;
  }

  .delivery-footer strong {
    min-height: 12px !important;
  }
}
