:root {
  --bg: #f5f9ff;
  --surface: #ffffff;
  --surface-2: #eef5ff;
  --ink: #10243f;
  --muted: #6c7d91;
  --line: #dbe7f5;
  --accent: #2557a6;
  --accent-dark: #183f82;
  --accent-soft: #eaf1fb;
  --warning: #b7791f;
  --danger: #b42318;
  --ok: #2557a6;
  --shadow: 0 18px 45px rgba(37, 87, 166, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
}

img {
  max-width: 100%;
}

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

button {
  border: 0;
  cursor: pointer;
}

.language-switcher {
  position: fixed;
  top: 18px;
  right: 22px;
  z-index: 60;
}

.language-toggle {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #ffffff;
  color: var(--accent-dark);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  font-weight: 700;
  box-shadow: 0 10px 24px rgba(37, 87, 166, 0.12);
}

.language-globe {
  font-size: 16px;
  line-height: 1;
}

.language-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 88px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: var(--shadow);
  display: grid;
  gap: 4px;
}

.language-menu button {
  min-height: 32px;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
}

.language-menu button.active,
.language-menu button:hover {
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.warehouse-picker {
  min-width: 240px;
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.warehouse-picker select {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: #ffffff;
  color: var(--ink);
  font-weight: 650;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px 1fr;
}

.sidebar {
  min-width: 0;
  background: #ffffff;
  color: var(--ink);
  border-right: 1px solid var(--line);
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
}

.brand-logo {
  display: block;
  width: 130px;
  height: 48px;
  max-width: 100%;
  object-fit: contain;
  object-position: left center;
}

.brand h1 {
  margin: 0;
  font-size: 18px;
  overflow-wrap: anywhere;
}

.brand p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

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

.nav button {
  min-height: 42px;
  color: #52657c;
  background: transparent;
  border-radius: 8px;
  padding: 0 12px;
  display: grid;
  grid-template-columns: 16px 1fr;
  align-items: center;
  column-gap: 10px;
  text-align: left;
  line-height: 1.25;
}

.nav button span:first-child {
  display: inline-flex;
  width: 16px;
  justify-content: center;
  line-height: 1;
}

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

.sidebar-footer {
  margin-top: auto;
  display: grid;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}

.main {
  min-width: 0;
  padding: 24px;
  display: grid;
  gap: 20px;
  align-content: start;
}

.topbar {
  min-height: 64px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.page-title h2 {
  margin: 0;
  font-size: 24px;
}

.page-title p {
  margin: 4px 0 0;
  color: var(--muted);
  max-width: 860px;
  line-height: 1.45;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-size: 13px;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.search {
  min-width: min(100%, 360px);
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  padding: 0 12px;
  box-shadow: 0 8px 20px rgba(37, 87, 166, 0.04);
}

.button {
  min-height: 40px;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 650;
  line-height: 1.2;
  text-align: center;
  white-space: nowrap;
  box-shadow: 0 10px 22px rgba(37, 87, 166, 0.2);
}

.button:hover {
  background: var(--accent-dark);
}

.button:disabled {
  opacity: 0.52;
  cursor: not-allowed;
  box-shadow: none;
}

.button.secondary {
  background: #ffffff;
  border: 1px solid var(--line);
  color: var(--accent-dark);
  box-shadow: none;
}

.button.danger {
  background: var(--danger);
}

.button.success {
  background: #15803d;
}

.button.success:hover {
  background: #166534;
}

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

.inventory-toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.inventory-export-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 166px;
}

.inventory-export-button img {
  flex: 0 0 18px;
  filter: brightness(0) invert(1);
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.product-showcase {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 26px;
  display: grid;
  gap: 24px;
}

.product-category-line {
  display: flex;
  justify-content: center;
  gap: 24px;
  color: var(--muted);
  font-size: 14px;
  flex-wrap: wrap;
}

.product-category-line button,
.product-subcategory-line button {
  min-height: 36px;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  padding: 0 14px;
  font-weight: 650;
  line-height: 1.2;
  text-align: center;
}

.product-category-line button {
  font-size: 16px;
  min-width: 180px;
}

.product-category-line button.active,
.product-subcategory-line button.active {
  color: var(--accent);
  font-weight: 700;
}

.product-category-line button:hover,
.product-subcategory-line button:hover {
  color: var(--accent-dark);
  background: var(--accent-soft);
}

.product-subcategory-line {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.product-subcategory-line button {
  border: 1px solid var(--line);
  background: #ffffff;
  font-size: 13px;
  min-width: 132px;
}

.product-subcategory-line button.active {
  border-color: #b9cdec;
  background: var(--accent-soft);
}

.category-manager {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  display: grid;
  gap: 12px;
}

.inline-command {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-start;
}

.product-grid {
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 18px;
}

.customer-order-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 18px;
  align-items: start;
}

.customer-order-workspace .product-showcase {
  min-width: 0;
}

.product-card {
  min-height: 430px;
  background: #ffffff;
  border: 1px solid #edf0f1;
  border-radius: 8px;
  overflow: hidden;
  display: grid;
  grid-template-rows: minmax(245px, 1fr) auto auto;
  box-shadow: 0 14px 32px rgba(37, 87, 166, 0.08);
  transition: transform 180ms ease, box-shadow 180ms ease;
}

.product-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 20px 42px rgba(37, 87, 166, 0.14);
}

.product-image {
  position: relative;
  min-height: 245px;
  padding: 24px;
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, #ffffff 0%, #f4f9ff 100%);
}

.product-image-link {
  color: inherit;
  text-decoration: none;
  cursor: pointer;
}

.product-image-link:hover img,
.product-image-link:focus-visible img {
  transform: scale(1.02);
}

.product-image img {
  width: 100%;
  height: 220px;
  object-fit: contain;
  transition: transform 180ms ease;
}

.product-image img.product-image-cropped {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.product-image-placeholder {
  width: 190px;
  height: 190px;
  display: grid;
  place-items: center;
  border: 1px dashed #cbd5d8;
  color: #8b9aa1;
  font-weight: 800;
}

.stock-badge {
  position: absolute;
  top: 14px;
  right: 14px;
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  border: 1px solid #b9cdec;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 700;
}

.card-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
}

.sku {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
}

.product-copy {
  padding: 4px 20px 16px;
  text-align: center;
}

.product-copy h3 {
  margin: 7px 0 8px;
  font-size: 17px;
  font-weight: 700;
}

.product-copy p {
  min-height: 24px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.product-copy p span {
  display: inline-block;
  padding: 0 7px;
  color: #a6b2b7;
}

.product-copy .product-description,
.products-table .product-description,
.products-table .muted-cell {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.stock {
  text-align: right;
  min-width: 76px;
}

.stock strong {
  display: block;
  font-size: 20px;
}

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

.qty-row,
.product-actions {
  display: grid;
  grid-template-columns: 1fr 96px;
  gap: 10px;
  align-items: center;
}

.product-actions {
  min-height: 58px;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  grid-template-columns: minmax(0, 1fr) auto;
}

.qty-row input,
.product-actions input {
  width: 96px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
}

.order-qty-control {
  display: grid;
  grid-template-columns: 88px 38px;
  gap: 8px;
  align-items: center;
}

.order-qty-control input {
  width: 88px;
}

.order-qty-control .button {
  width: 38px;
  min-width: 38px;
  height: 38px;
  min-height: 38px;
  padding: 0;
  font-size: 18px;
}

.customer-product-toolbar {
  justify-content: flex-start;
}

.order-draft-panel {
  position: sticky;
  top: 24px;
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: var(--shadow);
}

.draft-header,
.draft-total,
.draft-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.draft-header h3 {
  margin: 0;
  font-size: 16px;
  min-width: 0;
  overflow-wrap: anywhere;
}

.draft-lines {
  display: grid;
  gap: 10px;
  max-height: 220px;
  overflow: auto;
}

.draft-empty {
  padding: 14px;
  border: 1px dashed #cbd5d8;
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

.draft-line {
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.draft-line > div {
  min-width: 0;
}

.draft-line strong,
.draft-line small {
  display: block;
  overflow-wrap: anywhere;
}

.draft-line small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.draft-line span {
  font-weight: 700;
  white-space: nowrap;
}

.draft-total {
  min-height: 48px;
  padding: 12px;
  border-radius: 8px;
  background: #f8fbff;
  border: 1px solid var(--line);
}

.draft-total span {
  color: var(--muted);
  font-weight: 650;
  min-width: 0;
  overflow-wrap: anywhere;
}

.draft-total strong {
  font-size: 18px;
  text-align: right;
  overflow-wrap: anywhere;
}

.checkout-card-section {
  display: grid;
  gap: 10px;
}

.checkout-card-section h4 {
  margin: 0;
  font-size: 14px;
}

.checkout-card-section p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

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

.checkout-address-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: start;
  background: #ffffff;
  cursor: pointer;
  min-width: 0;
}

.checkout-address-card > span {
  min-width: 0;
}

.checkout-address-card strong {
  display: block;
  overflow-wrap: anywhere;
}

.checkout-address-card.selected {
  border-color: #7f9ed0;
  background: var(--accent-soft);
}

.checkout-address-card small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.draft-note textarea {
  resize: vertical;
}

.draft-actions {
  display: grid;
  gap: 8px;
}

.summary-band {
  background: #ffffff;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
}

.metric {
  min-height: 96px;
  padding: 18px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
}

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

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

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

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

.panel-header h3 {
  margin: 0;
  font-size: 16px;
  min-width: 0;
  overflow-wrap: anywhere;
}

.panel-header p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.table-wrap {
  overflow-x: auto;
}

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

.data-table {
  table-layout: fixed;
  min-width: 980px;
}

.orders-table {
  min-width: 940px;
}

.after-sales-table {
  min-width: 900px;
}

.after-sales-table:has(.table-actions) {
  min-width: 1040px;
}

.locks-table {
  min-width: 1180px;
}

.products-table {
  min-width: 1120px;
}

.products-table .col-actions {
  width: 180px;
}

.users-table {
  min-width: 1120px;
}

.data-table .col-order-id {
  width: 250px;
}

.orders-table .col-order-id,
.after-sales-table .col-order-id {
  width: 280px;
}

.data-table .col-customer,
.data-table .col-name {
  width: 220px;
}

.data-table .col-date {
  width: 220px;
}

.data-table .col-qty,
.data-table .col-total,
.data-table .col-email,
.data-table .col-status,
.data-table .col-role,
.data-table .col-unit,
.data-table .col-price,
.data-table .col-stock,
.data-table .col-save {
  width: 130px;
}

.data-table .col-actions {
  width: 420px;
}

.orders-table .col-actions,
.after-sales-table .col-actions {
  width: 600px;
}

.data-table .col-sku {
  width: 150px;
}

.data-table .col-product,
.data-table .col-product-name {
  width: 230px;
}

.data-table .col-main,
.data-table .col-subcategory {
  width: 190px;
}

.data-table.products-table .col-sku {
  width: 300px;
}

.data-table.products-table .col-main {
  width: 130px;
}

.data-table.products-table .col-subcategory {
  width: 140px;
}

.data-table.products-table .col-unit {
  width: 90px;
}

.data-table .col-locked-qty,
.data-table .col-image {
  width: 150px;
}

.data-table .col-product-url {
  width: 220px;
}

.data-table .col-description {
  width: 280px;
}

.muted-cell {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  text-transform: none;
  white-space: normal;
  overflow-wrap: anywhere;
}

.data-table .col-email-address {
  width: 320px;
}

th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
  vertical-align: middle;
}

.data-table th,
.data-table td {
  overflow: hidden;
  text-overflow: ellipsis;
}

.products-table th:first-child,
.products-table td:first-child,
.products-table th:nth-child(3),
.products-table td:nth-child(3),
.products-table th:nth-child(4),
.products-table td:nth-child(4) {
  white-space: normal;
  overflow-wrap: anywhere;
  text-overflow: clip;
}

.orders-table th:first-child,
.orders-table td:first-child,
.after-sales-table th:first-child,
.after-sales-table td:first-child {
  overflow: visible;
  text-overflow: clip;
}

.data-table:has(.table-actions) th:last-child,
.data-table:has(.table-actions) td:last-child {
  position: sticky;
  right: 0;
  z-index: 2;
  background: #ffffff;
  box-shadow: -12px 0 20px rgba(37, 87, 166, 0.08);
}

.data-table:has(.table-actions) th:last-child {
  z-index: 3;
  background: #f6faff;
}

.data-table td:has(.table-actions),
.data-table td:has(input),
.data-table td:has(select),
.data-table td:has(.image-upload-cell) {
  overflow: visible;
  text-overflow: clip;
}

th {
  color: var(--muted);
  background: #f6faff;
  font-size: 12px;
  text-transform: uppercase;
}

td input,
td select,
.form-grid input,
.form-grid select,
.form-grid textarea {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: white;
}

td input:focus,
td select:focus,
.form-grid input:focus,
.form-grid select:focus,
.form-grid textarea:focus,
.field input:focus,
.field textarea:focus,
.search:focus {
  outline: 2px solid #b9cdec;
  border-color: #7f9ed0;
}

.image-upload-cell {
  display: grid;
  width: 116px;
  cursor: pointer;
}

.image-file-input {
  display: none;
}

.image-upload-preview {
  width: 116px;
  height: 54px;
  border: 1px dashed #a9bbd5;
  border-radius: 8px;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: #f8fbff;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
  line-height: 1.2;
}

.image-upload-preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #ffffff;
}

.image-upload-cell:hover .image-upload-preview {
  border-color: #6d8ec4;
  background: #eef5ff;
  color: var(--accent);
}

.form-image-upload,
.form-image-upload .image-upload-preview {
  width: 180px;
}

.form-image-upload .image-upload-preview {
  height: 96px;
}

textarea {
  resize: vertical;
}

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

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

.form-grid.order-filters {
  grid-template-columns: minmax(180px, 1.2fr) repeat(2, minmax(155px, 0.8fr)) minmax(180px, 1.2fr) auto;
  align-items: end;
  gap: 12px;
  padding: 0;
  margin: 0 0 20px;
}

.order-filters input,
.order-filters select {
  min-width: 0;
  height: 38px;
}

.order-filters .button {
  min-height: 38px;
}

@media (max-width: 1200px) {
  .form-grid.order-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .order-filters .button { justify-self: start; }
}

@media (max-width: 600px) {
  .form-grid.order-filters { grid-template-columns: minmax(0, 1fr); }
}

.password-field {
  position: relative;
  display: block;
  min-width: 0;
}

.password-field input {
  padding-right: 44px;
}

.password-toggle {
  position: absolute;
  top: 50%;
  right: 6px;
  width: 30px;
  height: 30px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  transform: translateY(-50%);
  background: transparent;
  color: var(--accent-dark);
  font-size: 15px;
  line-height: 1;
}

.password-toggle:hover,
.password-toggle.active {
  background: var(--accent-soft);
}

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

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

.panel > .form-grid {
  padding: 16px;
}

.form-grid.compact {
  padding: 0;
}

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

.form-grid label.checkline input {
  width: auto;
  min-height: auto;
}

.after-sales-add-row {
  display: grid;
  grid-template-columns: minmax(220px, 1.4fr) minmax(180px, 1fr) auto;
  gap: 12px;
  align-items: end;
  padding: 14px;
}

.after-sales-add-row label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.after-sales-add-row .button {
  min-height: 40px;
}

.choice-field {
  width: 100%;
  min-height: 54px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  padding: 10px 12px;
  text-align: left;
  display: grid;
  gap: 4px;
  cursor: pointer;
}

.choice-field:disabled {
  cursor: not-allowed;
  background: #f5f8fc;
  color: var(--muted);
}

.choice-field strong {
  color: var(--text);
  overflow-wrap: anywhere;
}

.choice-field span {
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.choice-field:hover:not(:disabled) {
  border-color: #7f9ed0;
  box-shadow: 0 0 0 2px rgba(47, 94, 171, 0.12);
}

.picker-toolbar {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr)) auto;
  gap: 12px;
  padding: 16px;
  align-items: end;
  border-bottom: 1px solid var(--line);
}

.picker-toolbar label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.picker-toolbar input {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
}

.picker-table-wrap,
.picker-card-list {
  padding: 16px;
}

.picker-table {
  min-width: 760px;
}

.picker-row {
  cursor: pointer;
}

.picker-row:hover td {
  background: #f6faff;
}

.picker-card-list {
  display: grid;
  gap: 12px;
}

.picker-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  background: #ffffff;
  cursor: pointer;
}

.picker-card:hover {
  border-color: #7f9ed0;
  background: #f8fbff;
}

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

.address-list {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.address-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  background: #ffffff;
  box-shadow: 0 10px 26px rgba(37, 87, 166, 0.06);
  min-width: 0;
}

.address-card > div:first-child {
  min-width: 0;
}

.address-title {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex-wrap: wrap;
}

.address-title strong {
  min-width: 0;
  overflow-wrap: anywhere;
}

.address-card p {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.payment-info-list {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.payment-info-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #ffffff;
  display: grid;
  gap: 12px;
}

.payment-info-summary {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}

.address-actions,
.modal-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.address-actions .button,
.modal-actions .button {
  min-width: 128px;
}

.form-actions {
  display: flex;
  align-items: end;
  min-width: 0;
}

.table-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.table-actions .button {
  min-width: 104px;
}

.link-manager-button {
  width: 128px;
}

.readonly-stock {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  min-width: 112px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f8fbff;
  color: var(--text);
  font-weight: 700;
}

.price-language-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 160px;
  gap: 12px;
  grid-column: 1 / -1;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(16, 36, 63, 0.32);
  display: grid;
  place-items: center;
  padding: 20px;
}

.modal {
  width: min(100%, 680px);
  max-height: min(90vh, 760px);
  overflow: auto;
  background: #ffffff;
  border-radius: 8px;
  box-shadow: 0 28px 80px rgba(16, 36, 63, 0.22);
}

.modal-wide {
  width: min(100%, 1040px);
}

.order-table-form {
  display: grid;
  gap: 14px;
  padding: 16px;
}

.order-table-wrap {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.order-draft-table {
  min-width: 880px;
}

.order-draft-table td strong,
.order-draft-table td small {
  display: block;
}

.order-draft-table td small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.order-draft-table input {
  width: 96px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
}

.order-draft-table .button {
  min-width: 88px;
}

.order-add-row td {
  padding: 14px;
  background: #f8fbff;
}

.order-add-button {
  width: 100%;
  min-height: 56px;
  border: 1px dashed #a9bbd5;
  border-radius: 8px;
  background: #ffffff;
  color: var(--accent-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-weight: 700;
}

.order-add-button:hover {
  background: var(--accent-soft);
  border-color: #7f9ed0;
}

.order-add-button span {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: var(--accent);
  color: #ffffff;
  display: inline-grid;
  place-items: center;
  font-size: 22px;
  line-height: 1;
}

.product-picker {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  display: grid;
  gap: 12px;
  background: #f8fbff;
}

.product-picker-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.product-picker-header h4 {
  margin: 0;
  font-size: 15px;
}

.product-picker-header p {
  margin: 4px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.product-picker-list {
  display: grid;
  gap: 8px;
  max-height: 330px;
  overflow: auto;
}

.product-picker-option {
  width: 100%;
  min-height: 66px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  padding: 10px 12px;
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 120px 130px auto;
  align-items: center;
  gap: 12px;
  text-align: left;
}

.product-picker-option > * {
  min-width: 0;
}

.product-picker-option:hover {
  border-color: #b9cdec;
  background: var(--accent-soft);
}

.product-picker-option strong,
.product-picker-option small {
  display: block;
  overflow-wrap: anywhere;
}

.product-picker-option small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.product-picker-option .button {
  min-width: 88px;
  box-shadow: none;
}

.order-table-footer {
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbff;
}

.order-table-footer span,
.order-table-footer strong {
  min-width: 0;
  overflow-wrap: anywhere;
}

.order-table-footer strong {
  font-size: 18px;
  text-align: right;
}

.order-details {
  display: grid;
  gap: 14px;
  padding: 16px;
}

.order-details-wrap {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.order-details-table {
  min-width: 760px;
}

.order-details-table td strong,
.order-details-table td small {
  display: block;
  overflow-wrap: anywhere;
}

.order-details-table td small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.order-details-total {
  min-height: 54px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.order-details-total span {
  color: var(--muted);
  font-weight: 650;
  min-width: 0;
  overflow-wrap: anywhere;
}

.order-details-total strong {
  font-size: 20px;
  text-align: right;
  overflow-wrap: anywhere;
}

.order-allocation {
  display: grid;
  gap: 12px;
}

.outbound-detail-summary {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbff;
  color: var(--muted);
  font-weight: 700;
}

.outbound-detail-summary span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.order-customer-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #ffffff;
}

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

.order-customer-grid div {
  min-height: 64px;
  padding: 12px 14px;
  border-top: 1px solid var(--line);
  min-width: 0;
}

.order-customer-grid div:nth-child(odd) {
  border-right: 1px solid var(--line);
}

.order-customer-grid span,
.order-customer-grid strong {
  display: block;
}

.order-customer-grid span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 6px;
}

.order-customer-grid strong {
  color: var(--text);
  overflow-wrap: anywhere;
}

.outbound-detail-group {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.panel-header.compact {
  min-height: 48px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.outbound-detail-group > .panel-header.compact {
  background: #fbfdff;
}

.order-allocation-table {
  min-width: 0;
  table-layout: fixed;
}

.order-allocation-table .col-allocation-product {
  width: 42%;
}

.order-allocation-table .col-allocation-action {
  width: 130px;
}

.order-allocation-table .col-allocation-qty {
  width: 120px;
}

.order-allocation-table .col-allocation-warehouse {
  width: 22%;
}

.order-allocation-table .col-allocation-detail {
  width: 130px;
}

.order-allocation-table th,
.order-allocation-table td {
  white-space: normal;
  overflow-wrap: anywhere;
}

.order-allocation-table .allocation-product-label span {
  min-width: 0;
}

.order-allocation-table .allocation-product-label strong,
.order-allocation-table .allocation-product-label small {
  display: block;
  overflow-wrap: anywhere;
}

.after-sales-detail-table {
  min-width: 860px;
}

.logistics-panel {
  padding: 14px;
  border-top: 1px solid var(--line);
}

.logistics-panel h4 {
  margin: 0 0 10px;
  font-size: 14px;
}

.logistics-timeline {
  display: grid;
  gap: 10px;
}

.logistics-event {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fbfdff;
}

.logistics-event div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.logistics-event span,
.logistics-event p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.order-allocation-table select,
.order-allocation-table input {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  background: #ffffff;
}

.order-allocation-table input {
  width: 100px;
}

.allocation-child-row td {
  background: #fbfdff;
}

.allocation-product-cell {
  position: relative;
}

.allocation-product-label {
  display: flex;
  align-items: center;
  gap: 10px;
}

.allocation-branch {
  width: 28px;
  height: 28px;
  border-left: 2px solid #b9cdec;
  border-bottom: 2px solid #b9cdec;
  border-bottom-left-radius: 8px;
  flex: 0 0 auto;
  margin-left: 8px;
  transform: translateY(-8px);
}

.allocation-child-row .allocation-product-label strong {
  color: var(--muted);
  font-size: 13px;
}

.allocation-child-row .allocation-product-label small {
  color: var(--ink);
}

.allocation-actions .button {
  min-width: 92px;
}

.crop-workspace {
  padding: 16px;
  display: grid;
  gap: 12px;
}

.crop-stage {
  width: min(100%, 640px);
  height: min(62vh, 560px);
  min-height: 360px;
  margin: 0 auto;
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  touch-action: none;
  cursor: grab;
}

.crop-stage:active {
  cursor: grabbing;
}

.crop-box {
  position: absolute;
  z-index: 2;
  left: 50%;
  top: 50%;
  width: min(500px, calc(100% - 72px));
  aspect-ratio: 500 / 490;
  transform: translate(-50%, -50%);
  border: 2px solid #4f9cff;
  border-radius: 4px;
  box-shadow: 0 0 0 9999px rgba(16, 28, 42, 0.48);
  pointer-events: none;
}

.crop-image {
  position: absolute;
  z-index: 1;
  top: 0;
  left: 0;
  max-width: none;
  transform-origin: 0 0;
  user-select: none;
  pointer-events: none;
}

.crop-zoom-control {
  width: min(100%, 640px);
  margin: 0 auto;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) 52px;
  gap: 12px;
  align-items: center;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.crop-zoom-control input {
  width: 100%;
  accent-color: var(--accent);
}

.crop-zoom-control strong {
  color: var(--accent-dark);
  text-align: right;
}

.confirm-order {
  padding: 16px;
  display: grid;
  gap: 14px;
}

.address-options {
  display: grid;
  gap: 10px;
}

.address-option {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: start;
  background: #ffffff;
  min-width: 0;
}

.address-option > span {
  min-width: 0;
}

.address-option strong {
  display: block;
  overflow-wrap: anywhere;
}

.address-option small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.login-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  background: #ffffff;
}

.login-visual {
  padding: 48px;
  color: white;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background:
    linear-gradient(120deg, rgba(20, 62, 126, 0.9), rgba(37, 87, 166, 0.72)),
    url("https://images.unsplash.com/photo-1581092335397-9583eb92d232?auto=format&fit=crop&w=1600&q=80") center / cover;
}

.login-visual h1 {
  margin: 0;
  max-width: 680px;
  font-size: 46px;
  line-height: 1.05;
}

.login-visual p {
  max-width: 540px;
  color: #eaf5ff;
  line-height: 1.6;
}

.login-panel {
  min-height: 100vh;
  background: linear-gradient(180deg, #ffffff 0%, #f4f9ff 100%);
  display: grid;
  place-items: center;
  padding: 28px;
}

.login-box {
  width: min(100%, 420px);
  display: grid;
  gap: 18px;
}

.login-box h2 {
  margin: 0;
  font-size: 24px;
}

.login-context {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.login-box form,
.order-form {
  display: grid;
  gap: 12px;
}

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

.field input,
.field textarea {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
}

.notice {
  border-radius: 8px;
  padding: 12px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.notice.error {
  background: #fff1f0;
  color: var(--danger);
}

.status {
  font-weight: 650;
}

.status.ok {
  color: var(--ok);
}

.status.warn {
  color: var(--warning);
}

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

.hidden {
  display: none !important;
}

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

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 5;
    padding: 14px;
  }

  .nav {
    grid-auto-flow: column;
    overflow-x: auto;
  }

  .sidebar-footer {
    display: none;
  }

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

  .customer-order-workspace {
    grid-template-columns: 1fr;
  }

  .order-draft-panel {
    position: static;
  }

  .login-page {
    grid-template-columns: 1fr;
  }

  .login-visual {
    min-height: 36vh;
  }

  .login-panel {
    min-height: auto;
  }
}

@media (max-width: 620px) {
  .main {
    padding: 16px;
  }

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

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

  .after-sales-add-row {
    grid-template-columns: 1fr;
  }

  .address-card,
  .payment-info-summary {
    grid-template-columns: 1fr;
  }

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

  .order-table-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .order-details-total {
    align-items: stretch;
    flex-direction: column;
  }

  .product-picker-header {
    align-items: stretch;
    flex-direction: column;
  }

  .product-picker-header .search {
    width: 100%;
  }

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

  .product-showcase {
    padding: 18px;
  }

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

  .order-qty-control {
    grid-template-columns: 1fr 42px;
  }

  .order-qty-control input {
    width: 100%;
  }

  .product-category-line {
    justify-content: flex-start;
    overflow-x: auto;
  }

  .product-subcategory-line {
    justify-content: flex-start;
  }

  .login-visual {
    padding: 28px;
  }

  .login-visual h1 {
    font-size: 34px;
  }
}
