:root {
    --bg: #f6f7f9;
    --surface: #ffffff;
    --surface-muted: #f3f4f6;
    --sidebar: #fbfbfc;
    --border: #d7dbe3;
    --border-soft: #e8ebf0;
    --text: #111318;
    --muted: #626b7a;
    --muted-2: #89919f;
    --accent: #0a84ff;
    --accent-soft: #e8f0ff;
    --danger: #c2410c;
    --danger-soft: #fff1eb;
    --success: #147d4f;
    --shadow: 0 16px 40px rgba(20, 24, 32, 0.08);
    --row-shadow: 0 8px 22px rgba(20, 24, 32, 0.045);
}


* {
    box-sizing: border-box;
}

html {
    height: 100%;
    background: var(--bg);
}

body {
    height: 100%;
    margin: 0;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Inter", "Segoe UI", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 16px;
    line-height: 1.45;
    letter-spacing: 0;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

a {
    color: inherit;
}

.app {
    display: flex;
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
}

.sidebar {
    position: relative;
    display: flex;
    flex-direction: column;
    width: 280px;
    min-width: 280px;
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
    background: var(--sidebar);
    border-right: 1px solid var(--border-soft);
    padding: 28px 22px 18px;
}

.sidebar-logo {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 18px;
    padding-right: 2px;
}

.sidebar-logo img {
    display: block;
    width: min(220px, 96%);
    max-height: 110px;
    object-fit: contain;
}

.sidebar-title,
.logo {
    margin-bottom: 24px;
    font-size: 25px;
    font-weight: 700;
    color: var(--text);
}

.tree {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 22px;
}

.sidebar-scroll {
    flex: 1;
    min-height: 0;
    margin-right: -6px;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 0 6px 0 0;
    scrollbar-color: #c8ced8 transparent;
    scrollbar-width: thin;
}

.sidebar-scroll::-webkit-scrollbar,
.main::-webkit-scrollbar,
.agent-conversation::-webkit-scrollbar {
    width: 8px;
}

.sidebar-scroll::-webkit-scrollbar-thumb,
.main::-webkit-scrollbar-thumb,
.agent-conversation::-webkit-scrollbar-thumb {
    border: 2px solid transparent;
    border-radius: 999px;
    background: #c8ced8;
    background-clip: padding-box;
}

.catalog-menu-panel,
.tkp-menu-panel,
.compose-menu-panel {
    transform: translateX(26px);
    opacity: 0;
    pointer-events: none;
    max-height: 0;
    overflow: hidden;
    transition: opacity .42s ease, transform .48s ease, max-height .48s ease;
}

.catalog-menu-panel.is-active,
.tkp-menu-panel.is-active,
.compose-menu-panel.is-active {
    transform: translateX(0);
    opacity: 1;
    pointer-events: auto;
    max-height: 5000px;
}

.tkp-menu-panel,
.compose-menu-panel {
    display: flex;
    flex-direction: column;
    gap: 7px;
    margin-bottom: 22px;
}

.compose-menu-action {
    align-items: flex-start;
    justify-content: flex-start !important;
}

.compose-menu-current {
    margin: 8px 0 4px;
    padding: 12px 10px;
    border-top: 1px solid var(--border-soft);
    border-bottom: 1px solid var(--border-soft);
}

.compose-menu-current span,
.compose-menu-current strong {
    display: block;
}

.compose-menu-current span {
    margin-bottom: 3px;
    color: var(--muted-2);
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
}

.compose-menu-current strong {
    color: var(--text);
    font-size: 14px;
}

.tree-title {
    margin: 0;
    padding: 0 10px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--muted-2);
}

.tree-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.side-add-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border: 1px solid var(--border-soft);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    font-size: 20px;
    font-weight: 500;
    line-height: 1;
    text-decoration: none;
}

.side-add-button:hover {
    border-color: var(--border);
    background: var(--surface-muted);
}

.tree-section {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.tree-section-title {
    margin: 12px 0 7px;
    padding: 0 10px 0;
    color: #4f5866;
    font-size: 13px;
    font-weight: 800;
    letter-spacing: .05em;
    text-transform: uppercase;
}

.tree-section-title::after {
    content: "";
    display: block;
    width: 100%;
    height: 3px;
    margin-top: 9px;
    border-radius: 999px;
    background: #c5cbd5;
}

.tree-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-height: 46px;
    padding: 9px 10px;
    border-radius: 8px;
    color: var(--muted);
    font-size: 15px;
    text-decoration: none;
    font-weight: 700;
}

.tree-item small {
    color: var(--muted-2);
    font-size: 12px;
    font-weight: 500;
}

.tree-item:hover {
    background: var(--surface-muted);
    color: var(--text);
}

.tree-item.active {
    background: var(--accent-soft);
    color: var(--accent);
}

.tkp-item.is-active {
    background: var(--accent-soft);
    color: var(--accent);
}

.tree-empty {
    padding: 12px 10px;
    color: var(--muted-2);
    font-size: 13px;
}

.trash-link {
    display: block;
    margin-top: 18px;
    padding: 11px 10px;
    border-radius: 8px;
    color: var(--danger);
    background: var(--danger-soft);
    font-weight: 700;
    text-decoration: none;
}

.rate-box {
    margin-top: 26px;
    margin-bottom: 16px;
    padding: 14px;
    border: 1px solid var(--border-soft);
    border-radius: 8px;
    background: var(--surface);
    color: var(--muted);
    font-size: 13px;
    line-height: 1.8;
}

.rate-box.catalog-menu-panel {
    transform: translateY(12px);
    transition: opacity .42s ease, transform .48s ease, max-height .48s ease;
}

.rate-box.catalog-menu-panel.is-active {
    transform: translateY(0);
}

.sidebar-account {
    position: static;
    flex: none;
    width: 100%;
    display: grid;
    grid-template-columns: 38px 1fr 34px;
    align-items: center;
    gap: 10px;
    margin-top: 12px;
    padding: 12px;
    border: 1px solid var(--border-soft);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.78);
    box-shadow: 0 10px 24px rgba(20, 24, 32, 0.05);
}

.account-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 8px;
    background: var(--text);
    color: white;
    font-size: 14px;
    font-weight: 800;
}

.account-meta {
    min-width: 0;
}

.account-meta strong,
.account-meta span {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.account-meta strong {
    color: var(--text);
    font-size: 14px;
    font-weight: 800;
}

.account-meta span {
    color: var(--muted-2);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

.logout-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    color: var(--muted);
    text-decoration: none;
    font-size: 16px;
    font-weight: 800;
}

.logout-link:hover {
    background: var(--surface-muted);
    color: var(--text);
}

.rate-box small {
    display: block;
    margin-top: 4px;
    color: var(--muted-2);
    line-height: 1.4;
}

.rate-form {
    margin-top: 10px;
}

.rate-form button {
    width: 100%;
    min-height: 34px;
    padding: 7px 10px;
    font-size: 13px;
}

.main {
    flex: 1;
    min-width: 0;
    height: 100dvh;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 34px 24px 34px 34px;
    scrollbar-color: #c8ced8 transparent;
    scrollbar-width: thin;
}

.copilot-panel {
    width: 20vw;
    min-width: 280px;
    max-width: 380px;
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
    padding: 18px 18px 18px 0;
}

.topbar {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 24px;
}

.catalog-view,
.tkp-view,
.compose-view {
    display: none;
}

.catalog-view.is-active,
.tkp-view.is-active,
.compose-view.is-active {
    display: block;
}

.tkp-view,
.compose-view {
    padding-bottom: 30px;
}

.tkp-topbar,
.section-heading-row,
.proposal-heading-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
}

.tkp-topbar {
    align-items: center;
    margin-bottom: 22px;
}

.tkp-topbar-actions,
.tkp-empty-actions {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
}

.proposal-workspace {
    display: grid;
    gap: 14px;
}

.proposal-summary,
.proposal-spec-panel,
.proposal-versions,
.proposal-quicklook,
.knowledge-library,
.tkp-empty-state,
.compose-empty-state {
    border: 1px solid var(--border-soft);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.88);
}

.proposal-summary {
    padding: 26px 28px;
}

.proposal-quicklook {
    padding: 22px 24px 24px;
}

.quicklook-heading,
.compose-current-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.quicklook-heading {
    margin-bottom: 16px;
}

.quicklook-heading h2 {
    margin: 4px 0 0;
    font-size: 19px;
}

.proposal-preview-frame {
    display: block;
    width: 100%;
    height: min(68vh, 760px);
    min-height: 520px;
    border: 1px solid var(--border-soft);
    border-radius: 7px;
    background: #f1f2f4;
}

.proposal-preview-text {
    max-height: 680px;
    margin: 0;
    overflow: auto;
    padding: 24px;
    border: 1px solid var(--border-soft);
    border-radius: 7px;
    background: #fafbfc;
    color: #303641;
    font-family: "SFMono-Regular", Consolas, monospace;
    font-size: 12px;
    line-height: 1.65;
    white-space: pre-wrap;
}

.proposal-preview-empty {
    display: grid;
    min-height: 220px;
    place-items: center;
    border: 1px dashed var(--border);
    border-radius: 7px;
    background: #fafbfc;
    color: var(--muted-2);
    font-size: 13px;
}

.compose-current-heading {
    margin-bottom: 14px;
    padding: 17px 20px;
    border-top: 1px solid var(--border-soft);
    border-bottom: 1px solid var(--border-soft);
}

.compose-current-heading span,
.compose-current-heading strong,
.compose-current-heading small {
    display: block;
}

.compose-current-heading span {
    color: var(--muted-2);
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
}

.compose-current-heading strong {
    margin-top: 2px;
    font-size: 17px;
}

.compose-current-heading small {
    margin-top: 2px;
    color: var(--muted);
    font-size: 13px;
}

.compose-empty-state {
    padding: 34px 28px;
    text-align: center;
}

.compose-empty-state h2 {
    margin: 5px 0 0;
    font-size: 20px;
}

#compose-spec,
#compose-versions,
#compose-knowledge,
#compose-template,
#compose-brandbook {
    scroll-margin-top: 24px;
}

.proposal-heading-row h2 {
    margin: 8px 0 3px;
    font-size: 22px;
}

.proposal-heading-row p,
.proposal-spec-panel p,
.tkp-empty-state p {
    margin: 3px 0 0;
}

.proposal-heading-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 7px;
}

.document-format-link {
    min-width: 58px;
    text-align: center;
}

.proposal-cover-preview {
    width: 52px;
    height: 52px;
    object-fit: contain;
    border: 1px solid var(--border-soft);
    border-radius: 8px;
    background: white;
}

.status-badge,
.index-status {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 3px 8px;
    border-radius: 6px;
    background: var(--surface-muted);
    color: var(--muted);
    font-size: 11px;
    font-style: normal;
    font-weight: 800;
    text-transform: uppercase;
}

.status-ready,
.index-indexed {
    background: #e8f5ee;
    color: var(--success);
}

.index-needs_ocr {
    background: #fff4df;
    color: #8a5a00;
}

.index-processing,
.index-ocr_processing {
    background: #e8f0ff;
    color: var(--accent);
}

.index-failed {
    background: var(--danger-soft);
    color: var(--danger);
}

.index-stored {
    background: #eef2f7;
    color: #5f6c7b;
}

.proposal-facts {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1px;
    margin-top: 24px;
    overflow: hidden;
    border: 1px solid var(--border-soft);
    border-radius: 8px;
    background: var(--border-soft);
}

.proposal-facts div {
    min-width: 0;
    padding: 13px 14px;
    background: #fafbfc;
}

.proposal-facts span,
.proposal-facts strong {
    display: block;
}

.proposal-facts span {
    margin-bottom: 3px;
    color: var(--muted-2);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
}

.proposal-facts strong {
    overflow: hidden;
    color: var(--text);
    font-size: 13px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.document-extract {
    margin-top: 18px;
    border-top: 1px solid var(--border-soft);
    padding-top: 16px;
}

.document-extract summary {
    cursor: pointer;
    color: var(--accent);
    font-size: 13px;
    font-weight: 700;
}

.document-extract pre {
    max-height: 360px;
    margin: 14px 0 0;
    overflow: auto;
    padding: 16px;
    border-radius: 8px;
    background: var(--surface-muted);
    color: #303641;
    font-family: "SFMono-Regular", Consolas, monospace;
    font-size: 12px;
    line-height: 1.6;
    white-space: pre-wrap;
}

.notice {
    margin-top: 18px;
    padding: 12px 14px;
    border-radius: 8px;
    background: #fff4df;
    color: #744b00;
    font-size: 13px;
}

.proposal-spec-panel {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(300px, .8fr);
    align-items: center;
    gap: 24px;
    padding: 22px 28px;
}

.proposal-spec-panel h2 {
    margin-top: 4px;
}

.proposal-versions {
    padding: 22px 28px;
}

.proposal-versions button:disabled {
    cursor: not-allowed;
    opacity: .45;
}

.generation-note {
    margin-top: 14px;
    padding: 10px 12px;
    border-radius: 8px;
    background: var(--surface-muted);
    color: var(--muted);
    font-size: 12px;
}

.version-list {
    margin-top: 15px;
    border-top: 1px solid var(--border-soft);
}

.version-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    min-height: 62px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-soft);
}

.version-row strong,
.version-row span {
    display: block;
}

.version-row strong {
    font-size: 14px;
}

.version-row > div:first-child > span {
    margin-top: 2px;
    color: var(--muted-2);
    font-size: 12px;
}

.version-actions {
    display: flex;
    align-items: center;
    gap: 7px;
}

.version-actions form {
    margin: 0;
}

.status-approved {
    background: #e8f5ee;
    color: var(--success);
}

.version-empty {
    padding: 20px 0 4px;
    color: var(--muted-2);
    font-size: 13px;
}

.text-link {
    display: inline-block;
    margin-top: 9px;
    color: var(--accent);
    font-size: 13px;
    font-weight: 700;
    text-decoration: none;
}

.compact-upload {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
}

.compact-upload input[type="file"] {
    min-width: 0;
    padding: 8px;
    border: 1px dashed var(--border);
    border-radius: 8px;
    background: #fafbfc;
    color: var(--muted);
    font-size: 12px;
}

.knowledge-library {
    margin-top: 14px;
    padding: 24px 28px;
}

.section-heading-row {
    align-items: center;
    margin-bottom: 16px;
}

.section-heading-row h2 {
    margin-top: 4px;
}

.knowledge-list {
    border-top: 1px solid var(--border-soft);
}

.knowledge-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 20px;
    min-height: 62px;
    padding: 10px 4px;
    border-bottom: 1px solid var(--border-soft);
    text-decoration: none;
}

.knowledge-row:hover strong {
    color: var(--accent);
}

.knowledge-download {
    min-width: 0;
    color: inherit;
    text-decoration: none;
}

.knowledge-row strong,
.knowledge-row span {
    display: block;
}

.knowledge-row strong {
    font-size: 14px;
}

.knowledge-row span {
    margin-top: 2px;
    color: var(--muted-2);
    font-size: 12px;
}

.knowledge-meta {
    display: flex;
    align-items: center;
    gap: 9px;
    text-align: right;
}

.knowledge-meta form {
    margin: 0;
}

.knowledge-icon-btn {
    display: inline-grid;
    width: 30px;
    height: 30px;
    min-height: 30px;
    padding: 0;
    place-items: center;
    border: 1px solid var(--border-soft);
    border-radius: 7px;
    background: white;
    color: var(--muted);
    font-size: 18px;
    line-height: 1;
}

.knowledge-icon-btn:hover {
    border-color: #b8c8df;
    background: #f3f7fc;
    color: var(--accent);
}

.knowledge-delete-btn:hover {
    border-color: #edc3c8;
    background: var(--danger-soft);
    color: var(--danger);
}

.knowledge-empty {
    padding: 26px 4px 8px;
    color: var(--muted-2);
    font-size: 13px;
}

.material-section + .material-section {
    margin-top: 10px;
}

.active-material-label {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 3px 8px;
    border-radius: 6px;
    background: #e8f5ee;
    color: var(--success);
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
}

.tkp-empty-state {
    padding: 48px 36px;
    text-align: center;
}

.tkp-empty-state h2 {
    margin: 5px 0;
    font-size: 22px;
}

.tkp-empty-state .button {
    margin-top: 18px;
}

.tkp-empty-actions {
    margin-top: 18px;
}

.tkp-empty-actions .button {
    margin-top: 0;
}

.eyebrow {
    margin: 0 0 5px;
    color: var(--muted-2);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .05em;
    text-transform: uppercase;
}

h1,
h2 {
    margin: 0;
    font-weight: 700;
    letter-spacing: 0;
    color: var(--text);
}

h1 {
    font-size: 32px;
    line-height: 1.15;
    letter-spacing: 0;
}

h2 {
    font-size: 19px;
}

p {
    color: var(--muted);
}

.button,
button,
.secondary-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 10px 15px;
    font: inherit;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
}

.button,
button {
    background: var(--text);
    color: white;
}

.button:hover,
button:hover {
    background: #2b2d33;
}

button.sidebar-mode-toggle {
    justify-content: flex-start;
    width: 100%;
    min-height: 34px;
    border: 0;
    padding: 2px 0;
    background: transparent;
    color: var(--text);
    font-size: 25px;
    text-align: left;
    transition: color .18s ease, transform .18s ease;
}

button.sidebar-mode-toggle:hover {
    background: transparent;
    color: var(--accent);
    outline: 0;
    transform: translateX(2px);
}

button.sidebar-mode-toggle:focus {
    background: transparent;
    color: var(--text);
    outline: 0;
}

button.tree-item {
    align-items: flex-start;
    justify-content: center;
    width: 100%;
    border: 0;
    background: transparent;
    color: var(--muted);
    text-align: left;
}

button.tree-item:hover,
button.tree-item:focus {
    background: var(--surface-muted);
    color: var(--text);
    outline: 0;
}

.secondary-btn {
    color: var(--text);
    background: var(--surface);
    border-color: var(--border);
}

.secondary-btn:hover {
    background: var(--surface-muted);
}

.table-shell,
.card {
    overflow: hidden;
    border: 1px solid var(--border-soft);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.catalog-shell {
    padding: 10px;
    border-color: transparent;
    background: rgba(255, 255, 255, 0.78);
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.catalog-table {
    border-collapse: separate;
    border-spacing: 0 6px;
    min-width: 920px;
}

.catalog-table .col-position {
    width: 210px;
}

.catalog-table .col-code {
    width: 108px;
}

.catalog-table .col-price {
    width: 92px;
}

.catalog-table .col-date {
    width: 110px;
}

.catalog-table .col-drawings {
    width: 164px;
}

.catalog-table .col-edit {
    width: 50px;
}

th,
td {
    border-bottom: 1px solid var(--border-soft);
    padding: 9px 12px;
    vertical-align: middle;
    overflow-wrap: anywhere;
}

th {
    background: #fafbfc;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .03em;
    text-align: left;
    text-transform: uppercase;
}

.catalog-table th {
    border-bottom: 0;
    background: transparent;
    color: var(--muted-2);
    font-size: 14px;
    font-weight: 800;
    letter-spacing: .06em;
}

td {
    color: #2b2f38;
    font-size: 15px;
}

tbody tr:last-child td {
    border-bottom: 0;
}

.catalog-table td {
    border-top: 1px solid var(--border-soft);
    border-bottom: 1px solid var(--border-soft);
    background: var(--surface);
}

.catalog-table th:nth-child(3),
.catalog-table th:nth-child(4),
.catalog-table th:nth-child(5) {
    text-align: center;
}

.catalog-table th:nth-child(3) {
    border-radius: 6px;
    background: #f4f5f7;
    color: #343a44;
}

.catalog-table .catalog-item-row td:nth-child(3) {
    background: #f4f5f7;
    color: #171a20;
    font-weight: 760;
}

.catalog-table tbody tr:last-child td {
    border-bottom: 1px solid var(--border-soft);
}

.catalog-table .catalog-item-row td:first-child {
    border-left: 1px solid var(--border-soft);
    border-radius: 8px 0 0 8px;
}

.catalog-table .catalog-item-row td:last-child {
    border-right: 1px solid var(--border-soft);
    border-radius: 0 8px 8px 0;
}

.catalog-item-row:hover td {
    border-color: #cfd5df;
    box-shadow: var(--row-shadow);
}

.factory-group-row td {
    padding: 13px 0 3px;
    border: 0;
    background: transparent;
}

.factory-band {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 10px 14px;
    border: 1px solid var(--border-soft);
    border-radius: 8px;
    background: #eef2f7;
    color: var(--text);
}

.factory-band span {
    display: block;
    margin-bottom: 2px;
    color: var(--muted-2);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .06em;
    text-transform: uppercase;
}

.factory-band strong {
    display: block;
    font-size: 14px;
    line-height: 1.25;
}

.factory-band em {
    flex: 0 0 auto;
    padding: 5px 9px;
    border-radius: 8px;
    background: var(--surface);
    color: var(--muted);
    font-size: 12px;
    font-style: normal;
    font-weight: 800;
}

.position-cell {
    color: var(--text);
    font-weight: 700;
}

.catalog-table .price-cell {
    text-align: center;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.missing,
.no {
    color: var(--muted-2);
}

.yes {
    color: var(--success);
    font-weight: 700;
}

.drawing-link {
    display: inline-flex;
    align-items: center;
    min-height: 30px;
    padding: 5px 9px;
    border-radius: 8px;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 13px;
    font-weight: 700;
    text-decoration: none;
}

.drawing-link:hover {
    background: #dbe8ff;
}

.drawing-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 7px;
}

.download-list {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 5px;
}

.download-link {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 4px 8px;
    border: 1px solid var(--border-soft);
    border-radius: 8px;
    background: #fafbfc;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    text-decoration: none;
}

.download-link:hover {
    border-color: var(--border);
    background: var(--surface-muted);
    color: var(--text);
}

.drawing-menu-list {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    gap: 6px;
    white-space: nowrap;
}

.drawing-menu {
    position: relative;
    z-index: 20;
}

.drawing-menu-trigger {
    display: inline-flex;
    align-items: center;
    min-height: 32px;
    padding: 6px 10px;
    border: 0;
    border-radius: 8px;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 12px;
    font-weight: 800;
    list-style: none;
    cursor: pointer;
}

.drawing-menu-trigger:hover,
.drawing-menu-trigger:focus {
    background: var(--accent-soft);
    color: var(--accent);
    outline: 0;
}

.drawing-menu.is-open .drawing-menu-trigger,
.drawing-menu-trigger:focus {
    background: #dbe8ff;
}

.drawing-menu-panel {
    position: fixed;
    z-index: 1000;
    top: var(--drawing-menu-top, 0);
    left: var(--drawing-menu-left, 0);
    min-width: 126px;
    padding: 6px;
    border: 1px solid var(--border-soft);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow);
    opacity: 0;
    pointer-events: none;
    visibility: hidden;
    transition: opacity .12s ease, visibility .12s ease;
}

.drawing-menu-panel.is-visible {
    opacity: 1;
    pointer-events: auto;
    visibility: visible;
}

.drawing-menu-panel a {
    display: block;
    padding: 8px 9px;
    border-radius: 7px;
    color: var(--text);
    font-size: 13px;
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
}

.drawing-menu-panel a:hover {
    background: var(--surface-muted);
}

.drawing-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 26px;
    height: 26px;
    margin-left: 6px;
    border-radius: 999px;
    background: var(--surface-muted);
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.icon-btn,
.edit-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    color: var(--muted);
    text-decoration: none;
    font-size: 17px;
}

.copilot-card {
    position: static;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    height: 100%;
    min-height: 0;
    padding: 16px;
    border: 1px solid rgba(215, 219, 227, 0.78);
    border-radius: 8px;
    background: linear-gradient(180deg, #f2f3f5 0%, #f7f8fa 48%, #ffffff 100%);
    box-shadow: 0 16px 38px rgba(20, 24, 32, 0.07);
}

.agent-conversation {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 2px 0 14px;
    scrollbar-color: #c8ced8 transparent;
    scrollbar-width: thin;
}

.agent-message {
    margin-bottom: 10px;
    padding: 10px 11px;
    border: 1px solid var(--border-soft);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.9);
    color: #2c323c;
    font-size: 13px;
    line-height: 1.5;
    white-space: pre-wrap;
}

.agent-message-user {
    margin-left: 22px;
    border-color: #cdddf7;
    background: #edf4ff;
}

.agent-message-error {
    border-color: #f2c9bb;
    background: var(--danger-soft);
    color: var(--danger);
}

.agent-sources {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 9px;
    padding-top: 8px;
    border-top: 1px solid var(--border-soft);
}

.agent-sources a {
    color: var(--accent);
    font-size: 11px;
    font-weight: 700;
    text-decoration: none;
}

.copilot-compose {
    display: grid;
    grid-template-columns: 1fr 36px;
    align-items: center;
    gap: 8px;
    padding: 7px;
    border: 1px solid rgba(199, 205, 216, 0.82);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.92);
    box-shadow: 0 10px 26px rgba(20, 24, 32, 0.08);
}

.copilot-compose textarea {
    min-height: 36px;
    max-height: 120px;
    resize: none;
    border: 0;
    border-radius: 6px;
    background: transparent;
    padding: 8px;
    color: var(--text);
    font-size: 14px;
    font-weight: 550;
    font-family: inherit;
    line-height: 1.4;
}

.copilot-compose textarea:focus {
    outline: 0;
}

.copilot-compose button {
    width: 36px;
    min-height: 36px;
    padding: 0;
    border-radius: 8px;
    background: var(--text);
    color: white;
    font-size: 18px;
    line-height: 1;
}

.copilot-compose button:disabled {
    cursor: wait;
    opacity: .45;
}

.workspace-dialog {
    width: min(520px, calc(100vw - 32px));
    padding: 0;
    border: 1px solid var(--border-soft);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: 0 28px 80px rgba(18, 23, 33, .2);
}

.workspace-dialog-wide {
    width: min(680px, calc(100vw - 32px));
}

.workspace-dialog::backdrop {
    background: rgba(25, 30, 40, .28);
    backdrop-filter: blur(4px);
}

.workspace-dialog form {
    display: grid;
    gap: 15px;
    padding: 24px;
}

.dialog-heading,
.dialog-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.dialog-heading {
    margin-bottom: 4px;
}

.dialog-heading h2 {
    margin-top: 4px;
    font-size: 21px;
}

.dialog-close {
    width: 34px;
    min-height: 34px;
    padding: 0;
    border: 0;
    border-radius: 8px;
    background: var(--surface-muted);
    color: var(--muted);
    font-size: 22px;
    font-weight: 400;
}

.workspace-dialog label {
    display: grid;
    gap: 6px;
    color: #4c5564;
    font-size: 13px;
    font-weight: 700;
}

.workspace-dialog input,
.workspace-dialog select {
    width: 100%;
    min-height: 42px;
    padding: 9px 11px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: white;
    color: var(--text);
    font: inherit;
    font-size: 14px;
}

.workspace-dialog input:focus,
.workspace-dialog select:focus {
    border-color: var(--accent);
    outline: 3px solid rgba(10, 132, 255, .12);
}

.workspace-dialog .file-field input {
    min-height: 70px;
    border-style: dashed;
    background: #fafbfc;
}

.reference-compose {
    display: grid;
    grid-template-columns: auto minmax(90px, 150px) auto;
    align-items: center;
    justify-content: start;
    gap: 8px;
    min-height: 42px;
    padding: 0 11px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: white;
    color: var(--text);
    font-size: 14px;
    font-weight: 700;
}

.workspace-dialog .reference-compose input {
    min-height: 34px;
    padding: 4px 8px;
    border: 0;
    border-radius: 5px;
    background: var(--surface-muted);
    text-align: center;
}

.workspace-dialog .reference-compose input:focus {
    border: 0;
    outline: 2px solid rgba(10, 132, 255, .18);
}

.proposal-upload-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.workspace-dialog .dropzone {
    align-content: center;
    min-height: 132px;
    text-align: center;
}

.workspace-dialog .binary-option {
    display: flex;
    grid-template-columns: none;
    align-items: center;
    gap: 9px;
}

.workspace-dialog .binary-option input {
    width: 17px;
    min-height: 17px;
    margin: 0;
    padding: 0;
}

.dialog-actions {
    justify-content: flex-end;
    margin-top: 6px;
    padding-top: 16px;
    border-top: 1px solid var(--border-soft);
}

.icon-btn:hover,
.edit-btn:hover {
    background: var(--surface-muted);
    color: var(--text);
}

.empty-cell {
    padding: 34px 14px;
    color: var(--muted);
    text-align: center;
}

.form-page {
    min-height: 100vh;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 44px 20px;
}

.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px 20px;
    background: linear-gradient(180deg, #f5f6f8 0%, #ffffff 100%);
}

.login-card {
    width: min(430px, 100%);
    padding: 34px 30px 30px;
    border: 1px solid var(--border-soft);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.92);
    box-shadow: 0 22px 56px rgba(20, 24, 32, 0.09);
}

.login-logo {
    display: block;
    width: 286px;
    max-width: 100%;
    margin: 0 auto 12px;
}

.login-dept {
    margin: 0 0 32px;
    color: #20242b;
    font-family: "Palatino Linotype", "Book Antiqua", Georgia, serif;
    font-size: 36px;
    font-style: normal;
    font-weight: 400;
    letter-spacing: .02em;
    line-height: 1.2;
    text-align: center;
}

.login-error {
    padding: 10px 12px;
    border: 1px solid #f2a190;
    border-radius: 8px;
    background: var(--danger-soft);
    color: var(--danger);
    font-size: 13px;
    font-weight: 800;
}

.form-card {
    width: min(900px, 100%);
    padding: 26px;
    border: 1px solid var(--border-soft);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.narrow-form {
    width: min(620px, 100%);
}

.form-heading {
    margin-bottom: 22px;
}

form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

label {
    display: flex;
    flex-direction: column;
    gap: 7px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

input,
select,
textarea {
    width: 100%;
    min-height: 42px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    padding: 10px 12px;
    font: inherit;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--accent);
    outline: 3px solid rgba(37, 99, 235, 0.14);
}

input:disabled {
    background: var(--surface-muted);
    color: var(--muted);
}

textarea {
    min-height: 96px;
    resize: vertical;
}

input[type="file"] {
    padding: 8px;
}

.uppercase-input {
    text-transform: uppercase;
}

select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' fill='none' stroke='%23687083' stroke-width='2' viewBox='0 0 16 16'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
    background-position: right 12px center;
    background-repeat: no-repeat;
    background-size: 14px;
    padding-right: 34px;
}

.actions {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 8px;
}

.drawing-panel {
    margin-top: 24px;
    padding-top: 22px;
    border-top: 1px solid var(--border-soft);
}

.panel-heading {
    margin-bottom: 14px;
}

.panel-heading p {
    margin: 5px 0 0;
    font-size: 13px;
}

.upload-form {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
    margin-bottom: 14px;
}

.drawing-upload-panel {
    margin-top: 8px;
    padding: 18px;
    border: 1px solid var(--border-soft);
    border-radius: 8px;
    background: #fafbfc;
}

.drawing-drop-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.dropzone {
    position: relative;
    min-height: 118px;
    justify-content: center;
    gap: 6px;
    padding: 16px;
    border: 1px dashed #c6ccd8;
    border-radius: 8px;
    background: var(--surface);
    color: var(--muted);
    cursor: pointer;
    transition: border-color .15s ease, background .15s ease, color .15s ease;
}

.dropzone:hover,
.dropzone.dragover {
    border-color: var(--accent);
    background: var(--accent-soft);
    color: var(--accent);
}

.dropzone.has-file {
    border-style: solid;
    border-color: #b9c8e8;
    background: #f6f9ff;
}

.dropzone.has-error {
    border-color: #f2a190;
    background: var(--danger-soft);
}

.dropzone input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
    z-index: 1;
}

.dropzone-title {
    color: var(--text);
    font-size: 14px;
    font-weight: 800;
}

.dropzone-hint {
    font-size: 12px;
    font-weight: 650;
}

.dropzone-file {
    display: block;
    max-width: 100%;
    margin-top: 4px;
    color: var(--muted-2);
    font-size: 12px;
    font-weight: 600;
    overflow-wrap: anywhere;
}

.dropzone-error {
    min-height: 16px;
    color: var(--danger);
    font-size: 12px;
    font-weight: 700;
    overflow-wrap: anywhere;
}

.dropzone-clear {
    position: relative;
    z-index: 2;
    display: none;
    min-height: 28px;
    margin-top: 4px;
    padding: 5px 9px;
    border: 1px solid var(--border-soft);
    border-radius: 8px;
    background: var(--surface);
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
}

.dropzone-clear:hover {
    background: var(--surface-muted);
    color: var(--text);
}

.dropzone.has-file .dropzone-clear,
.dropzone.has-error .dropzone-clear {
    display: inline-flex;
}

.drawing-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.drawing-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 10px 12px;
    border: 1px solid var(--border-soft);
    border-radius: 8px;
    background: #fafbfc;
}

.drawing-file {
    display: flex;
    align-items: center;
    min-width: 0;
    gap: 10px;
    color: var(--text);
    font-weight: 650;
}

.drawing-variant {
    flex: 0 0 auto;
    color: var(--muted);
    font-size: 12px;
    font-weight: 750;
}

.drawing-file span:last-child {
    overflow-wrap: anywhere;
}

.drawing-type {
    flex: 0 0 auto;
    min-width: 46px;
    padding: 4px 7px;
    border-radius: 8px;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 12px;
    font-weight: 800;
    text-align: center;
}

.drawing-row-actions {
    display: flex;
    align-items: center;
    flex: 0 0 auto;
    gap: 8px;
}

.drawing-row form {
    margin: 0;
}

.compact-btn {
    min-height: 32px;
    padding: 6px 10px;
    font-size: 13px;
}

.row-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.row-actions form {
    margin: 0;
}

.empty-panel {
    padding: 16px;
    border: 1px dashed var(--border);
    border-radius: 8px;
    color: var(--muted);
    background: #fafbfc;
    text-align: center;
}

.delete-btn {
    width: 100%;
    margin-top: 18px;
    background: var(--danger-soft);
    color: var(--danger);
}

.delete-btn:hover {
    background: #ffe2d6;
}

.text-danger {
    min-height: 32px;
    padding: 6px 10px;
    background: transparent;
    color: var(--danger);
}

.text-danger:hover {
    background: var(--danger-soft);
}

.solid-danger {
    background: var(--danger-soft);
}

.viewer-page {
    min-height: 100vh;
    padding: 28px;
    background: var(--bg);
}

.viewer-topbar {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 18px;
}

.viewer-topbar p:last-child {
    margin: 8px 0 0;
    color: var(--muted);
    font-size: 14px;
    overflow-wrap: anywhere;
}

.viewer-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.viewer-shell {
    height: calc(100vh - 142px);
    min-height: 560px;
    overflow: hidden;
    border: 1px solid var(--border-soft);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.pdf-viewer {
    display: block;
    width: 100%;
    height: 100%;
    border: 0;
    background: var(--surface);
}

@media (max-width: 980px) {
    html,
    body {
        height: auto;
        overflow-y: auto;
        overflow-x: hidden;
    }

    .app {
        height: auto;
        min-height: 100vh;
        overflow: visible;
        flex-direction: column;
    }

    .sidebar {
        position: relative;
        width: 100%;
        min-width: 0;
        height: auto;
        min-height: 0;
        overflow: visible;
        border-right: 0;
        border-bottom: 1px solid var(--border-soft);
        padding-bottom: 24px;
    }

    .sidebar-account {
        position: static;
        margin-top: 18px;
    }

    .sidebar-scroll {
        flex: none;
        max-height: 58vh;
        margin-right: 0;
        overflow-y: auto;
        padding-right: 6px;
        padding-bottom: 0;
    }

    .main {
        height: auto;
        overflow: visible;
        padding: 24px 16px;
    }

    .copilot-panel {
        width: 100%;
        min-width: 0;
        height: auto;
        padding: 0 16px 24px;
    }

    .copilot-card {
        position: static;
        height: auto;
        min-height: 0;
    }

    .agent-conversation {
        max-height: 420px;
    }

    .topbar {
        flex-direction: column;
    }

    .viewer-topbar {
        flex-direction: column;
    }

    .table-shell {
        overflow-x: auto;
    }

    table {
        min-width: 980px;
    }

    .drawing-drop-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 680px) {
    .tkp-topbar,
    .section-heading-row,
    .proposal-heading-row {
        align-items: stretch;
        flex-direction: column;
    }

    .proposal-facts,
    .proposal-spec-panel,
    .compact-upload,
    .knowledge-row {
        grid-template-columns: 1fr;
    }

    .knowledge-meta {
        text-align: left;
    }

    .proposal-summary,
    .proposal-spec-panel,
    .proposal-versions,
    .proposal-quicklook,
    .knowledge-library {
        padding: 20px;
    }

    .quicklook-heading,
    .compose-current-heading {
        align-items: stretch;
        flex-direction: column;
    }

    .proposal-preview-frame {
        height: 62vh;
        min-height: 420px;
    }

    .version-row,
    .version-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .form-grid,
    .upload-form,
    .drawing-drop-grid,
    .proposal-upload-grid {
        grid-template-columns: 1fr;
    }

    .proposal-heading-actions {
        justify-content: flex-start;
    }

    .tkp-topbar-actions {
        justify-content: flex-start;
    }

    .form-card {
        padding: 20px;
    }

    .drawing-row,
    .drawing-row-actions,
    .viewer-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .drawing-row-actions,
    .viewer-actions {
        width: 100%;
    }

    .viewer-page {
        padding: 20px 14px;
    }

    .viewer-shell {
        height: calc(100vh - 220px);
        min-height: 420px;
    }

    h1 {
        font-size: 25px;
    }
}
