:root {
  --background: #f8fafc;
  --foreground: #0f172a;
  --card: #ffffff;
  --muted: #f1f5f9;
  --muted-foreground: #64748b;
  --border: #e2e8f0;
  --input: #cbd5e1;
  --primary: #2563eb;
  --primary-foreground: #ffffff;
  --accent: #06b6d4;
  --danger: #dc2626;
  --sidebar: #f8fafc;
  --sidebar-accent: #eff6ff;
  --sidebar-foreground: #0f172a;
  --radius: 10px;
  --shadow: 0 10px 24px rgba(15, 23, 42, 0.06);
}

* {
  box-sizing: border-box;
}

html,
body {
  max-width: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--foreground);
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  background:
    radial-gradient(circle at top left, #eef5ff 0, transparent 28rem),
    linear-gradient(180deg, #f8fafc 0%, var(--background) 18rem);
}

button,
input,
select {
  font: inherit;
}

button {
  border-radius: 8px;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  border-right: 1px solid rgba(226, 232, 240, 0.92);
  background: rgba(248, 250, 252, 0.96);
  box-shadow: 1px 0 0 rgba(226, 232, 240, 0.7);
  padding: 14px 8px;
}

.brand {
  display: grid;
  place-items: center;
  min-height: 54px;
  padding: 0 0 12px;
  position: relative;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 12px;
  background: linear-gradient(135deg, #2563eb, #06b6d4);
  color: #ffffff;
  font-size: 20px;
  font-weight: 900;
  box-shadow: 0 8px 18px rgba(37, 99, 235, 0.22);
}

.brand-menu-trigger {
  border: 0;
  cursor: pointer;
}

.brand-menu {
  position: absolute;
  top: 46px;
  left: 50%;
  z-index: 60;
  display: none;
  min-width: 86px;
  transform: translateX(-50%);
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #ffffff;
  padding: 6px;
  box-shadow: var(--shadow);
}

.brand-menu.open {
  display: block;
}

.brand-menu .button {
  width: 100%;
  min-height: 32px;
  padding: 5px 10px;
}

.brand-title {
  display: none;
}

.brand-subtitle {
  margin-top: 3px;
  color: var(--muted-foreground);
  font-size: 12px;
  font-weight: 700;
}

.nav-list {
  display: grid;
  gap: 6px;
  padding: 10px 0 14px;
  border-top: 1px solid rgba(226, 232, 240, 0.78);
}

.nav-item {
  position: relative;
  width: 100%;
  height: 42px;
  border: 0;
  background: transparent;
  color: rgba(15, 23, 42, 0.72);
  text-align: center;
  padding: 0;
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
  transition: background 0.16s ease, color 0.16s ease, box-shadow 0.16s ease;
}

.nav-item::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  width: 3px;
  height: 18px;
  transform: translateY(-50%);
  border-radius: 0 8px 8px 0;
  background: var(--primary);
  opacity: 0;
}

.nav-item.active {
  background: #dbeafe;
  color: #1d4ed8;
  box-shadow: inset 0 0 0 1px rgba(37, 99, 235, 0.16), 0 8px 18px rgba(37, 99, 235, 0.1);
}

.nav-item.active::before {
  opacity: 1;
}

.nav-item:hover {
  background: rgba(241, 245, 249, 0.9);
  color: #0f172a;
}

.main {
  min-width: 0;
  padding: 22px 24px 32px;
}

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

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 26px;
  line-height: 1.2;
  font-weight: 900;
}

h2 {
  font-size: 17px;
  font-weight: 900;
}

.topbar p,
.panel p,
.dialog-head p {
  margin-top: 7px;
  color: var(--muted-foreground);
  font-size: 13px;
}

.top-actions,
.button-row,
.dialog-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 9px;
  flex-wrap: wrap;
}

.button {
  min-height: 38px;
  border: 1px solid var(--border);
  padding: 8px 13px;
  background: #ffffff;
  color: #0f172a;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  transition: border-color 0.16s ease, background 0.16s ease, color 0.16s ease, box-shadow 0.16s ease;
}

.button.primary {
  border-color: var(--primary);
  background: var(--primary);
  color: var(--primary-foreground);
  box-shadow: 0 8px 18px rgba(37, 99, 235, 0.18);
}

.button.primary:hover {
  background: #1d4ed8;
}

.button.secondary:hover {
  border-color: rgba(37, 99, 235, 0.36);
  background: #eff6ff;
  color: #1d4ed8;
}

.logout-button {
  min-width: 68px;
}

.button.danger {
  border-color: rgba(220, 38, 38, 0.28);
  color: var(--danger);
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.role-pill {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid #bfdbfe;
  background: #eff6ff;
  color: #1d4ed8;
  font-size: 13px;
  font-weight: 900;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 300px) 150px 130px 130px 160px 112px minmax(330px, 1fr);
  align-items: end;
  gap: 12px;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.mobile-search-actions {
  display: flex;
  align-items: end;
  gap: 8px;
}

.mobile-search-actions .button {
  height: 42px;
  min-height: 42px;
  padding: 0 14px;
  font-size: 12px;
}

.grid-toggle {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  align-self: end;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #ffffff;
  color: #334155;
  cursor: pointer;
  padding: 0 10px;
  white-space: nowrap;
}

.grid-toggle input {
  width: 16px;
  min-height: 16px;
  height: 16px;
  accent-color: var(--primary);
}

.toolbar-actions {
  display: flex;
  align-items: end;
  justify-content: flex-end;
  gap: 12px;
  min-width: 0;
}

.toolbar-actions .button,
.toolbar-actions .file-button {
  height: 42px;
  min-height: 42px;
  padding: 0 18px;
  font-size: 12px;
}

.toolbar-actions .button.primary {
  min-width: 190px;
}

.file-button {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  border: 1px solid var(--border);
  background: #ffffff;
  color: #0f172a;
  padding: 8px 13px;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}

.file-button:hover {
  border-color: #bfdbfe;
  background: #eff6ff;
}

.file-button input {
  display: none;
}

.export-dialog {
  width: min(460px, calc(100vw - 36px));
}

.export-dialog-body {
  display: grid;
  gap: 16px;
}

.export-progress {
  display: grid;
  gap: 8px;
}

.export-progress-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted-foreground);
  font-size: 12px;
  font-weight: 800;
}

.export-progress-meta strong {
  color: var(--foreground);
}

.export-progress-track {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #e2e8f0;
}

.export-progress-bar {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--primary);
  transition: width 0.18s ease;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted-foreground);
  font-size: 12px;
  font-weight: 800;
}

input,
select {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--input);
  border-radius: 8px;
  background: #ffffff;
  color: var(--foreground);
  padding: 8px 10px;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.summary-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.summary-strip > div,
.panel,
.table-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
}

.summary-strip > div {
  padding: 14px 16px;
}

.summary-strip span:last-child {
  color: var(--muted-foreground);
  font-size: 12px;
  font-weight: 800;
}

.metric {
  display: block;
  color: #0f172a;
  font-size: 24px;
  font-weight: 900;
}

.table-wrap {
  overflow: auto;
}

.mobile-product-list {
  display: none;
}

table {
  width: 100%;
  min-width: 1260px;
  border-collapse: separate;
  border-spacing: 0;
}

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

.table-wrap.show-grid th,
.table-wrap.show-grid td {
  border-right: 1px solid rgba(203, 213, 225, 0.92);
}

.table-wrap.show-grid th:last-child,
.table-wrap.show-grid td:last-child {
  border-right: 0;
}

.table-wrap.show-grid tbody td {
  border-bottom-color: rgba(203, 213, 225, 0.92);
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f8fafc;
  color: #334155;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.field-help-anchor {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.field-help-text {
  color: #94a3b8;
  font-size: 11px;
  font-weight: 400;
  line-height: 1.35;
}

th[data-field="image"],
td[data-field="image"] {
  width: 24%;
  min-width: 220px;
}

th[data-field="price1000"],
th[data-field="price3000"],
th[data-field="price10000"],
th[data-field="price50000"] {
  text-align: center;
}

td {
  color: #1e293b;
  font-size: 13px;
}

.tier-price-cell {
  display: grid;
  gap: 12px;
  min-width: 78px;
}

.tier-price-line {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  line-height: 1.18;
  white-space: nowrap;
}

.tier-price-line em {
  color: #64748b;
  font-size: 11px;
  font-style: normal;
  font-weight: 800;
}

.tier-price-line strong {
  color: #0f172a;
  font-size: 13px;
  font-weight: 800;
}

.tier-price-line.tax-included strong {
  color: #0369a1;
}

tbody tr:hover td {
  background: #f8fbff;
}

tbody tr.row-hover td {
  background: #eef6ff;
}

th.col-hover,
td.col-hover {
  background: #eaf2ff;
}

tbody tr.row-hover td.col-hover {
  background: #dbeafe;
}

td.cell-hover {
  position: relative;
  background: #bfdbfe !important;
  box-shadow: inset 0 0 0 2px rgba(37, 99, 235, 0.7);
}

tbody tr {
  cursor: default;
}

tbody tr[data-product-id] {
  cursor: pointer;
}

td.inline-editable-cell {
  cursor: text;
}

td.inline-editable-cell:hover {
  box-shadow: inset 0 0 0 1px rgba(37, 99, 235, 0.28);
}

td.inline-editing {
  padding: 4px;
  background: #ffffff !important;
  box-shadow: inset 0 0 0 2px rgba(37, 99, 235, 0.58);
}

.inline-edit-input {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  min-height: 34px;
  box-sizing: border-box;
  border: 1px solid rgba(37, 99, 235, 0.38);
  border-radius: 6px;
  padding: 5px 8px;
  font-size: 13px;
  font-weight: 700;
}

td.inline-saving {
  opacity: 0.72;
}

.product-image,
.image-preview img {
  width: 54px;
  height: 54px;
  object-fit: cover;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--muted);
}

.image-placeholder {
  display: grid;
  width: 54px;
  height: 54px;
  place-items: center;
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  color: var(--muted-foreground);
  background: #f8fafc;
  font-size: 12px;
  font-weight: 800;
}

.image-placeholder-button {
  cursor: pointer;
}

.image-placeholder-button:hover {
  border-color: rgba(37, 99, 235, 0.56);
  color: #1d4ed8;
  background: #eff6ff;
}

.image-cell-list {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 184px;
  max-width: min(620px, 30vw);
  overflow: hidden;
}

.image-cell-button {
  display: inline-grid;
  width: 58px;
  height: 58px;
  flex: 0 0 58px;
  place-items: center;
  border: 0;
  background: transparent;
  padding: 0;
  cursor: zoom-in;
}

.image-cell-button:hover .product-image,
.preview-image-button:hover img,
.gallery-thumb:hover img {
  border-color: rgba(37, 99, 235, 0.56);
  box-shadow: 0 8px 18px rgba(37, 99, 235, 0.14);
}

.image-count {
  display: inline-grid;
  min-width: 28px;
  height: 28px;
  flex: 0 0 auto;
  place-items: center;
  border: 2px solid #ffffff;
  border-radius: 999px;
  background: #1d4ed8;
  color: #ffffff;
  font-size: 12px;
  font-weight: 900;
}

.row-actions {
  display: flex;
  gap: 8px;
  white-space: nowrap;
}

.text-button {
  border: 0;
  background: transparent;
  color: var(--primary);
  cursor: pointer;
  padding: 4px;
  font-size: 13px;
  font-weight: 900;
}

.text-button.danger {
  color: var(--danger);
}

.empty-state {
  display: none;
  padding: 42px 20px;
  text-align: center;
  color: var(--muted-foreground);
}

.empty-state strong {
  display: block;
  margin-bottom: 8px;
  color: var(--foreground);
  font-size: 17px;
}

.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.96);
  padding: 10px 12px;
  box-shadow: var(--shadow);
}

.pagination-info {
  color: #334155;
  font-size: 13px;
  font-weight: 900;
}

.pagination-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.compact-button-light {
  min-height: 32px;
  padding: 5px 10px;
  font-size: 12px;
}

.page-jump,
.page-size-select {
  display: flex;
  grid-template-columns: none;
  align-items: center;
  gap: 6px;
  color: #334155;
}

.page-jump input,
.page-size-select select {
  width: 70px;
  min-height: 32px;
  text-align: center;
}

.page-size-select select {
  width: 88px;
}

.export-scope-field {
  margin: 16px 0 14px;
}

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

.panel {
  padding: 18px;
}

.stack {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.field-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 16px;
}

.field-item {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f8fafc;
  padding: 12px;
}

.field-item strong {
  display: block;
  margin-bottom: 4px;
  color: #0f172a;
  font-size: 13px;
}

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

.hidden-field-picker {
  display: grid;
  gap: 8px;
  color: var(--muted-foreground);
  font-size: 12px;
  font-weight: 800;
}

.multi-select {
  position: relative;
}

.multi-select-trigger {
  position: relative;
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--input);
  border-radius: 8px;
  background: #ffffff;
  color: #0f172a;
  padding: 8px 34px 8px 10px;
  text-align: left;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}

.multi-select-trigger::after {
  content: "";
  position: absolute;
  right: 12px;
  top: 50%;
  width: 8px;
  height: 8px;
  border-right: 2px solid #64748b;
  border-bottom: 2px solid #64748b;
  transform: translateY(-70%) rotate(45deg);
}

.multi-select.open .multi-select-trigger {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.multi-select-menu {
  position: absolute;
  z-index: 80;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  display: none;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  max-height: 260px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #ffffff;
  padding: 10px;
  box-shadow: 0 18px 38px rgba(15, 23, 42, 0.14);
}

#accountHiddenFieldsSelect .multi-select-menu {
  top: auto;
  bottom: calc(100% + 6px);
  max-height: min(320px, calc(100vh - 180px));
}

.multi-select.open .multi-select-menu {
  display: grid;
}

.checkbox-item {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 28px;
  color: #0f172a;
  font-size: 13px;
  font-weight: 800;
}

.checkbox-item input {
  width: 16px;
  min-height: 16px;
  height: 16px;
  accent-color: var(--primary);
}

dialog {
  width: min(900px, calc(100vw - 32px));
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.24);
}

dialog::backdrop {
  background: rgba(15, 23, 42, 0.42);
}

.gallery-dialog::backdrop {
  background: rgba(15, 23, 42, 0.86);
}

#productForm,
#accountForm,
#passwordForm,
#exportForm {
  padding: 20px;
}

.login-dialog {
  width: min(420px, calc(100vw - 36px));
  border: 1px solid rgba(226, 232, 240, 0.94);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 28px 90px rgba(15, 23, 42, 0.28);
}

.login-dialog::backdrop {
  background:
    linear-gradient(rgba(15, 23, 42, 0.62), rgba(15, 23, 42, 0.62)),
    radial-gradient(circle at top left, rgba(37, 99, 235, 0.24), transparent 34rem);
}

.login-dialog.force-closed {
  display: none !important;
  pointer-events: none;
}

.login-dialog.force-closed::backdrop {
  background: transparent;
  pointer-events: none;
}

.login-card {
  padding: 34px 34px 30px;
}

.login-brand {
  display: grid;
  justify-items: center;
  gap: 8px;
  margin-bottom: 26px;
  text-align: center;
}

.login-mark {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  font-size: 24px;
}

.login-brand h2 {
  font-size: 24px;
  letter-spacing: 0;
}

.login-brand p {
  color: var(--muted-foreground);
  font-size: 13px;
  font-weight: 800;
}

.login-grid {
  display: grid;
  gap: 14px;
}

.login-grid input {
  min-height: 46px;
}

.login-error {
  display: none;
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid rgba(220, 38, 38, 0.26);
  border-radius: 8px;
  background: rgba(254, 242, 242, 0.92);
  color: #b91c1c;
  font-size: 13px;
  font-weight: 800;
  line-height: 1.45;
}

.login-error.show {
  display: block;
}

.login-actions {
  margin-top: 22px;
}

.login-submit {
  width: 100%;
  min-height: 44px;
  font-size: 15px;
}

.dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.icon-button {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #ffffff;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}

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

.price-row {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: repeat(4, minmax(104px, 1fr));
  gap: 10px;
}

.image-upload-field {
  grid-column: 1 / -1;
}

.image-upload-field input {
  display: none;
}

.image-preview {
  display: flex;
  grid-column: 1 / -1;
  flex-wrap: nowrap;
  gap: 10px;
  min-height: 74px;
  align-items: center;
  justify-content: flex-start;
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  background: #f8fafc;
  color: var(--muted-foreground);
  font-size: 13px;
  font-weight: 800;
  padding: 9px;
  overflow-x: auto;
}

.preview-thumb {
  position: relative;
  width: 62px;
  height: 62px;
}

.preview-image-button {
  display: grid;
  width: 62px;
  height: 62px;
  place-items: center;
  border: 0;
  background: transparent;
  padding: 0;
  cursor: zoom-in;
}

.preview-add {
  display: grid;
  width: 62px;
  height: 62px;
  flex: 0 0 62px;
  place-items: center;
  border: 1px dashed #93c5fd;
  border-radius: 8px;
  background: #eff6ff;
  color: #1d4ed8;
  font-size: 30px;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
}

.preview-add:hover {
  border-color: #2563eb;
  background: #dbeafe;
}

.preview-remove {
  position: absolute;
  top: -7px;
  right: -7px;
  display: grid;
  width: 22px;
  height: 22px;
  place-items: center;
  border: 2px solid #ffffff;
  border-radius: 999px;
  background: #dc2626;
  color: #ffffff;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 8px 14px rgba(220, 38, 38, 0.22);
}

.dialog-actions {
  margin-top: 18px;
}

.readonly-dialog input:disabled {
  border-color: #e2e8f0;
  background: #f8fafc;
  color: #0f172a;
  opacity: 1;
}

.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.compact-table {
  box-shadow: none;
}

.compact-table table {
  min-width: 920px;
}

.settings-tabs {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.settings-tab {
  min-height: 36px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #ffffff;
  color: #475569;
  padding: 0 14px;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
}

.settings-tab.active {
  border-color: #bfdbfe;
  background: #dbeafe;
  color: #1d4ed8;
  box-shadow: inset 0 0 0 1px rgba(37, 99, 235, 0.12);
}

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

.settings-tab-panel.active {
  display: block;
}

.settings-tab-panel .panel {
  margin: 0;
}

.settings-tab-panel .panel + .panel {
  margin-top: 14px;
}

.settings-form {
  display: grid;
  grid-template-columns: minmax(180px, 260px) max-content max-content;
  gap: 12px;
  align-items: end;
}

.storage-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.storage-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f8fafc;
  padding: 13px 14px;
}

.storage-card span {
  display: block;
  color: var(--muted-foreground);
  font-size: 12px;
  font-weight: 800;
}

.storage-card strong {
  display: block;
  margin-top: 6px;
  color: #0f172a;
  font-size: 20px;
  font-weight: 900;
}

.storage-note {
  margin-top: 12px;
}

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

.status-pill.success {
  background: #dcfce7;
  color: #166534;
}

.status-pill.danger {
  background: #fee2e2;
  color: #991b1b;
}

.gallery-dialog {
  width: fit-content;
  max-width: calc(100vw - 48px);
  height: fit-content;
  max-height: calc(100vh - 48px);
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  overflow: visible;
}

.gallery-dialog::backdrop {
  background: transparent;
}

.gallery-shell {
  display: grid;
  grid-template-rows: auto auto auto;
  width: fit-content;
  max-width: calc(100vw - 48px);
  max-height: calc(100vh - 48px);
  padding: 0;
  background: transparent;
}

.gallery-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  color: #ffffff;
}

.gallery-title-block h2 {
  color: #ffffff;
}

.gallery-title-block p {
  color: rgba(255, 255, 255, 0.72);
}

.gallery-tools {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.gallery-image-tools {
  display: flex;
  justify-content: center;
  gap: 10px;
  padding: 12px 0 0;
}

.compact-button {
  min-height: 34px;
  padding: 6px 10px;
  border-color: rgba(255, 255, 255, 0.2);
  background: rgba(15, 23, 42, 0.62);
  color: #ffffff;
  font-size: 12px;
}

.gallery-tool-button {
  width: 36px;
  min-width: 36px;
  height: 36px;
  min-height: 36px;
  padding: 0;
  justify-content: center;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 900;
  line-height: 1;
}

.gallery-tool-button#zoomResetBtn {
  width: 42px;
  min-width: 42px;
  font-size: 12px;
}

.gallery-tools .icon-button {
  border-color: rgba(255, 255, 255, 0.2);
  background: rgba(15, 23, 42, 0.62);
  color: #ffffff;
}

.gallery-stage {
  position: relative;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 0;
  background: transparent;
  padding: 0;
  overflow: hidden;
}

.gallery-stage img {
  width: auto;
  height: auto;
  max-width: calc(100vw - 48px);
  max-height: calc(100vh - 232px);
  object-fit: contain;
  justify-self: center;
  align-self: center;
  border-radius: 0;
  cursor: zoom-in;
  transition: transform 0.12s ease;
  transform-origin: center center;
  user-select: none;
  touch-action: none;
}

.gallery-stage img.is-zoomed {
  cursor: grab;
}

.gallery-stage img.is-dragging {
  cursor: grabbing;
  transition: none;
}

.gallery-loading {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 3;
  transform: translate(-50%, -50%);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.78);
  color: #ffffff;
  font-size: 13px;
  font-weight: 800;
  line-height: 1;
  padding: 12px 16px;
  pointer-events: none;
  white-space: nowrap;
}

.gallery-nav {
  display: none;
}

#prevImageBtn {
  left: 8px;
}

#nextImageBtn {
  right: 8px;
}

.gallery-nav:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.gallery-thumb-strip {
  display: grid;
  grid-template-columns: 34px minmax(0, auto) 34px;
  align-items: center;
  justify-self: center;
  width: fit-content;
  max-width: 100%;
  gap: 8px;
  padding: 12px 2px 0;
}

.gallery-thumb-nav {
  display: grid;
  width: 34px;
  height: 54px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(15, 23, 42, 0.62);
  color: #ffffff;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
}

.gallery-thumb-nav:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.gallery-thumbs {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  justify-content: center;
  max-width: min(calc(100vw - 128px), 560px);
  padding: 0;
}

.gallery-thumb {
  display: grid;
  width: 62px;
  height: 62px;
  flex: 0 0 auto;
  place-items: center;
  border: 2px solid transparent;
  background: transparent;
  padding: 0;
  cursor: pointer;
}

.gallery-thumb.active {
  border-color: #ffffff;
}

.gallery-thumb img {
  width: 54px;
  height: 54px;
  object-fit: cover;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--muted);
}

.spacer {
  flex: 1;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  transform: translateY(24px);
  opacity: 0;
  pointer-events: none;
  border-radius: 10px;
  background: #0f172a;
  color: #ffffff;
  padding: 12px 16px;
  font-size: 13px;
  font-weight: 800;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.18);
  transition: opacity 160ms ease, transform 160ms ease;
}

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

.hidden-field,
.readonly-hidden {
  display: none !important;
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 64px minmax(0, 1fr);
  }

  .sidebar {
    position: sticky;
    height: 100vh;
    z-index: 5;
    padding: 12px 6px;
  }

  .brand {
    min-height: 52px;
    padding-bottom: 10px;
  }

  .nav-list {
    display: grid;
    overflow-x: visible;
    padding-bottom: 4px;
  }

  .nav-item {
    min-width: 0;
  }

  .topbar,
  .toolbar,
  .summary-strip,
  .panel-grid,
  .field-list,
  .settings-form,
  .storage-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }

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

  .topbar {
    display: grid;
  }

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

  .top-actions,
  .toolbar-actions,
  .pagination-controls,
  .dialog-actions {
    justify-content: flex-start;
  }

  .toolbar-actions {
    flex-wrap: wrap;
  }

  .main {
    padding: 14px;
  }
}

@media (max-width: 720px) {
  body {
    background: #f8fafc;
  }

  .app-shell {
    display: block;
    min-height: 100vh;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    height: auto;
    padding: 8px 10px;
    border-right: 0;
    border-bottom: 1px solid rgba(226, 232, 240, 0.95);
    overflow-x: auto;
    overflow-y: hidden;
  }

  .brand {
    min-height: 0;
    padding: 0;
    flex: 0 0 auto;
  }

  .brand-mark {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    font-size: 16px;
  }

  .brand-menu {
    position: fixed;
    top: 50px;
    left: 8px;
    transform: none;
  }

  .nav-list {
    display: flex;
    flex: 1 0 auto;
    gap: 6px;
    min-width: max-content;
    padding: 0;
    border-top: 0;
  }

  .nav-item {
    width: auto;
    min-width: 58px;
    height: 34px;
    border-radius: 8px;
    padding: 0 10px;
    font-size: 14px;
  }

  .nav-item::before {
    display: none;
  }

  .main {
    padding: 12px 10px 18px;
  }

  .topbar {
    gap: 10px;
    margin-bottom: 12px;
  }

  .topbar > div:first-child {
    display: none;
  }

  .topbar h1 {
    display: none;
  }

  .topbar p {
    display: none;
  }

  .top-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
    gap: 6px;
  }

  .top-actions .role-pill {
    grid-column: 1 / -1;
    justify-content: center;
    width: 100%;
  }

  .top-actions .button {
    width: 100%;
    min-height: 32px;
    padding: 5px 6px;
    font-size: 12px;
  }

  .toolbar {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 7px;
    margin-bottom: 10px;
    padding: 9px;
  }

  .toolbar label {
    min-width: 0;
    gap: 4px;
    font-size: 11px;
  }

  .toolbar .search-box {
    grid-column: 1 / 3;
  }

  .toolbar .search-box span {
    display: none;
  }

  .mobile-search-actions {
    display: grid;
    grid-column: 3;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }

  .mobile-search-actions .button {
    width: 100%;
    min-width: 0;
    height: 32px;
    min-height: 32px;
    padding: 0 4px;
    justify-content: center;
    font-size: 11px;
    white-space: nowrap;
  }

  .toolbar-actions {
    display: grid;
    grid-column: 1 / -1;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
    gap: 6px;
  }

  .toolbar-actions .button,
  .toolbar-actions .file-button {
    width: 100%;
    min-width: 0;
    height: 32px;
    min-height: 32px;
    padding: 0 6px;
    justify-content: center;
    font-size: 11px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .toolbar-actions .button.primary {
    grid-column: 1 / -1;
    min-width: 0;
  }

  .button,
  .file-button,
  input,
  select,
  .multi-select-trigger {
    min-height: 32px;
    border-radius: 7px;
    padding: 5px 8px;
    font-size: 12px;
  }

  .gallery-tool-button {
    width: 34px;
    min-width: 34px;
    height: 34px;
    min-height: 34px;
    padding: 0;
    border-radius: 9px;
    font-size: 14px;
  }

  .gallery-tool-button#zoomResetBtn {
    width: 40px;
    min-width: 40px;
    font-size: 11px;
  }

  .settings-form,
  .form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 9px;
  }

  .settings-form .button {
    align-self: end;
  }

  .price-row {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 7px;
  }

  .grid-toggle {
    display: none;
  }

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

  .summary-strip > div {
    padding: 11px 12px;
  }

  .metric {
    font-size: 21px;
  }

  .table-wrap {
    display: none;
  }

  .mobile-product-list {
    display: grid;
    gap: 7px;
  }

  .mobile-product-card {
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #ffffff;
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.05);
    padding: 8px 10px;
  }

  .mobile-card-main {
    display: grid;
    grid-template-columns: 56px minmax(0, 1fr);
    gap: 9px;
    align-items: center;
  }

  .mobile-card-image .image-stack,
  .mobile-card-image .image-placeholder,
  .mobile-card-image img {
    width: 56px;
    height: 56px;
  }

  .mobile-card-title {
    min-width: 0;
  }

  .mobile-card-title strong,
  .mobile-card-title span,
  .mobile-card-title em {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mobile-card-title strong {
    color: #0f172a;
    font-size: 15px;
    font-weight: 900;
  }

  .mobile-card-title span {
    margin-top: 3px;
    color: #64748b;
    font-size: 12px;
    font-weight: 800;
  }

  .mobile-card-title em {
    display: inline-block;
    width: fit-content;
    max-width: 100%;
    margin-top: 4px;
    border-radius: 999px;
    background: #eff6ff;
    color: #2563eb;
    padding: 2px 7px;
    font-size: 11px;
    font-style: normal;
    font-weight: 850;
  }

  .mobile-card-fields {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 7px;
  }

  .mobile-price-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 6px;
  }

  .mobile-field,
  .mobile-price {
    flex: 0 1 auto;
    max-width: 100%;
    border: 1px solid #e2e8f0;
    border-radius: 999px;
    background: #f8fafc;
    padding: 4px 8px;
    line-height: 1.15;
  }

  .mobile-field span,
  .mobile-price span {
    display: inline;
    color: #94a3b8;
    font-size: 11px;
    line-height: 1.2;
  }

  .mobile-field strong,
  .mobile-price strong {
    display: inline;
    margin-left: 4px;
    color: #0f172a;
    font-size: 12px;
    font-weight: 850;
    line-height: 1.2;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .tier-mobile-price {
    border-radius: 8px;
    padding: 5px 8px;
  }

  .tier-mobile-price > span {
    display: block;
    margin-bottom: 4px;
  }

  .tier-mobile-price .tier-price-line {
    gap: 6px;
    justify-content: flex-start;
  }

  .tier-mobile-price .tier-price-line strong {
    margin-left: 0;
    font-size: 12px;
  }

  .mobile-card-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid #e2e8f0;
  }

  .mobile-card-actions [data-field="actions"] {
    display: inline-flex;
    gap: 12px;
  }

  .pagination-bar {
    margin-top: 8px;
    padding: 9px 10px;
  }

  .pagination-info {
    font-size: 12px;
  }

  .pagination-controls {
    display: none;
  }

  dialog:not(.gallery-dialog):not(.login-dialog) {
    width: min(100vw - 16px, 680px);
    max-height: calc(100dvh - 18px);
    margin: auto;
    padding: 14px;
  }

  .dialog-head {
    align-items: flex-start;
    gap: 10px;
  }

  .dialog-actions {
    position: sticky;
    bottom: -14px;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    padding-top: 8px;
    background: #ffffff;
  }

  .dialog-actions .button {
    width: 100%;
  }

  .settings-tabs {
    position: sticky;
    top: 51px;
    z-index: 20;
    margin: 0 -10px 12px;
    padding: 8px 10px;
    background: rgba(248, 250, 252, 0.96);
    border-bottom: 1px solid rgba(226, 232, 240, 0.9);
  }

  .settings-tab-panel .panel {
    border-radius: 8px;
  }

  .storage-grid,
  .mobile-price-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

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

  .mobile-card-fields,
  .mobile-price-grid,
  .storage-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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