:root {
  color-scheme: light;
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --line: #d7dce2;
  --line-strong: #b8c0cb;
  --text: #1f2933;
  --muted: #667085;
  --primary: #166534;
  --primary-hover: #14532d;
  --primary-soft: #e8f5ec;
  --accent: #1d4ed8;
  --danger: #b42318;
  --danger-soft: #fff1f0;
  --warning: #9a6500;
  --shadow: 0 8px 24px rgba(31, 41, 51, 0.08);
  font-family: "Microsoft JhengHei", "PingFang TC", "Noto Sans TC", Arial, sans-serif;
}

[hidden] {
  display: none !important;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(420px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 24px;
}

.login-brand {
  margin-bottom: 24px;
}

.login-form {
  display: grid;
  gap: 14px;
}

.login-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}

.form-error {
  min-height: 20px;
  margin: 0;
  color: var(--danger);
  font-size: 13px;
}

.session-chip {
  position: fixed;
  top: 10px;
  right: 14px;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px 6px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
  color: var(--text);
}

.session-chip small {
  color: var(--muted);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: wait;
  opacity: 0.64;
}

.app-shell {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 18px;
  border-right: 1px solid var(--line);
  background: #fcfcfd;
  padding: 20px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand > div:not(.brand-mark) {
  min-width: 0;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--primary);
  font-weight: 800;
}

.brand h1,
.brand p,
.topbar h2,
.topbar p,
.panel h3 {
  margin: 0;
}

.brand h1 {
  font-size: 18px;
  line-height: 1.3;
}

.brand p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.brand-sync-button {
  width: 58px;
  min-height: 42px;
  margin-left: auto;
  padding: 0 8px;
  justify-content: center;
  font-size: 13px;
  font-weight: 800;
}

.toolbar,
.panel-actions,
.status-strip,
.form-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.toolbar {
  display: grid;
  grid-template-columns: 1fr;
  align-items: stretch;
  width: 100%;
}

.toolbar .primary-button,
.toolbar .secondary-button {
  display: inline-flex;
  align-items: center;
  width: 100%;
  justify-content: flex-start;
}

.nav-category {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  overflow: hidden;
}

.nav-category summary {
  min-height: 38px;
  display: flex;
  align-items: center;
  padding: 0 14px;
  color: var(--text);
  cursor: pointer;
  font-weight: 800;
  list-style: none;
}

.nav-category summary::-webkit-details-marker {
  display: none;
}

.nav-category summary::after {
  content: "v";
  margin-left: auto;
  color: var(--muted);
  font-size: 12px;
}

.nav-category:not([open]) summary::after {
  content: ">";
}

.nav-category[open] summary {
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}

.nav-category-items {
  display: grid;
  gap: 6px;
  padding: 8px;
}

.nav-category-items .nav-button {
  min-height: 34px;
  padding-left: 18px;
}

.primary-button,
.secondary-button,
.text-button {
  min-height: 36px;
  border-radius: 8px;
  padding: 0 14px;
  white-space: nowrap;
}

.nav-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.nav-button.is-active {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 800;
}

.primary-button {
  background: var(--primary);
  color: #ffffff;
  font-weight: 700;
}

.primary-button:hover {
  background: var(--primary-hover);
}

.secondary-button {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
}

.secondary-button:hover {
  border-color: var(--line-strong);
  background: var(--surface-2);
}

.secondary-button.danger {
  border-color: #f0b9b4;
  background: var(--danger-soft);
  color: var(--danger);
}

.text-button {
  min-height: 30px;
  padding: 0 8px;
  background: transparent;
  color: var(--accent);
}

.text-button:hover {
  background: #edf4ff;
}

.text-button.danger {
  color: var(--danger);
}

.order-list {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
  overflow: auto;
  padding-right: 2px;
}

.side-panel {
  min-height: 0;
  box-shadow: none;
}

.side-filter {
  display: grid;
  gap: 8px;
  border-bottom: 1px solid var(--line);
  padding: 12px;
}

.sales-mode-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  border-bottom: 1px solid var(--line);
  padding: 12px 12px 0;
}

.sales-mode-tabs .secondary-button {
  justify-content: center;
}

.sales-mode-tabs .secondary-button.is-active {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 800;
}

.sales-case-list {
  max-height: calc(100vh - 360px);
  padding: 12px;
}

.order-button {
  display: grid;
  width: 100%;
  gap: 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 12px;
  text-align: left;
}

.order-button:hover {
  border-color: var(--line-strong);
}

.order-button.active {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.order-button strong {
  overflow: hidden;
  color: var(--text);
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.order-button span {
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workspace {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
  padding: 20px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 54px;
}

.eyebrow {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
}

.topbar h2 {
  margin-top: 2px;
  font-size: 24px;
  line-height: 1.25;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  padding: 0 12px;
}

.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 56px;
  border-bottom: 1px solid var(--line);
  padding: 12px 16px;
}

.panel h3 {
  font-size: 16px;
}

.panel-note {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.order-form,
.item-form {
  display: grid;
  gap: 14px;
  padding: 16px;
}

.order-form {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.compact-form {
  grid-template-columns: minmax(180px, 280px) minmax(0, 1fr);
}

.item-form {
  grid-template-columns: minmax(160px, 1fr) minmax(280px, 2fr) minmax(140px, 1fr) minmax(140px, 1fr);
  align-items: start;
}

label {
  display: grid;
  gap: 6px;
  min-width: 0;
}

label span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.field-hint {
  min-height: 18px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

label.wide {
  grid-column: span 2;
}

.sales-daily-form {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(260px, 1fr);
  gap: 16px;
  align-items: start;
  padding: 16px;
}

.daily-field-stack {
  display: grid;
  gap: 14px;
}

.daily-full {
  grid-column: 1 / -1;
}

.sales-daily-form textarea {
  min-height: 92px;
  resize: vertical;
}

.sales-daily-form .daily-discussion textarea {
  min-height: 130px;
}

.item-remarks-field {
  grid-column: 2 / 5;
}

.item-remarks-textarea {
  min-height: 64px;
  resize: vertical;
}

input {
  width: 100%;
  min-width: 0;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  padding: 0 10px;
}

input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.12);
  outline: none;
}

input[readonly] {
  background: var(--surface-2);
  color: var(--muted);
}

select {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 0 10px;
}

textarea {
  width: 100%;
  min-width: 0;
  min-height: 76px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  padding: 10px;
}

textarea:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.12);
  outline: none;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 16px;
  align-items: start;
}

.sub-panel {
  border-top: 1px solid var(--line);
}

.panel-actions.align-right {
  justify-content: flex-end;
  padding: 0 16px 16px;
}

.form-actions {
  justify-content: flex-end;
  grid-column: 1 / -1;
}

.allocation-editor,
.receipt-editor {
  grid-column: 1 / -1;
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin: 0;
  padding: 12px;
}

.allocation-editor legend,
.receipt-editor legend {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  padding: 0 6px;
}

.allocation-controls {
  display: grid;
  grid-template-columns: minmax(130px, 160px) minmax(110px, 140px) minmax(0, 1fr) minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
}

.receipt-controls {
  display: grid;
  grid-template-columns: minmax(110px, 140px) minmax(140px, 170px) minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
}

.allocation-list {
  display: grid;
  gap: 8px;
}

.receipt-list {
  display: grid;
  gap: 8px;
}

.allocation-balance {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  padding: 8px 10px;
  color: var(--muted);
  font-size: 12px;
}

.receipt-balance {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  padding: 8px 10px;
  color: var(--muted);
  font-size: 12px;
}

.receipt-balance strong {
  color: var(--text);
  font-size: 13px;
}

.receipt-row {
  display: grid;
  grid-template-columns: minmax(120px, 160px) minmax(90px, 120px) minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  padding: 8px 10px;
}

.receipt-row strong,
.receipt-row span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.allocation-balance strong {
  color: var(--text);
  font-size: 13px;
}

.allocation-balance.is-complete strong {
  color: var(--success);
}

.allocation-balance.is-partial strong,
.allocation-balance.is-pending strong {
  color: var(--warning);
}

.allocation-balance.is-over strong {
  color: var(--danger);
}

.allocation-row {
  display: grid;
  grid-template-columns: minmax(120px, 160px) minmax(80px, 110px) minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  padding: 8px 10px;
}

.allocation-row strong,
.allocation-row span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.allocation-row small {
  display: block;
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workbench-panel .panel-header {
  align-items: flex-start;
}

.workbench-actions {
  flex: 1;
  justify-content: flex-end;
  min-width: 420px;
}

.workbench-actions input {
  max-width: 360px;
}

.quote-pdf-panel .panel-actions {
  min-width: 360px;
}

.quote-pdf-panel .panel-actions input {
  min-width: 220px;
}

.quote-workbench-panel .panel-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
  max-width: 820px;
}

.quote-workbench-panel .panel-actions input {
  min-width: 240px;
}

.quote-items-table {
  min-width: 720px;
}

.workbench-status {
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  padding: 10px 16px;
}

.workbench-results {
  display: grid;
  gap: 10px;
  max-height: 360px;
  overflow: auto;
  padding: 12px 16px 16px;
}

.workbench-order {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.workbench-order-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--surface-2);
  padding: 10px 12px;
}

.workbench-order-header strong,
.workbench-order-header span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workbench-order-header span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.workbench-item-list {
  display: grid;
}

.workbench-item {
  display: grid;
  grid-template-columns: 28px minmax(120px, 180px) minmax(0, 1fr) minmax(90px, 120px) minmax(120px, 180px);
  gap: 10px;
  align-items: center;
  min-height: 44px;
  border-top: 1px solid var(--line);
  padding: 8px 12px;
}

.workbench-item input[type="checkbox"] {
  min-height: auto;
}

.workbench-item small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.workbench-linked {
  color: var(--warning);
  font-size: 12px;
  font-weight: 700;
}

.item-table-wrap {
  max-width: 100%;
  overflow: auto;
  border-top: 1px solid var(--line);
}

.item-table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
}

.item-table.quote-line-editor-table {
  min-width: 1320px;
}

.item-table th,
.item-table td {
  border-bottom: 1px solid var(--line);
  padding: 10px 12px;
  text-align: left;
  vertical-align: middle;
}

.item-name-cell {
  display: grid;
  gap: 4px;
}

.item-name-cell small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  white-space: pre-wrap;
}

.item-table th {
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.item-table td {
  font-size: 14px;
}

.quote-line-editor-table th,
.quote-line-editor-table td {
  padding: 6px 8px;
  vertical-align: top;
}

.quote-line-editor-table .quote-line-name-cell {
  min-width: 360px;
}

.quote-line-editor-table .table-input,
.quote-line-editor-table .table-textarea {
  width: 100%;
  min-height: 32px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: var(--text);
  padding: 5px 6px;
}

.quote-line-editor-table .table-textarea {
  min-height: 46px;
  margin-top: 5px;
  resize: vertical;
  line-height: 1.45;
}

.quote-line-editor-table .table-input:focus,
.quote-line-editor-table .table-textarea:focus {
  border-color: var(--accent);
  background: var(--surface);
  outline: none;
}

.quote-line-editor-table .numeric-input {
  text-align: right;
}

.item-table .source-line {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
  margin-top: 3px;
}

.receipt-summary {
  display: grid;
  gap: 2px;
}

.receipt-summary strong {
  font-size: 13px;
  white-space: nowrap;
}

.receipt-summary small {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.receipt-summary.arrived strong,
.receipt-balance.arrived strong {
  color: var(--success);
}

.receipt-summary.partially_arrived strong,
.receipt-balance.partially_arrived strong {
  color: var(--warning);
}

.receipt-summary.pending strong,
.receipt-balance.pending strong {
  color: var(--muted);
}

.fulfillment-panel {
  display: grid;
  gap: 12px;
  border-top: 1px solid var(--line);
  margin-top: 16px;
  padding-top: 14px;
}

.subsection-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.subsection-header h4 {
  margin: 0;
  font-size: 16px;
}

.subsection-header p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.subsection-header > span {
  color: var(--accent-soft);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.fulfillment-summary {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: 8px;
}

.fulfillment-table-wrap {
  max-width: 100%;
  overflow: auto;
}

.fulfillment-table {
  min-width: 880px;
}

.fulfillment-source-line {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  margin-top: 3px;
}

.fulfillment-status {
  display: inline-block;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  padding: 3px 8px;
  white-space: nowrap;
}

.fulfillment-status.ordered,
.fulfillment-status.partially_ordered {
  border-color: rgba(37, 99, 235, 0.45);
  color: var(--accent-soft);
}

.fulfillment-status.available,
.fulfillment-status.partially_available,
.fulfillment-status.shipped,
.fulfillment-status.partially_shipped {
  border-color: rgba(22, 163, 74, 0.45);
  color: var(--success);
}

.fulfillment-status.pending {
  border-color: rgba(245, 158, 11, 0.45);
  color: var(--warning);
}

.allocation-summary {
  display: grid;
  gap: 5px;
  margin-top: 6px;
}

.allocation-summary strong {
  color: var(--muted);
  font-size: 12px;
}

.allocation-summary.is-complete strong {
  color: var(--success);
}

.allocation-summary.is-partial strong,
.allocation-summary.is-pending strong {
  color: var(--warning);
}

.allocation-summary.is-over strong {
  color: var(--danger);
}

.allocation-chip {
  display: inline-block;
  max-width: 100%;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
  margin: 0 4px 4px 0;
  padding: 2px 8px;
  text-overflow: ellipsis;
  vertical-align: top;
  white-space: nowrap;
}

.clickable-row {
  cursor: pointer;
}

.clickable-row:hover {
  background: var(--surface-2);
}

.numeric {
  text-align: right !important;
  white-space: nowrap;
}

.row-actions {
  display: flex;
  justify-content: flex-end;
  gap: 4px;
  white-space: nowrap;
}

.empty,
.empty-cell {
  color: var(--muted);
  font-size: 14px;
}

.empty {
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  padding: 16px;
  text-align: center;
}

.empty-cell {
  padding: 24px !important;
  text-align: center !important;
}

.timeline-panel {
  position: sticky;
  top: 20px;
}

.timeline {
  display: grid;
  gap: 12px;
  max-height: calc(100vh - 170px);
  overflow: auto;
  padding: 14px;
}

.timeline-item {
  display: grid;
  gap: 8px;
  border-left: 3px solid var(--line-strong);
  padding: 2px 0 2px 12px;
}

.timeline-time {
  color: var(--muted);
  font-size: 12px;
}

.timeline-item strong {
  display: block;
  margin-top: 5px;
  font-size: 14px;
  line-height: 1.4;
}

.timeline-item p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.type-pill {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  border-radius: 999px;
  background: #fff7ed;
  color: var(--warning);
  font-size: 12px;
  font-weight: 800;
  padding: 0 8px;
}

.type-pill.imported {
  background: #ecfdf5;
  color: var(--success);
}

.type-pill.conflict,
.type-pill.error {
  background: #fef2f2;
  color: var(--danger);
}

.type-pill.void {
  background: #f3f4f6;
  color: var(--muted);
}

.ragic-bridge-panel {
  margin-bottom: 20px;
}

.ragic-bridge-list {
  display: grid;
  gap: 10px;
  border-top: 1px solid var(--line);
  padding: 12px 16px 16px;
}

.ragic-bridge-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 150px auto;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 12px;
}

.ragic-bridge-card strong {
  display: block;
  margin-top: 6px;
  font-size: 15px;
}

.ragic-bridge-card p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.quote-layout {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  border-top: 1px solid var(--line);
}

.quote-order-list {
  display: grid;
  align-content: start;
  gap: 8px;
  max-height: 520px;
  overflow: auto;
  border-right: 1px solid var(--line);
  padding: 12px;
}

.quote-order-button span + span {
  color: var(--text);
  font-weight: 700;
}

.quote-detail {
  min-width: 0;
  overflow: auto;
  padding: 14px;
}

.quote-detail-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.quote-meta-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.quote-detail-note {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  margin-bottom: 12px;
  padding: 10px 12px;
  white-space: pre-wrap;
}

.quote-detail-note span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.danger-text {
  display: block;
  margin-top: 6px;
  color: var(--danger);
  font-size: 12px;
}

.imported-panel {
  margin-bottom: 20px;
}

.imported-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  padding: 14px 16px;
}

.inventory-summary {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  padding-top: 14px;
}

.summary-tile {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  padding: 10px 12px;
}

.summary-tile span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.summary-tile strong {
  display: block;
  margin-top: 4px;
  font-size: 18px;
}

.side-summary {
  display: grid;
  gap: 8px;
  min-height: 0;
  overflow: auto;
}

.side-summary-card,
.side-summary-line {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 10px 12px;
}

.side-summary-card span,
.side-summary-line span {
  display: block;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.side-summary-card strong,
.side-summary-line strong {
  display: block;
  overflow: hidden;
  margin-top: 4px;
  color: var(--text);
  font-size: 16px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.side-summary-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.side-summary-line strong {
  margin-top: 0;
  font-size: 13px;
}

.cashflow-controls {
  align-items: end;
}

.cashflow-controls label {
  width: 150px;
}

.cashflow-kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.cashflow-kpi small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.cashflow-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
}

.dashboard-grid {
  align-items: stretch;
}

.decision-panel {
  min-height: 100%;
}

.decision-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding: 14px 16px;
}

.decision-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  padding: 12px;
}

.decision-card.warning {
  border-color: rgba(220, 38, 38, 0.42);
  background: rgba(127, 29, 29, 0.16);
}

.decision-card.stable {
  border-color: rgba(22, 163, 74, 0.35);
}

.decision-card span,
.decision-card small {
  display: block;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.decision-card strong {
  display: block;
  overflow: hidden;
  margin-top: 6px;
  color: var(--text);
  font-size: 20px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.decision-card small {
  margin-top: 5px;
  font-weight: 600;
  line-height: 1.45;
  white-space: normal;
}

.boundary-list {
  display: grid;
  gap: 10px;
  padding: 14px 16px;
}

.boundary-list div {
  display: grid;
  grid-template-columns: 90px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  padding: 10px 12px;
}

.boundary-list strong {
  font-size: 14px;
}

.boundary-list span {
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.section-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 14px 16px;
}

.section-heading h3 {
  margin: 4px 0 0;
  font-size: 18px;
}

.section-heading p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.cashflow-query-panel {
  overflow: hidden;
}

.query-form {
  grid-template-columns: minmax(220px, 1.4fr) minmax(130px, 0.7fr) minmax(130px, 0.7fr) minmax(130px, 0.7fr) minmax(150px, 0.8fr);
}

.query-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  border-top: 1px solid var(--line);
  padding: 12px 16px;
}

.query-summary:empty {
  display: none;
}

.status-guide {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  border-top: 1px solid var(--line);
  padding: 12px 16px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.status-guide strong {
  color: var(--text);
  font-weight: 700;
}

.query-summary small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.query-table {
  min-width: 1040px;
}

.settings-shell {
  overflow: hidden;
}

.settings-tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  border-bottom: 1px solid var(--line);
  padding: 12px 16px;
}

.settings-tab {
  display: grid;
  gap: 4px;
  min-height: 56px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 8px 10px;
  text-align: left;
}

.settings-tab span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.settings-tab strong {
  font-size: 18px;
}

.settings-tab.is-active {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary);
}

.settings-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  border-top: 1px solid var(--line);
  padding: 16px;
}

.settings-form-actions {
  align-self: end;
}

.checkbox-field {
  align-content: center;
  grid-auto-flow: column;
  justify-content: start;
  min-height: 38px;
}

.checkbox-field input {
  width: 18px;
  min-height: 18px;
}

.settings-table {
  min-width: 980px;
}

.is-selected-row {
  background: var(--primary-soft);
}

.cleanup-dashboard {
  display: grid;
  grid-column: 1 / -1;
  gap: 14px;
}

.cleanup-toolbar,
.cleanup-section-header,
.cleanup-group-header,
.cleanup-product {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.cleanup-toolbar {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  padding: 12px;
}

.cleanup-toolbar strong,
.cleanup-toolbar small {
  display: block;
}

.cleanup-toolbar small,
.cleanup-section-header p,
.cleanup-group-header small,
.cleanup-product small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.cleanup-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
}

.cleanup-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.cleanup-section-header {
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  padding: 12px;
}

.cleanup-section-header h4,
.cleanup-section-header p {
  margin: 0;
}

.cleanup-section-header strong {
  white-space: nowrap;
}

.cleanup-items,
.cleanup-products {
  display: grid;
  gap: 8px;
  padding: 10px;
}

.cleanup-group {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  overflow: hidden;
}

.cleanup-group-header {
  border-bottom: 1px solid var(--line);
  padding: 10px 12px;
}

.cleanup-product {
  display: grid;
  grid-template-columns: minmax(180px, 1.6fr) minmax(70px, 0.5fr) minmax(140px, 1fr) minmax(70px, 0.5fr) auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 10px 12px;
}

.cleanup-pending-product {
  grid-template-columns: minmax(220px, 1.7fr) minmax(70px, 0.4fr) minmax(140px, 0.9fr) minmax(120px, 0.8fr) minmax(150px, 0.9fr) auto;
}

.cleanup-product strong,
.cleanup-product span,
.cleanup-product small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.compact-form {
  display: grid;
  grid-template-columns: minmax(160px, 1.2fr) repeat(4, minmax(120px, 1fr)) auto;
  gap: 10px;
  align-items: end;
  padding: 14px 16px;
}

.compact-form.two-line {
  grid-template-columns: 110px minmax(150px, 1fr) minmax(130px, 0.8fr) minmax(110px, 0.7fr);
}

.compact-form.bank-account-form {
  grid-template-columns: repeat(12, minmax(0, 1fr));
}

.compact-form.bank-account-form > * {
  min-width: 0;
}

.compact-form.bank-account-form #bankOwnerType {
  grid-column: span 1;
}

.compact-form.bank-account-form #bankAccountUsage {
  grid-column: span 2;
}

.compact-form.bank-account-form #bankOwnerName {
  grid-column: span 3;
}

.compact-form.bank-account-form #bankName {
  grid-column: span 2;
}

.compact-form.bank-account-form #bankCode,
.compact-form.bank-account-form #branchCode {
  grid-column: span 2;
}

.compact-form.bank-account-form #bankAccountNumber,
.compact-form.bank-account-form #bankAccountName {
  grid-column: span 3;
}

.compact-form.bank-account-form #bankFeeType,
.compact-form.bank-account-form #bankRemarks,
.compact-form.bank-account-form #saveBankAccountButton {
  grid-column: span 2;
}

.compact-form button {
  min-width: 120px;
}

.cashflow-table {
  min-width: 680px;
}

.cleanup-table {
  min-width: 980px;
}

.bank-account-table {
  min-width: 1040px;
}

.cashflow-table small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.forecast-row.is-expanded {
  background: var(--surface-2);
}

.forecast-detail-row > td {
  background: rgba(15, 23, 42, 0.03);
  padding: 0 !important;
}

.forecast-detail-list {
  display: grid;
  gap: 8px;
  padding: 12px;
}

.forecast-event {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(150px, 190px) minmax(220px, 1.2fr);
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 10px 12px;
}

.forecast-event strong,
.forecast-event small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.forecast-event strong {
  margin-top: 5px;
  font-size: 14px;
}

.forecast-event small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.forecast-event.event-inflow {
  border-left: 3px solid var(--primary);
}

.forecast-event.event-outflow {
  border-left: 3px solid var(--danger);
}

.cleanup-table small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.inflow {
  color: var(--primary);
}

.outflow {
  color: var(--danger);
}

.open-items {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 14px;
}

.open-item-column {
  display: grid;
  align-content: start;
  gap: 8px;
  min-width: 0;
}

.open-item-column h4 {
  margin: 0;
  font-size: 14px;
}

.open-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(110px, 150px);
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  padding: 9px 10px;
}

.open-item.overdue {
  border-color: #f0b9b4;
  background: var(--danger-soft);
}

.open-item strong,
.open-item span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.open-item strong {
  font-size: 13px;
}

.open-item span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.imported-layout {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  border-top: 1px solid var(--line);
}

.imported-order-list {
  display: grid;
  align-content: start;
  gap: 8px;
  max-height: 560px;
  overflow: auto;
  border-right: 1px solid var(--line);
  padding: 12px;
}

.imported-order-button {
  display: grid;
  gap: 5px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 10px 12px;
  text-align: left;
}

.imported-order-button:hover,
.imported-order-button.active {
  border-color: var(--primary);
}

.imported-order-button.active {
  background: var(--primary-soft);
}

.imported-order-button strong,
.imported-order-button span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.imported-order-button strong {
  font-size: 14px;
}

.imported-order-button span {
  color: var(--muted);
  font-size: 12px;
}

.imported-detail {
  min-width: 0;
  overflow: auto;
  padding: 14px;
}

.imported-detail-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.imported-detail-header h4 {
  margin: 0;
  font-size: 18px;
}

.imported-detail-header p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.imported-item-table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
}

.imported-item-table th,
.imported-item-table td {
  border-bottom: 1px solid var(--line);
  padding: 9px 10px;
  text-align: left;
}

.imported-item-table th {
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
}

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 280px minmax(0, 1fr);
  }

  .order-form,
  .item-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .item-remarks-field {
    grid-column: 1 / -1;
  }

  .content-grid {
    grid-template-columns: 1fr;
  }

  .imported-layout,
  .quote-layout {
    grid-template-columns: 1fr;
  }

  .ragic-bridge-card {
    grid-template-columns: 1fr;
  }

  .imported-order-list,
  .quote-order-list {
    max-height: 360px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .quote-meta-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .timeline-panel {
    position: static;
  }

  .timeline {
    max-height: 360px;
  }
}

@media (max-width: 760px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .order-list {
    max-height: 260px;
  }

  .workspace {
    padding: 14px;
  }

  .topbar,
  .panel-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .quote-detail-actions {
    align-items: flex-start;
    flex-direction: column;
  }

  .quote-meta-grid {
    grid-template-columns: 1fr;
  }

  .status-strip,
  .panel-actions,
  .toolbar {
    width: 100%;
  }

  .workbench-actions {
    min-width: 0;
  }

  .quote-pdf-panel .panel-actions {
    min-width: 0;
  }

  .workbench-actions input {
    max-width: none;
  }

  .workbench-item {
    grid-template-columns: 28px minmax(0, 1fr);
  }

  .primary-button,
  .secondary-button {
    flex: 1;
  }

  .order-form,
  .item-form,
  .sales-daily-form {
    grid-template-columns: 1fr;
  }

  label.wide,
  .daily-full,
  .item-remarks-field {
    grid-column: 1 / -1;
  }

  .imported-summary {
    grid-template-columns: 1fr 1fr;
  }

  .cashflow-kpis,
  .cashflow-grid,
  .decision-grid,
  .open-items {
    grid-template-columns: 1fr;
  }

  .boundary-list div {
    grid-template-columns: 1fr;
  }

  .forecast-event {
    grid-template-columns: 1fr;
  }

  .section-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .settings-tabs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .settings-form {
    grid-template-columns: 1fr;
  }

  .cleanup-kpis,
  .cleanup-product {
    grid-template-columns: 1fr;
  }

  .cleanup-toolbar,
  .cleanup-section-header,
  .cleanup-group-header {
    align-items: stretch;
    flex-direction: column;
  }

  .compact-form,
  .compact-form.two-line,
  .compact-form.query-form,
  .compact-form.bank-account-form {
    grid-template-columns: 1fr;
  }

  .query-summary {
    grid-template-columns: 1fr 1fr;
  }

  .status-guide {
    grid-template-columns: 1fr;
  }

  .compact-form.bank-account-form > * {
    grid-column: auto;
  }

  .cashflow-controls {
    align-items: stretch;
  }

  .cashflow-controls label {
    width: 100%;
  }

  label.wide {
    grid-column: auto;
  }
}
