:root {
    --bg: #0b0d10;
    --fg: #e8edf2;
    --muted: #9aa7b3;
    --card: #12161c;
    --line: #1f2630;
    --accent: #7dd3fc;
  }
  
  * { box-sizing: border-box; }
  body {
    margin: 0;
    font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial;
    background: var(--bg);
    color: var(--fg);
  }
  
  header {
    padding: 16px 18px;
    border-bottom: 1px solid var(--line);
    display: flex;
    gap: 18px;
    align-items: end;
    justify-content: space-between;
    flex-wrap: wrap;
  }
  
  h1 { margin: 0; font-size: 20px; }
  .sub { color: var(--muted); font-size: 13px; margin-top: 4px; }
  
  .controls { display: flex; gap: 12px; flex-wrap: wrap; }
  label { display: grid; gap: 6px; font-size: 12px; color: var(--muted); }
  select, input {
    background: var(--card);
    border: 1px solid var(--line);
    color: var(--fg);
    padding: 8px 10px;
    border-radius: 10px;
    min-width: 220px;
  }
  
  main {
    display: grid;
    grid-template-columns: 1fr 420px;
    min-height: calc(100vh - 120px);
  }
  
  .tableWrap { padding: 14px 18px; overflow: auto; }
  #chart-container.chart-hidden { display: none; }
  .tableActions {
    display: flex;
    justify-content: flex-start;
    margin-bottom: 8px;
  }
  table { 
    width: 100%; 
    border-collapse: collapse;
    font-size: 14px;
    table-layout: fixed;
  }
  #spending-table th:first-child,
  #spending-table td:first-child {
    width: 38%;
  }
  thead th {
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
    border-bottom: 2px solid var(--line);
    padding: 12px 12px;
    white-space: nowrap;
  }
  thead th.num {
    text-align: right;
  }
  thead th.sources-header {
    text-align: center;
  }
  tbody tr {
    transition: background-color 0.15s ease;
  }
  tbody tr:hover {
    background-color: rgba(255, 255, 255, 0.02);
  }
  tbody tr:nth-child(even) {
    background-color: rgba(255, 255, 255, 0.01);
  }
  tbody tr:nth-child(even):hover {
    background-color: rgba(255, 255, 255, 0.03);
  }
  tbody td {
    border-bottom: 1px solid var(--line);
    padding: 12px 12px;
    vertical-align: middle;
  }
  tbody td:first-child {
    font-weight: 500;
    color: var(--fg);
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: normal;
  }
  .label-line {
    display: block;
  }
  .label-name {
    display: inline-block;
  }
  .chart-label-wrap {
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: normal;
  }
  .label-desc-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: 4px;
    width: 16px;
    height: 16px;
    padding: 0;
    border: 1px solid var(--accent);
    border-radius: 3px;
    background: rgba(125, 211, 252, 0.08);
    color: var(--accent);
    cursor: pointer;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
    vertical-align: middle;
    line-height: 1;
  }
  .label-desc-link:hover {
    background: rgba(125, 211, 252, 0.18);
    border-color: #a5e3ff;
    color: #a5e3ff;
  }
  .label-desc-link:focus-visible {
    outline: 2px solid #a5e3ff;
    outline-offset: 2px;
  }
  .label-desc-summary-inline {
    color: var(--fg);
    font-size: inherit;
    line-height: 1.4;
    font-weight: 500;
  }
  .label-desc-anchor {
    margin-top: 4px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.35;
    font-style: italic;
    font-weight: 400;
  }
  tbody td:last-child {
    text-align: center;
  }
  tbody td:last-child .btn {
    display: inline-block;
    margin: 0 auto;
  }
  .num { 
    text-align: right; 
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum";
  }
  
  .btn {
    background: transparent;
    border: 1px solid var(--line);
    color: var(--fg);
    padding: 7px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s ease;
  }
  .btn:hover { 
    border-color: var(--accent);
    background: rgba(125, 211, 252, 0.08);
  }
  .btn-sm {
    padding: 6px 10px;
    font-size: 11px;
  }
.active-view {
  background: rgba(255,255,255,0.15);
  font-weight: 600;
}
#spending-chart .bar { cursor: pointer; opacity: 0.85; }
#spending-chart .bar:hover { opacity: 1; }

#pie-chart .pie-path { cursor: pointer; opacity: 0.92; transition: opacity 0.15s ease; }
#pie-chart .pie-path:hover { opacity: 1; filter: brightness(1.08); }

/* Thought-bubble popover for expanded category descriptions in charts */
.chart-desc-popover {
  position: fixed;
  z-index: 10002;
  max-width: 360px;
  padding: 12px 14px;
  background: var(--card);
  border: 1px solid var(--accent);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4), 0 0 0 1px rgba(125,211,252,0.2);
  font-size: 13px;
  line-height: 1.45;
}
.chart-desc-popover::before {
  content: "";
  position: absolute;
  left: 16px;
  top: -8px;
  border: 8px solid transparent;
  border-bottom-color: var(--accent);
  border-top: none;
}
.chart-desc-popover.hidden { display: none; }
.chart-desc-popover-inner { position: relative; }
.chart-desc-popover-title { font-weight: 600; margin-bottom: 6px; color: var(--fg); }
.chart-desc-popover-summary { color: var(--fg); margin-bottom: 8px; }
.chart-desc-popover-anchor { color: var(--muted); font-size: 12px; font-style: italic; }

/* Table For Me / For Govt: hide the non-active column */
#spending-table.table-view-for-me th:nth-child(3),
#spending-table.table-view-for-me td:nth-child(3) { display: none; }
#spending-table.table-view-for-govt th:nth-child(2),
#spending-table.table-view-for-govt td:nth-child(2) { display: none; }
  
  .panel {
    border-left: 1px solid var(--line);
    background: #0f1319;
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 64px);
  }
  .hidden { display: none; }
  
  .panelHead {
    padding: 14px 14px 10px 14px;
    border-bottom: 1px solid var(--line);
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: flex-start;
  }
  .panelTitle { font-weight: 700; }
  .panelSub { color: var(--muted); font-size: 12px; margin-top: 4px; }
  
  .panelBody { padding: 14px; overflow-x: hidden; overflow-y: auto; display: grid; gap: 14px; min-width: 0; }
  .block { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px; min-width: 0; overflow-wrap: break-word; }
  .blockTitle { font-size: 12px; color: var(--muted); margin-bottom: 10px; }
  .pre { margin: 0; white-space: pre-wrap; word-break: break-word; font-size: 12px; color: #d6dee7; }
  .links { margin: 0; padding-left: 18px; word-break: break-word; overflow-wrap: break-word; max-width: 100%; }
  .links a { color: var(--accent); text-decoration: none; word-break: break-word; overflow-wrap: break-word; }
  .links a:hover { text-decoration: underline; }
  .links li { word-break: break-word; overflow-wrap: break-word; }
  .links ul { word-break: break-word; overflow-wrap: break-word; }
  
  footer {
    padding: 10px 18px;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: 12px;
  }
  @media (max-width: 1050px) {
    main { grid-template-columns: 1fr; }
    .panel { border-left: none; border-top: 1px solid var(--line); }
  }
  
/* --- "Your share" help (floating tooltip, appears above tax panel) --- */

.shareHelp {
  position: relative;
}

.shareHelpTrigger {
  cursor: pointer;
}
.shareHelpTrigger:hover {
  text-decoration: underline;
}

/* Floating tooltip: position:fixed + high z-index so it appears in front of tax panel */
.shareTipFloating {
  position: fixed;
  z-index: 10000;
  max-width: 360px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #111;
  border: 1px solid rgba(255,255,255,0.15);
  box-shadow: 0 12px 30px rgba(0,0,0,0.4);
  font-size: 0.9rem;
  line-height: 1.3;
  text-align: left;
}
.shareTipFloating.hidden {
  display: none;
}

