/* Business overview page. Chart colours are their own tokens: green bars, blue bars and an amber line, so no series relies on
   colour alone (bars versus a line, a legend, labelled tooltips and a table view all carry the same information). */
:root {
  --ov-inv: #0B7A55;
  --ov-rec: #3B5BDB;
  --ov-exp: #B7791F;
  --ov-grid: #E5E2D8;
  --ov-bar-bg: #F2F0E9;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --ov-inv: #34D399; --ov-rec: #7C9CFF; --ov-exp: #F5C25B; --ov-grid: #1F382E; --ov-bar-bg: #0F211B; }
}
:root[data-theme="dark"] { --ov-inv: #34D399; --ov-rec: #7C9CFF; --ov-exp: #F5C25B; --ov-grid: #1F382E; --ov-bar-bg: #0F211B; }

.ov-wrap { max-width: 1120px; margin: 0 auto; }
.ov-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.ov-head h1 { font-size: 24px; margin-bottom: 4px; }
.ov-head p { color: var(--text-muted); font-size: 14.5px; max-width: 60ch; }
.ov-periods { display: flex; gap: 4px; padding: 4px; border: 1px solid var(--border); border-radius: 12px; background: var(--bg-elevated); overflow-x: auto; scrollbar-width: none; max-width: 100%; }
.ov-periods::-webkit-scrollbar { display: none; }
.ov-period { flex: none; font: inherit; font-size: 13.5px; font-weight: 600; padding: 8px 12px; min-height: 38px; border: 0; border-radius: 9px; background: transparent; color: var(--text-muted); cursor: pointer; white-space: nowrap; }
.ov-period:hover { color: var(--text); }
.ov-period[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent-strong); }
.ov-period:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.ov-window { color: var(--text-muted); font-size: 12.5px; margin: -8px 0 16px; }
.ov-wrap.is-loading .ov-body { opacity: .55; transition: opacity .15s ease; }

/* KPI tiles */
.ov-kpis { padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; margin-bottom: 16px; }
.ov-kpi { display: flex; flex-direction: column; gap: 4px; padding: 14px 16px; border: 1px solid var(--border); border-radius: 14px; background: var(--bg-elevated); color: var(--text); text-decoration: none; min-width: 0; }
a.ov-kpi:hover { border-color: var(--accent-strong); }
a.ov-kpi:focus-visible { outline: 2px solid var(--accent-strong); outline-offset: 2px; }
.ov-kpi-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); display: flex; gap: 6px; align-items: baseline; flex-wrap: wrap; }
.ov-kpi-label small { font-size: 10.5px; font-weight: 600; text-transform: none; letter-spacing: 0; opacity: .85; }
.ov-kpi-value { font-size: 24px; font-weight: 800; letter-spacing: -.015em; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; line-height: 1.15; }
.ov-kpi.is-bad .ov-kpi-value { color: var(--red); }
.ov-kpi.is-good .ov-kpi-value { color: var(--green); }
.ov-kpi-sub { font-size: 12.5px; color: var(--text-muted); line-height: 1.4; }
.ov-delta { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 999px; width: fit-content; font-variant-numeric: tabular-nums; }
.ov-delta.up { background: var(--green-soft); color: var(--green); }
.ov-delta.down { background: var(--red-soft); color: var(--red); }
.ov-delta.flat, .ov-delta.watch { background: var(--bg-sunken); color: var(--text-muted); }
.ov-delta.watch.up { background: var(--gold-soft); color: var(--gold); }
.ov-delta-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.ov-delta-note { font-size: 11.5px; font-weight: 500; color: var(--text-muted); }

/* panels */
.ov-panel { border: 1px solid var(--border); border-radius: 16px; background: var(--bg-elevated); padding: 18px; margin-bottom: 16px; min-width: 0; }
.ov-panel h2 { font-size: 16px; margin: 0 0 2px; }
.ov-panel-sub { color: var(--text-muted); font-size: 13px; margin-bottom: 14px; }
.ov-row2 { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.ov-row-even { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.ov-row2 > .ov-panel, .ov-row-even > .ov-panel { margin-bottom: 0; }
.ov-row2, .ov-row-even { margin-bottom: 16px; }
.ov-link { font-size: 13px; font-weight: 600; color: var(--accent-strong); text-decoration: none; white-space: nowrap; }
.ov-link:hover { text-decoration: underline; }
.ov-panel-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }

/* what needs attention */
.ov-insights { display: flex; flex-direction: column; gap: 10px; }
.ov-insight { display: flex; gap: 14px; align-items: center; justify-content: space-between; flex-wrap: wrap; padding: 12px 14px; border: 1px solid var(--border); border-left: 4px solid var(--border-strong); border-radius: 12px; background: var(--bg); }
.ov-insight.bad { border-left-color: var(--red); }
.ov-insight.warn { border-left-color: var(--gold); }
.ov-insight.good { border-left-color: var(--green); }
.ov-insight.info { border-left-color: var(--accent); }
.ov-insight-text { min-width: 0; flex: 1 1 320px; }
.ov-insight-title { font-weight: 700; font-size: 14.5px; }
.ov-insight-detail { color: var(--text-muted); font-size: 13.5px; margin-top: 2px; }
.ov-insight .btn { flex: none; }

/* 12-month chart */
.ov-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12.5px; color: var(--text-muted); margin-bottom: 8px; }
.ov-legend span { display: inline-flex; align-items: center; gap: 6px; }
.ov-key { display: inline-block; width: 12px; height: 12px; border-radius: 3px; }
.ov-key.inv { background: var(--ov-inv); }
.ov-key.rec { background: var(--ov-rec); }
.ov-key.exp { width: 16px; height: 0; border-top: 3px solid var(--ov-exp); border-radius: 0; position: relative; }
.ov-key.exp::after { content: ""; position: absolute; left: 4px; top: -6px; width: 6px; height: 6px; border-radius: 50%; background: var(--ov-exp); }
.ov-chart-wrap { position: relative; overflow-x: auto; }
.ov-chart { display: block; width: 100%; min-width: 560px; height: auto; }
.ov-chart text { font-family: inherit; fill: var(--text-muted); font-size: 11px; }
.ov-chart .grid { stroke: var(--ov-grid); stroke-width: 1; }
.ov-chart .axis { stroke: var(--border-strong); stroke-width: 1; }
.ov-chart .b-inv { fill: var(--ov-inv); }
.ov-chart .b-rec { fill: var(--ov-rec); }
.ov-chart .l-exp { fill: none; stroke: var(--ov-exp); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.ov-chart .d-exp { fill: var(--ov-exp); stroke: var(--bg-elevated); stroke-width: 2; }
.ov-chart .hit { fill: transparent; cursor: default; outline: none; }
.ov-chart .hit:hover, .ov-chart .hit:focus-visible { fill: var(--ov-bar-bg); opacity: .6; }
.ov-chart .hit:focus-visible { stroke: var(--accent-strong); stroke-width: 2; }
.ov-chart .now { fill: var(--accent-soft); opacity: .55; }
.ov-tip { position: absolute; z-index: 3; pointer-events: none; min-width: 170px; padding: 10px 12px; border: 1px solid var(--border-strong); border-radius: 10px; background: var(--bg-elevated); color: var(--text); box-shadow: var(--shadow); font-size: 12.5px; line-height: 1.5; }
.ov-tip[hidden] { display: none; }
.ov-tip b { display: block; margin-bottom: 4px; font-size: 13px; }
.ov-tip div { display: flex; justify-content: space-between; gap: 14px; font-variant-numeric: tabular-nums; }
.ov-empty-chart { color: var(--text-muted); font-size: 13.5px; padding: 28px 0; text-align: center; }
.ov-table-view { margin-top: 10px; font-size: 13px; }
.ov-table-view summary { cursor: pointer; color: var(--accent-strong); font-weight: 600; }
.ov-table-view table { width: 100%; border-collapse: collapse; margin-top: 8px; min-width: 460px; }
.ov-table-view th, .ov-table-view td { padding: 6px 8px; border-bottom: 1px solid var(--border); text-align: right; font-variant-numeric: tabular-nums; }
.ov-table-view th:first-child, .ov-table-view td:first-child { text-align: left; }
.ov-table-scroll { overflow-x: auto; }

/* horizontal bars (age of unpaid invoices, share of income) */
.ov-bars { display: flex; flex-direction: column; gap: 10px; }
.ov-bar-row { display: grid; grid-template-columns: 92px minmax(0, 1fr) auto; gap: 10px; align-items: center; font-size: 13px; }
.ov-bar-label { color: var(--text-muted); }
.ov-bars.clients .ov-bar-row { grid-template-columns: 130px minmax(0, 1fr) auto; }
.ov-bar-track, .ov-bar-fill { display: block; }
.ov-bar-track { height: 10px; border-radius: 6px; background: var(--ov-bar-bg); overflow: hidden; }
.ov-bar-fill { height: 100%; border-radius: 6px; min-width: 2px; }
.ov-bar-fill.cur { background: var(--accent); }
.ov-bar-fill.warn { background: var(--gold); }
.ov-bar-fill.late { background: var(--red); }
.ov-bar-fill.client { background: var(--ov-rec); }
.ov-bar-val { font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.ov-bar-val small { display: block; font-weight: 500; color: var(--text-muted); font-size: 11.5px; }

/* simple lists */
.ov-list { display: flex; flex-direction: column; }
.ov-item { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--border); font-size: 13.5px; }
.ov-item:first-child { border-top: 0; }
.ov-item-main { min-width: 0; }
.ov-item-name { font-weight: 600; overflow-wrap: anywhere; }
.ov-item-meta { color: var(--text-muted); font-size: 12.5px; }
.ov-item-amt { font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.ov-item-amt small { display: block; font-weight: 500; color: var(--text-muted); font-size: 11.5px; }
.ov-sub-h { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); margin: 16px 0 4px; }
.ov-expect { display: grid; grid-template-columns: repeat(auto-fit, minmax(118px, 1fr)); gap: 10px; margin-bottom: 4px; }
.ov-expect div { padding: 10px 12px; border-radius: 12px; background: var(--bg-sunken); }
.ov-expect span { display: block; font-size: 11.5px; color: var(--text-muted); font-weight: 600; }
.ov-expect strong { font-size: 15px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ov-expect .late strong { color: var(--red); }
.ov-note { color: var(--text-muted); font-size: 12.5px; margin-top: 10px; }
.ov-big { font-size: 34px; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.ov-big small { font-size: 14px; font-weight: 600; color: var(--text-muted); letter-spacing: 0; margin-left: 4px; }
.ov-kind { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-strong); margin-right: 6px; white-space: nowrap; }
.ov-empty { padding: 36px 20px; text-align: center; }
.ov-empty h2 { font-size: 20px; margin-bottom: 6px; }
.ov-empty p { color: var(--text-muted); max-width: 52ch; margin: 0 auto 16px; }
.ov-empty ol { text-align: left; max-width: 44ch; margin: 0 auto 18px; color: var(--text-muted); padding-left: 20px; }

@media (max-width: 1100px) {
  .ov-row2 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 900px) {
  .ov-row-even { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 560px) {
  .ov-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .ov-kpi { padding: 12px; }
  .ov-kpi-value { font-size: 19px; }
  .ov-panel { padding: 14px; border-radius: 14px; }
  .ov-bar-row { grid-template-columns: 70px minmax(0, 1fr) auto; gap: 8px; }
  .ov-big { font-size: 28px; }
}
