/*
 * Page layouts for Quantify Desktop QA. Primitives come from ui.css; the shell,
 * page header and sign-in are copied from the Quantify QA Console's app.css.
 * Colors use tokens only, so light and dark both follow ui.css.
 */

/* Shell: a grey Mac-style sidebar and a white main column with a top bar */
.shell { display: flex; min-height: 100%; }
.sidebar { flex: 0 0 248px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; background: var(--sidebar); border-right: 1px solid var(--sidebar-border); overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 14px 16px 12px; color: inherit; }
.brand:hover { text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; background: var(--foreground); color: #fff; flex: none; }
.brand-mark svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.brand-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.brand-name { font-weight: 600; font-size: 14px; letter-spacing: -0.005em; }
.brand-sub { font-size: 12px; color: var(--muted-foreground); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-section { display: flex; flex-direction: column; gap: 1px; padding: 4px 10px; }
.nav-heading { display: flex; align-items: center; justify-content: space-between; font-size: 11px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted-foreground); padding: 14px 10px 6px; }
.nav-heading .count { font-family: var(--font-mono); font-weight: 500; letter-spacing: 0; text-transform: none; font-size: 11.5px; }
.nav-item { display: flex; align-items: center; gap: 9px; height: 28px; padding: 0 8px; border-radius: 6px; color: var(--foreground); font-weight: 400; font-size: 13px; }
.nav-item .ic { width: 16px; height: 16px; color: var(--muted-foreground); }
.nav-item:hover { background: var(--sidebar-active); text-decoration: none; color: var(--foreground); }
.nav-item.active { background: var(--sidebar-active); font-weight: 500; }
.nav-item.active .ic { color: var(--foreground); }
.nav-count { margin-left: auto; font-family: var(--font-mono); font-size: 11.5px; color: var(--muted-foreground); }
.nav-count:empty { display: none; }
.nav-foot { margin-top: auto; display: flex; align-items: center; gap: 8px; padding: 10px 16px; border-top: 1px solid var(--sidebar-border); font-size: 12px; color: var(--muted-foreground); min-height: 40px; }
.nav-foot .dot { width: 7px; height: 7px; }
.nav-foot .foot-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-foot .ic { width: 15px; height: 15px; }
.main { flex: 1; min-width: 0; padding: 0 var(--space-10) var(--space-10); display: flex; flex-direction: column; gap: var(--space-6); outline: none; }
.main > * { max-width: 1480px; width: 100%; }
.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: var(--space-3); height: 52px; margin: 0 calc(-1 * var(--space-10)); padding: 0 var(--space-10); max-width: none; width: auto; background: color-mix(in srgb, var(--background) 88%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-bottom: 1px solid var(--border); }
.topbar .crumbs { flex: 1; min-width: 0; flex-wrap: nowrap; }
.topbar .crumbs .current { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-actions { display: flex; align-items: center; gap: var(--space-2); flex: none; }
.topbar-actions .select { width: auto; min-width: 200px; }
.topbar-actions .muted { font-size: 12.5px; }
.topbar + * { margin-top: var(--space-2); }
@media (max-width: 900px) {
  .shell { flex-direction: column; }
  .sidebar { flex: none; position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 0; border-right: 0; border-bottom: 1px solid var(--sidebar-border); padding: 6px 8px; overflow: visible; }
  .brand { padding: 6px 8px; }
  .nav-section { flex-direction: row; padding: 0 4px; }
  .nav-foot { margin: 0; border: 0; padding: 0 8px; min-height: 0; }
  .main { padding: 0 var(--space-4) var(--space-8); }
  .topbar { margin: 0 calc(-1 * var(--space-4)); padding: 0 var(--space-4); height: auto; min-height: 48px; flex-wrap: wrap; row-gap: 6px; padding-top: 6px; padding-bottom: 6px; }
}

/* Page header: title, the one-line summary, the longer description, and a quiet action on the right */
.page-header { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: var(--space-3) var(--space-6); padding-top: var(--space-2); }
.page-title { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.page-title .row { gap: 10px; }
.page-summary { font-size: 13.5px; color: var(--foreground); }
.page-description { color: var(--muted-foreground); font-size: 13px; max-width: 80ch; text-wrap: pretty; }
.page-description .badge { vertical-align: middle; }
.page-aside { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); font-size: 13px; color: var(--muted-foreground); padding-top: 4px; }
.page-aside a { color: var(--foreground); font-weight: 500; }
.page-error { color: var(--destructive); }

/* Sign-in */
.login { min-height: 100%; display: grid; place-items: center; padding: var(--space-6); }
.login-card { width: min(400px, 100%); }
.login h1 { font-size: 16px; }

/* Brand mark inverts with the theme */
.brand-mark { color: var(--background); }
.brand-name { font-family: var(--font-display); }

/* Outcome pills and tags */
.pill { display: inline-flex; align-items: center; gap: 5px; height: 20px; padding: 0 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; white-space: nowrap; border: 1px solid transparent; }
.pill .ic { width: 12px; height: 12px; stroke-width: 2.6; }
.pill-pass { background: var(--success-soft); color: var(--success-foreground); }
.pill-fail { background: var(--destructive-soft); color: var(--destructive-foreground); }
.pill-blocked { background: var(--warning-soft); color: var(--warning-foreground); }
.pill-skipped, .pill-none { background: transparent; color: var(--muted-foreground); border-color: var(--border-strong); border-style: dashed; }
.pill-running { background: var(--info-soft); color: var(--info-foreground); }
.app-badge { font-weight: 600; }
.app-vnext { background: var(--info-soft); color: var(--info-foreground); }
.app-legacy { background: var(--secondary); color: var(--secondary-foreground); }
.cause { display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 7px; border-radius: 5px; border: 1px solid var(--border-strong); font-size: 11.5px; color: var(--foreground); white-space: nowrap; }
.cause::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--neutral); }
.cause-library::before { background: var(--destructive); }
.cause-winforms::before { background: var(--primary); }
.cause-database::before { background: var(--warning); }
.cause-gap::before { background: var(--meter); }
.cause-test::before { background: var(--success); }
.cause-triaged { border-style: solid; border-color: var(--foreground); }

/* Stacked pass/fail/blocked/skipped bar */
.stackbar { display: flex; width: 100%; height: 5px; border-radius: 3px; overflow: hidden; background: var(--meter-track); }
.stackbar > i { display: block; height: 100%; }
.stackbar .sb-pass { background: var(--success); }
.stackbar .sb-fail { background: var(--destructive); }
.stackbar .sb-blocked { background: var(--warning); }
.stackbar .sb-skipped { background: var(--neutral); }
.counts { display: flex; gap: 10px; font-family: var(--font-mono); font-size: 12px; white-space: nowrap; }
.counts span { display: inline-flex; align-items: center; gap: 4px; }
.counts .dot { width: 7px; height: 7px; }
.counts .zero { opacity: 0.4; }

/* Runs list */
.run-list { display: flex; flex-direction: column; }
.run-row { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr) minmax(170px, 0.9fr); gap: var(--space-4); align-items: center; padding: 12px var(--space-4); border-top: 1px solid var(--border); color: var(--foreground); }
.run-row:first-child { border-top: 0; }
.run-row:hover { background: var(--muted-soft); text-decoration: none; color: var(--foreground); }
.run-main { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.run-main .row { gap: 6px; flex-wrap: wrap; }
.run-id { font-family: var(--font-mono); font-size: 11.5px; color: var(--muted-foreground); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.run-when { display: flex; flex-direction: column; gap: 3px; font-size: 12.5px; min-width: 0; }
.run-when .muted { font-size: 12px; }
.run-tally { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.status-running { display: inline-flex; align-items: center; gap: 6px; color: var(--primary); font-weight: 500; }
.status-running .dot { background: var(--primary); color: var(--primary); }
@media (max-width: 760px) { .run-row { grid-template-columns: minmax(0, 1fr); gap: var(--space-2); } }

/* Run page */
.filters { display: flex; flex-direction: column; gap: var(--space-3); }
.filter-label { font-size: 12px; color: var(--muted-foreground); min-width: 54px; }
.group-card { overflow: hidden; }
.group-bar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); padding: 10px var(--space-4); background: var(--muted-soft); border-bottom: 1px solid var(--border); }
.group-bar h2 { font-size: 13.5px; flex: 1; min-width: 160px; }
.result-row { display: grid; grid-template-columns: 74px 34px minmax(0, 1.4fr) 92px 64px minmax(0, 1.2fr) 46px; gap: 12px; align-items: center; padding: 10px var(--space-4); border-top: 1px solid var(--border); color: var(--foreground); }
.group-bar + .result-row { border-top: 0; }
.result-row:hover { background: var(--muted-soft); text-decoration: none; color: var(--foreground); }
.result-ord { font-family: var(--font-mono); font-size: 12px; color: var(--muted-foreground); text-align: right; }
.result-name { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.result-name b { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result-name .mono { color: var(--muted-foreground); font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result-dur, .result-shots { font-family: var(--font-mono); font-size: 12px; color: var(--muted-foreground); text-align: right; white-space: nowrap; }
.result-shots .ic { width: 13px; height: 13px; }
.result-err { font-size: 12px; color: var(--destructive-foreground); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.result-err.blocked { color: var(--warning-foreground); }
@media (max-width: 900px) {
  .result-row { grid-template-columns: auto minmax(0, 1fr) auto; gap: 4px 10px; }
  .result-row .pill { grid-column: 1; grid-row: 1; }
  .result-ord { display: none; }
  .result-name { grid-column: 2; grid-row: 1; }
  .result-dur { grid-column: 3; grid-row: 1; }
  .result-row .cause, .result-row .cause-empty { grid-column: 2; grid-row: 2; justify-self: start; }
  .result-err { grid-column: 1 / -1; grid-row: 3; white-space: normal; }
  .result-err:empty { display: none; }
  .result-shots { grid-column: 3; grid-row: 2; }
}

/* Test result page */
.result-layout { display: flex; flex-wrap: wrap; gap: var(--space-6); align-items: flex-start; }
.result-main { flex: 999 1 600px; min-width: 0; display: flex; flex-direction: column; gap: var(--space-4); }
.result-rail { flex: 1 1 280px; min-width: 0; display: flex; flex-direction: column; gap: var(--space-4); }
.steps { display: flex; flex-direction: column; }
.step { display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 12px; padding: 12px var(--space-4); border-top: 1px solid var(--border); }
.step:first-child { border-top: 0; }
.step-n { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; font-family: var(--font-mono); font-size: 11.5px; font-weight: 600; background: var(--secondary); color: var(--secondary-foreground); }
.step-n.n-pass { background: var(--success-soft); color: var(--success-foreground); }
.step-n.n-fail { background: var(--destructive); color: #fff; }
.step-n.n-blocked { background: var(--warning-soft); color: var(--warning-foreground); }
.step-body { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.step-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.step-text { flex: 1; min-width: 200px; overflow-wrap: anywhere; }
.step-meta { font-family: var(--font-mono); font-size: 12px; color: var(--muted-foreground); }
.step-error { font-size: 12.5px; color: var(--destructive-foreground); background: var(--destructive-soft); border-radius: var(--radius-sm); padding: 6px 9px; overflow-wrap: anywhere; }
.thumbs { display: flex; flex-wrap: wrap; gap: 8px; }
.thumb { padding: 0; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--muted); cursor: zoom-in; overflow: hidden; width: 240px; max-width: 100%; aspect-ratio: 16 / 9; display: block; position: relative; }
.thumb:hover { border-color: var(--border-strong); }
.thumb img { display: block; width: 100%; height: 100%; object-fit: cover; object-position: top left; }
.thumb span { position: absolute; left: 6px; bottom: 6px; max-width: calc(100% - 12px); font-family: var(--font-mono); font-size: 10.5px; color: #fff; background: rgba(0, 0, 0, 0.6); border-radius: 4px; padding: 1px 5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.error-box { display: flex; flex-direction: column; gap: var(--space-3); }
.error-text { font-family: var(--font-mono); font-size: 12.5px; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--destructive-foreground); }
details.stack summary { cursor: pointer; font-size: 12.5px; color: var(--muted-foreground); display: flex; align-items: center; gap: var(--space-2); list-style: none; }
details.stack summary::-webkit-details-marker { display: none; }
details.stack summary::before { content: "▸"; font-size: 10px; }
details.stack[open] summary::before { content: "▾"; }
.stack-text { margin: var(--space-2) 0 0; padding: var(--space-3); max-height: 420px; overflow: auto; background: var(--muted); border: 1px solid var(--border); border-radius: var(--radius-sm); font-family: var(--font-mono); font-size: 11.5px; line-height: 1.5; white-space: pre; color: var(--foreground); }
.triage-form { display: flex; flex-direction: column; gap: var(--space-3); }
.hist-list { display: flex; flex-direction: column; }
.hist-item { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 4px 10px; align-items: center; padding: 9px var(--space-4); border-top: 1px solid var(--border); color: var(--foreground); font-size: 12.5px; }
.hist-item:first-child { border-top: 0; }
.hist-item:hover { background: var(--muted-soft); text-decoration: none; color: var(--foreground); }
.hist-item .mono { color: var(--muted-foreground); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11.5px; }

/* Tests library */
.lib-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.lib-toolbar .input-group { flex: 1 1 260px; }
.lib-row { display: grid; grid-template-columns: 40px minmax(0, 1fr) 132px 132px; gap: 12px; align-items: center; padding: 9px var(--space-4); border-top: 1px solid var(--border); color: var(--foreground); }
.group-bar + .lib-row { border-top: 0; }
.lib-row:hover { background: var(--muted-soft); text-decoration: none; color: var(--foreground); }
.lib-row.is-disabled { opacity: 0.6; }
.lib-head { font-size: 11.5px; color: var(--muted-foreground); padding-top: 6px; padding-bottom: 6px; }
.lib-head:hover { background: none; }
.lib-app { display: flex; flex-direction: column; gap: 2px; align-items: flex-start; min-width: 0; }
.lib-app .xs { color: var(--muted-foreground); font-family: var(--font-mono); }
@media (max-width: 700px) {
  .lib-row { grid-template-columns: minmax(0, 1fr) auto auto; gap: 4px 8px; }
  .lib-row .result-ord { display: none; }
  .lib-row .result-name { grid-column: 1 / -1; }
  .lib-row .lib-app { grid-row: 2; }
  .lib-row .lib-app:nth-of-type(3) { grid-column: 1; }
  .lib-head { display: none; }
}
.compare { display: grid; gap: var(--space-4); grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 1fr)); }
.tc-steps { margin: 0; padding: var(--space-3) var(--space-4) var(--space-3) calc(var(--space-4) + 3ch); font-family: var(--font-mono); font-size: 11.5px; line-height: 1.6; max-height: 70vh; overflow: auto; }
.tc-steps li { overflow-wrap: anywhere; padding: 1px 0; }
.tc-steps li::marker { color: var(--muted-foreground); }

/* Lightbox */
.gallery-image { max-height: calc(100vh - 150px); }
.gallery-strip img { object-position: top left; }
@media (max-width: 640px) { .gallery-body > .btn { display: none; } }

/* Categories: one card per area with each app's pass meter and queue buttons */
.cat-card .card-title a { color: var(--foreground); }
.cat-app { display: grid; grid-template-columns: 48px minmax(0, 1fr) auto; gap: 8px; align-items: center; }
.cat-fail { color: var(--destructive); }
.cat-actions { flex-wrap: wrap; gap: var(--space-2); margin-top: var(--space-1); }
