/*
 * Engineering Console visual system
 * A restrained, high-density interface for controlled drawings and production data.
 * This layer intentionally overrides legacy presentation without changing business behavior.
 */

:root {
    color-scheme: light;
    --ec-navy: #102a43;
    --ec-navy-deep: #0b2034;
    --ec-canvas: #f3f6f8;
    --ec-surface: #ffffff;
    --ec-ink: #17212b;
    --ec-muted: #627184;
    --ec-blue: #2563eb;
    --ec-blue-hover: #1d4ed8;
    --ec-blue-soft: #edf4ff;
    --ec-red: #c83a3a;
    --ec-amber: #a76005;
    --ec-green: #16734b;
    --ec-line: #d7e0e8;
    --ec-line-strong: #b9c7d5;
    --ec-surface-subtle: #f7f9fb;
    --ec-focus: rgba(37, 99, 235, 0.22);
    --ec-shadow: 0 1px 2px rgba(16, 42, 67, 0.05), 0 10px 28px rgba(16, 42, 67, 0.055);
    --ec-shadow-dialog: 0 24px 70px rgba(10, 31, 50, 0.28);
    --ec-radius: 8px;
    --ec-radius-control: 6px;
    --ec-font: "Microsoft YaHei UI", "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", sans-serif;
    --ec-data-font: Bahnschrift, "Segoe UI", "Microsoft YaHei UI", sans-serif;

    /* Compatibility tokens used by existing views. */
    --bg: var(--ec-canvas);
    --text: var(--ec-ink);
    --muted: var(--ec-muted);
    --line: var(--ec-line);
    --panel: var(--ec-surface);
    --accent: var(--ec-blue);
    --accent-soft: var(--ec-blue-soft);
    --ok: var(--ec-green);
    --border: var(--ec-line);
    --surface: var(--ec-surface);
    --surface-muted: var(--ec-surface-subtle);
    --text-muted: var(--ec-muted);
    --brand: var(--ec-blue);
    --primary: var(--ec-blue);
    --sidebar: var(--ec-navy);
    --sidebar-deep: var(--ec-navy-deep);
    --sidebar-hover: rgba(255, 255, 255, 0.08);
    --brand-red: var(--ec-red);
    --workspace-line: var(--ec-line);
    --workspace-shadow: var(--ec-shadow);
    --shadow-sm: var(--ec-shadow);
}

html {
    background: var(--ec-canvas);
    scroll-behavior: smooth;
}

body {
    background: var(--ec-canvas);
    color: var(--ec-ink);
    font-family: var(--ec-font);
    font-size: 14px;
    line-height: 1.55;
    text-rendering: optimizeLegibility;
    -webkit-tap-highlight-color: rgba(37, 99, 235, 0.12);
}

button,
input,
select,
textarea {
    font: inherit;
    touch-action: manipulation;
}

button:not(:disabled),
[role="button"]:not([aria-disabled="true"]) {
    cursor: pointer;
}

h1,
h2,
h3,
h4 {
    color: var(--ec-ink);
    font-weight: 650;
    letter-spacing: -0.018em;
    text-wrap: balance;
}

p,
li,
dd {
    text-wrap: pretty;
}

code,
kbd,
pre,
.mono,
.version-number,
.page-number,
td.num,
th.num,
input[type="number"] {
    font-family: var(--ec-data-font);
    font-variant-numeric: tabular-nums;
}

a {
    text-underline-offset: 3px;
}

a:focus-visible,
button:focus-visible,
[role="button"]:focus-visible,
summary:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 3px solid var(--ec-focus);
    outline-offset: 2px;
}

.skip-link {
    position: fixed;
    top: 10px;
    left: 12px;
    z-index: 200;
    padding: 9px 13px;
    border-radius: var(--ec-radius-control);
    background: var(--ec-blue);
    color: #fff;
    font-weight: 700;
    text-decoration: none;
    transform: translateY(-160%);
    transition: transform 0.16s ease;
}

.skip-link:focus {
    transform: translateY(0);
}

/* Base form controls ------------------------------------------------------ */

input:not([type="hidden"]):not([type="checkbox"]):not([type="radio"]),
select,
textarea {
    min-height: 40px;
    padding: 8px 11px;
    border: 1px solid var(--ec-line-strong);
    border-radius: var(--ec-radius-control);
    background-color: var(--ec-surface);
    color: var(--ec-ink);
    box-shadow: inset 0 1px 1px rgba(16, 42, 67, 0.025);
    transition: border-color 0.16s ease, box-shadow 0.16s ease, background-color 0.16s ease;
}

textarea {
    min-height: 96px;
    line-height: 1.6;
    resize: vertical;
}

select {
    color-scheme: light;
}

input:not([type="hidden"]):not([type="checkbox"]):not([type="radio"]):hover,
select:hover,
textarea:hover {
    border-color: #95a8bb;
}

input:not([type="hidden"]):not([type="checkbox"]):not([type="radio"]):focus,
select:focus,
textarea:focus {
    border-color: var(--ec-blue);
    outline: 0;
    box-shadow: 0 0 0 3px var(--ec-focus);
}

input::placeholder,
textarea::placeholder {
    color: #8b98a7;
    opacity: 1;
}

input:disabled,
select:disabled,
textarea:disabled {
    border-color: #dce3ea;
    background: #eef2f5;
    color: #718096;
    cursor: not-allowed;
    opacity: 1;
}

input[type="checkbox"],
input[type="radio"] {
    width: 18px;
    height: 18px;
    margin: 0;
    accent-color: var(--ec-blue);
}

input[type="file"] {
    min-height: 44px;
    padding: 5px 8px;
}

input[type="file"]::file-selector-button {
    min-height: 32px;
    margin-right: 10px;
    padding: 5px 11px;
    border: 1px solid var(--ec-line-strong);
    border-radius: 5px;
    background: var(--ec-surface-subtle);
    color: var(--ec-ink);
    cursor: pointer;
    font-weight: 650;
}

label,
legend {
    color: #364658;
}

.checkbox-row,
.switch-row,
label:has(> input[type="checkbox"]),
label:has(> input[type="radio"]) {
    align-items: center;
    min-height: 36px;
    gap: 9px;
}

fieldset {
    border-color: var(--ec-line);
    border-radius: var(--ec-radius);
}

/* Buttons and action links ------------------------------------------------ */

.primary-button,
.primary-link,
.danger-button,
.secondary-button,
.secondary-link {
    display: inline-flex;
    min-height: 40px;
    align-items: center;
    justify-content: center;
    gap: 7px;
    margin: 0;
    padding: 8px 15px;
    border-radius: var(--ec-radius-control);
    box-shadow: none;
    font-weight: 650;
    line-height: 1.2;
    text-decoration: none;
    transition: border-color 0.16s ease, background-color 0.16s ease, color 0.16s ease, box-shadow 0.16s ease, transform 0.08s ease;
}

.primary-button,
.primary-link {
    border: 1px solid var(--ec-blue);
    background: var(--ec-blue);
    color: #fff;
}

.primary-button:hover,
.primary-link:hover {
    border-color: var(--ec-blue-hover);
    background: var(--ec-blue-hover);
    color: #fff;
    box-shadow: 0 5px 14px rgba(37, 99, 235, 0.18);
}

.secondary-button,
.secondary-link {
    border: 1px solid var(--ec-line-strong);
    background: var(--ec-surface);
    color: #30445a;
}

.secondary-button:hover,
.secondary-link:hover {
    border-color: #7f96ad;
    background: #f4f7fa;
    color: var(--ec-blue-hover);
}

.danger-button {
    border: 1px solid var(--ec-red);
    background: var(--ec-red);
    color: #fff;
}

.danger-button:hover {
    border-color: #a92e2e;
    background: #a92e2e;
    box-shadow: 0 5px 14px rgba(200, 58, 58, 0.18);
}

.primary-button:active,
.primary-link:active,
.secondary-button:active,
.secondary-link:active,
.danger-button:active,
button:not(:disabled):active {
    transform: translateY(1px);
}

.primary-button:disabled,
.secondary-button:disabled,
.danger-button:disabled,
button:disabled {
    cursor: not-allowed;
    box-shadow: none;
    opacity: 0.56;
}

.compact-button {
    min-width: 0;
    min-height: 34px;
    padding: 6px 11px;
    font-size: 13px;
}

button:not([class]) {
    min-height: 38px;
    padding: 7px 12px;
    border: 1px solid var(--ec-line-strong);
    border-radius: var(--ec-radius-control);
    background: var(--ec-surface);
    color: #30445a;
    font-weight: 650;
}

button:not([class]):hover {
    border-color: #7f96ad;
    background: #f4f7fa;
}

/* Application shell ------------------------------------------------------ */

.app-shell {
    min-height: 100dvh;
    grid-template-columns: 220px minmax(0, 1fr);
}

.app-sidebar {
    width: 220px;
    height: 100dvh;
    background: var(--ec-navy);
    box-shadow: 6px 0 24px rgba(9, 29, 48, 0.08);
}

.sidebar-brand {
    min-height: 92px;
    padding: 18px 18px 12px;
}

.sidebar-brand img {
    width: 178px;
    height: 58px;
    border-radius: 6px;
    box-shadow: none;
}

.app-sidebar .topnav {
    gap: 2px;
    padding: 8px 11px 18px;
}

.nav-group-label {
    padding: 12px 12px 6px;
    color: #91a4b7;
    font-size: 11px;
    font-weight: 650;
    letter-spacing: 0.1em;
}

.app-sidebar .app-nav-link {
    min-height: 44px;
    gap: 11px;
    padding: 9px 12px;
    border-radius: 6px;
    color: #d3deea;
    font-size: 14px;
}

.app-sidebar .app-nav-link:hover {
    background: rgba(255, 255, 255, 0.075);
}

.app-sidebar .app-nav-link.is-active {
    background: #1d3b56;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.035);
}

.app-sidebar .app-nav-link.is-active::before {
    left: -11px;
    width: 3px;
    border-radius: 0 2px 2px 0;
    background: var(--ec-red);
}

.app-sidebar .app-nav-link:focus-visible,
.nav-admin-group summary:focus-visible,
.sidebar-user button:focus-visible {
    outline-color: rgba(255, 255, 255, 0.48);
}

.nav-admin-group {
    border-color: rgba(255, 255, 255, 0.11);
}

.nav-admin-group summary {
    color: #a9bac9;
}

.sidebar-user {
    background: var(--ec-navy-deep);
}

.sidebar-user button {
    min-height: 32px;
    padding: 0;
    border: 0;
    background: transparent;
}

.user-avatar {
    border-radius: 9px;
    border-width: 1px;
}

.workspace-topbar {
    min-height: 58px;
    border-color: var(--ec-line);
    background: var(--ec-surface);
    box-shadow: 0 1px 4px rgba(16, 42, 67, 0.035);
    backdrop-filter: none;
}

.workspace-breadcrumb {
    color: #7b8a9a;
}

.workspace-breadcrumb strong {
    color: #26384b;
    font-weight: 650;
}

.global-search {
    height: 40px;
    border-color: var(--ec-line-strong);
    background: #f8fafc;
}

.global-search:focus-within {
    border-color: var(--ec-blue);
    background: #fff;
    box-shadow: 0 0 0 3px var(--ec-focus);
}

.global-search input {
    height: 36px !important;
    min-height: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
}

.topbar-icon-button,
.topbar-user {
    border-radius: 6px;
    transition: background-color 0.16s ease, color 0.16s ease;
}

.topbar-icon-button:hover,
.topbar-user:hover {
    background: var(--ec-blue-soft);
    color: var(--ec-blue-hover);
}

.topbar-user {
    padding: 0 10px 0 16px;
}

.is-authenticated {
    background: var(--ec-canvas);
}

.is-authenticated .page {
    max-width: 1520px;
    padding: 22px clamp(18px, 2vw, 32px) 48px;
}

/* Data-heavy pages need more horizontal room than reading and edit forms. */
.is-authenticated .page.page--wide {
    max-width: 1920px;
}

.page:focus {
    outline: 0;
}

.is-authenticated .page-heading {
    align-items: center;
    padding: 10px 0 20px;
}

/* Review closure: keep action labels above their controls and use wide screens. */
.review-issue-body {
    grid-template-columns: minmax(28rem, 1fr) minmax(36rem, 44rem);
    align-items: start;
}

.review-issue-main,
.review-issue-actions,
.review-issue-actions form {
    min-width: 0;
}

.review-issue-actions:has(form:nth-child(2)) {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.review-issue-actions form > label:not(.inline-check) {
    display: grid;
    gap: 7px;
    min-width: 0;
    color: var(--ec-ink-soft);
    font-size: 13px;
    font-weight: 650;
}

.review-issue-actions textarea {
    width: 100%;
    max-width: none;
    min-height: 96px;
    margin: 0;
}

.review-issue-actions form > button {
    width: 100%;
}

.review-issue-actions .inline-check {
    min-height: 32px;
}

.is-authenticated .page-heading h1,
.dashboard-page-heading h1 {
    color: var(--ec-ink);
    font-size: clamp(26px, 2vw, 32px);
    font-weight: 680;
    letter-spacing: -0.035em;
}

.eyebrow {
    color: var(--ec-blue-hover);
    font-size: 12px;
    font-weight: 750;
    letter-spacing: 0.08em;
}

.summary,
.form-hint,
.muted {
    color: var(--ec-muted);
}

/* Surfaces, headings and feedback --------------------------------------- */

.table-panel,
.filter-panel,
.workflow-card,
.auth-card,
.dashboard-panel,
.dashboard-status-card,
.empty-state,
.approval-asset-card,
.seal-board,
.signature-placement-app,
.meta-panel > div,
.status-panel,
.product-category-card {
    border: 1px solid var(--ec-line);
    border-radius: var(--ec-radius);
    background: var(--ec-surface);
    box-shadow: var(--ec-shadow);
}

.filter-panel,
.auth-card,
.workflow-card {
    padding: 18px;
}

.table-section-heading,
.panel-heading-row,
.dashboard-panel-heading {
    border-color: var(--ec-line);
}

.panel-summary-row,
details > summary {
    border-radius: var(--ec-radius-control);
}

details > summary:hover {
    background: #f4f7fa;
}

.flash-list {
    position: relative;
    z-index: 4;
    gap: 8px;
    margin-bottom: 16px;
}

.flash {
    padding: 11px 14px;
    border: 1px solid var(--ec-line);
    border-left-width: 4px;
    border-radius: 6px;
    background: #fff;
    box-shadow: 0 4px 14px rgba(16, 42, 67, 0.055);
}

.flash-success {
    border-left-color: var(--ec-green);
    background: #f2faf6;
    color: #135f40;
}

.flash-error {
    border-left-color: var(--ec-red);
    background: #fff5f5;
    color: #8c2d2d;
}

.message-alert,
.production-dev-banner {
    border-radius: var(--ec-radius);
}

.badge,
.status-pill,
.nav-badge,
.verify-status-pill {
    border-radius: 5px;
    font-weight: 700;
}

.badge-active,
.badge-released,
.badge-approved {
    background: #eaf7f0;
    color: var(--ec-green);
}

.badge-warning {
    background: #fff6e7;
    color: var(--ec-amber);
}

.badge-error {
    background: #fff0f0;
    color: var(--ec-red);
}

.empty-state {
    min-height: 150px;
    display: grid;
    align-content: center;
    border-style: dashed;
    box-shadow: none;
    text-align: center;
}

.empty-state h2 {
    font-size: 20px;
}

/* Tables and lists ------------------------------------------------------- */

.table-panel {
    scrollbar-color: #b5c2ce transparent;
}

table {
    font-variant-numeric: tabular-nums;
}

th,
td {
    padding: 12px 14px;
    border-color: #e2e8ee;
}

th {
    background: #f2f5f8;
    color: #536477;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.015em;
}

tbody tr {
    transition: background-color 0.14s ease;
}

tbody tr:hover > td {
    background: #f7faff;
}

.table-panel tbody tr[data-row-href]:hover > td,
.table-panel tbody tr[data-row-href]:focus-visible > td {
    background: var(--ec-blue-soft);
}

.table-panel tbody tr[data-row-href]:focus-visible {
    outline: 3px solid var(--ec-focus);
    outline-offset: -3px;
}

.table-input {
    min-height: 36px !important;
    border-color: var(--ec-line-strong) !important;
    border-radius: 5px !important;
}

.table-input:focus-visible {
    border-color: var(--ec-blue) !important;
    outline: 0 !important;
    box-shadow: 0 0 0 3px var(--ec-focus) !important;
}

.pagination-bar {
    min-height: 52px;
    padding: 8px 12px;
    border-top: 1px solid var(--ec-line);
}

.pagination-bar a,
.pagination-bar span {
    font-variant-numeric: tabular-nums;
}

/* Authentication and guest views --------------------------------------- */

.guest-topbar {
    min-height: 74px;
    border-color: var(--ec-line);
    background: #fff;
}

.guest-brand img {
    width: 150px;
    height: 49px;
    object-fit: contain;
}

.guest-page {
    min-height: calc(100dvh - 74px);
    background:
        linear-gradient(rgba(37, 99, 235, 0.035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(37, 99, 235, 0.035) 1px, transparent 1px),
        var(--ec-canvas);
    background-size: 28px 28px;
}

.auth-layout {
    grid-template-columns: minmax(0, 1fr) minmax(340px, 390px);
    gap: clamp(36px, 8vw, 110px);
    align-items: center;
    padding: clamp(54px, 9vh, 100px) 0;
}

.auth-layout > div {
    max-width: 590px;
}

.auth-layout > div h1 {
    margin: 7px 0 10px;
    font-size: clamp(34px, 4vw, 52px);
    line-height: 1.08;
    letter-spacing: -0.045em;
}

.auth-layout > div .summary {
    max-width: 34rem;
    font-size: 16px;
}

.auth-card {
    gap: 9px;
    padding: 26px;
    border-top: 3px solid var(--ec-blue);
}

.auth-card label {
    margin-top: 5px;
    color: #314255;
    font-size: 13px;
    font-weight: 650;
}

.auth-card input,
.auth-card select,
.auth-card textarea {
    width: 100%;
    min-height: 44px;
    border-color: var(--ec-line-strong);
    border-radius: var(--ec-radius-control);
    background: #fff;
}

.auth-card .primary-button {
    width: 100%;
    min-height: 44px;
    margin-top: 9px;
}

.auth-card .form-hint {
    margin: 6px 0 0;
    text-align: center;
}

.upload-card {
    gap: 11px;
}

.upload-card .form-hint {
    margin: 6px 2px 0;
    text-align: left;
    line-height: 1.55;
}

.field-requirement {
    display: inline-flex;
    align-items: center;
    min-height: 20px;
    margin-left: 6px;
    padding: 1px 7px;
    border-radius: 4px;
    background: #eaf2ff;
    color: var(--ec-blue-dark);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.02em;
    vertical-align: 1px;
}

.field-requirement--optional {
    background: #eef2f6;
    color: #5b6b7e;
}

.upload-field {
    display: grid;
    gap: 0;
    margin-top: 3px;
    min-width: 0;
}

.file-picker {
    position: relative;
    display: grid;
    grid-template-columns: 28px auto minmax(0, 1fr);
    align-items: center;
    gap: 10px;
    min-height: 58px;
    margin-top: 8px;
    padding: 8px 12px;
    overflow: hidden;
    border: 1px dashed #9aacc0;
    border-radius: var(--ec-radius-control);
    background: #f8fafc;
    color: #314255;
    transition: border-color 160ms ease, background-color 160ms ease, box-shadow 160ms ease;
}

.file-picker:hover {
    border-color: #6f8fb5;
    background: #f3f7fc;
}

.file-picker:focus-within {
    border-color: var(--ec-blue);
    background: #f5f9ff;
    box-shadow: 0 0 0 3px var(--ec-blue-soft);
}

.file-picker.has-selection {
    border-style: solid;
    border-color: #76a0d4;
    background: #f5f9ff;
}

.file-picker input[type="file"] {
    position: absolute;
    inset: 0;
    z-index: 2;
    width: 100%;
    height: 100%;
    min-height: 0;
    padding: 0;
    cursor: pointer;
    opacity: 0;
}

.file-picker__icon {
    display: grid;
    width: 28px;
    height: 28px;
    place-items: center;
    border-radius: 6px;
    background: #e7f0ff;
    color: var(--ec-blue);
}

.file-picker__icon svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.8;
}

.file-picker__action {
    color: #15385f;
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
}

.file-picker__status {
    min-width: 0;
    overflow: hidden;
    color: #6a7889;
    font-size: 13px;
    text-align: right;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-picker.has-selection .file-picker__status {
    color: #25496f;
    font-weight: 600;
}

.upload-empty-project {
    padding: 9px 11px;
    border-left: 3px solid var(--ec-warning);
    background: #fff9eb;
    color: #715313;
}

.upload-empty-project a {
    margin: 0 3px;
    font-weight: 700;
}

/* Dashboard -------------------------------------------------------------- */

.dashboard-status-grid {
    gap: 12px;
}

.dashboard-status-card {
    min-height: 96px;
    gap: 14px;
    padding: 16px 18px;
    box-shadow: none;
}

.dashboard-status-card:hover {
    border-color: #9fb4c9;
    box-shadow: 0 8px 20px rgba(16, 42, 67, 0.07);
}

.status-card-icon {
    width: 46px;
    height: 46px;
    flex-basis: 46px;
    border-radius: 8px;
    font-size: 21px;
}

.status-blue .status-card-icon { background: #eaf2ff; color: var(--ec-blue); }
.status-orange .status-card-icon { background: #fff4e3; color: var(--ec-amber); }
.status-green .status-card-icon { background: #eaf7f0; color: var(--ec-green); }
.status-red .status-card-icon { background: #fff0f0; color: var(--ec-red); }

.dashboard-status-card strong {
    color: var(--ec-ink);
    font-family: var(--ec-data-font);
    font-variant-numeric: tabular-nums;
}

.dashboard-panel,
.dashboard-status-card {
    border-radius: var(--ec-radius);
}

/* Production secondary navigation uses a compact control-strip treatment. */

.production-subnav {
    gap: 4px;
    margin-bottom: 20px;
    padding: 4px;
    border: 1px solid var(--ec-line);
    border-radius: var(--ec-radius);
    background: #eaf0f5;
}

.production-subnav a {
    min-height: 38px;
    padding: 7px 12px;
    border: 0;
    border-radius: 5px;
    background: transparent;
    color: #42556a;
    font-size: 13px;
    font-weight: 650;
    transition: background-color 0.16s ease, color 0.16s ease, box-shadow 0.16s ease;
}

.production-subnav a:hover {
    background: rgba(255, 255, 255, 0.72);
    color: var(--ec-blue-hover);
}

.production-subnav a.is-active {
    background: #fff;
    color: var(--ec-blue-hover);
    box-shadow: 0 1px 3px rgba(16, 42, 67, 0.11);
}

/* Dialogs --------------------------------------------------------------- */

dialog {
    color: var(--ec-ink);
}

dialog::backdrop {
    background: rgba(9, 29, 48, 0.56);
}

.bom-edit-dialog,
.bom-prototype-editor {
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 10px;
    box-shadow: var(--ec-shadow-dialog);
}

.bom-dialog-form > header,
.bom-dialog-form > footer,
.bom-prototype-editor-head,
.bom-prototype-editor-actions {
    background: #fbfcfd;
    border-color: var(--ec-line);
}

/* BOM engineering workbench --------------------------------------------- */

.page:has(.bom-prototype-shell) {
    max-width: none;
    padding: 20px;
}

.bom-prototype-shell {
    --bp-nav: var(--ec-navy);
    --bp-blue: var(--ec-blue);
    --bp-blue2: var(--ec-blue-soft);
    --bp-ink: var(--ec-ink);
    --bp-muted: var(--ec-muted);
    --bp-line: var(--ec-line);
    --bp-bg: var(--ec-canvas);
    --bp-paper: var(--ec-surface);
    --bp-warn: var(--ec-amber);
    --bp-bad: var(--ec-red);
    --bp-ok: var(--ec-green);
    margin: -20px;
    background: var(--ec-canvas);
    font-family: var(--ec-font);
}

.bom-prototype-top {
    display: grid;
    height: auto;
    min-height: 60px;
    grid-template-columns: auto minmax(260px, 1fr) auto;
    gap: 0;
    padding: 0;
    border-bottom: 1px solid var(--ec-line);
    background: #fff;
    color: var(--ec-ink);
}

.bom-prototype-brand,
.bom-prototype-file,
.bom-prototype-stats {
    display: flex;
    min-width: 0;
    min-height: 60px;
    align-items: center;
    padding: 9px 14px;
}

.bom-prototype-brand {
    border-right: 1px solid var(--ec-line);
    font-size: 17px;
}

.bom-prototype-tag {
    margin-left: 8px;
    border-color: #9bbcf7;
    border-radius: 5px;
    background: var(--ec-blue-soft);
    color: var(--ec-blue-hover);
}

.bom-prototype-file {
    color: #4f6073;
    font-family: var(--ec-data-font);
    font-variant-numeric: tabular-nums;
}

.bom-prototype-stats {
    margin-left: 0;
    gap: 7px;
    border-left: 1px solid var(--ec-line);
}

.bom-prototype-stat,
.bom-prototype-draft {
    padding: 5px 8px;
    border-radius: 4px;
    background: #f2f5f8;
    color: #405267;
    font-size: 12px;
    font-variant-numeric: tabular-nums;
}

.bom-prototype-draft {
    background: #edf8f3;
    color: var(--ec-green);
}

.bom-prototype-top-btn {
    min-height: 34px;
    display: inline-flex;
    align-items: center;
    padding: 6px 10px;
    border: 1px solid var(--ec-line-strong);
    border-radius: 5px;
    background: #fff;
    color: #30445a;
    font-size: 12px;
    font-weight: 650;
}

.bom-prototype-top-btn:hover {
    border-color: #7f96ad;
    background: #f4f7fa;
    color: var(--ec-blue-hover);
}

.bom-prototype-top-btn:last-child {
    border-color: var(--ec-blue);
    background: var(--ec-blue);
    color: #fff;
}

.bom-prototype-top-btn:last-child:hover {
    background: var(--ec-blue-hover);
}

.bom-prototype-app {
    height: calc(100dvh - 138px);
    gap: 8px;
    padding: 8px;
}

.bom-prototype-panel {
    border-color: var(--ec-line);
    border-radius: var(--ec-radius);
    box-shadow: none;
}

.bom-prototype-catalog-head,
.bom-prototype-filters,
.bom-prototype-viewer-head,
.bom-prototype-summary,
.bom-prototype-tabs,
.bom-prototype-footer {
    border-color: var(--ec-line);
}

.bom-prototype-search,
.bom-prototype-bom-tools input,
.bom-prototype-form-grid input,
.bom-prototype-form-grid textarea,
.bom-prototype-form-grid select {
    min-height: 38px;
    border-color: var(--ec-line-strong);
    border-radius: 5px;
    outline: 0;
}

.bom-prototype-search:focus-visible,
.bom-prototype-bom-tools input:focus-visible,
.bom-prototype-form-grid input:focus-visible,
.bom-prototype-form-grid textarea:focus-visible,
.bom-prototype-form-grid select:focus-visible {
    border-color: var(--ec-blue);
    box-shadow: 0 0 0 3px var(--ec-focus);
}

.bom-prototype-filter {
    min-height: 30px;
    border-radius: 5px;
    font-size: 11px;
}

.bom-prototype-filter.active {
    border-color: var(--ec-navy);
    background: var(--ec-navy);
}

.bom-prototype-page-item {
    min-height: 48px;
    border-radius: 5px;
}

.bom-prototype-page-item.active {
    background: var(--ec-blue-soft);
    box-shadow: inset 3px 0 var(--ec-blue);
}

.bom-prototype-icon,
.bom-prototype-row-action,
.bom-prototype-btn {
    border-color: var(--ec-line-strong);
    border-radius: 5px;
    background: #fff;
    color: #30445a;
}

.bom-prototype-icon:hover,
.bom-prototype-row-action:hover,
.bom-prototype-btn:hover {
    border-color: #7f96ad;
    background: #f4f7fa;
    color: var(--ec-blue-hover);
}

.bom-prototype-icon:focus-visible,
.bom-prototype-row-action:focus-visible,
.bom-prototype-btn:focus-visible,
.bom-prototype-tab:focus-visible,
.bom-prototype-filter:focus-visible,
.bom-prototype-page-item:focus-visible,
.bom-prototype-field:focus-visible,
.bom-prototype-clickable:focus-visible,
.bom-data-row[role="button"]:focus-visible {
    outline: 3px solid var(--ec-focus);
    outline-offset: -1px;
}

.bom-prototype-canvas,
.bom-drawing-stage {
    background-color: #e9eef3;
    background-image:
        linear-gradient(rgba(65, 91, 117, 0.065) 1px, transparent 1px),
        linear-gradient(90deg, rgba(65, 91, 117, 0.065) 1px, transparent 1px);
    background-size: 24px 24px;
}

.bom-prototype-drawing img,
.bom-drawing-stage > img {
    box-shadow: 0 5px 20px rgba(16, 42, 67, 0.18);
}

.bom-prototype-type,
.bom-prototype-candidate,
.bom-prototype-status,
.bom-review-badges span,
.bom-count-badge,
.bom-row-state,
.bom-mini-status span,
.bom-maintenance-status span {
    border-radius: 4px;
}

.bom-prototype-fields {
    gap: 6px;
}

.bom-prototype-field {
    min-height: 50px;
    border-radius: 5px;
}

.bom-prototype-field:not(:disabled):hover {
    border-color: #9bbcf7;
    background: #f5f8ff;
}

.bom-prototype-tabs {
    gap: 4px;
    padding: 0 10px;
}

.bom-prototype-tab {
    min-height: 42px;
    padding: 0 10px;
    border-radius: 0;
}

.bom-prototype-tab:hover {
    background: #f4f7fa;
    color: var(--ec-blue-hover);
}

.bom-prototype-table {
    font-variant-numeric: tabular-nums;
}

.bom-prototype-table th,
.bom-prototype-table td {
    border-color: #e2e8ee;
}

.bom-prototype-table th {
    background: #f2f5f8;
    color: #526477;
}

.bom-prototype-clickable:hover,
.bom-prototype-clickable:focus {
    background: var(--ec-blue-soft);
    outline: 0;
}

.bom-prototype-empty,
.bom-page-empty-state {
    border-color: #c7d3de;
    background: #f8fafc;
}

.bom-prototype-create-panel {
    border-color: #afc5e9;
    border-left-color: var(--ec-blue);
    background: #f4f7fc;
}

.bom-prototype-create-option.primary {
    border-color: #9eb9e8;
    box-shadow: inset 0 3px var(--ec-blue);
}

.bom-prototype-footer {
    background: #fbfcfd;
}

.bom-prototype-btn.primary {
    border-color: var(--ec-blue);
    background: var(--ec-blue);
}

.bom-data-row[role="button"]:focus {
    outline: 0;
    background: var(--ec-blue-soft);
}

/* Responsive behavior --------------------------------------------------- */

@media (max-width: 1180px) {
    .workspace-topbar {
        grid-template-columns: minmax(150px, 1fr) minmax(220px, 340px) 42px auto;
    }

    .bom-prototype-top {
        grid-template-columns: auto minmax(180px, 1fr);
    }

    .bom-prototype-stats {
        grid-column: 1 / -1;
        min-height: 48px;
        border-top: 1px solid var(--ec-line);
        border-left: 0;
        justify-content: flex-end;
    }

    .bom-prototype-brand,
    .bom-prototype-file {
        min-height: 54px;
    }

    .bom-prototype-app {
        height: calc(100dvh - 180px);
    }
}

@media (max-width: 1380px) {
    .review-issue-body {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 900px) {
    .auth-layout {
        grid-template-columns: 1fr;
        max-width: 620px;
        margin: 0 auto;
        gap: 28px;
        padding: 42px 0;
    }

    .auth-layout > div h1 {
        font-size: 36px;
    }

    .bom-prototype-app {
        height: auto;
    }
}

@media (max-width: 720px) {
    html {
        scroll-behavior: auto;
    }

    .is-authenticated .page,
    .guest-page {
        padding-left: 14px;
        padding-right: 14px;
    }

    .workspace-topbar {
        min-height: 58px;
        grid-template-columns: minmax(0, 1fr) 44px 44px;
        gap: 4px;
        padding: 7px 10px;
        background: #fff;
        color: var(--ec-ink);
    }

    .mobile-brand {
        color: var(--ec-ink);
    }

    .workspace-topbar .mobile-nav-toggle,
    .topbar-icon-button {
        color: #30445a;
    }

    .workspace-topbar .mobile-nav-toggle:hover,
    .topbar-icon-button:hover {
        background: var(--ec-blue-soft);
        color: var(--ec-blue-hover);
    }

    .topbar-notification-count {
        border-color: #fff;
    }

    .app-sidebar {
        width: min(82vw, 320px);
    }

    .mobile-nav-toggle,
    .topbar-icon-button,
    .app-sidebar .app-nav-link,
    .sidebar-close,
    .primary-button,
    .primary-link,
    .secondary-button,
    .secondary-link,
    .danger-button,
    button:not([class]),
    input:not([type="hidden"]):not([type="checkbox"]):not([type="radio"]),
    select {
        min-height: 44px;
    }

    .compact-button {
        min-height: 44px;
        padding: 8px 12px;
    }

    .page-heading {
        align-items: stretch;
    }

    .page-heading > :last-child,
    .page-heading .action-row {
        width: 100%;
    }

    .page-heading .primary-link,
    .page-heading .secondary-link,
    .page-heading .primary-button,
    .page-heading .secondary-button {
        flex: 1 1 auto;
    }

    .filter-panel {
        padding: 14px;
    }

    .table-scroll-hint {
        color: var(--ec-muted);
    }

    .production-subnav {
        flex-wrap: nowrap;
        overflow-x: auto;
        overscroll-behavior-x: contain;
        scrollbar-width: thin;
    }

    .review-issue-actions:has(form:nth-child(2)) {
        grid-template-columns: 1fr;
    }

    .review-issue-actions .inline-check {
        min-height: 44px;
    }

    .production-subnav a {
        min-height: 44px;
        flex: 0 0 auto;
    }

    .table-panel,
    .dashboard-table-wrap {
        max-width: 100%;
        overflow-x: auto;
        overscroll-behavior-x: contain;
    }

    .dashboard-section-title-row > a,
    .dashboard-panel-heading > a,
    .dashboard-panel-footer > a,
    .table-actions a,
    td:last-child > a {
        display: inline-flex;
        min-width: 44px;
        min-height: 44px;
        align-items: center;
        justify-content: center;
        padding-inline: 8px;
    }

    .guest-topbar {
        padding-inline: 14px;
    }

    .guest-brand img {
        width: 132px;
        height: auto;
    }

    .guest-brand span {
        padding-left: 12px;
    }

    .auth-card {
        padding: 20px;
    }

    .file-picker {
        grid-template-columns: 28px minmax(0, 1fr);
    }

    .file-picker__status {
        grid-column: 1 / -1;
        padding-left: 38px;
        text-align: left;
    }

    .bom-prototype-shell {
        margin: -14px;
    }

    .bom-prototype-top {
        display: block;
    }

    .bom-prototype-brand,
    .bom-prototype-file,
    .bom-prototype-stats {
        min-height: 48px;
        border-right: 0;
        border-left: 0;
    }

    .bom-prototype-file {
        display: flex;
        border-top: 1px solid var(--ec-line);
    }

    .bom-prototype-stats {
        justify-content: flex-start;
        overflow-x: auto;
    }

    .bom-prototype-app {
        padding: 6px;
    }

    .bom-prototype-icon,
    .bom-prototype-row-action,
    .bom-prototype-btn,
    .bom-prototype-filter,
    .bom-prototype-tab {
        min-height: 44px;
    }

    .bom-prototype-tabpage {
        overflow-x: auto;
    }

    .bom-prototype-table {
        min-width: 720px;
    }

    .bom-prototype-table th:nth-child(4),
    .bom-prototype-table td:nth-child(4),
    .bom-prototype-table th:nth-child(6),
    .bom-prototype-table td:nth-child(6) {
        display: table-cell;
    }
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
