:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #1c2430;
  --muted: #5b6675;
  --line: #dfe3e8;
  --accent: #245a8d;
  --accent-weak: #e8f0f7;
  --ok: #1a7f52;
  --warn: #9a6a00;
  --err: #b3261e;
  --chip: #eef1f4;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
}
/* Flex/grid children must be allowed to shrink below their content width so long
   paths/names wrap or scroll inside their own region instead of forcing the whole
   document to overflow horizontally. */
.layout, .card-grid, .browse-tiles, .searchbar, .ds-actions, .ds-meta { min-width: 0; }
.layout > *, .ds-card, .tile, main > * { min-width: 0; }
.identity { min-width: 0; }
.identity select { max-width: 100%; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
header.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 10px 18px; background: var(--panel); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
}
.topbar .brand { font-weight: 700; letter-spacing: .2px; }
.topbar .brand small { color: var(--muted); font-weight: 400; margin-left: 6px; }
.topbar nav { display: flex; gap: 14px; }
.topbar .spacer { flex: 1; }
.identity { display: flex; align-items: center; gap: 6px; }
.identity select { padding: 4px 6px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.role-pill { font-size: 11px; padding: 2px 7px; border-radius: 10px; background: var(--accent-weak); color: var(--accent); }
main { max-width: 1200px; margin: 18px auto; padding: 0 18px; }
.layout { display: grid; grid-template-columns: 240px 1fr; gap: 18px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px; margin-bottom: 16px; }
.panel h2 { margin: 0 0 10px; font-size: 15px; }
.panel h3 { margin: 16px 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); }
.searchbar { display: flex; gap: 8px; }
.searchbar input[type=search] {
  flex: 1; padding: 9px 12px; font-size: 15px; border: 1px solid var(--line); border-radius: 8px;
}
.btn { padding: 8px 12px; border: 1px solid var(--line); background: #fff; border-radius: 8px; cursor: pointer; font-size: 13px; }
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.small { padding: 4px 8px; font-size: 12px; }
label.filter { display: block; margin-bottom: 10px; font-size: 12px; color: var(--muted); }
label.filter select { width: 100%; margin-top: 3px; padding: 6px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
table.grid { width: 100%; border-collapse: collapse; }
table.grid th, table.grid td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.grid th { font-size: 11px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); }
table.grid tbody tr:hover { background: #fafbfc; }
.result-name { font-weight: 600; }
.result-path { font-family: var(--mono); font-size: 12px; color: var(--muted); word-break: break-all; }
.chip { display: inline-block; font-size: 11px; padding: 2px 7px; border-radius: 10px; background: var(--chip); color: var(--muted); margin-right: 4px; }
.chip.type { background: var(--accent-weak); color: var(--accent); }
.q-OK { color: var(--ok); } .q-WARNING { color: var(--warn); } .q-ERROR { color: var(--err); }
.dot { display:inline-block; width:8px;height:8px;border-radius:50%; margin-right:5px; }
.dot.OK{background:var(--ok);} .dot.WARNING{background:var(--warn);} .dot.ERROR{background:var(--err);}
.notice { padding: 9px 12px; border-radius: 8px; margin-bottom: 14px; font-size: 13px; }
.notice.warn { background: #fff6e6; border: 1px solid #f1d79a; color: #7a5600; }
.notice.info { background: var(--accent-weak); border: 1px solid #bcd4e8; color: var(--accent); }
.notice.ok { background: #e7f5ee; border: 1px solid #a9dcc2; color: var(--ok); }
.kv { display: grid; grid-template-columns: 160px minmax(0, 1fr); gap: 4px 12px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.prov { font-size: 11px; padding: 1px 6px; border-radius: 4px; border: 1px solid var(--line); }
.prov.PARTNER_PROVIDED { background:#eef7ff; }
.prov.PIPELINE_EXTRACTED { background:#eef1f4; }
.prov.HUMAN_CURATED { background:#eefbf3; }
.prov.LLM_GENERATED { background:#fdf1e7; }
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.thumb { border: 1px solid var(--line); border-radius: 6px; padding: 6px; background:#fff; text-align:center; }
.thumb img { max-width: 100%; height: auto; image-rendering: auto; }
.thumb .cap { font-size: 11px; color: var(--muted); margin-top: 4px; word-break: break-all; }
.mono { font-family: var(--mono); font-size: 12px; overflow-wrap: anywhere; }
.small { font-size: 12px; color: var(--muted); }
.grid-scroll { overflow-x: auto; }
.stage-badge { font-size:11px; padding:1px 6px; border-radius:4px; background:var(--chip); margin:1px; display:inline-block;}
.breadcrumb { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
/* --- marketplace --- */
.market-hero h1 { margin: 0 0 4px; font-size: 22px; }
.market-hero .sub { margin: 0 0 14px; color: var(--muted); }
.assist-toggle { display: flex; align-items: center; gap: 5px; font-size: 13px; color: var(--accent);
  border: 1px solid var(--line); border-radius: 8px; padding: 0 10px; white-space: nowrap; }
.browse-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; margin-top: 14px; }
.tile { display: flex; flex-direction: column; gap: 2px; border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 12px; background: #fff; position: relative; }
.tile:hover { border-color: var(--accent); text-decoration: none; }
.tile.active { border-color: var(--accent); background: var(--accent-weak); }
.tile-label { font-weight: 600; color: var(--ink); }
.tile-count { position: absolute; top: 8px; right: 10px; font-size: 12px; color: var(--muted); }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.ds-card { border: 1px solid var(--line); border-radius: 10px; background: var(--panel); padding: 14px 16px;
  display: flex; flex-direction: column; gap: 8px; }
.ds-card-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.ds-name { font-size: 15px; font-weight: 700; }
.ds-partner { color: var(--muted); }
.ds-summary { margin: 0; font-size: 13px; }
.match-reason { color: var(--accent); }
.ds-summary-lg { font-size: 14px; margin: 12px 0; max-width: 70ch; }
.ds-uses { background: var(--accent-weak); border-radius: 8px; padding: 8px 10px; }
.ds-uses .uses-label { text-transform: uppercase; letter-spacing: .4px; color: var(--accent); }
.ds-uses ul { margin: 4px 0 0; padding-left: 18px; font-size: 13px; }
.ds-meta { display: flex; flex-wrap: wrap; gap: 4px; }
.ds-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 2px; }
.ds-detail-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.ds-detail-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.chip.patient { background: #fdeaea; color: #a33; }
.chip.access-ok { background: #e7f5ee; color: var(--ok); }
.chip.ai { background: #fdf1e7; color: #9a5b00; }
.ai-interp .chip { margin-left: 4px; }
.results-head { margin-bottom: 12px; }

footer { max-width: 1200px; margin: 20px auto; padding: 0 18px; color: var(--muted); font-size: 12px; }
@media (max-width: 820px) {
  .layout { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; }
  .topbar { flex-wrap: wrap; row-gap: 8px; }
  .card-grid { grid-template-columns: 1fr; }
  .searchbar { flex-wrap: wrap; }
  .searchbar input[type=search] { flex: 1 1 100%; }
  .market-hero h1 { font-size: 19px; }
  .ds-detail-head { flex-direction: column; }
  .identity { flex-wrap: wrap; justify-content: flex-end; }
  .brand small { display: none; }
}
/* No global overflow-x:hidden — overflow is fixed at the source (min-width:0 on
   flex/grid children, wrapping on long paths, and scroll containers on tables). */
