/* HAYL v3 (preview, 10 Nov 2026): workspace layout and shared components.
   Loaded after styles.css, theme-light.css and restyle.css. Colours come from tokens only,
   so both themes follow. Layout: compact header + section tabs; overview = indicator strip,
   map workspace with deadlines and feed beside it, balance strip and charts below. */

:root:not([data-theme="light"]) {
  --bg: #121315; --side: #121315; --panel: #191b1e; --panel-2: #1f2226;
  --seam: #2a2d32; --seam-2: #3b3f46;
  --text: #f1ece1; --muted: #a9a79e; --dim: #8b8a83;
  --gold: #d6a544; --gold-ink: #1a1408;
  --hydro: #2bb3b1; --geo: #e07a4f; --wind: #8fb3d9; --solar: #e3cf6b; --thermal: #8b9096; --grid: #9a9ea3;
  --good: #7fc48f; --warn: #d6a544;
}
:root[data-theme="light"] {
  --bg: #f4f2ec; --side: #f4f2ec; --panel: #ffffff; --panel-2: #f6f4ef;
  --seam: #dedbd3; --seam-2: #c9c5ba;
  --text: #1b1c1e; --muted: #55575a; --dim: #66686b;
  --gold: #8f6410; --gold-ink: #ffffff;
  --hydro: #12898c; --geo: #c0502a; --wind: #4f7fae; --solar: #a8860f; --thermal: #7a7e83; --grid: #7a7e83;
  --good: #2f7d46; --warn: #8f6410;
}
:root { --r: 6px; --pad: 20px; }

html, body { font-size: 14px; }
body { display: block; }
main { max-width: 1760px; margin: 0 auto; padding: 12px var(--pad) 32px; }
section { scroll-margin-top: 104px; padding-top: 24px; }
#overview { padding-top: 0; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.num, td.num, .val b { font-variant-numeric: tabular-nums; }
.na { color: var(--dim); font-style: italic; }
.lnk { color: var(--gold); font-size: 12px; text-decoration: none; white-space: nowrap; }
.lnk:hover { text-decoration: underline; }
.skip { position: absolute; left: -999px; top: 8px; z-index: 60; background: var(--gold); color: var(--gold-ink); padding: 6px 10px; border-radius: 4px; text-decoration: none; }
.skip:focus { left: 8px; }

/* ---------- header ---------- */
.hdr { position: sticky; top: 0; z-index: 30; background: var(--bg); border-bottom: 1px solid var(--seam); }
.hdr-row { display: flex; align-items: center; gap: 16px; max-width: 1760px; margin: 0 auto; padding: 8px var(--pad); }
.hdr .brand { padding: 0; gap: 10px; flex: none; color: var(--text); }
.hdr .brand .mark { width: 30px; height: 30px; flex: none; }
.hdr .brand b { font-size: 15px; letter-spacing: .3em; line-height: 1.1; }
.hdr .brand small { font-size: 11px; margin-top: 2px; color: var(--muted); letter-spacing: 0; white-space: nowrap; }
.hdr .search { flex: 1 1 280px; width: auto; max-width: 560px; margin-left: 20px; }
.hdr .search input { height: 34px; border-radius: 5px; border-color: var(--seam-2); background: var(--panel); color: var(--text); }
.hdr .search input:focus { border-color: var(--gold); }
.hdr .search .icon { top: 9px; }
.hdr .search kbd { top: 7px; }
.hdr-meta { margin-left: auto; display: flex; align-items: center; gap: 12px; flex: none; }
.hdr .ed { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.2; }
.hdr .ed span { font-size: 11px; color: var(--muted); }
.hdr .ed b { font-size: 12.5px; font-weight: 500; color: var(--text); }
.hdr .theme-btn { width: 34px; height: 34px; border-radius: 5px; }
.hdr .btn { height: 34px; border-radius: 5px; }
.tabs { display: flex; align-items: stretch; gap: 2px; max-width: 1760px; margin: 0 auto; padding: 0 calc(var(--pad) - 10px); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a { display: inline-flex; align-items: center; gap: 6px; padding: 8px 10px 7px; color: var(--muted); text-decoration: none; font-size: 13px; white-space: nowrap; border-bottom: 2px solid transparent; }
.tabs a:hover { color: var(--text); }
.tabs a.active { color: var(--text); border-bottom-color: var(--gold); }
.tabs a:focus-visible { outline-offset: -2px; }
.tabs .badge { font-family: var(--mono); font-size: 11px; color: var(--muted); border: 1px solid var(--seam-2); border-radius: 3px; padding: 0 5px; line-height: 16px; }
.tabs .badge:empty { display: none; }
.tabs-sep { flex: none; width: 1px; margin: 9px 6px; background: var(--seam-2); }
.hdr .tibeb { height: 3px; margin: 0; border: 0; opacity: .7;
  background: repeating-linear-gradient(90deg, var(--gold) 0 12px, transparent 12px 16px, var(--geo) 16px 22px, transparent 22px 26px, var(--hydro) 26px 38px, transparent 38px 42px, var(--geo) 42px 48px, transparent 48px 52px); }
.hdr .tibeb svg { display: none; }

/* ---------- panels ---------- */
.panel { padding: 12px 14px; border-radius: var(--r); }
.panel h3 { font-size: 13.5px; font-weight: 600; }
.panel .sub { font-size: 12px; margin-top: 2px; }
.panel-head { margin-bottom: 10px; align-items: flex-start; }
.sec-head { margin-bottom: 10px; flex-wrap: wrap; }
.sec-head h2 { font-size: 19px; }

/* ---------- indicator strip ---------- */
.inds { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 1px; background: var(--seam); border: 1px solid var(--seam); border-radius: var(--r); overflow: hidden; }
.ind { background: var(--panel); padding: 9px 14px 8px; min-width: 0; }
.ind-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.ind-l { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; color: var(--muted); min-width: 0; }
.ind-l i { width: 6px; height: 6px; border-radius: 50%; flex: none; }
.ind-p { font-size: 11px; color: var(--dim); white-space: nowrap; }
.ind .val { display: flex; align-items: baseline; gap: 6px; margin-top: 3px; }
.ind .val b { font-size: 24px; font-weight: 500; line-height: 1.15; letter-spacing: -.01em; }
.ind .val span { font-size: 12px; color: var(--muted); }
.ind-d { font-size: 11.5px; color: var(--muted); margin-top: 1px; min-height: 17px; }
.ind-d em { font-style: normal; color: var(--text); }
.ind-s { font-size: 11px; color: var(--dim); margin-top: 3px; }
.ind-type { border: 1px solid var(--seam-2); border-radius: 3px; padding: 0 5px; margin-right: 6px; color: var(--muted); }

/* ---------- overview workspace ---------- */
.ws { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(360px, 1fr); gap: 12px; margin-top: 12px; }
.ws-side { display: flex; flex-direction: column; gap: 12px; min-width: 0; height: 0; min-height: 100%; }
.dl-panel { flex: none; }
.feed-panel { flex: 1 1 0; min-height: 0; display: flex; flex-direction: column; }
.feed-panel .rows { flex: 1; min-height: 0; overflow-y: auto; margin-right: -6px; padding-right: 6px; }
.ov-charts { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr); gap: 12px; margin-top: 12px; align-items: start; }
#overview .flow { margin-top: 12px; padding-top: 12px; }
.map-panel .legend { margin-top: 10px; padding-top: 10px; gap: 12px; }
.map-panel .src { margin-top: 8px; font-size: 11.5px; }
#map .bubble .ring { transition: stroke-width .15s; }
#map .bubble.sel .ring { stroke-width: 2.8px; }
#map .bubble:focus-visible { outline: none; }
#map .bubble:focus-visible .ring { stroke-width: 2.8px; stroke: var(--gold); }
#map:has(.bubble.sel) .bubble:not(.sel) { opacity: .45; }
.asset-card { border-radius: var(--r); background: var(--panel); }

/* ---------- scannable rows (signals, edition changes) ---------- */
.rows-h { font-size: 12px; font-weight: 600; color: var(--dim); padding: 8px 6px 5px; border-bottom: 1px solid var(--seam-2); position: sticky; top: 0; background: var(--panel); z-index: 1; }
.rows-h:first-child { padding-top: 0; }
.rows-none { margin: 0; padding: 9px 6px; font-size: 12.5px; color: var(--muted); border-bottom: 1px solid var(--seam); }
.row { display: grid; grid-template-columns: 88px 104px minmax(0, 1fr) auto; gap: 2px 12px; align-items: baseline; width: 100%; padding: 7px 6px; background: none; border: 0; border-bottom: 1px solid var(--seam); color: inherit; font: inherit; text-align: left; text-decoration: none; cursor: pointer; }
.row:hover { background: var(--panel-2); }
.row:focus-visible { outline-offset: -2px; }
.row-d { font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.row-c { font-size: 12px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.row-c i { width: 6px; height: 6px; border-radius: 50%; flex: none; }
.row-t { min-width: 0; }
.row-t b { display: block; font-size: 13px; font-weight: 600; line-height: 1.35; }
.row-t span { display: block; font-size: 12px; color: var(--muted); line-height: 1.4; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.tag { display: inline-block; font-size: 11px; line-height: 16px; padding: 0 6px; border: 1px solid currentColor; border-radius: 3px; white-space: nowrap; }
.tag.new { color: var(--good); }
.tag.upd { color: var(--gold); }
.tag.hist { color: var(--muted); border-style: dashed; }
.tag.none { visibility: hidden; padding: 0; border: 0; }
.ws-side .row, .rows.narrow .row { grid-template-columns: 84px minmax(0, 1fr) auto; }
.ws-side .row-d { grid-column: 1; grid-row: 1; }
.ws-side .row-c { grid-column: 1; grid-row: 2; }
.ws-side .row-t { grid-column: 2; grid-row: 1 / 3; }
.ws-side .row .tag { grid-column: 3; grid-row: 1 / 3; align-self: start; }
.ws-side .row .tag.hist { max-width: 104px; white-space: normal; line-height: 1.25; padding: 1px 6px; }

/* ---------- deadline summary ---------- */
.dlrow { display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: 10px; align-items: start; padding: 7px 6px; border-top: 1px solid var(--seam); color: inherit; text-decoration: none; }
.dlrow:hover { background: var(--panel-2); }
.dl-t b { display: block; font-size: 13px; font-weight: 600; line-height: 1.35; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.dl-t span { display: block; font-size: 12px; color: var(--muted); line-height: 1.4; }
.dls .more { display: block; padding: 7px 6px 0; border-top: 1px solid var(--seam); }
.dl-pill { border-radius: 3px; text-align: center; font-size: 11.5px; padding: 1px 6px; background: transparent; }
.dl-pill[data-state="open"] { color: var(--good); border-color: color-mix(in srgb, var(--good) 50%, transparent); background: transparent; }
.dl-pill[data-state="soon"] { color: var(--gold); border-color: var(--gold); background: color-mix(in srgb, var(--gold) 12%, transparent); font-weight: 500; }
.dl-pill[data-state="closed"] { color: var(--muted); border-color: var(--seam-2); }
.opp { border-radius: var(--r); padding: 12px 14px; }

/* ---------- tables ---------- */
.table-wrap { margin: 0; }
.table-wrap.tall { max-height: min(72vh, 660px); overflow: auto; border: 1px solid var(--seam); border-radius: 4px; }
table { font-size: 12.5px; }
th { position: sticky; top: 0; z-index: 2; background: var(--panel-2); font-size: 11.5px; font-weight: 600; letter-spacing: 0; text-transform: none; color: var(--muted); padding: 7px 10px; border-bottom: 1px solid var(--seam-2); }
td { padding: 7px 10px; border-bottom: 1px solid var(--seam); }
tbody tr:hover > td { background: color-mix(in srgb, var(--panel-2) 70%, transparent); }
th button { display: inline-flex; align-items: center; gap: 5px; }
th .sort { color: var(--dim); font-family: var(--mono); }
th[aria-sort="ascending"] button, th[aria-sort="descending"] button { color: var(--text); }
th[aria-sort="ascending"] .sort, th[aria-sort="descending"] .sort { color: var(--gold); }
th.c, td.c { width: 34px; padding-right: 0; }
input.cmp { width: 16px; height: 16px; margin: 1px 0 0; accent-color: var(--gold); cursor: pointer; }
input.cmp:disabled { cursor: not-allowed; opacity: .4; }
.tlink { background: none; border: 0; border-bottom: 1px dotted var(--seam-2); padding: 0; font: inherit; font-weight: 600; color: var(--text); text-align: left; cursor: pointer; }
.tlink:hover { color: var(--gold); border-bottom-color: var(--gold); }
.td-sub { font-size: 11.5px; color: var(--dim); margin-top: 1px; }
td.ms { min-width: 260px; max-width: 520px; }
.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
#projTable { min-width: 900px; }
#assetTable { min-width: 860px; }
.cmp-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; min-height: 28px; margin: 0 0 8px; font-size: 12.5px; }
.stage { border-radius: 3px; font-size: 11.5px; padding: 0 7px; line-height: 18px; background: transparent; border-color: color-mix(in srgb, currentColor 45%, transparent); }
.stage.operating { color: var(--good); background: transparent; border-color: color-mix(in srgb, var(--good) 45%, transparent); }
.stage.construction { color: var(--gold); background: transparent; border-color: color-mix(in srgb, var(--gold) 55%, transparent); }
.stage.tender, .stage.procurement { color: var(--wind); background: transparent; border-color: color-mix(in srgb, var(--wind) 50%, transparent); }
.stage.financing { color: var(--hydro); background: transparent; border-color: color-mix(in srgb, var(--hydro) 50%, transparent); }
.stage.development, .stage.planned { color: var(--muted); border-color: var(--seam-2); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.results { background: var(--panel-2); border-radius: var(--r); }
.results button:hover, .results button.sel { background: var(--seam); }

/* ---------- detail drawer and comparison ---------- */
dialog { background: var(--panel); }
dialog::backdrop { background: rgba(8, 9, 10, .62); }
dialog.drawer { position: fixed; inset: 0 0 0 auto; margin: 0; width: min(540px, 100vw); max-width: 100vw; height: 100dvh; max-height: 100dvh; padding: 0; border: 0; border-left: 1px solid var(--seam-2); border-radius: 0; display: none; flex-direction: column; }
dialog.drawer[open], dialog.cmp-dlg[open] { display: flex; }
dialog.cmp-dlg { width: min(1120px, calc(100vw - 24px)); max-width: none; max-height: calc(100dvh - 24px); padding: 0; border-radius: var(--r); display: none; flex-direction: column; }
.drawer-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 14px 18px 12px; border-bottom: 1px solid var(--seam); flex: none; }
.drawer-k { font-size: 12px; color: var(--gold); }
.drawer-head h3 { margin: 3px 0 0; font-family: var(--sans); font-size: 17px; font-weight: 600; line-height: 1.3; outline: none; }
.drawer-head .x { flex: none; width: 34px; height: 34px; border: 1px solid var(--seam-2); border-radius: 5px; background: none; color: var(--muted); font-size: 20px; line-height: 1; cursor: pointer; }
.drawer-head .x:hover { color: var(--text); border-color: var(--dim); }
.drawer-body { padding: 14px 18px 24px; overflow: auto; min-height: 0; font-size: 13.5px; line-height: 1.55; }
.drawer-body p { margin: 0 0 10px; color: var(--text); font-size: 13.5px; line-height: 1.55; }
.drawer-body p.muted, .drawer-body .sub { color: var(--muted); font-size: 12.5px; }
.drawer-body .sub { margin: 10px 0 0; }
.drawer-body h4 { margin: 16px 0 7px; padding-top: 11px; border-top: 1px solid var(--seam); font-size: 12px; font-weight: 600; color: var(--muted); }
.kv { display: grid; grid-template-columns: minmax(120px, max-content) minmax(0, 1fr); gap: 5px 14px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.srcl { margin: 0; padding-left: 18px; display: grid; gap: 7px; }
.srcl .slink { color: var(--text); text-decoration: underline; text-decoration-color: var(--seam-2); text-underline-offset: 3px; }
.srcl .slink:hover { color: var(--gold); text-decoration-color: var(--gold); }
.srcl .skind, .srcl .schk { color: var(--muted); font-size: 12px; }
.rec { margin-top: 16px !important; font-family: var(--mono); font-size: 11px !important; color: var(--dim) !important; }
#cmpTable { font-size: 12.5px; }
#cmpTable td { min-width: 230px; vertical-align: top; line-height: 1.5; }
#cmpTable tbody th { position: sticky; left: 0; z-index: 1; min-width: 130px; white-space: normal; vertical-align: top; background: var(--panel-2); border-bottom: 1px solid var(--seam); border-right: 1px solid var(--seam-2); }
#cmpTable thead th { font-size: 13px; color: var(--text); white-space: normal; }
#cmpTable thead th:first-child { left: 0; z-index: 3; }
.cmp-dlg .table-wrap { overflow: auto; }

/* ---------- responsive ---------- */
@media (max-width: 1180px) {
  .ws { grid-template-columns: minmax(0, 1fr); }
  .ws-side { height: auto; min-height: 0; }
  .feed-panel .rows { max-height: 430px; }
  .inds { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .inds .ind:last-child { grid-column: span 2; }
}
@media (max-width: 900px) {
  :root { --pad: 16px; }
  .ov-charts { grid-template-columns: minmax(0, 1fr); }
  .row { grid-template-columns: 84px minmax(0, 1fr) auto; }
  .row-d { grid-column: 1; grid-row: 1; }
  .row-c { grid-column: 1; grid-row: 2; }
  .row-t { grid-column: 2; grid-row: 1 / 3; }
  .row .tag { grid-column: 3; grid-row: 1 / 3; align-self: start; }
}
@media (max-width: 720px) {
  .hdr { top: -94px; }
  .hdr-row { flex-wrap: wrap; gap: 8px 12px; }
  .hdr .search { order: 3; flex-basis: 100%; max-width: none; margin-left: 0; }
  .hdr .search input { height: 38px; }
  .hdr .search kbd { display: none; }
  .tabs a { padding: 11px 10px 10px; }
  section { scroll-margin-top: 56px; }
  .inds { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .inds .ind:last-child { grid-column: span 2; }
  .row { grid-template-columns: minmax(0, 1fr) auto; padding: 9px 4px; }
  .row-d { grid-column: 1; grid-row: 1; }
  .row-c { grid-column: 2; grid-row: 1; justify-self: end; }
  .row-t, .ws-side .row-t { grid-column: 1 / 3; grid-row: 2; }
  .row .tag, .ws-side .row .tag { grid-column: 1 / 3; grid-row: 3; justify-self: start; }
  .row .tag.none { display: none; }
  .ws-side .row { grid-template-columns: minmax(0, 1fr) auto; }
  .ws-side .row-c { grid-column: 2; grid-row: 1; }
  .row-t span { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
  .dlrow { grid-template-columns: minmax(0, 1fr); gap: 4px; padding: 9px 4px; }
  .dlrow .dl-pill { justify-self: start; }
  .dl-t b { white-space: normal; }
  dialog.drawer { inset: auto 0 0 0; width: 100vw; height: min(88dvh, 100dvh); border-left: 0; border-top: 1px solid var(--seam-2); border-radius: 12px 12px 0 0; }
  .drawer-head .x { width: 40px; height: 40px; }
  .kv { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .kv dd { margin-bottom: 8px; }
  input.cmp { width: 20px; height: 20px; }
  .table-wrap.tall { max-height: 70vh; }
}
@media (max-width: 420px) {
  .hdr .brand small { display: none; }
  .hdr .ed span { display: none; }
}
@media print {
  .hdr { position: static; }
  .tabs, .hdr .search, .hdr .theme-btn, .skip { display: none; }
  .table-wrap.tall { max-height: none; overflow: visible; }
  .ws-side { height: auto; }
}

/* fixes after first review */
.stack { grid-template-columns: minmax(0, 1fr); }
.dlrow { grid-template-columns: 128px minmax(0, 1fr); }
.dl-pill { white-space: nowrap; }
@media (max-width: 720px) { .dlrow { grid-template-columns: minmax(0, 1fr); } }
.table-wrap { position: relative; } /* keeps visually hidden labels inside the scroll area */
.drawer-body .stage { margin-right: 8px; }
@media (max-width: 720px) { .ind-top { flex-direction: column; gap: 0; } .ind-p { order: -1; } }

/* tenders closing today or tomorrow: a quiet pulse draws the eye; the text label carries the meaning */
@media screen and (prefers-reduced-motion: no-preference) {
  .dl-pill[data-urgent] { animation: hayl-urgent 2.4s ease-out infinite; }
}
@keyframes hayl-urgent { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--gold) 55%, transparent); } 70%, 100% { box-shadow: 0 0 0 6px transparent; } }
