/* Insights section (reports, statements, analytics, document history, audit
   trail, cost centres). Module scoped: every rule starts with .ins- and uses
   the --gig-* tokens declared in index.html. Nothing here touches existing
   selectors. */

.ins-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.ins-head h1 { font-size: 20px; font-weight: 700; color: var(--gig-teal); margin: 0; letter-spacing: -.2px; }
.ins-head .ins-sub { font-size: 13px; color: var(--gig-ink-3); margin-top: 4px; }
.ins-nav { display: flex; gap: 6px; flex-wrap: wrap; }
.ins-nav a {
  display: inline-block; padding: 6px 12px; border-radius: var(--gig-radius-button, 8px);
  font-size: 13px; color: var(--gig-ink-2); text-decoration: none; border: 1px solid transparent;
  transition: background var(--gig-motion-hover, 120ms) var(--ease-standard, ease), color var(--gig-motion-hover, 120ms) var(--ease-standard, ease);
}
.ins-nav a:hover { background: var(--gig-surface-alt); color: var(--gig-teal); }
.ins-nav a.active { background: var(--gig-teal); color: #fff; }
.ins-nav a:focus-visible { outline: 4px solid var(--gig-lime); outline-offset: 2px; }

.ins-toolbar { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 12px; }
.ins-toolbar > div { display: flex; flex-direction: column; gap: 4px; }
.ins-toolbar label { font-size: 11px; font-weight: 600; color: var(--gig-ink-3); text-transform: uppercase; letter-spacing: .04em; }
.ins-toolbar input, .ins-toolbar select {
  height: 34px; padding: 0 10px; border: 1px solid var(--gig-line); border-radius: var(--gig-radius-input, 4px);
  font: inherit; font-size: 13.5px; color: var(--gig-ink); background: #fff; min-width: 140px;
}
.ins-toolbar input:focus, .ins-toolbar select:focus { outline: 4px solid var(--gig-lime); outline-offset: 0; border-color: var(--gig-teal); }
.ins-toolbar .ins-spacer { flex: 1; }
.ins-toolbar .ins-actions { flex-direction: row; gap: 8px; align-items: center; }

.ins-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 16px; }
.ins-kpi { background: #fff; border: 1px solid var(--gig-line); border-radius: var(--gig-radius-card, 12px); padding: 14px 16px; }
.ins-kpi .k { font-size: 11px; font-weight: 600; color: var(--gig-ink-3); text-transform: uppercase; letter-spacing: .04em; }
.ins-kpi .v { font-size: 24px; font-weight: 700; color: var(--gig-teal); margin-top: 4px; letter-spacing: -.3px; font-variant-numeric: tabular-nums; }
.ins-kpi .s { font-size: 12px; color: var(--gig-ink-3); margin-top: 2px; }
.ins-kpi.accent .v { color: var(--gig-green); }
.ins-kpi.dark { background: var(--gig-teal); border-color: var(--gig-teal); }
.ins-kpi.dark .k { color: rgba(255,255,255,.72); }
.ins-kpi.dark .v { color: var(--gig-lime); }
.ins-kpi.dark .s { color: rgba(255,255,255,.7); }

.ins-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 16px; }
.ins-grid .card { margin: 0; }
.ins-card-title { font-size: 13px; font-weight: 700; color: var(--gig-teal); margin: 0 0 10px; }
.ins-empty { padding: 28px 12px; text-align: center; color: var(--gig-ink-3); font-size: 13.5px; }

.ins-table-wrap { overflow-x: auto; }
table.ins-table { width: 100%; border-collapse: collapse; font-size: 13px; }
table.ins-table th {
  text-align: left; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
  color: var(--gig-ink-3); padding: 8px 10px; border-bottom: 1px solid var(--gig-line); white-space: nowrap; background: #fff;
  position: sticky; top: 0;
}
table.ins-table td { padding: 9px 10px; border-bottom: 1px solid var(--gig-line); vertical-align: top; color: var(--gig-ink); }
table.ins-table tr:last-child td { border-bottom: 0; }
table.ins-table tbody tr:hover td { background: var(--gig-surface-alt); }
table.ins-table td.num, table.ins-table th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.ins-table tr.ins-total td { font-weight: 700; color: var(--gig-teal); border-top: 2px solid var(--gig-line); background: var(--gig-surface-alt); }
table.ins-table a.ins-ref { color: var(--gig-teal); font-weight: 600; text-decoration: none; }
table.ins-table a.ins-ref:hover { text-decoration: underline; }
table.ins-table select.ins-inline { height: 30px; font: inherit; font-size: 12.5px; border: 1px solid var(--gig-line); border-radius: 4px; padding: 0 6px; background: #fff; max-width: 220px; }
table.ins-table tr.clickable { cursor: pointer; }
/* On a phone the tables were squeezed into the screen width: references broke
   mid-code, dates took three lines and long supplier names stretched rows to
   several times their height. The wrap already scrolls sideways, so the text
   columns keep a readable width and references and dates stay on one line. */
@media (max-width: 720px) {
  table.ins-table td:not(.num) { min-width: 160px; }
  table.ins-table a.ins-ref, table.ins-table td:nth-child(2) { white-space: nowrap; }
}

.ins-muted { color: var(--gig-ink-3); }
.ins-small { font-size: 12px; }

/* Timeline (document history) */
.ins-doc-head { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; align-items: flex-start; margin-bottom: 14px; }
.ins-doc-head .ref { font-size: 18px; font-weight: 700; color: var(--gig-teal); }
.ins-doc-head .meta { font-size: 13px; color: var(--gig-ink-2); margin-top: 2px; }
.ins-timeline { list-style: none; margin: 0; padding: 0 0 0 18px; border-left: 2px solid var(--gig-line); }
.ins-timeline li { position: relative; padding: 0 0 18px 18px; }
.ins-timeline li::before {
  content: ""; position: absolute; left: -25px; top: 5px; width: 12px; height: 12px; border-radius: 50%;
  background: #fff; border: 2px solid var(--gig-teal);
}
.ins-timeline li.k-status::before { background: var(--gig-teal); }
.ins-timeline li.k-link-approve::before, .ins-timeline li.k-paid::before { background: var(--gig-green); border-color: var(--gig-green); }
.ins-timeline li.k-link-reject::before { background: var(--gig-danger); border-color: var(--gig-danger); }
.ins-timeline li.k-link-superseded::before { background: var(--gig-line); border-color: var(--gig-line); }
.ins-timeline li.k-attachment::before, .ins-timeline li.k-review::before, .ins-timeline li.k-packet::before { border-color: var(--gig-ink-3); }
.ins-timeline .t { font-size: 13.5px; font-weight: 600; color: var(--gig-ink); }
.ins-timeline .d { font-size: 12.5px; color: var(--gig-ink-2); margin-top: 2px; white-space: pre-wrap; }
.ins-timeline .w { font-size: 12px; color: var(--gig-ink-3); margin-top: 3px; }
.ins-timeline .w b { font-weight: 600; color: var(--gig-ink-2); }
.ins-via { display: inline-block; font-size: 10.5px; padding: 1px 6px; border-radius: 999px; background: var(--gig-surface-alt); color: var(--gig-ink-3); margin-left: 6px; vertical-align: middle; }

/* Audit changes */
.ins-diff { display: flex; flex-wrap: wrap; gap: 4px; }
.ins-diff span { font-size: 11.5px; background: var(--gig-surface-alt); border: 1px solid var(--gig-line); border-radius: 4px; padding: 1px 6px; font-variant-numeric: tabular-nums; max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ins-diff span b { color: var(--gig-teal); font-weight: 600; }
details.ins-json summary { cursor: pointer; font-size: 12px; color: var(--gig-teal); }
details.ins-json pre { font-size: 11px; max-height: 220px; overflow: auto; background: var(--gig-surface-alt); padding: 8px; border-radius: 4px; margin: 6px 0 0; }

/* Charts */
.ins-chart { width: 100%; height: auto; display: block; }
.ins-chart text { font-family: inherit; font-size: 11px; fill: var(--gig-ink-3); }
.ins-chart .grid line { stroke: var(--gig-line); stroke-width: 1; }
.ins-chart .bar-a { fill: var(--gig-teal); }
.ins-chart .bar-b { fill: var(--gig-green); }
.ins-chart .bar-c { fill: var(--gig-lime); }
.ins-chart .bar-h { fill: var(--gig-teal); }
.ins-chart .bar-h:hover, .ins-chart .bar-a:hover, .ins-chart .bar-b:hover { opacity: .85; }
.ins-chart .lbl { fill: var(--gig-ink-2); font-size: 11px; }
.ins-chart .val { fill: var(--gig-ink); font-size: 11px; font-weight: 600; }
.ins-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--gig-ink-2); margin-top: 6px; }
.ins-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: middle; }

/* Cost centre form */
.ins-form { display: grid; grid-template-columns: 120px 1fr 160px 110px auto; gap: 10px; align-items: end; }
.ins-form label { display: block; font-size: 11px; font-weight: 600; color: var(--gig-ink-3); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 4px; }
.ins-form input, .ins-form select { width: 100%; height: 34px; padding: 0 10px; border: 1px solid var(--gig-line); border-radius: var(--gig-radius-input, 4px); font: inherit; font-size: 13.5px; }
.ins-check { display: flex; align-items: center; gap: 8px; height: 34px; font-size: 13px; }

.ins-notice { font-size: 13px; color: var(--gig-ink-2); background: var(--gig-surface-alt); border: 1px solid var(--gig-line); border-radius: 8px; padding: 10px 12px; margin-bottom: 14px; }

@media (max-width: 720px) {
  .ins-form { grid-template-columns: 1fr 1fr; }
  .ins-toolbar input, .ins-toolbar select { min-width: 120px; }
}

/* ================= ERP redesign, stage E8: Insights ======================
   design_handoff_gig_erp_redesign/README.md section 8, restyle only and
   modern only (classic keeps the rules above). Page head with the 5.x
   eyebrow; KPI cards at the ERP metrics (12px sentence-case label, 28px
   value, 12px/500 sub-line); tables on the grid pattern (paper header band,
   12px sentence-case headers, 42px rows); card titles and field labels as
   on every other ERP screen. */
html:not(.theme-classic) .ins-head { margin: 4px 0 20px; }
html:not(.theme-classic) .ins-head h1 {
  font-family: var(--font-display); font-size: 26px; font-weight: 500; line-height: 1.2;
  letter-spacing: 0; margin: 4px 0 0;
}
html:not(.theme-classic) .ins-head .ins-sub { font-size: 13.5px; }
html:not(.theme-classic) .ins-nav { gap: 4px; }
html:not(.theme-classic) .ins-nav a { height: 30px; display: inline-flex; align-items: center; padding: 0 10px; color: var(--erp-ink-2); }
html:not(.theme-classic) .ins-nav a:hover { background: var(--erp-teal-08); }
html:not(.theme-classic) .ins-nav a.active { font-weight: 500; color: #fff; }
html:not(.theme-classic) .ins-nav a.active:hover { background: var(--gig-teal); }
html:not(.theme-classic) .ins-nav a:focus-visible { outline: 0; box-shadow: var(--erp-focus); }

html:not(.theme-classic) .ins-toolbar label,
html:not(.theme-classic) .ins-form label { font-size: 12px; font-weight: 500; text-transform: none; letter-spacing: 0; color: var(--gig-ink-3); }
html:not(.theme-classic) .ins-toolbar input, html:not(.theme-classic) .ins-toolbar select,
html:not(.theme-classic) .ins-form input, html:not(.theme-classic) .ins-form select { height: 36px; min-height: 0; font-size: 13px; }
html:not(.theme-classic) .ins-toolbar input:focus, html:not(.theme-classic) .ins-toolbar select:focus { outline: 0; box-shadow: var(--erp-focus); }

html:not(.theme-classic) .ins-kpis { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 20px; }
html:not(.theme-classic) .ins-kpi { padding: 16px 18px; border-radius: 12px; }
html:not(.theme-classic) .ins-kpi .k { font-size: 12px; font-weight: 400; text-transform: none; letter-spacing: 0; }
html:not(.theme-classic) .ins-kpi .v { font-size: 28px; letter-spacing: 0; line-height: 1.15; }
html:not(.theme-classic) .ins-kpi .s { font-size: 12px; font-weight: 500; }
html:not(.theme-classic) .ins-kpi.accent .s { color: var(--gig-green); }

html:not(.theme-classic) .ins-grid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: 20px; }
html:not(.theme-classic) #tab-insights .card { border-radius: 12px; }
html:not(.theme-classic) .ins-card-title { font-size: 15px; font-weight: 500; margin: 0 0 12px; }
html:not(.theme-classic) .ins-empty { padding: 40px 16px; }

html:not(.theme-classic) table.ins-table { font-size: 13.5px; }
html:not(.theme-classic) table.ins-table th {
  height: 36px; padding: 0 12px; font-size: 12px; font-weight: 400; text-transform: none; letter-spacing: 0;
  background: var(--gig-paper); border-bottom: 1px solid var(--gig-line);
}
html:not(.theme-classic) table.ins-table td { padding: 11px 12px; border-bottom: 1px solid var(--gig-row-line); vertical-align: middle; }
html:not(.theme-classic) table.ins-table td.num { font-weight: 500; }
html:not(.theme-classic) table.ins-table tr.ins-total td { border-top: 1px solid var(--gig-line); background: var(--gig-paper); }
html:not(.theme-classic) table.ins-table a.ins-ref { font-weight: 500; }

html:not(.theme-classic) .ins-chart .val { font-weight: 700; }
html:not(.theme-classic) .ins-notice { border-radius: 8px; background: var(--gig-paper); }
html:not(.theme-classic) .ins-doc-head .ref { font-size: 20px; font-weight: 500; }
