/* CertifyLab Online: app shell and shared page styles */
:root {
    --cl-navy: #12263f;
    --cl-navy-2: #1c3557;
    --cl-accent: #1f6feb;
    --cl-bg: #f5f7fa;
    --cl-border: #dfe3e8;
    --cl-muted: #6b7785;
}

html, body { font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif; background: var(--cl-bg); color: #1d2733; }
a, .btn-link { color: var(--cl-accent); }

.app-shell { display: flex; min-height: 100vh; }
.app-sidebar { width: 240px; flex-shrink: 0; background: var(--cl-navy); color: #c9d4e2; display: flex; flex-direction: column; }
.app-shell.owner .app-sidebar { background: #2b1f3f; }
.app-brand { display: flex; align-items: center; gap: .6rem; padding: 1rem 1.1rem; }
.app-brand-mark { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 6px; background: var(--cl-accent); color: #fff; font-weight: 700; font-size: .9rem; }
.app-brand-name { font-weight: 600; color: #fff; letter-spacing: .2px; }
.app-nav { display: flex; flex-direction: column; padding: .25rem .5rem 1rem; overflow-y: auto; }
.app-nav-group { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: #7f93ab; padding: 1rem .75rem .35rem; }
.app-nav-link { color: #c9d4e2; text-decoration: none; padding: .42rem .75rem; border-radius: 6px; font-size: .92rem; }
.app-nav-link:hover { background: var(--cl-navy-2); color: #fff; }
.app-nav-link.active { background: var(--cl-accent); color: #fff; }
.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.app-topbar { height: 56px; display: flex; align-items: center; justify-content: space-between; padding: 0 1.5rem; background: #fff; border-bottom: 1px solid var(--cl-border); }
.app-tenant { font-weight: 600; }
.app-user { display: flex; align-items: center; }
.app-user-name { color: #1d2733; text-decoration: none; font-size: .92rem; }
.app-content { padding: 1.5rem; }

.portal-shell { min-height: 100vh; }
.portal-header { display: flex; align-items: center; gap: 2rem; padding: .5rem 1.5rem; background: var(--cl-navy); }
.portal-nav { display: flex; gap: 1rem; flex: 1; }
.portal-nav a { color: #c9d4e2; text-decoration: none; }
.portal-nav a.active { color: #fff; font-weight: 600; }
.portal-header .app-user-name { color: #fff; }
.portal-content { padding: 1.5rem; max-width: 1200px; margin: 0 auto; }

.auth-shell { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(160deg, var(--cl-navy) 0%, #24496f 100%); }
.auth-card { background: #fff; border-radius: 10px; padding: 2rem; width: min(560px, 92vw); box-shadow: 0 10px 40px rgba(0,0,0,.25); }

.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; }
.page-title { font-size: 1.45rem; font-weight: 600; margin: 0; }
.page-subtitle { color: var(--cl-muted); font-size: .92rem; margin-top: .2rem; }
.page-actions { display: flex; gap: .5rem; }

.panel { background: #fff; border: 1px solid var(--cl-border); border-radius: 8px; padding: 1rem 1.25rem; margin-bottom: 1rem; }
.panel-title { font-size: 1rem; font-weight: 600; margin: 0 0 .75rem; }
.two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1rem; }
.dl-grid { display: grid; grid-template-columns: max-content 1fr; gap: .3rem 1rem; margin: 0; }
.dl-grid dt { color: var(--cl-muted); font-weight: 500; }
.checklist { list-style: none; padding: 0; margin: 0; }
.checklist li { padding: .3rem 0 .3rem 1.6rem; position: relative; }
.checklist li::before { content: "○"; position: absolute; left: 0; color: var(--cl-muted); }
.checklist li.done::before { content: "●"; color: #1a7f37; }

.form-grid { display: grid; gap: 1rem; max-width: 900px; }
.form-grid fieldset { background: #fff; border: 1px solid var(--cl-border); border-radius: 8px; padding: 1rem 1.25rem; display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: .75rem 1rem; }
.form-grid legend { font-size: 1rem; font-weight: 600; float: none; width: auto; padding: 0 .25rem; margin: 0; grid-column: 1 / -1; }
.form-grid label, .form-inline-grid label { display: flex; flex-direction: column; gap: .25rem; font-size: .88rem; color: #3b4652; }
.form-inline-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: .75rem 1rem; align-items: end; }
.form-inline-grid .role-picks { grid-column: 1 / -1; }
.form-actions { display: flex; gap: .5rem; }

.tile-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.tile { background: #fff; border: 1px solid var(--cl-border); border-radius: 8px; padding: 1rem 1.25rem; }
.tile-label { color: var(--cl-muted); font-size: .85rem; }
.tile-value { font-size: 1.8rem; font-weight: 600; }
.empty-state { background: #fff; border: 1px dashed var(--cl-border); border-radius: 8px; padding: 2rem; color: var(--cl-muted); }

#blazor-error-ui { background: lightyellow; bottom: 0; box-shadow: 0 -1px 2px rgba(0,0,0,.2); display: none; left: 0; padding: .6rem 1.25rem .7rem; position: fixed; width: 100%; z-index: 1000; }
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: .75rem; top: .5rem; }

.btn-primary {
    color: #fff;
    background-color: #1b6ec2;
    border-color: #1861ac;
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
  box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}

.content {
    padding-top: 1.1rem;
}

h1:focus {
    outline: none;
}

.valid.modified:not([type=checkbox]) {
    outline: 1px solid #26b050;
}

.invalid {
    outline: 1px solid #e50000;
}

.validation-message {
    color: #e50000;
}

.blazor-error-boundary {
    background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwM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zg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}

    .blazor-error-boundary::after {
        content: "An error has occurred."
    }

.darker-border-checkbox.form-check-input {
    border-color: #929292;
}

/* ---- M9 shared styles (ADR 0025, UX-PRINCIPLES §7): one palette for status, one primary colour, one danger colour ---- */
:root {
    --cl-status-neutral-bg: #eef1f4; --cl-status-neutral-fg: #3b4652;
    --cl-status-info-bg: #e3effd;    --cl-status-info-fg: #0b4f9c;
    --cl-status-progress-bg: #ece8fb; --cl-status-progress-fg: #4b2fa3;
    --cl-status-success-bg: #e3f4e8; --cl-status-success-fg: #17663a;
    --cl-status-warning-bg: #fff3d6; --cl-status-warning-fg: #7a5200;
    --cl-status-danger-bg: #fde6e6;  --cl-status-danger-fg: #a11d1d;
}
.page-title-row { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }
.page-actions { align-items: center; }
.status-pill { display: inline-flex; align-items: baseline; gap: .4rem; border-radius: 999px; padding: .15rem .7rem; font-size: .82rem; font-weight: 600; white-space: nowrap; }
.status-pill-meta { font-weight: 400; opacity: .85; }
.status-neutral { background: var(--cl-status-neutral-bg); color: var(--cl-status-neutral-fg); }
.status-info { background: var(--cl-status-info-bg); color: var(--cl-status-info-fg); }
.status-progress { background: var(--cl-status-progress-bg); color: var(--cl-status-progress-fg); }
.status-success { background: var(--cl-status-success-bg); color: var(--cl-status-success-fg); }
.status-warning { background: var(--cl-status-warning-bg); color: var(--cl-status-warning-fg); }
.status-danger { background: var(--cl-status-danger-bg); color: var(--cl-status-danger-fg); }
.more-menu { position: relative; display: inline-block; }
.more-menu-items { position: absolute; right: 0; top: calc(100% + 4px); z-index: 1050; min-width: 220px; background: #fff; border: 1px solid var(--cl-border); border-radius: 6px; box-shadow: 0 6px 24px rgba(0,0,0,.12); padding: .3rem 0; }
.more-menu-items .dropdown-item { display: block; width: 100%; text-align: left; padding: .4rem 1rem; border: 0; background: none; color: #1d2733; text-decoration: none; font-size: .92rem; }
.more-menu-items .dropdown-item:hover { background: var(--cl-bg); }
.more-menu-items .dropdown-item.text-danger { color: var(--cl-status-danger-fg); }
.screen-intro { color: var(--cl-muted); font-size: .88rem; margin-top: .25rem; max-width: 72ch; }
.cell-label { }
.cell-ref { display: block; color: var(--cl-muted); font-size: .78rem; font-family: ui-monospace, Consolas, monospace; }
.alert-fade { animation: cl-fade 0.5s ease 4s forwards; }
@keyframes cl-fade { to { opacity: 0; height: 0; padding: 0; margin: 0; border-width: 0; overflow: hidden; } }
.guide-highlight { outline: 3px solid #f0a500 !important; outline-offset: 3px; border-radius: 4px; box-shadow: 0 0 0 9999px rgba(18, 38, 63, .18); position: relative; z-index: 1040; }
.guide-bubble { position: absolute; z-index: 1060; max-width: 340px; background: var(--cl-navy); color: #fff; padding: .55rem .8rem; border-radius: 6px; font-size: .9rem; box-shadow: 0 6px 24px rgba(0,0,0,.25); }

/* M9 WS5 guidance (ADR 0030): walkthrough bubble controls; "?" to show a hidden screen intro; the intro's "More" detail. */
.guide-bubble-text { padding-right: 1.1rem; }
.guide-bubble-nav { display: flex; align-items: center; gap: .4rem; margin-top: .55rem; }
.guide-bubble-count { font-size: .78rem; opacity: .8; margin-right: auto; }
.guide-bubble-close { position: absolute; top: .15rem; right: .35rem; border: 0; background: none; color: #fff; font-size: 1.15rem; line-height: 1; opacity: .75; padding: .1rem .2rem; }
.guide-bubble-close:hover, .guide-bubble-close:focus { opacity: 1; }
.screen-intro-show { display: inline-flex; align-items: center; justify-content: center; width: 1.25rem; height: 1.25rem; margin-top: .2rem; border: 1px solid var(--cl-border); border-radius: 50%; background: #fff; color: var(--cl-muted); font-size: .75rem; font-weight: 600; line-height: 1; padding: 0; }
.screen-intro-show:hover { color: var(--cl-navy); border-color: var(--cl-navy); }
.screen-intro-detail { margin-top: .35rem; padding-left: .6rem; border-left: 2px solid var(--cl-border); }
.screen-intro-detail p { margin-bottom: .3rem; }

/* WS2 plain-language builder (ADR 0027): the sheet with its side panel, colour legend, scrolling lists. */
.builder-sheet { min-width: 0; }
.builder-side { width: 340px; flex-shrink: 0; }
.builder-scroll { max-height: 620px; overflow: auto; }
.legend-swatch { display: inline-block; padding: 1px 8px; border: 1px solid var(--cl-border); border-radius: 3px; margin-right: 4px; }

/* ---- M9 WS3 persona home, navigation, onboarding (ADR 0028, UX-PRINCIPLES §1, §5, §7) ---- */
.home-next-action { font-size: 1.15rem; font-weight: 500; margin: 0 0 1rem; }
.home-tabs { margin-bottom: 1rem; }
.home-tab-dot { display: inline-block; width: .5rem; height: .5rem; border-radius: 50%; background: var(--cl-status-warning-fg); margin-left: .35rem; vertical-align: middle; }
.home-tone-info { color: var(--cl-status-info-fg); }
.home-tone-progress { color: var(--cl-status-progress-fg); }
.home-tone-success { color: var(--cl-status-success-fg); }
.home-tone-warning { color: var(--cl-status-warning-fg); }
.home-tone-danger { color: var(--cl-status-danger-fg); }
.onboarding-progress { margin-bottom: 1rem; }
.onboarding-progress .progress { height: .5rem; }
.onboarding-list { list-style: none; padding: 0; margin: 0; }
.onboarding-item { display: flex; align-items: center; gap: .9rem; padding: .55rem 0; border-top: 1px solid var(--cl-border); }
.onboarding-text { flex: 1; }
.onboarding-mark { display: inline-grid; place-items: center; width: 1.6rem; height: 1.6rem; border-radius: 50%; font-weight: 700; font-size: .85rem; }
.onboarding-mark-done { background: var(--cl-status-success-bg); color: var(--cl-status-success-fg); }
.onboarding-mark-todo { background: var(--cl-status-warning-bg); color: var(--cl-status-warning-fg); }
.onboarding-mark-optional { background: var(--cl-status-neutral-bg); color: var(--cl-status-neutral-fg); }
.topbar-onboarding { display: inline-flex; align-items: center; gap: .5rem; text-decoration: none; color: inherit; margin-right: .5rem; }
.topbar-onboarding-bar { display: inline-flex; width: 110px; height: .45rem; }
.form-required::after { content: " *"; color: var(--cl-status-danger-fg); }
.form-unit { color: var(--cl-muted); white-space: nowrap; }
.form-help { color: var(--cl-muted); font-size: .8rem; }
.print-only { display: none; }
/* Printable notes (receipt, delivery note): only the sheet prints. */
.print-sheet { background: #fff; padding: 1.5rem; border: 1px solid var(--cl-border, #dee2e6); border-radius: 8px; max-width: 1100px; }
@media print {
    .app-sidebar, .app-topbar, .no-print { display: none !important; }
    .app-content { padding: 0 !important; }
    .print-sheet { border: none; padding: 0; }
}
.input-narrow { max-width: 240px; }
.form-span-all { grid-column: 1 / -1; }
.form-scroll { max-height: 320px; overflow: auto; }
.board-card { padding: 6px 8px; border-left: 4px solid var(--cl-status-success-fg); }
.board-card-soon { border-left-color: #e0a800; }
.board-card-late { border-left-color: var(--cl-status-danger-fg); background: var(--cl-status-danger-bg); }
.form-check-inline-label { display: inline; }
.text-prewrap { white-space: pre-wrap; }
.input-w140 { max-width: 140px; }
.input-w160 { max-width: 160px; }
.input-w200 { max-width: 200px; }
.input-w220 { max-width: 220px; }
.input-w260 { max-width: 260px; }
.input-w90 { max-width: 90px; }
.branding-preview { min-height: 70px; }
.branding-preview-img { max-height: 70px; max-width: 220px; }
/* WS3 Assets */
.table-narrow { max-width: 720px; }
/* WS3 Owner and Portal */
.tile-value-sm { font-size: 1.1rem; }

/* ---- M9 WS6: help and assistant panel, Explain popover (ADR 0031, FR-14.2, FR-14.5) ---- */
.assistant-panel { width: 360px; flex-shrink: 0; position: sticky; top: 0; height: 100vh; overflow-y: auto; background: #fff; border-left: 1px solid var(--cl-border); padding: .75rem 1rem; display: flex; flex-direction: column; gap: .75rem; z-index: 1030; }
@media (max-width: 991.98px) { .assistant-panel { position: fixed; right: 0; top: 0; bottom: 0; width: min(360px, 100vw); box-shadow: -6px 0 24px rgba(0,0,0,.15); } }
.assistant-header { display: flex; justify-content: space-between; align-items: center; }
.assistant-title { font-size: 1rem; font-weight: 600; margin: 0; }
.assistant-section-title { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--cl-muted); margin-bottom: .35rem; }
.assistant-turn { border-radius: 8px; padding: .5rem .65rem; font-size: .9rem; margin-bottom: .4rem; white-space: pre-line; }
.assistant-turn.question { background: var(--cl-bg); }
.assistant-turn.answer { border: 1px solid var(--cl-border); }
.assistant-cite { font-size: .78rem; color: var(--cl-muted); margin-top: .3rem; white-space: normal; }
.assistant-stuck { background: var(--cl-status-warning-bg); border-radius: 8px; padding: .65rem .75rem; }
.assistant-topic summary { cursor: pointer; font-weight: 500; font-size: .92rem; }
.assistant-topic p { font-size: .88rem; margin: .35rem 0 .5rem; }
.explain { position: relative; display: inline-block; }
.explain-popover { position: absolute; z-index: 1050; top: calc(100% + 4px); left: 0; width: 340px; max-width: 80vw; background: #fff; border: 1px solid var(--cl-border); border-radius: 6px; box-shadow: 0 6px 24px rgba(0,0,0,.12); padding: .65rem .8rem; font-size: .88rem; font-weight: normal; text-align: left; white-space: normal; color: #1d2733; }
.explain-polished { border-top: 1px solid var(--cl-border); margin-top: .5rem; padding-top: .5rem; }

/* ---- M9 §7 sweep: bench, review and layout designer (moved from page <style> blocks) ---- */
/* Bench entry and review detail (shared layout) */
.bench-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
@media (max-width: 1100px) { .bench-layout { grid-template-columns: 1fr; } }
.bench-side .panel { margin-bottom: 12px; }
.bench-btn { min-height: 44px; } /* FR-3.7 touch targets */
.bench-form { display: grid; gap: 8px; }
.bench-form input, .bench-form select, .bench-form textarea { min-height: 42px; font-size: 1rem; }
.bench-check { display: flex; gap: 8px; align-items: center; }
/* Bench queue (also the scan lookup button) */
.bench-action { min-height: 44px; min-width: 104px; } /* FR-3.7 touch targets */
/* Bench sheet */
.bench-sheet { border: 1px solid #dee2e6; border-radius: 6px; overflow: hidden; }
.bench-sheet .e-spreadsheet { font-size: 15px; } /* FR-3.7: larger rows/text for tablets */
/* Specification and uncertainty panel */
.spec-diff { padding: 6px 8px; border: 1px solid #f0d78c; background: #fff7d6; border-radius: 6px; font-size: .9rem; }
.spec-panel .btn { min-height: 36px; }
/* Review detail and review queue */
.review-scroll { max-height: 360px; overflow: auto; }
.review-photo { max-width: 100%; max-height: 320px; border: 1px solid #dee2e6; border-radius: 4px; margin-top: 4px; }
.review-actions { margin-bottom: 12px; }
.review-action { min-height: 40px; }
/* Layout designer */
.ld-canvas { position: relative; flex-shrink: 0; background: #fff; touch-action: none; user-select: none; overflow: hidden; }
.ld-row { position: absolute; left: 0; width: 34px; font-size: 9px; line-height: 1; color: #667; text-align: right; padding-right: 3px;
          border-bottom: 1px solid #eef; background: #f6f7fb; cursor: pointer; overflow: hidden; }
.ld-row:hover { background: #ffe3e3; }
.ld-row-break { border-top: 2px dashed #c92a2a; }
.ld-break { position: absolute; left: 0; right: 0; border-top: 2px dashed #c92a2a; pointer-events: none; }
.ld-break span { position: absolute; right: 4px; top: 0; font-size: 10px; color: #c92a2a; background: rgba(255,255,255,.85); padding: 0 3px; }
.ld-titles { position: absolute; left: 0; right: 0; background: rgba(51,154,240,.18); pointer-events: none; }
.ld-item { position: absolute; border: 2px solid; background: rgba(255,255,255,.08); cursor: move; box-sizing: border-box; }
.ld-selected { box-shadow: 0 0 0 3px rgba(255,212,59,.9); }
.ld-label { position: absolute; left: -2px; top: -16px; font-size: 10px; color: #fff; padding: 0 4px; white-space: nowrap; pointer-events: none; }
.ld-handle { position: absolute; right: -5px; bottom: -5px; width: 10px; height: 10px; cursor: nwse-resize; }
.ld-key { display: inline-block; border: 2px solid transparent; padding: 0 4px; margin-right: 4px; }
