/* =====================================================================
   AFORME COMMERCE OS V6 — Enterprise UI layer
   ===================================================================== */
:root{
  --bg:#f5f7fb;
  --panel:#ffffff;
  --panel-soft:#fafbfe;
  --line:#e4e9f1;
  --line2:#d8dfeb;
  --text:#172033;
  --muted:#77839a;
  --primary:#3158d4;
  --primary2:#2548b6;
  --primarySoft:#eef3ff;
  --green:#138a5b;
  --greenSoft:#eaf8f1;
  --amber:#bb7710;
  --amberSoft:#fff6e5;
  --red:#d44646;
  --redSoft:#fff0f0;
  --shadow:0 14px 44px rgba(31,48,82,.09);
  --shadow-soft:0 6px 22px rgba(31,48,82,.055);
}
body{background:linear-gradient(180deg,#f7f9fc 0,#f4f6fa 220px,#f5f7fb 100%)}
.topbar{height:72px;padding:0 24px;border-bottom:1px solid #e9edf4;box-shadow:0 1px 0 rgba(28,46,80,.02)}
.scope-select{width:190px;height:42px;border-radius:12px;background:#fff}
.global-search{max-width:780px}.global-search input{height:42px;border-radius:12px;background:#f8faff;border-color:#e5eaf3;font-size:13px}.global-search input:focus{background:#fff}
.context-title{display:flex;align-items:center;gap:10px;min-width:260px}.context-title .ctx-icon{width:34px;height:34px;border-radius:10px;background:var(--primarySoft);color:var(--primary);display:grid;place-items:center;font-weight:900}.context-title b{font-size:13px}.context-title span{display:block;color:var(--muted);font-size:10px;margin-top:2px}
.page{padding:20px 24px 34px;max-width:1900px}.page-head{margin-bottom:16px}.page-head h2{font-size:23px;letter-spacing:-.02em}.page-head p{font-size:12px}
.card,.kpi,.ops-stat,.scan-panel,.sheet-card{border-color:#e3e8f0;box-shadow:var(--shadow-soft)}
.card{border-radius:16px}.card-head{padding:15px 17px}.card-head h3{font-size:13px;letter-spacing:.01em}
.btn{min-height:38px;border-radius:10px;border-color:#dce3ee;box-shadow:0 1px 1px rgba(20,35,60,.02)}.btn.primary{box-shadow:0 7px 18px rgba(49,88,212,.18)}.btn.sm{min-height:32px}.btn:hover{border-color:#cbd5e4}
.tabs{border:1px solid #e2e7f0;background:#f1f4f8;padding:4px}.tab{min-width:92px}.tab.active{box-shadow:0 2px 10px rgba(42,63,100,.09)}
.notice{border-radius:12px;border-color:#bdd1fb;background:#f1f6ff;color:#37588b}
th{background:#f6f8fb;color:#526078;padding:11px 12px;border-bottom:1px solid #e5eaf2}td{padding:11px 12px}.table-scroll{border-radius:0 0 15px 15px}tbody tr:hover td{background:#f7faff}.link{color:#2d58c8}
.toggle{box-shadow:inset 0 0 0 1px rgba(22,34,60,.05)}

/* Downward module panel: no more floating to the right of the sidebar */
.submenu{
  position:relative!important;
  left:auto!important;top:auto!important;
  margin:10px 24px 0!important;
  width:calc(100% - 48px)!important;
  min-width:0!important;
  padding:0!important;
  border:1px solid #e0e6ef!important;
  border-radius:16px!important;
  background:rgba(255,255,255,.98)!important;
  box-shadow:var(--shadow)!important;
  overflow:hidden;
  z-index:18!important;
  animation:moduleDown .16s ease-out;
}
@keyframes moduleDown{from{opacity:0;transform:translateY(-5px)}to{opacity:1;transform:none}}
.module-panel{padding:17px 20px 18px}.module-panel-head{display:flex;justify-content:space-between;align-items:center;border-bottom:1px solid #edf0f5;padding-bottom:12px;margin-bottom:12px}.module-panel-head h3{margin:0;font-size:15px}.module-panel-head p{margin:3px 0 0;color:var(--muted);font-size:11px}.module-close{width:32px;height:32px;border:0;border-radius:9px;background:#f4f6f9;color:#6c788c}.module-close:hover{background:#eaf0fb;color:var(--primary)}
.module-grid{display:grid;grid-template-columns:repeat(4,minmax(170px,1fr));gap:12px}.module-group{border:1px solid #edf0f5;background:#fbfcfe;border-radius:12px;padding:10px}.module-group h4{margin:2px 8px 7px!important;color:#929cae!important;font-size:10px!important}.module-group button{display:flex!important;width:100%;align-items:center;gap:8px;padding:9px 10px!important;border-radius:8px!important;font-size:12px}.module-group button:hover{background:#eef4ff!important}

/* Product list & expandable variants */
.product-table{min-width:1320px}.expand-btn{width:28px;height:28px;border:1px solid #dde4ee;border-radius:8px;background:#fff;color:#5b6a83;font-weight:800}.expand-btn.open{background:var(--primarySoft);color:var(--primary);border-color:#cad8fb}.variant-child td{background:#fbfcff!important}.variant-child td:first-child{border-left:3px solid #d7e2ff}.variant-indent{display:flex;align-items:center;gap:8px;padding-left:12px}.variant-dot{width:7px;height:7px;border-radius:50%;background:#9ab1e8}.stock-number{font-variant-numeric:tabular-nums;font-weight:750}
.quick-action{white-space:nowrap;display:flex;gap:6px}.icon-pill{border:1px solid #dfe5ef;background:#fff;border-radius:8px;padding:6px 8px;color:#516079}.icon-pill:hover{background:#eef4ff;color:#3158d4}

/* Product editor */
dialog.product-editor{width:min(1480px,97vw)!important;height:min(900px,95vh);border-radius:18px;overflow:hidden}dialog.product-editor .modal-body{max-height:none;overflow:auto;flex:1;background:#f7f9fc;padding:16px 18px 22px}dialog.product-editor #modalContent{height:100%;display:flex;flex-direction:column}dialog.product-editor .modal-foot{position:sticky;bottom:0;background:#fff;z-index:8;box-shadow:0 -8px 20px rgba(33,50,81,.05)}
.editor-shell{display:grid;grid-template-columns:minmax(0,1fr);gap:14px}.editor-section{background:#fff;border:1px solid #e2e7ef;border-radius:15px;box-shadow:var(--shadow-soft)}.editor-section-head{padding:13px 15px;border-bottom:1px solid #edf0f5;display:flex;justify-content:space-between;align-items:center}.editor-section-head h4{margin:0;font-size:13px}.editor-section-head small{color:var(--muted)}.editor-section-body{padding:14px 15px}.editor-grid{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:12px}.editor-grid .span2{grid-column:span 2}.editor-grid .span4{grid-column:1/-1}
.field-hint{font-size:10px;color:var(--muted);margin-top:5px}.chip-input{min-height:42px;border:1px solid var(--line2);border-radius:10px;background:#fff;padding:5px 7px;display:flex;gap:5px;align-items:center;flex-wrap:wrap}.chip{display:inline-flex;align-items:center;gap:5px;padding:5px 8px;border-radius:8px;background:#eef3ff;color:#3158c8;font-size:11px;font-weight:750}.chip button{border:0;background:transparent;color:#6c7db0;padding:0}.attribute-builder{display:grid;grid-template-columns:1fr 1fr 1fr auto;gap:10px;align-items:end}.variant-generator{border:1px solid #dce5f5;background:linear-gradient(180deg,#f7faff,#f3f7ff);border-radius:13px;padding:12px;margin-top:12px}.variant-generator-title{display:flex;justify-content:space-between;align-items:center;margin-bottom:9px}.variant-generator-title b{font-size:12px}.variant-preview{max-height:310px;overflow:auto;border:1px solid #e0e6ef;border-radius:11px;background:#fff}.variant-preview table{min-width:980px}.variant-preview input{height:34px;padding:6px 8px;border-radius:8px;font-size:11px}.variant-preview th,.variant-preview td{padding:7px 8px}
.variant-master-table{max-height:410px;overflow:auto;border:1px solid #e2e7ef;border-radius:12px}.variant-master-table table{min-width:1280px}.variant-master-table th{top:0}.effective-price{font-size:10px;color:#7a8497}.empty-variant{padding:26px;text-align:center;color:#7c8798}.empty-variant b{display:block;color:#354258;margin-bottom:4px}

/* Stock editor */
.stock-modal-grid{display:grid;grid-template-columns:1fr 1fr 1fr;gap:10px;margin-bottom:12px}.stock-edit-table{max-height:440px;overflow:auto;border:1px solid #e1e6ee;border-radius:12px}.stock-edit-table table{min-width:920px}.stock-target{width:110px!important;text-align:right;font-weight:800}.delta-pos{color:#0b8a57}.delta-neg{color:#d14343}.delta-zero{color:#7c8797}.stock-summary{display:grid;grid-template-columns:repeat(4,1fr);gap:9px;margin:10px 0}.stock-summary>div{border:1px solid #e4e9f1;background:#fafbfd;border-radius:11px;padding:10px}.stock-summary span{font-size:10px;color:var(--muted)}.stock-summary b{display:block;font-size:18px;margin-top:4px}

/* Variant tab */
.variant-toolbar{display:flex;gap:8px;align-items:center;flex-wrap:wrap;padding:12px 15px;border-bottom:1px solid #edf0f5;background:#fbfcfe}.variant-toolbar .spacer{flex:1}.variant-filter{width:150px}.variant-status-active{color:#0b8b58}.variant-status-off{color:#9aa3b2}

/* Inventory */
.inventory-toolbar{padding:12px 15px;border-bottom:1px solid #edf0f5;display:flex;gap:8px;align-items:center;flex-wrap:wrap}.inventory-toolbar .spacer{flex:1}

/* Polished scanner */
.scan-input{border-radius:12px!important;background:#fbfdff!important}.scan-panel{border-radius:16px}.flow-node{box-shadow:0 3px 13px rgba(40,57,89,.04)}

/* Dialog base refinement */
dialog{border:1px solid rgba(222,228,238,.9)}.modal-head{min-height:60px}.modal-head h3{letter-spacing:-.01em}.modal-foot{background:#fbfcfe}

@media(max-width:1250px){.module-grid{grid-template-columns:repeat(2,1fr)}.editor-grid{grid-template-columns:repeat(2,1fr)}.editor-grid .span4{grid-column:1/-1}.attribute-builder{grid-template-columns:1fr 1fr}.stock-summary{grid-template-columns:repeat(2,1fr)}}
@media(max-width:760px){.submenu{margin:8px 10px 0!important;width:calc(100% - 20px)!important}.module-grid{grid-template-columns:1fr}.editor-grid,.stock-modal-grid{grid-template-columns:1fr}.editor-grid .span2,.editor-grid .span4{grid-column:auto}.context-title{display:none}.global-search{max-width:none}.page{padding:12px}.product-editor{width:98vw!important}}
