/* BoardPack v4 — Management Reporting Interface */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  /* ================================================================
     CANONICAL DESIGN TOKENS — mirror bpack-v4.pen (get_variables) 1:1
     so the app and the Pencil design stay in lockstep. Colours/fonts
     are verbatim from the .pen. The .pen's numeric tokens are
     unit-less (e.g. 48); they're written here with `px` because CSS
     requires units — the values are identical to the design.
     "Graphite · Slate Teal" skin. Edit the .pen first, then mirror here.
     ================================================================ */

  /* Core surfaces & text */
  --primary: #3F6E72;
  --primary-hover: #345B5E;
  --primary-foreground: #FFFFFF;
  --accent: #3F6E72;
  --background: #F4F4F4;
  --surface: #FFFFFF;
  --surface-alt: #ECECEC;
  --foreground: #222222;
  --muted-foreground: #6B6F6F;
  --subtle-foreground: #9AA0A0;
  --border: #DCDCDC;
  --border-strong: #C8C8C8;
  --table-border: #E7E7E7;
  --text-heading: #222222;

  /* Typography */
  --font-primary: "Inter";
  --font-display: "Source Serif 4";
  --font-mono: "JetBrains Mono";

  /* Status */
  --positive: #3F7A4E;
  --negative: #B4453B;
  --warning: #9A6B2F;

  /* Top-nav / tab bar */
  --tab-bar-bg: #2E5256;
  --tab-bar-border: #244246;
  --tab-active-bg: #FFFFFF;
  --tab-active-fg: #2E5256;
  --tab-inactive-bg: #2E5256;
  --tab-inactive-fg: #BCC9C9;
  --top-nav-height: 48px;            /* .pen: 48 */
  --top-nav-active-bg: #FFFFFF1F;
  --top-nav-fg-dim: #FFFFFFA6;

  /* P&L row hierarchy */
  --row-section: #2E5256;
  --row-section-fg: #FFFFFF;
  --row-category: #ECECEC;
  --row-subtotal: #E3EBE4;
  --row-summary: #F2F2F0;
  --row-summary-highlight: #E3EBE4;
  --row-zebra: #FAFAF9;
  --row-height: 32px;                /* .pen: 32 */
  --row-height-section: 36px;        /* .pen: 36 */
  --row-height-summary: 40px;        /* .pen: 40 */

  /* Grid cells */
  --cell-editable: #FFFFFF;
  --cell-editable-hover: #EFF4F3;
  --cell-editable-tint: #FFFFFF;
  --cell-focus-bg: #EAF1F0;
  --cell-focus-ring: #3F6E72;
  --error-bg: #F1E4E1;
  --error-border: #B4453B;
  --error-text: #B4453B;

  /* Column widths */
  --col-label-width: 240px;          /* .pen: 240 */
  --col-month-width: 92px;           /* .pen: 92 */
  --col-total-width: 112px;          /* .pen: 112 */

  /* Capacity heatmap — teal ramp / neutral gaps / brand red */
  --heat-alloc-1: #3F6E7226;
  --heat-alloc-2: #3F6E7266;
  --heat-alloc-3: #3F6E72BF;
  --heat-alloc-4: #3F6E72;
  --heat-alloc-text: #3F6E72;
  --heat-gap-1: #F2F2F2;
  --heat-gap-2: #E7E7E7;
  --heat-gap-3: #DCDCDC;
  --heat-gap-text: #6B6F6F;
  --heat-over-1: #F1E4E1;
  --heat-over-2: #B4453B;
  --heat-over-text: #B4453B;

  /* Badges / status pills */
  --badge-active-bg: #E0EAEA;
  --badge-active-fg: #2E5256;
  --badge-inactive-bg: #E7E7E7;
  --badge-inactive-fg: #6B6F6F;
  --pill-active-bg: #E0EAEA;
  --pill-proposal-bg: #EDE8D8;
  --pill-closed-bg: #E7E7E7;

  /* Avatar palette — 8 stable hues for the coloured initials circles. */
  --avatar-1: #2E5256;
  --avatar-2: #3F6E72;
  --avatar-3: #6F8F77;
  --avatar-4: #B4453B;
  --avatar-5: #5E6B8C;
  --avatar-6: #8C7A3E;
  --avatar-7: #2F6B7A;
  --avatar-8: #6E3D5C;

  /* Work-type palette (bg / fg / bd per variant) */
  --wt-design-bg: #F9E0E9;       --wt-design-fg: #80284F;       --wt-design-bd: #ECC2D2;
  --wt-dev-bg: #D9DBEE;          --wt-dev-fg: #2E2C75;          --wt-dev-bd: #B9BCDB;
  --wt-strategy-bg: #E9DDD0;     --wt-strategy-fg: #5A4416;     --wt-strategy-bd: #D8C5A8;
  --wt-account-bg: #DCE8EA;      --wt-account-fg: #195159;      --wt-account-bd: #B7CDD2;
  --wt-workshops-bg: #E7DEF1;    --wt-workshops-fg: #4D3479;    --wt-workshops-bd: #CDC2DD;
  --wt-production-bg: #DEE8DC;   --wt-production-fg: #2E5230;   --wt-production-bd: #BFD2BC;
  --wt-marketing-bg: #F3E3CB;    --wt-marketing-fg: #6E4A0E;    --wt-marketing-bd: #DFC8A6;
  --wt-copywriting-bg: #E6E3F1;  --wt-copywriting-fg: #3C3279;  --wt-copywriting-bd: #C8C4DD;
  --wt-unspecified-bg: #EEF0F5;  --wt-unspecified-fg: #2A2A4A;
  --wt-primary-bg: #D8DDEE;      --wt-primary-fg: #16213E;

  /* Spacing scale (.pen: 4/8/12/16/20/24/32) */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;

  /* Radii (.pen graphite: soft rounded corners) */
  --radius-s: 6px;
  --radius-m: 8px;
  --radius-l: 10px;
  --radius-pill: 999px;

  /* Shape radii for round identity elements — graphite makes pills, tags and
     avatars fully rounded (the XP skin squared them off at 2px). */
  --avatar-radius: 999px;
  --pill-radius: 999px;
  --tag-radius: 999px;

  /* Surface chrome — graphite is flat: control/panel faces are plain white,
     bevels collapse to a single hairline grey, header/top-nav gradients are
     flat. (The XP skin used two-stop gradients + light/dark bevels here.) */
  --control-face-1: #FFFFFF;
  --control-face-2: #FFFFFF;
  --panel-face-1: #FFFFFF;
  --panel-face-2: #FFFFFF;
  --panel-border: #DCDCDC;
  --bevel-light: #DCDCDC;
  --bevel-dark: #DCDCDC;
  --bevel-inset-light: #DCDCDC;
  --bevel-inset-dark: #DCDCDC;
  --header-grad-1: #FFFFFF;
  --header-grad-2: #FFFFFF;
  --header-border: #DCDCDC;
  --topnav-grad-1: #F4F4F4;
  --topnav-grad-2: #F4F4F4;
  --topnav-tab-grad-1: #F4F4F4;
  --topnav-tab-grad-2: #F4F4F4;
  --modal-titlebar-1: #4A7E82;
  --modal-titlebar-2: #2E5256;
  --card-footer-bg: #ECECEC;
  --card-shadow: #00000014;
  --bar-fill-1: #5A8E92;
  --bar-fill-2: #3F6E72;

  /* Cross-domain nav chrome (graphite: flat, teal underline, no bevel) */
  --nav-active-bottom: #3F6E72;
  --nav-active-fill: #F4F4F4;
  --nav-border: #DCDCDC;
  --nav-logo-dim: #6B6F6F;
  --nav-logo-fg: #222222;
  --nav-tab-bevel-dark: #00000000;
  --nav-tab-bevel-light: #00000000;
  --nav-underline-w: 2px;

  --brand-orange: #E0701B;

  /* Width of the kept legacy reports sidebar (not modelled in the .pen,
     which only has the top tab bar). The sidebar re-uses the tab-bar palette. */
  --sidebar-width: 220px;
}

/* ─── Top-level cross-domain nav (P&L | Team | Projects | Settings) ─── */

.top-nav {
  position: sticky;
  top: 0;
  z-index: 200;
  display: flex;
  align-items: stretch;
  height: var(--top-nav-height);
  background: var(--tab-bar-bg);
  color: var(--primary-foreground);
  border-bottom: 1px solid var(--tab-bar-border);
}

.top-nav-brand {
  display: flex;
  align-items: center;
  padding: 0 1rem;
  font-family: var(--font-display), Georgia, 'Times New Roman', serif;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.top-nav-brand-link {
  color: inherit;
  text-decoration: none;
}

.top-nav-brand-suffix {
  margin-left: 0.25rem;
  color: var(--top-nav-fg-dim);
  font-weight: 400;
}

.top-nav-tabs {
  list-style: none;
  display: flex;
  align-items: flex-end;
  gap: 2px;
  padding: 6px 0 0;
}

/* XP "Luna" tabs: inactive tabs read as a slightly lighter blue raised from
   the bar; the active tab lifts to a pale near-white panel with a navy label
   and a light top/left bevel — the "current document" tab. */
.top-nav-tab a {
  display: flex;
  align-items: center;
  padding: 0 1.1rem;
  height: calc(var(--top-nav-height) - 6px);
  color: var(--tab-inactive-fg);
  background: var(--tab-inactive-bg);
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 700;
  border: 1px solid var(--tab-bar-border);
  border-bottom: none;
  border-radius: var(--radius-m) var(--radius-m) 0 0;
}

.top-nav-tab a:hover {
  background: var(--primary-hover);
  color: var(--primary-foreground);
}

.top-nav-tab.active a {
  color: var(--tab-active-fg);
  background: var(--tab-active-bg);
  border-color: var(--border-strong);
  box-shadow: inset 1px 1px 0 #ffffff;
}

/* ─── Dropdown menu (e.g. the top-nav Reports dropdown) ─── */

/* XP-Luna menu panel. Position-agnostic: the trigger wraps it in a
   position:relative container and positions it (the top-nav anchors it to
   the bottom edge of the bar). */
.dropdown-menu {
  display: flex;
  flex-direction: column;
  gap: 1px;
  width: 236px;
  padding: var(--space-1);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-m);
  box-shadow: 1px 4px 8px rgba(0, 0, 0, 0.25);   /* .pen: (1,4) blur 8 #00000040 */
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 8px 10px;
  border-radius: var(--radius-s);
  text-decoration: none;
}

.dropdown-item .icon {
  width: 16px;
  flex-shrink: 0;
  text-align: center;
  font-size: 0.875rem;
  line-height: 1;
  color: var(--muted-foreground);
}

.dropdown-item .text {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.dropdown-item .label {
  font-size: 0.875rem;            /* .pen: 14 */
  font-weight: 600;
  color: var(--foreground);
}

.dropdown-item .sub {
  font-size: 0.72rem;             /* .pen: 11.5 */
  color: var(--muted-foreground);
}

.dropdown-item:hover { background: var(--surface-alt); }

.dropdown-item.active { background: var(--accent); }
.dropdown-item.active .icon,
.dropdown-item.active .label { color: var(--primary-foreground); }
.dropdown-item.active .sub   { color: var(--top-nav-fg-dim); }

.dropdown-separator {
  margin: 3px 6px;
  border-top: 1px solid var(--border);
}

/* The menu's natural anchor is its trigger tab (a position:relative
   .top-nav-tab) — shield the menu items from the tab's own link styling. */
.top-nav-tab .dropdown-item {
  height: auto;
  padding: 8px 10px;
  background: none;
  border: none;
  border-radius: var(--radius-s);
}

.top-nav-tab .dropdown-item:hover { background: var(--surface-alt); }

.top-nav-tab .dropdown-item.active,
.top-nav-tab .dropdown-item.active:hover { background: var(--accent); }

/* Existing sidebar sits below the top-nav. */
.layout {
  padding-top: 0;
}

.sidebar {
  top: var(--top-nav-height);
  height: calc(100vh - var(--top-nav-height));
}

/* Placeholder page styling for the team/projects/settings stubs that ship
   in Unit 7 ahead of their real implementations in later units. */
.page-stub {
  max-width: 720px;
  margin: 2.5rem auto;
  padding: 2rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-m);
}

.page-stub h1 {
  margin-bottom: 0.75rem;
  color: var(--text-heading);
}

.page-stub p {
  color: var(--muted-foreground);
}

html {
  font-size: 16px;
}

body {
  background: var(--background);
  color: var(--foreground);
  font-family: var(--font-primary), 'Segoe UI', system-ui, -apple-system, Helvetica, Arial, sans-serif;
  line-height: 1.5;
}

/* ─── Layout ─── */

.layout {
  display: flex;
  min-height: 100vh;
}

/* ─── Sidebar ─── */

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--primary);
  color: var(--tab-inactive-fg);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  z-index: 100;
}

.sidebar-logo {
  padding: 1.25rem 1rem 1rem;
  border-bottom: 1px solid var(--tab-bar-border);
}

.sidebar-logo a {
  text-decoration: none;
  color: #ffffff;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.sidebar-logo span {
  display: block;
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--top-nav-fg-dim);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-top: 0.15rem;
}

.sidebar nav {
  flex: 1;
  padding: 0.75rem 0;
}

.workbook-back-link {
  display: block;
  padding: 0.5rem 1rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid var(--tab-bar-border);
  margin-bottom: 0.25rem;
}

.workbook-back-link:hover {
  background: var(--primary-hover);
  color: #ffffff;
}

.nav-group {
  margin-bottom: 0.5rem;
}

.nav-group-label {
  padding: 0.5rem 1rem 0.25rem;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--top-nav-fg-dim);
}

.sidebar nav a {
  display: block;
  padding: 0.35rem 1rem 0.35rem 1.25rem;
  color: var(--tab-inactive-fg);
  text-decoration: none;
  font-size: 0.82rem;
  line-height: 1.4;
  transition: background 0.1s, color 0.1s;
}

.sidebar nav a:hover {
  background: var(--primary-hover);
  color: #ffffff;
}

.sidebar nav a.active {
  background: var(--tab-bar-border);
  color: var(--accent);
  border-left: 2px solid var(--accent);
  padding-left: calc(1.25rem - 2px);
}

/* ─── Main content ─── */

.main {
  margin-left: var(--sidebar-width);
  flex: 1;
  padding: 2rem 2.5rem;
  min-width: 0;
}

/* ─── Workbook view — sidebar hidden ─── */

.workbook-view aside.sidebar,
.team-view aside.sidebar,
.projects-view aside.sidebar,
.settings-view aside.sidebar {
  display: none;
}

.team-view .main,
.projects-view .main,
.settings-view .main {
  margin-left: 0;
}

/* ─── Buttons (canonical) — XP "Luna" raised bevel ───
   Recipe from bpack-v4.pen Atom/Button (FBplc): 3px radius, vertical
   white→beige gradient, per-side bevel border (light top/left, grey
   bottom/right). :active inverts the bevel for the pressed (sunken) look.
   One canonical set lives here (style.css is loaded on every page); the old
   .btn-primary/.btn-secondary/.btn-danger were consolidated to modifiers. */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 15px;
  border-radius: var(--radius-m);
  border: 1px solid var(--border-strong);
  background: var(--control-face-1);
  color: var(--foreground);
  font-family: var(--font-primary), system-ui, -apple-system, sans-serif;
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.2;
  cursor: pointer;
  text-decoration: none;
  transition: background-color 0.12s ease, border-color 0.12s ease;
}

.btn:hover {
  background: var(--surface-alt);
  border-color: var(--border-strong);
}

.btn:active {
  background: var(--surface-alt);
  border-color: var(--muted-foreground);
}

.btn:focus-visible {
  outline: 2px solid var(--cell-focus-ring);
  outline-offset: 1px;
}

.btn:disabled,
.btn[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
}

/* Primary — flat slate-teal button */
.btn.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--primary-foreground);
}
.btn.primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}
.btn.primary:active {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}

/* Danger — flat brick-red button */
.btn.danger {
  background: var(--negative);
  border-color: var(--negative);
  color: var(--primary-foreground);
}
.btn.danger:hover {
  background: #9C3A31;
  border-color: #9C3A31;
}
.btn.danger:active {
  background: #9C3A31;
  border-color: #9C3A31;
}

/* Secondary is the default chrome — no extra rules needed. */

.btn.small {
  font-size: 0.75rem;
  padding: 4px 10px;
}
.btn.small:active {
  padding: 5px 9px 3px 11px;
}

.workbook-view .main {
  margin-left: 0;
  padding: 0;
}

/* ─── Report header ─── */

.report-header {
  margin-bottom: 1.5rem;
}

.report-header h1 {
  font-family: var(--font-display), Georgia, 'Times New Roman', serif;
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-heading);
  line-height: 1.2;
}

.report-header .period-label {
  margin-top: 0.3rem;
  font-size: 0.85rem;
  color: var(--muted-foreground);
}

/* ─── Period picker ─── */

.period-picker {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1rem;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-s);
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.period-picker label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.82rem;
  color: var(--muted-foreground);
  white-space: nowrap;
}

.period-picker input[type="date"],
.period-picker select {
  padding: 0.3rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-s);
  background: #ffffff;
  font-size: 0.82rem;
  color: var(--foreground);
  font-family: inherit;
}

.period-picker button {
  padding: 0.3rem 0.9rem;
  background: var(--primary);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-s);
  font-size: 0.82rem;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.1s;
}

.period-picker button:hover {
  background: var(--primary-hover);
}

/* ─── Cards ─── */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-s);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
}

/* ─── Tables ─── */

.table-wrapper {
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-s);
  margin-bottom: 1.5rem;
}

.report-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.83rem;
}

.report-table thead th {
  position: sticky;
  top: 0;
  background: var(--surface-alt);
  border-bottom: 2px solid var(--table-border);
  padding: 0.55rem 0.75rem;
  text-align: right;
  font-weight: 600;
  color: var(--muted-foreground);
  font-size: 0.75rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  white-space: nowrap;
  z-index: 10;
}

.report-table thead th:first-child {
  text-align: left;
}

.report-table tbody tr:nth-child(even) {
  background: var(--row-zebra);
}

.report-table tbody td {
  padding: 0.45rem 0.75rem;
  border-bottom: 1px solid var(--table-border);
  text-align: right;
  vertical-align: middle;
}

.report-table tbody td:first-child {
  text-align: left;
}

.report-table tfoot td {
  padding: 0.55rem 0.75rem;
  text-align: right;
  font-weight: 600;
  border-top: 2px solid var(--table-border);
  background: var(--surface-alt);
}

.report-table tfoot td:first-child {
  text-align: left;
}

/* ─── P&L row hierarchy ─── */

.section-row td {
  background: var(--row-section) !important;
  color: var(--row-section-fg) !important;
  height: var(--row-height-section);
  font-weight: 700;
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding-top: 0.6rem;
  padding-bottom: 0.6rem;
}

.category-row td {
  background: var(--row-category) !important;
  height: var(--row-height);
  font-weight: 700;
  padding-left: 1.5rem !important;
}

.line-item-row td {
  height: var(--row-height);
}

.line-item-row td:first-child {
  padding-left: 2.5rem;
  color: var(--muted-foreground);
}

.subtotal-row td {
  background: var(--row-subtotal) !important;
  font-weight: 700;
  border-top: 1px solid var(--table-border);
}

.summary-row td {
  font-weight: 700;
  height: var(--row-height-summary);
  background: var(--row-summary) !important;
  border-top: 2px solid var(--table-border);
}

.summary-row.highlight td {
  background: var(--row-summary-highlight) !important;
}

.margin-row td {
  color: var(--muted-foreground);
  font-size: 0.8rem;
  font-style: italic;
  border-top: none;
}

/* ─── Standard P&L month matrix ─── */
/* Wide: one column per month (× transaction type) plus an FY Total group.
   The .table-wrapper already scrolls horizontally; these rules pin the row
   label, mark the month-group separators, and emphasise the Total column. */

.report-table.pl-matrix {
  font-variant-numeric: tabular-nums;
}

.report-table.pl-matrix thead th.month-head {
  text-align: center;
}

.report-table.pl-matrix .thead-sub th {
  font-size: 0.68rem;
  font-weight: 500;
  padding: 0.15rem 0.5rem;
  text-align: right;
}

/* Group separators: a light rule after each month, a heavier one before the
   FY Total group. */
.report-table.pl-matrix .month-end {
  border-right: 1px solid var(--table-border);
}

.report-table.pl-matrix .total-start {
  border-left: 2px solid var(--table-border);
}

/* The FY Total columns read as the headline figure. */
.report-table.pl-matrix .col-total {
  font-weight: 600;
  background: rgba(0, 0, 0, 0.025);
}

.report-table.pl-matrix tfoot .col-total {
  font-weight: 700;
}

/* Sticky row-label column so it stays put on wide tables. Per-row backgrounds
   are restated here because position:sticky cells need an opaque fill. */
.report-table.pl-matrix thead th:first-child,
.report-table.pl-matrix tbody td:first-child,
.report-table.pl-matrix tfoot td:first-child {
  position: sticky;
  left: 0;
  z-index: 3;
  background: var(--surface);
}

.report-table.pl-matrix thead th:first-child {
  z-index: 11;
}

.report-table.pl-matrix tbody .section-row td:first-child {
  background: var(--row-section);
}

.report-table.pl-matrix tbody .category-row td:first-child {
  background: var(--row-category);
}

.report-table.pl-matrix tbody tr:nth-child(even) td:first-child {
  background: var(--row-zebra);
}

.report-table.pl-matrix tfoot .summary-row td:first-child {
  background: var(--row-summary);
}

.report-table.pl-matrix tfoot .summary-row.highlight td:first-child {
  background: var(--row-summary-highlight);
}

/* ─── Value classes ─── */

.positive {
  color: var(--positive);
}

.negative {
  color: var(--negative);
}

.neutral {
  color: var(--muted-foreground);
}

/* ─── Utilisation colour bands ─── */

.util-low {
  background: var(--heat-over-1) !important;
  color: var(--negative);
  font-weight: 600;
}

.util-mid {
  background: var(--wt-marketing-bg) !important;
  color: var(--warning);
  font-weight: 600;
}

.util-high {
  background: var(--badge-active-bg) !important;
  color: var(--positive);
  font-weight: 600;
}

/* ─── Report header extras ─── */

.report-header-back {
  margin-bottom: 0.5rem;
}

.report-header-back a {
  font-size: 0.8125rem;
  color: var(--muted-foreground);
  text-decoration: none;
}

.report-header-back a:hover {
  color: var(--accent);
}

.report-subtitle {
  font-size: 0.875rem;
  color: var(--muted-foreground);
  margin-top: 0.25rem;
}

/* ─── KPI strip (horizontal row for project detail) ─── */

.kpi-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 2rem;
}

.kpi-strip .kpi-card {
  flex: 1 1 130px;
}

/* ─── KPI grid ─── */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-s);
  padding: 1rem 1.25rem;
}

.kpi-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted-foreground);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.5rem;
}

.kpi-actual {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-heading);
  font-family: var(--font-display), Georgia, 'Times New Roman', serif;
  line-height: 1.2;
}

.kpi-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.kpi-budget {
  font-size: 0.78rem;
  color: var(--muted-foreground);
}

.kpi-badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.15rem 0.45rem;
  border-radius: var(--radius-s);
  background: #f0f0ec;
  color: var(--muted-foreground);
}

.kpi-badge.positive {
  background: #eaf5ee;
  color: var(--positive);
}

.kpi-badge.negative {
  background: #faeaea;
  color: var(--negative);
}

/* ─── Report body layout ─── */

.report-body {
  display: flex;
  gap: 2.5rem;
  align-items: flex-start;
}

.report-data {
  flex: 1;
  min-width: 0;
}

.report-notes {
  width: 320px;
  flex-shrink: 0;
}

/* ─── Calc notes ─── */

.calc-notes {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: 0 6px 6px 0;
  padding: 1.5rem;
  position: sticky;
  top: 1.5rem;
}

.calc-notes h2 {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--accent);
  font-weight: 700;
  margin-bottom: 1rem;
}

.calc-notes p {
  font-size: 0.92rem;
  color: var(--foreground);
  line-height: 1.8;
  margin-bottom: 0.9rem;
}

.calc-notes p:last-child {
  margin-bottom: 0;
}

@media (max-width: 960px) {
  .report-body {
    flex-direction: column;
  }
  .report-notes {
    width: 100%;
  }
  .calc-notes {
    position: static;
  }
}

/* ─── Contacts: badges & tags ─── */

.badge {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-m);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.badge-active {
  background: var(--badge-active-bg);
  color: var(--badge-active-fg);
}

.badge-inactive {
  background: var(--badge-inactive-bg);
  color: var(--badge-inactive-fg);
}

.tag {
  display: inline-block;
  padding: 0.15rem 0.45rem;
  border-radius: var(--radius-s);
  font-size: 0.78rem;
  margin: 0.1rem 0.2rem 0.1rem 0;
  border: 1px solid transparent;
}

.tag-active {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: #1d4ed8;
}

.tag-inactive {
  background: #f9fafb;
  border-color: #e5e7eb;
  color: #9ca3af;
}

/* ─── Error banner ─── */

.error-banner {
  background: var(--error-bg);
  border: 1px solid var(--error-border);
  border-radius: var(--radius-s);
  padding: 0.85rem 1rem;
  color: var(--error-text);
  font-size: 0.85rem;
  margin-bottom: 1.5rem;
  font-family: var(--font-mono), 'Courier New', Courier, monospace;
}

.error-banner::before {
  content: "Error: ";
  font-weight: 700;
}

/* ─── Notice / stub ─── */

.notice-banner {
  background: var(--cell-focus-bg);
  border: 1px solid var(--warning);
  border-radius: var(--radius-s);
  padding: 1rem 1.25rem;
  color: #6a5a00;
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
}

.notice-banner strong {
  display: block;
  font-size: 1rem;
  margin-bottom: 0.3rem;
}

/* ─── Index page ─── */

.report-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

.report-card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-s);
  padding: 1rem 1.25rem;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.1s, box-shadow 0.1s;
}

.report-card:hover {
  border-color: #a0a0c8;
  box-shadow: 0 2px 8px rgba(0,0,0,0.07);
}

.report-card h3 {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-heading);
  margin-bottom: 0.3rem;
}

.report-card p {
  font-size: 0.78rem;
  color: var(--muted-foreground);
  line-height: 1.4;
}

.rate-hint {
  font-size: 0.7rem;
  color: var(--muted-foreground);
  display: block;
}

.empty-state {
  font-size: 0.875rem;
  color: var(--muted-foreground);
  padding: 1rem 0;
  margin-bottom: 1.5rem;
}

/* ─── Section headings within reports ─── */

.section-heading {
  font-family: var(--font-display), Georgia, 'Times New Roman', serif;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-heading);
  margin: 1.5rem 0 0.75rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid var(--border);
}

/* ─── Misc utilities ─── */

.text-right { text-align: right; }
.text-muted { color: var(--muted-foreground); }
.font-bold { font-weight: 700; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }

/* ─── Hamburger / nav toggle (pure CSS checkbox hack) ─── */

.nav-toggle {
  display: none;
}

.nav-toggle-label {
  display: none;
  cursor: pointer;
  padding: 0.75rem 1rem;
  font-size: 1.4rem;
  color: #ffffff;
  line-height: 1;
  user-select: none;
}

/* ─── Responsive: Tablet (768px – 1024px) ─── */

@media (min-width: 768px) and (max-width: 1024px) {
  :root {
    --sidebar-width: 180px;
  }

  .main {
    padding: 1.5rem 1.75rem;
  }
}

/* ─── Responsive: Mobile (max 767px) ─── */

@media (max-width: 767px) {
  html {
    font-size: 16px;
  }

  /* Sidebar becomes a top nav bar */
  .layout {
    flex-direction: column;
  }

  .sidebar {
    position: relative;
    width: 100%;
    height: auto;
    overflow-y: visible;
    flex-direction: column;
  }

  /* Logo row: flex row so hamburger sits alongside logo */
  .sidebar-logo {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
  }

  /* Show hamburger label on mobile */
  .nav-toggle-label {
    display: block;
    padding: 0;
    font-size: 1.5rem;
  }

  /* Hide nav links by default */
  .sidebar nav {
    display: none;
    padding: 0.5rem 0;
  }

  /* Show nav when checkbox is checked */
  .nav-toggle:checked ~ nav {
    display: block;
  }

  /* Main content: full width, no left margin */
  .main {
    margin-left: 0;
    padding: 1rem;
    width: 100%;
  }

  /* Report header */
  .report-header h1 {
    font-size: 1.25rem;
  }

  /* KPI grid: single column */
  .kpi-grid {
    grid-template-columns: 1fr;
  }

  /* Period picker: stack vertically */
  .period-picker {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.6rem;
  }

  .period-picker label {
    width: 100%;
  }

  .period-picker input[type="date"],
  .period-picker select {
    width: 100%;
  }

  .period-picker button {
    width: 100%;
    padding: 0.45rem 0.9rem;
  }

  /* Tables: horizontal scroll */
  .report-table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Table wrapper already has overflow-x: auto, but reinforce on mobile */
  .table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* ============================================================
   Schema / Data Model page
   ============================================================ */
.schema-diagram {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-m);
  padding: 2rem;
  margin-bottom: 2rem;
  overflow-x: auto;
}

.schema-diagram svg {
  display: block;
  margin: 0 auto;
  max-width: 100%;
}

.schema-notes {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-m);
  padding: 1.5rem 2rem;
}

.schema-notes h2 {
  font-size: 1rem;
  font-weight: 600;
  margin: 0 0 1rem;
  color: var(--foreground);
}

.schema-notes ul {
  margin: 0;
  padding-left: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.schema-notes li {
  font-size: 0.875rem;
  color: var(--muted-foreground);
  line-height: 1.5;
}

.schema-notes li strong {
  color: var(--foreground);
}

.schema-notes code {
  font-family: monospace;
  font-size: 0.8125rem;
  background: var(--border);
  padding: 0.1em 0.35em;
  border-radius: var(--radius-s);
}

/* ============================================================
   Notes widget
   ============================================================ */
.notes-widget {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.5rem;
}

.notes-toggle {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-m);
  padding: 0.55rem 1rem;
  font-size: 0.9rem;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
  transition: background 0.15s;
}

.notes-toggle:hover,
.notes-toggle.active {
  background: var(--primary-hover);
}

.notes-panel {
  background: #fff;
  border: 1px solid var(--table-border);
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  width: min(420px, calc(100vw - 3rem));
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.notes-panel[hidden] {
  display: none;
}

.notes-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.6rem 0.9rem;
  background: var(--surface-alt);
  border-bottom: 1px solid var(--table-border);
  font-size: 0.8rem;
  color: var(--muted-foreground);
}

.notes-header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.notes-saved {
  font-size: 0.75rem;
  color: var(--positive);
  font-weight: 600;
}

.notes-close-btn {
  background: none;
  border: none;
  color: var(--muted-foreground);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}

.notes-close-btn:hover {
  color: var(--foreground);
}

.notes-textarea {
  width: 100%;
  min-height: 80px;
  padding: 0.75rem;
  font-size: 0.9rem;
  font-family: inherit;
  line-height: 1.5;
  border: none;
  resize: none;
  outline: none;
  color: var(--foreground);
  overflow-y: hidden;
}

.notes-actions {
  padding: 0.5rem 0.75rem;
  border-top: 1px solid var(--table-border);
  display: flex;
  justify-content: flex-end;
}

.notes-save-btn {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-s);
  padding: 0.4rem 1rem;
  font-size: 0.85rem;
  cursor: pointer;
}

.notes-save-btn:hover {
  background: var(--primary-hover);
}
