@import url(https://fonts.googleapis.com/css?family=Roboto);

html, body {
  font-family: 'Roboto', sans-serif;
  width: 100%;
  min-height: 100vh;
  padding: 0;
  margin: 0;
  overflow-x: hidden;
  background: var(--bg-color);

  --primary-color: #BA6548;
  --bg-color: #0B0623;
  --card-color: #120C2E;
  --text-color: #FBFBFB;
  --text-secondary: #F2F2F2;
  --error-color: #C20A0C;
}

h1 {
  font-size: 4rem;
  margin: unset;
}

.main {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  flex-wrap: nowrap;
  overflow-x: hidden;
  width: 100%;
  max-width: 100%;
}

.main section {
  flex: 1 0 auto;
  display: flex;
  flex-direction: column;
}

header {
  display: flex;
  justify-content: center;
  padding: 1em;
}

header nav {
  background-color: var(--primary-color);
  height: 3em;
  border-radius: 10px;
  overflow: clip;
  display: flex;
  justify-content: space-between;
}

header nav a,
header nav .app-nav-link {
  color: white;
  font-weight: 700;
  text-decoration: none;
  padding-left: 2em;
  padding-right: 2em;
  height: 100%;
  display: flex;
  align-items: center;
  box-sizing: border-box;
  cursor: pointer;
  pointer-events: auto;
  position: relative;
  z-index: 1;
}

header nav a:hover,
header nav .app-nav-link:hover {
  background-color: #0005;
}

header nav .app-nav-link.active {
  position: relative;
}

header nav .app-nav-link.active::before {
  content: "";
  display: block;
  height: 2px;
  border-radius: 1px;
  position: absolute;
  left: 20px;
  bottom: 0.5em;
  right: 20px;
  background-color: white;
}

.app-header {
  background: var(--bg-color);
  position: relative;
  z-index: 20;
}

.app-nav {
  max-width: 980px;
  width: 100%;
  position: relative;
  z-index: 21;
  pointer-events: auto;
}

.page {
  padding: 24px;
  color: var(--text-color);
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  overflow-x: hidden;
}

.auth-page {
  background: var(--bg-color);
  color: var(--text-color);
  min-height: 100vh;
  justify-content: center;
  align-items: center;
}

.auth-card {
  background: var(--card-color);
  padding: 24px;
  border-radius: 16px;
  width: 360px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

.input-base {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--primary-color);
  background: #0E0A2A;
  color: var(--text-color);
}

.input-base::placeholder {
  color: var(--text-secondary);
}

.input-error {
  color: var(--error-color);
  font-size: 12px;
}

.btn-primary {
  background: var(--primary-color);
  color: var(--text-color);
  border: none;
  border-radius: 12px;
  padding: 10px 12px;
  cursor: pointer;
  font-weight: 600;
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: default;
}

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

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

.pinput-input {
  letter-spacing: 6px;
  text-align: center;
}

.counter {
  display: flex;
  align-items: center;
  padding-top: 10px;
  padding-bottom: 10px;
  border-top-style: solid;
  border-bottom-style: solid;
  border-top-color: var(--primary-color);
  border-bottom-color: var(--primary-color);
  border-top-width: 1px;
  border-bottom-width: 1px;
}

.counter button {
  font-size: 2rem;
  width: 2em;
  height: 2em;
  border: unset;
  cursor: pointer;
  border-radius: 2em;
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: transparent;
}

.counter button:hover {
  background-color: #0001;
}

.counter span {
  padding-left: 2rem;
  padding-right: 2rem;
  box-sizing: border-box;
  min-width: 2.5em;
  color: var(--primary-color);
  font-size: 4rem;
  text-align: center;
}

ol {
  max-width: 500px;
}

.error-wrapper {
  position: relative;
  min-height: 100vh;
}

.error-toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: var(--error-color);
  color: var(--text-color);
  padding: 10px 16px;
  border-radius: 10px;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
  z-index: 9999;
  max-width: 90vw;
  white-space: pre-wrap;
}

/* ─── Catalog Page ──────────────────────────────────────────────────────────── */

.catalog-page {
  gap: 20px;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.catalog-page-title {
  font-size: 2.2rem;
  margin: 0;
}

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

.catalog-toolbar-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.catalog-error-banner {
  background: rgba(194, 10, 12, 0.15);
  border: 1px solid var(--error-color);
  color: var(--error-color);
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 14px;
}

.catalog-loading {
  color: var(--text-secondary);
  padding: 24px 0;
  text-align: center;
}

/* ─── Two-panel layout ─────────────────────────────────────────────────────── */

.catalog-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 16px;
  align-items: start;
  flex: 1;
}

/* ─── Sidebar ──────────────────────────────────────────────────────────────── */

.catalog-sidebar {
  background: var(--card-color);
  border-radius: 14px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 200px;
}

.catalog-sidebar-header {
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  padding-bottom: 10px;
}

.sidebar-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
  opacity: 0.6;
}

.catalog-empty-tree {
  color: var(--text-secondary);
  opacity: 0.5;
  font-size: 13px;
  text-align: center;
  padding: 16px 0;
  margin: 0;
}

/* ─── Tree ─────────────────────────────────────────────────────────────────── */

.catalog-tree {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.catalog-node {
  display: flex;
  flex-direction: column;
}

.catalog-node-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 8px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
}

.catalog-node-row:hover {
  background: rgba(255, 255, 255, 0.05);
}

.catalog-node-row.selected {
  background: rgba(186, 101, 72, 0.18);
  border: 1px solid rgba(186, 101, 72, 0.35);
}

.btn-expand {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 10px;
  width: 18px;
  min-width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  opacity: 0.5;
  flex-shrink: 0;
}

.btn-expand:hover {
  opacity: 1;
}

.catalog-node-title {
  flex: 1;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.catalog-node-actions {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 0.15s;
}

.catalog-node-row:hover .catalog-node-actions,
.catalog-node-row.selected .catalog-node-actions {
  opacity: 1;
}

.btn-icon {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 12px;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border-radius: 4px;
  transition: background 0.1s, color 0.1s;
}

.btn-icon:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-color);
}

.btn-icon:disabled {
  opacity: 0.3;
  cursor: default;
}

.btn-icon-active {
  color: var(--primary-color);
}

.btn-icon-danger:hover {
  background: rgba(194, 10, 12, 0.2);
  color: var(--error-color);
}

.btn-icon-edit:hover {
  background: rgba(186, 101, 72, 0.2);
  color: var(--primary-color);
}

.catalog-node-children {
  margin-left: 14px;
  border-left: 1px solid rgba(255, 255, 255, 0.06);
  padding-left: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 2px;
}

/* ─── Inline forms ─────────────────────────────────────────────────────────── */

.catalog-edit-form,
.catalog-create-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 8px;
  margin: 4px 0;
}

.create-form-actions {
  display: flex;
  gap: 6px;
}

/* ─── Badges ───────────────────────────────────────────────────────────────── */

.catalog-badge {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--primary-color);
  background: rgba(186, 101, 72, 0.15);
  padding: 2px 6px;
  border-radius: 4px;
  flex-shrink: 0;
}

.badge-sm {
  font-size: 9px;
  padding: 1px 5px;
}

/* ─── Extra button styles ──────────────────────────────────────────────────── */

.btn-secondary {
  background: rgba(255, 255, 255, 0.07);
  color: var(--text-color);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 500;
  font-size: 14px;
  transition: background 0.15s;
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.12);
}

.btn-secondary:disabled {
  opacity: 0.5;
  cursor: default;
}

.btn-danger {
  background: rgba(194, 10, 12, 0.8);
  color: white;
  border: none;
  border-radius: 10px;
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 600;
  transition: background 0.15s;
}

.btn-danger:hover {
  background: #C20A0C;
}

.btn-danger:disabled {
  opacity: 0.5;
  cursor: default;
}

.btn-sm {
  padding: 7px 12px;
  font-size: 13px;
  border-radius: 8px;
}

.input-sm {
  padding: 7px 10px;
  font-size: 13px;
  border-radius: 8px;
}

/* ─── Content panel ────────────────────────────────────────────────────────── */

.catalog-content {
  background: var(--card-color);
  border-radius: 14px;
  padding: 20px;
  min-height: 300px;
}

.catalog-content-inner {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.content-back-row {
  display: flex;
  align-items: center;
}

/* ─── Empty state ──────────────────────────────────────────────────────────── */

.catalog-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 60px 24px;
  text-align: center;
}

.empty-state-icon {
  font-size: 3rem;
  opacity: 0.3;
}

.empty-state-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-color);
  opacity: 0.6;
  margin: 0;
}

.empty-state-hint {
  font-size: 13px;
  color: var(--text-secondary);
  opacity: 0.5;
  margin: 0;
  max-width: 260px;
}

/* ─── Node detail ──────────────────────────────────────────────────────────── */

.node-detail-header {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.node-detail-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0;
  flex: 1;
}

.node-detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.node-meta-item {
  font-size: 12px;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.05);
  padding: 3px 8px;
  border-radius: 5px;
  opacity: 0.7;
}

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

.node-section-header {
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  padding-top: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.node-section-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 0;
  opacity: 0.7;
}

.node-no-products {
  padding: 24px 0;
  text-align: center;
}

.node-no-products-text {
  color: var(--text-secondary);
  opacity: 0.4;
  font-size: 13px;
  margin: 0;
}

/* ─── Products list ────────────────────────────────────────────────────────── */

.catalog-products-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.catalog-product-item {
  background: rgba(255, 255, 255, 0.04);
  border-radius: 10px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.product-item-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.product-item-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

.catalog-product-item--editing {
  border-color: rgba(186, 101, 72, 0.3);
  background: rgba(186, 101, 72, 0.05);
  padding: 0;
}

.product-item-title {
  font-weight: 500;
  font-size: 14px;
}

.product-item-price {
  font-size: 13px;
  color: var(--primary-color);
  font-weight: 600;
}

.product-item-attrs {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.product-attr-chip {
  font-size: 11px;
  background: rgba(255, 255, 255, 0.06);
  padding: 2px 7px;
  border-radius: 4px;
  color: var(--text-secondary);
}

/* ─── Product create form ──────────────────────────────────────────────────── */

.product-create-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 10px;
  border: 1px dashed rgba(255, 255, 255, 0.12);
  margin-bottom: 4px;
}

/* ─── Product delete confirm (inline) ──────────────────────────────────────── */

.product-delete-confirm {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: rgba(220, 80, 60, 0.08);
  border: 1px solid rgba(220, 80, 60, 0.22);
  border-radius: 8px;
  margin-bottom: 4px;
}

.product-delete-icon {
  font-size: 16px;
  color: #e06060;
}

.product-delete-text {
  flex: 1;
  font-size: 13px;
  color: var(--text-secondary);
}

.product-delete-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

/* ─── Delete confirmation ──────────────────────────────────────────────────── */

.catalog-confirm-delete {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 40px 24px;
  text-align: center;
}

.confirm-delete-icon {
  font-size: 2.5rem;
  color: var(--error-color);
}

.confirm-delete-title {
  font-size: 1.3rem;
  font-weight: 700;
  margin: 0;
}

.confirm-delete-name {
  font-size: 1rem;
  font-weight: 600;
  color: var(--primary-color);
  margin: 0;
}

.confirm-delete-hint {
  font-size: 13px;
  color: var(--text-secondary);
  opacity: 0.7;
  max-width: 340px;
  margin: 0;
}

.confirm-delete-actions {
  display: flex;
  gap: 10px;
  margin-top: 4px;
}

/* ─── Matrix section ───────────────────────────────────────────────────────── */

.catalog-matrix-section {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.matrix-header-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.matrix-title {
  font-size: 1.3rem;
  font-weight: 700;
  margin: 0;
}

.matrix-empty-hint {
  font-size: 13px;
  color: var(--text-secondary);
  opacity: 0.5;
  margin: 0;
  padding: 16px 0;
  text-align: center;
}

/* ─── Axis direction config ─────────────────────────────────────────────────── */

.matrix-axis-config-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.matrix-axis-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
  opacity: 0.6;
  flex-shrink: 0;
}

.matrix-axis-config {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.matrix-depth-toggle {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text-color);
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
}

.matrix-depth-toggle:hover {
  background: rgba(186, 101, 72, 0.15);
  border-color: rgba(186, 101, 72, 0.4);
}

/* ─── Recursive flex tree layout ────────────────────────────────────────────── */

.matrix-scroll-host {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.matrix-scroll-top {
  overflow-x: auto;
  overflow-y: hidden;
  max-width: 100%;
  width: 100%;
  height: 12px;
  margin-bottom: 4px;
  border-radius: 6px;
  scrollbar-width: thin;
}

.matrix-scroll-top-inner {
  height: 1px;
  pointer-events: none;
}

.matrix-recursive-wrap {
  overflow-x: auto;
  overflow-y: visible;
  max-width: 100%;
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  min-height: 180px;
  box-sizing: border-box;
}

.matrix-level {
  display: flex;
  align-items: stretch;
  min-width: max-content;
  width: max-content;
}

.matrix-level--columns {
  flex-direction: row;
}

.matrix-level--rows {
  flex-direction: column;
}

.matrix-col-segment {
  display: flex;
  flex-direction: column;
  flex: 0 0 auto;
  min-inline-size: 25ch;
  width: max-content;
  border-right: 1px solid rgba(255, 255, 255, 0.1);
}

.matrix-col-segment:last-child {
  border-right: none;
}

.matrix-row-segment {
  display: grid;
  grid-template-columns: minmax(25ch, max-content) minmax(25ch, max-content);
  min-width: max-content;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.matrix-row-segment:last-child {
  border-bottom: none;
}

.matrix-col-content,
.matrix-row-content {
  display: flex;
  flex-direction: column;
  min-width: 25ch;
  min-height: 100%;
  width: max-content;
}

.matrix-row-content {
  border-left: 1px solid rgba(255, 255, 255, 0.1);
}

.matrix-node-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  background: rgba(186, 101, 72, 0.13);
  position: relative;
}

.matrix-node-header--column {
  border-bottom: 1px solid rgba(186, 101, 72, 0.22);
  justify-content: center;
  min-block-size: var(--matrix-rank-header-block-size, auto);
}

.matrix-node-header--row {
  inline-size: var(--matrix-rank-header-inline-size, 25ch);
  min-inline-size: var(--matrix-rank-header-inline-size, 25ch);
  min-height: 42px;
  border-right: 1px solid rgba(186, 101, 72, 0.22);
}

.matrix-node-header.selected {
  background: rgba(186, 101, 72, 0.28);
  outline: 1px solid rgba(186, 101, 72, 0.5);
  outline-offset: -1px;
}

.matrix-node-header.target-mode {
  cursor: pointer;
}

.matrix-node-header.target-mode:hover {
  background: rgba(186, 101, 72, 0.22);
}

.matrix-node-title {
  flex: 1;
  min-width: 25ch;
  max-width: 25ch;
  color: var(--primary-color);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  overflow-wrap: anywhere;
  text-overflow: clip;
  text-transform: uppercase;
  white-space: normal;
}

.matrix-node-header--column .matrix-node-title {
  text-align: center;
}

.matrix-col-segment.matrix-segment--leaf > .matrix-node-header--column {
  min-inline-size: 0;
}

.matrix-col-segment.matrix-segment--leaf .matrix-node-title {
  flex: 0 1 auto;
  min-width: 0;
  inline-size: min-content;
  max-width: 25ch;
  overflow-wrap: normal;
}

.matrix-col-segment.matrix-segment--branch > .matrix-node-header--column .matrix-node-title {
  min-width: 0;
}

.matrix-node-actions {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 0.15s;
}

.matrix-node-header:hover .matrix-node-actions,
.matrix-node-header.selected .matrix-node-actions {
  opacity: 1;
}

.matrix-node-products {
  min-inline-size: 25ch;
  min-height: 50px;
  border: none;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  width: max-content;
}

.matrix-node-products--columns {
  min-inline-size: max-content;
  inline-size: max-content;
}

.matrix-node-products--rows {
  inline-size: 25ch;
}

.matrix-node-products:last-child {
  border-bottom: none;
}

.matrix-tree-layout {
  overflow: auto;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  display: flex;
}

.matrix-group {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 180px;
}

.matrix-group-header {
  padding: 6px 10px;
  background: rgba(186, 101, 72, 0.15);
  border-bottom: 1px solid rgba(186, 101, 72, 0.25);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--primary-color);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.matrix-children {
  display: flex;
  flex: 1;
}

.matrix-children-row {
  flex-direction: row;
}

.matrix-children-col {
  flex-direction: column;
}

.matrix-child {
  display: flex;
  flex: 1;
  min-width: 0;
}

/* Top-level root groups size to content instead of stretching equally */
.matrix-tree-layout > .matrix-child {
  flex: 0 0 auto;
}

.matrix-children-row > .matrix-child {
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.matrix-children-row > .matrix-child:last-child {
  border-right: none;
}

.matrix-children-col > .matrix-child {
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.matrix-children-col > .matrix-child:last-child {
  border-bottom: none;
}

/* ─── Leaf cells ─────────────────────────────────────────────────────────────── */

.matrix-leaf {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 100px;
}

.matrix-leaf-header {
  padding: 5px 10px;
  background: rgba(255, 255, 255, 0.04);
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-secondary);
}

.matrix-leaf-products {
  flex: 1;
  padding: 8px;
  overflow: visible;
  max-height: none;
}

/* Products shown inside a non-leaf group (group has both children AND products) */
.matrix-group-own-products {
  padding: 6px 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  background: rgba(255, 255, 255, 0.02);
  overflow: visible;
  max-height: none;
}

.matrix-leaf-empty {
  text-align: center;
  color: var(--text-secondary);
  opacity: 0.25;
  font-size: 18px;
  padding: 14px 0;
}

.matrix-product-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  gap: 4px;
  width: max-content;
}

.matrix-product-list--rows {
  flex-direction: column;
}

.matrix-product-list--columns {
  flex-direction: row;
  align-items: stretch;
  inline-size: max-content;
}

.matrix-product-list--columns > .matrix-product-item {
  flex: 0 0 auto;
  min-inline-size: 0;
  inline-size: max-content;
  max-inline-size: 25ch;
}

/* ─── Catalog page: full-width matrix wrapper ──────────────────────────────── */

.catalog-matrix-wrapper {
  flex: 1;
  background: var(--card-color);
  border-radius: 14px;
  padding: 20px;
  overflow: hidden;
  min-height: 300px;
}

/* ─── Breadcrumb ───────────────────────────────────────────────────────────── */

.catalog-breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
}

.breadcrumb-sep {
  color: var(--text-secondary);
  opacity: 0.4;
  font-size: 14px;
}

.breadcrumb-current {
  font-size: 14px;
  font-weight: 600;
  color: var(--primary-color);
}

/* ─── Action bar ───────────────────────────────────────────────────────────── */

.catalog-action-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: rgba(186, 101, 72, 0.1);
  border: 1px solid rgba(186, 101, 72, 0.3);
  border-radius: 10px;
  flex-wrap: wrap;
}

.catalog-action-bar--mode {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.15);
}

.action-bar-selected {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
}

.action-bar-label {
  font-size: 12px;
  color: var(--text-secondary);
  opacity: 0.7;
}

.action-bar-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--primary-color);
}

.action-bar-hint {
  flex: 1;
  font-size: 13px;
  color: var(--text-secondary);
}

.action-bar-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

/* ─── Delete confirmation banner ───────────────────────────────────────────── */

.catalog-delete-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: rgba(194, 10, 12, 0.1);
  border: 1px solid rgba(194, 10, 12, 0.35);
  border-radius: 10px;
  flex-wrap: wrap;
}

.delete-banner-icon {
  font-size: 1.3rem;
  color: var(--error-color);
  flex-shrink: 0;
}

.delete-banner-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.delete-banner-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-color);
}

.delete-banner-hint {
  font-size: 12px;
  color: var(--text-secondary);
  opacity: 0.65;
}

.delete-banner-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

/* ─── Root create form ─────────────────────────────────────────────────────── */

.catalog-root-create-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px dashed rgba(255, 255, 255, 0.15);
  border-radius: 10px;
}

/* ─── Matrix group header (interactive) ────────────────────────────────────── */

.matrix-group-header-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  background: rgba(186, 101, 72, 0.13);
  border-bottom: 1px solid rgba(186, 101, 72, 0.22);
  position: relative;
}

.matrix-group-header-row.selected {
  background: rgba(186, 101, 72, 0.28);
  border-bottom-color: rgba(186, 101, 72, 0.5);
  outline: 1px solid rgba(186, 101, 72, 0.5);
  outline-offset: -1px;
}

.matrix-group-header-row.target-mode {
  cursor: pointer;
}

.matrix-group-header-row.target-mode:hover {
  background: rgba(186, 101, 72, 0.22);
}

.matrix-group-title {
  flex: 1;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--primary-color);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.matrix-group-actions {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 0.15s;
}

.matrix-group-header-row:hover .matrix-group-actions,
.matrix-group-header-row.selected .matrix-group-actions {
  opacity: 1;
}

/* ─── Matrix leaf header (interactive) ─────────────────────────────────────── */

.matrix-leaf-header-row {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  background: rgba(255, 255, 255, 0.04);
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.matrix-leaf-header-row.selected {
  background: rgba(186, 101, 72, 0.2);
  border-bottom-color: rgba(186, 101, 72, 0.4);
  outline: 1px solid rgba(186, 101, 72, 0.4);
  outline-offset: -1px;
}

.matrix-leaf-header-row.selected .matrix-leaf-actions {
  opacity: 1;
}

.matrix-leaf-title {
  flex: 1;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.matrix-leaf-actions {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 0.15s;
}

.matrix-leaf-header-row:hover .matrix-leaf-actions {
  opacity: 1;
}

/* ─── Matrix header buttons ────────────────────────────────────────────────── */

.matrix-header-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 11px;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border-radius: 3px;
  transition: background 0.1s, color 0.1s;
  flex-shrink: 0;
}

.matrix-header-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: var(--text-color);
}

.matrix-header-btn:disabled {
  opacity: 0.3;
  cursor: default;
}

.matrix-header-btn-danger:hover {
  background: rgba(194, 10, 12, 0.2);
  color: var(--error-color);
}

/* ─── Selection checkbox button ────────────────────────────────────────────── */

.matrix-sel-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 13px;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  flex-shrink: 0;
  opacity: 0.5;
  transition: opacity 0.15s, color 0.15s;
}

.matrix-sel-btn:hover,
.matrix-sel-btn.active {
  opacity: 1;
  color: var(--primary-color);
}

/* ─── Inline create panel ──────────────────────────────────────────────────── */

.matrix-inline-create {
  border-top: 1px dashed rgba(255, 255, 255, 0.08);
  padding: 6px 8px;
  display: flex;
  justify-content: center;
}

.matrix-create-btn {
  background: none;
  border: 1px dashed rgba(255, 255, 255, 0.18);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 5px;
  opacity: 0.45;
  transition: opacity 0.15s, border-color 0.15s, color 0.15s;
  width: 100%;
}

.matrix-create-btn:hover {
  opacity: 1;
  border-color: rgba(186, 101, 72, 0.5);
  color: var(--primary-color);
}

.matrix-create-btn:disabled {
  cursor: default;
  opacity: 0.2;
}

.matrix-inline-create-btns {
  border-top: 1px dashed rgba(255, 255, 255, 0.08);
  padding: 6px 8px;
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  justify-content: center;
}

.matrix-inline-create-form {
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: rgba(255, 255, 255, 0.02);
}

/* ─── Inline rename input in matrix ────────────────────────────────────────── */

.matrix-rename-input {
  flex: 1;
  min-width: 0;
}

/* ─── Matrix product item — interactive ─────────────────────────────────────── */

.matrix-product-main {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  width: 100%;
}

.matrix-product-item-actions {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 0.15s;
}

.matrix-product-item:hover .matrix-product-item-actions {
  opacity: 1;
}

.matrix-product-item {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  min-inline-size: 25ch;
  max-inline-size: 25ch;
  width: fit-content;
  padding: 4px 7px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 5px;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.matrix-product-item--columns {
  align-self: stretch;
}

.matrix-product-name {
  display: block;
  width: 100%;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-color);
  line-height: 1.35;
  white-space: normal;
  overflow-wrap: anywhere;
}

.matrix-product-price {
  display: block;
  width: 100%;
  font-size: 11px;
  color: var(--primary-color);
  opacity: 0.85;
}

.matrix-product-item-actions {
  width: 100%;
  justify-content: flex-end;
}

.matrix-product-item--editing {
  padding: 0;
  border-color: rgba(186, 101, 72, 0.3);
  background: rgba(186, 101, 72, 0.05);
}

.matrix-product-item--deleting {
  background: rgba(194, 10, 12, 0.08);
  border-color: rgba(194, 10, 12, 0.25);
  flex-direction: column;
  align-items: stretch;
}

.matrix-product-delete-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 0;
  flex-wrap: wrap;
}

.matrix-product-delete-label {
  font-size: 11px;
  color: var(--error-color);
  flex: 1;
}

/* ─── Pivot table layout ────────────────────────────────────────────────────── */

.matrix-table-wrap {
  overflow: auto;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
}

.matrix-pivot-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: auto;
  min-width: 960px;
}

.matrix-pivot-table th,
.matrix-pivot-table td {
  border: 1px solid rgba(255, 255, 255, 0.12);
  vertical-align: middle;
  padding: 6px 8px;
}

.matrix-corner-cell {
  min-width: 180px;
  text-align: left;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.03);
}

.matrix-col-header {
  background: rgba(186, 101, 72, 0.12);
  min-width: 180px;
}

.matrix-col-header.matrix-col-header--stub {
  text-align: center;
  color: var(--text-secondary);
  font-size: 12px;
  background: rgba(255, 255, 255, 0.03);
}

.matrix-row-header {
  background: rgba(255, 255, 255, 0.03);
  min-width: 220px;
  text-align: left;
}

.matrix-row-header.matrix-row-header--empty,
.matrix-col-header.matrix-col-header--empty {
  background: rgba(255, 255, 255, 0.02);
}

.matrix-row-header.selected,
.matrix-col-header.selected {
  background: rgba(186, 101, 72, 0.24);
  outline: 1px solid rgba(186, 101, 72, 0.5);
  outline-offset: -1px;
}

.matrix-row-header.target-mode,
.matrix-col-header.target-mode {
  cursor: pointer;
}

.matrix-row-header.target-mode:hover,
.matrix-col-header.target-mode:hover {
  background: rgba(186, 101, 72, 0.2);
}

.matrix-axis-header-content {
  display: flex;
  align-items: center;
  gap: 6px;
}

.matrix-axis-title {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 12px;
  font-weight: 700;
}

.matrix-axis-actions {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
}

.matrix-node-panel {
  min-inline-size: 25ch;
  min-block-size: 50px;
  width: max-content;
  background: rgba(255, 255, 255, 0.015);
}

.matrix-cell-empty {
  text-align: center;
  color: var(--text-secondary);
  opacity: 0.35;
  font-size: 16px;
  padding: 8px 0;
}

/* ─── Users pages ─────────────────────────────────────────────────────────── */

.users-page,
.user-details-page {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

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

.users-page-title,
.user-details-title {
  margin: 0;
  font-size: 24px;
}

.users-search {
  max-width: 720px;
  width: 100%;
}

.users-search .input-base {
  width: 100%;
  box-sizing: border-box;
}

.users-error-banner {
  background: rgba(255, 82, 82, 0.12);
  border: 1px solid rgba(255, 82, 82, 0.35);
  color: var(--error-color);
  padding: 10px 12px;
  border-radius: 10px;
}

.users-loading,
.users-empty,
.user-details-empty {
  color: var(--text-secondary);
}

.users-table-wrap {
  overflow-x: auto;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
}

.users-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

.users-table th,
.users-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.users-table th {
  color: var(--text-secondary);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.users-table-row {
  cursor: pointer;
}

.users-table-row:hover {
  background: rgba(255, 255, 255, 0.04);
}

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

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

.users-pagination-info {
  color: var(--text-secondary);
  font-size: 14px;
}

.user-details-card {
  background: var(--card-color);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

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

.user-details-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.user-details-field-label {
  color: var(--text-secondary);
  font-size: 12px;
}

.user-details-field-value {
  word-break: break-word;
}

.user-details-total {
  margin: 0;
  font-weight: 600;
}

/* ─── Orders pages ────────────────────────────────────────────────────────── */

.orders-page,
.order-details-page {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

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

.orders-page-title,
.order-details-title {
  margin: 0;
  font-size: 24px;
}

.orders-filters {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.orders-filter-label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 180px;
}

.orders-status-filter {
  min-width: 180px;
}

.orders-error-banner {
  background: rgba(255, 82, 82, 0.12);
  border: 1px solid rgba(255, 82, 82, 0.35);
  color: var(--error-color);
  padding: 10px 12px;
  border-radius: 10px;
}

.orders-loading,
.orders-empty,
.order-details-empty {
  color: var(--text-secondary);
}

.orders-table-wrap {
  overflow-x: auto;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
}

.orders-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

.orders-table th,
.orders-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.orders-table th {
  color: var(--text-secondary);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.orders-table-row {
  cursor: pointer;
}

.orders-table-row:hover {
  background: rgba(255, 255, 255, 0.04);
}

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

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

.orders-pagination-info {
  color: var(--text-secondary);
  font-size: 14px;
}

.order-details-card {
  background: var(--card-color);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

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

.order-details-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.order-details-field-label {
  color: var(--text-secondary);
  font-size: 12px;
}

.order-details-field-value {
  word-break: break-word;
}

.order-details-actions {
  display: flex;
  justify-content: flex-end;
}

.order-details-user-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.order-details-user-link {
  width: 100%;
  text-align: center;
}

.orders-qty-input {
  max-width: 96px;
}

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

.orders-line-no-file {
  color: var(--text-secondary);
}

.orders-file-preview-card {
  gap: 12px;
}

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

.orders-file-preview {
  width: 100%;
  min-height: 520px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.2);
}

.orders-file-preview-frame {
  width: 100%;
  min-height: 520px;
  border: 0;
  display: block;
}
