:root {
  color-scheme: light;
  --bg: #f4f6fb;
  --panel: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --danger: #dc2626;
  --success: #059669;
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: linear-gradient(180deg, #eef2ff 0%, var(--bg) 220px);
  color: var(--text);
}

.hidden {
  display: none !important;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 32px;
}

.login-card h1 {
  margin: 8px 0 12px;
}

.login-form {
  display: grid;
  gap: 14px;
  margin-top: 20px;
}

.login-submit {
  width: 100%;
  margin-top: 4px;
}

.login-error {
  margin: 0;
  color: var(--danger);
  font-size: 14px;
}

.not-found-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.not-found-card {
  width: min(480px, 100%);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 40px 32px;
  text-align: center;
}

.not-found-card h1 {
  margin: 8px 0 12px;
}

.not-found-code {
  margin: 0 0 4px;
  font-size: clamp(3.5rem, 14vw, 5.5rem);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.04em;
  color: var(--primary);
  opacity: 0.92;
}

.not-found-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 24px;
}

.not-found-actions .btn {
  min-width: 148px;
}

.app {
  max-width: 1280px;
  margin: 0 auto;
  padding: 32px 20px 64px;
}

.header,
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  padding: 22px 28px;
  margin-bottom: 24px;
}

.header-brand {
  flex: 1;
  min-width: 0;
}

.header-brand h1 {
  font-size: clamp(1.35rem, 2vw, 1.75rem);
  line-height: 1.2;
}

.header-meta {
  margin: 8px 0 0;
  font-size: 14px;
  line-height: 1.5;
}

.header-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.user-chip {
  margin: 0;
  padding: 8px 14px;
  border-radius: 999px;
  background: #f3f4f6;
  border: 1px solid var(--border);
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.header-buttons {
  display: flex;
  gap: 8px;
}

.eyebrow {
  margin: 0 0 8px;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--primary);
  font-weight: 700;
}

h1,
h2,
h3 {
  margin: 0;
}

.subtitle,
.muted {
  color: var(--muted);
}

.subtitle {
  margin-top: 8px;
}

.panel {
  padding: 24px;
  margin-bottom: 24px;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
}

.panel-header-actions {
  display: flex;
  gap: 10px;
  flex-shrink: 0;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.column-picker-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.column-picker-groups {
  display: grid;
  gap: 16px;
  max-height: min(60vh, 480px);
  overflow-y: auto;
  padding-right: 4px;
}

.column-picker-group h4 {
  margin: 0 0 10px;
  font-size: 14px;
}

.column-picker-options {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px;
}

.column-picker-option {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
  cursor: pointer;
}

.column-picker-option input {
  width: auto;
  margin: 0;
}

.column-picker-option .badge {
  margin-left: auto;
}

.template-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.template-card {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
  cursor: pointer;
  transition: 0.2s ease;
  background: #fafbff;
}

.template-card.active {
  border-color: var(--primary);
  box-shadow: inset 0 0 0 1px var(--primary);
  background: #eff6ff;
}

.template-card h3 {
  margin-bottom: 8px;
}

.btn {
  border: none;
  border-radius: 10px;
  padding: 10px 16px;
  min-height: 42px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  line-height: 1.2;
  transition: background-color 0.15s ease, transform 0.15s ease;
}

.btn i {
  font-size: 0.95em;
  flex-shrink: 0;
}

.icon-heading {
  margin-right: 0.35em;
  color: var(--primary);
}

.label-with-icon {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.eyebrow i {
  margin-right: 0.35em;
  opacity: 0.85;
}

.app-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 20px;
  padding: 6px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
}

.app-nav-item {
  border: none;
  border-radius: 10px;
  padding: 10px 16px;
  min-height: 42px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  color: var(--muted);
  transition: background-color 0.15s ease, color 0.15s ease;
}

.app-nav-item:hover {
  background: #eef2ff;
  color: #1e3a8a;
}

.app-nav-item.is-active {
  background: var(--primary);
  color: #fff;
}

.user-form-fields {
  display: grid;
  gap: 14px;
  margin: 16px 0 8px;
}

.checkbox-field {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  cursor: pointer;
}

.checkbox-field input {
  width: auto;
}

.field-hint {
  display: block;
  margin-top: 6px;
  font-size: 13px;
}

.users-table-container {
  margin-bottom: 0;
}

.audit-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px 16px;
  margin-bottom: 16px;
}

.audit-filter {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

.audit-filter select,
.audit-filter input {
  min-width: 180px;
  font-weight: 400;
}

.audit-filter-search {
  flex: 1 1 220px;
}

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

.audit-table-container {
  margin-bottom: 0;
}

.audit-details-cell {
  max-width: 320px;
  white-space: normal;
  word-break: break-word;
}

.audit-product-cell {
  max-width: 240px;
}

.shopee-category-picker {
  display: grid;
  gap: 8px;
  position: relative;
}

.shopee-category-search {
  width: 100%;
}

.shopee-category-selected {
  margin: 0;
  font-size: 13px;
  line-height: 1.45;
}

.shopee-category-results {
  list-style: none;
  margin: 0;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  box-shadow: var(--shadow);
  max-height: 260px;
  overflow: auto;
  position: absolute;
  z-index: 20;
  left: 0;
  right: 0;
  top: calc(100% - 4px);
}

.shopee-category-results li + li {
  margin-top: 4px;
}

.shopee-category-option {
  width: 100%;
  border: none;
  border-radius: 10px;
  background: transparent;
  text-align: left;
  padding: 10px 12px;
  cursor: pointer;
  display: grid;
  gap: 2px;
}

.shopee-category-option:hover,
.shopee-category-option:focus-visible {
  background: #eef2ff;
  outline: none;
}

.shopee-category-option-name {
  font-weight: 600;
  font-size: 14px;
}

.shopee-category-option-path {
  font-size: 12px;
  line-height: 1.35;
}

.shopee-category-option-id {
  font-size: 12px;
  color: var(--muted);
}

.shopee-category-empty {
  padding: 10px 12px;
  font-size: 13px;
  color: var(--muted);
}

.shopee-category-field {
  position: relative;
}

.btn-link {
  border: none;
  padding: 0;
  background: none;
  color: var(--primary);
  font: inherit;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.btn-link:hover {
  color: #1e40af;
}

.badge-audit-created {
  background: #ecfdf5;
  color: #047857;
}

.badge-audit-updated {
  background: #eff6ff;
  color: #1d4ed8;
}

.badge-audit-deleted {
  background: #fef2f2;
  color: #b91c1c;
}

.badge-audit-imported {
  background: #f5f3ff;
  color: #6d28d9;
}

.badge-audit-default {
  background: #f3f4f6;
  color: #374151;
}

.badge-admin {
  background: #ede9fe;
  color: #5b21b6;
}

.badge-operator {
  background: #e0f2fe;
  color: #0369a1;
}

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

.badge-inactive {
  background: #f3f4f6;
  color: #6b7280;
}

.badge i {
  margin-right: 0.25em;
}

.products-table .actions-cell .btn span {
  white-space: nowrap;
}

.btn-label-short {
  display: none;
}

.btn:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

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

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-secondary {
  background: #eef2ff;
  color: #1e3a8a;
}

.btn-danger {
  background: #fee2e2;
  color: var(--danger);
}

.btn:disabled,
.btn.is-loading {
  opacity: 0.65;
  cursor: not-allowed;
  pointer-events: none;
}

.records-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.search-field {
  flex: 1;
  min-width: min(100%, 320px);
  max-width: 420px;
}

.search-label {
  font-size: 13px;
  font-weight: 600;
}

.search-summary {
  margin: 0;
  font-size: 14px;
}

.empty-state {
  text-align: center;
  padding: 40px 24px;
  border: 1px dashed var(--border);
  border-radius: 14px;
  background: #fafbff;
}

.empty-state p {
  margin: 0 0 16px;
}

.empty-state .btn {
  margin-top: 4px;
}

.cell-empty {
  color: #9ca3af;
}

.products-table td[title] {
  cursor: help;
}

.field-group-item.field-invalid input,
.field-group-item.field-invalid textarea,
.field-group-item.field-invalid select {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.12);
}

.image-field.field-invalid .image-preview-wrap,
.image-field.field-invalid .image-url-input {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.12);
}

.form-validation-error {
  margin: 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #b91c1c;
  font-size: 14px;
}

.delete-message {
  margin: 0 0 8px;
  font-size: 15px;
}

.delete-message strong {
  color: var(--text);
}

.export-empty-notice {
  padding: 16px 18px;
  border-radius: 12px;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  font-size: 14px;
}

.export-meta {
  margin-top: 4px;
  font-size: 13px;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: max(20px, env(safe-area-inset-bottom));
  left: auto;
  z-index: 1000;
  background: #111827;
  color: white;
  padding: 14px 18px;
  border-radius: 12px;
  box-shadow: var(--shadow);
  max-width: min(420px, calc(100vw - 40px));
}

.toast.toast-success {
  background: #065f46;
}

.toast.toast-error {
  background: #991b1b;
}

.toast.toast-info {
  background: #1e3a8a;
}

.toast.hidden {
  display: none;
}

.records-table-container {
  margin-bottom: 0;
}

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

.products-table th,
.products-table td {
  padding: 6px 10px;
  font-size: 13px;
  line-height: 1.35;
  vertical-align: middle;
}

.products-table thead th {
  padding-top: 8px;
  padding-bottom: 8px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.products-table td {
  max-width: 240px;
}

.products-table tbody td:not(.actions-cell):not(.cell-id):not(.cell-datetime) {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.products-table .actions-cell {
  white-space: nowrap;
  width: 1%;
}

.products-table .actions-cell .record-actions {
  gap: 4px;
}

.products-table .actions-cell .btn {
  padding: 5px 10px;
  min-height: 0;
  font-size: 12px;
  border-radius: 8px;
}

.products-table .cell-datetime {
  white-space: nowrap;
  font-size: 12px;
  color: var(--muted);
  min-width: 118px;
}

.products-table .cell-id {
  white-space: nowrap;
  font-weight: 600;
  font-size: 12px;
  color: var(--muted);
  width: 1%;
}

.table-pagination {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.table-pagination.hidden {
  display: none;
}

.pagination-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.pagination-size {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 600;
}

.pagination-size select {
  width: auto;
  min-width: 80px;
}

.pagination-info {
  margin: 0;
  font-size: 14px;
}

.pagination-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.pagination-pages {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.pagination-page-btn {
  min-width: 36px;
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.pagination-page-btn:hover:not(:disabled) {
  border-color: var(--primary);
  color: var(--primary);
}

.pagination-page-btn.is-active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  cursor: default;
}

.pagination-page-btn:disabled:not(.is-active) {
  opacity: 0.45;
  cursor: not-allowed;
}

.pagination-ellipsis {
  min-width: 24px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  user-select: none;
}

.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  border-radius: 12px;
  border: 1px solid var(--border);
}

.table-wrapper--scroll {
  background:
    linear-gradient(to right, var(--panel) 30%, rgba(255, 255, 255, 0)),
    linear-gradient(to right, rgba(255, 255, 255, 0), var(--panel) 70%) 100% 0,
    radial-gradient(farthest-side at 0 50%, rgba(0, 0, 0, 0.12), rgba(0, 0, 0, 0)),
    radial-gradient(farthest-side at 100% 50%, rgba(0, 0, 0, 0.12), rgba(0, 0, 0, 0)) 100% 0;
  background-repeat: no-repeat;
  background-size: 40px 100%, 40px 100%, 14px 100%, 14px 100%;
  background-attachment: local, local, scroll, scroll;
}

.product-cards {
  display: grid;
  gap: 12px;
}

.product-card {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  background: #fcfcfd;
  display: grid;
  gap: 14px;
}

.product-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.product-card-heading {
  min-width: 0;
}

.product-card-id {
  display: inline-block;
  margin-bottom: 4px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}

.product-card-title {
  margin: 0;
  font-size: 16px;
  line-height: 1.35;
  word-break: break-word;
}

.product-card-updated {
  flex-shrink: 0;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.product-card-fields {
  margin: 0;
  display: grid;
  gap: 10px;
}

.product-card-field {
  display: grid;
  gap: 4px;
}

.product-card-field dt {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.product-card-field dd {
  margin: 0;
  font-size: 14px;
  line-height: 1.45;
  word-break: break-word;
}

.record-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.actions-cell .record-actions .btn {
  width: auto;
}

.product-card .record-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.product-card .record-actions .btn {
  width: 100%;
}

.pagination-info-short {
  display: none;
}

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

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

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

.badge {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 12px;
  background: #ecfdf5;
  color: #047857;
}

.badge.required {
  background: #fee2e2;
  color: #b91c1c;
}

.color-chip {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  display: inline-block;
}

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.rows-container {
  display: grid;
  gap: 16px;
}

.row-card {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  background: #fcfcfd;
}

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

.field-label {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
}

dialog {
  border: none;
  border-radius: 16px;
  padding: 0;
  width: min(920px, calc(100vw - 32px));
  max-height: calc(100dvh - 24px);
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(2px);
}

dialog form {
  padding: 24px;
  display: grid;
  gap: 14px;
  max-height: calc(100dvh - 24px);
  overflow: hidden;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 8px;
  padding-top: 4px;
}

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

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
}

.checkbox {
  grid-template-columns: auto 1fr;
  align-items: center;
}

.row-fields {
  display: grid;
  gap: 12px;
  max-height: 70vh;
  overflow: auto;
  min-height: 0;
}

dialog.record-dialog {
  width: min(980px, calc(100vw - 32px));
}

dialog.record-dialog form.record-form {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 0;
  padding: 0;
  overflow: hidden;
  height: min(88dvh, 780px);
  max-height: calc(100dvh - 24px);
}

.record-dialog-header {
  padding: 18px 24px 14px;
  border-bottom: 1px solid var(--border);
}

.record-dialog-header h3 {
  margin: 0;
  font-size: 1.25rem;
  line-height: 1.3;
}

.record-dialog-subtitle {
  margin: 4px 0 0;
  font-size: 13px;
  line-height: 1.4;
}

.record-fields {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  padding: 16px 24px 0;
}

.record-fields > .form-validation-error {
  flex-shrink: 0;
  margin: 0 0 14px;
}

.record-dialog-actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
  padding: 14px 24px 18px;
  border-top: 1px solid var(--border);
  margin: 0;
}

.record-form-shell {
  display: flex;
  flex-direction: column;
  gap: 18px;
  flex: 1;
  min-height: 0;
  padding: 0 0 16px;
}

.record-form-overview {
  display: grid;
  gap: 14px;
  flex-shrink: 0;
}

.record-form-tabbed {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.record-form-progress {
  display: grid;
  gap: 10px;
  flex-shrink: 0;
  padding-top: 2px;
}

.record-form-progress-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.3;
}

.record-form-progress-meta strong {
  color: var(--text);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  transition: color 0.35s ease;
}

.record-form-progress-meta strong.is-complete {
  color: #059669;
}

.record-form-progress-track {
  height: 6px;
  border-radius: 999px;
  background: #e5e7eb;
  overflow: hidden;
}

.record-form-progress-fill {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #2563eb 0%, #3b82f6 55%, #60a5fa 100%);
  background-size: 200% 100%;
  transition: width 0.65s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: width;
}

.record-form-progress-fill.is-complete {
  background: linear-gradient(90deg, #059669 0%, #10b981 55%, #34d399 100%);
  background-size: 200% 100%;
  animation: record-progress-shimmer 2.4s ease-in-out infinite;
}

@keyframes record-progress-shimmer {
  0% {
    background-position: 100% 0;
  }
  100% {
    background-position: -100% 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .record-form-progress-fill {
    transition: none;
  }

  .record-form-progress-fill.is-complete {
    animation: none;
  }
}

.record-form-tabs {
  display: flex;
  align-items: flex-end;
  flex-wrap: nowrap;
  flex-shrink: 0;
  gap: 0;
  height: 40px;
  min-height: 40px;
  max-height: 40px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0 0 0 4px;
  scrollbar-width: thin;
  background: #eef2f7;
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: 10px 10px 0 0;
}

.record-form-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex: 0 0 auto;
  height: 36px;
  min-height: 36px;
  max-height: 36px;
  box-sizing: border-box;
  padding: 0 14px;
  margin: 0;
  border: 1px solid transparent;
  border-bottom: none;
  border-radius: 8px 8px 0 0;
  background: transparent;
  color: #4b5563;
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.record-form-tab + .record-form-tab {
  margin-left: 2px;
}

.record-form-tab:hover {
  background: rgba(255, 255, 255, 0.65);
  color: var(--primary);
}

.record-form-tab.is-active {
  height: 37px;
  min-height: 37px;
  max-height: 37px;
  margin-bottom: -1px;
  border-color: var(--border);
  border-bottom-color: #fff;
  background: #fff;
  color: #1d4ed8;
  z-index: 1;
  position: relative;
}

.record-form-tab i {
  font-size: 12px;
  flex-shrink: 0;
}

.record-tab-badge {
  flex-shrink: 0;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: #dc2626;
  color: #fff;
  font-size: 10px;
  line-height: 16px;
  text-align: center;
}

.record-form-panels {
  flex: 1;
  min-height: 240px;
  overflow: auto;
  padding: 18px 20px;
  background: #fff;
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 10px 10px;
}

.record-form-panel {
  display: none;
  gap: 14px;
}

.record-form-panel.is-active {
  display: grid;
}

.record-form-panel .field-group {
  padding: 14px 16px;
  border-radius: 10px;
}

.record-form-panel .field-group h4 {
  margin: 0 0 10px;
  font-size: 13px;
  letter-spacing: 0.01em;
}

.record-form-panel .field-group-grid {
  gap: 14px;
}

.record-form-panel .field-group-item {
  gap: 5px;
}

.record-form-panel .field-group-item textarea {
  min-height: 96px;
  resize: vertical;
}

.record-form-panel .image-field-body {
  gap: 14px;
}

.record-form-panel .form-legend--compact {
  margin: 0;
}

.image-field-cover {
  margin-bottom: 8px;
}

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

.image-gallery-grid .image-field {
  grid-column: auto;
}

.image-gallery-grid .image-field-body {
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 10px;
}

.image-gallery-grid .image-preview-wrap {
  width: 72px;
  height: 72px;
}

.image-gallery-grid .image-field-controls {
  gap: 8px;
}

.image-gallery-grid .image-url-input {
  font-size: 12px;
  padding: 8px 10px;
}

.image-gallery-grid .image-field-actions {
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
}

.image-gallery-grid .image-field-actions .btn {
  width: 100%;
  justify-content: center;
  font-size: 12px;
  min-height: 34px;
  padding: 6px 10px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.field-group {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  background: #fafafa;
}

.field-group h4 {
  margin: 0 0 12px;
  font-size: 14px;
  color: var(--primary);
}

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

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

.image-field-body {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.image-preview-wrap {
  width: 120px;
  height: 120px;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: #f9fafb;
  display: grid;
  place-items: center;
}

.image-preview {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.image-preview-placeholder {
  padding: 12px;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
}

.image-field-controls {
  display: grid;
  gap: 10px;
  align-content: start;
}

.image-upload-btn {
  justify-self: start;
}

.image-field-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.image-copy-url-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.cell-image {
  display: flex;
  align-items: center;
}

.cell-image-thumb {
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #f9fafb;
}

.image-pending-note {
  margin: 0;
  font-size: 12px;
  font-weight: 500;
  color: #0369a1;
}

.image-crop-dialog {
  width: min(720px, calc(100vw - 32px));
  max-width: none;
  z-index: 1100;
}

.image-crop-message {
  margin: 0 0 12px;
}

.image-crop-container {
  width: 100%;
  height: min(60vh, 420px);
  background: #111827;
  border-radius: 12px;
  overflow: hidden;
}

.image-crop-container img {
  display: block;
  max-width: 100%;
}

.image-crop-dialog .dialog-actions {
  margin-top: 16px;
}

.field-group-item {
  display: grid;
  gap: 6px;
  font-size: 14px;
  font-weight: 600;
}

.field-group-item small {
  font-weight: 400;
}

.required-mark {
  color: #b91c1c;
  margin-left: 2px;
  font-weight: 700;
}

.field-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.field-label-text {
  display: inline-flex;
  align-items: center;
}

.field-group-item.is-required input,
.field-group-item.is-required textarea,
.field-group-item.is-required select {
  border-color: #fca5a5;
}

.form-legend {
  padding: 12px 14px;
  border-radius: 10px;
  background: #fff7ed;
  border: 1px solid #fed7aa;
}

.form-legend p {
  margin: 0;
  font-size: 14px;
}

.form-legend p + p {
  margin-top: 6px;
  font-size: 13px;
}

.form-legend--compact {
  padding: 11px 14px;
  margin: 0;
}

.form-legend--compact p {
  font-size: 13px;
  line-height: 1.45;
}

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

.export-card {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
  background: #fcfcfd;
}

.export-card-pending {
  opacity: 0.85;
  border-style: dashed;
}

.export-actions {
  align-items: flex-end;
}

.export-format {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
}

.export-format select {
  width: auto;
  min-width: 150px;
}

.export-card h3 {
  margin-bottom: 6px;
}

.export-validation-dialog {
  width: min(720px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
}

.export-validation-issues {
  max-height: 360px;
  overflow: auto;
  margin: 16px 0;
  display: grid;
  gap: 12px;
}

.export-validation-product {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  background: #fcfcfd;
}

.export-validation-product h4 {
  margin: 0 0 8px;
  font-size: 14px;
}

.export-validation-product ul {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 6px;
}

.export-validation-product li {
  font-size: 13px;
  line-height: 1.45;
}

.export-validation-product li.is-error {
  color: #b91c1c;
}

.export-validation-product li.is-warning {
  color: #b45309;
}

@media (max-width: 1024px) {
  .app {
    padding: 20px 16px 48px;
  }

  .header,
  .panel {
    border-radius: 16px;
  }

  .panel {
    padding: 20px;
  }

  .header {
    padding: 18px 20px;
  }
}

@media (max-width: 767px) {
  .app {
    padding: 16px 12px calc(40px + env(safe-area-inset-bottom));
  }

  .header {
    flex-direction: column;
    align-items: stretch;
    gap: 16px;
    padding: 16px;
  }

  .header-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .user-chip {
    align-self: flex-start;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .header-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
    gap: 8px;
  }

  .header-buttons .btn {
    width: 100%;
    min-height: 44px;
  }

  .panel {
    padding: 16px;
    margin-bottom: 16px;
  }

  .panel-header {
    flex-direction: column;
    align-items: stretch;
    gap: 14px;
  }

  .panel-header-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
    gap: 8px;
  }

  .panel-header-actions .btn {
    width: 100%;
    min-height: 44px;
  }

  .panel-header-actions #addRecordBtn {
    grid-column: 1 / -1;
  }

  .btn-label-full {
    display: none;
  }

  .btn-label-short {
    display: inline;
  }

  .records-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .search-field {
    max-width: none;
    min-width: 0;
  }

  input,
  select,
  textarea {
    font-size: 16px;
  }

  .export-card {
    flex-direction: column;
    align-items: stretch;
  }

  .export-actions {
    width: 100%;
    align-items: stretch;
  }

  .export-actions .btn,
  .export-format select {
    width: 100%;
  }

  .export-format {
    width: 100%;
  }

  .pagination-controls {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .pagination-size {
    justify-content: space-between;
  }

  .pagination-info-full {
    display: none;
  }

  .pagination-info-short {
    display: inline;
  }

  .pagination-actions {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 8px;
    align-items: center;
  }

  .pagination-pages {
    justify-content: center;
    grid-column: 1 / -1;
    order: -1;
  }

  .pagination-actions .btn {
    width: 100%;
    min-height: 44px;
  }

  .image-field-body {
    grid-template-columns: 1fr;
  }

  .image-preview-wrap {
    width: 100%;
    max-width: 180px;
  }

  .field-group-grid {
    grid-template-columns: 1fr;
  }

  .column-picker-options {
    grid-template-columns: 1fr;
  }

  dialog {
    width: calc(100vw - 16px);
    max-height: calc(100dvh - 16px);
    margin: auto;
    border-radius: 14px;
  }

  dialog form {
    padding: 18px 16px;
    max-height: calc(100dvh - 16px);
  }

  dialog.record-dialog form.record-form {
    height: calc(100dvh - 16px);
    max-height: calc(100dvh - 16px);
    padding: 0;
  }

  .record-fields {
    padding: 12px 16px 0;
  }

  .record-dialog-header {
    padding: 14px 16px 12px;
  }

  .record-dialog-actions {
    padding: 12px 16px 14px;
  }

  .record-form-shell {
    gap: 14px;
    padding-bottom: 12px;
  }

  .record-form-overview {
    gap: 12px;
  }

  .record-form-progress {
    gap: 8px;
  }

  .record-form-panels {
    min-height: 200px;
    padding: 14px 16px;
  }

  .record-form-tab span:not(.record-tab-badge) {
    max-width: 88px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .image-gallery-grid {
    grid-template-columns: 1fr;
  }

  .dialog-actions {
    flex-direction: column-reverse;
    align-items: stretch;
  }

  .dialog-actions .btn {
    width: 100%;
    min-height: 44px;
  }

  .import-toolbar {
    gap: 12px;
  }

  .import-downloads-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .import-downloads-actions .btn-compact {
    width: 100%;
    min-height: 40px;
  }

  .import-file-field {
    padding-top: 12px;
  }

  .import-dialog-actions {
    flex-direction: column-reverse;
  }

  .import-dialog-actions .btn {
    width: 100%;
    min-height: 44px;
  }

  .import-results {
    max-height: min(46dvh, 360px);
  }

  .import-scroll-panel {
    max-height: min(180px, 24dvh);
  }

  .toast {
    left: 12px;
    right: 12px;
    max-width: none;
    text-align: center;
  }

  .login-card {
    padding: 24px 20px;
  }

  .empty-state {
    padding: 28px 16px;
  }
}

@media (max-width: 820px) {
  .template-list {
    grid-template-columns: 1fr;
  }
}

.import-intro {
  margin: 0;
  font-size: 14px;
  line-height: 1.5;
}

.btn-compact {
  padding: 7px 12px;
  min-height: 34px;
  font-size: 13px;
  font-weight: 600;
}

.import-toolbar {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 14px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #f9fafb;
}

.import-downloads {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.import-downloads-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.import-file-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.import-downloads-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.import-file-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.import-file-field input[type="file"] {
  padding: 8px 10px;
  font-size: 13px;
  background: var(--panel);
}

.import-dialog-actions {
  justify-content: flex-end;
}

.import-dialog-actions .btn-primary {
  min-width: 112px;
}

.import-summary {
  margin: 0;
  padding: 12px 14px;
  border-radius: 10px;
  background: #eef6ff;
  border: 1px solid #bfdbfe;
  font-size: 14px;
}

.import-summary.is-error {
  background: #fef2f2;
  border-color: #fecaca;
}

#importForm {
  grid-template-rows: auto auto auto minmax(0, 1fr) auto;
  gap: 12px;
}

.import-results {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
  max-height: min(52vh, 480px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 4px;
}

.import-panel {
  display: flex;
  flex-direction: column;
  gap: 0;
  min-height: 0;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
  overflow: hidden;
}

.import-panel-skipped {
  border-color: #fde68a;
  background: #fffbeb;
}

.import-panel-errors {
  border-color: #fecaca;
  background: #fef2f2;
}

.import-panel-preview {
  border-color: #bfdbfe;
  background: #f8fbff;
}

.import-panel-title {
  margin: 0;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  flex-shrink: 0;
}

.import-panel-title.is-skipped {
  color: #92400e;
}

.import-panel-title.is-error {
  color: #991b1b;
}

.import-panel-title.is-preview {
  color: #1e40af;
}

.import-panel-count {
  font-weight: 500;
  color: var(--muted);
}

.import-scroll-panel {
  max-height: min(220px, 28vh);
  overflow-x: auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 10px 14px 12px;
}

.import-panel-list {
  margin: 0;
  padding-left: 18px;
}

.import-panel-list li {
  margin-bottom: 6px;
  font-size: 13px;
  line-height: 1.45;
}

.import-panel-more {
  margin: 10px 0 0;
  font-size: 12px;
}

.import-preview-table {
  width: 100%;
  min-width: 520px;
  border-collapse: collapse;
  font-size: 13px;
}

.import-preview-table th,
.import-preview-table td {
  border: 1px solid var(--border);
  padding: 8px 10px;
  text-align: left;
  white-space: nowrap;
}

.import-preview-table td:nth-child(2) {
  white-space: normal;
  min-width: 180px;
}

.import-preview-table th {
  background: #f9fafb;
  position: sticky;
  top: 0;
  z-index: 1;
}

.app-footer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  padding: 10px 20px max(12px, env(safe-area-inset-bottom));
  text-align: center;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(244, 246, 251, 0) 0%, var(--bg) 40%);
}

.app-footer-text {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}

.app-footer-text strong {
  color: var(--text);
  font-weight: 600;
}

.app-footer-sep {
  margin: 0 0.35em;
  opacity: 0.6;
}

.app-footer-version {
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}
