/* ============================================================
   Freight Ops · operations report · sober monochrome styling
   Design principles:
   - Single accent (red) used only for negative/alert values
   - Dense tables, tabular numerals, no zebra
   - No hero numbers, no gradients, no shadows beyond hairlines
   ============================================================ */

:root {
  --bg: #ffffff;
  --bg-soft: #fafaf9;
  --bg-row-hover: #f5f5f4;
  --bg-rail: #fafaf9;
  --border: #e7e5e4;
  --border-strong: #d6d3d1;
  --text: #18181b;
  --text-muted: #71717a;
  --text-subtle: #a8a29e;
  --alert: #b91c1c;
  --alert-soft: #fef2f2;
  --good: #15803d;

  --rail-w: 240px;
  --gap: 24px;
  --radius: 4px;
  --radius-lg: 10px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04), 0 0 0 1px rgba(15, 23, 42, 0.04);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Geist', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

html.is-embedded .lg-back,
html.is-embedded .lg-header { display: none; }

.lg-main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 32px 40px 80px;
}

.lg-back {
  display: inline-block;
  margin-bottom: 24px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13px;
}
.lg-back:hover { color: var(--text); }

/* ---------- Header ---------- */
.lg-header {
  border-bottom: 1px solid var(--border);
  padding-bottom: 20px;
  margin-bottom: 24px;
}
.lg-eyebrow {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.lg-h1 {
  font-size: 22px;
  font-weight: 600;
  margin: 0 0 6px 0;
  color: var(--text);
}
.lg-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0;
  font-variant-numeric: tabular-nums;
}

/* ---------- Shell: rail + pane ---------- */
.lg-shell {
  display: grid;
  grid-template-columns: var(--rail-w) 1fr;
  gap: var(--gap);
  align-items: start;
}

/* ---------- Left rail ---------- */
.lg-rail {
  position: sticky;
  top: 24px;
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px 8px;
  box-shadow: var(--shadow-sm);
  min-height: calc(100vh - 48px);
}

/* Brand block */
.lg-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 14px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--border);
}
.lg-brand-text { flex: 1; }

/* Rail collapse toggle */
.lg-rail-toggle {
  appearance: none;
  background: transparent;
  border: 0;
  cursor: pointer;
  color: var(--text-subtle);
  padding: 4px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color 80ms, background 80ms;
}
.lg-rail-toggle:hover { color: var(--text); background: var(--bg-soft); }
.lg-rail-toggle svg {
  width: 14px;
  height: 14px;
  transition: transform 200ms;
}
.is-rail-collapsed .lg-rail-toggle svg { transform: rotate(180deg); }
.lg-brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: var(--text);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}
.lg-brand-text { line-height: 1.2; min-width: 0; }
.lg-brand-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.lg-brand-sub {
  font-size: 11px;
  color: var(--text-subtle);
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
}

/* Section label */
.lg-rail-section {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-subtle);
  padding: 12px 12px 4px;
  font-weight: 500;
}

.lg-rail-group {
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin-bottom: 2px;
}

.lg-rail-item {
  appearance: none;
  background: transparent;
  border: 0;
  text-align: left;
  font: inherit;
  color: var(--text-muted);
  padding: 7px 10px;
  cursor: pointer;
  border-radius: 6px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: background 80ms, color 80ms;
}
.lg-rail-item:hover {
  color: var(--text);
  background: var(--bg-soft);
}
.lg-rail-item.is-active {
  color: var(--text);
  background: var(--bg-soft);
  font-weight: 500;
}
.lg-rail-item.is-active .lg-rail-icon {
  color: var(--text);
}
.lg-rail-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: var(--text-subtle);
}
.lg-rail-item:hover .lg-rail-icon { color: var(--text-muted); }

/* Spacer pushes account block to bottom */
.lg-rail-spacer { flex: 1; min-height: 16px; }

/* Account block */
.lg-rail-account {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 8px 4px;
  border-top: 1px solid var(--border);
  margin-top: 8px;
}
.lg-rail-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg-soft);
  border: 1px solid var(--border-strong);
  color: var(--text);
  font-size: 11px;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  letter-spacing: 0.02em;
}
.lg-rail-account-text { line-height: 1.2; min-width: 0; }
.lg-rail-account-name {
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
}
.lg-rail-account-org {
  font-size: 11px;
  color: var(--text-subtle);
  margin-top: 2px;
}

/* ---------- Pane ---------- */
.lg-pane { min-width: 0; }
.lg-pane[hidden] { display: none; }

.lg-pane-head { margin-bottom: 20px; }
.lg-pane-head h2 {
  font-size: 18px;
  font-weight: 600;
  margin: 0 0 4px 0;
}
.lg-pane-head p {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0;
  max-width: 70ch;
}

/* ---------- Stat strip ---------- */
.lg-stat-strip {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 20px;
  background: #fff;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
@media (max-width: 1100px) {
  .lg-stat-strip { grid-template-columns: repeat(3, 1fr); }
  .lg-stat-strip .lg-stat:nth-child(3) { border-right: 0; }
  .lg-stat-strip .lg-stat:nth-child(-n+3) { border-bottom: 1px solid var(--border); }
}
.lg-stat {
  padding: 12px 16px;
  border-right: 1px solid var(--border);
}
.lg-stat:last-child { border-right: 0; }
.lg-stat-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.lg-stat-value {
  font-size: 17px;
  font-weight: 500;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}
.lg-stat-sub {
  font-size: 11px;
  color: var(--text-subtle);
  margin-top: 2px;
}

/* ---------- Toolbar ---------- */
.lg-toolbar {
  position: sticky;
  top: 0;
  z-index: 3;
  background: #fff;
  padding: 14px 0 12px;
  margin: -32px 0 0;     /* cancel pane top spacing so it docks cleanly */
  padding-top: 32px;     /* keep visual breathing room above */
  margin-bottom: 4px;
}
.lg-toolbar-row {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
}
.lg-search {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px 10px;
  background: #fff;
}
.lg-search:focus-within { border-color: var(--text); }
.lg-search-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}
.lg-search input {
  appearance: none;
  border: 0;
  outline: 0;
  font: inherit;
  font-size: 13px;
  color: var(--text);
  width: 200px;
  padding: 4px 0;
  background: transparent;
}

.lg-select {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px 10px;
  background: #fff;
  cursor: pointer;
}
.lg-select:hover { border-color: var(--border-strong); }
.lg-select:focus-within { border-color: var(--text); }
.lg-select-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  pointer-events: none;
}
.lg-select select {
  appearance: none;
  border: 0;
  outline: 0;
  font: inherit;
  font-size: 13px;
  color: var(--text);
  background: transparent;
  cursor: pointer;
  padding: 4px 18px 4px 0;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%2371717a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M6 9l6 6 6-6'/></svg>");
  background-repeat: no-repeat;
  background-position: right center;
  background-size: 10px 10px;
}
.lg-chips {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: #fff;
}
.lg-chip {
  appearance: none;
  background: #fff;
  border: 0;
  border-right: 1px solid var(--border);
  font: inherit;
  font-size: 12px;
  color: var(--text-muted);
  padding: 6px 12px;
  cursor: pointer;
}
.lg-chip:last-child { border-right: 0; }
.lg-chip:hover { color: var(--text); }
.lg-chip.is-active {
  background: var(--text);
  color: #fff;
}

/* ---------- Table ---------- */
.lg-table-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: clip;       /* clips rounded corners without breaking sticky thead */
  background: #fff;
  box-shadow: var(--shadow-sm);
}
.lg-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
  table-layout: fixed;
}

/* Customers table — fixed column widths so sorting doesn't reflow */
#cust-table th:nth-child(1),  #cust-table td:nth-child(1)  { width: 18%; } /* Customer */
#cust-table th:nth-child(2),  #cust-table td:nth-child(2)  { width: 9%;  } /* Type */
#cust-table th:nth-child(3),  #cust-table td:nth-child(3)  { width: 6%;  } /* Loads */
#cust-table th:nth-child(4),  #cust-table td:nth-child(4)  { width: 8%;  } /* Miles */
#cust-table th:nth-child(5),  #cust-table td:nth-child(5)  { width: 11%; } /* Revenue */
#cust-table th:nth-child(6),  #cust-table td:nth-child(6)  { width: 6%;  } /* Share */
#cust-table th:nth-child(7),  #cust-table td:nth-child(7)  { width: 10%; } /* Trend */
#cust-table th:nth-child(8),  #cust-table td:nth-child(8)  { width: 6%;  } /* $/mi */
#cust-table th:nth-child(9),  #cust-table td:nth-child(9)  { width: 7%;  } /* GC/mi */
#cust-table th:nth-child(10), #cust-table td:nth-child(10) { width: 8%;  } /* Fuel recov */
#cust-table th:nth-child(11), #cust-table td:nth-child(11) { width: 6%;  } /* OTD */
#cust-table th:nth-child(12), #cust-table td:nth-child(12) { width: 7%;  } /* Detention */

/* Lanes table — fixed column widths */
#lane-table th:nth-child(1),  #lane-table td:nth-child(1)  { width: 14%; } /* Origin */
#lane-table th:nth-child(2),  #lane-table td:nth-child(2)  { width: 14%; } /* Destination */
#lane-table th:nth-child(3),  #lane-table td:nth-child(3)  { width: 7%;  } /* Distance */
#lane-table th:nth-child(4),  #lane-table td:nth-child(4)  { width: 6%;  } /* Loads */
#lane-table th:nth-child(5),  #lane-table td:nth-child(5)  { width: 11%; } /* Revenue */
#lane-table th:nth-child(6),  #lane-table td:nth-child(6)  { width: 6%;  } /* Share */
#lane-table th:nth-child(7),  #lane-table td:nth-child(7)  { width: 11%; } /* Trend */
#lane-table th:nth-child(8),  #lane-table td:nth-child(8)  { width: 7%;  } /* $/mi */
#lane-table th:nth-child(9),  #lane-table td:nth-child(9)  { width: 8%;  } /* GC/mi */
#lane-table th:nth-child(10), #lane-table td:nth-child(10) { width: 8%;  } /* Fuel recov */
#lane-table th:nth-child(11), #lane-table td:nth-child(11) { width: 8%;  } /* OTD */

/* Trucks table */
#truck-table th:nth-child(1),  #truck-table td:nth-child(1)  { width: 11%; } /* Unit */
#truck-table th:nth-child(2),  #truck-table td:nth-child(2)  { width: 13%; } /* Make/Year */
#truck-table th:nth-child(3),  #truck-table td:nth-child(3)  { width: 9%;  } /* Status */
#truck-table th:nth-child(4),  #truck-table td:nth-child(4)  { width: 6%;  } /* Trips */
#truck-table th:nth-child(5),  #truck-table td:nth-child(5)  { width: 8%;  } /* Miles */
#truck-table th:nth-child(6),  #truck-table td:nth-child(6)  { width: 10%; } /* Revenue */
#truck-table th:nth-child(7),  #truck-table td:nth-child(7)  { width: 12%; } /* Trend */
#truck-table th:nth-child(8),  #truck-table td:nth-child(8)  { width: 6%;  } /* MPG */
#truck-table th:nth-child(9),  #truck-table td:nth-child(9)  { width: 9%;  } /* Maint $/mi */
#truck-table th:nth-child(10), #truck-table td:nth-child(10) { width: 8%;  } /* Downtime */
#truck-table th:nth-child(11), #truck-table td:nth-child(11) { width: 8%;  } /* Incidents */

/* Drivers table */
#driver-table th:nth-child(1),  #driver-table td:nth-child(1)  { width: 14%; } /* Driver */
#driver-table th:nth-child(2),  #driver-table td:nth-child(2)  { width: 8%;  } /* Status */
#driver-table th:nth-child(3),  #driver-table td:nth-child(3)  { width: 10%; } /* Terminal */
#driver-table th:nth-child(4),  #driver-table td:nth-child(4)  { width: 5%;  } /* Exp */
#driver-table th:nth-child(5),  #driver-table td:nth-child(5)  { width: 6%;  } /* Trips */
#driver-table th:nth-child(6),  #driver-table td:nth-child(6)  { width: 8%;  } /* Miles */
#driver-table th:nth-child(7),  #driver-table td:nth-child(7)  { width: 10%; } /* Revenue */
#driver-table th:nth-child(8),  #driver-table td:nth-child(8)  { width: 11%; } /* Trend */
#driver-table th:nth-child(9),  #driver-table td:nth-child(9)  { width: 6%;  } /* MPG */
#driver-table th:nth-child(10), #driver-table td:nth-child(10) { width: 7%;  } /* Idle/trip */
#driver-table th:nth-child(11), #driver-table td:nth-child(11) { width: 7%;  } /* OTD */
#driver-table th:nth-child(12), #driver-table td:nth-child(12) { width: 8%;  } /* Incidents */

/* Driver column: hide overflow if name + id wrap */
#driver-table td:nth-child(1) { overflow: hidden; text-overflow: ellipsis; }

/* Row click affordance */
#cust-table tbody tr,
#lane-table tbody tr,
#truck-table tbody tr,
#driver-table tbody tr { cursor: pointer; }

/* Fuel pane: grid with two side-by-side tables */
.lg-fuel-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 1100px) {
  .lg-fuel-grid { grid-template-columns: 1fr; }
}
.lg-fuel-section {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: #fff;
  box-shadow: var(--shadow-sm);
  margin-bottom: 16px;
}
.lg-fuel-section.lg-detail-section { padding: 18px 20px; }
.lg-fuel-grid > .lg-fuel-section { margin-bottom: 0; }

.lg-toolbar-static {
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
}

/* ---------- P&L decomposition ---------- */
#summary-pl-table {
  table-layout: fixed;
  max-width: 760px;
}
#summary-pl-table th:nth-child(1), #summary-pl-table td:nth-child(1) { width: 42%; }
#summary-pl-table th:nth-child(2), #summary-pl-table td:nth-child(2) { width: 22%; }
#summary-pl-table th:nth-child(3), #summary-pl-table td:nth-child(3) { width: 18%; }
#summary-pl-table th:nth-child(4), #summary-pl-table td:nth-child(4) { width: 18%; }

.lg-pl-total td {
  font-weight: 600;
  background: var(--bg-soft);
  border-top: 1px solid var(--border-strong) !important;
}
.lg-pl-section td {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-subtle);
  padding-top: 12px;
  font-weight: 500;
  background: transparent;
}
.lg-pl-final td {
  font-weight: 600;
  background: #f0f9ff;     /* very subtle blue bg for the final number */
  color: #0c4a6e;
  border-top: 2px solid var(--border-strong) !important;
  padding-top: 11px;
  padding-bottom: 11px;
}
.lg-pl-desc {
  font-size: 11px;
  color: var(--text-subtle);
  font-weight: 400;
  margin-left: 6px;
}

/* Inline flag text in safety incidents list */
.lg-flag-text {
  display: inline-block;
  padding: 0 5px;
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-radius: 3px;
  background: var(--bg-soft);
  color: var(--text-muted);
  border: 1px solid var(--border-strong);
  margin-right: 3px;
}
.lg-flag-text--bad {
  background: #fef2f2;
  color: #b91c1c;
  border-color: #fecaca;
}
.lg-fuel-legend {
  margin: 12px 0 0 0;
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  gap: 20px;
  align-items: center;
}
.lg-legend-mark {
  display: inline-block;
  width: 12px;
  height: 2px;
  margin-right: 6px;
  vertical-align: middle;
}
.lg-legend-mark--alt { height: 2px; border-top: 1px dashed currentColor; background: transparent !important; }

#fuel-summary { grid-template-columns: repeat(6, 1fr); }
@media (max-width: 1100px) {
  #fuel-summary { grid-template-columns: repeat(3, 1fr); }
}

/* Auto-flag badges next to customer name */
.lg-flag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  font-size: 9px;
  font-weight: 700;
  margin-left: 6px;
  vertical-align: 1px;
  letter-spacing: 0;
  flex-shrink: 0;
}
.lg-flag-risk    { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }
.lg-flag-premium { background: #fffbeb; color: #b45309; border: 1px solid #fde68a; }
.lg-flag-dormant { background: var(--bg-soft); color: var(--text-subtle); border: 1px solid var(--border-strong); }

/* Share column — small percentage */
.lg-share { color: var(--text-muted); font-size: 12px; }

/* Sparkline cell */
.lg-spark {
  display: block;
  width: 100%;
  height: 18px;
  color: var(--text-subtle);
}
.lg-spark-empty {
  font-size: 11px;
  color: var(--text-subtle);
}

/* Truncate long customer names instead of wrapping */
#cust-table td:nth-child(1) {
  overflow: hidden;
  text-overflow: ellipsis;
}
.lg-table thead th {
  position: sticky;
  top: 76px;  /* sits below the sticky toolbar (28+~30 + 16 buffer) */
  z-index: 2;
  background-color: #f5f5f4;
  font-weight: 500;
  color: var(--text-muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 10px 12px;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  box-shadow: inset 0 -1px 0 var(--border-strong);
}
.lg-table thead th:hover { color: var(--text); }
.lg-table thead th.is-sorted { color: var(--text); }
.lg-table thead th.is-sorted::after {
  content: " ↑";
  font-size: 10px;
  color: var(--text-muted);
}
.lg-table thead th.is-sorted.is-desc::after { content: " ↓"; }

.lg-th-num { text-align: right; }
.lg-th-text { text-align: left; }

.lg-table tbody td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.lg-table tbody tr:last-child td { border-bottom: 0; }
.lg-table tbody tr:hover { background: var(--bg-row-hover); }

.lg-td-num { text-align: right; }
.lg-td-text { text-align: left; }

.lg-td-name {
  font-weight: 500;
  color: var(--text);
}
.lg-td-name-id {
  font-size: 11px;
  color: var(--text-subtle);
  font-family: 'Geist Mono', ui-monospace, monospace;
  margin-left: 6px;
}

.lg-tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  border: 0;
  border-radius: 999px;
  color: #fff;
  background: var(--text-muted);
  line-height: 1.5;
}

/* Customer-type chips — solid, distinct hues, lightened */
.lg-tag-Contract  { background: #60a5fa; }  /* blue-400 */
.lg-tag-Dedicated { background: #c084fc; }  /* purple-400 */
.lg-tag-Spot      { background: #fb923c; }  /* orange-400 */

.lg-tag-inactive {
  background: transparent !important;
  border: 1px dashed var(--border-strong) !important;
  color: var(--text-subtle) !important;
  padding: 1px 7px;
}

/* Status pill for trucks / drivers (subtle, with a colored dot) */
.lg-tag-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 1px 8px 1px 7px;
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-radius: 999px;
  background: var(--bg-soft);
  color: var(--text-muted);
  border: 1px solid var(--border-strong);
}
.lg-tag-status::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--text-subtle);
  flex-shrink: 0;
}
.lg-tag-status--on {
  background: #ecfeff;
  border-color: #a5f3fc;
  color: #0e7490;
}
.lg-tag-status--on::before { background: #06b6d4; }
.lg-tag-status--maint {
  background: #fffbeb;
  border-color: #fde68a;
  color: #92400e;
}
.lg-tag-status--maint::before { background: #f59e0b; }
.lg-tag-status--off {
  border-style: dashed;
  color: var(--text-subtle);
}
.lg-tag-status--off::before { display: none; }

.lg-empty {
  padding: 32px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  margin: 0;
}

/* ---------- Method button (icon-only, sits at end of toolbar) ---------- */
.lg-method-btn {
  appearance: none;
  background: transparent;
  border: 0;
  cursor: pointer;
  color: var(--text-subtle);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: auto;
  transition: color 80ms, background 80ms;
}
.lg-method-btn:hover {
  color: var(--text);
  background: var(--bg-soft);
}
.lg-method-btn svg {
  width: 16px;
  height: 16px;
}

/* ---------- Modal ---------- */
.lg-modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.lg-modal[hidden] { display: none; }
.lg-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.32);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}
.lg-modal-card {
  position: relative;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow:
    0 20px 40px rgba(15, 23, 42, 0.16),
    0 4px 12px rgba(15, 23, 42, 0.08);
  max-width: 640px;
  width: 100%;
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: lg-modal-in 140ms ease-out;
}
@keyframes lg-modal-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.lg-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.lg-modal-head h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}
.lg-modal-close {
  appearance: none;
  background: transparent;
  border: 0;
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px;
  border-radius: 4px;
  display: inline-flex;
}
.lg-modal-close:hover { color: var(--text); background: var(--bg-soft); }
.lg-modal-close svg { width: 16px; height: 16px; }
.lg-modal-body {
  padding: 20px;
  overflow-y: auto;
  font-size: 13px;
  color: var(--text);
  line-height: 1.55;
}
.lg-modal-body .lg-glossary {
  margin: 0;
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 10px 20px;
}
.lg-modal-body .lg-glossary dt {
  font-weight: 500;
  color: var(--text);
}
.lg-modal-body .lg-glossary dd {
  margin: 0;
  color: var(--text-muted);
}
.lg-modal-note {
  margin: 16px 0 0 0;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-subtle);
  font-family: 'Geist Mono', ui-monospace, monospace;
  line-height: 1.6;
}
.lg-modal-note code {
  background: var(--bg-soft);
  padding: 1px 4px;
  border-radius: 2px;
  border: 1px solid var(--border);
  font-size: 11px;
}
@media (max-width: 600px) {
  .lg-modal-body .lg-glossary {
    grid-template-columns: 1fr;
    gap: 4px 0;
  }
  .lg-modal-body .lg-glossary dt { margin-top: 8px; }
}

/* ---------- Drill-down (wide) modal ---------- */
.lg-modal-wide .lg-modal-card {
  max-width: 960px;
}

.lg-detail-head { flex: 1; min-width: 0; }
.lg-detail-head-name {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}
.lg-detail-head-id {
  font-family: 'Geist Mono', ui-monospace, monospace;
  font-size: 12px;
  color: var(--text-subtle);
  font-weight: 400;
}
.lg-detail-head-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-muted);
}
.lg-detail-head-meta span { display: inline-flex; align-items: center; }

.lg-detail-body {
  padding: 0 !important;
}

.lg-detail-body .lg-stat-strip {
  border-radius: 0;
  border: 0;
  border-bottom: 1px solid var(--border);
  margin: 0;
  box-shadow: none;
  grid-template-columns: repeat(6, 1fr);
}
.lg-detail-body .lg-stat-strip .lg-stat:last-child { border-right: 0; }

.lg-detail-section {
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}
.lg-detail-section:last-child { border-bottom: 0; }
.lg-detail-section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 12px;
  gap: 12px;
}
.lg-detail-section-head h4 {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.lg-detail-section-sub {
  font-size: 11px;
  color: var(--text-subtle);
}

/* Chart container */
.lg-chart {
  width: 100%;
  position: relative;
}
.lg-chart svg { display: block; width: 100%; height: auto; }
.lg-chart-axis text {
  font-size: 11px;
  fill: var(--text-muted);
  font-family: 'Geist Mono', ui-monospace, monospace;
}
.lg-chart-grid line {
  stroke: var(--border);
  stroke-width: 1;
}
.lg-chart-line {
  fill: none;
  stroke: var(--text);
  stroke-width: 1.4;
  stroke-linejoin: round;
}
.lg-chart-area {
  fill: var(--text);
  opacity: 0.06;
}
.lg-chart-dot {
  fill: var(--text);
}

/* Compact lanes table inside drill-down */
.lg-table-wrap-inline {
  border-radius: var(--radius);
  box-shadow: none;
  max-height: 280px;
  overflow: auto;
}
.lg-table-compact {
  table-layout: auto;            /* size columns to content; no overlap */
}
.lg-table-compact thead th {
  background: var(--bg-soft);
  top: 0;                        /* override main-table offset, modal has no toolbar above */
  padding: 8px 10px;
  font-size: 10px;
  cursor: default;
  white-space: nowrap;
}
.lg-table-compact tbody td {
  font-size: 12px;
  padding: 7px 10px;
  white-space: nowrap;
}
.lg-table-compact tbody tr { cursor: default; }

/* Activity facts */
.lg-detail-facts {
  margin: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px 24px;
  font-size: 13px;
}
.lg-detail-facts dt {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 2px;
}
.lg-detail-facts dd {
  margin: 0;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

@media (max-width: 700px) {
  .lg-detail-body .lg-stat-strip { grid-template-columns: repeat(2, 1fr); }
  .lg-detail-body .lg-stat-strip .lg-stat { border-right: 0; border-bottom: 1px solid var(--border); }
  .lg-detail-facts { grid-template-columns: repeat(2, 1fr); }
}

/* ---------- Pane footer / methodology ---------- */
.lg-pane-foot {
  margin-top: 24px;
  border-top: 1px solid var(--border);
  padding-top: 16px;
}
.lg-pane-foot details summary {
  cursor: pointer;
  font-size: 12px;
  color: var(--text-muted);
  padding: 4px 0;
  list-style: none;
  user-select: none;
}
.lg-pane-foot details summary::-webkit-details-marker { display: none; }
.lg-pane-foot details summary::before {
  content: "+ ";
  color: var(--text-subtle);
}
.lg-pane-foot details[open] summary::before { content: "− "; }
.lg-pane-foot details[open] summary { color: var(--text); }

.lg-glossary {
  margin: 12px 0 0 0;
  font-size: 13px;
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 6px 16px;
}
.lg-glossary dt { font-weight: 500; color: var(--text); }
.lg-glossary dd { margin: 0; color: var(--text-muted); }
.lg-foot-note {
  margin-top: 12px;
  font-size: 12px;
  color: var(--text-subtle);
  font-family: 'Geist Mono', ui-monospace, monospace;
  line-height: 1.6;
}
.lg-foot-note code {
  background: var(--bg-soft);
  padding: 1px 4px;
  border-radius: 2px;
  border: 1px solid var(--border);
  font-size: 11px;
}

/* ---------- Methodology document page ---------- */
.lg-method-doc {
  max-width: 80ch;
  font-size: 13px;
  line-height: 1.65;
  color: var(--text);
}
.lg-method-doc-head {
  border-bottom: 1px solid var(--border);
  padding-bottom: 18px;
  margin-bottom: 24px;
}
.lg-method-doc-head h2 {
  font-size: 22px;
  font-weight: 600;
  margin: 0 0 8px 0;
}
.lg-method-doc-head p {
  font-size: 14px;
  color: var(--text-muted);
  margin: 0;
}
.lg-method-section {
  margin-bottom: 32px;
}
.lg-method-section h3 {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text);
  margin: 0 0 10px 0;
}
.lg-method-section p { margin: 0 0 10px 0; color: var(--text); }
.lg-method-section ul { margin: 0; padding-left: 18px; color: var(--text); }
.lg-method-section li { margin-bottom: 6px; }
.lg-method-section code {
  background: var(--bg-soft);
  padding: 1px 4px;
  border-radius: 2px;
  border: 1px solid var(--border);
  font-size: 11px;
  font-family: 'Geist Mono', ui-monospace, monospace;
}
.lg-glossary-wide {
  grid-template-columns: 220px 1fr;
}

/* ---------- Stubs ---------- */
.lg-stub {
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 20px 24px;
  background: var(--bg-soft);
  color: var(--text-muted);
  font-size: 13px;
  max-width: 70ch;
}
.lg-stub-status {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--alert);
  margin: 0 0 12px 0;
  font-weight: 500;
}
.lg-stub p { margin: 0 0 8px 0; }
.lg-stub ul { margin: 0; padding-left: 18px; }
.lg-stub li { margin-bottom: 3px; }

/* ---------- Rail collapsed state ---------- */
.is-rail-collapsed { --rail-w: 60px; }
.is-rail-collapsed .lg-rail { padding: 8px 6px; }
.is-rail-collapsed .lg-brand {
  flex-direction: column;
  gap: 4px;
  padding: 2px 0 10px;
  border-bottom: 1px solid var(--border);
}
.is-rail-collapsed .lg-brand-text { display: none; }
.is-rail-collapsed .lg-rail-toggle { margin: 0; }
.is-rail-collapsed .lg-rail-section {
  font-size: 0;
  height: 1px;
  background: var(--border);
  padding: 0;
  margin: 8px 6px 4px;
}
.is-rail-collapsed .lg-rail-item {
  justify-content: center;
  padding: 9px 0;
  gap: 0;
}
.is-rail-collapsed .lg-rail-item span { display: none; }
.is-rail-collapsed .lg-rail-account {
  flex-direction: column;
  gap: 0;
  padding: 8px 0 4px;
}
.is-rail-collapsed .lg-rail-account-text { display: none; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .lg-shell { grid-template-columns: 1fr; }
  .lg-rail {
    position: static;
    flex-direction: row;
    overflow-x: auto;
    padding: 4px;
  }
  .lg-rail-sep { display: none; }
  .lg-stat-strip { grid-template-columns: repeat(2, 1fr); }
  .lg-stat:nth-child(2) { border-right: 0; }
  .lg-stat { border-bottom: 1px solid var(--border); }
  .lg-stat:nth-last-child(-n+2) { border-bottom: 0; }
}
@media (max-width: 600px) {
  .lg-main { padding: 20px 16px 60px; }
  .lg-toolbar-row { flex-direction: column; align-items: stretch; }
  .lg-search input { width: 100%; }
}
