/* ---------------------------------------------------------------------------
   Outsource China — intelligence components

   The shared building blocks of the trade-intelligence pages: numbered
   section frames, hairline data grids, tags, certification chips, compliance
   matrices, KPI strips, feasibility tiles, feeds and stage gates.

   Every number or status drawn with these comes from a query or a stated
   rule. None of them may show a price, MOQ, lead time or carton figure.
   Loaded per page through the controller's $styles.
--------------------------------------------------------------------------- */

/* --- Page head ------------------------------------------------------------- */

.ipage-head { padding: var(--s-6) 0 var(--s-5); }
.ipage-head__eyebrow { margin: 0 0 var(--s-2); }
.ipage-head h1 { margin: 0; max-width: 24ch; }
.ipage-head__lede { max-width: 70ch; margin: var(--s-3) 0 0; color: var(--text-muted); font-size: 15px; }

/* --- Section frame — .ifr -------------------------------------------------- */

.ifr { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); scroll-margin-top: var(--sticky-top); }
.ifr + .ifr { margin-top: var(--s-4); }
.ifr__head { display: flex; align-items: baseline; flex-wrap: wrap; gap: var(--s-2) var(--s-3); padding: var(--s-3) var(--s-4); border-bottom: 1px solid var(--border); }
.ifr__idx { color: var(--signal); }
.ifr__title { margin: 0; font-size: 15px; }
.ifr__aside { margin: 0 0 0 auto; font-size: 12px; color: var(--text-muted); }
.ifr__body { padding: var(--s-4); }
.ifr__body > :last-child { margin-bottom: 0; }
.ifr__body--flush { padding: 0; }

/* --- Data grid — .dgrid ---------------------------------------------------- */

.dgrid { width: 100%; border-collapse: collapse; font-size: 13px; }
.dgrid th, .dgrid td { padding: 9px var(--s-4); border-bottom: 1px solid var(--grid-line); text-align: left; vertical-align: baseline; }
.dgrid tbody tr:last-child > * { border-bottom: 0; }
.dgrid thead th {
  font: 600 var(--fs-xs)/1.2 var(--mono); text-transform: uppercase; letter-spacing: var(--track-label);
  color: var(--text-subtle); background: var(--surface-sunken); border-bottom-color: var(--grid-line-strong);
}
.dgrid tbody th { width: 34%; font-weight: 600; }
.dgrid__label { display: block; }
.dgrid__key { display: block; margin-top: 2px; padding: 0; background: none; font: 500 var(--fs-xs)/1.2 var(--mono); color: var(--text-subtle); }
.dgrid__unit { width: 64px; font-family: var(--mono); color: var(--text-muted); }
.dgrid tbody tr:hover > * { background: var(--surface-hover); }

/* --- Tags — .tag ------------------------------------------------------------
   Square, mono, small. Not .chip (defined twice in app.css) and not .badge
   (admin status semantics). */

.tags { display: flex; flex-wrap: wrap; gap: 4px; margin: 0; padding: 0; list-style: none; }
.tag {
  display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font: 600 var(--fs-xs)/1 var(--mono); letter-spacing: .03em; color: var(--text-muted); white-space: nowrap;
}
.tag--signal { color: var(--signal);  border-color: color-mix(in srgb, var(--signal) 35%, transparent);  background: var(--signal-subtle); }
.tag--on     { color: var(--success); border-color: color-mix(in srgb, var(--success) 35%, transparent); background: var(--success-subtle); }
.tag--off    { color: var(--text-subtle); border-style: dashed; }
.tag--warn   { color: var(--warning); border-color: color-mix(in srgb, var(--warning) 35%, transparent); background: var(--warning-subtle); }

/* --- Certification chip — .cert ---------------------------------------------
   Code plus evidence level. Only "declared" ships until the business keeps
   certificates on file for an order. */

.certs { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; list-style: none; }
.cert {
  display: inline-flex; align-items: stretch; height: 26px; overflow: hidden;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); font-size: var(--fs-xs);
}
.cert__code { display: grid; place-items: center; padding: 0 8px; font: 700 12px/1 var(--mono); background: var(--surface-sunken); }
.cert__state { display: grid; place-items: center; padding: 0 8px; font-weight: 600; }
.cert--declared { border-color: color-mix(in srgb, var(--cx-declared) 40%, transparent); }
.cert--declared .cert__state { color: var(--cx-declared); background: var(--cx-declared-subtle); }
.cert--verified { border-color: color-mix(in srgb, var(--cx-verified) 40%, transparent); }
.cert--verified .cert__state { color: var(--cx-verified); background: var(--cx-verified-subtle); }
.cert--required { border-color: color-mix(in srgb, var(--cx-required) 40%, transparent); }
.cert--required .cert__state { color: var(--cx-required); background: var(--cx-required-subtle); }

/* --- Compliance matrix — .cmatrix -------------------------------------------
   Frameworks down, markets across; every cell says its state in words. */

.cmatrix { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.cmatrix th, .cmatrix td { padding: 7px 8px; border-bottom: 1px solid var(--grid-line); text-align: center; }
.cmatrix thead th { font: 600 var(--fs-xs)/1 var(--mono); color: var(--text-subtle); letter-spacing: var(--track-label); }
.cmatrix tbody th { text-align: left; font: 700 12px/1.2 var(--mono); }
.cmx span { display: inline-block; min-width: 64px; padding: 3px 6px; border-radius: var(--radius-sm); font-size: 11px; font-weight: 600; }
.cmx--required span { color: var(--cx-required); background: var(--cx-required-subtle); }
.cmx--common span   { color: var(--cx-common);   background: var(--cx-common-subtle); }
.cmx--na span       { color: var(--cx-na); }
.cmatrix__key { margin: var(--s-3) 0 0; font-size: 11.5px; color: var(--text-muted); }

/* --- KPI strip — .kpi ------------------------------------------------------ */

.kpi { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); margin: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); }
.kpi__cell { padding: var(--s-3) var(--s-4); }
.kpi__cell + .kpi__cell { border-left: 1px solid var(--grid-line-strong); }
.kpi dd { margin: var(--s-1) 0 0; font-size: 24px; font-weight: 700; letter-spacing: -.02em; }
.kpi dd small { font-size: 13px; font-weight: 500; color: var(--text-subtle); }
.kpi--plate { background: transparent; border-color: var(--plate-line); }
.kpi--plate .kpi__cell + .kpi__cell { border-left-color: var(--plate-line); }
.kpi--plate dt { color: var(--plate-text-muted); }
.kpi--plate dd { color: var(--plate-text); }

/* --- Feasibility tile — .tile ---------------------------------------------- */

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: var(--s-2); }
.tile { padding: var(--s-3); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.tile__name { margin: 0; font-size: 12.5px; font-weight: 600; }
.tile__val { margin: var(--s-1) 0 var(--s-2); font-size: 18px; font-weight: 700; }
.tile__val small { font-size: 11px; font-weight: 500; color: var(--text-subtle); }
.tile__bar { height: 4px; border-radius: 2px; background: var(--grid-line-strong); overflow: hidden; }
.tile__bar i { display: block; height: 100%; width: calc(var(--v, 0) * 100%); background: var(--signal); }

/* --- Feed — .feed ---------------------------------------------------------- */

.feed { margin: 0; padding: 0; list-style: none; }
.feed__item { display: grid; grid-template-columns: 52px minmax(0, 1fr) auto; gap: var(--s-2); align-items: baseline; padding: 8px 0; border-bottom: 1px solid var(--grid-line); font-size: 12.5px; }
.feed__item:last-child { border-bottom: 0; }
.feed__when { font-size: 11px; color: var(--text-subtle); }
.feed__what { color: var(--text); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* --- Stage gates — .gates / .gate ------------------------------------------ */

.gates { display: grid; margin: 0; padding: 0; list-style: none; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); }
.gate { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: var(--s-3); align-items: start; padding: var(--s-3) var(--s-4); }
.gate + .gate { border-top: 1px solid var(--grid-line); }
.gate__id { display: grid; place-items: center; width: 36px; height: 24px; border: 1px solid var(--signal); border-radius: var(--radius-sm); color: var(--signal); font-size: 12px; font-weight: 700; }
.gate__name { display: block; }
.gate__check { margin: 2px 0 0; font-size: 12.5px; color: var(--text-muted); }
.gate__owner { white-space: nowrap; }
.gate--quote .gate__id { border-color: var(--brand); background: var(--brand); color: var(--brand-contrast); }

/* --- Compliance page ------------------------------------------------------- */

.cxp { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: var(--s-5); align-items: start; padding-bottom: var(--s-7); }
.cxp__toc { position: sticky; top: var(--sticky-top); }
.cxp__toc ol { display: grid; gap: 2px; margin: var(--s-2) 0 0; padding: 0; list-style: none; }
.cxp__toc a { display: grid; grid-template-columns: 56px 1fr; gap: var(--s-2); padding: 6px 10px; border-radius: var(--radius-sm); font-size: 13px; color: var(--text); }
.cxp__toc a:hover { background: var(--surface-hover); text-decoration: none; }
.cxp__toc .num { color: var(--signal); font-weight: 700; }
.cxp__note { margin: 0 0 var(--s-4); padding: var(--s-3) var(--s-4); border-left: 3px solid var(--info); background: var(--info-subtle); border-radius: var(--radius-sm); font-size: 13px; }
.cxp__facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-4); margin: var(--s-3) 0 0; }
.cxp__facts dt { margin-bottom: var(--s-1); }
.cxp__facts dd { margin: 0; font-size: 13px; }
.cxp__facts ul { margin: 0; padding-left: 18px; }
.cxp__close { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s-4); margin-top: var(--s-5); padding: var(--s-5); background: var(--plate-1); color: var(--plate-text); border-radius: var(--radius-lg); }
.cxp__close h2 { margin: 0 0 var(--s-1); color: var(--plate-text); }
.cxp__close p { margin: 0; color: var(--plate-text-muted); }

@media (max-width: 900px) {
  .cxp { grid-template-columns: 1fr; }
  .cxp__toc { position: static; }
  .cxp__toc ol { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .cxp__facts { grid-template-columns: 1fr; }
}
