:root {
  --bg: #fafaf9;
  --surface: #ffffff;
  --border: #e7e5e4;
  --border-strong: #d6d3d1;
  --text: #0c0a09;
  --text-2: #44403c;
  --text-3: #78716c;
  --text-4: #a8a29e;
  --hover: #f5f5f4;
  --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: 52px;
  --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; }
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; }
.last-sync { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-3); white-space: nowrap; }
.last-sync .dot { width: 6px; height: 6px; border-radius: 50%; background: #16a34a; }
.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 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); }
.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 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-verdict { width: 130px; }
.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); }
.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; }
.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; }
.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; }
.classification { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border); display: flex; gap: 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; }
.verdict-block { margin-top: 16px; background: var(--surface); border: 1px solid var(--border); padding: 18px 22px; display: grid; grid-template-columns: 200px 1fr; gap: 28px; align-items: center; }
.verdict-block .v-label { font-size: 11px; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 6px; }
.verdict-block .v-value { display: flex; align-items: center; gap: 10px; font-size: 22px; font-weight: 600; }
.verdict-block .v-value .swatch { width: 14px; height: 14px; flex-shrink: 0; }
.verdict-block .v-reason { font-size: 13px; color: var(--text-2); line-height: 1.5; }
.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; }
.ai-box, .handoff-panel .handoff-text { background: var(--surface); border: 1px solid var(--border); }
.ai-box { padding: 14px; }
.ai-box textarea, .handoff-text { 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, .handoff-text: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; }
.handoff-text { min-height: 230px; padding: 12px; font-family: var(--mono); font-size: 12px; line-height: 1.55; }
.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; white-space: pre-wrap; }
.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; }
.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; }
.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; }
