/* FolioAtlas application styling.

   The CompAtlas look, carried over: same palette, same type, same components
   under the same class names, so a screen built for one reads as the other.
   Kit values live in /brand/folioatlas-brand.css -- change them there first. */
@import url("/brand/folioatlas-fonts.css");
@import url("/brand/folioatlas-brand.css");

:root {
  --ink: #16202e;
  --muted: #5a6472;
  --line: #dde3ea;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --navy: #1f3a6e;
  --navy-deep: #152a52;
  --navy-soft: #e8edf5;
  --olive: #9a9500;            /* the mark. never body text */
  --olive-deep: #7a7600;       /* olive that carries text on white */
  --olive-light: #bfba3c;      /* olive that carries text on navy */
  --olive-wash: #f2f1dc;
  --green: #157347;
  --green-bg: #d6f0e0;
  --amber: #8a6100;
  --amber-bg: #fdf0c8;
  --red: #b02a37;
  --red-bg: #fadbdd;
  --grey-bg: #eceef2;

  --font-display: Archivo, "Segoe UI", system-ui, sans-serif;
  --font-body: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, Consolas, monospace;
  --radius-sm: 4px;
  --radius: 6px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 14px/1.45 var(--font-body);
  color: var(--ink);
  background: var(--bg);
}

a { color: var(--navy); }

/* A data product lines its digits up. */
td, th, .num, .kpi-figure, input[type="number"] { font-variant-numeric: tabular-nums; }

/* Visible on navy and on white alike, which a navy focus ring is not. */
a:focus-visible, button:focus-visible, .btn:focus-visible,
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--olive-light);
  outline-offset: 2px;
}

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; gap: 20px; flex-wrap: wrap;
  padding: 6px 20px; min-height: 54px;
  background: var(--navy); color: #fff;
  border-bottom: 2px solid var(--olive);
}
.topbar .brand { display: flex; align-items: center; text-decoration: none; }
.topbar .brand img { height: 26px; width: auto; display: block; }
.topbar nav { display: flex; flex-wrap: wrap; gap: 4px 2px; margin-right: auto; }
.topbar nav a {
  color: #c9d5ee; text-decoration: none; padding: 6px 10px;
  border-radius: var(--radius-sm); font-weight: 500;
}
.topbar nav a:hover { background: rgba(255,255,255,.12); color: #fff; }
.topbar nav a.on { background: rgba(255,255,255,.2); color: #fff; }

.topbar-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-left: auto; align-items: center; }
.topbar .btn-onnavy {
  background: #fff; border-color: #fff; color: var(--navy); font-weight: 600;
}
.topbar .btn-onnavy:hover {
  background: var(--navy-soft); border-color: var(--navy-soft); color: var(--navy-deep);
}
.whoami { display: flex; align-items: center; gap: 10px; }
.whoami a { color: #fff; text-decoration: none; font-weight: 500; }
.whoami a:hover { text-decoration: underline; }
.inline-form { display: inline; margin: 0; }

main { padding: 20px; max-width: 1500px; margin: 0 auto; }

/* ---------- generic ---------- */
h1 { font-family: var(--font-display); font-weight: 500; font-size: 22px; margin: 0 0 4px; }
h2, h3 { font-family: var(--font-display); }
h2 { font-size: 16px; margin: 0 0 10px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); }
h3 { font-size: 15px; margin: 0 0 8px; }
.sub { color: var(--muted); margin: 0 0 16px; }

.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; margin-bottom: 18px;
}
.panel-note { font-size: 13px; margin: 0 0 12px; }
.row { display: flex; gap: 16px; flex-wrap: wrap; align-items: flex-start; }
.row > .panel { flex: 1 1 340px; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }

.btn {
  display: inline-block; padding: 7px 14px; border-radius: 5px; border: 1px solid var(--line);
  background: #fff; color: var(--ink); text-decoration: none; font-size: 13px; cursor: pointer;
  font-family: inherit;
}
.btn:hover { background: #f0f3f8; }
.btn-primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn-primary:hover { background: var(--navy-deep); border-color: var(--navy-deep); color: #fff; }
.btn-excel { background: var(--green); border-color: var(--green); color: #fff; }
.btn-excel:hover { background: #10603a; color: #fff; }
.btn-danger { color: var(--red); border-color: #e6b8bd; }
.btn-sm { padding: 3px 8px; font-size: 12px; }

/* ---------- badges ---------- */
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 10px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
}
.badge-fresh { background: var(--green-bg); color: var(--green); }
.badge-aging { background: var(--amber-bg); color: var(--amber); }
.badge-stale { background: var(--red-bg); color: var(--red); }
.badge-none  { background: var(--grey-bg); color: var(--muted); }
.badge-gap   { background: #ffe8cc; color: #9a4a00; text-decoration: none; }
a.badge-gap:hover { background: #ffd9a8; }

.pill {
  display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 12px;
  background: var(--navy-soft); color: var(--navy); font-weight: 600; white-space: nowrap;
}

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--line); margin-bottom: 14px; flex-wrap: wrap; }
.tabs a {
  padding: 8px 16px; text-decoration: none; color: var(--muted); font-weight: 600;
  border-bottom: 2px solid transparent; margin-bottom: -2px;
}
.tabs a.on { color: var(--navy); border-bottom-color: var(--navy); }
.tabs a .n { color: var(--muted); font-weight: 500; }

/* ---------- fields ---------- */
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.field { display: flex; flex-direction: column; gap: 3px; }
.field label { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); font-weight: 600; }
.field input, .field select, .field textarea {
  padding: 6px 8px; border: 1px solid var(--line); border-radius: 5px;
  font: inherit; font-size: 13px; background: #fff; min-width: 140px;
}
.field textarea { min-height: 60px; resize: vertical; }
.field.wide input, .field.wide textarea, .field.wide select { min-width: 320px; }
.field .hint { font-size: 11px; color: var(--muted); }

/* ---------- tables ---------- */
table { border-collapse: collapse; width: 100%; font-size: 13px; background: #fff; }
th, td { padding: 6px 9px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th {
  background: #eef1f6; font-size: 11px; text-transform: uppercase; letter-spacing: .5px;
  color: #46536b; font-weight: 700; white-space: nowrap;
}
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr:hover { background: #f7f9fc; }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.table-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.table-scroll table tr:last-child td { border-bottom: 0; }

tr.group-head td {
  background: #e7ecf5; font-weight: 700; border-top: 2px solid #c8d3e6;
}
tr.row-off td { color: #8a93a1; }
td a.name { font-weight: 600; text-decoration: none; }
td a.name:hover { text-decoration: underline; }

.empty { padding: 40px; text-align: center; color: var(--muted); }

/* ---------- detail ---------- */
.kv { display: grid; grid-template-columns: minmax(150px, auto) 1fr; gap: 6px 14px; font-size: 13px; margin: 0; }
.kv dt { color: var(--muted); font-weight: 600; }
.kv dd { margin: 0; }

.flash { padding: 10px 14px; border-radius: 6px; background: var(--green-bg); color: var(--green);
  margin-bottom: 14px; font-weight: 600; }
.warn-note { background: #fff4e5; color: #9a4a00; border-radius: 6px; padding: 8px 12px;
  font-size: 13px; margin: 0 0 10px; }
.auth-error { background: #fdeaec; border: 1px solid #e6b8bd; color: #8a1122;
  border-radius: 6px; padding: 9px 11px; font-size: 13px; margin: 0 0 16px; }

.form-grid { display: flex; flex-wrap: wrap; gap: 12px; }
.actions { display: flex; gap: 8px; margin-top: 14px; align-items: center; flex-wrap: wrap; }
fieldset { border: 1px solid var(--line); border-radius: 8px; padding: 14px; margin: 0 0 16px; }
legend { font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); font-weight: 700; padding: 0 6px; }

/* ---------- FolioAtlas additions ---------- */
/* A blank is a fact, and it should look like one: quiet, italic, never a 0. */
.ns { color: #98a1ae; font-style: italic; }

/* The headline figures across the top of a screen. */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  border-top: 3px solid var(--navy); padding: 12px 14px; }
.kpi-label { font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); font-weight: 700; }
.kpi-figure { font-family: var(--font-display); font-size: 26px; font-weight: 500; color: var(--navy); line-height: 1.2; margin: 2px 0; }
.kpi-note { font-size: 12px; color: var(--muted); }

.setup-link { flex: 1 1 420px; padding: 7px 9px; border: 1px solid var(--line); border-radius: 5px;
  font: 12px var(--font-mono); background: #fbfcfe; }

.ticks { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 4px 18px; margin: 0 0 14px; }
.ticks label { display: flex; align-items: center; gap: 8px; padding: 4px 6px; border-radius: 4px; cursor: pointer; }
.ticks label:hover { background: #f2f5fa; }

details.editor { border-top: 1px solid var(--line); padding: 10px 0; }
details.editor > summary { cursor: pointer; font-weight: 600; }
details.editor[open] > summary { margin-bottom: 12px; }

.phase-card { max-width: 640px; }
.phase-card .phase { font-family: var(--font-display); font-size: 13px; text-transform: uppercase;
  letter-spacing: .6px; color: var(--olive-deep); font-weight: 700; }

/* ---------- imports ---------- */
.tabs-sub { border-bottom-width: 1px; margin-top: -6px; }
.tabs-sub a { padding: 5px 12px; font-size: 13px; font-weight: 500; }

.bar { height: 6px; background: var(--grey-bg); border-radius: 3px; margin-top: 8px; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--navy); transition: width .4s; }

/* The coverage grid: a month is a square, and its colour is its state. */
table.coverage { width: auto; margin: 0 0 14px; table-layout: fixed; }
table.coverage th, table.coverage td { padding: 3px 4px; border-bottom: 0; background: none; vertical-align: middle; }
table.coverage th { font-size: 10px; text-align: center; color: var(--muted); width: 30px; }
table.coverage th:first-child { text-align: left; font-family: var(--font-display); font-size: 15px;
  color: var(--navy); text-transform: none; letter-spacing: 0; }
table.coverage tbody tr:hover { background: none; }
.cell { display: block; width: 22px; height: 22px; border-radius: 4px; margin: 0 auto; position: relative;
  border: 1px solid transparent; }
i.cell { display: inline-block; width: 13px; height: 13px; border-radius: 3px; vertical-align: -2px; margin: 0; }
.cell.committed { background: var(--green); }
.cell.ready { background: #9db7e4; }
.cell.flagged { background: #e8a33d; }
.cell.covered { background: #cfdcf3; }
.cell.unreadable { background: var(--red); }
.cell.missing { background: #fff; border: 1px dashed #c3ccd8; }
/* A dot: the Word report for the month is on file. */
.cell b { position: absolute; right: 2px; bottom: 2px; width: 5px; height: 5px; border-radius: 50%;
  background: rgba(255,255,255,.9); box-shadow: 0 0 0 1px rgba(0,0,0,.25); }
.cell.missing b, .cell.covered b { background: var(--muted); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }

.flag { border-left: 3px solid var(--line); padding: 1px 0 1px 7px; margin-bottom: 4px; color: var(--muted); }
.flag strong { color: var(--ink); }
.flag-foot, .flag-leftout, .flag-missing { border-left-color: var(--red); }
.flag-restated, .flag-duplicate, .flag-source { border-left-color: #e8a33d; }
.flag-unmapped { border-left-color: #9a4a00; background: #fff4e5; }
select.flag-unmapped { border: 1px solid #e8a33d; }
.restated { color: #9a4a00; font-weight: 600; }

/* ---------- charts ---------- */
.chart-box { min-height: 300px; }
.kv dd.num { text-align: right; }
.kv small { font-size: 11px; }

/* ---------- grades ---------- */
.grade { display: inline-block; min-width: 28px; text-align: center; padding: 1px 6px; border-radius: 4px;
  font-family: var(--font-display); font-weight: 700; font-size: 12px; }
.grade-A, .grade-B { background: var(--green-bg); color: var(--green); }
.grade-C { background: var(--amber-bg); color: var(--amber); }
.grade-D { background: var(--red-bg); color: var(--red); }
.grade-big { font-family: var(--font-display); font-size: 54px; font-weight: 700; text-align: center;
  border-radius: 10px; padding: 12px 0; line-height: 1; }
.grade-big.grade-none { background: var(--grey-bg); color: var(--muted); }

/* Report commentary (Phase 6) */
.comment { border-left: 3px solid #c7d1b0; padding: 6px 0 6px 12px; margin: 6px 0 10px; }
.comment.struck .comment-text { text-decoration: line-through; color: #8a929b; }
.comment-text { font-size: 14px; line-height: 1.5; }
.comment-meta { font-size: 12px; margin-top: 3px; }
.comment-meta details { display: inline; margin-left: 6px; }
.comment-meta summary, .comment-edit summary { cursor: pointer; color: #1f7a80; display: inline; }
.comment-edit { margin-top: 4px; font-size: 12px; }
.comment-edit textarea { font: inherit; font-size: 13px; margin-top: 4px; }
.sources { margin: 6px 0 4px 18px; padding: 0; }
.sources li { margin: 2px 0; }

/* Report builder (Phase 6B) */
.ticks { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 13px; }
.ticks label { white-space: nowrap; cursor: pointer; }
.kinds { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 8px; }
.kind { display: block; border: 1px solid #dde3ea; border-radius: 6px; padding: 8px 10px; cursor: pointer; font-size: 13px; }
.kind span { display: block; font-size: 12px; margin: 2px 0 0 20px; }
.kind:has(input:checked) { border-color: #1f7a80; background: #f2f8f8; }
table.sortable th.sorted-down::after { content: " \25BE"; }
table.sortable th.sorted-up::after { content: " \25B4"; }
.watch { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 6px 18px; font-size: 13px; }
.watch .w-kind { display: inline-block; min-width: 68px; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: #a33a5f; }

/* A chart opened large, over the page */
.chart-expand { position: absolute; top: 2px; right: 2px; z-index: 5; width: 26px; height: 26px; border: 1px solid #dde3ea;
  border-radius: 5px; background: #fff; color: #5a6472; font-size: 15px; line-height: 1; cursor: pointer; opacity: .75; }
.chart-expand:hover { opacity: 1; border-color: #1f7a80; color: #1f7a80; }
.chart-overlay { position: fixed; inset: 0; z-index: 1000; background: rgba(22, 32, 46, .55); display: flex;
  align-items: center; justify-content: center; }
.chart-window { background: #fff; border-radius: 8px; width: 94vw; height: 90vh; display: flex; flex-direction: column;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .3); }
.chart-window-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 16px;
  border-bottom: 1px solid #e5e9ee; font-size: 15px; }
.chart-close { border: 0; background: none; font-size: 28px; line-height: 1; cursor: pointer; color: #5a6472; padding: 0 6px; }
.chart-close:hover { color: #16202e; }
.chart-big { flex: 1 1 auto; min-height: 0; margin: 8px 12px 12px; }

/* Phase 7: investors */
.view-as { background: #fbeaf0; border-bottom: 2px solid #c9718f; padding: 8px 24px; font-size: 13px; }
.view-as a { margin: 0 4px; }
details.terms { border-top: 1px solid #e5e9ee; padding: 8px 0; font-size: 13px; }
details.terms summary { cursor: pointer; }

/* Phase 7B: the map */
.map-panel { padding: 0; overflow: hidden; }
.map-bar { display: flex; flex-wrap: wrap; gap: 8px 18px; align-items: center; padding: 10px 16px; font-size: 13px; border-bottom: 1px solid #e5e9ee; }
.map-bar select { margin-left: 4px; }
.map-zoom { margin-left: auto; }
.map-box { height: 62vh; min-height: 420px; background: #eef1f6; }
.map-foot { display: flex; flex-wrap: wrap; gap: 6px 24px; align-items: center; padding: 10px 16px; border-top: 1px solid #e5e9ee; }
.map-legend { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 13px; }
.map-key { white-space: nowrap; }
.map-key i { display: inline-block; width: 12px; height: 12px; border-radius: 50%; margin-right: 6px; vertical-align: -1px; border: 1px solid #fff; box-shadow: 0 0 0 1px #c8d3e6; }
.map-name { background: rgba(255, 255, 255, .92); border: 0; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); font-size: 11px; font-weight: 600; padding: 1px 6px; color: #16202e; }
.map-name::before { display: none; }
.map-pop { font-size: 13px; min-width: 220px; }
.map-pop table { width: 100%; margin: 6px 0; font-size: 12px; }
.map-pop td { padding: 1px 0; border: 0; }
.map-pop td:last-child { text-align: right; font-weight: 600; }
.map-reading { margin: 6px 0 2px; font-weight: 600; }
.map-reading span { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; }

/* The small map on an investor's page */
.mini-map { height: 300px; border-radius: 6px; overflow: hidden; background: #eef1f6; }
