/*
 * Overview grid — matches the approved command-center mock-up.
 *
 * Three proportional rows inside one viewport: headline metrics, a wide chart
 * beside the acquisition mix, then the attention queue beside source health.
 * Panels that can overflow scroll internally so the page itself never does.
 */

.overview-body {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1.25fr) minmax(0, 1fr);
  gap: 10px;
}

/* --- headline metrics ---------------------------------------------------- */

.metrics-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.metric-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 104px;
  align-items: center;
  gap: 8px;
  min-height: 96px;
  padding: 12px 14px;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  background: var(--surface);
  overflow: hidden;
}

.metric-main { min-width: 0; display: flex; flex-direction: column; gap: 4px; }

.metric-label {
  font-size: 9.5px; font-weight: 680; letter-spacing: .05em;
  text-transform: uppercase; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.metric-value {
  font-size: 26px; font-weight: 640; line-height: 1.05;
  letter-spacing: -.025em; font-variant-numeric: tabular-nums;
}

.metric-delta-row { display: flex; align-items: baseline; gap: 6px; min-height: 14px; }
.metric-vs { font-size: 9px; color: var(--faint); }
.metric-reason { font-size: 9.5px; color: var(--faint); }

.metric-unavailable { border-style: dashed; opacity: .62; }
.metric-unavailable .metric-value { color: var(--faint); }

.metric-spark { height: 40px; display: flex; align-items: center; }
.sparkline { width: 100%; height: 40px; display: block; }

/* --- primary and lower rows ---------------------------------------------- */

.primary-row,
.lower-row {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-columns: 1.55fr minmax(0, 1fr);
  gap: 10px;
}
.lower-row { grid-template-columns: 1.2fr minmax(0, 1fr); }

.chart-panel { overflow: hidden; }
.chart-fill { flex: 1 1 auto; min-height: 130px; display: block; }
.area-chart { width: 100%; height: 100%; display: block; }

.axis-label { fill: var(--faint); font-size: 9px; font-family: inherit; }

/* --- acquisition mix ----------------------------------------------------- */

.source-mix { display: flex; flex-direction: column; gap: 5px; }

.mix-row {
  display: grid;
  grid-template-columns: minmax(58px, 1fr) minmax(40px, 1.4fr) auto 44px;
  align-items: center;
  gap: 8px;
  padding: 4px 5px;
  margin: 0 -5px;
  border-radius: 6px;
  font-size: 11px;
  cursor: pointer;
  transition: background .12s var(--ease);
}
.mix-row:hover { background: rgba(217, 175, 87, .08); }
.mix-row:hover .mix-label { color: var(--gold-bright); }

.mix-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mix-track { height: 6px; border-radius: 999px; background: rgba(255, 255, 255, .05); overflow: hidden; }
.mix-fill {
  display: block; height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, var(--gold-deep), var(--gold-bright));
}
.mix-value { font-weight: 640; font-variant-numeric: tabular-nums; }
.mix-share { text-align: right; color: var(--faint); font-variant-numeric: tabular-nums; }

/* --- product card view --------------------------------------------------- */

.view-toggle {
  display: flex; gap: 2px; padding: 2px;
  border: 1px solid var(--line-soft); border-radius: 8px;
}
.view-btn {
  width: 28px; height: 24px;
  display: grid; place-items: center;
  border: 0; border-radius: 6px;
  background: transparent; color: var(--muted);
  cursor: pointer;
}
.view-btn svg { width: 14px; height: 14px; }
.view-btn:hover { color: var(--text); }
.view-btn.active { background: rgba(217, 175, 87, .14); color: var(--gold-bright); }

.card-grid {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(176px, 1fr));
  grid-auto-rows: min-content;
  gap: 12px;
  overflow: hidden;
  align-content: start;
}

.product-card {
  display: flex; flex-direction: column;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  background: var(--surface);
  overflow: hidden;
  cursor: pointer;
  transition: transform .13s var(--ease), border-color .13s var(--ease), box-shadow .13s var(--ease);
}
.product-card:hover {
  transform: translateY(-3px);
  border-color: var(--gold-deep);
  box-shadow: 0 10px 26px rgba(0, 0, 0, .5);
}
.product-card:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

.card-media {
  position: relative;
  aspect-ratio: 1 / 1;
  background: var(--surface-2);
  display: grid; place-items: center;
  overflow: hidden;
}
.card-media img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card-noimage { font-size: 10px; color: var(--faint); }

.card-stock {
  position: absolute; top: 7px; left: 7px;
  font-size: 8.5px; padding: 2px 7px;
}

.card-body { padding: 9px 11px 11px; display: flex; flex-direction: column; gap: 3px; }
.card-name {
  font-size: 11.5px; font-weight: 640; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-sku { font-size: 9.5px; color: var(--faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-foot {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 8px; margin-top: 4px;
}
.card-price { font-size: 13px; font-weight: 660; font-variant-numeric: tabular-nums; }
.card-sold { font-size: 9.5px; color: var(--faint); }

/* --- settings ------------------------------------------------------------ */

.role-chip {
  padding: 2px 9px; border-radius: 999px;
  font-size: 9.5px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
}
.role-owner, .role-admin { background: rgba(217, 175, 87, .16); color: var(--gold-bright); }
.role-operator { background: rgba(88, 207, 145, .14); color: var(--green); }
.role-viewer { background: rgba(255, 255, 255, .06); color: var(--muted); }

.users-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 12px; flex-wrap: wrap; font-size: 12px;
}

.new-user {
  padding: 14px;
  margin-bottom: 12px;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  background: var(--surface-2);
}
.new-user[hidden] { display: none; }

.role-legend {
  margin-top: 12px; padding-top: 10px;
  border-top: 1px solid var(--line-soft);
  display: flex; flex-direction: column; gap: 4px;
  font-size: 10px; color: var(--faint); line-height: 1.5;
}
.role-legend strong { color: var(--muted); }

.user-actions { display: flex; flex-wrap: wrap; gap: 4px; }
.user-actions .ghost-btn { padding: 4px 8px; font-size: 10px; }
.danger-text { color: #ff97a5 !important; }
.danger-text:hover { border-color: var(--red) !important; }

.np-hint { font-size: 9.5px; color: var(--faint); }

.audit-action {
  padding: 2px 7px; border-radius: 999px;
  font-size: 9.5px; font-weight: 650;
  background: rgba(255, 255, 255, .05); color: var(--muted);
}
.audit-failure { background: rgba(255, 102, 120, .14); color: #ff97a5; }

.findings { display: flex; flex-direction: column; gap: 8px; max-width: 760px; }
.finding {
  display: flex; flex-direction: column; gap: 3px;
  padding: 10px 12px; border-radius: 8px;
  border-left: 2px solid var(--line);
  background: rgba(255, 255, 255, .02);
  font-size: 11px; line-height: 1.5;
}
.finding strong { font-size: 11.5px; }
.finding span { color: var(--muted); }
.finding-warn { border-left-color: var(--amber); background: rgba(240, 169, 66, .05); }
.finding-info { border-left-color: var(--gold-deep); background: rgba(217, 175, 87, .04); }
.finding-ok { border-left-color: var(--green); background: rgba(88, 207, 145, .05); }

/* --- responsive ---------------------------------------------------------- */

@media (max-width: 1080px) {
  .metrics-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 1000px) {
  .primary-row, .lower-row { grid-template-columns: minmax(0, 1fr); }
  .overview-body { grid-template-rows: auto auto auto; overflow-y: auto; }
}

/* --- table alignment ------------------------------------------------------
 * A header and its values must share an alignment, or the eye cannot track a
 * column. Numeric columns are right-aligned on both th and td so the digits
 * line up; status and action columns are centred; text stays left.
 */
.sync-table th,
.sync-table td { text-align: left; }

.sync-table th.num,
.sync-table td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.sync-table th.mid,
.sync-table td.mid { text-align: center; }

/* A cell carrying a status pill centres the pill with its header. */
.sync-table td.mid .status { display: inline-block; }

/* --- source health rows ---------------------------------------------------
 * The message column must clip, not overflow: connector errors name several
 * missing secrets and were spilling over the rows beneath them.
 */
.lower-row .source-row {
  display: grid;
  grid-template-columns: minmax(74px, auto) auto minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  min-width: 0;
}
.lower-row .source-line {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lower-row .source-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
