:root {
  --primary-color: #667eea;
  --primary-dark: #5a6fd6;
  --secondary-color: #764ba2;
  --accent-color: #f2994a;
  --success-color: #11998e;
  --warning-color: #f2994a;
  --danger-color: #eb3349;
  --info-color: #2193b0;
  --text-color: #1f2937;
  --text-muted: #6b7280;
  --surface-color: #ffffff;
  --bg-color: #f5f7fb;
  --border-color: #e5e7eb;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.1);
  --sidebar-width: 260px;
  --header-height: 60px;
}

body {
  font-family: "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  color: var(--text-color);
  background: linear-gradient(135deg, #eef2ff 0%, #f8fafc 60%, #fff7ed 100%);
  min-height: 100vh;
}

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

.sidebar {
  width: var(--sidebar-width);
  background: #0f172a;
  color: #fff;
  padding: 1.25rem;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-brand {
  font-size: 1.125rem;
  font-weight: 600;
}

.sidebar .nav-link {
  color: #cbd5e1;
  border-radius: var(--radius-sm);
  margin-bottom: 0.25rem;
}

.sidebar .nav-link:hover,
.sidebar .nav-link:focus {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}

.main-area {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: var(--header-height);
  background: var(--surface-color);
  border-bottom: 1px solid var(--border-color);
  padding: 0 1.5rem;
}

.page-content {
  padding: 1.5rem;
  flex: 1;
}

.page-title {
  font-size: 24px;
  font-weight: 600;
}

.card {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

.auth-container {
  min-height: calc(100vh - 52px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.auth-card {
  width: 100%;
  max-width: 420px;
}

.auth-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-footer {
  border-top: 1px solid var(--border-color);
  background: rgba(255, 255, 255, 0.85);
  padding: 0.75rem 1.5rem;
}

.footer__credit {
  margin: 0;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
}

.footer__credit a {
  color: var(--primary-color);
  text-decoration: none;
}

.footer__credit a:hover,
.footer__credit a:focus {
  color: var(--primary-dark);
  text-decoration: underline;
}

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

.btn-primary:hover,
.btn-primary:focus {
  background-color: var(--primary-dark);
  border-color: var(--primary-dark);
}

.module-config-example {
  background: #f8fafc;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
  font-size: 13px;
  white-space: pre-wrap;
  word-break: break-word;
}

.dashboard-shortcuts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.9rem;
}

.dashboard-shortcut-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-decoration: none;
  text-align: center;
  color: var(--text-color);
  background: linear-gradient(150deg, #ffffff 0%, #f8fafc 70%, #eef2ff 100%);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.9rem;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.dashboard-shortcut-tile:hover,
.dashboard-shortcut-tile:focus {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: #c7d2fe;
}

.dashboard-shortcut-tile--inactive {
  opacity: 0.72;
}

.dashboard-shortcut-tile--inactive:hover,
.dashboard-shortcut-tile--inactive:focus {
  transform: none;
  box-shadow: var(--shadow-sm);
  border-color: var(--border-color);
}

.dashboard-shortcut-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: #334155;
  background: #e2e8f0;
  margin-bottom: 0.55rem;
}

.dashboard-shortcut-name {
  display: block;
  font-weight: 600;
  margin-bottom: 0.2rem;
  text-align: center;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  min-height: 2.7em;
}

.dashboard-shortcut-url {
  display: block;
  color: var(--text-muted);
  font-size: 13px;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.shortcut-icon-trigger {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.55rem;
}

.shortcut-icon-trigger__preview {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #eef2ff;
  color: #334155;
  font-size: 18px;
}

/* ==========================================================================
   Operations flow chart (production order details modal)
   Each operation renders as exactly one tile, grouped into columns by
   dependency depth. Real operation -> operation relations (incl. several
   operations feeding a single one) are drawn as SVG connector lines
   overlaid after layout, so no tile is ever duplicated.
   ========================================================================== */

.op-tree-chart {
  overflow-x: auto;
  overflow-y: hidden;
  padding: 8px 4px 12px;
}

.op-tree-chart-scroll {
  position: relative;
  display: inline-block;
  min-width: 100%;
}

.op-tree-connectors {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
}

.op-tree-columns {
  position: relative;
  display: flex;
  align-items: stretch;
  gap: 56px;
}

.op-tree-col {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 22px;
}

.op-tree-node-wrap {
  position: relative;
  z-index: 1;
  transition: opacity .15s ease, transform .15s ease;
  cursor: pointer;
}

.op-tree-node-wrap.op-tree-active {
  transform: scale(1.04);
}

.op-tree-node-wrap.op-tree-active .op-tree-node {
  box-shadow: 0 0 0 2px var(--primary-color), var(--shadow-md);
}

.op-tree-node-wrap.op-tree-dim {
  opacity: .25;
}

.op-tree-node-wrap.op-tree-pinned .op-tree-node {
  box-shadow: 0 0 0 2px var(--accent-color), var(--shadow-md);
}

.op-tree-node-wrap.op-tree-pinned::before {
  content: "📌";
  position: absolute;
  top: -8px;
  right: -6px;
  z-index: 2;
  font-size: .7rem;
  line-height: 1;
  background: var(--surface-color);
  border-radius: 50%;
  box-shadow: var(--shadow-sm);
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.op-tree-node {
  background: var(--surface-color);
  box-shadow: var(--shadow-sm);
  transition: box-shadow .15s ease;
}

.op-tree-path {
  transition: opacity .15s ease, stroke-width .15s ease;
}

.op-tree-path-active {
  opacity: 0.95 !important;
  stroke-width: 3 !important;
}

.op-tree-path-dim {
  opacity: 0.08 !important;
}


.shortcut-icon-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(56px, 1fr));
  gap: 0.55rem;
}

.shortcut-icon-grid__item {
  height: 52px;
  font-size: 22px;
}

.shortcut-icon-grid__item.active {
  border-color: var(--primary-color);
  background: #e0e7ff;
  color: #1f2937;
}

.js-sortable-shortcut-row {
  cursor: move;
}

.js-sortable-shortcut-row.is-dragging {
  opacity: 0.45;
}

.js-sortable-shortcuts.is-drag-over .js-sortable-shortcut-row {
  transition: background-color 0.12s ease;
}

@media (max-width: 991.98px) {
  .sidebar {
    display: none;
  }

  .page-content {
    padding: 1rem;
  }
}

.product-photo-box {
  background-color: #f8f9fa;
  border-radius: 0.5rem;
  overflow: hidden;
}

.product-photo-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  cursor: zoom-in;
}

.product-photo-edit-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 32px;
  height: 32px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 50%;
  opacity: 0;
  transition: opacity 0.15s ease-in-out;
}

.product-photo-box:hover .product-photo-edit-btn,
.product-photo-edit-btn:focus {
  opacity: 1;
}

.product-photo-empty {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  background-color: transparent;
  border: 2px dashed #ced4da;
  border-radius: 0.5rem;
  color: #6c757d;
}

.product-photo-empty:hover {
  background-color: #f1f3f5;
  border-color: #adb5bd;
}

.product-photo-dropzone {
  position: relative;
  min-height: 220px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 1.5rem;
  border: 2px dashed #ced4da;
  border-radius: 0.5rem;
  cursor: pointer;
  transition: border-color 0.15s ease-in-out, background-color 0.15s ease-in-out;
}

.product-photo-dropzone.is-dragover {
  border-color: #0d6efd;
  background-color: rgba(13, 110, 253, 0.06);
}

.product-photo-dropzone img#productPhotoPreview {
  max-height: 260px;
  max-width: 100%;
  border-radius: 0.375rem;
}

.product-photo-lightbox {
  position: fixed;
  inset: 0;
  z-index: 1080;
  background-color: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  cursor: zoom-out;
}

.product-photo-lightbox-scroll {
  max-width: 100%;
  max-height: 100%;
  overflow: auto;
  cursor: default;
}

.product-photo-lightbox-scroll img {
  display: block;
}

.product-photo-lightbox-close {
  position: fixed;
  top: 1rem;
  right: 1.25rem;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: rgba(255, 255, 255, 0.15);
  border: none;
  border-radius: 50%;
  color: #fff;
  font-size: 1.1rem;
}

.product-photo-lightbox-close:hover {
  background-color: rgba(255, 255, 255, 0.3);
}
