:root {
  color-scheme: light;
  font-family: Segoe UI, system-ui, sans-serif;
  background: #eef2f7;
  color: #1f2937;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
}

.hidden { display: none !important; }

.panel {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
  padding: 20px;
}

.login-panel {
  width: min(420px, calc(100vw - 32px));
  margin: 80px auto;
}

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

label {
  display: grid;
  gap: 6px;
  font-size: 14px;
}

input[type="text"],
input[type="password"],
input[type="number"],
select {
  padding: 10px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 14px;
}

.full-width {
  grid-column: 1 / -1;
}

fieldset {
  border: 1px solid #dbe3ee;
  border-radius: 10px;
  padding: 12px 16px 16px;
}

fieldset legend {
  padding: 0 6px;
  font-weight: 600;
}

.attribute-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.attribute-option-field {
  display: grid;
  gap: 6px;
}

.attribute-create-hint {
  margin: 0;
  font-size: 12px;
  color: #0f766e;
}

.attribute-list {
  margin: 0;
  padding-left: 18px;
  font-size: 13px;
}

.categories-heading {
  margin: 24px 0 12px;
  font-size: 18px;
}

.categories-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}

.categories-empty,
.category-empty-attrs,
.category-attr-hint {
  margin: 0;
  font-size: 13px;
}

.category-card {
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: #f8fafc;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 140px;
}

.category-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
}

.category-card-header h4 {
  margin: 4px 0 0;
  font-size: 17px;
}

.category-code {
  display: inline-block;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  font-weight: 700;
  color: #1d4ed8;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 999px;
  padding: 2px 8px;
}

.category-count {
  font-size: 12px;
  color: #64748b;
  white-space: nowrap;
}

.category-attr-list {
  display: grid;
  gap: 10px;
  padding: 12px;
}

.category-attr {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 10px 12px;
}

.category-attr-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.category-attr-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
  align-items: center;
  font-size: 12px;
}

.attr-type-badge,
.attr-flag {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
}

.attr-type-badge {
  background: #eef2ff;
  color: #3730a3;
}

.attr-flag {
  background: #fef3c7;
  color: #92400e;
}

.category-attr-options {
  margin-top: 10px;
  display: grid;
  gap: 8px;
}

.option-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 160px;
  overflow: auto;
  padding-right: 2px;
}

.option-chip {
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  color: #0f172a;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.option-chip:hover {
  border-color: #93c5fd;
  background: #eff6ff;
}

.option-chip.is-used {
  background: #ecfdf5;
  border-color: #a7f3d0;
}

.option-chip.more {
  background: #e2e8f0;
  color: #334155;
}

.compact-btn {
  padding: 6px 10px;
  font-size: 12px;
  white-space: nowrap;
}

.options-toggle {
  justify-self: start;
  padding: 0;
}

button {
  border: 0;
  border-radius: 8px;
  padding: 10px 16px;
  background: #2563eb;
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}

button.secondary {
  background: #e2e8f0;
  color: #334155;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  background: #0f172a;
  color: #fff;
}

.topbar .muted {
  margin-left: 12px;
  color: #94a3b8;
}

.layout {
  display: grid;
  gap: 20px;
  padding: 20px;
}

.nav-tabs {
  display: flex;
  gap: 8px;
  padding: 12px 20px 0;
}

.tab-btn {
  background: #e2e8f0;
  color: #334155;
}

.tab-btn.active {
  background: #2563eb;
  color: #fff;
}

.tab-panel.hidden {
  display: none;
}

select {
  padding: 10px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 14px;
}

.grid-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.checkbox {
  align-content: end;
  grid-auto-flow: column;
  justify-content: start;
  align-items: center;
}

.form-actions {
  grid-column: 1 / -1;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

button:disabled {
  opacity: 0.65;
  cursor: wait;
}

button.is-loading {
  position: relative;
  padding-left: 36px;
}

button.is-loading::before {
  content: "";
  position: absolute;
  left: 14px;
  top: 50%;
  width: 14px;
  height: 14px;
  margin-top: -7px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: receipt-spin 0.7s linear infinite;
}

.receipt-saving-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: #2563eb;
}

.receipt-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid #bfdbfe;
  border-top-color: #2563eb;
  border-radius: 50%;
  animation: receipt-spin 0.7s linear infinite;
  flex-shrink: 0;
}

@keyframes receipt-spin {
  to { transform: rotate(360deg); }
}

.table-wrap {
  overflow: auto;
}

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

th, td {
  padding: 10px 8px;
  border-bottom: 1px solid #e2e8f0;
  text-align: left;
}

th {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #64748b;
}

th .sort-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 700;
  letter-spacing: inherit;
  text-transform: inherit;
  cursor: pointer;
}

th .sort-btn:hover,
th .sort-btn.active {
  color: #0f172a;
}

.muted { color: #64748b; }

.product-photo-row {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  flex-wrap: wrap;
}

.product-photo-crop-frame {
  width: 260px;
  height: 260px;
  overflow: hidden;
  border-radius: 10px;
  border: 3px solid #2f6fed;
  background: #e2e8f0;
  flex: 0 0 auto;
}

.product-photo-preview {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center center;
  display: block;
}

.product-photo-actions {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  min-width: 220px;
}

.product-photo-crop-controls {
  display: grid;
  gap: 0.5rem;
  padding: 0.75rem;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #f8fafc;
}

.product-photo-crop-controls label {
  display: grid;
  grid-template-columns: 90px minmax(160px, 1fr);
  align-items: center;
  gap: 0.5rem;
}

.product-thumb {
  width: 40px;
  height: 40px;
  object-fit: contain;
  object-position: center center;
  border-radius: 6px;
  background: #e2e8f0;
  display: block;
}

.product-thumb.placeholder {
  width: 40px;
  height: 40px;
  border-radius: 6px;
  background: #e2e8f0;
}

.product-detail-card {
  width: min(1500px, 97vw);
}

.cash-session-detail-card {
  width: min(1680px, 98vw);
}

.cash-session-detail-card .modal-body {
  overflow-x: auto;
}

.purchase-note-detail-card {
  width: min(1400px, 96vw);
}

.product-detail-modal-header {
  align-items: flex-start;
  gap: 12px;
}

.product-detail-title {
  display: flex;
  gap: 1rem;
  align-items: center;
  min-width: 0;
}

.product-detail-title > div {
  min-width: 0;
}

.product-detail-photo-frame {
  width: 400px;
  height: 400px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  flex-shrink: 0;
  overflow: hidden;
}

.product-detail-photo {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.product-detail-photo-empty {
  color: #64748b;
  font-size: 1.15rem;
  font-weight: 600;
}

.product-detail-modal-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-shrink: 0;
}

.product-detail-modal-body {
  padding-top: 12px;
}

.detail-meta-grid {
  display: grid;
  gap: 0.35rem;
}

.detail-meta-grid p {
  margin: 0;
}

.product-detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.product-detail-grid h4 {
  margin: 0 0 0.5rem;
  font-size: 14px;
}

.product-detail-grid .full-width {
  grid-column: 1 / -1;
}

.product-detail-scroll {
  max-height: 360px;
}

@media (max-width: 900px) {
  .product-detail-photo-frame {
    width: 140px;
    height: 140px;
  }

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

.sku-preview {
  display: block;
  margin-top: 6px;
  font-weight: 600;
  color: #0f172a;
  word-break: break-all;
}

.error { color: #dc2626; }

.message {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #ecfdf5;
  color: #047857;
}

.message.error {
  background: #fef2f2;
  color: #b91c1c;
}

.positive { color: #047857; font-weight: 600; }
.negative { color: #b91c1c; font-weight: 600; }

.link-btn {
  background: transparent;
  color: #2563eb;
  padding: 0;
}

.receipt-header {
  margin-bottom: 8px;
}

.receipt-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
}

.receipt-hint {
  font-size: 13px;
}

.receipt-grid-wrap {
  max-height: 420px;
  margin-bottom: 16px;
  border: 1px solid #dbe3ee;
  border-radius: 10px;
}

.receipt-grid input,
.receipt-grid select {
  width: 100%;
  min-width: 72px;
  padding: 6px 8px;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  font-size: 13px;
}

.receipt-grid th {
  position: sticky;
  top: 0;
  background: #f8fafc;
  z-index: 1;
}

.receipt-grid td {
  vertical-align: middle;
  padding: 4px;
}

.receipt-grid .row-actions {
  width: 36px;
  text-align: center;
}

.receipt-row-remove {
  background: transparent;
  color: #94a3b8;
  padding: 0 6px;
  font-size: 18px;
  line-height: 1;
}

.receipt-row-remove:hover {
  color: #dc2626;
}

#receipt-result {
  margin-top: 12px;
  padding: 12px;
  border-radius: 8px;
  background: #f8fafc;
  font-size: 14px;
}

#receipt-result ul {
  margin: 8px 0 0;
  padding-left: 20px;
}

.receipt-grid .na {
  color: #cbd5e1;
  text-align: center;
  font-size: 12px;
}

.receipt-grid .subtotal-cell {
  font-weight: 600;
  white-space: nowrap;
  font-size: 13px;
  color: #334155;
}

.receipt-template-panel {
  margin-bottom: 16px;
  padding: 14px 16px;
  border: 1px solid #dbe3ee;
  border-radius: 10px;
  background: #f8fafc;
}

.receipt-template-panel h3 {
  margin: 0 0 6px;
  font-size: 15px;
}

.receipt-template-panel p {
  margin: 0 0 12px;
}

.template-categories {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.template-category-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.template-category-toolbar .secondary {
  padding: 6px 12px;
  font-size: 13px;
}

.template-category-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 999px;
  background: #fff;
  font-size: 13px;
  cursor: pointer;
}

.template-category-chip:has(input:checked) {
  border-color: #2563eb;
  background: #eff6ff;
}

.template-category-chip input {
  margin: 0;
}

.receipt-totals {
  display: flex;
  flex-wrap: wrap;
  gap: 16px 32px;
  justify-content: flex-end;
  margin-bottom: 16px;
  padding: 12px 16px;
  background: #f1f5f9;
  border-radius: 10px;
  font-size: 14px;
}

.receipt-totals strong {
  font-size: 16px;
  color: #0f172a;
}

.products-toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 2fr) repeat(5, minmax(110px, 1fr)) auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 12px;
}

.products-count {
  align-self: center;
  justify-self: end;
  white-space: nowrap;
}

.products-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.products-header-row h2 {
  margin: 0;
}

.products-table-wrap {
  max-height: min(68vh, 720px);
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  background: #fff;
}

.products-table {
  font-size: 13px;
}

.products-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f8fafc;
  box-shadow: inset 0 -1px 0 #e2e8f0;
}

.products-table th,
.products-table td {
  padding: 8px 10px;
  vertical-align: middle;
}

.products-table .col-photo {
  width: 52px;
}

.products-table .col-id {
  width: 4.5rem;
  max-width: 4.5rem;
  white-space: nowrap;
  text-align: right;
}

.products-table .product-id {
  font-size: 0.85rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
  color: #334155;
  user-select: all;
}

.products-table .col-num {
  text-align: right;
  white-space: nowrap;
  width: 88px;
}

.products-table .col-num .sort-btn {
  width: 100%;
  justify-content: flex-end;
}

.products-table td.col-num {
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.products-table tr[data-product-row] {
  cursor: pointer;
}

.products-table tr[data-product-row].is-selected {
  background: #dbeafe;
  outline: 2px solid #3b82f6;
  outline-offset: -2px;
}

.products-table tr[data-product-row].is-selected td {
  background: transparent;
}

.products-table .col-actions {
  width: 148px;
  white-space: nowrap;
}

.product-cell-title {
  font-weight: 600;
  color: #0f172a;
}

.product-cell-meta {
  margin-top: 2px;
  font-size: 12px;
  color: #64748b;
  line-height: 1.35;
}

.product-status {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.product-status.active {
  background: #ecfdf5;
  color: #047857;
}

.product-status.inactive {
  background: #f1f5f9;
  color: #64748b;
}

.products-pager {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 12px;
}

.products-pager button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.product-form-panel {
  margin-bottom: 20px;
}

.product-form-panel summary {
  cursor: pointer;
  padding: 8px 0 12px;
  color: #2563eb;
  font-size: 15px;
}

.product-form-panel[open] summary {
  margin-bottom: 8px;
}

.search-field input[type="search"] {
  padding: 10px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 14px;
  width: 100%;
}

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

  .products-count {
    grid-column: 1 / -1;
    justify-self: start;
  }
}

@media (min-width: 1100px) {
  .layout {
    grid-template-columns: 1fr;
    align-items: start;
  }
}

.receipt-payables-panel {
  margin: 1.25rem 0;
  padding: 1rem;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  background: #f8fafc;
}

.receipt-payables-panel h3 {
  margin-top: 0;
}

.receipt-installments-table input {
  width: 100%;
  min-width: 8rem;
}

.receipt-installments-summary {
  margin-top: 0.5rem;
}

.receipt-existing-panel {
  margin: 1rem 0;
  padding: 0.85rem 1rem;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  background: #fff;
}

.receipt-existing-panel h3 {
  margin: 0 0 0.5rem;
  font-size: 1rem;
}

.receipt-existing-lookup {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.receipt-existing-lookup input {
  flex: 1 1 220px;
  min-width: 180px;
}

.receipt-payment-mode {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}

.radio-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.7rem;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
}

.radio-chip input {
  margin: 0;
}

.receipt-linked-product {
  display: block;
  font-size: 0.75rem;
  color: #2563eb;
  margin-top: 0.2rem;
}

#receipt-paid-panel label {
  display: block;
  max-width: 420px;
}

#receipt-paid-panel select {
  width: 100%;
  margin-top: 0.25rem;
}

.purchase-note-detail {
  margin-top: 1.5rem;
  padding: 1rem;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  background: #f8fafc;
}

.purchase-note-detail h4 {
  margin-bottom: 0.5rem;
}

.purchase-note-photo {
  display: block;
  max-width: min(100%, 900px);
  max-height: 65vh;
  object-fit: contain;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  background: #f8fafc;
}

.transfer-toolbar {
  margin: 12px 0;
}

.transfer-search-wrap {
  position: relative;
  flex: 1 1 280px;
  min-width: 220px;
}

.transfer-search-wrap input {
  width: 100%;
}

.transfer-search-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 280px;
  overflow-y: auto;
  background: #fff;
  border: 1px solid #dbe3ee;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
  z-index: 20;
}

.transfer-search-results button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  background: transparent;
  border: none;
  border-bottom: 1px solid #f1f5f9;
  color: #0f172a;
  font-size: 13px;
  cursor: pointer;
}

.transfer-search-results button:hover {
  background: #f8fafc;
}

.transfer-search-results .search-meta {
  display: block;
  font-size: 12px;
  color: #64748b;
  margin-top: 2px;
}

.transfer-grid .product-cell {
  font-size: 13px;
  color: #334155;
  min-width: 160px;
}

.transfer-grid .stock-cell {
  text-align: right;
  white-space: nowrap;
  font-size: 13px;
}

.transfer-grid .stock-cell.low {
  color: #dc2626;
  font-weight: 600;
}

.transfer-grid .sku-input {
  min-width: 110px;
}

.transfer-grid .qty-input {
  width: 72px;
  text-align: right;
}

.transfer-workspace {
  display: grid;
  grid-template-columns: minmax(220px, 280px) 1fr;
  gap: 16px;
  margin-bottom: 24px;
  align-items: start;
}

.transfer-drafts-panel {
  border: 1px solid #dbe3ee;
  border-radius: 10px;
  background: #f8fafc;
  padding: 12px;
  max-height: 640px;
  display: flex;
  flex-direction: column;
}

.transfer-drafts-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}

.transfer-drafts-header h3 {
  margin: 0;
  font-size: 15px;
}

.transfer-drafts-list {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.transfer-draft-card {
  text-align: left;
  padding: 10px 12px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
}

.transfer-draft-card:hover {
  border-color: #94a3b8;
}

.transfer-draft-card.active {
  border-color: #2563eb;
  box-shadow: 0 0 0 1px #2563eb;
}

.transfer-draft-card strong {
  display: block;
  font-size: 13px;
}

.transfer-draft-card .draft-store {
  display: block;
  font-size: 13px;
  margin-top: 2px;
}

.transfer-draft-card .draft-meta {
  display: block;
  font-size: 12px;
  color: #64748b;
  margin-top: 4px;
}

.transfer-editor-panel {
  border: 1px solid #dbe3ee;
  border-radius: 10px;
  padding: 16px;
  min-height: 360px;
}

.transfer-editor-empty {
  padding: 48px 16px;
  text-align: center;
}

.transfer-editor-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
}

.transfer-editor-header h3 {
  margin: 0 0 4px;
}

.transfer-save-status.saving {
  color: #2563eb;
}

.transfer-save-status.saved {
  color: #16a34a;
}

.transfer-save-status.error {
  color: #dc2626;
}

.transfers-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: end;
  margin: 0.75rem 0 1rem;
}

.transfers-toolbar label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 220px;
}

.transfer-detail-meta {
  display: grid;
  gap: 0.25rem;
  margin: 0.75rem 0;
}

.status-badge {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
}

.status-badge.status-draft {
  background: #e2e8f0;
  color: #334155;
}

.status-badge.status-shipped {
  background: #ffedd5;
  color: #c2410c;
}

.status-badge.status-partial {
  background: #fef08a;
  color: #854d0e;
}

.status-badge.status-received {
  background: #dcfce7;
  color: #166534;
}

.status-badge.status-cancelled {
  background: #fee2e2;
  color: #991b1b;
}

.status-badge.status-ordered {
  background: #dbeafe;
  color: #1d4ed8;
}

.status-badge.status-note-received {
  background: #dcfce7;
  color: #166534;
}

.purchase-notes-table tbody tr.note-row-ordered {
  background: linear-gradient(90deg, rgba(37, 99, 235, 0.06), transparent 40%);
}

.purchase-notes-table tbody tr.note-row-received {
  background: transparent;
}

.purchase-notes-table .note-number {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-weight: 650;
  letter-spacing: 0.01em;
}

.purchase-notes-table .note-payable-due {
  color: #b45309;
  font-weight: 650;
}

.purchase-notes-table .note-payable-clear {
  color: #64748b;
}

.purchase-notes-table .note-photo-yes,
.purchase-notes-table .note-photo-no {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 12px;
  font-weight: 650;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
}

.purchase-notes-table .note-photo-yes {
  background: #ecfdf5;
  color: #047857;
}

.purchase-notes-table .note-photo-no {
  background: #f1f5f9;
  color: #64748b;
}

.purchase-notes-table .note-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}

.danger-link {
  background: transparent;
  color: #dc2626;
  border: none;
  text-decoration: underline;
  cursor: pointer;
  padding: 8px 12px;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 1000;
}

.modal-overlay.hidden {
  display: none;
}

.modal-card {
  width: min(920px, 100%);
  max-height: calc(100vh - 48px);
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.2);
  display: flex;
  flex-direction: column;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #e2e8f0;
}

.modal-header h3 {
  margin: 0;
  font-size: 18px;
}

.modal-close {
  background: transparent;
  border: none;
  font-size: 24px;
  line-height: 1;
  color: #64748b;
  cursor: pointer;
  padding: 0 4px;
}

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

.modal-footer {
  padding: 12px 20px 16px;
  border-top: 1px solid #e2e8f0;
}

.transfer-picker-table-wrap {
  max-height: 420px;
  margin-top: 12px;
}

.transfer-note-filters {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 4px;
}

@media (max-width: 720px) {
  .transfer-note-filters {
    grid-template-columns: 1fr;
  }
}

.transfer-picker-table-wrap input[type="number"] {
  width: 72px;
}

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

.detail-panel {
  margin-top: 1.5rem;
  padding: 1rem;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  background: #f8fafc;
}

.detail-panel h4 {
  margin: 0 0 12px;
}

.detail-panel .detail-actions {
  margin-top: 12px;
}

.accounts-branch-filter {
  display: inline-flex;
  flex-direction: column;
  gap: 0.25rem;
  margin: 0.75rem 0 1rem;
  max-width: 280px;
}

.account-detail-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.account-detail-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  background: #f8fafc;
}

.account-detail-header h2 {
  margin: 0.15rem 0;
}

.account-detail-balance {
  text-align: right;
}

.account-detail-balance strong {
  display: block;
  font-size: 1.6rem;
  margin-top: 0.15rem;
}

.account-detail-ops {
  display: grid;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

@media (min-width: 900px) {
  .account-detail-ops {
    grid-template-columns: 1fr 1fr;
  }
}

.account-detail-movements h3 {
  margin-bottom: 0.35rem;
}

.account-movement-in {
  color: #15803d;
  font-weight: 600;
}

.account-movement-out {
  color: #b91c1c;
  font-weight: 600;
}

/* Dashboard */
.dashboard-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.dashboard-header h2 {
  margin: 0 0 4px;
}

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

.dashboard-filters label {
  min-width: 140px;
}

.dashboard-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
}

.preset-btn {
  background: #e2e8f0;
  color: #334155;
  padding: 6px 14px;
  font-size: 13px;
}

.preset-btn.active {
  background: #2563eb;
  color: #fff;
}

.dashboard-loading {
  padding: 40px;
  text-align: center;
  color: #64748b;
}

.section-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 32px 20px;
  text-align: center;
  color: #64748b;
  font-size: 14px;
}

.section-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid #bfdbfe;
  border-top-color: #2563eb;
  border-radius: 50%;
  animation: receipt-spin 0.7s linear infinite;
  flex-shrink: 0;
}

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

.app-initial-loading {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 12px;
  padding: 10px 16px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  color: #1e40af;
  font-size: 14px;
}

.app-initial-loading.error {
  background: #fef2f2;
  border-color: #fecaca;
  color: #b91c1c;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.kpi-card {
  background: linear-gradient(135deg, #f8fafc 0%, #eef2ff 100%);
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 16px;
  display: grid;
  gap: 4px;
}

.kpi-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #64748b;
}

.kpi-value {
  font-size: 22px;
  line-height: 1.2;
}

.kpi-card.positive .kpi-value { color: #047857; }
.kpi-card.negative .kpi-value { color: #b91c1c; }

.kpi-sub {
  font-size: 12px;
  color: #64748b;
}

.cash-detail-kpis {
  margin-bottom: 1.25rem;
}

.cash-session-sales-list {
  display: grid;
  gap: 0.75rem;
}

.cash-sale-card {
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 0.65rem 0.85rem;
  background: #f8fafc;
}

.cash-sale-card summary {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) auto minmax(0, 1fr) minmax(0, 0.8fr);
  gap: 0.5rem 1rem;
  align-items: center;
  cursor: pointer;
  list-style: none;
}

.cash-sale-card summary::-webkit-details-marker {
  display: none;
}

.cash-sale-card[open] {
  background: #fff;
}

.cash-sale-card .table-wrap {
  margin-top: 0.5rem;
}
}

.dashboard-charts-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.dashboard-grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.dashboard-grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.dashboard-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 16px;
}

.dashboard-card h3 {
  margin: 0 0 12px;
  font-size: 16px;
}

.chart-card {
  min-height: 280px;
}

.chart-card canvas {
  max-height: 240px;
}

.dashboard-stats-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.dashboard-stats-list li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid #e2e8f0;
}

.dashboard-stats-list li:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.positive { color: #059669; }
.negative { color: #dc2626; }

.prenotas-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(280px, 0.9fr);
  gap: 16px;
  align-items: start;
}

.prenotas-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: end;
  margin-bottom: 10px;
}

.prenotas-toolbar label {
  display: grid;
  gap: 4px;
  font-size: 13px;
}

.prenotas-toolbar input,
.prenotas-toolbar select {
  min-width: 0;
}

.prenotas-table-wrap {
  max-height: 70vh;
}

.prenotas-table .prenotas-supplier {
  min-width: 140px;
  max-width: 200px;
}

.prenotas-drafts-panel {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 12px;
  position: sticky;
  top: 12px;
}

.prenotas-drafts-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.prenotas-drafts-list {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
  max-height: 280px;
  overflow: auto;
}

.prenota-draft-card {
  display: grid;
  gap: 2px;
  text-align: left;
  padding: 10px 12px;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
}

.prenota-draft-card.active {
  border-color: #2563eb;
  box-shadow: 0 0 0 1px #2563eb;
}

.prenota-draft-card .draft-store {
  font-weight: 600;
}

.prenota-draft-card .draft-meta {
  color: #64748b;
  font-size: 12px;
}

.prenotas-detail {
  border-top: 1px solid #e2e8f0;
  padding-top: 12px;
  display: grid;
  gap: 10px;
}

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

  .prenotas-drafts-panel {
    position: static;
  }
}

@media (max-width: 768px) {
  .dashboard-filters {
    width: 100%;
  }

  .dashboard-filters label {
    flex: 1 1 100%;
  }
}
