:root {
  --pronto-blue: #2ea3f2;
  --pronto-blue-d: #1f8ad6;
  --ink: #1f2733;
  --muted: #6b7684;
  --bg: #eef1f4;
  --line: #e2e7ec;
  --ok: #1a9e5c;
  --bad: #d64545;
  --pending: #b08d2f;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 14px/1.5 var(--pp-font, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif);
  color: var(--pp-ink, var(--ink)); background: var(--pp-bg, var(--bg));
}

.btn { border: 1px solid var(--line); background: #fff; color: var(--ink); padding: 8px 14px; border-radius: 4px; font-weight: 600; cursor: pointer; font-size: 13px; }
.btn:hover { border-color: #cfd6dd; }
.btn.primary { background: var(--pronto-blue); border-color: var(--pronto-blue); color: #fff; }
.btn.primary:hover { background: var(--pronto-blue-d); }
.btn-clear { width: 100%; margin-top: 4px; color: var(--muted); }

/* ================= Layout: facet sidebar + results ================= */
.layout {
  display: flex; gap: 18px; align-items: flex-start;
  margin: 16px var(--pp-gutter, 40px) 28px;
}

.facets {
  flex: 0 0 272px; min-width: 0; position: sticky; top: calc(var(--pp-nav-h, 56px) + 10px);
  max-height: calc(100vh - var(--pp-nav-h, 56px) - 24px);
  overflow-y: auto; overflow-x: hidden;          /* never scroll sideways */
  background: #fff; border: 1px solid var(--line); border-radius: 4px;
  box-shadow: 0 1px 3px rgba(16,24,40,.06); padding: 14px;
}
.facets * { min-width: 0; }                       /* stop intrinsic widths forcing overflow */
.facet-search { display: flex; gap: 8px; }
.facet-search input { flex: 1; min-width: 0; padding: 8px 10px; border: 1px solid var(--line); border-radius: 4px; font-size: 13px; }
.facet-search input:focus { outline: none; border-color: var(--pronto-blue); box-shadow: 0 0 0 3px rgba(46,163,242,.15); }
.facet-exact { margin: 8px 0 4px; }

.facet { border: 0; padding: 0; margin: 0 0 4px; border-top: 1px solid var(--line); padding-top: 10px; margin-top: 10px; }
.facet legend {
  font-size: 10.5px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: .6px; padding: 0; margin-bottom: 6px;
}
.facet select, .facet input[type=text], .facet input[type=search], .facet input[type=date] {
  width: 100%; padding: 7px 9px; border: 1px solid var(--line); border-radius: 4px;
  font-size: 13px; color: var(--ink); background: #fff;
}
.facet select:focus, .facet input:focus { outline: none; border-color: var(--pronto-blue); box-shadow: 0 0 0 3px rgba(46,163,242,.15); }
.facet .two { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; }
.facet input[type=date] { min-width: 0; width: 100%; padding: 7px 5px; font-size: 11.5px; }
.facet .two label { font-size: 11px; color: var(--muted); font-weight: 600; }
.chk { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--ink); cursor: pointer; }
.chk input { accent-color: var(--pronto-blue); }

/* SAYT (search-as-you-type) menus */
.sayt { position: relative; }
.sayt-menu {
  display: none; position: absolute; left: 0; right: 0; top: 34px; z-index: 72;
  max-height: 240px; overflow: auto; background: #fff; border: 1px solid var(--line);
  border-radius: 4px; box-shadow: 0 6px 20px rgba(0,0,0,.14);
}
.sayt-menu.open { display: block; }
.sayt-item { padding: 7px 11px; font-size: 12.5px; cursor: pointer; }
.sayt-item:hover, .sayt-item.hi { background: #eaf5fd; }
.sayt-empty { padding: 8px 11px; font-size: 12px; color: var(--muted); }

/* Chips */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.chips:empty { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; max-width: 100%;
  background: #eaf5fd; color: var(--pronto-blue-d); border: 1px solid #c9e7fb;
  border-radius: 999px; padding: 3px 8px 3px 10px; font-size: 12px; font-weight: 600;
}
.chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip button { border: 0; background: transparent; color: inherit; font-size: 13px; line-height: 1; cursor: pointer; padding: 0 2px; }
.popular-tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.pop-tag {
  font-size: 11px; font-weight: 600; color: var(--muted); background: #f1f3f5;
  border: 1px solid var(--line); border-radius: 999px; padding: 2px 9px; cursor: pointer;
}
.pop-tag:hover { color: var(--pronto-blue-d); border-color: #c9e7fb; background: #eaf5fd; }

/* Facet count groups (left nav) */
#facetGroups.fload { opacity: .55; transition: opacity .15s; }
.fgroup legend { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; }
.fgroup .fgtotal {
  flex: none; font-size: 11px; font-weight: 700; letter-spacing: 0; text-transform: none;
  color: #fff; background: #2b2b2b; border-radius: 4px; padding: 2px 7px; line-height: 1.3;
}
.fgroup .fitems { display: flex; flex-direction: column; gap: 1px; }
.fitem {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  width: 100%; border: 0; background: transparent; text-align: left; cursor: pointer;
  padding: 4px 6px; border-radius: 4px; font: inherit; font-size: 12.5px; color: var(--ink);
}
.fitem:hover { background: #eaf5fd; color: var(--pronto-blue-d); }
.fitem .fv { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fitem .fc {
  flex: none; font-size: 11px; font-weight: 700; color: var(--muted);
  background: #f1f3f5; border-radius: 999px; padding: 1px 7px;
}
.fitem.on { background: var(--pronto-blue); color: #fff; font-weight: 600; }
.fitem.on:hover { background: var(--pronto-blue-d); color: #fff; }
.fitem.on .fc { background: rgba(255,255,255,.22); color: #fff; }
.fmore {
  border: 0; background: transparent; cursor: pointer; padding: 4px 6px 0;
  font-size: 11px; font-weight: 700; color: var(--pronto-blue-d);
}
.fmore:hover { text-decoration: underline; }

/* "More filters" collapsible section */
.facet-more { border-top: 1px solid var(--line); margin-top: 10px; padding-top: 8px; }
.facet-more > summary {
  cursor: pointer; list-style: none; font-size: 10.5px; font-weight: 700;
  color: var(--muted); text-transform: uppercase; letter-spacing: .6px; padding: 2px 0;
}
.facet-more > summary::before { content: "▸ "; }
.facet-more[open] > summary::before { content: "▾ "; }
.facet-more > summary::-webkit-details-marker { display: none; }

/* ================= Results ================= */
.results { flex: 1; min-width: 0; }
.results-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.chips-active { flex: 1; min-width: 0; margin-top: 0; }
.results-meta { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.results-meta select { padding: 7px 9px; border: 1px solid var(--line); border-radius: 4px; font-size: 12.5px; background: #fff; }
.count { font-size: 12.5px; color: var(--muted); font-weight: 600; white-space: nowrap; }

.asset-grid {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(218px, 1fr));
}
.card {
  background: #fff; border: 1px solid var(--line); border-radius: 4px;
  box-shadow: 0 1px 3px rgba(16,24,40,.06); overflow: hidden;
  display: flex; flex-direction: column; position: relative; cursor: pointer;
}
.card:hover { border-color: #c9d2da; box-shadow: 0 3px 10px rgba(16,24,40,.10); }
.card-thumb {
  position: relative; aspect-ratio: 4 / 3; background: #f1f3f5 url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='38' height='38' viewBox='0 0 24 24' fill='none' stroke='%23c6ccd3' stroke-width='1.4'%3E%3Crect x='3' y='3' width='18' height='18' rx='2'/%3E%3Ccircle cx='8.5' cy='8.5' r='1.5'/%3E%3Cpath d='M21 15l-5-5L5 21'/%3E%3C/svg%3E") center/38px no-repeat;
  overflow: hidden;
}
.card-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card-thumb .ext {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 800; color: #b6bdc6; letter-spacing: 1px; text-transform: uppercase;
}
.card-status {
  position: absolute; top: 8px; left: 8px; font-size: 10px; font-weight: 700;
  letter-spacing: .4px; text-transform: uppercase; color: #fff;
  background: var(--pending); border-radius: 3px; padding: 3px 7px;
}
.card-status.s-approved, .card-status.s-final, .card-status.s-approved-for-release { background: var(--ok); }
.card-actions {
  position: absolute; top: 6px; right: 6px; display: none; gap: 5px;
}
.card:hover .card-actions { display: flex; }
.card-actions a {
  display: flex; align-items: center; justify-content: center; width: 26px; height: 26px;
  background: rgba(255,255,255,.94); border: 1px solid var(--line); border-radius: 4px;
  color: var(--ink); text-decoration: none; font-size: 13px;
}
.card-actions a:hover { border-color: var(--pronto-blue); color: var(--pronto-blue-d); }
.card-body { padding: 9px 11px 11px; }
.card-title {
  font-size: 12.5px; font-weight: 700; line-height: 1.35; word-break: break-word;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card-brand { font-size: 11.5px; color: var(--pronto-blue-d); font-weight: 600; margin-top: 2px; }
.card-meta { font-size: 11px; color: var(--muted); margin-top: 3px; }

.empty { padding: 60px 20px; text-align: center; color: var(--muted); font-size: 14px; }
/* Search-in-flight: the grid is cleared on every new request and this loader is
   the feedback. Sits at the top of the results area (its DOM slot). */
.results { position: relative; }
.loading {
  width: max-content; margin: 46px auto;
  display: flex; align-items: center; gap: 9px;
  padding: 9px 18px; color: var(--ink); font-weight: 600; font-size: 13px;
  background: #fff; border: 1px solid var(--line); border-radius: 999px;
  box-shadow: 0 4px 16px rgba(16,24,40,.14);
}
.loading[hidden] { display: none; }   /* author display:flex would otherwise beat [hidden] */
.spinner {
  width: 18px; height: 18px; border: 2.5px solid var(--line); border-top-color: var(--pronto-blue);
  border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Pagination */
.pagination { display: flex; align-items: center; justify-content: center; gap: 5px; margin: 20px 0 6px; flex-wrap: wrap; }
.pagination:empty { display: none; }
.page-btn {
  min-width: 34px; padding: 7px 10px; border: 1px solid var(--line); background: #fff;
  border-radius: 4px; font-size: 12.5px; font-weight: 600; color: var(--ink); cursor: pointer; text-align: center;
}
.page-btn:hover { border-color: var(--pronto-blue); color: var(--pronto-blue-d); }
.page-btn.cur { background: var(--pronto-blue); border-color: var(--pronto-blue); color: #fff; cursor: default; }
.page-btn[disabled] { opacity: .45; cursor: default; }
.page-gap { color: var(--muted); padding: 0 2px; }

/* ================= Login screen (same as Reporting Dashboard) ================= */
.login-screen {
  position: fixed; inset: 0; z-index: 2000;
  display: flex; align-items: center; justify-content: center;
  background: var(--pp-bg, #f2f3f5); padding: 20px;
}
.login-screen[hidden] { display: none; }
.login-card {
  width: 400px; max-width: 94vw; background: #fff;
  border: 1px solid var(--pp-line, #e5e8ec); border-radius: 4px;
  box-shadow: 0 18px 50px rgba(0,0,0,.14); padding: 30px 30px 24px;
}
.login-logo { height: 24px; width: auto; display: block; margin-bottom: 20px; }
.login-card h2 { margin: 0 0 6px; font-size: 18px; }
.login-sub { margin: 0 0 18px; font-size: 12.5px; color: var(--pp-muted, #8a94a1); line-height: 1.5; }
.login-btn { width: 100%; justify-content: center; }
.login-note { font-size: 11px; color: var(--pp-muted, #8a94a1); margin: 10px 0 0; line-height: 1.45; }
.login-divider { display: flex; align-items: center; gap: 10px; margin: 18px 0 14px; color: var(--pp-muted, #8a94a1); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .8px; }
.login-divider::before, .login-divider::after { content: ""; flex: 1; height: 1px; background: var(--pp-line, #e5e8ec); }
.login-row { display: flex; align-items: center; gap: 12px; }
.login-row .login-btn { width: auto; flex: 1; }
.login-row a { font-size: 12px; font-weight: 700; white-space: nowrap; }
.login-err { margin-top: 12px; font-size: 12.5px; font-weight: 600; color: var(--bad); background: #fdf0f0; border: 1px solid #f0c4c4; border-radius: 4px; padding: 9px 11px; }

/* Fallback button styles if pronto-base css hasn't loaded */
.pp-btn { display: inline-flex; align-items: center; gap: 8px; padding: 9px 16px; border: 1px solid var(--line); border-radius: 4px; background: #fff; font-weight: 700; font-size: 13.5px; cursor: pointer; }
.pp-btn--primary { background: var(--pronto-blue); border-color: var(--pronto-blue); color: #fff; }
.pp-input { display: block; width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 4px; font-size: 13.5px; margin-top: 4px; }
.pp-label { display: block; font-size: 12.5px; font-weight: 600; margin-bottom: 12px; }

@media (max-width: 860px) {
  .layout { flex-direction: column; }
  .facets { position: static; max-height: none; flex-basis: auto; width: 100%; }
}

/* ================= Asset preview modal ================= */
.modal-scrim {
  position: fixed; inset: 0; z-index: 900; background: rgba(16,24,40,.62);
  opacity: 0; pointer-events: none; transition: opacity .2s;
}
.modal-scrim.open { opacity: 1; pointer-events: auto; }
.asset-modal {
  position: fixed; inset: 0; z-index: 910; display: none; align-items: center; justify-content: center;
  padding: 28px 40px; pointer-events: none;
}
.asset-modal.open { display: flex; }
.asset-modal .dw-panel {
  pointer-events: auto; width: min(1180px, 100%); height: min(860px, calc(100vh - 56px));
  background: #fff; border-radius: 8px; box-shadow: 0 24px 80px rgba(0,0,0,.35);
  display: flex; flex-direction: column; overflow: hidden;
  animation: dw-in .18s ease-out;
}
@keyframes dw-in { from { transform: scale(.97); opacity: 0; } to { transform: none; opacity: 1; } }
.dw-stepper { display: flex; align-items: center; gap: 6px; flex: none; }
.dw-nav {
  width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line); cursor: pointer;
  background: #fff; color: var(--ink); font-size: 30px; line-height: 1; padding: 0 0 5px;
  transition: background .12s, color .12s;
}
.dw-nav:hover { background: var(--pronto-blue); border-color: var(--pronto-blue); color: #fff; }
.dw-nav:disabled { opacity: .35; cursor: default; }
.dw-nav:disabled:hover { background: #fff; border-color: var(--line); color: var(--ink); }
/* Overlay arrows on the preview itself: where the eye already is */
.dw-ov {
  position: absolute; top: 50%; transform: translateY(-50%); z-index: 2;
  width: 48px; height: 64px; border: 0; cursor: pointer; border-radius: 6px;
  background: rgba(16,24,40,.55); color: #fff; font-size: 44px; line-height: 1; padding: 0 0 8px;
  opacity: .85; transition: opacity .12s, background .12s;
}
.dw-ov:hover { opacity: 1; background: var(--pronto-blue); }
.dw-ov:disabled { opacity: .2; cursor: default; }
.dw-ov:disabled:hover { background: rgba(16,24,40,.55); }
.dw-ov-prev { left: 10px; }
.dw-ov-next { right: 10px; }
.dw-loading {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  flex: 1 1 auto; min-height: 0; font-size: 14px; font-weight: 600; color: var(--muted);
}
.dw-loading[hidden] { display: none; }
.dw-body[hidden] { display: none; }
.dw-head { display: flex; align-items: center; gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--line); flex: none; }
.dw-headtext { flex: 1; min-width: 0; }
.dw-title { display: block; font-weight: 700; font-size: 15px; line-height: 1.4; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dw-pos { display: block; font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.dw-close { border: 0; background: transparent; font-size: 16px; color: var(--muted); cursor: pointer; padding: 2px 4px; }
.dw-close:hover { color: var(--ink); }
.dw-body { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(300px, 1fr); gap: 0; overflow: hidden; min-height: 0; }
.dw-left { padding: 18px; border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.dw-right { padding: 16px 18px; overflow-y: auto; min-height: 0; }
/* Fixed-height preview box: fills the left column so the modal and its arrows
   never move when the thumbnail's aspect ratio changes. */
.dw-preview {
  position: relative; flex: 1 1 auto; min-height: 0; margin-bottom: 14px; overflow: hidden;
  background: #f1f3f5; border: 1px solid var(--line); border-radius: 4px;
}
.dw-preview .ext {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 34px; font-weight: 800; color: #b6bdc6; letter-spacing: 2px; text-transform: uppercase;
}
.dw-preview img { position: absolute; inset: 0; z-index: 1; width: 100%; height: 100%; object-fit: contain; background: #fff; display: block; }
.dw-preview video { position: absolute; inset: 0; z-index: 1; width: 100%; height: 100%; object-fit: contain; background: #000; display: block; }
.dw-preview video[hidden] { display: none; }
.dw-actions { display: flex; flex-direction: column; gap: 8px; flex: none; }
.dw-download { display: flex; justify-content: center; width: 100%; padding: 11px; font-size: 14px; text-decoration: none; }
.dw-project { display: block; text-align: center; font-size: 13px; font-weight: 700; color: var(--pronto-blue-d); text-decoration: none; }
.dw-project:hover { text-decoration: underline; }
.dw-project[hidden] { display: none; }
.dw-section { margin: 0 0 14px; }
.dw-section h4 {
  margin: 0 0 6px; font-size: 10.5px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: .6px; border-bottom: 1px solid var(--line); padding-bottom: 4px;
}
.dw-meta { display: grid; grid-template-columns: 124px 1fr; gap: 5px 12px; margin: 0; font-size: 12.5px; }
.dw-meta dt { color: var(--muted); font-weight: 600; }
.dw-meta dd { margin: 0; word-break: break-word; }
.dw-meta dd .tagchip { display: inline-block; background: #eef1f4; border-radius: 3px; padding: 1px 6px; margin: 0 4px 3px 0; font-size: 11.5px; }
@media (max-width: 900px) {
  .asset-modal { padding: 12px 16px; }
  .dw-body { grid-template-columns: 1fr; overflow-y: auto; }
  .dw-left { border-right: 0; border-bottom: 1px solid var(--line); overflow: visible; }
  .dw-preview { flex: none; height: 44vh; }
  .dw-ov { width: 36px; height: 48px; font-size: 32px; }
}

/* ---- Pronto environment picker (login) + session badge (results head) ---- */
.login-env { margin: 0 0 16px; padding: 12px 12px 10px; border: 1px solid var(--pp-line, #e5e8ec); border-radius: 6px; background: #f7f9fb; }
.login-env .pp-label { margin: 0; }
.login-env select.pp-input { width: 100%; }
.login-env #l_envCustom { margin-top: 8px; }
.login-env #l_envCustom[hidden] { display: none; }   /* .pp-input sets display:block, which beats [hidden] */
.login-env .login-note { margin-top: 8px; }
.login-env.is-test { border-color: #f0c36d; background: #fff8e6; }
.env-badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 700; letter-spacing: .3px; text-transform: uppercase; white-space: nowrap; background: #fff3d6; color: #8a5a00; border: 1px solid #f0c36d; }
.env-badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #e0a100; }
.env-badge[hidden] { display: none; }
