/* NASA Procurement report */
:root {
  color-scheme: light;
  --bg: #f4f4f2;
  --surface: #fcfcfb;
  --surface-2: #f0efec;
  --border: #dddcd7;
  --text: #0b0b0b;
  --text-2: #52514e;
  --text-3: #75736e;
  --brand: #e00000;
  --brand-ink: #c40000;
  --link: #1c5cab;
  --focus: #2a78d6;
  --grid: #e7e6e2;
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100;
  --s5: #e87ba4; --s6: #008300; --s7: #6250d6; --s8: #e34948;
  --neg: #c4314b;
  --pos: #18794e;
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 4px 16px rgba(0,0,0,.05);
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #111110; --surface: #1a1a19; --surface-2: #232321; --border: #34342f;
    --text: #f0efec; --text-2: #c3c2b7; --text-3: #95948b;
    --brand: #ff2b2b; --brand-ink: #ff5a5a; --link: #86b6ef; --focus: #5598e7; --grid: #2b2b28;
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
    --s5: #d55181; --s6: #0ca30c; --s7: #9085e9; --s8: #e66767;
    --neg: #f07a8c; --pos: #4cc38a;
    --shadow: 0 1px 2px rgba(0,0,0,.4);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111110; --surface: #1a1a19; --surface-2: #232321; --border: #34342f;
  --text: #f0efec; --text-2: #c3c2b7; --text-3: #95948b;
  --brand: #ff2b2b; --brand-ink: #ff5a5a; --link: #86b6ef; --focus: #5598e7; --grid: #2b2b28;
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
  --s5: #d55181; --s6: #0ca30c; --s7: #9085e9; --s8: #e66767;
  --neg: #f07a8c; --pos: #4cc38a;
  --shadow: 0 1px 2px rgba(0,0,0,.4);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.45 "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-variant-numeric: tabular-nums;
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* Header */
.top {
  position: sticky; top: 0; z-index: 1000;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--border);
}
.top-inner { max-width: 1480px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.logo { height: 44px; width: auto; display: block; }
.brandline { display: flex; align-items: center; gap: 14px; min-width: 0; }
.brandline .sub { color: var(--text-2); font-size: 12.5px; line-height: 1.3; max-width: 360px; }
.tabs { display: flex; gap: 4px; margin-left: auto; background: var(--surface-2); padding: 3px; border-radius: 9px; }
.tab { border: 0; background: transparent; padding: 7px 14px; border-radius: 7px; cursor: pointer; color: var(--text-2); font-weight: 600; white-space: nowrap; }
.tab[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.social { margin-left: auto; display: inline-flex; align-items: center; gap: 7px; padding: 6px 11px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: #563acc; font-weight: 600; font-size: 13px; white-space: nowrap; }
.social:hover { text-decoration: none; background: var(--surface-2); }
.social svg { width: 17px; height: 17px; color: #6364ff; flex: none; }
:root[data-theme="dark"] .social { color: #a5a6ff; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .social { color: #a5a6ff; } }
.social + .tabs { margin-left: 0; }
.social + .social { margin-left: -8px; }
/* Two social buttons + tabs don't fit on one line below ~1400px: icons only (labels stay in the title) */
@media (max-width: 1400px) { .social span { display: none; } .social { padding: 7px 9px; } }
.social.fb { color: #1564d1; }
.social.fb svg { color: #1877f2; }
:root[data-theme="dark"] .social.fb { color: #6aa8ff; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .social.fb { color: #6aa8ff; } }
.tab .count { color: var(--text-3); font-weight: 500; margin-left: 4px; }
.theme-btn { border: 1px solid var(--border); background: var(--surface); border-radius: 8px; padding: 6px 10px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); }
.theme-btn svg { width: 16px; height: 16px; }

main { max-width: 1480px; margin: 0 auto; padding: 16px; }
.view[hidden] { display: none; }

/* Filter bar */
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; box-shadow: var(--shadow); }
.field { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.field > span { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); font-weight: 600; }
.field input, .field select {
  border: 1px solid var(--border); background: var(--bg); border-radius: 7px; padding: 6px 8px; min-height: 34px; max-width: 100%;
}
.field.grow { flex: 1 1 260px; }
.field.search input { padding-left: 30px; background: var(--bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%2395948b' stroke-width='2' viewBox='0 0 24 24'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E") no-repeat 8px center; }
.field select { max-width: 220px; }
.check { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); font-size: 13px; min-height: 34px; white-space: nowrap; cursor: pointer; }
.btn { border: 1px solid var(--border); background: var(--surface); border-radius: 7px; padding: 6px 12px; min-height: 34px; cursor: pointer; color: var(--text-2); white-space: nowrap; }
.btn:hover { color: var(--text); border-color: var(--text-3); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 2px 4px 2px 10px; font-size: 12.5px; color: var(--text-2); }
.chip button { border: 0; background: transparent; cursor: pointer; color: var(--text-3); font-size: 15px; line-height: 1; padding: 0 4px; }

/* KPI tiles */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin: 14px 0; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); }
.kpi .label { color: var(--text-3); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.kpi .value { font-size: 24px; font-weight: 700; margin-top: 2px; letter-spacing: -.01em; }
.kpi .note { color: var(--text-3); font-size: 12px; }

/* Cards */
.grid2 { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 14px; }
@media (max-width: 1000px) { .grid2 { grid-template-columns: minmax(0, 1fr); } }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 0; }
.card-h { display: flex; align-items: center; gap: 10px; padding: 12px 14px 0; flex-wrap: wrap; }
.card-h h2 { font-size: 15px; margin: 0; font-weight: 700; }
.card-h .hint { color: var(--text-3); font-size: 12.5px; }
.card-h .right { margin-left: auto; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.card-b { padding: 10px 14px 14px; }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 7px; padding: 2px; }
.seg button { border: 0; background: transparent; padding: 4px 10px; border-radius: 6px; cursor: pointer; color: var(--text-2); font-size: 12.5px; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); font-weight: 600; }
.chart-box { position: relative; height: 260px; }
.chart-box.small { height: 150px; }
.map { height: 434px; border-radius: 8px; overflow: hidden; background: var(--surface-2); }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12.5px; color: var(--text-2); margin-top: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.mt { margin-top: 14px; }

/* Latest spending feed */
.feed { margin-bottom: 14px; }
.feed-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 8px; }
.feed-item { display: flex; flex-direction: column; gap: 2px; min-width: 0; padding: 9px 11px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); }
.feed-item .top { display: flex; align-items: baseline; gap: 8px; }
.feed-item .amt { font-size: 17px; font-weight: 700; letter-spacing: -.01em; }
.feed-item .date { margin-left: auto; color: var(--text-3); font-size: 12px; white-space: nowrap; }
.feed-item .name { font-weight: 600; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed-item .s { color: var(--text-3); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed-item .ext { font-size: 12px; }

/* Tables */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; position: sticky; top: 0; background: var(--surface); user-select: none; }
table.data th.sortable { cursor: pointer; }
table.data th.sortable:hover { color: var(--text); }
table.data th .arrow { opacity: .35; margin-left: 3px; }
table.data th[aria-sort] { color: var(--text); }
table.data th[aria-sort] .arrow { opacity: 1; color: var(--brand); }
table.data td { padding: 8px 10px; border-bottom: 1px solid var(--grid); vertical-align: top; }
table.data tbody tr { cursor: pointer; }
table.data tbody tr:hover { background: var(--surface-2); }
table.data .num { text-align: right; white-space: nowrap; }
table.data .nowrap { white-space: nowrap; }
table.data .muted, .muted { color: var(--text-3); }
.neg { color: var(--neg); }
.title-cell { min-width: 260px; max-width: 520px; }
.title-cell .t { font-weight: 600; color: var(--text); }
.title-cell .s { color: var(--text-3); font-size: 12px; margin-top: 1px; }
.badge { display: inline-block; font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 999px; background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); white-space: nowrap; }
.badge.idv { border-color: color-mix(in srgb, var(--s7) 50%, var(--border)); color: var(--s7); }
.badge.off { color: var(--text-3); }
.badge.open { border-color: color-mix(in srgb, var(--pos) 50%, var(--border)); color: var(--pos); }
.pager { display: flex; align-items: center; gap: 8px; padding: 10px 14px; color: var(--text-2); font-size: 13px; flex-wrap: wrap; }
.pager .sp { margin-left: auto; }
.bar-cell { display: flex; align-items: center; gap: 8px; justify-content: flex-end; }
.bar-cell .b { height: 6px; border-radius: 3px; background: var(--s1); opacity: .75; }
.empty { padding: 40px; text-align: center; color: var(--text-3); }

/* Modal */
dialog.detail { width: min(1100px, calc(100vw - 24px)); max-height: calc(100vh - 32px); border: 1px solid var(--border); border-radius: 14px; padding: 0; background: var(--surface); color: var(--text); box-shadow: 0 20px 60px rgba(0,0,0,.35); }
dialog.detail::backdrop { background: rgba(0,0,0,.45); }
.d-head { display: flex; gap: 12px; align-items: start; padding: 16px 18px 10px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); z-index: 2; }
.d-head h3 { margin: 0; font-size: 18px; line-height: 1.3; }
.d-head .sub { color: var(--text-3); font-size: 12.5px; margin-top: 3px; }
.d-head .x { margin-left: auto; border: 0; background: var(--surface-2); border-radius: 8px; width: 34px; height: 34px; cursor: pointer; font-size: 18px; flex: none; }
.d-body { padding: 14px 18px 18px; }
.meta { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px 18px; margin-bottom: 14px; }
.meta .k { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); font-weight: 600; }
.meta .v { font-size: 13.5px; overflow-wrap: anywhere; }
.desc { white-space: pre-wrap; background: var(--surface-2); border-radius: 8px; padding: 12px; font-size: 13px; color: var(--text-2); max-height: 360px; overflow: auto; overflow-wrap: anywhere; }
.d-links { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }

/* Leaflet theming */
:root[data-theme="dark"] .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(.9) contrast(.85) saturate(.4); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(.9) contrast(.85) saturate(.4); } }
.leaflet-container { font: inherit; background: var(--surface-2); }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.leaflet-popup-content { margin: 10px 12px; font-size: 13px; line-height: 1.4; }
.leaflet-popup-content ul { margin: 6px 0 0; padding-left: 16px; max-height: 180px; overflow: auto; }
.leaflet-bar a, .leaflet-bar a:hover { background: var(--surface); color: var(--text); border-color: var(--border); }
.leaflet-control-attribution { background: color-mix(in srgb, var(--surface) 80%, transparent) !important; color: var(--text-3); }
.leaflet-control-attribution a { color: var(--text-2); }
.pop-title { font-weight: 700; }
.pop-btn { margin-top: 8px; }

.loading { opacity: .55; transition: opacity .15s; }
.footer { color: var(--text-3); font-size: 12px; padding: 22px 16px 30px; text-align: center; max-width: 1480px; margin: 0 auto; }

@media (max-width: 720px) {
  .logo { height: 34px; }
  .brandline .sub { display: none; }
  .tabs { margin-left: 0; width: 100%; overflow-x: auto; }
  .social span { display: none; }
  .tab { padding: 6px 10px; }
  .field select { max-width: 100%; }
  .field { flex: 1 1 140px; }
  .map { height: 320px; }
  .kpi .value { font-size: 20px; }
}

/* ---------- Hover explanations (glossary.js) ---------- */
[data-tip] { cursor: help; text-decoration: underline dotted; text-decoration-color: var(--text-3); text-decoration-thickness: 1px; text-underline-offset: 3px; }
.tab[data-tip], .badge[data-tip], th[data-tip] { text-decoration: none; }
.tab[data-tip], table.data th.sortable[data-tip] { cursor: pointer; }
th[data-tip] .lbl { text-decoration: underline dotted; text-decoration-color: var(--text-3); text-decoration-thickness: 1px; text-underline-offset: 3px; }
[data-tip]:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 3px; }
.tipbox { position: fixed; z-index: 10000; left: 0; top: 0; max-width: min(320px, calc(100vw - 16px)); padding: 8px 11px;
  background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 6px 24px rgba(0,0,0,.18);
  font-size: 12.5px; font-weight: 400; line-height: 1.45; letter-spacing: normal; text-transform: none; text-align: left; white-space: normal;
  pointer-events: none; opacity: 0; visibility: hidden; transition: opacity .12s; }
.tipbox.on { opacity: 1; visibility: visible; }
