/* EY Tender Radar — light-corporate design system */
:root {
  --bg: #f6f7f9; --surface: #ffffff; --surface2: #fbfbfd; --raised: #ffffff;
  --line: #e6e8ee; --line2: #eef0f4;
  --tx: #1b2230; --tx2: #5a6474; --tx3: #97a0af;
  --accent: #3b5bdb; --accent-hover: #2f4bc4; --accent-soft: #eef1fd; --accent-tx: #ffffff;
  --ey: #ffe600;
  --good: #2f9e57; --good-soft: #e7f4ec;
  --warn: #c98a1a; --warn-soft: #fbf1de;
  --bad: #d64545; --bad-soft: #fbe9e9;
  --info: #3b5bdb; --slate: #8a93a3;
  --radius: 10px; --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(20,26,45,.05);
  --shadow: 0 6px 24px rgba(20,26,45,.10);
  --sb: 236px; --fs: 13.5px;
}
:root[data-theme="dark"] {
  --bg: #14161c; --surface: #1b1e26; --surface2: #191c23; --raised: #21252f;
  --line: #2b2f3a; --line2: #262a33;
  --tx: #e8eaf0; --tx2: #9aa2b1; --tx3: #6b7280;
  --accent: #6b8afd; --accent-hover: #7f9bff; --accent-soft: #222842; --accent-tx: #0e1424;
  --good: #46c479; --good-soft: #16281f; --warn: #e0a53a; --warn-soft: #2a2113;
  --bad: #f06060; --bad-soft: #2c1717; --info: #6b8afd; --slate: #7b8494;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.3); --shadow: 0 10px 34px rgba(0,0,0,.45);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: -apple-system, "Segoe UI", Roboto, Inter, Arial, sans-serif; background: var(--bg); color: var(--tx); font-size: var(--fs); -webkit-font-smoothing: antialiased; }
.hidden { display: none !important; }
button { font-family: inherit; cursor: pointer; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.icon { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.tnum { font-variant-numeric: tabular-nums; }

/* Logomark */
.logomark { display: inline-block; width: 22px; height: 22px; border-radius: 6px; background: var(--accent); position: relative; flex: none; }
.logomark::before { content: ""; position: absolute; inset: 5px; border-radius: 50%; border: 1.5px solid rgba(255,255,255,.55); }
.logomark::after { content: ""; position: absolute; left: 9px; top: 9px; width: 4px; height: 4px; border-radius: 50%; background: #fff; }

/* Login */
.login { position: fixed; inset: 0; display: grid; place-items: center; background: radial-gradient(900px 500px at 70% -10%, var(--accent-soft), var(--bg)); }
.login-card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 34px 30px; width: min(370px, 92vw); box-shadow: var(--shadow); text-align: center; }
.login-logo { font-size: 20px; font-weight: 700; display: flex; gap: 10px; align-items: center; justify-content: center; }
.login-sub { color: var(--tx2); font-size: 12px; margin: 10px 0 22px; line-height: 1.5; }
.login-card input { width: 100%; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface2); color: var(--tx); font-size: 15px; }
.login-card input + input { margin-top: 10px; }
.login-card .login-logo + input { margin-top: 20px; }
.login-card input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.login-card button { width: 100%; margin-top: 12px; padding: 12px; border: 0; border-radius: 10px; background: var(--accent); color: var(--accent-tx); font-weight: 600; font-size: 15px; }
.login-card button:hover { background: var(--accent-hover); }
.login-err { color: var(--bad); font-size: 13px; min-height: 18px; margin-top: 10px; }

/* Shell */
.app { display: grid; grid-template-columns: var(--sb) 1fr; height: 100vh; }
.sidebar { background: var(--surface); border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 18px 12px; gap: 4px; }
.brand { font-weight: 700; font-size: 15px; padding: 4px 10px 16px; display: flex; gap: 10px; align-items: center; letter-spacing: -.01em; }
.nav { display: flex; flex-direction: column; gap: 1px; overflow-y: auto; flex: 1; }
.nav .group { color: var(--tx3); font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .09em; padding: 16px 12px 5px; }
.nav button { position: relative; display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 8px 12px; border: 0; border-radius: 8px; background: transparent; color: var(--tx2); font-size: 13px; }
.nav button:hover { background: var(--surface2); color: var(--tx); }
.nav button.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav button.active .icon { stroke: var(--accent); }
.nav button .badge { margin-left: auto; background: var(--line2); color: var(--tx2); font-size: 11px; font-weight: 600; border-radius: 20px; padding: 1px 8px; min-width: 22px; text-align: center; }
.nav button.active .badge { background: var(--accent); color: var(--accent-tx); }
.side-foot { display: flex; gap: 6px; padding-top: 12px; border-top: 1px solid var(--line); }
.ghost { background: transparent; border: 1px solid var(--line); color: var(--tx2); border-radius: 8px; padding: 7px 9px; display: inline-flex; align-items: center; justify-content: center; }
.ghost:hover { color: var(--tx); border-color: var(--tx3); background: var(--surface2); }

/* Main */
.main { display: flex; flex-direction: column; min-width: 0; overflow: hidden; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 16px 26px; border-bottom: 1px solid var(--line); background: var(--surface); }
.topbar h1 { margin: 0; font-size: 18px; font-weight: 650; letter-spacing: -.01em; }
.poll-info { color: var(--tx3); font-size: 11.5px; margin-top: 3px; }
.search { width: min(320px, 40vw); padding: 9px 13px; border-radius: 9px; border: 1px solid var(--line); background: var(--surface2); color: var(--tx); }
.search:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.content { padding: 22px 26px; overflow-y: auto; flex: 1; }

/* KPI cards */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(158px, 1fr)); gap: 12px; margin-bottom: 18px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 15px 16px; box-shadow: var(--shadow-sm); }
.card .k { color: var(--tx2); font-size: 12px; }
.card .v { font-size: 25px; font-weight: 700; margin-top: 6px; letter-spacing: -.02em; }
.card.accent .v { color: var(--accent); }
.card.warn .v { color: var(--warn); }

/* Filters */
.filters { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 14px; align-items: center; }
.chip { border: 1px solid var(--line); background: var(--surface); color: var(--tx2); border-radius: 8px; padding: 6px 12px; font-size: 12.5px; }
.chip:hover { color: var(--tx); border-color: var(--tx3); }
.chip.active { background: var(--accent); color: var(--accent-tx); border-color: var(--accent); font-weight: 600; }

/* Country code badge */
.cc { display: inline-flex; align-items: center; justify-content: center; min-width: 30px; height: 22px; padding: 0 7px; border-radius: 6px; font-size: 11px; font-weight: 700; letter-spacing: .03em; background: var(--line2); color: var(--tx2); border: 1px solid var(--line); }
.cc.KZ { background: #eaf1fb; color: #2a5fb0; border-color: #d6e4f7; }
.cc.UZ { background: #e9f5ee; color: #2b7d4c; border-color: #d3ecdb; }
.cc.KG { background: #fdeeee; color: #b8443f; border-color: #f6dada; }
.cc.AC { background: #f2eefc; color: #6b45c0; border-color: #e6dcf7; }
:root[data-theme="dark"] .cc { background: var(--raised); color: var(--tx2); border-color: var(--line); }

/* Table */
.table-wrap { border: 1px solid var(--line); border-radius: var(--radius-lg); overflow: auto; background: var(--surface); box-shadow: var(--shadow-sm); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 15px; border-bottom: 1px solid var(--line2); font-size: 13px; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
th { color: var(--tx3); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; position: sticky; top: 0; background: var(--surface); cursor: pointer; user-select: none; z-index: 1; }
th:hover { color: var(--tx2); }
tbody tr { cursor: pointer; transition: background .1s; }
tbody tr:hover { background: var(--surface2); }
td.title-cell { white-space: normal; max-width: 440px; }
td.title-cell b { font-weight: 600; }
td.title-cell .cust { color: var(--tx3); font-size: 11.5px; display: block; margin-top: 2px; }

/* Competitors table: fixed layout so every column (incl. the last) stays visible without
   horizontal scroll; Subject/Customer wrap instead of pushing width. */
.comp-table { table-layout: fixed; width: 100%; }
.comp-table col.c-firm { width: 90px; } .comp-table col.c-type { width: 64px; }
.comp-table col.c-subject { width: auto; } .comp-table col.c-customer { width: 18%; }
.comp-table col.c-amount { width: 100px; } .comp-table col.c-date { width: 100px; }
.comp-table col.c-sl { width: 130px; }
.comp-table td.wrap { white-space: normal; overflow-wrap: break-word; }
.comp-table col.c-winner { width: 220px; } .comp-table col.c-year { width: 70px; }

/* Archive search page */
.archive-search-row { display: flex; align-items: center; gap: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 12px 16px; margin-bottom: 14px; box-shadow: var(--shadow-sm); }
.archive-search-row .icon { stroke: var(--tx3); flex: none; }
.archive-search-input { flex: 1; border: 0; background: transparent; color: var(--tx); font-size: 15px; }
.archive-search-input:focus { outline: none; }
.archive-search-row .btn { flex: none; white-space: nowrap; }
.btn.ghost-btn { background: var(--accent-soft); color: var(--accent); display: inline-flex; align-items: center; gap: 6px; }
.btn.ghost-btn .icon { stroke: var(--accent); width: 14px; height: 14px; }
.btn.ghost-btn:hover { background: var(--line2); }
.archive-terms { color: var(--tx2); font-size: 12.5px; margin-bottom: 14px; }
.term-chip { display: inline-block; background: var(--surface2); border: 1px solid var(--line); border-radius: 20px; padding: 2px 10px; margin: 2px 4px; font-size: 12px; color: var(--tx2); }
/* Source status — state of the tender on its origin portal (see server/source-status.js).
   `.computed` is the deadline-derived fallback for portals that don't expose a status. */
.srcst { display: inline-block; max-width: 150px; border-radius: 6px; padding: 2px 8px; font-size: 11.5px; font-weight: 600; white-space: normal; line-height: 1.35; }
.srcst.open { background: var(--good-soft); color: var(--good); }
.srcst.wip { background: var(--warn-soft); color: var(--warn); }
.srcst.done { background: var(--line2); color: var(--tx2); }
.srcst.bad { background: var(--bad-soft); color: var(--bad); }
.srcst.other { background: var(--surface2); color: var(--tx2); border: 1px solid var(--line); }
.srcst.computed { background: transparent; color: var(--tx3); font-style: italic; font-weight: 500; border: 1px dashed var(--line); }

/* (i) in the Source status header */
.th-with-info { display: inline-flex; align-items: center; gap: 5px; }
.th-info { background: none; border: 0; padding: 0; display: inline-flex; border-radius: 4px; color: var(--tx3); transition: color .12s; }
.th-info:hover, .th-info.on { color: var(--accent); }
.th-info:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.th-info .icon { width: 13px; height: 13px; }

/* Status key — reference panel toggled by the (i). Width is capped so a description never drifts
   far from the badge it explains; the two groups sit side by side to use the space instead. */
.sk { max-width: 860px; margin: 0 0 16px; background: var(--surface); border: 1px solid var(--line);
      border-radius: var(--radius-lg); padding: 16px 18px 14px; box-shadow: var(--shadow-sm);
      animation: sk-in .16s ease; }
@keyframes sk-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .sk { animation: none; } }
.sk-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.sk-head h3 { margin: 0; font-size: 14px; font-weight: 650; letter-spacing: -.01em; }
.sk-close { background: none; border: 0; padding: 0 2px; font-size: 18px; line-height: 1; color: var(--tx3); border-radius: 4px; }
.sk-close:hover { color: var(--tx); }
.sk-close:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sk-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 22px 34px; }
.sk-eyebrow { color: var(--tx3); font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .09em; margin-bottom: 10px; }
.sk-list, .sk-exits, .sk-flow { list-style: none; margin: 0; padding: 0; }

/* The grid lives on the LIST, not the row: rows are `display: contents` so their badge and text
   become cells of one shared grid. That gives the badge column a single width for the whole
   group, so every description starts on the same vertical line. */
.sk-row, .sk-flow, .sk-exits { display: contents; }
.sk-portal { display: grid; grid-template-columns: 13px max-content 1fr; column-gap: 10px; }
.sk-list { display: grid; grid-template-columns: max-content 1fr; column-gap: 10px; }
.sk-div { grid-column: 1 / -1; border-top: 1px solid var(--line2); margin: 10px 0; }
.sk-row .srcst { max-width: none; align-self: start; margin: 4px 0; }
.sk-desc { margin: 0; padding: 5px 0; color: var(--tx2); font-size: 12.5px; line-height: 1.45; align-self: start; }

/* Portal statuses are a pipeline, so each step carries a ring plus a connector down to the next
   one. The connector is drawn per-row and stretched to the row's height, so it lines up no matter
   how tall a description wraps. The two states that leave the pipeline sit below a hairline with
   an empty marker cell — off the track, visually as well as literally. */
.sk-dot { align-self: stretch; position: relative; }
.sk-dot.step::before, .sk-dot.last::before { content: ''; position: absolute; top: 10px; left: 3px;
  width: 7px; height: 7px; border-radius: 50%; background: var(--surface); border: 1.5px solid var(--tx3); }
.sk-dot.step::after { content: ''; position: absolute; top: 21px; bottom: -1px; left: 6px; width: 1px; background: var(--line); }
.sk-note { margin: 16px 0 0; padding-top: 12px; border-top: 1px solid var(--line2); color: var(--tx3); font-size: 12px; line-height: 1.5; }
@media (max-width: 760px) { .sk-cols { grid-template-columns: 1fr; } }

.score { display: inline-block; min-width: 32px; text-align: center; border-radius: 6px; padding: 2px 7px; font-weight: 700; font-size: 12px; }
.score.hi { background: var(--good-soft); color: var(--good); }
.score.mid { background: var(--warn-soft); color: var(--warn); }
.dl { font-variant-numeric: tabular-nums; }
.dl.soon { color: var(--bad); font-weight: 600; }
.dl.near { color: var(--warn); }
.muted { color: var(--tx3); }

/* Status select */
.status-sel { border: 1px solid var(--line); background: var(--surface2); color: var(--tx); border-radius: 7px; padding: 5px 9px; font-size: 12px; }
.status-sel:focus { outline: none; border-color: var(--accent); }

/* Drawer */
.drawer { position: fixed; inset: 0; z-index: 50; }
.drawer-scrim { position: absolute; inset: 0; background: rgba(20,26,45,.38); backdrop-filter: blur(1px); }
.drawer-panel { position: absolute; right: 0; top: 0; height: 100%; width: min(580px, 95vw); background: var(--surface); border-left: 1px solid var(--line); box-shadow: var(--shadow); overflow-y: auto; padding: 24px 26px; animation: slidein .18s ease; }
@keyframes slidein { from { transform: translateX(24px); opacity: .5; } to { transform: none; opacity: 1; } }
.drawer-panel h2 { margin: 0 34px 4px 0; font-size: 18px; line-height: 1.4; font-weight: 650; }
.dw-meta { display: flex; flex-wrap: wrap; gap: 7px; margin: 14px 0; }
.pill { background: var(--surface2); border: 1px solid var(--line); border-radius: 7px; padding: 4px 10px; font-size: 12px; color: var(--tx2); }
.dw-section { margin-top: 20px; }
.dw-section .lbl { color: var(--tx3); font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; margin-bottom: 7px; }
.dw-section p { margin: 0; line-height: 1.6; color: var(--tx); }
.notes { width: 100%; min-height: 92px; border: 1px solid var(--line); background: var(--surface2); color: var(--tx); border-radius: 10px; padding: 10px 12px; font: inherit; resize: vertical; }
.notes:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.save-row { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.btn { background: var(--accent); color: var(--accent-tx); border: 0; border-radius: 9px; padding: 9px 16px; font-weight: 600; }
.btn:hover { background: var(--accent-hover); }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: 6px 0 6px 13px; color: var(--tx2); font-size: 12.5px; border-left: 2px solid var(--line); }
.close-x { position: absolute; top: 18px; right: 20px; font-size: 20px; line-height: 1; color: var(--tx3); background: none; border: 0; }
.close-x:hover { color: var(--tx); }

/* Charts + health */
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 18px; box-shadow: var(--shadow-sm); }
.panel h3 { margin: 0 0 14px; font-size: 13.5px; font-weight: 600; }
.health-group { margin-bottom: 22px; }
.health-group:last-child { margin-bottom: 0; }
.health-group-title { color: var(--tx3); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .09em; padding: 0 0 8px; }
.health-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
.hsrc { display: flex; align-items: center; gap: 11px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); box-shadow: var(--shadow-sm); }
.hsrc .dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.hsrc .dot.ok { background: var(--good); } .hsrc .dot.bad { background: var(--bad); }
.hsrc .nm { font-size: 12.5px; font-weight: 500; } .hsrc .ct { margin-left: auto; font-weight: 700; font-variant-numeric: tabular-nums; }
.empty { color: var(--tx3); text-align: center; padding: 54px; }

@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 40; left: 0; top: 0; bottom: 0; width: 220px; transform: translateX(-100%); transition: .2s; }
  .sidebar.open { transform: none; }
  .search { width: 44vw; }
  .grid2 { grid-template-columns: 1fr; }
}
