:root {
  --bg: #fafaf9;
  --surface: #ffffff;
  --surface-2: #f7f6f4;
  --border: #e7e5e4;
  --border-strong: #d6d3d1;
  --text: #0c0a09;
  --text-2: #44403c;
  --text-3: #78716c;
  --text-4: #a8a29e;
  --hover: #f5f5f4;
  --active: #ebe9e6;
  --row-hover: #f7f7f5;
  --accent-2: #1e40af;
  --green-bg: #dcfce7;
  --green-fg: #14532d;
  --amber-bg: #fef3c7;
  --amber-fg: #78350f;
  --red-bg: #fee2e2;
  --red-fg: #7f1d1d;
  --blue-bg: #dbeafe;
  --blue-fg: #1e3a8a;
  --gray-bg: #e7e5e4;
  --gray-fg: #44403c;
  --row-h: 40px;
  --header-h: 56px;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html, body { min-height: 100%; background: var(--bg); color: var(--text); font-family: var(--sans); font-size: 13px; line-height: 1.4; font-feature-settings: "ss01", "tnum"; }
button, input, select { font-family: inherit; font-size: inherit; color: inherit; }
a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }
.mono { font-family: var(--mono); font-feature-settings: "tnum"; }
.app { display: flex; flex-direction: column; min-height: 100vh; min-width: 1280px; }
.topbar { height: var(--header-h); display: flex; align-items: center; gap: 16px; padding: 0 20px; border-bottom: 1px solid var(--border); background: var(--surface); flex-shrink: 0; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 14px; }
.brand-mark { width: 22px; height: 22px; background: var(--text); display: grid; place-items: center; color: white; font-weight: 700; font-size: 11px; }
.sep { width: 1px; height: 20px; background: var(--border); }
.crumb { color: var(--text-3); display: flex; align-items: center; gap: 8px; }
.crumb a { color: var(--text-3); }
.crumb .arrow { color: var(--text-4); }
.crumb .current { color: var(--text); font-weight: 500; max-width: 620px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.spacer { flex: 1; }
.stats { display: flex; align-items: center; gap: 16px; color: var(--text-3); font-size: 12px; }
.stats b { color: var(--text); font-weight: 600; }
.logout { color: var(--text-3); font-size: 12px; }
.filterbar { display: flex; align-items: center; gap: 8px; padding: 10px 20px; border-bottom: 1px solid var(--border); background: var(--surface); flex-shrink: 0; flex-wrap: wrap; }
.search { position: relative; flex: 0 0 320px; }
.search input { width: 100%; height: 32px; padding: 0 10px 0 30px; border: 1px solid var(--border-strong); background: var(--surface); outline: none; }
.search input:focus { border-color: var(--text-2); }
.search .icon { position: absolute; left: 9px; top: 50%; transform: translateY(-50%); color: var(--text-3); pointer-events: none; }
.filter-group, .amount-range { display: flex; align-items: center; height: 32px; border: 1px solid var(--border-strong); background: var(--surface); }
.filter-group .label, .amount-range .label { padding: 0 10px; color: var(--text-3); font-size: 12px; border-right: 1px solid var(--border); height: 100%; display: flex; align-items: center; }
.filter-group select { border: none; background: transparent; padding: 0 26px 0 10px; height: 100%; outline: none; cursor: pointer; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10'%3E%3Cpath d='M2 4l3 3 3-3' stroke='%2378716c' stroke-width='1.2' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 8px center; }
.amount-range input { width: 90px; height: 100%; border: none; padding: 0 8px; outline: none; background: transparent; font-family: var(--mono); font-size: 12px; }
.amount-range .dash { color: var(--text-4); padding: 0 2px; }
.toggle { display: flex; align-items: center; gap: 6px; height: 32px; padding: 0 10px; border: 1px solid var(--border-strong); background: var(--surface); cursor: pointer; font-size: 12px; color: var(--text-2); user-select: none; }
.toggle:hover { background: var(--hover); }
.toggle.on { background: var(--text); color: white; border-color: var(--text); }
.toggle.disabled { opacity: 0.55; cursor: not-allowed; }
.toggle.disabled:hover { background: var(--surface); }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle .box { width: 12px; height: 12px; border: 1.5px solid currentColor; display: grid; place-items: center; }
.toggle.on .box::after { content: ""; width: 6px; height: 6px; background: currentColor; }
.btn, .reset-btn { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border: 1px solid var(--border-strong); background: var(--surface); cursor: pointer; font-size: 12px; color: var(--text); }
.btn:hover, .reset-btn:hover { background: var(--hover); text-decoration: none; }
.btn.primary { background: var(--text); color: white; border-color: var(--text); }
.share-menu-wrap { position: relative; display: inline-flex; }
.share-trigger { min-width: 64px; justify-content: center; }
.share-menu { position: absolute; top: calc(100% + 8px); right: 0; z-index: 35; width: 300px; padding: 14px; border: 1px solid var(--border); background: var(--surface); box-shadow: 0 18px 50px rgb(12 10 9 / 0.16); }
.share-menu-title { margin-bottom: 8px; color: var(--text); font-size: 12px; font-weight: 700; }
.share-access-select { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 38px; padding: 0 12px; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); font-size: 12px; font-weight: 600; box-shadow: inset 0 1px 2px rgb(12 10 9 / 0.04); }
.share-access-select .chevron { color: var(--text-4); font-size: 16px; line-height: 1; }
.share-copy-link { margin-top: 10px; }
.share-menu-note { margin-top: 12px; color: var(--text-3); font-size: 12px; line-height: 1.45; }
.share-menu-separator { height: 1px; margin: 14px 0 8px; background: var(--border); }
.share-menu-item { display: flex; align-items: center; gap: 9px; width: 100%; min-height: 36px; padding: 0 8px; border: 0; background: transparent; color: var(--text-2); cursor: pointer; user-select: none; font-family: var(--sans); font-size: 13px; text-align: left; }
.share-menu-item:hover { background: var(--hover); color: var(--text); text-decoration: none; }
.share-menu-item:active { background: var(--active); transform: translateY(1px); }
.share-menu-item .icon { color: var(--text-3); }
.handoff-backdrop { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 24px; background: rgb(12 10 9 / 0.44); }
.handoff-shell { width: min(720px, calc(100vw - 48px)); max-height: calc(100vh - 48px); overflow: auto; border: 1px solid var(--border-strong); background: var(--surface); box-shadow: 0 20px 70px rgb(12 10 9 / 0.22); }
.handoff-tabs { display: flex; align-items: center; gap: 0; padding: 14px 18px 10px; border-bottom: 1px solid var(--border); }
.handoff-tab { height: 30px; padding: 0; border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--text); cursor: default; font-size: 13px; font-weight: 600; }
.handoff-tab:first-child,
.handoff-tab + .handoff-tab { border-radius: 0; }
.handoff-tab.active { border-bottom-color: var(--text); background: transparent; color: var(--text); box-shadow: none; }
.handoff-close { margin-left: auto; width: 30px; height: 30px; border: 0; background: transparent; color: var(--text-2); cursor: pointer; font-size: 26px; line-height: 1; }
.handoff-close:hover { color: var(--text); }
.handoff-panel { padding: 16px 18px 20px; }
.handoff-terminal { overflow: hidden; border: 1px solid #292524; background: #1c1917; color: #e7e5e4; }
.handoff-terminal-bar { display: grid; grid-template-columns: 10px 10px 10px 1fr; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border-bottom: 1px solid #292524; }
.handoff-terminal-bar .dot { width: 10px; height: 10px; border-radius: 50%; }
.handoff-terminal-bar .dot.red { background: #ff5f57; }
.handoff-terminal-bar .dot.amber { background: #febc2e; }
.handoff-terminal-bar .dot.green { background: #28c840; }
.handoff-terminal-bar .title { justify-self: center; color: #a8a29e; font-size: 12px; font-weight: 600; }
.handoff-terminal pre { min-height: 112px; padding: 16px 18px; overflow: auto; color: #f5f5f4; font-family: var(--mono); font-size: 13px; line-height: 1.55; white-space: pre-wrap; }
.handoff-actions { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
.handoff-actions .btn { height: 32px; padding: 0 12px; border-radius: 0; font-size: 12px; }
.handoff-actions [data-handoff-status] { flex: 1; min-width: 0; }
.handoff-options { margin-top: 18px; }
.handoff-options-title { margin-bottom: 10px; color: var(--text-3); font-size: 11px; font-weight: 700; letter-spacing: 0.06em; }
.handoff-check { display: flex; align-items: flex-start; gap: 10px; color: var(--text); font-size: 13px; cursor: pointer; user-select: none; }
.handoff-check input { width: 18px; height: 18px; margin-top: 1px; accent-color: var(--text); cursor: pointer; }
.handoff-check span { display: grid; gap: 2px; }
.handoff-check b { font-weight: 600; }
.handoff-check small { color: var(--text-3); font-size: 12px; line-height: 1.35; }
.handoff-note { display: block; margin-top: 18px; color: var(--text); font-size: 13px; font-weight: 600; }
.handoff-note em { color: var(--text-3); font-style: normal; font-weight: 400; }
.handoff-note textarea { width: 100%; min-height: 76px; margin-top: 8px; padding: 11px 12px; border: 1px solid var(--border); border-radius: 0; outline: none; resize: vertical; background: var(--surface); color: var(--text); font-weight: 400; line-height: 1.5; }
.handoff-note textarea:focus { border-color: var(--text); }
.archive-shell { width: min(520px, calc(100vw - 48px)); max-height: calc(100vh - 48px); overflow: auto; border: 1px solid var(--border-strong); background: var(--surface); box-shadow: 0 20px 70px rgb(12 10 9 / 0.22); }
.archive-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.archive-head h2 { margin: 0; color: var(--text); font-size: 14px; font-weight: 700; letter-spacing: 0; text-transform: none; }
.archive-body { padding: 16px; }
.archive-body label { display: block; color: var(--text); font-size: 13px; font-weight: 600; }
.archive-body textarea { width: 100%; min-height: 118px; margin-top: 8px; padding: 11px 12px; border: 1px solid var(--border); background: var(--surface); color: var(--text); outline: none; resize: vertical; line-height: 1.5; }
.archive-body textarea:focus { border-color: var(--text); }
.archive-presets { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 14px; }
.archive-preset { min-height: 28px; padding: 0 9px; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); cursor: pointer; font-size: 12px; }
.archive-preset:hover { border-color: var(--text-2); background: var(--hover); color: var(--text); }
.archive-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.archive-status { flex: 1; min-width: 0; color: var(--text-3); font-size: 12px; }
.table-wrap { flex: 1; overflow: auto; background: var(--surface); }
table.tenders { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
table.tenders thead th { position: sticky; top: 0; background: var(--bg); z-index: 2; height: 34px; text-align: left; font-weight: 500; color: var(--text-3); font-size: 11px; letter-spacing: 0.03em; text-transform: uppercase; border-bottom: 1px solid var(--border-strong); padding: 0 10px; white-space: nowrap; }
table.tenders tbody tr { cursor: pointer; transition: background 0.05s; }
table.tenders tbody tr:hover { background: var(--hover); }
table.tenders tbody tr.overdue { color: var(--text-3); }
table.tenders tbody tr.workflow-reviewing { background: var(--surface); box-shadow: inset 7px 0 0 #2563eb; }
table.tenders tbody tr.workflow-reviewing:hover { background: var(--hover); }
table.tenders tbody tr.workflow-accepted { background: #f0fdf4; }
table.tenders tbody tr.workflow-rejected { color: var(--text-3); background: #fef2f2; }
table.tenders tbody tr.viewed { box-shadow: inset 7px 0 0 #2563eb, inset 0 0 0 9999px rgba(37, 99, 235, 0.035); }
table.tenders tbody tr.viewed:not(.workflow-reviewing):not(.workflow-accepted):not(.workflow-rejected) { background: #f1f5ff; }
table.tenders tbody tr.viewed:not(.workflow-reviewing):not(.workflow-accepted):not(.workflow-rejected):hover { background: #e4edff; }
table.tenders tbody tr.workflow-reviewing.viewed { background: var(--surface); }
table.tenders tbody tr.workflow-reviewing.viewed:hover { background: var(--hover); }
table.tenders tbody tr.workflow-accepted.viewed { background: #d9f99d; }
table.tenders tbody tr.workflow-rejected.viewed { background: #fecaca; }
table.tenders tbody tr.workflow-reviewing td:first-child,
table.tenders tbody tr.viewed td:first-child { box-shadow: inset 7px 0 0 #2563eb; }
table.tenders tbody td { padding: 0 10px; height: var(--row-h); border-bottom: 1px solid var(--border); vertical-align: middle; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.col-num { width: 110px; color: var(--text-2); font-size: 12px; }
.col-title { min-width: 320px; max-width: 480px; }
.col-customer { min-width: 180px; max-width: 260px; color: var(--text-2); }
.col-work-type { width: 118px; }
.col-amount { width: 140px; font-family: var(--mono); text-align: right; font-feature-settings: "tnum"; }
.col-amount .kzt { color: var(--text-4); font-size: 11px; margin-left: 4px; }
.col-bidding, .col-deadline { width: 110px; font-family: var(--mono); font-size: 12px; color: var(--text-2); }
.col-left { width: 100px; }
.col-status { width: 98px; }
.col-selection { width: 205px; text-align: center; }
.col-reason { min-width: 260px; max-width: 360px; color: var(--text-2); }
.col-links { width: 80px; text-align: right; }
.title-line { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; color: var(--text); }
.row-submeta { display: flex; gap: 10px; margin-top: 3px; overflow: hidden; color: var(--text-4); font-size: 11px; line-height: 1.25; white-space: nowrap; }
.row-submeta span { overflow: hidden; text-overflow: ellipsis; }
.status-chip { display: inline-flex; align-items: center; height: 18px; margin-right: 8px; padding: 0 7px; background: var(--blue-bg); color: var(--blue-fg); font-size: 10px; font-weight: 600; vertical-align: 1px; }
.status-chip.green { background: var(--green-bg); color: var(--green-fg); }
.status-chip.amber { background: var(--amber-bg); color: var(--amber-fg); }
.status-chip.red { background: var(--red-bg); color: var(--red-fg); }
.status-chip.gray { background: var(--surface-2); color: var(--text-3); }
.status-chip.equipment { background: var(--blue-bg); color: var(--blue-fg); }
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; font-size: 11px; font-weight: 500; white-space: nowrap; line-height: 1.4; letter-spacing: 0.01em; }
.pill .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.pill.green, .swatch.green { background: var(--green-bg); color: var(--green-fg); }
.pill.amber, .swatch.amber { background: var(--amber-bg); color: var(--amber-fg); }
.pill.red, .swatch.red { background: var(--red-bg); color: var(--red-fg); }
.pill.blue, .swatch.blue { background: var(--blue-bg); color: var(--blue-fg); }
.pill.gray, .swatch.gray { background: var(--gray-bg); color: var(--gray-fg); }
.pill.running .dot { animation: pulse 1.2s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }
.left-soon { color: #b91c1c; font-weight: 500; }
.left-warn { color: #b45309; font-weight: 500; }
.left-ok { color: var(--text-2); }
.left-over { color: var(--text-4); text-decoration: line-through; }
.icon-btn { display: inline-grid; place-items: center; width: 24px; height: 24px; border: 1px solid transparent; background: transparent; cursor: pointer; color: var(--text-3); vertical-align: middle; }
.icon-btn:hover { border-color: var(--border-strong); color: var(--text); background: var(--surface); text-decoration: none; }
.row-actions { display: inline-flex; align-items: center; gap: 6px; }
.take-btn, .dismiss-btn { height: 26px; padding: 0 9px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-2); cursor: pointer; font-size: 11px; font-weight: 500; white-space: nowrap; }
.take-btn:hover, .dismiss-btn:hover { background: var(--hover); color: var(--text); }
.take-btn.selected { border-color: #86efac; background: var(--green-bg); color: var(--green-fg); }
.dismiss-btn { color: var(--text-3); }
.dismiss-btn:hover { border-color: #fecaca; background: var(--red-bg); color: var(--red-fg); }
.take-btn:disabled, .dismiss-btn:disabled { opacity: 0.55; cursor: wait; }
.workflow-select { height: 26px; min-width: 148px; padding: 0 24px 0 8px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-2); cursor: pointer; font-size: 11px; font-weight: 500; outline: none; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10'%3E%3Cpath d='M2 4l3 3 3-3' stroke='%2378716c' stroke-width='1.2' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 8px center; }
.workflow-select:hover, .workflow-select:focus { border-color: var(--text-2); }
.workflow-select.green { border-color: #86efac; background-color: var(--green-bg); color: var(--green-fg); }
.workflow-select.blue { border-color: #bfdbfe; background-color: var(--blue-bg); color: var(--blue-fg); }
.workflow-select.red { border-color: #fecaca; background-color: var(--red-bg); color: var(--red-fg); }
.workflow-select.gray { background-color: var(--surface); color: var(--text-2); }
.workflow-select:disabled { opacity: 0.6; cursor: wait; }
.workflow-control { display: inline-flex; align-items: center; gap: 6px; height: 32px; color: var(--text-3); font-size: 12px; }
.workflow-control .workflow-select { height: 32px; min-width: 165px; }
.empty { padding: 80px 20px; text-align: center; color: var(--text-3); }
.empty .big { font-size: 15px; color: var(--text); margin-bottom: 6px; }
.pager { display: flex; justify-content: flex-end; align-items: center; gap: 8px; padding: 14px 20px; background: var(--surface); }
.pager .page-info { margin-right: auto; color: var(--text-3); font-size: 12px; }
.portfolio-ranking-backdrop { position: fixed; inset: 0; z-index: 45; display: grid; place-items: center; padding: 24px; background: rgb(12 10 9 / 0.44); }
.portfolio-ranking-backdrop[hidden] { display: none; }
.portfolio-ranking { padding: 16px 20px; border: 1px solid var(--border); background: var(--surface); }
.portfolio-ranking-dialog { width: min(980px, calc(100vw - 48px)); max-height: calc(100vh - 48px); overflow: auto; box-shadow: 0 20px 70px rgb(12 10 9 / 0.22); }
.portfolio-ranking-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.portfolio-ranking h2 { margin-bottom: 8px; color: var(--text); font-size: 15px; font-weight: 700; letter-spacing: 0; }
.portfolio-ranking-actions { display: flex; align-items: center; gap: 8px; }
.portfolio-ranking-close { width: 30px; height: 30px; border: 0; background: transparent; color: var(--text-2); cursor: pointer; font-size: 26px; line-height: 1; }
.portfolio-ranking-close:hover { color: var(--text); }
.portfolio-ranking-status { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; color: var(--text-3); font-family: var(--mono); font-size: 11px; }
.portfolio-ranking-summary,
.portfolio-ranking-error { margin-top: 12px; color: var(--text-2); line-height: 1.5; }
.portfolio-ranking-error { color: var(--red-fg); }
.portfolio-ranking-list { display: grid; grid-template-columns: 1fr; gap: 8px; margin-top: 14px; }
.portfolio-ranking-item { display: grid; grid-template-columns: 44px 1fr; gap: 12px; padding: 12px 14px; border: 1px solid var(--border); background: #fcfcfb; }
.portfolio-ranking-item > .rank { color: var(--text); font-family: var(--mono); font-size: 16px; font-weight: 700; }
.portfolio-ranking-item .body { min-width: 0; }
.portfolio-ranking-item .title-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-weight: 600; }
.portfolio-ranking-item .title-row a { color: var(--text); }
.portfolio-ranking-item .score { color: var(--text-3); font-family: var(--mono); font-size: 11px; }
.portfolio-ranking-item .meta { display: flex; flex-wrap: wrap; gap: 6px 12px; margin-top: 6px; color: var(--text-3); font-size: 12px; }
.portfolio-ranking-item .reason { margin-top: 8px; color: var(--text-2); line-height: 1.5; }
.portfolio-ranking-item .next-action,
.portfolio-ranking-item .blockers { margin-top: 6px; color: var(--text-2); font-size: 12px; line-height: 1.45; }
.detail { flex: 1; overflow: auto; background: var(--bg); }
.detail-inner { max-width: 1240px; margin: 0 auto; padding: 20px 24px 80px; }
.back-link { display: inline-flex; align-items: center; gap: 6px; color: var(--text-3); font-size: 12px; margin-bottom: 14px; }
.back-link:hover { color: var(--text); text-decoration: none; }
.detail-header { background: var(--surface); border: 1px solid var(--border); padding: 20px 22px; }
.detail-header .top-row { display: flex; justify-content: space-between; gap: 24px; align-items: flex-start; }
.detail-header .actions { display: flex; gap: 6px; flex-shrink: 0; }
.detail-header .num-row { display: flex; align-items: center; gap: 12px; color: var(--text-3); font-size: 12px; margin-bottom: 8px; font-family: var(--mono); }
.detail-header .num-row .sep { color: var(--text-4); background: transparent; width: auto; height: auto; }
.detail-header h1 { font-size: 20px; font-weight: 600; line-height: 1.3; margin-bottom: 14px; max-width: 920px; }
.meta-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0; border-top: 1px solid var(--border); margin-top: 14px; }
.meta-grid .cell { padding: 12px 16px 0; border-right: 1px solid var(--border); min-height: 58px; }
.meta-grid .cell:nth-child(4n) { border-right: none; }
.meta-grid .cell .label { font-size: 11px; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 4px; }
.meta-grid .cell .value { font-size: 14px; font-weight: 500; font-family: var(--mono); font-feature-settings: "tnum"; }
.meta-grid .cell .value.lg { font-size: 18px; }
.meta-grid .cell .value.amount-highlight { color: var(--text); font-weight: 700; }
.meta-grid .cell .value.customer-highlight { color: var(--text); font-family: var(--sans); font-weight: 700; font-feature-settings: normal; }
.classification { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border); display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; font-size: 12px; color: var(--text-2); }
.classification .tag { flex-shrink: 0; background: var(--gray-bg); color: var(--gray-fg); padding: 2px 8px; font-size: 11px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.03em; }
.classification .tag.green { background: var(--green-bg); color: var(--green-fg); }
.classification .tag.blue,
.classification .tag.equipment { background: var(--blue-bg); color: var(--blue-fg); }
.classification .tag.amber { background: var(--amber-bg); color: var(--amber-fg); }
.classification .tag.red { background: var(--red-bg); color: var(--red-fg); }
.classification .tag.gray { background: var(--surface-2); color: var(--text-3); }
.audit-strip { display: flex; flex-wrap: wrap; gap: 8px 14px; margin-top: 10px; color: var(--text-3); font-size: 12px; line-height: 1.45; }
.audit-strip span { min-width: 0; overflow-wrap: anywhere; }
.workflow-note {
  margin-top: 12px;
  padding: 12px 14px;
  border: 1px solid #fecaca;
  background: #fef2f2;
  color: var(--red-fg);
}
.workflow-note.hidden { display: none; }
.workflow-note-label {
  margin-bottom: 5px;
  color: var(--red-fg);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.workflow-note-text {
  color: var(--text);
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
}
.section { margin-top: 24px; }
.section h2 { font-size: 11px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.07em; margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.section h2 .count { background: var(--gray-bg); color: var(--gray-fg); padding: 1px 6px; font-weight: 500; }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 10px; }
.section-head h2 { margin-bottom: 0; }
.analysis-columns { display: grid; grid-template-columns: minmax(0, 1fr) minmax(360px, 0.95fr); gap: 18px; align-items: start; }
.analysis-columns > .section { margin-top: 24px; min-width: 0; }
.analysis-columns .summary-grid { grid-template-columns: 1fr; }
.analysis-columns .summary-grid .card.span-2 { grid-column: auto; }
.executive-brief {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(380px, 0.8fr);
  gap: 1px;
  margin-top: 24px;
  border: 1px solid var(--border);
  background: var(--border);
}
.brief-main,
.brief-estimates,
.brief-mini {
  min-width: 0;
  background: var(--surface);
}
.brief-main {
  padding: 18px 20px;
}
.brief-kicker {
  margin-bottom: 6px;
  color: var(--text-3);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}
.brief-main h2 {
  max-width: 780px;
  color: var(--text);
  font-size: 20px;
  font-weight: 700;
  line-height: 1.2;
}
.brief-main ul {
  display: grid;
  gap: 7px;
  margin-top: 14px;
  padding-left: 18px;
  color: var(--text-2);
  line-height: 1.55;
}
.brief-risk {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 14px;
}
.brief-risk span {
  padding: 5px 8px;
  background: var(--amber-bg);
  color: var(--amber-fg);
  font-size: 12px;
  line-height: 1.35;
}
.brief-estimates {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1px;
  background: var(--border);
}
.brief-estimate {
  padding: 16px;
  background: var(--surface);
}
.brief-estimate .label,
.brief-mini .label,
.cost-line span,
.cost-total span {
  color: var(--text-3);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.brief-estimate .value {
  margin-top: 6px;
  color: var(--text);
  font-size: 18px;
  font-weight: 700;
  line-height: 1.2;
}
.brief-estimate .note {
  margin-top: 4px;
  color: var(--text-3);
  font-size: 12px;
  line-height: 1.35;
}
.brief-mini {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--border);
}
.brief-mini > div {
  min-width: 0;
  padding: 14px 18px;
  background: var(--surface);
}
.brief-mini p {
  margin-top: 6px;
  color: var(--text-2);
  line-height: 1.45;
}
.cost-box {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1px;
  border: 1px solid var(--border);
  background: var(--border);
}
.cost-total,
.cost-lines,
.cost-assumptions {
  background: var(--surface);
}
.cost-total {
  display: grid;
  align-content: start;
  gap: 8px;
  padding: 18px;
}
.cost-total strong {
  color: var(--text);
  font-size: 24px;
  line-height: 1.15;
}
.cost-total small,
.cost-line small {
  color: var(--text-3);
  font-size: 12px;
  line-height: 1.35;
}
.cost-lines {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--border);
}
.cost-line {
  display: grid;
  gap: 5px;
  min-width: 0;
  padding: 14px;
  background: var(--surface);
}
.cost-line strong {
  color: var(--text);
  font-size: 16px;
}
.team-lines {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  background: var(--border);
}
.team-line-title,
.team-line {
  display: grid;
  gap: 5px;
  min-width: 0;
  padding: 14px;
  background: var(--surface);
}
.team-line-title {
  background: var(--surface-2);
}
.team-line-title span,
.team-line span {
  color: var(--text-3);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.team-line-title strong,
.team-line strong {
  color: var(--text);
  font-size: 15px;
  line-height: 1.25;
}
.team-line-title small,
.team-line small {
  color: var(--text-3);
  font-size: 12px;
  line-height: 1.35;
}
.profit-lines {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(0, 0.8fr) minmax(0, 0.9fr) minmax(0, 1.3fr);
  gap: 1px;
  background: var(--border);
}
.profit-lines.finance-summary {
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr);
}
.profit-line {
  display: grid;
  gap: 5px;
  min-width: 0;
  padding: 14px;
  background: var(--surface);
}
.profit-line span {
  color: var(--text-3);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.profit-line strong {
  color: var(--text);
  font-size: 16px;
  line-height: 1.25;
}
.profit-line small {
  color: var(--text-3);
  font-size: 12px;
  line-height: 1.35;
}
.profit-line.emphasis strong {
  font-size: 18px;
}
.cost-breakdown {
  background: var(--surface);
}
.cost-breakdown-summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 16px;
  align-items: center;
  padding: 14px 18px;
  cursor: pointer;
  list-style: none;
}
.cost-breakdown-summary::-webkit-details-marker {
  display: none;
}
.cost-breakdown-summary > span:first-child {
  display: grid;
  gap: 4px;
  min-width: 0;
}
.cost-breakdown-title {
  color: var(--text);
  font-weight: 700;
}
.cost-breakdown-summary strong {
  color: var(--text-2);
  font-size: 13px;
  line-height: 1.35;
  text-align: right;
}
.cost-breakdown-summary small {
  color: var(--text-3);
  font-size: 12px;
  line-height: 1.35;
}
.cost-breakdown[open] .disclosure-action {
  color: transparent;
}
.cost-breakdown[open] .disclosure-action::after {
  color: var(--text-3);
  content: "Свернуть";
}
.cost-breakdown-body {
  display: grid;
  grid-template-columns: minmax(280px, 0.85fr) minmax(0, 1.15fr);
  gap: 1px;
  background: var(--border);
  border-top: 1px solid var(--border);
}
.cost-assumptions {
  grid-column: 1 / -1;
  display: grid;
  gap: 5px;
  padding: 12px 18px 12px 34px;
  color: var(--text-3);
  line-height: 1.45;
}
.detail-disclosure {
  border: 1px solid var(--border);
  background: var(--surface);
}
.detail-disclosure > :not(summary) {
  margin-left: 14px;
  margin-right: 14px;
}
.detail-disclosure > :last-child {
  margin-bottom: 14px;
}
.disclosure-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 52px;
  padding: 12px 14px;
  cursor: pointer;
  list-style: none;
  border-bottom: 1px solid transparent;
}
.disclosure-head::-webkit-details-marker { display: none; }
.detail-disclosure[open] .disclosure-head { border-bottom-color: var(--border); }
.disclosure-head > span:first-child {
  display: grid;
  gap: 3px;
  min-width: 0;
}
.disclosure-title {
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
}
.disclosure-subtitle {
  color: var(--text-3);
  font-size: 12px;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.disclosure-action {
  flex: 0 0 auto;
  color: var(--accent-2);
  font-size: 12px;
  font-weight: 600;
}
.detail-disclosure[open] .disclosure-action {
  font-size: 0;
}
.detail-disclosure[open] .disclosure-action::after {
  content: "Скрыть";
  font-size: 12px;
}
.ai-box { background: var(--surface); border: 1px solid var(--border); }
.ai-box { padding: 14px; }
.ai-box textarea { width: 100%; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); resize: vertical; outline: none; }
.ai-box textarea { min-height: 84px; padding: 10px; }
.ai-box textarea:focus { border-color: var(--text-2); }
.ai-actions { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.ai-answer { margin-top: 12px; color: var(--text-2); line-height: 1.55; white-space: pre-wrap; }
.mirofish-box { background: var(--surface); border: 1px solid var(--border); padding: 14px; }
.mirofish-status-line { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.mirofish-status-line > div { display: flex; align-items: center; gap: 10px; min-width: 0; }
.mirofish-message { margin-top: 10px; color: var(--text-2); line-height: 1.5; white-space: pre-wrap; }
.mirofish-web-toggle { display: inline-flex; align-items: center; gap: 7px; margin-top: 12px; color: var(--text-2); font-size: 12px; }
.mirofish-web-toggle input { margin: 0; accent-color: var(--text); }
.mirofish-web-toggle input:disabled + span { color: var(--text-4); }
.mirofish-meta { display: flex; flex-wrap: wrap; gap: 8px 14px; margin-top: 12px; color: var(--text-3); font-family: var(--mono); font-size: 11px; }
.mirofish-results-list { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }
.mirofish-result { border: 1px solid var(--border); background: var(--surface); padding: 14px; }
.mirofish-result-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.mirofish-result-head .chat-time { margin-left: auto; }
.mirofish-result-empty { border: 1px dashed var(--border-strong); background: var(--surface); padding: 18px; color: var(--text-3); line-height: 1.5; }
.mirofish-result-empty .title { color: var(--text); font-weight: 600; margin-bottom: 4px; }
.integration-box { background: var(--surface); border: 1px solid var(--border); padding: 14px; }
.integration-status-line { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.integration-status-line > div { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; min-width: 0; }
.integration-updated { color: var(--text-3); font-family: var(--mono); font-size: 11px; white-space: nowrap; }
.integration-message { margin-top: 10px; color: var(--text-2); line-height: 1.5; white-space: pre-wrap; }
.integration-list { display: grid; gap: 10px; margin-top: 14px; }
.integration-item { border: 1px solid var(--border); background: #fcfcfb; padding: 14px; }
.integration-item-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding-bottom: 10px; border-bottom: 1px solid var(--border); }
.integration-name { color: var(--text); font-size: 14px; font-weight: 700; }
.integration-product { margin-top: 3px; color: var(--text-3); font-size: 12px; line-height: 1.45; }
.integration-counts { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; color: var(--text-3); font-family: var(--mono); font-size: 11px; }
.integration-counts span { padding: 2px 6px; background: var(--surface-2); }
.integration-subblock { margin-top: 12px; color: var(--text-2); line-height: 1.55; }
.integration-subblock.warn { color: var(--red-fg); }
.integration-subblock.muted-block { color: var(--text-3); }
.integration-subtitle { margin-bottom: 5px; color: var(--text-3); font-size: 10.5px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
.integration-subblock ul { display: grid; gap: 5px; padding-left: 18px; }
.integration-evidence { margin-top: 12px; color: var(--text-3); }
.integration-evidence summary { cursor: pointer; font-size: 12px; font-weight: 600; }
.integration-evidence-list { display: grid; gap: 6px; margin-top: 8px; padding: 10px; border: 1px solid var(--border); background: var(--surface); }
.integration-evidence-list a,
.integration-evidence-list div { overflow-wrap: anywhere; color: var(--text-2); font-size: 12px; line-height: 1.45; }
.mirofish-qa { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); }
.mirofish-qa textarea { width: 100%; min-height: 70px; padding: 10px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); resize: vertical; outline: none; }
.mirofish-qa textarea:disabled { background: var(--bg); color: var(--text-4); cursor: not-allowed; }
.mirofish-qa textarea:focus { border-color: var(--text-2); }
.questions-box { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(300px, 0.9fr); gap: 1px; border: 1px solid var(--border); background: var(--border); }
.question-group { min-width: 0; padding: 16px; background: var(--surface); }
.question-group-title { margin-bottom: 12px; color: var(--text-3); font-size: 11px; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase; }
.question-list.ai-list,
.question-list.agent-list { display: grid; gap: 10px; padding-left: 18px; color: var(--text); line-height: 1.55; }
.question-list.ai-list li,
.question-list.agent-list li { padding-left: 4px; }
.question-list.human-list,
.question-list.comment-list { display: grid; gap: 8px; }
.question-source { display: inline-flex; align-items: center; height: 18px; margin-right: 7px; padding: 0 6px; font-size: 10px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; vertical-align: 1px; }
.question-source.ai { background: var(--blue-bg); color: var(--blue-fg); }
.question-source.agents { background: var(--amber-bg); color: var(--amber-fg); }
.question-source.human { background: var(--green-bg); color: var(--green-fg); }
.question-text { color: var(--text); line-height: 1.55; white-space: pre-wrap; }
.question-ref {
  margin-top: 7px;
  color: var(--text-3);
  font-size: 12px;
}
.question-ref summary {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--accent-2);
  cursor: pointer;
  font-weight: 600;
  list-style: none;
}
.question-ref summary::-webkit-details-marker { display: none; }
.question-ref-body {
  display: grid;
  gap: 4px;
  margin-top: 7px;
  padding: 9px 10px;
  border-left: 3px solid var(--blue-bg);
  background: var(--surface-2);
}
.question-ref-body span {
  color: var(--text);
  font-weight: 600;
}
.question-ref-body small {
  color: var(--text-4);
  font-family: var(--mono);
  font-size: 10.5px;
}
.question-ref-body p {
  color: var(--text-2);
  line-height: 1.45;
}
.question-empty { padding: 12px; border: 1px dashed var(--border-strong); color: var(--text-3); background: var(--bg); }
.human-question { padding: 11px 12px; border: 1px solid var(--border); background: #fcfcfb; }
.human-question-meta { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; color: var(--text-4); font-family: var(--mono); font-size: 11px; }
.comment-edited { color: var(--text-4); }
.comment-icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; margin-left: auto; border: 1px solid transparent; background: transparent; color: var(--text-3); cursor: pointer; }
.comment-icon-btn:hover { border-color: var(--border); background: var(--bg); color: var(--text); }
.comment-edit-form { display: grid; gap: 8px; margin-top: 8px; }
.comment-edit-form textarea { width: 100%; min-height: 74px; padding: 10px 12px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); resize: vertical; outline: none; line-height: 1.5; }
.comment-edit-form textarea:focus { border-color: var(--text); }
.comment-edit-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.question-add { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.question-add textarea { width: 100%; min-height: 68px; padding: 10px 12px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); resize: vertical; outline: none; line-height: 1.5; }
.question-add textarea:focus { border-color: var(--text); }
.question-add-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.question-status { flex: 1; min-width: 0; color: var(--text-3); font-size: 12px; }
.chat-box { background: var(--surface); border: 1px solid var(--border); padding: 14px; }
.chat-history { max-height: 420px; overflow: auto; border: 1px solid var(--border); background: var(--bg); margin-bottom: 12px; }
.chat-empty { padding: 18px; color: var(--text-3); text-align: center; }
.chat-message { padding: 12px 14px; border-bottom: 1px solid var(--border); }
.chat-message:last-child { border-bottom: none; }
.chat-message.user { background: var(--surface); }
.chat-message.assistant { background: #fcfcfb; }
.chat-message-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; color: var(--text-3); font-size: 11px; }
.chat-role { color: var(--text); font-weight: 600; }
.chat-provider { padding: 1px 7px; background: var(--gray-bg); color: var(--gray-fg); font-weight: 600; }
.chat-provider.mirofish { background: var(--blue-bg); color: var(--blue-fg); }
.chat-provider.llm { background: var(--green-bg); color: var(--green-fg); }
.chat-author { color: var(--text-3); font-size: 11px; font-weight: 600; }
.chat-time { margin-left: auto; font-family: var(--mono); color: var(--text-4); }
.chat-content { color: var(--text-2); line-height: 1.55; white-space: pre-wrap; }
.chat-box textarea { width: 100%; min-height: 84px; padding: 10px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); resize: vertical; outline: none; }
.chat-box textarea:focus { border-color: var(--text-2); }
.chat-actions { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.summary-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--border); border: 1px solid var(--border); }
.summary-grid .card { background: var(--surface); padding: 16px 18px; }
.summary-grid .card.span-2 { grid-column: 1 / -1; }
.summary-grid .card .head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.summary-grid .card .head .idx { font-family: var(--mono); font-size: 11px; color: var(--text-4); width: 20px; }
.summary-grid .card .head .title { font-size: 13px; font-weight: 600; }
.summary-grid .card .body { font-size: 13px; color: var(--text-2); line-height: 1.55; padding-left: 28px; }
.summary-grid .card .body-line + .body-line { margin-top: 6px; }
.summary-grid .card .body.red { color: var(--red-fg); }
.summary-stub { background: var(--surface); border: 1px solid var(--border); padding: 32px 22px; text-align: center; color: var(--text-3); }
.summary-stub .icon { display: block; margin: 0 auto 10px; color: var(--text-4); }
.summary-stub .title { font-size: 14px; color: var(--text); margin-bottom: 4px; font-weight: 500; }
.summary-section-head .summary-sources-btn { height: 28px; padding: 0 10px; }
.summary-sources-btn span { min-width: 18px; height: 18px; display: inline-grid; place-items: center; padding: 0 5px; background: var(--gray-bg); color: var(--gray-fg); font-family: var(--mono); font-size: 10px; }
.sources-backdrop { position: fixed; inset: 0; z-index: 55; display: flex; align-items: flex-end; justify-content: center; padding: 24px; background: rgb(12 10 9 / 0.32); }
.sources-drawer { width: min(920px, calc(100vw - 48px)); max-height: min(72vh, 620px); overflow: hidden; border: 1px solid var(--border-strong); background: var(--surface); box-shadow: 0 -18px 70px rgb(12 10 9 / 0.2); animation: sources-slide-up 140ms ease-out; }
.sources-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.sources-kicker { margin-bottom: 3px; color: var(--text-3); font-size: 11px; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase; }
.sources-head h2 { margin: 0; color: var(--text); font-size: 15px; font-weight: 700; letter-spacing: 0; text-transform: none; }
.sources-close { width: 30px; height: 30px; border: 0; background: transparent; color: var(--text-2); cursor: pointer; font-size: 26px; line-height: 1; }
.sources-close:hover { color: var(--text); }
.sources-list { max-height: calc(min(72vh, 620px) - 74px); overflow: auto; padding: 8px; }
.source-link { display: grid; grid-template-columns: 42px minmax(0, 1fr) 22px; gap: 12px; padding: 12px 10px; border-bottom: 1px solid var(--border); color: var(--text); }
.source-link:last-child { border-bottom: none; }
.source-link:hover { background: var(--hover); text-decoration: none; }
.source-id { align-self: start; color: var(--text-3); font-family: var(--mono); font-size: 11px; font-weight: 700; }
.source-main { display: grid; gap: 4px; min-width: 0; }
.source-title { color: var(--text); font-size: 13px; font-weight: 600; line-height: 1.35; }
.source-url { overflow: hidden; color: var(--accent-2); font-family: var(--mono); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.source-excerpt { color: var(--text-3); font-size: 12px; line-height: 1.45; }
.source-open { align-self: center; color: var(--text-4); }
@keyframes sources-slide-up {
  from { opacity: 0.9; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
.docs { background: var(--surface); border: 1px solid var(--border); }
.docs table { width: 100%; border-collapse: collapse; font-size: 13px; }
.docs thead th { text-align: left; font-weight: 500; font-size: 11px; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.03em; padding: 10px 14px; border-bottom: 1px solid var(--border); background: var(--bg); }
.docs tbody td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.docs tbody tr:last-child td { border-bottom: none; }
.docs .doc-name { display: flex; align-items: center; gap: 10px; }
.docs .doc-name .icon { color: var(--text-3); flex-shrink: 0; }
.docs .doc-name .used { background: var(--blue-bg); color: var(--blue-fg); padding: 1px 6px; font-size: 10px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.03em; margin-left: 4px; }
.docs .err { color: var(--red-fg); font-size: 12px; font-family: var(--mono); }
.docs .doc-actions { display: flex; gap: 6px; justify-content: flex-end; }
.docs .doc-btn { display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border: 1px solid var(--border-strong); background: var(--surface); cursor: pointer; font-size: 12px; color: var(--text-2); }
.docs .doc-btn:hover { background: var(--hover); color: var(--text); text-decoration: none; }
.trace-page { flex: 1; overflow: auto; background: var(--bg); }
.trace-inner { max-width: 1180px; margin: 0 auto; padding: 20px 24px 80px; }
.trace-header { display: flex; justify-content: space-between; gap: 24px; align-items: flex-start; background: var(--surface); border: 1px solid var(--border); padding: 20px 22px; }
.trace-header .num-row { color: var(--text-3); font-family: var(--mono); font-size: 12px; margin-bottom: 8px; }
.trace-header h1 { font-size: 22px; line-height: 1.25; margin-bottom: 8px; }
.trace-header p { max-width: 820px; color: var(--text-2); line-height: 1.5; }
.trace-header .actions { display: flex; gap: 6px; flex-shrink: 0; }
.trace-run { margin-top: 14px; background: var(--surface); border: 1px solid var(--border); padding: 14px 16px; }
.trace-run-main { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; color: var(--text-2); }
.trace-run-meta { display: flex; flex-wrap: wrap; gap: 8px 14px; margin-top: 10px; color: var(--text-3); font-family: var(--mono); font-size: 11px; }
.trace-cards { display: grid; grid-template-columns: repeat(6, 1fr); gap: 1px; margin-top: 14px; border: 1px solid var(--border); background: var(--border); }
.trace-card { min-height: 72px; padding: 12px 14px; background: var(--surface); }
.trace-card .label { margin-bottom: 6px; color: var(--text-3); font-size: 10px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; }
.trace-card .value { color: var(--text); font-family: var(--mono); font-size: 15px; font-weight: 600; word-break: break-word; }
.trace-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(360px, 0.8fr); gap: 16px; align-items: start; }
.trace-section { margin-top: 18px; }
.trace-section h2 { margin-bottom: 10px; color: var(--text-3); font-size: 11px; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase; }
.trace-table-wrap { overflow-x: auto; border: 1px solid var(--border); background: var(--surface); }
.trace-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.trace-table th,
.trace-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.trace-table tr:last-child td { border-bottom: none; }
.trace-table th { background: var(--surface-2); color: var(--text-3); font-size: 10px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; }
.trace-table td { color: var(--text-2); }
.trace-feed { display: flex; flex-direction: column; gap: 10px; }
.trace-item { border: 1px solid var(--border); background: var(--surface); padding: 14px 16px; }
.trace-item.action { background: #fcfcfb; }
.trace-item.error { border-color: #fecaca; background: #fff7f7; }
.trace-item-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 6px; color: var(--text-3); font-family: var(--mono); font-size: 11px; }
.trace-item-head .idx { color: var(--text); font-family: var(--sans); font-size: 12px; font-weight: 700; }
.trace-item-meta { margin-bottom: 10px; color: var(--text-3); font-family: var(--mono); font-size: 11px; line-height: 1.45; }
.trace-text { color: var(--text); font-size: 14px; line-height: 1.65; white-space: pre-wrap; }
.trace-report { border: 1px solid var(--border); background: var(--surface); padding: 18px; }
.trace-empty { border: 1px dashed var(--border-strong); background: var(--surface); padding: 18px; color: var(--text-3); }
.muted { color: var(--text-3); }
.login-page { display: grid; min-height: 100vh; place-items: center; }
.login { width: 360px; background: var(--surface); border: 1px solid var(--border); padding: 20px; }
.login-title { font-size: 18px; font-weight: 700; margin-bottom: 18px; }
.login-error { margin-bottom: 12px; color: var(--red-fg); font-size: 12px; }
.login label { display: block; color: var(--text-3); font-size: 12px; margin-bottom: 6px; }
.login input { width: 100%; height: 34px; border: 1px solid var(--border-strong); padding: 0 10px; margin-bottom: 12px; }
.login button { height: 34px; padding: 0 14px; border: 0; background: var(--text); color: white; cursor: pointer; }

/* Design handoff: tabbed dense shell + quick workflow actions */
.app { height: 100vh; min-height: 100vh; }
.topbar { height: var(--header-h); gap: 0; padding: 0 24px; }
.brand { margin-right: 8px; letter-spacing: -0.01em; }
.brand-mark { width: 24px; height: 24px; letter-spacing: -0.02em; }
.tabs { display: flex; align-items: stretch; height: 100%; margin-left: 12px; }
.tab {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 100%;
  padding: 0 14px;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  color: var(--text-3);
  font-size: 13px;
  white-space: nowrap;
  user-select: none;
}
.tab:hover { color: var(--text); text-decoration: none; }
.tab.active { color: var(--text); border-bottom-color: var(--text); font-weight: 500; }
.tab .badge {
  font-family: var(--mono);
  font-size: 11px;
  padding: 1px 6px;
  background: var(--gray-bg);
  color: var(--text-2);
  border-radius: 2px;
  font-weight: 500;
}
.tab.active .badge { background: var(--text); color: white; }
.last-sync { display: flex; align-items: center; gap: 6px; margin-right: 16px; color: var(--text-3); font-size: 12px; }
.last-sync .dot { width: 6px; height: 6px; border-radius: 50%; background: #16a34a; }
.current-user { height: 26px; margin-right: 12px; padding: 0 9px; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); font-size: 12px; line-height: 24px; }
.logout {
  display: inline-flex;
  align-items: center;
  height: 30px;
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  background: transparent;
  color: var(--text-2);
}
.logout:hover { background: var(--hover); color: var(--text); text-decoration: none; }
.user-menu { position: relative; margin-left: 4px; }
.avatar-btn {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
  list-style: none;
}
.avatar-btn::marker { content: ""; }
.avatar-btn::-webkit-details-marker { display: none; }
.avatar-btn:hover,
.user-menu[open] .avatar-btn {
  border-color: var(--border-strong);
  background: var(--hover);
  color: var(--text);
}
.dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 50;
  width: 220px;
  padding: 6px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  box-shadow: 0 16px 40px rgb(12 10 9 / 0.14), 0 2px 8px rgb(12 10 9 / 0.08);
}
.dd-item {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 36px;
  padding: 0 8px;
  color: var(--text-2);
  font-size: 13px;
}
.dd-item:hover,
.dd-item.active {
  background: var(--hover);
  color: var(--text);
  text-decoration: none;
}
.dd-item.danger { color: var(--red-fg); }
.dd-icon { display: inline-grid; place-items: center; flex: 0 0 14px; }
.dd-label { flex: 1; min-width: 0; }
.dd-badge {
  flex: 0 0 auto;
  padding: 1px 6px;
  border-radius: 2px;
  background: var(--gray-bg);
  color: var(--text-2);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
}
.dd-item.active .dd-badge { background: var(--text); color: white; }
.dd-sep { height: 1px; margin: 6px 0; background: var(--border); }
.filterbar { padding: 12px 24px; }
.search { flex-basis: 300px; }
.table-wrap { animation: pageIn 0.22s cubic-bezier(0.22, 1, 0.36, 1); }
@keyframes pageIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}
table.tenders thead th { height: 36px; background: var(--surface); color: var(--text-4); font-size: 10.5px; letter-spacing: 0.08em; padding: 0 14px; }
table.tenders tbody tr:hover { background: var(--row-hover); }
table.tenders tbody tr.workflow-reviewing { background: var(--surface); }
table.tenders tbody tr.workflow-reviewing:hover,
table.tenders tbody tr.workflow-reviewing.viewed:hover { background: var(--row-hover); }
table.tenders tbody td { height: 56px; padding: 0 14px; }
table.tenders { table-layout: fixed; }
.col-num { width: 70px; }
.col-title { width: 310px; min-width: 0; max-width: none; }
.col-customer { width: 150px; min-width: 0; max-width: none; }
.col-work-type { width: 135px; }
.col-amount { width: 110px; }
.col-bidding, .col-deadline { width: 80px; }
.col-left { width: 70px; }
.col-selection { width: 230px; text-align: right; padding-right: 8px !important; }
.row-actions { justify-content: flex-end; }
.qa { display: inline-flex; align-items: center; justify-content: flex-end; gap: 4px; }
.qa-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 26px;
  padding: 0 9px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-2);
  cursor: pointer;
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0.005em;
  white-space: nowrap;
}
.qa-btn:hover { background: var(--hover); color: var(--text); }
.qa-btn.accept:hover { background: var(--green-bg); color: var(--green-fg); border-color: var(--green-bg); }
.qa-btn.reject:hover { background: var(--red-bg); color: var(--red-fg); border-color: var(--red-bg); }
.qa-btn.accept.active { background: var(--green-bg); color: var(--green-fg); border-color: var(--green-bg); }
.qa-btn.reject.active { background: var(--red-bg); color: var(--red-fg); border-color: var(--red-bg); }
.qa-btn:disabled, .qa-undo:disabled { opacity: 0.55; cursor: wait; }
.qa-btn svg { opacity: 0.72; }
.qa-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 26px;
  padding: 0 9px;
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0.005em;
  white-space: nowrap;
}
.qa-badge.accepted { background: var(--green-bg); color: var(--green-fg); }
.qa-badge.rejected { background: var(--red-bg); color: var(--red-fg); }
.qa-undo {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-3);
  cursor: pointer;
}
.qa-undo:hover { background: var(--hover); color: var(--text); }
.detail-header .actions { align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.detail-header .actions .qa { margin-right: 2px; }

/* Design handoff: tender detail tabs + embedded AI chat */
:root {
  --user-bg: #f4f3f1;
  --user-bg-2: #ecebe8;
  --code-bg: #f5f4f2;
  --code-fg: #1f2937;
  --code-border: #e7e5e4;
  --agent-bg: #dbeafe;
  --agent-fg: #1e3a8a;
  --agent-bg-2: #ede9fe;
  --agent-fg-2: #5b21b6;
  --chat-max-w: 760px;
}

.detail-tabs {
  display: flex;
  align-items: stretch;
  height: 44px;
  margin-top: 16px;
  border: 1px solid var(--border);
  border-bottom: none;
  background: var(--surface);
}
.detail-tab {
  display: inline-flex;
  align-items: center;
  height: 100%;
  padding: 0 18px;
  border: 0;
  border-right: 1px solid var(--border);
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
}
.detail-tab:hover { background: var(--hover); color: var(--text); }
.detail-tab.active {
  color: var(--text);
  border-bottom-color: var(--text);
  background: var(--surface);
}
.detail-tab-panel { display: none; animation: pageIn 0.18s cubic-bezier(0.22, 1, 0.36, 1); }
.detail-tab-panel.active { display: block; }

.chat-panel.embedded { min-height: 620px; }
.chat-panel.embedded .section-head {
  padding: 0 0 10px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0;
}
.chat-panel.embedded .chat-box {
  display: flex;
  flex-direction: column;
  min-height: 620px;
  padding: 0;
  overflow: hidden;
}
.chat-history.conversation {
  flex: 1;
  max-height: none;
  min-height: 420px;
  margin: 0;
  border: 0;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.conv-inner {
  max-width: var(--chat-max-w);
  margin: 0 auto;
  padding: 28px 24px 46px;
  display: flex;
  flex-direction: column;
  gap: 26px;
}
.chat-empty {
  border: 1px dashed var(--border-strong);
  background: var(--surface);
}
.chat-message {
  padding: 0;
  border-bottom: 0;
  animation: msgIn 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes msgIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}
.chat-message.user {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  background: transparent;
}
.chat-message.user .chat-content {
  max-width: 80%;
  padding: 12px 16px;
  background: var(--user-bg);
  color: var(--text);
  line-height: 1.55;
  white-space: pre-wrap;
}
.chat-message.user .chat-time {
  color: var(--text-4);
  font-family: var(--mono);
  font-size: 11px;
}
.chat-message-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-height: 26px;
  margin-top: 6px;
}
.chat-message.assistant { background: transparent; }
.chat-message.assistant .chat-message-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  color: var(--text-3);
  font-size: 11px;
}
.chat-avatar {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  background: var(--text);
  color: white;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0;
}
.chat-provider.agent-tag {
  padding: 1px 8px;
  background: var(--agent-bg);
  color: var(--agent-fg);
  font-size: 12px;
  font-weight: 500;
}
.chat-provider.agent-tag.mirofish {
  background: var(--agent-bg-2);
  color: var(--agent-fg-2);
}
.chat-head-spacer { flex: 1; }
.chat-message-actions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.14s ease;
}
.chat-message:hover .chat-message-actions,
.chat-message:focus-within .chat-message-actions,
.chat-action-btn.copied {
  opacity: 1;
}
.chat-action-btn {
  width: 26px;
  height: 26px;
  display: inline-grid;
  place-items: center;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-4);
  cursor: pointer;
  line-height: 1;
}
.chat-action-btn:hover,
.chat-action-btn:focus-visible {
  border-color: var(--border);
  background: var(--surface);
  color: var(--text-2);
  outline: none;
}
.chat-action-btn:active {
  transform: translateY(1px);
}
.chat-action-btn.copied {
  color: var(--green-fg);
}
.chat-copy {
  height: 22px;
  padding: 0 7px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-4);
  cursor: pointer;
  font-size: 11px;
}
.chat-copy:hover {
  border-color: var(--border);
  background: var(--surface);
  color: var(--text-2);
}
.chat-edit-form {
  width: min(80%, 720px);
  padding: 12px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
}
.chat-edit-form textarea {
  width: 100%;
  min-height: 92px;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  background: var(--bg);
  color: var(--text);
  outline: none;
  resize: vertical;
  line-height: 1.55;
}
.chat-edit-form textarea:focus {
  border-color: var(--text);
}
.chat-edit-hint {
  margin-top: 8px;
  color: var(--text-4);
  font-size: 12px;
  line-height: 1.4;
}
.chat-edit-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 10px;
}
.chat-content.md {
  color: var(--text);
  font-size: 14px;
  line-height: 1.65;
  white-space: normal;
}
.chat-content.md > * + * { margin-top: 14px; }
.chat-content.md h1,
.chat-content.md h2,
.chat-content.md h3 {
  display: block;
  margin: 0;
  color: var(--text);
  font-weight: 600;
  letter-spacing: 0;
  line-height: 1.3;
  text-transform: none;
}
.chat-content.md h1 { font-size: 18px; }
.chat-content.md h2 { font-size: 16px; }
.chat-content.md h3 { font-size: 14px; color: var(--text-2); }
.chat-content.md p { color: var(--text); }
.chat-content.md strong { color: var(--text); font-weight: 600; }
.chat-content.md ul,
.chat-content.md ol {
  padding-left: 22px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.chat-content.md li { padding-left: 2px; }
.chat-content.md blockquote {
  border-left: 3px solid var(--border-strong);
  padding: 2px 0 2px 14px;
  color: var(--text-2);
  font-style: italic;
}
.chat-content.md hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 20px 0;
}
.chat-content.md code {
  padding: 1px 5px;
  background: var(--code-bg);
  color: var(--code-fg);
  border-radius: 2px;
  font-family: var(--mono);
  font-size: 0.88em;
}
.chat-content.md pre {
  overflow-x: auto;
  padding: 12px 14px;
  border: 1px solid var(--code-border);
  background: var(--code-bg);
  line-height: 1.6;
}
.chat-content.md pre code { padding: 0; background: transparent; font-size: inherit; }
.chat-content.md .md-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
}
.chat-content.md table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.chat-content.md th,
.chat-content.md td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}
.chat-content.md th {
  background: var(--surface);
  color: var(--text);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.chat-content.md td { color: var(--text-2); }
.chat-citation {
  display: inline-flex;
  align-items: center;
  min-height: 18px;
  margin: 0 2px;
  padding: 0 5px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--blue-fg);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  line-height: 1.4;
  vertical-align: 1px;
  white-space: nowrap;
}
.chat-citation:hover {
  border-color: var(--border-strong);
  background: var(--blue-bg);
  color: var(--blue-fg);
  text-decoration: none;
}
.chat-sources {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}
.chat-sources-btn {
  min-height: 24px;
  height: 24px;
  padding: 0 8px;
  font-size: 11px;
}
.chat-sources-btn span {
  min-width: 16px;
  height: 16px;
  display: inline-grid;
  place-items: center;
  padding: 0 4px;
  background: var(--gray-bg);
  color: var(--gray-fg);
  font-family: var(--mono);
  font-size: 10px;
}
.chat-source {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  min-height: 24px;
  padding: 3px 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-3);
  font-size: 11px;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-source:hover {
  border-color: var(--border-strong);
  color: var(--text);
  text-decoration: none;
}
.source-empty {
  padding: 18px;
  color: var(--text-3);
  font-size: 13px;
}
.chat-message.typing .chat-content.md { color: var(--text-3); }
.typing-dots {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.typing-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-4);
  animation: blink 1.4s infinite;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink {
  0%, 60%, 100% { opacity: 0.25; }
  30% { opacity: 1; }
}
.chat-composer {
  flex-shrink: 0;
  padding: 14px 24px 18px;
  background: var(--surface);
}
.prompts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}
.prompt-chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 5px 11px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-2);
  cursor: pointer;
  font-size: 12px;
  line-height: 1.2;
  max-width: 100%;
  text-align: left;
  white-space: normal;
}
.prompt-chip:hover {
  background: var(--text);
  border-color: var(--text);
  color: white;
}
.prompt-chip:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.prompt-chip:disabled:hover {
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--text-2);
}
.input-wrap {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border-strong);
  background: var(--surface);
}
.input-wrap:focus-within { border-color: var(--text); }
.input-wrap textarea {
  width: 100%;
  min-height: 46px;
  max-height: 220px;
  padding: 14px 16px 6px;
  border: 0;
  outline: none;
  resize: none;
  background: transparent;
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
}
.input-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px 8px 12px;
}
.chat-tools-wrap {
  position: relative;
  flex: 0 0 auto;
}
.chat-tool-plus,
.chat-active-tool {
  width: 30px;
  height: 30px;
  display: inline-grid;
  place-items: center;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
}
.chat-tool-plus:hover,
.chat-tool-plus[aria-expanded="true"],
.chat-active-tool:hover,
.chat-active-tool.active {
  background: var(--text);
  color: white;
}
.chat-active-tool.web.active {
  background: var(--blue-bg);
  color: var(--blue-fg);
}
.chat-active-tool.web.active:hover {
  background: var(--blue-bg);
  color: var(--blue-fg);
}
.chat-active-tool.web .chat-tool-x { display: none; font-size: 20px; line-height: 1; }
.chat-active-tool.web.active:hover .chat-tool-globe { display: none; }
.chat-active-tool.web.active:hover .chat-tool-x { display: block; }
.chat-tools-menu {
  position: absolute;
  left: 0;
  bottom: calc(100% + 8px);
  width: 248px;
  padding: 8px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.14);
  z-index: 30;
}
.chat-tool-item {
  width: 100%;
  min-height: 36px;
  display: grid;
  grid-template-columns: 24px 1fr 18px;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border: 0;
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  font-size: 13px;
  line-height: 1.25;
  text-align: left;
}
.chat-tool-item:hover {
  background: var(--hover);
  color: var(--text);
}
.chat-tool-item.active {
  color: var(--blue-fg);
}
.chat-tool-item:disabled {
  color: var(--text-4);
  cursor: not-allowed;
}
.chat-tool-item:disabled:hover {
  background: transparent;
}
.chat-tool-icon {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
}
.chat-tool-icon.text {
  background: var(--bg);
  color: var(--text-3);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
}
.chat-tool-check {
  opacity: 0;
  color: var(--blue-fg);
  font-weight: 600;
  text-align: center;
}
.chat-tool-item.active .chat-tool-check { opacity: 1; }
.chat-tool-separator {
  height: 1px;
  margin: 6px 0;
  background: var(--border);
}
.agent-pick,
.agent-toggle {
  display: inline-flex;
  align-items: stretch;
  height: 28px;
  border: 1px solid var(--border);
  background: var(--bg);
}
.agent-toggle { overflow: hidden; }
.agent-pick .label {
  display: flex;
  align-items: center;
  padding: 0 8px;
  border-right: 1px solid var(--border);
  color: var(--text-3);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.agent-pick select {
  min-width: 170px;
  height: 100%;
  padding: 0 24px 0 8px;
  border: 0;
  outline: none;
  appearance: none;
  background-color: transparent;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10'%3E%3Cpath d='M2 4l3 3 3-3' stroke='%2378716c' stroke-width='1.2' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  color: var(--text-2);
  cursor: pointer;
  font-size: 12px;
}
.agent-toggle-btn {
  height: 100%;
  padding: 0 10px;
  border: 0;
  border-right: 1px solid var(--border);
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
}
.agent-toggle-btn:last-child { border-right: 0; }
.agent-toggle-btn:hover { background: var(--hover); color: var(--text); }
.agent-toggle-btn.active {
  background: var(--text);
  color: white;
}
.agent-toggle-btn.mirofish.active {
  background: var(--agent-fg-2);
  color: white;
}
.agent-toggle-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.agent-toggle-btn:disabled:hover {
  background: transparent;
  color: var(--text-3);
}
.input-actions [data-chat-status] {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-shortcut {
  color: var(--text-4);
  font-family: var(--mono);
  font-size: 11px;
}
.send-btn { height: 30px; }

@media (max-width: 1100px) {
  .executive-brief,
  .brief-mini,
  .cost-box,
  .cost-lines,
  .team-lines,
  .profit-lines,
  .profit-lines.finance-summary,
  .cost-breakdown-body,
  .cost-breakdown-summary {
    grid-template-columns: 1fr;
  }

  .cost-breakdown-summary strong {
    text-align: left;
  }

  .analysis-columns { grid-template-columns: 1fr; }
  .questions-box { grid-template-columns: 1fr; }
}

@media (max-width: 1280px) {
  .app { min-width: 0; }
}

@media (max-width: 980px) {
  .app {
    min-width: 0;
    height: auto;
    min-height: 100dvh;
  }

  .topbar {
    height: auto;
    min-height: var(--header-h);
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 8px;
    padding: 10px 14px 0;
  }

  .brand {
    height: 32px;
    margin-right: 4px;
  }

  .tabs {
    order: 3;
    width: calc(100% + 28px);
    height: 42px;
    margin: 2px -14px 0;
    padding: 0 14px;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
  }

  .tabs::-webkit-scrollbar { display: none; }

  .tab {
    flex: 0 0 auto;
    padding: 0 12px;
    font-size: 12px;
  }

  .last-sync {
    max-width: 168px;
    min-height: 30px;
    margin: 0 4px 0 auto;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 11px;
  }

  .logout {
    height: 30px;
    padding: 0 10px;
  }

  .user-menu {
    margin-left: 0;
  }

  .avatar-btn {
    width: 30px;
    height: 30px;
  }

  .dropdown {
    top: calc(100% + 4px);
    right: 0;
  }

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

  .search,
  .amount-range {
    grid-column: 1 / -1;
    flex: none;
    width: 100%;
  }

  .filter-group,
  .amount-range,
  .filterbar > .btn,
  .filterbar > .reset-btn {
    width: 100%;
    min-width: 0;
    min-height: 36px;
    height: 36px;
  }

  .filter-group select,
  .search input {
    min-width: 0;
    width: 100%;
  }

  .amount-range input { width: 100%; }

  .detail-inner {
    max-width: none;
    padding: 14px 14px 56px;
  }

  .detail-header {
    padding: 16px;
  }

  .detail-header .top-row {
    flex-direction: column;
    gap: 14px;
  }

  .detail-header .actions {
    width: 100%;
    justify-content: flex-start;
  }

  .share-menu {
    right: auto;
    left: 0;
  }

  .detail-header h1 {
    max-width: none;
    font-size: 19px;
  }

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

  .meta-grid .cell:nth-child(4n) { border-right: 1px solid var(--border); }
  .meta-grid .cell:nth-child(2n) { border-right: none; }

  .summary-grid {
    grid-template-columns: 1fr;
  }

  .summary-grid .card.span-2 { grid-column: auto; }
}

@media (max-width: 760px) {
  html,
  body {
    font-size: 12px;
    overflow-x: hidden;
  }

  .topbar { padding-inline: 12px; }

  .tabs {
    width: calc(100% + 24px);
    margin-inline: -12px;
    padding-inline: 12px;
  }

  .brand span { display: none; }

  .last-sync {
    max-width: 132px;
    font-size: 10.5px;
  }

  .filterbar {
    grid-template-columns: 1fr;
    padding: 10px 12px;
  }

  .portfolio-ranking-backdrop {
    align-items: start;
    padding: 12px;
  }

  .portfolio-ranking-dialog {
    width: calc(100vw - 24px);
    max-height: calc(100dvh - 24px);
  }

  .portfolio-ranking-head {
    flex-direction: column;
    gap: 12px;
  }

  .portfolio-ranking-actions {
    width: 100%;
    justify-content: space-between;
  }

  .portfolio-ranking-item {
    grid-template-columns: 1fr;
  }

  .filter-group .label,
  .amount-range .label {
    width: 98px;
    flex: 0 0 98px;
  }

  .table-wrap {
    flex: none;
    overflow: visible;
    padding: 10px 12px 18px;
    background: var(--bg);
  }

  table.tenders,
  table.tenders tbody,
  table.tenders tr,
  table.tenders td {
    display: block;
    width: 100%;
  }

  table.tenders { table-layout: auto; }
  table.tenders thead { display: none; }

  table.tenders tbody {
    display: grid;
    gap: 10px;
  }

  table.tenders tbody tr {
    padding: 12px;
    border: 1px solid var(--border);
    background: var(--surface);
  }

  table.tenders tbody tr:hover { background: var(--surface); }
  table.tenders tbody tr.workflow-reviewing { background: #f0f6ff; }
  table.tenders tbody tr.workflow-accepted { background: #f0fdf4; }
  table.tenders tbody tr.workflow-rejected { background: #fef2f2; }

  table.tenders tbody td {
    height: auto;
    padding: 7px 0;
    border-bottom: 0;
    overflow: visible;
    text-overflow: initial;
    white-space: normal;
    text-align: right;
  }

  table.tenders tbody td:not(.col-title) {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
  }

  table.tenders tbody td::before {
    content: attr(data-label);
    flex: 0 0 92px;
    color: var(--text-3);
    font-family: var(--sans);
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-align: left;
    text-transform: uppercase;
  }

  table.tenders tbody td.col-title {
    padding-top: 0;
    text-align: left;
  }

  table.tenders tbody td.col-title::before {
    display: block;
    margin-bottom: 5px;
  }

  .title-line {
    white-space: normal;
    font-size: 14px;
    line-height: 1.35;
  }
  .row-submeta {
    flex-direction: column;
    gap: 2px;
    white-space: normal;
  }

  .col-num,
  .col-title,
  .col-customer,
  .col-work-type,
  .col-amount,
  .col-bidding,
  .col-deadline,
  .col-left,
  .col-selection {
    min-width: 0;
    max-width: none;
    width: auto;
  }

  .col-selection {
    margin-top: 6px;
    padding-top: 10px !important;
    border-top: 1px solid var(--border);
    text-align: left;
  }

  .col-selection::before { display: none; }

  .col-selection .qa,
  .detail-header .actions .qa {
    width: 100%;
    justify-content: stretch;
  }

  .qa-btn,
  .qa-badge {
    flex: 1 1 0;
    justify-content: center;
  }

  .qa-undo { flex: 0 0 30px; }

  .pager {
    padding: 12px 0 0;
    flex-wrap: wrap;
    justify-content: stretch;
  }

  .pager .page-info {
    width: 100%;
    margin-right: 0;
  }

  .pager .btn {
    flex: 1 1 0;
    justify-content: center;
  }

  .detail-inner { padding: 12px 10px 42px; }

  .back-link { margin-bottom: 10px; }

  .detail-header {
    padding: 14px;
  }

  .detail-header .num-row {
    flex-wrap: wrap;
    gap: 6px 10px;
  }

  .detail-header h1 {
    font-size: 18px;
    line-height: 1.28;
  }

  .detail-header .actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .detail-header .actions .qa {
    grid-column: 1 / -1;
  }

  .detail-header .actions .share-menu-wrap {
    width: 100%;
  }

  .detail-header .actions .share-menu {
    left: auto;
    right: 0;
    width: min(320px, calc(100vw - 36px));
  }

  .detail-header .actions .btn {
    justify-content: center;
    min-width: 0;
    width: 100%;
  }

  .handoff-backdrop {
    align-items: start;
    padding: 12px;
  }

  .handoff-shell {
    width: calc(100vw - 24px);
    max-height: calc(100dvh - 24px);
    border-radius: 12px;
  }

  .handoff-tabs {
    padding: 14px 14px 12px;
  }

  .handoff-tab {
    flex: 1 1 0;
    min-width: 0;
    height: 40px;
    padding: 0 10px;
    font-size: 13px;
  }

  .handoff-close {
    flex: 0 0 34px;
    width: 34px;
    height: 34px;
    font-size: 30px;
  }

  .handoff-panel {
    padding: 0 14px 18px;
  }

  .handoff-terminal-bar {
    grid-template-columns: 12px 12px 12px 1fr;
    gap: 7px;
    height: 38px;
    padding: 0 14px;
  }

  .handoff-terminal-bar .dot {
    width: 12px;
    height: 12px;
  }

  .handoff-terminal-bar .title {
    font-size: 12px;
  }

  .handoff-terminal pre {
    min-height: 128px;
    padding: 16px;
    font-size: 12px;
    line-height: 1.65;
  }

  .handoff-actions {
    align-items: stretch;
    flex-direction: column;
    gap: 8px;
    margin-top: 14px;
  }

  .handoff-actions .btn {
    width: 100%;
    height: 38px;
    font-size: 13px;
  }

  .handoff-options {
    margin-top: 18px;
  }

  .handoff-options-title {
    margin-bottom: 10px;
    font-size: 12px;
  }

  .handoff-check {
    gap: 10px;
    font-size: 14px;
  }

  .handoff-check input {
    width: 22px;
    height: 22px;
  }

  .handoff-check small {
    font-size: 12px;
  }

  .handoff-note {
    margin-top: 18px;
    font-size: 14px;
  }

  .handoff-note textarea {
    min-height: 78px;
    padding: 12px;
  }

  .meta-grid {
    grid-template-columns: 1fr;
  }

  .meta-grid .cell {
    min-height: 0;
    padding: 11px 0;
    border-right: 0 !important;
    border-bottom: 1px solid var(--border);
  }

  .meta-grid .cell:last-child { border-bottom: 0; }

  .meta-grid .cell .value.lg { font-size: 17px; }

  .classification {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .detail-tabs {
    height: 42px;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .detail-tabs::-webkit-scrollbar { display: none; }

  .detail-tab {
    flex: 0 0 auto;
    padding: 0 16px;
  }

  .section { margin-top: 18px; }

  .section-head {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .brief-main,
  .brief-estimate,
  .brief-mini > div,
  .cost-total,
  .cost-line,
  .team-line-title,
  .team-line,
  .profit-line {
    padding: 14px;
  }

  .brief-main h2 {
    font-size: 17px;
  }

  .disclosure-head {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .disclosure-subtitle {
    white-space: normal;
  }

  .mirofish-status-line {
    align-items: flex-start;
    flex-direction: column;
  }

  .mirofish-status-line > div {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .mirofish-status-line .btn { width: 100%; justify-content: center; }

  .summary-grid .card {
    padding: 14px;
  }

  .summary-grid .card .body {
    padding-left: 0;
  }

  .question-group {
    padding: 14px;
  }

  .question-add-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .comment-edit-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .comment-edit-actions .btn {
    width: 100%;
    justify-content: center;
  }

  .question-add-actions .btn {
    width: 100%;
    justify-content: center;
  }

  .sources-backdrop {
    padding: 12px;
  }

  .sources-drawer {
    width: 100%;
    max-height: 78vh;
  }

  .source-link {
    grid-template-columns: 34px minmax(0, 1fr) 18px;
    gap: 8px;
  }

  .docs table,
  .docs tbody,
  .docs tr,
  .docs td {
    display: block;
    width: 100%;
  }

  .docs thead { display: none; }

  .docs tbody tr {
    padding: 12px;
    border-bottom: 1px solid var(--border);
  }

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

  .docs tbody td {
    display: grid;
    grid-template-columns: 88px minmax(0, 1fr);
    gap: 12px;
    padding: 6px 0;
    border-bottom: 0;
  }

  .docs tbody td::before {
    color: var(--text-3);
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
  }

  .docs tbody td:nth-child(1)::before { content: "Документ"; }
  .docs tbody td:nth-child(2)::before { content: "Download"; }
  .docs tbody td:nth-child(3)::before { content: "Extraction"; }
  .docs tbody td:nth-child(4)::before { content: "Error"; }
  .docs tbody td:nth-child(5)::before { content: ""; }

  .docs .doc-name {
    align-items: flex-start;
    flex-wrap: wrap;
    min-width: 0;
    word-break: break-word;
  }

  .docs .doc-name .used {
    margin-left: 0;
  }

  .docs .doc-actions {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .chat-panel.embedded,
  .chat-panel.embedded .chat-box {
    min-height: 440px;
  }

  .chat-panel.embedded .section-head {
    padding-bottom: 8px;
  }

  .chat-history.conversation {
    min-height: 240px;
  }

  .conv-inner {
    max-width: none;
    padding: 18px 14px 28px;
    gap: 22px;
  }

  .chat-message.user .chat-content {
    max-width: 100%;
    padding: 11px 13px;
  }

  .chat-message.assistant .chat-message-head {
    flex-wrap: wrap;
  }

  .chat-head-spacer { display: none; }

  .chat-message-actions {
    opacity: 1;
    margin-left: auto;
  }

  .chat-edit-form {
    width: 100%;
  }

  .chat-content.md {
    font-size: 13px;
    line-height: 1.6;
  }

  .chat-content.md .md-table-wrap {
    margin-inline: -2px;
  }

  .chat-source {
    width: 100%;
  }

  .chat-composer {
    padding: 12px;
  }

  .prompts {
    flex-wrap: nowrap;
    margin-inline: -12px;
    padding: 0 12px 2px;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .prompts::-webkit-scrollbar { display: none; }

  .prompt-chip {
    flex: 0 0 auto;
    max-width: 82vw;
    white-space: normal;
  }

  .input-wrap textarea {
    min-height: 58px;
    padding: 12px 12px 4px;
  }

  .input-actions {
    flex-wrap: wrap;
    padding: 8px;
  }

  .chat-tools-menu {
    width: min(248px, calc(100vw - 40px));
  }

  .agent-toggle {
    flex: 1 1 auto;
  }

  .agent-toggle-btn {
    flex: 1 1 0;
  }

  .input-actions [data-chat-status] {
    order: 3;
    flex: 1 0 100%;
    min-height: 16px;
  }

  .chat-shortcut { display: none; }

  .send-btn {
    min-width: 112px;
    justify-content: center;
  }
}

@media (max-width: 420px) {
  .last-sync { display: none; }

  .detail-header .actions {
    grid-template-columns: 1fr;
  }

  .detail-header .actions .share-menu {
    width: calc(100vw - 48px);
  }

  .filter-group .label,
  .amount-range .label {
    width: 88px;
    flex-basis: 88px;
  }

  table.tenders tbody td:not(.col-title) {
    flex-direction: column;
    gap: 4px;
    text-align: left;
  }

  table.tenders tbody td::before {
    flex-basis: auto;
  }
}
