:root {
  --blue: #0067c8;          /* Costain blue, matches the logo */
  --blue-dark: #0055a6;
  --blue-soft: #e8f1fb;
  --navy: #0b1f33;
  --bg: #eef1f5;
  --panel: #ffffff;
  --line: #e1e5ea;
  --text: #1b1f24;
  --muted: #6b7280;
  --pass: #2e8b57; --warn: #d98b00; --fail: #d0392e; --info: #6b7280;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(11, 31, 51, .06), 0 4px 14px rgba(11, 31, 51, .05);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; font: 13px/1.5 "Segoe UI", Inter, system-ui, sans-serif; color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; }

/* ---------------------------------------------------------------- header */
#top { height: 52px; background: var(--blue); color: #fff; display: flex; align-items: center; gap: 14px; padding: 0 16px 0 0; box-shadow: 0 1px 0 rgba(0,0,0,.08); }
#top .logo { height: 52px; width: auto; display: block; }
#top .brand { font-weight: 600; font-size: 15px; letter-spacing: .2px; }
#top .spacer { flex: 1; }
#top .user { opacity: .9; font-size: 12.5px; }
#top button, #top a.btn { background: rgba(255,255,255,.12); color: #fff; border: 1px solid rgba(255,255,255,.35); border-radius: 6px; padding: 6px 12px; cursor: pointer; text-decoration: none; transition: background .15s; }
#top button:hover, #top a.btn:hover { background: rgba(255,255,255,.22); }

/* ---------------------------------------------------------------- admin dialog + denied */
dialog#admin { border: 0; border-radius: 12px; padding: 20px 22px; width: min(720px, 92vw); box-shadow: 0 20px 60px rgba(11,31,51,.25); }
dialog#admin::backdrop { background: rgba(11,31,51,.45); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; margin: 0 0 6px; }
.dialog-head h3 { margin: 0; font-size: 16px; color: var(--navy); }
.muted { color: var(--muted); font-size: 12.5px; margin: 4px 0 10px; }
.add-user { display: grid; grid-template-columns: 1.4fr 1fr auto; gap: 8px; margin-bottom: 8px; }
table.users { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.users th { text-align: left; color: var(--muted); font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: .4px; padding: 6px 8px; border-bottom: 1px solid var(--line); }
table.users td { padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.users tr.admin td { color: var(--muted); }
.denied { position: fixed; inset: 52px 0 0 0; background: var(--bg); display: grid; place-items: center; z-index: 5; }
.denied .card { max-width: 440px; text-align: center; padding: 28px; }
.denied h2 { justify-content: center; font-size: 16px; }

/* ---------------------------------------------------------------- layout */
#layout { display: grid; grid-template-columns: 320px 1fr 420px; height: calc(100% - 52px); }
.pane { overflow: auto; display: flex; flex-direction: column; }
#files { background: var(--bg); padding: 14px; gap: 12px; border-right: 1px solid var(--line); }
#results { background: var(--panel); border-left: 1px solid var(--line); }

/* ---------------------------------------------------------------- left: cards */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.card.grow { flex: 1; min-height: 240px; }
.card h2 { margin: 0 0 2px; font-size: 13px; font-weight: 600; color: var(--navy); display: flex; align-items: center; gap: 8px; }
.card h2 .step { width: 20px; height: 20px; border-radius: 50%; background: var(--blue); color: #fff; font-size: 11px; font-weight: 700; display: inline-grid; place-items: center; }
.card h2 .hint { margin-left: auto; font-weight: 400; font-size: 11.5px; color: var(--muted); }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 11.5px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
input[type=text], select { width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; background: #fbfcfd; color: var(--text); transition: border-color .15s, box-shadow .15s; }
input[type=text]::placeholder { color: #9aa3ad; }
input[type=text]:focus, select:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(0,103,200,.15); background: #fff; }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 16px) 55%, calc(100% - 11px) 55%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 30px; }
button.primary { background: var(--blue); color: #fff; border: 0; border-radius: 8px; padding: 9px 14px; font-weight: 600; cursor: pointer; transition: background .15s, transform .05s; }
button.primary:hover { background: var(--blue-dark); }
button.primary:active { transform: translateY(1px); }
button.primary:disabled { opacity: .5; cursor: default; }
button.primary.wide { width: 100%; }
button.link { background: none; border: 0; color: var(--blue); cursor: pointer; padding: 0; font-weight: 500; }
button.link:hover { text-decoration: underline; }

/* breadcrumbs + tree */
.crumbs { display: flex; flex-wrap: wrap; gap: 2px 4px; font-size: 12px; color: var(--muted); min-height: 18px; }
.crumbs button { color: var(--muted); font-weight: 500; }
.crumbs button:last-child { color: var(--navy); font-weight: 600; }
ul.tree { list-style: none; margin: 0; padding: 0; flex: 1; overflow: auto; border-top: 1px solid var(--line); }
ul.tree li { padding: 7px 8px; border-radius: 6px; cursor: pointer; display: flex; gap: 9px; align-items: center; transition: background .1s; }
ul.tree li:hover { background: var(--blue-soft); }
ul.tree li .ico { width: 16px; text-align: center; color: var(--muted); font-size: 12px; }
ul.tree li > span:not(.ico):not(.ext) { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
ul.tree li .ext { font-size: 10px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase; padding: 1px 6px; border-radius: 4px; background: #eef1f5; color: var(--muted); }
ul.tree li .ext.rvt { background: #e6f0fb; color: #0b5cad; }
ul.tree li .ext.ifc { background: #e7f5ec; color: #1f6b3a; }
ul.tree li .ext.dwg { background: #fdf0e0; color: #8a4b00; }
ul.tree li.dim { opacity: .45; cursor: default; }
ul.tree li input[type=checkbox] { margin: 0; width: 15px; height: 15px; accent-color: var(--blue); cursor: pointer; }
.batchbar { display: flex; gap: 10px; align-items: center; padding-top: 10px; border-top: 1px solid var(--line); }
.batchbar span { flex: 1; color: var(--navy); font-weight: 600; }

/* status */
.status { font-size: 12px; color: var(--muted); padding: 8px 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; display: flex; align-items: center; gap: 8px; }
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--pass); flex: none; }
.status.err { color: var(--fail); }
.status.err::before { background: var(--fail); }

/* ---------------------------------------------------------------- viewer */
#viewer { position: relative; background: #e4e8ee; }
#viewer .empty { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; padding: 40px; color: var(--muted); max-width: 440px; margin: 0 auto; gap: 4px; }
#viewer .empty .mark { width: 64px; height: 64px; margin: 0 auto 10px; border-radius: 16px; background: var(--blue); color: #fff; font-weight: 800; letter-spacing: 1px; display: grid; place-items: center; box-shadow: var(--shadow); }
#viewer .empty p { margin: 4px 0; }
#viewer .empty strong { color: var(--navy); font-size: 14px; }

/* ---------------------------------------------------------------- right: results */
#results h2 { font-size: 11.5px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); margin: 0; padding: 12px 14px 6px; }
.model-head { padding: 12px 14px; border-bottom: 1px solid var(--line); }
.model-head .name { font-weight: 600; word-break: break-all; color: var(--navy); }
.model-head .meta { color: var(--muted); font-size: 12px; }
.summary { display: flex; gap: 6px; padding: 8px 14px; flex-wrap: wrap; }
.legend { padding-top: 0; border-bottom: 1px solid var(--line); padding-bottom: 10px; }
.legend:empty { display: none; }
.chip { border-radius: 12px; padding: 2px 10px; font-size: 12px; color: #fff; font-weight: 600; }
.chip.PASS { background: var(--pass); } .chip.WARN { background: var(--warn); } .chip.FAIL { background: var(--fail); } .chip.INFO { background: var(--info); }
.group { padding: 8px 14px 2px; font-weight: 600; color: var(--navy); border-top: 1px solid var(--line); margin-top: 6px; }
.result { display: grid; grid-template-columns: 18px 1fr auto; gap: 4px 8px; padding: 6px 14px; align-items: start; }
.result .dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 5px; }
.dot.PASS { background: var(--pass); } .dot.WARN { background: var(--warn); } .dot.FAIL { background: var(--fail); } .dot.INFO { background: var(--info); }
.result .name { font-weight: 500; }
.result .detail { grid-column: 2 / 4; color: var(--muted); font-size: 12px; word-break: break-word; }
.result button.link { font-size: 12px; white-space: nowrap; }
.actions { display: flex; gap: 12px; align-items: center; padding: 12px 14px; border-top: 1px solid var(--line); margin-top: auto; background: var(--panel); position: sticky; bottom: 0; }
#runs { border-bottom: 1px solid var(--line); }
.run { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; padding: 8px 14px; border-top: 1px solid var(--line); align-items: center; cursor: pointer; }
.run:hover { background: var(--blue-soft); }
.run.active { background: var(--blue-soft); box-shadow: inset 3px 0 0 var(--blue); }
.run .name { font-weight: 500; word-break: break-all; }
.run .chips { display: flex; gap: 4px; }
.run .chips .chip { padding: 1px 7px; font-size: 11px; }
.run .sub { grid-column: 1 / 3; color: var(--muted); font-size: 12px; }
.run .sub.err { color: var(--fail); }

/* ---------------------------------------------------------------- landing page (/) */
body.landing { background: #0b1f33; color: #e6ebf1; min-height: 100%; display: flex; flex-direction: column; }
.landing-top { display: flex; align-items: center; gap: 18px; padding: 18px 32px; border-bottom: 1px solid rgba(255,255,255,.08); }
.landing-top .wordmark { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 15px; letter-spacing: .3px; color: #fff; }
.landing-top .wordmark img { height: 34px; width: auto; }
.landing-top .wordmark em { font-style: normal; color: #7fb7ff; }
.landing-title { color: rgba(255,255,255,.75); font-size: 14px; padding-left: 18px; border-left: 1px solid rgba(255,255,255,.15); }
.landing-main { flex: 1; padding: 48px 32px; max-width: 1080px; width: 100%; margin: 0 auto; }
.hero h1 { font-size: 30px; line-height: 1.2; margin: 0 0 12px; max-width: 720px; letter-spacing: -.3px; }
.hero p { color: rgba(255,255,255,.72); max-width: 640px; font-size: 14.5px; margin: 0 0 36px; }
.packs { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.pack-card { display: flex; flex-direction: column; gap: 10px; background: #fff; color: var(--text); border-radius: 12px; padding: 18px; text-decoration: none; border-top: 4px solid var(--accent, #0b1f33); box-shadow: 0 8px 30px rgba(0,0,0,.25); transition: transform .12s, box-shadow .12s; }
.pack-card:hover { transform: translateY(-2px); box-shadow: 0 12px 36px rgba(0,0,0,.3); }
.pack-head { display: flex; align-items: center; gap: 12px; }
.pack-head img { height: 40px; width: auto; border-radius: 4px; }
.pack-name { font-weight: 700; color: var(--navy); font-size: 15px; }
.pack-client { color: var(--muted); font-size: 12px; }
.pack-card p { margin: 0; color: #3b4450; font-size: 13px; flex: 1; }
.pack-card .open { color: var(--accent, #0067c8); font-weight: 600; font-size: 13px; }
.landing .muted { color: rgba(255,255,255,.55); }
.landing-foot { padding: 16px 32px; color: rgba(255,255,255,.45); font-size: 12px; border-top: 1px solid rgba(255,255,255,.08); }
.landing-top .spacer { flex: 1; }
.landing-user { color: rgba(255,255,255,.8); font-size: 12.5px; }
button.ghost { background: transparent; color: #fff; border: 1px solid rgba(255,255,255,.35); border-radius: 6px; padding: 6px 12px; cursor: pointer; }
button.ghost:hover { background: rgba(255,255,255,.1); }
a.signin { display: inline-block; background: #fff; color: #0b1f33; font-weight: 700; padding: 11px 18px; border-radius: 8px; text-decoration: none; box-shadow: 0 8px 30px rgba(0,0,0,.25); }
a.signin:hover { background: #e8f1fb; }

/* ---------------------------------------------------------------- signed-out gate */
body.landing { background: radial-gradient(1200px 600px at 20% -10%, #17365a 0%, #0b1f33 55%, #081627 100%); }
.gate { display: grid; place-items: center; min-height: 60vh; }
.gate-card { background: #fff; color: var(--text); border-radius: 16px; padding: 40px 40px 32px; width: min(460px, 92vw); text-align: center; box-shadow: 0 30px 80px rgba(0,0,0,.45); }
.gate-logo { height: 64px; width: auto; margin-bottom: 14px; }
.gate-card h1 { font-size: 24px; margin: 0 0 8px; color: var(--navy); letter-spacing: -.2px; }
.gate-lead { color: #3b4450; margin: 0 0 24px; font-size: 14px; }
.btn-autodesk { display: inline-flex; align-items: center; justify-content: center; gap: 10px; width: 100%; background: var(--navy); color: #fff; font-weight: 600; font-size: 14px; padding: 13px 18px; border-radius: 10px; text-decoration: none; transition: background .15s, transform .05s; }
.btn-autodesk:hover { background: #163a63; }
.btn-autodesk:active { transform: translateY(1px); }
.gate-note { color: var(--muted); font-size: 12px; margin: 18px 0 0; line-height: 1.5; }

/* clearable input */
.field.clearable { position: relative; }
.field.clearable input { padding-right: 34px; }
.field.clearable .clear { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 24px; height: 24px; border: 0; border-radius: 50%; background: #e6eaf0; color: var(--muted); font-size: 16px; line-height: 1; cursor: pointer; display: grid; place-items: center; }
.field.clearable .clear:hover { background: #d5dbe3; color: var(--text); }

/* ---------------------------------------------------------------- results pane, refined */
#results { background: #f7f8fa; }
#results h2 { padding: 14px 16px 6px; }
.model-head { background: var(--panel); padding: 14px 16px; border-bottom: 1px solid var(--line); }
.model-head .name { font-size: 13.5px; }
.model-head .meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.badge { font-size: 11px; font-weight: 600; letter-spacing: .3px; padding: 2px 8px; border-radius: 999px; background: #eef1f5; color: var(--muted); }
.badge.fmt { text-transform: uppercase; }
.badge.fmt.rvt { background: #e6f0fb; color: #0b5cad; } .badge.fmt.ifc { background: #e7f5ec; color: #1f6b3a; } .badge.fmt.dwg { background: #fdf0e0; color: #8a4b00; }
.summary { padding: 14px 16px 0; }
.score { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; width: 100%; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; }
.tile b { font-size: 22px; line-height: 1.1; font-weight: 700; }
.tile span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.tile.FAIL b { color: var(--fail); } .tile.WARN b { color: var(--warn); } .tile.PASS b { color: var(--pass); }
.tile.lead.FAIL { background: #fff5f4; border-color: #f3c4bf; } .tile.lead.WARN { background: #fff9ec; border-color: #f2ddb0; } .tile.lead.PASS { background: #f1faf4; border-color: #bfe3cb; }
.legend { display: block; padding: 12px 16px 14px; border-bottom: 0; }
.elbar { display: flex; height: 8px; border-radius: 999px; overflow: hidden; background: #e6eaf0; }
.elbar i { display: block; height: 100%; }
.elbar i.FAIL { background: var(--fail); } .elbar i.WARN { background: var(--warn); } .elbar i.PASS { background: var(--pass); }
.elcounts { display: flex; gap: 14px; margin-top: 8px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.elcounts span { display: inline-flex; align-items: center; gap: 6px; }
.elcounts .total { margin-left: auto; }
.sw { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.sw.FAIL { background: var(--fail); } .sw.WARN { background: var(--warn); } .sw.PASS { background: var(--pass); }
.group { margin: 10px 16px 4px; padding: 0; border: 0; font-size: 11.5px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); font-weight: 600; }
.result { display: grid; grid-template-columns: auto 1fr auto; gap: 8px 10px; align-items: start; margin: 0 12px 6px; padding: 10px 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; }
.result .body { min-width: 0; }
.result .name { font-weight: 600; color: var(--navy); }
.result .detail { grid-column: auto; color: var(--muted); font-size: 12px; margin-top: 2px; word-break: break-word; }
.result.FAIL { border-left: 3px solid var(--fail); } .result.WARN { border-left: 3px solid var(--warn); } .result.PASS { border-left: 3px solid var(--pass); } .result.INFO { border-left: 3px solid #cbd2db; }
.pill { font-size: 10.5px; font-weight: 700; letter-spacing: .4px; text-transform: uppercase; padding: 3px 8px; border-radius: 999px; white-space: nowrap; margin-top: 1px; }
.pill.FAIL, .pill.ERROR { background: #fde3e0; color: #9b1c12; } .pill.WARN { background: #ffefc7; color: #7a4e00; } .pill.PASS { background: #dcf2e3; color: #1f6b3a; } .pill.INFO { background: #eef1f5; color: #4b5563; }
.ghost-sm { border: 1px solid var(--line); background: #fff; color: var(--blue); border-radius: 6px; padding: 4px 9px; font-size: 12px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.ghost-sm:hover { background: var(--blue-soft); border-color: #c7dcf3; }
.errorbox { background: #fde3e0; color: #9b1c12; border-radius: 10px; padding: 10px 12px; font-weight: 500; }
.actions { gap: 10px; padding: 12px 16px; box-shadow: 0 -8px 20px rgba(11,31,51,.06); }
.actions button.link { font-size: 12.5px; }
#runs { background: var(--panel); padding-bottom: 4px; }
.run { margin: 0 12px 8px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; }
.run.active { background: var(--blue-soft); box-shadow: inset 0 0 0 1px #c7dcf3; }
.run .name { color: var(--navy); }

.gate-alt { display: inline-block; margin-top: 12px; font-size: 12.5px; color: var(--blue); text-decoration: none; font-weight: 500; }
.gate-alt:hover { text-decoration: underline; }
.row-center { display: flex; gap: 14px; align-items: center; justify-content: center; margin-top: 6px; }
a.btn-like { text-decoration: none; display: inline-block; }
