:root {
      --bg: #faf7f6;
      --panel: #fffefe;
      --line: #ead8d8;
      --ink: #071d42;
      --muted: #76656a;
      --red: #cf1238;
      --red-soft: #f4dce2;
      --rose: #dd647b;
      --icon-bg: #f1f3f7;
      --shadow: 0 1px 0 rgba(7, 29, 66, 0.03);
    }
    * { box-sizing: border-box; }
    [hidden] { display: none !important; }
    body {
      margin: 0;
      background: var(--bg);
      color: var(--ink);
      font-family: Inter, "Segoe UI", Arial, sans-serif;
      font-size: 14px;
    }
    body.modal-open {
      overflow: hidden;
    }
    .skip-link {
      position: fixed;
      top: 8px;
      left: 8px;
      z-index: 100;
      transform: translateY(-150%);
      border-radius: 7px;
      background: var(--ink);
      color: white;
      padding: 9px 12px;
      text-decoration: none;
    }
    .skip-link:focus {
      transform: translateY(0);
    }
    .visually-hidden {
      position: absolute !important;
      width: 1px !important;
      height: 1px !important;
      padding: 0 !important;
      margin: -1px !important;
      overflow: hidden !important;
      clip: rect(0, 0, 0, 0) !important;
      white-space: nowrap !important;
      border: 0 !important;
    }
    .page {
      width: min(1180px, calc(100vw - 24px));
      margin: 0 auto;
      padding: 28px 0 34px;
    }
    .eyebrow {
      color: #c10025;
      font-size: 12px;
      font-weight: 800;
      letter-spacing: 1.7px;
      text-transform: uppercase;
    }
    .brand-line {
      display: flex;
      align-items: center;
      gap: 10px;
      margin-bottom: 8px;
    }
    .logo {
      width: 38px;
      height: auto;
      border: 1px solid var(--line);
      background: white;
      object-fit: contain;
    }
    h1 {
      margin: 8px 0 8px;
      color: var(--ink);
      font-family: Georgia, "Times New Roman", serif;
      font-size: clamp(32px, 4vw, 46px);
      line-height: 1.04;
      letter-spacing: 0;
    }
    .intro {
      max-width: 690px;
      margin: 0 0 26px;
      color: var(--muted);
      line-height: 1.5;
    }
    .filters {
      display: flex;
      align-items: center;
      gap: 14px;
      margin-bottom: 18px;
    }
    label {
      color: var(--muted);
      font-size: 12px;
      font-weight: 800;
      letter-spacing: 0.5px;
      text-transform: uppercase;
    }
    select, input {
      min-width: 200px;
      height: 36px;
      border: 1px solid var(--line);
      border-radius: 8px;
      background: white;
      color: #151018;
      padding: 0 12px;
      font-size: 14px;
    }
    select:focus-visible,
    input:focus-visible,
    button:focus-visible,
    a:focus-visible,
    th[tabindex]:focus-visible {
      outline: 3px solid rgba(207, 18, 56, 0.25);
      outline-offset: 2px;
    }
    input {
      min-width: 260px;
    }
    .metrics {
      display: grid;
      grid-template-columns: repeat(4, minmax(0, 1fr));
      gap: 12px;
      margin-bottom: 22px;
    }
    .metric {
      min-height: 122px;
      padding: 16px 18px;
      border: 1px solid var(--line);
      border-radius: 12px;
      background: var(--panel);
      box-shadow: var(--shadow);
    }
    .metric-head {
      display: flex;
      align-items: center;
      gap: 10px;
      margin-bottom: 13px;
      color: #756572;
      font-size: 12px;
      font-weight: 750;
      letter-spacing: 0.2px;
      text-transform: uppercase;
    }
    .icon {
      display: inline-grid;
      place-items: center;
      width: 30px;
      height: 30px;
      border-radius: 8px;
      background: var(--icon-bg);
      color: var(--ink);
      font-weight: 800;
    }
    .metric.pp .icon {
      background: var(--red-soft);
      color: var(--red);
    }
    .metric-value {
      display: block;
      margin-bottom: 5px;
      color: #060817;
      font-family: Georgia, "Times New Roman", serif;
      font-size: 29px;
      font-weight: 800;
      letter-spacing: 0;
    }
    .metric.pp .metric-value { color: var(--red); }
    .metric-note {
      color: var(--muted);
      font-size: 12px;
      line-height: 1.35;
    }
    .panel {
      border: 1px solid var(--line);
      border-radius: 14px;
      background: var(--panel);
      padding: 16px 18px 18px;
      box-shadow: var(--shadow);
    }
    .panel-head {
      display: flex;
      justify-content: space-between;
      gap: 18px;
      align-items: start;
      margin-bottom: 16px;
    }
    h2 {
      margin: 0 0 4px;
      font-family: Georgia, "Times New Roman", serif;
      font-size: 22px;
      line-height: 1.15;
      letter-spacing: 0;
    }
    .panel-subtitle, .axis-label {
      color: var(--muted);
      font-size: 12px;
      line-height: 1.4;
    }
    .chart {
      position: relative;
      display: grid;
      grid-template-columns: 235px 1fr;
      min-height: 420px;
      padding-bottom: 26px;
    }
    .plot {
      position: relative;
      border-left: 1px solid #bbb4b6;
      border-bottom: 2px solid #aaa4a6;
      background:
        linear-gradient(to right, transparent 0, transparent calc(25% - 1px), #f0dfe1 calc(25% - 1px), #f0dfe1 25%, transparent 25%),
        linear-gradient(to right, transparent 0, transparent calc(50% - 1px), #f0dfe1 calc(50% - 1px), #f0dfe1 50%, transparent 50%),
        linear-gradient(to right, transparent 0, transparent calc(75% - 1px), #f0dfe1 calc(75% - 1px), #f0dfe1 75%, transparent 75%),
        linear-gradient(to right, transparent 0, transparent calc(100% - 1px), #f0dfe1 calc(100% - 1px), #f0dfe1 100%, transparent 100%);
    }
    .labels, .bars {
      display: flex;
      flex-direction: column;
      gap: 10px;
    }
    .labels {
      padding-right: 8px;
      text-align: right;
    }
    .label-row, .bar-row {
      height: 17px;
      line-height: 1;
    }
    .label-row {
      display: flex;
      align-items: center;
      justify-content: end;
      color: #071126;
      font-size: 11px;
      text-transform: uppercase;
    }
    .label-row span {
      max-width: 225px;
      overflow-wrap: anywhere;
    }
    .bars {
      position: relative;
      padding: 0 0 0 0;
    }
    .bar-row {
      position: relative;
      width: 100%;
    }
    .bar {
      height: 17px;
      min-width: 2px;
      border-radius: 0 6px 6px 0;
      background: linear-gradient(90deg, var(--red), var(--rose));
    }
    .bar.strong {
      background: var(--red);
    }
    .value {
      position: absolute;
      top: 2px;
      transform: translateX(6px);
      color: #293245;
      font-size: 11px;
      white-space: nowrap;
    }
    .ticks {
      position: absolute;
      right: 0;
      bottom: 0;
      left: 235px;
      display: grid;
      grid-template-columns: repeat(5, 1fr);
      color: var(--muted);
      font-size: 11px;
    }
    .ticks span:nth-child(1) { text-align: left; }
    .ticks span:nth-child(n+2) { text-align: right; }
    .empty {
      padding: 34px;
      color: var(--muted);
      text-align: center;
    }
    .detail {
      margin-top: 18px;
    }
    .detail summary {
      cursor: pointer;
      color: var(--muted);
      font-weight: 700;
    }
    table {
      width: 100%;
      margin-top: 12px;
      border-collapse: collapse;
      font-size: 12px;
    }
    th, td {
      padding: 8px;
      border-bottom: 1px solid var(--line);
      text-align: left;
      vertical-align: top;
    }
    th {
      color: var(--muted);
      font-size: 11px;
      text-transform: uppercase;
    }
    .chart + .ticks {
      pointer-events: none;
    }
    .stack-row {
      display: grid;
      grid-template-columns: 235px 1fr 124px;
      gap: 9px;
      align-items: center;
      margin: 9px 0;
      font-size: 11px;
      text-transform: uppercase;
    }
    .stack-label {
      color: #071126;
      text-align: right;
      overflow-wrap: anywhere;
    }
    .stack-track {
      position: relative;
      display: flex;
      height: 18px;
      overflow: hidden;
      border-radius: 0 6px 6px 0;
      background: #f3e7e9;
    }
    .stack-part {
      position: relative;
      min-width: 0;
      height: 18px;
    }
    .stack-cc { background: var(--ink); }
    .stack-pp { background: var(--red); }
    .stack-inside {
      position: absolute;
      inset: 0 5px;
      display: flex;
      align-items: center;
      justify-content: flex-end;
      overflow: hidden;
      color: white;
      font-size: 10px;
      font-weight: 750;
      white-space: nowrap;
      text-transform: none;
    }
    .stack-inside.hidden {
      display: none;
    }
    .stack-value {
      color: var(--muted);
      font-variant-numeric: tabular-nums;
      text-align: right;
      text-transform: none;
      white-space: nowrap;
    }
    .company-label {
      position: absolute;
      top: 2px;
      z-index: 2;
      font-size: 10px;
      font-weight: 750;
      white-space: nowrap;
      text-transform: none;
    }
    .company-label.inside {
      right: 5px;
      color: white;
    }
    .company-label.outside {
      color: #5d4e54;
    }
    .legend {
      display: flex;
      gap: 18px;
      margin-top: 10px;
      color: var(--muted);
      font-size: 12px;
    }
    .legend span {
      display: inline-flex;
      align-items: center;
      gap: 6px;
    }
    .swatch {
      width: 10px;
      height: 10px;
      border-radius: 3px;
      display: inline-block;
    }
    .swatch-confederale { background: var(--ink); }
    .swatch-pirata { background: var(--red); }
    .toolbar {
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      gap: 10px;
      margin: 22px 0 10px;
    }
    .results-count {
      color: var(--muted);
      font-size: 12px;
    }
    .scope-note {
      color: var(--muted);
      font-size: 12px;
      font-weight: 700;
      letter-spacing: 0.04em;
      text-transform: uppercase;
    }
    .table-card {
      overflow: hidden;
      padding: 0;
    }
    .table-wrap {
      overflow-x: auto;
    }
    .table-wrap table {
      min-width: 900px;
      margin-top: 0;
    }
    .table-wrap th {
      position: sticky;
      top: 0;
      background: var(--ink);
      color: white;
      cursor: pointer;
      user-select: none;
    }
    .table-wrap td {
      background: white;
      font-variant-numeric: tabular-nums;
    }
    .table-wrap tr:nth-child(even) td {
      background: #fbf4f5;
    }
    .num {
      text-align: right;
      white-space: nowrap;
    }
    .muted-cell {
      color: var(--muted);
      font-size: 12px;
    }
    .pirate-high {
      color: var(--red);
      font-weight: 800;
    }
    .pirate-row td {
      font-weight: 800;
    }
    .pirate-row td:first-child {
      color: var(--red);
    }
    .pager {
      display: flex;
      justify-content: space-between;
      align-items: center;
      gap: 12px;
      padding: 10px 14px;
      border-top: 1px solid var(--line);
      color: var(--muted);
      font-size: 12px;
    }
    .pager-actions {
      display: flex;
      gap: 7px;
    }
    button {
      min-height: 30px;
      border: 1px solid var(--line);
      border-radius: 8px;
      background: white;
      color: var(--ink);
      padding: 5px 10px;
      cursor: pointer;
    }
    button:disabled {
      cursor: default;
      opacity: 0.45;
    }
    a.nav-button {
      display: inline-flex;
      align-items: center;
      min-height: 30px;
      border: 1px solid var(--line);
      border-radius: 8px;
      background: white;
      color: var(--ink);
      padding: 5px 10px;
      text-decoration: none;
    }
    .hidden {
      display: none !important;
    }
    .load-status {
      display: flex;
      align-items: center;
      gap: 10px;
      min-height: 58px;
      margin: 20px 0;
      padding: 14px 16px;
      border: 1px solid var(--line);
      border-radius: 12px;
      background: white;
      color: var(--muted);
    }
    .load-status.load-error {
      border-color: #e8aeb9;
      background: #fff8f9;
      color: #9c1631;
    }
    .spinner {
      width: 18px;
      height: 18px;
      flex: 0 0 auto;
      border: 2px solid var(--red-soft);
      border-top-color: var(--red);
      border-radius: 50%;
      animation: spin 0.8s linear infinite;
    }
    .load-error .spinner {
      display: none;
    }
    #retry-load {
      margin-left: auto;
    }
    @keyframes spin {
      to { transform: rotate(360deg); }
    }
    .top-nav {
      display: flex;
      flex-wrap: wrap;
      gap: 8px;
      margin: 22px 0 18px;
    }
    .nav-button.active {
      border-color: var(--red);
      background: var(--red);
      color: white;
    }
    .close-button {
      margin-left: auto;
      border-color: var(--red-soft);
      color: var(--red);
    }
    .close-button:hover {
      border-color: var(--red);
    }
    .logout-form {
      margin: 0 0 0 auto;
    }
    .shutdown-message {
      margin-top: 18px;
      padding: 14px 16px;
      border: 1px solid var(--line);
      border-radius: 10px;
      background: white;
      color: var(--muted);
    }
    .signers-btn {
      min-height: 26px;
      padding: 4px 8px;
      font-size: 12px;
      white-space: nowrap;
    }
    .modal-backdrop {
      position: fixed;
      inset: 0;
      z-index: 20;
      display: none;
      align-items: center;
      justify-content: center;
      padding: 18px;
      background: rgba(7, 29, 66, 0.26);
    }
    .modal-backdrop.open {
      display: flex;
    }
    .modal {
      width: min(520px, 100%);
      max-height: min(72vh, 560px);
      overflow: auto;
      border: 1px solid var(--line);
      border-radius: 12px;
      background: white;
      box-shadow: 0 18px 60px rgba(7, 29, 66, 0.20);
    }
    .modal-head {
      display: flex;
      align-items: start;
      justify-content: space-between;
      gap: 12px;
      padding: 14px 16px;
      border-bottom: 1px solid var(--line);
    }
    .modal-title {
      margin: 0;
      font-family: Georgia, "Times New Roman", serif;
      font-size: 20px;
      color: var(--ink);
    }
    .modal-body {
      padding: 16px;
    }
    .firmatari-block + .firmatari-block {
      margin-top: 14px;
    }
    .firmatari-label {
      margin-bottom: 5px;
      color: var(--muted);
      font-size: 11px;
      font-weight: 800;
      letter-spacing: 0.04em;
      text-transform: uppercase;
    }
    .firmatari-text {
      color: var(--ink);
      line-height: 1.45;
      white-space: pre-wrap;
    }
    @media (prefers-reduced-motion: reduce) {
      .spinner { animation: none; }
    }
    @media (max-width: 900px) {
      .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
      .chart { grid-template-columns: 145px 1fr; }
      .ticks { left: 145px; }
      .stack-row { grid-template-columns: 145px 1fr 106px; }
      .label-row { font-size: 10px; }
    }
    @media (max-width: 640px) {
      .page { width: min(100vw - 18px, 1180px); padding-top: 18px; }
      .logo { width: 34px; }
      .filters { align-items: stretch; flex-direction: column; gap: 7px; }
      select { width: 100%; }
      input { width: 100%; min-width: 0; }
      .metrics { grid-template-columns: 1fr; }
      .panel-head { flex-direction: column; }
      .chart { grid-template-columns: 116px 1fr; }
      .ticks { left: 116px; }
      .stack-row { grid-template-columns: 116px 1fr; }
      .stack-value { grid-column: 2; text-align: left; font-size: 10px; }
      .value { font-size: 10px; }
      .logout-form { width: 100%; margin-left: 0; }
      .logout-form button { width: 100%; }
    }
