/* ===== INVENTORY STAT BAR ===== */
.inv-stat-bar {
  display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 14px;
}
.inv-stat {
  display: flex; align-items: center; gap: 7px;
  font-size: 0.83rem; color: var(--color-text-secondary);
  padding: 6px 14px;
  background: white;
  border: 1px solid var(--color-border);
  border-radius: 20px;
  box-shadow: var(--shadow-xs);
  font-weight: 500;
}
.inv-stat strong { color: var(--color-text); font-size: 0.95rem; font-weight: 800; }

/* ===== REORDER PLANNER ===== */
.reorder-summary-bar {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 13px; margin-bottom: 20px;
}
.reorder-stat-card {
  background: white; border-radius: var(--radius-lg); border: 1px solid var(--color-border);
  padding: 15px; text-align: center; box-shadow: var(--shadow-xs);
  transition: box-shadow var(--transition);
}
.reorder-stat-card:hover { box-shadow: var(--shadow-md); }
.reorder-stat-card .stat-num   { font-size: 1.65rem; font-weight: 900; color: var(--color-text); display: block; letter-spacing: -0.5px; }
.reorder-stat-card .stat-label { font-size: 0.76rem; color: var(--color-text-secondary); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }

.reorder-group {
  background: white; border-radius: var(--radius-lg); border: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm); margin-bottom: 14px; overflow: hidden;
}
.reorder-group-header {
  padding: 13px 16px; background: #fafbfc;
  border-bottom: 1px solid var(--color-border);
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
}
.reorder-group-header h3 { font-size: 0.92rem; font-weight: 800; color: var(--color-text); margin-bottom: 5px; }
.reorder-group-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.reorder-supplier-info { flex: 1; }

/* ===== STOCKTAKE ===== */
.stocktake-card {
  background: white; border-radius: var(--radius-lg); border: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm); margin-bottom: 12px; overflow: hidden;
  transition: box-shadow var(--transition);
}
.stocktake-card:hover { box-shadow: var(--shadow-md); }
.stocktake-card.completed { border-left: 3px solid var(--color-success); }
.stocktake-card.draft     { border-left: 3px solid var(--color-warning); }

.stocktake-card-header {
  padding: 13px 16px; border-bottom: 1px solid #f8fafc;
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
}
.stocktake-card-header h3 { font-size: 0.92rem; font-weight: 800; margin-bottom: 5px; }
.stocktake-actions { display: flex; gap: 6px; flex-wrap: wrap; flex-shrink: 0; }

.stocktake-card-stats { display: flex; padding: 12px 16px; }
.stk-stat { flex: 1; text-align: center; border-right: 1px solid var(--color-border); padding: 4px 6px; }
.stk-stat:last-child { border-right: none; }
.stk-stat span  { display: block; font-size: 1.05rem; font-weight: 800; color: var(--color-text); }
.stk-stat label { font-size: 0.67rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--color-text-muted); font-weight: 700; }

/* ===== STOCKTAKE SESSION ===== */

/* Progress card */
.stk-progress-card {
  background: white; border-radius: var(--radius-lg); border: 1px solid var(--color-border);
  padding: 14px 18px; margin-bottom: 14px; box-shadow: var(--shadow-xs);
}
.stk-progress-header {
  display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px;
}
.stk-progress-label {
  font-size: 0.75rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--color-text-muted);
}
.stk-progress-pct { font-size: 0.85rem; font-weight: 700; color: var(--color-primary); }
.stk-progress-track { height: 10px; background: #e2e8f0; border-radius: 5px; overflow: hidden; }
.stk-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--color-primary), var(--color-success));
  border-radius: 5px; transition: width 400ms ease;
}

/* KPI row */
.stk-kpi-row {
  display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; margin-bottom: 14px;
}
.stk-kpi {
  background: white; border-radius: var(--radius-md); border: 1px solid var(--color-border);
  padding: 14px 10px; text-align: center; box-shadow: var(--shadow-xs);
  position: relative; overflow: hidden;
}
.stk-kpi::after {
  content: ''; position: absolute; bottom: 0; left: 0; right: 0; height: 3px;
  background: var(--color-border);
}
.stk-kpi-accent-primary::after { background: var(--color-primary); }
.stk-kpi-accent-success::after { background: var(--color-success); }
.stk-kpi-accent-warning::after { background: var(--color-warning); }
.stk-kpi-accent-danger::after  { background: var(--color-danger); }
.stk-kpi-val {
  display: block; font-size: 1.5rem; font-weight: 900; color: var(--color-text);
  letter-spacing: -0.5px; margin-bottom: 4px;
}
.stk-kpi-accent-danger  .stk-kpi-val { color: var(--color-danger); }
.stk-kpi-accent-warning .stk-kpi-val { color: var(--color-warning); }
.stk-kpi-accent-success .stk-kpi-val { color: var(--color-success); }
.stk-kpi-lbl {
  display: block; font-size: 0.67rem; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--color-text-muted); font-weight: 700;
}

/* ===== CLIENT DETAIL ===== */
.client-kpi-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 14px; }
.client-info-card { margin-bottom: 16px; }
.client-info-body { padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.client-info-row { display: flex; justify-content: space-between; gap: 12px; font-size: 0.85rem; }
.client-info-label { color: var(--color-text-muted); font-weight: 600; }

/* Table card */
.stk-table-card {
  background: white; border-radius: var(--radius-lg); border: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm); overflow: hidden; margin-bottom: 14px;
}
.stk-table-toolbar {
  padding: 12px 18px; border-bottom: 1px solid var(--color-border);
  display: flex; align-items: center; justify-content: space-between;
  background: #fafbfc;
}
.stk-table-title { font-weight: 700; font-size: 0.9rem; color: var(--color-text); }
.stk-table-hint  { font-size: 0.78rem; color: var(--color-text-muted); }

/* Status dot column */
.stk-status-col  { width: 32px; padding-right: 0 !important; }
.stk-status-cell { text-align: center; padding-right: 0 !important; }
.stk-row-dot {
  display: inline-block; width: 10px; height: 10px; border-radius: 50%;
  border: 2px solid #cbd5e1; background: transparent;
  transition: background 200ms, border-color 200ms;
}
.stk-row-dot-counted { background: var(--color-success); border-color: var(--color-success); }

/* Count input */
.stk-count-input { width: 80px !important; text-align: right; }

/* Variance badges */
.stk-variance {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 0.8rem; font-weight: 700; padding: 3px 9px; border-radius: 12px;
}
.stk-variance-neg  { color: var(--color-danger);  background: var(--color-danger-light); }
.stk-variance-pos  { color: var(--color-success); background: #dcfce7; }
.stk-variance-zero { color: var(--color-text-muted); }

/* Action footer */
.stk-action-footer {
  background: white; border-radius: var(--radius-lg); border: 1px solid var(--color-border);
  padding: 16px 20px; display: flex; align-items: center;
  justify-content: space-between; gap: 16px; flex-wrap: wrap;
  box-shadow: var(--shadow-sm); margin-bottom: 8px;
}
.stk-footer-completed { justify-content: center; }
.stk-footer-info { display: flex; flex-direction: column; gap: 2px; }
.stk-footer-info > span:first-child { font-weight: 700; font-size: 0.9rem; }
.stk-footer-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* Legacy (session-footer kept for safety) */
.session-footer { padding: 14px 0; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

/* Progress bar legacy */
.progress-track { height: 8px; background: #e2e8f0; border-radius: 4px; overflow: hidden; }
.progress-fill  { height:100%; background:linear-gradient(90deg,var(--color-primary),var(--color-success)); border-radius:4px; transition:width 400ms ease; }
.progress-label { font-size:0.78rem; color:var(--color-text-muted); margin-top:5px; font-weight:500; }

/* ===== VALUATION ===== */
.valuation-hero {
  display: grid; grid-template-columns: repeat(3, 1fr) auto; gap: 14px; margin-bottom: 20px;
}
.val-stat-card {
  background: var(--color-card); border-radius: var(--radius-lg); border: 1px solid var(--color-border);
  padding: 18px 18px 16px; box-shadow: var(--shadow-sm); position: relative; overflow: hidden;
  transition: box-shadow var(--transition);
}
.val-stat-card:hover { box-shadow: var(--shadow-md); }
.val-stat-card::after {
  content: '';
  position: absolute; top: 0; right: 0;
  width: 60px; height: 60px;
  border-radius: 0 0 0 60px;
  opacity: 0.06;
}
.val-stat-card.val-cost::after  { background: var(--color-warning); }
.val-stat-card.val-rev::after   { background: var(--color-primary); }
.val-stat-card.val-profit::after{ background: var(--color-success); }

.val-label { font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.06em; font-weight: 700; color: var(--color-text-muted); margin-bottom: 7px; }
.val-value { font-size: 1.6rem; font-weight: 900; letter-spacing: -0.6px; }
.val-sub   { font-size: 0.77rem; color: var(--color-text-muted); margin-top: 5px; }
.val-green { color: var(--color-success); }
.val-blue  { color: var(--color-primary); }
.val-orange{ color: var(--color-warning); }

/* ===== PRODUCT IMAGE UPLOAD WIDGET ===== */
.form-optional {
  font-weight: 400; font-size: 0.8rem; color: var(--color-text-muted);
}

.product-img-upload {
  position: relative; border: 2px dashed var(--color-border);
  border-radius: var(--radius-md); cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
  overflow: hidden; min-height: 100px;
  display: flex; align-items: center; justify-content: center;
}
.product-img-upload:hover,
.product-img-upload.img-drag-over {
  border-color: var(--color-primary); background: rgba(59, 130, 246, 0.04);
}

.product-img-placeholder {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 18px; text-align: center; pointer-events: none;
}
.img-upload-icon { font-size: 1.6rem; line-height: 1; }
.img-upload-text { font-size: 0.84rem; font-weight: 600; color: var(--color-text-secondary); }
.img-upload-hint { font-size: 0.73rem; color: var(--color-text-muted); }

.product-img-preview {
  display: block; max-width: 100%; max-height: 200px; border-radius: var(--radius-sm);
  object-fit: contain; padding: 8px;
}

.product-img-remove {
  position: absolute; top: 6px; right: 6px;
  background: rgba(0,0,0,0.55); color: white;
  border: none; border-radius: var(--radius-sm);
  font-size: 0.75rem; font-weight: 700; padding: 3px 8px; cursor: pointer;
  transition: background var(--transition);
}
.product-img-remove:hover { background: rgba(0,0,0,0.75); }

/* ===== PRODUCT THUMBNAIL IN TABLE ===== */
.product-cell-thumb {
  flex-direction: row !important;
  align-items: center !important;
  gap: 10px;
}
.product-cell-info { display: flex; flex-direction: column; gap: 3px; }
.product-thumb {
  width: 36px; height: 36px; border-radius: var(--radius-sm);
  object-fit: cover; flex-shrink: 0;
  border: 1px solid var(--color-border);
}
.product-thumb-empty {
  width: 36px; height: 36px; border-radius: var(--radius-sm);
  background: var(--color-bg-subtle); flex-shrink: 0;
  border: 1px solid var(--color-border);
}

/* ===== MARGIN PREVIEW ===== */
#margin-preview {
  font-size: 0.8rem;
  padding: 6px 10px;
  background: var(--color-bg-subtle);
  border: 1px dashed var(--color-border-dark);
  border-radius: var(--radius-sm);
  margin-top: 4px;
  color: var(--color-text-secondary);
}

/* ===== VIEW TOGGLE ===== */
.view-toggle {
  display: flex; gap: 2px;
  background: var(--color-bg-subtle);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 3px; flex-shrink: 0;
}
.view-toggle-btn {
  width: 30px; height: 28px;
  border: none; background: transparent;
  border-radius: 5px; cursor: pointer;
  color: var(--color-text-muted);
  display: flex; align-items: center; justify-content: center;
  transition: background var(--transition), color var(--transition);
}
.view-toggle-btn:hover { background: white; color: var(--color-text); }
.view-toggle-btn.active { background: white; color: var(--color-primary); box-shadow: var(--shadow-xs); }

/* ===== INVENTORY GRID ===== */
.inv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px; padding: 16px;
}
.inv-grid-empty {
  grid-column: 1 / -1; text-align: center;
  padding: 56px 24px; color: var(--color-text-muted); font-size: 0.875rem;
}

.inv-card {
  background: white; border-radius: var(--radius-lg);
  border: 1px solid var(--color-border); box-shadow: var(--shadow-xs);
  display: flex; flex-direction: column; overflow: hidden;
  transition: box-shadow var(--transition), transform var(--transition);
}
.inv-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }

.inv-card-img {
  height: 150px; background: var(--color-bg-subtle);
  display: flex; align-items: center; justify-content: center;
  border-bottom: 1px solid var(--color-border); overflow: hidden;
}
.inv-card-photo { width: 100%; height: 100%; object-fit: cover; }
.inv-card-no-img { font-size: 2.6rem; opacity: 0.25; }

.inv-card-body {
  flex: 1; padding: 12px 14px;
  display: flex; flex-direction: column; gap: 9px;
}
.inv-card-top {
  display: flex; align-items: flex-start;
  justify-content: space-between; gap: 6px;
}
.inv-card-name {
  font-weight: 700; font-size: 0.88rem; color: var(--color-text);
  line-height: 1.3; flex: 1;
}
.inv-card-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

.inv-card-prices {
  display: flex; gap: 12px; padding: 8px 0;
  border-top: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
}
.inv-price-col { display: flex; flex-direction: column; gap: 1px; }
.inv-price-label {
  font-size: 0.64rem; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--color-text-muted); font-weight: 700;
}
.inv-price-val { font-size: 0.85rem; font-weight: 700; color: var(--color-text); }

.inv-card-stock-row {
  display: flex; align-items: baseline; gap: 6px;
}
.inv-stock-num {
  font-size: 1.35rem; font-weight: 900; color: var(--color-text); letter-spacing: -0.5px;
}
.inv-stock-sub { font-size: 0.71rem; color: var(--color-text-muted); }

.inv-card-footer {
  padding: 10px 12px; border-top: 1px solid var(--color-border);
  display: flex; align-items: center; gap: 6px; background: #fafbfc;
}
.inv-card-action { flex: 1; justify-content: center; font-size: 0.78rem !important; padding: 4px 6px !important; }

@media (max-width: 1024px) {
  .reorder-summary-bar { grid-template-columns: 1fr 1fr; }
  .valuation-hero { grid-template-columns: 1fr 1fr; }
  .inv-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
  .stk-kpi-row { grid-template-columns: repeat(3, 1fr); }
  .client-kpi-row { grid-template-columns: repeat(2, 1fr); }
  /* Touch devices (tablets included) have no :hover state */
  .view-toggle-btn { width: 40px; height: 40px; }
}
@media (max-width: 768px) {
  .view-toggle-btn { width: 48px; height: 48px; }
  .input-inline, .stk-count-input { min-height: 48px; }
}
@media (max-width: 600px) {
  .reorder-summary-bar { grid-template-columns: 1fr 1fr; }
  .stocktake-card-stats { flex-wrap: wrap; }
  .stk-stat { min-width: 30%; }
  .stk-kpi-row { grid-template-columns: repeat(2, 1fr); }
  .client-kpi-row { grid-template-columns: 1fr 1fr; }
  .stk-action-footer { flex-direction: column; align-items: flex-start; }
  .stk-footer-actions { width: 100%; }
  .stk-footer-actions .btn { flex: 1; }
  .inv-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; padding: 10px; }
}
@media (max-width: 480px) {
  .reorder-summary-bar { grid-template-columns: 1fr; }
  .valuation-hero { grid-template-columns: 1fr; }
  .client-kpi-row { grid-template-columns: 1fr; }
  .inv-grid { grid-template-columns: 1fr; }
}
