:root {
  --bg: #0a0f17;
  --panel: #121923;
  --panel-muted: #18212d;
  --line: #283446;
  --text: #ebf1f7;
  --muted: #93a1b5;
  --accent: #5ea0ff;
  --accent-soft: #172437;
  --danger: #ef6b63;
  --warning: #f4b74f;
  --success: #58c28e;
  --radius: 14px;
  --shadow: 0 18px 42px rgba(0, 0, 0, 0.32);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(94, 160, 255, 0.12), transparent 34%),
    linear-gradient(180deg, #0b1119 0%, #0a0f17 100%);
  color: var(--text);
}

body.auth-page {
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }

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

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

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

.auth-card-head {
  margin-bottom: 18px;
}

.auth-card-head h1 {
  margin: 0 0 8px 0;
  font-size: 1.5rem;
}

.auth-card-head p {
  margin: 0;
  color: var(--muted);
}

.sidebar {
  padding: 24px 18px;
  background: rgba(10, 15, 23, 0.94);
  border-right: 1px solid var(--line);
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  margin-bottom: 24px;
}

.brand h1 {
  margin: 0;
  font-size: 1.2rem;
}

.brand p {
  margin: 6px 0 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

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

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

.nav-group-secondary {
  margin-top: 12px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.nav-title {
  padding: 0 12px;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.nav a {
  padding: 11px 12px;
  border-radius: 10px;
  color: var(--muted);
}

.nav a.active,
.nav a:hover {
  background: var(--accent-soft);
  color: #f4f8ff;
}

.content {
  padding: 28px;
  min-width: 0;
}

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

.page-header h2 {
  margin: 0 0 8px 0;
  font-size: 1.7rem;
}

.page-header p,
.muted { color: var(--muted); }

.stack {
  display: grid;
  gap: 14px;
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.9fr);
  gap: 20px;
  align-items: start;
}

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

.filter-row-products {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 180px;
  gap: 14px;
  align-items: end;
}

.filter-row-detail {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(200px, 1fr) 300px 300px;
  gap: 14px;
  align-items: end;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 18px;
}

.message-details {
  margin-top: 10px;
}

.message-details summary {
  cursor: pointer;
  color: var(--text);
  font-size: 0.92rem;
  font-weight: 600;
}

.message-details pre {
  margin: 10px 0 0 0;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.18);
  color: #d8e3f2;
  font-family: "IBM Plex Mono", "SFMono-Regular", monospace;
  font-size: 0.85rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.panel h3 {
  margin: 0 0 10px 0;
  font-size: 1.08rem;
}

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

.compact-toolbar {
  gap: 8px;
  align-items: center;
}

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

.section-head p {
  margin: 6px 0 0 0;
}

label span {
  display: block;
  font-size: 0.92rem;
  font-weight: 600;
  margin-bottom: 6px;
}

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

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #0d141d;
  color: var(--text);
  padding: 11px 12px;
}

input::placeholder,
textarea::placeholder {
  color: #6f7f95;
}

textarea { resize: vertical; }

.button {
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  padding: 11px 16px;
  cursor: pointer;
  white-space: nowrap;
}

.button.secondary {
  background: #202b39;
  color: var(--text);
}

.compact-button {
  padding: 9px 12px;
  font-size: 0.88rem;
}

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

.button.link {
  background: transparent;
  color: var(--accent);
  padding: 0;
}

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

.messages {
  display: grid;
  gap: 10px;
  margin-bottom: 18px;
}

.message {
  border-radius: 12px;
  border: 1px solid transparent;
  padding: 12px 14px;
}

.message.success {
  background: rgba(88, 194, 142, 0.12);
  border-color: rgba(88, 194, 142, 0.36);
}

.message.error {
  background: rgba(239, 107, 99, 0.12);
  border-color: rgba(239, 107, 99, 0.36);
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 860px;
}

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

thead th {
  background: #18212d;
  font-size: 0.82rem;
  color: var(--muted);
}

th,
td {
  text-align: left;
  border-bottom: 1px solid var(--line);
  padding: 10px 12px;
  vertical-align: top;
  font-size: 0.92rem;
}

.table-compact th,
.table-compact td {
  padding: 9px 10px;
  font-size: 0.88rem;
}

.key-table th:first-child,
.key-table td:first-child {
  width: 30%;
}

.key-table th:last-child,
.key-table td:last-child {
  width: 1%;
  white-space: nowrap;
}

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

.button.is-current {
  background: var(--accent-soft);
  color: #f4f8ff;
  border: 1px solid rgba(94, 160, 255, 0.28);
}

.badge {
  display: inline-flex;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
}

.badge.available { background: rgba(88, 194, 142, 0.14); color: var(--success); }
.badge.reserved { background: rgba(244, 183, 79, 0.14); color: var(--warning); }
.badge.sold { background: rgba(94, 160, 255, 0.14); color: #8eb8ff; }
.badge.inactive { background: rgba(147, 161, 181, 0.12); color: var(--muted); }

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

.compact-listing-summary {
  grid-template-columns: repeat(2, minmax(140px, 1fr));
  min-width: 320px;
}

.product-count-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.summary-card {
  border: 1px solid var(--line);
  background: var(--panel-muted);
  border-radius: 12px;
  padding: 14px;
}

.summary-card strong {
  display: block;
  margin-top: 6px;
  font-size: 1.5rem;
}

.compact-summary-grid strong {
  font-size: 1.2rem;
}

.remote-select {
  position: relative;
}

.search-input-shell {
  position: relative;
}

.search-input-shell input {
  padding-right: 42px;
}

.selection-indicator {
  position: absolute;
  top: 50%;
  right: 12px;
  transform: translateY(-50%);
  width: 22px;
  height: 22px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(147, 161, 181, 0.12);
  color: transparent;
  border: 1px solid transparent;
  transition: all 120ms ease;
}

.selection-indicator.is-selected {
  color: var(--success);
  border-color: rgba(88, 194, 142, 0.28);
  background: rgba(88, 194, 142, 0.12);
}

.search-results {
  position: absolute;
  z-index: 10;
  left: 0;
  right: 0;
  top: calc(100% + 6px);
  background: #121923;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.search-results[hidden] { display: none; }

.search-results button {
  width: 100%;
  text-align: left;
  border: none;
  background: #121923;
  color: var(--text);
  padding: 10px 12px;
  cursor: pointer;
}

.search-results button:hover {
  background: var(--accent-soft);
}

.selected-card {
  margin-top: 10px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--panel-muted);
}

.page-stat-card {
  min-width: 140px;
}

.page-stat-card strong {
  display: block;
  margin-top: 6px;
  font-size: 1.4rem;
}

.header-stat-group {
  justify-content: flex-end;
  align-items: stretch;
  flex-wrap: nowrap;
}

.product-summary-card {
  min-height: 100%;
}

.product-summary-head {
  margin-bottom: 8px;
}

.field-note {
  font-size: 0.88rem;
}

.mapping-select-panel {
  max-width: 760px;
}

.mapping-detail-layout {
  grid-template-columns: minmax(320px, 0.9fr) minmax(0, 1.3fr);
}

.mapping-current-source {
  margin-bottom: 14px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-muted);
}

.mapping-current-source strong {
  display: block;
  margin-top: 6px;
  font-size: 1rem;
}

.back-link {
  margin-bottom: 12px;
}

.field-clear-button {
  margin-top: 8px;
  display: inline-flex;
}

.inline-product-header {
  margin-top: 8px;
}

.inline-product-display.is-hidden,
.inline-product-form.is-hidden {
  display: none;
}

.inline-product-display h2 {
  margin: 0;
}

.inline-product-form {
  margin: 0;
}

.inline-product-form-row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.inline-product-form-row input[type="text"] {
  flex: 1 1 420px;
  min-width: 260px;
}

.inline-checkbox {
  margin: 0;
}

.cell-stack {
  display: grid;
  gap: 4px;
}

.cell-stack strong {
  font-size: 0.95rem;
  line-height: 1.3;
}

.product-name-cell strong {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  max-height: 2.6em;
  max-width: 280px;
  font-size: 0.84rem;
  line-height: 1.28;
}

.inline-action-cell {
  text-align: right;
}

.inline-action-cell .row-actions {
  justify-content: flex-end;
  flex-wrap: nowrap;
}

.inline-action-cell form {
  margin: 0;
  display: flex;
}

.inline-danger-button {
  min-width: 64px;
}

.key-row-action-button {
  min-width: 78px;
  justify-content: center;
  padding: 8px 10px;
  font-size: 0.82rem;
}

.mono-cell strong,
.detail-title {
  word-break: break-all;
}

.selected-row td {
  background: rgba(94, 160, 255, 0.08);
}

.date-row {
  align-items: end;
}

.status-tabs {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.status-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 120px;
  padding: 11px 16px;
  border-radius: 10px;
  background: #1a2330;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.9rem;
}

.status-tab.active {
  background: var(--accent-soft);
  color: #f4f8ff;
  border-color: rgba(94, 160, 255, 0.35);
}

.filter-row-4 {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 180px 300px 300px;
  gap: 14px;
}

.date-row-end {
  align-self: end;
}

.date-field {
  display: flex;
  gap: 8px;
  align-items: center;
}

.date-field input {
  min-width: 0;
  flex: 1 1 auto;
}

.date-clear-button {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 42px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #202b39;
  font-size: 0.8rem;
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
  min-width: 96px;
}

.date-clear-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.checkbox-grid {
  display: grid;
  gap: 8px;
}

.checkbox {
  display: flex;
  gap: 8px;
  align-items: start;
}

.checkbox input {
  width: auto;
  margin-top: 4px;
}

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

.compact-section-head {
  margin-bottom: 14px;
}

.compact-section-head h3 {
  margin-bottom: 6px;
}

.listing-table th:nth-child(2),
.listing-table td:nth-child(2) {
  min-width: 220px;
}

.detail-type {
  color: var(--muted);
  font-size: 0.88rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 10px;
  background: rgba(147, 161, 181, 0.08);
}

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

.detail-item {
  border: 1px solid var(--line);
  background: var(--panel-muted);
  border-radius: 12px;
  padding: 12px 14px;
}

.detail-item strong {
  display: block;
  margin-top: 6px;
}

.readonly-box {
  border: 1px solid rgba(244, 183, 79, 0.28);
  background: rgba(244, 183, 79, 0.08);
  border-radius: 12px;
  padding: 14px;
}

.readonly-box p {
  margin: 8px 0 0 0;
}

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

.action-grow {
  width: 100%;
}

.modal-action-bar {
  position: sticky;
  bottom: 0;
  background: #121923;
  padding-top: 8px;
}

.empty-state {
  padding: 24px;
  border: 1px dashed var(--line);
  border-radius: 12px;
  color: var(--muted);
}

.pagination {
  margin-top: 14px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

dialog {
  border: none;
  border-radius: 16px;
  padding: 0;
  width: min(520px, calc(100vw - 32px));
  background: transparent;
}

.modal-wide {
  width: min(920px, calc(100vw - 40px));
}

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

.dialog-body {
  padding: 20px;
  background: #121923;
  color: var(--text);
}

@media (max-width: 1100px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .split,
  .two-col,
  .summary-grid,
  .filter-row-4 {
    grid-template-columns: 1fr;
  }
  .content { padding: 18px; }
}

@media (max-width: 800px) {
  .page-header,
  .section-head {
    flex-direction: column;
  }

  .detail-header {
    flex-direction: column;
  }

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