:root {
  --sa-ink: #14202b;
  --sa-muted: #5d6b78;
  --sa-line: #dde3e9;
  --sa-bg: #f3f5f7;
  --sa-panel: #ffffff;
  --sa-brand: #0f1a14;
  --sa-accent: #e8a317;
  --sa-blue: #1559d0;
  --sa-green: #0c7a32;
  --sa-garment-bg: #eceff2;
}
body { background: var(--sa-bg); color: var(--sa-ink); min-height: 100vh; display: flex; flex-direction: column; }
main { flex: 1 0 auto; }
.page-title { font-size: 1.6rem; font-weight: 700; margin-bottom: 1.25rem; }
a { color: var(--sa-blue); }

/* ---------- navigation ---------- */
.app-nav { background: var(--sa-brand); }
.app-nav .navbar-brand { letter-spacing: .06em; font-weight: 600; }
.app-nav .navbar-brand b { color: var(--sa-accent); }
.app-nav .nav-link.active { color: #fff; box-shadow: inset 0 -2px 0 var(--sa-accent); }
.crm-subnav { background: #22303c; padding: 6px 0; }
.crm-tab { color: #cfd8e0; text-decoration: none; padding: 6px 12px; border-radius: 6px; font-size: .95rem; }
.crm-tab:hover { color: #fff; background: #2f404e; }
.crm-tab.active { color: #fff; background: #3a5064; }
.crm-search { flex: 0 1 380px; }
.app-footer { color: var(--sa-muted); font-size: .85rem; padding: 24px 0; border-top: 1px solid var(--sa-line); background: #fff; }

/* ---------- panels ---------- */
.panel { background: var(--sa-panel); border: 1px solid var(--sa-line); border-radius: 10px; padding: 18px; }
.panel + .panel { margin-top: 16px; }
.panel-title { font-size: 1.05rem; font-weight: 700; margin: 0 0 12px; display: flex; align-items: center; gap: 8px; }
.muted { color: var(--sa-muted); }
.stat { background: #fff; border: 1px solid var(--sa-line); border-radius: 10px; padding: 14px 16px; height: 100%; }
.stat .num { font-size: 1.8rem; font-weight: 700; line-height: 1.1; }
.stat .lbl { color: var(--sa-muted); font-size: .85rem; }
.table > :not(caption) > * > * { vertical-align: middle; }
.table-clickable tbody tr { cursor: pointer; }
.empty { color: var(--sa-muted); text-align: center; padding: 28px 10px; border: 1px dashed var(--sa-line); border-radius: 10px; background: #fafbfc; }

/* ---------- shop ---------- */
.shop-hero { background: linear-gradient(120deg, #0f1a14, #22303c); color: #fff; border-radius: 14px; padding: 28px 28px; margin-bottom: 20px; }
.shop-hero .kicker { color: var(--sa-accent); font-weight: 700; letter-spacing: .08em; font-size: .8rem; }
.shop-hero h1 { font-weight: 800; margin: 6px 0; }
.filters { position: sticky; top: 12px; }
.filters .form-label { font-size: .85rem; font-weight: 600; margin-bottom: 2px; }
.cat-list { max-height: 360px; overflow: auto; }
.cat-list .form-check { font-size: .92rem; }
.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 16px; }
.product-card { background: #fff; border: 1px solid var(--sa-line); border-radius: 12px; overflow: hidden; text-align: left; padding: 0; display: flex; flex-direction: column; transition: box-shadow .15s, transform .15s; }
.product-card:hover, .product-card:focus-visible { box-shadow: 0 8px 22px rgba(20, 32, 43, .14); transform: translateY(-2px); }
.product-card .ph { aspect-ratio: 1; background: var(--sa-garment-bg); display: flex; align-items: center; justify-content: center; }
.product-card .ph img { width: 100%; height: 100%; object-fit: contain; }
.product-card .info { padding: 10px 12px 14px; }
.product-card .brand { color: var(--sa-muted); font-size: .8rem; }
.product-card .title { font-size: .95rem; font-weight: 600; margin: 2px 0 6px; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.product-card .price { font-weight: 700; color: var(--sa-green); }
.swatches { display: flex; flex-wrap: wrap; gap: 6px; }
.swatch { border: 2px solid #cfd6de; border-radius: 8px; padding: 2px; background: #fff; width: 40px; height: 40px; display: inline-flex; align-items: center; justify-content: center; font-size: 10px; line-height: 1; overflow: hidden; }
.swatch img { width: 100%; height: 100%; object-fit: cover; border-radius: 5px; }
.swatch[aria-pressed="true"] { border-color: var(--sa-blue); box-shadow: 0 0 0 2px rgba(21, 89, 208, .3); }
.size-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); gap: 8px; }
.size-grid label { display: flex; flex-direction: column; gap: 2px; font-size: .8rem; font-weight: 600; text-align: center; }
.size-grid input { text-align: center; }
.size-grid small { font-weight: 400; color: var(--sa-muted); }
.gallery-main { aspect-ratio: 1; background: var(--sa-garment-bg); border-radius: 10px; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.gallery-main img { width: 100%; height: 100%; object-fit: contain; }
.thumbs { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.thumbs button { width: 64px; height: 64px; padding: 3px; border: 2px solid var(--sa-line); border-radius: 8px; background: #fff; }
.thumbs button[aria-pressed="true"] { border-color: var(--sa-blue); }
.thumbs img { width: 100%; height: 100%; object-fit: contain; }

/* ---------- mockups (product photo with logos) ---------- */
.mockup { margin: 0; }
.mockup-box { position: relative; width: 100%; background: var(--sa-garment-bg); border-radius: 8px; overflow: hidden; aspect-ratio: 1; }
.mockup-box.broken { display: flex; align-items: center; justify-content: center; color: var(--sa-muted); font-size: .8rem; }
.mockup-box .mk-photo { position: absolute; left: 0; top: 0; width: 100%; height: auto; display: block; user-select: none; pointer-events: none; }
.mockup-box .mk-viewport { position: absolute; left: 50%; top: 50%; overflow: hidden; }
.mockup-box .mk-viewport img { display: block; width: 100%; height: 100%; object-fit: contain; }
.mockup-box .mk-logo { position: absolute; display: block; height: auto; pointer-events: none; user-select: none; }
.mockup figcaption { font-size: .8rem; color: var(--sa-muted); text-align: center; padding-top: 4px; }
.mockup-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.mockup-row.sm { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }

/* ---------- order lines ---------- */
.line-card { border: 1px solid var(--sa-line); border-radius: 10px; padding: 14px; background: #fff; }
.line-card + .line-card { margin-top: 12px; }
.size-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.size-chip { border: 1px solid var(--sa-line); border-radius: 6px; padding: 2px 8px; font-size: .85rem; background: #f8fafb; }
.size-chip b { margin-left: 4px; }
.placement-table td, .placement-table th { font-size: .85rem; }
.logo-thumb { width: 48px; height: 48px; object-fit: contain; background: repeating-conic-gradient(#e9edf1 0 25%, #fff 0 50%) 0 0 / 12px 12px; border: 1px solid var(--sa-line); border-radius: 6px; }
.logo-tile { background: #fff; border: 1px solid var(--sa-line); border-radius: 10px; padding: 10px; text-align: center; height: 100%; }
.logo-tile .img { aspect-ratio: 1; display: flex; align-items: center; justify-content: center; background: repeating-conic-gradient(#e9edf1 0 25%, #fff 0 50%) 0 0 / 14px 14px; border-radius: 8px; margin-bottom: 6px; }
.logo-tile .img img { max-width: 100%; max-height: 100%; object-fit: contain; }
.logo-tile .name { font-size: .8rem; word-break: break-all; }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { border-left: 3px solid var(--sa-line); padding: 4px 0 12px 14px; position: relative; }
.timeline li::before { content: ''; position: absolute; left: -7px; top: 9px; width: 11px; height: 11px; border-radius: 50%; background: #9fb0bf; }
.timeline li.t-call::before { background: var(--sa-green); }
.timeline li.t-email::before { background: var(--sa-blue); }
.timeline li.t-status::before, .timeline li.t-system::before { background: var(--sa-accent); }
.timeline .meta { font-size: .8rem; color: var(--sa-muted); }
.timeline .body { white-space: pre-wrap; }

/* ---------- designer ---------- */
.designer { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 16px; align-items: start; }
.designer-toolbar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 8px; }
.designer-toolbar .btn { min-width: 38px; }
.designer-toolbar .sep { width: 1px; height: 28px; background: var(--sa-line); margin: 0 4px; }
.stage-wrap { background: #fff; border: 1px solid var(--sa-line); border-radius: 12px; padding: 10px; }
.stage-scroll { overflow: auto; max-height: 76vh; border-radius: 8px; background: var(--sa-garment-bg); }
.stage-sheet { position: relative; margin: 0 auto; touch-action: none; user-select: none; }
.stage-sheet > .photo { position: absolute; left: 0; top: 0; width: 100%; display: block; pointer-events: none; }
.stage-sheet.mirrored > .photo { transform: scaleX(-1); }
.stage-sheet .guide { position: absolute; top: 0; bottom: 0; left: 50%; border-left: 1px dashed #e0457b; pointer-events: none; display: none; z-index: 5; }
.stage-sheet .guide.h { top: 50%; bottom: auto; left: 0; right: 0; border-left: 0; border-top: 1px dashed #e0457b; }
.stage-sheet .guide.on { display: block; }
.placed { position: absolute; transform-origin: center; cursor: move; touch-action: none; outline: 1px solid transparent; }
.placed img { display: block; width: 100%; height: auto; pointer-events: none; }
.placed:hover { outline-color: rgba(22, 132, 255, .45); }
.placed.selected { outline: 1.5px solid #1684ff; }
.placed .handle { display: none; position: absolute; width: 14px; height: 14px; background: #fff; border: 2px solid #1684ff; border-radius: 3px; z-index: 3; }
.placed.selected .handle { display: block; }
.placed .handle.nw { left: -8px; top: -8px; cursor: nwse-resize; }
.placed .handle.ne { right: -8px; top: -8px; cursor: nesw-resize; }
.placed .handle.sw { left: -8px; bottom: -8px; cursor: nesw-resize; }
.placed .handle.se { right: -8px; bottom: -8px; cursor: nwse-resize; }
.placed .handle.rot { left: calc(50% - 9px); top: -36px; width: 18px; height: 18px; border-radius: 50%; cursor: grab; }
.placed .handle.rot::after { content: '↻'; position: absolute; inset: -3px 0 0; text-align: center; font-size: 13px; color: #1684ff; line-height: 18px; }
.placed .tag { position: absolute; left: 50%; bottom: -22px; transform: translateX(-50%); background: #1684ff; color: #fff; font-size: 11px; border-radius: 4px; padding: 1px 6px; white-space: nowrap; display: none; }
.placed.selected .tag:not(:empty) { display: block; }
.view-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.view-tab { border: 2px solid var(--sa-line); background: #fff; border-radius: 10px; padding: 4px; width: 88px; text-align: center; font-size: .75rem; position: relative; }
.view-tab img { width: 100%; aspect-ratio: 1; object-fit: contain; background: var(--sa-garment-bg); border-radius: 6px; }
.view-tab[aria-pressed="true"] { border-color: var(--sa-blue); }
.view-tab .count { position: absolute; top: 2px; right: 2px; background: var(--sa-blue); color: #fff; border-radius: 10px; font-size: 11px; min-width: 18px; padding: 0 5px; }
.side .nav-tabs .nav-link { padding: 6px 10px; font-size: .9rem; }
.side .tab-pane { padding-top: 12px; }
.logo-pick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; max-height: 340px; overflow: auto; padding: 2px; }
.logo-pick button { aspect-ratio: 1; border: 1px solid var(--sa-line); border-radius: 8px; padding: 4px; background: repeating-conic-gradient(#e9edf1 0 25%, #fff 0 50%) 0 0 / 12px 12px; }
.logo-pick button:hover, .logo-pick button:focus-visible { border-color: var(--sa-blue); outline: 2px solid rgba(21, 89, 208, .25); }
.logo-pick img { width: 100%; height: 100%; object-fit: contain; }
.dropzone { border: 2px dashed #b8c4cf; border-radius: 10px; padding: 14px; text-align: center; color: var(--sa-muted); font-size: .9rem; cursor: pointer; margin-bottom: 10px; }
.dropzone.drag { border-color: var(--sa-blue); background: #eef4ff; color: var(--sa-blue); }
.designer-status { min-height: 1.4em; font-size: .9rem; }
.kbd-help { font-size: .8rem; color: var(--sa-muted); }

@media (max-width: 991px) {
  .designer { grid-template-columns: 1fr; }
  .filters { position: static; }
}

/* ---------- print (work orders) ---------- */
@media print {
  .app-nav, .crm-subnav, .app-footer, .no-print, .btn, form.no-print { display: none !important; }
  body { background: #fff; }
  main { padding: 0 !important; }
  .panel, .line-card { border: 1px solid #999; break-inside: avoid; }
  .mockup-row { grid-template-columns: repeat(4, 1fr); }
}
