      :root {
        --bg: #dfe3e8;
        --ink: #1c2735;
        --ink-soft: #364255;
        --blue: #0e56a6;
        --red: #ef1e14;
        --orange: #f39b16;
        --navy: #1f2d42;
        --slate: #3c4655;
        --paper: #edf1f5;
        --panel: #ffffff;
        --muted: #5a6574;
        --edge: #b3bbc7;
        --shadow: 0 3px 0 rgba(122, 133, 149, 0.45), 0 10px 18px rgba(20, 30, 44, 0.12);
      }
      * { box-sizing: border-box; }
      body {
        margin: 0;
        font-family: "Segoe UI", "Inter", "Helvetica Neue", Arial, sans-serif;
        background:
          linear-gradient(180deg, rgba(14, 86, 166, 0.07), rgba(14, 86, 166, 0) 220px),
          linear-gradient(135deg, #e8ebf0 0%, #d9dee6 100%);
        color: var(--ink);
      }
      .shell {
        min-height: 100vh;
        display: grid;
        grid-template-rows: auto auto 1fr auto;
        gap: 16px;
        padding: 24px;
        width: 100%;
        max-width: 100%;
      }
      header {
        display: block;
        border: 2px solid var(--ink-soft);
        background: linear-gradient(90deg, var(--blue), #1a67bf);
        color: #fff;
        border-radius: 14px;
        padding: 14px 16px 10px 16px;
        box-shadow: var(--shadow);
      }
      .header-main {
        display: grid;
        grid-template-columns: 1fr;
        gap: 8px;
      }
      header .title {
        font-size: 34px;
        letter-spacing: 0.8px;
        font-weight: 900;
        font-family: "Impact", "Arial Black", "Segoe UI", sans-serif;
        color: #ffd84d;
        text-shadow:
          -1px -1px 0 #4b2e00,
          1px -1px 0 #4b2e00,
          -1px 1px 0 #4b2e00,
          1px 1px 0 #4b2e00,
          0 3px 0 rgba(0, 0, 0, 0.28);
      }
      header .subtitle { color: #deebfa; font-size: 14px; }
      .header-tabs {
        display: flex;
        gap: 8px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.35);
        padding-top: 2px;
      }
      .tab {
        border: 0;
        background: rgba(8, 37, 77, 0.36);
        color: #dfe9f7;
        border-radius: 10px 10px 0 0;
        padding: 8px 12px;
        cursor: pointer;
        font-weight: 700;
      }
      .tab:hover {
        background: rgba(8, 37, 77, 0.52);
      }
      .tab.is-active {
        background: #f2f5fa;
        color: var(--ink);
        border: 1px solid #c3ccda;
        border-bottom-color: #f2f5fa;
        margin-bottom: -1px;
      }
      .top-panel, .content-panel {
        background: linear-gradient(180deg, var(--panel), #f1f3f7);
        border: 2px solid var(--edge);
        padding: 18px;
        border-radius: 14px;
        box-shadow: var(--shadow);
        min-width: 0;
      }
      .content-panel { min-height: 45vh; display: grid; grid-template-rows: auto auto 1fr; gap: 8px; }
      .search input {
        width: min(980px, 100%);
        padding: 12px 14px;
        border: 2px solid #b8c0ca;
        border-radius: 10px;
        font-size: 16px;
        background: #fff;
        color: var(--ink);
      }
      .search-main-input {
        border-color: #f39b16 !important;
        background: linear-gradient(180deg, #fffaf1, #fff);
        box-shadow: 0 0 0 2px rgba(243, 155, 22, 0.12);
      }
      .primary-search-row .search-main-input {
        flex: 2 1 480px;
        width: auto;
        max-width: none;
      }
      .primary-search-row input[type="date"] {
        flex: 0 1 180px;
        min-width: 160px;
      }
      .primary-search-row select {
        flex: 1 1 220px;
        min-width: 180px;
      }
      .search-main-input:focus {
        border-color: #d87c00 !important;
        box-shadow: 0 0 0 3px rgba(216, 124, 0, 0.2) !important;
      }
      .search { width: 100%; }
      .search input:focus, .filters select:focus, .filters input:focus, .inline-filter:focus {
        outline: 0;
        border-color: var(--blue);
        box-shadow: 0 0 0 3px rgba(14, 86, 166, 0.18);
      }
      .ingest { margin-bottom: 12px; }
      .ingest .label { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
      .ingest input {
        flex: 1 1 560px;
        min-width: 320px;
        max-width: 980px;
      }
      .ingest .row {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: 10px;
      }
      .ingest button {
        border: 0;
        background: linear-gradient(180deg, var(--orange), #d87c00);
        color: #fff;
        padding: 10px 12px;
        border-radius: 10px;
        cursor: pointer;
        font-weight: 700;
        box-shadow: 0 5px 0 #9f6c1d;
      }
      .ingest button:nth-child(3) {
        background: linear-gradient(180deg, #6a7380, #4d5563);
        box-shadow: 0 5px 0 #3a4150;
      }
      .ingest button:disabled {
        opacity: 0.55;
        cursor: not-allowed;
        box-shadow: none;
      }
      .filters { margin-bottom: 12px; }
      .filters .label { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
      .filters select, .filters input {
        flex: 1 1 260px;
        min-width: 0;
        max-width: 420px;
        padding: 10px;
        border: 2px solid #b8c0ca;
        border-radius: 10px;
        background: #fff;
      }
      .filters .row > * {
        min-width: 0;
      }
      .filters button {
        border: 1px solid #aeb6c0;
        background: #f8f9fb;
        color: var(--ink-soft);
        padding: 8px 10px;
        border-radius: 999px;
        cursor: pointer;
        font-size: 12px;
        font-weight: 600;
      }
      .filters .chip {
        background: #ebedf2;
      }
      .status { margin-top: 6px; font-size: 12px; color: var(--muted); }
      .error { margin-top: 6px; font-size: 12px; color: #b1120b; font-weight: 700; }
      .measure { margin: 8px 0; padding: 6px 8px; border: 1px dashed var(--ink); border-radius: 6px; }
      .loading { margin-top: 8px; color: var(--muted); }
      .results { margin-top: 12px; display: grid; gap: 10px; }
      .results-scroll {
        overflow: visible;
        max-height: none;
        padding-right: 0;
      }
      .result {
        text-align: left;
        background: linear-gradient(180deg, #ffffff, #f4f5f8);
        border: 2px solid #b7bfca;
        border-radius: 12px;
        padding: 10px 12px;
        margin-bottom: 8px;
        box-shadow: 0 4px 10px rgba(27, 37, 51, 0.11);
        transition: transform 0.14s ease, box-shadow 0.14s ease;
        min-width: 0;
      }
      .result-head {
        width: 100%;
        text-align: left;
        border: 0;
        background: transparent;
        cursor: pointer;
        padding: 2px;
      }
      .result:hover {
        transform: translateY(-2px);
        box-shadow: 0 8px 16px rgba(27, 37, 51, 0.16);
      }
      .result-details {
        margin-top: 10px;
        border-top: 1px dashed #8c95a3;
        padding-top: 10px;
        min-width: 0;
      }
      .detail-layout {
        display: grid;
        grid-template-columns: minmax(0, 1fr) 380px;
        gap: 12px;
        align-items: start;
      }
      .detail-layout.is-collapsed {
        grid-template-columns: minmax(0, 1fr) 44px;
      }
      .detail-main, .detail-side { min-width: 0; }
      .side-panel {
        border: 1px solid #c5cedb;
        border-radius: 10px;
        background: #f7f9fd;
        padding: 8px;
      }
      .detail-side {
        transition: transform 0.16s ease;
      }
      .detail-side.is-collapsed {
        transform: translateX(4px);
        display: flex;
        align-items: flex-start;
      }
      .insights-collapsed-toggle {
        min-width: 36px;
        padding: 6px 8px;
        border-radius: 8px;
      }
      .side-panel-head {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 8px;
        margin-bottom: 8px;
      }
      .side-panel-title {
        font-size: 12px;
        font-weight: 800;
        color: #334b68;
        text-transform: uppercase;
        letter-spacing: 0.03em;
      }
      .row { display: flex; gap: 10px; align-items: center; }
      .wrap { flex-wrap: wrap; }
      .space-between { justify-content: space-between; }
      .code { font-weight: 600; }
      .badge {
        background: var(--blue);
        color: #fff;
        padding: 3px 10px;
        border-radius: 999px;
        font-size: 12px;
        border: 1px solid rgba(16, 36, 64, 0.25);
      }
      .title { margin-top: 6px; font-size: 14px; }
      .link-chip {
        border: 1px solid #9fa8b4;
        border-radius: 999px;
        background: #edf1f6;
        color: var(--ink);
        cursor: pointer;
        padding: 2px 8px;
        font-weight: 700;
      }
      .badge.soft {
        background: #e5eaf1;
        color: #2b3340;
        border: 1px solid #aeb6c1;
      }
      .badge.status {
        color: #111;
        border: 1px solid #a7afb9;
        background: #f0f0f0;
      }
      .badge.status.s-active { background: #d8efe1; }
      .badge.status.s-future { background: #fde7bf; }
      .badge.status.s-expired { background: #f7d9d8; }
      .badge.group {
        color: #111;
        border: 1px solid #a7afb9;
        background: #e8e8e8;
      }
      .badge.group.g-base { background: #d3e7ff; }
      .badge.group.g-pref { background: #dee6ff; }
      .badge.group.g-vat { background: #ffe19f; }
      .badge.group.g-special { background: #f6d3dc; }
      .badge.group.g-other { background: #dde1e8; }
      .inline-filter {
        min-width: 0;
        width: min(420px, 100%);
        flex: 0 1 420px;
        padding: 10px 12px;
        border: 2px solid #b8c0ca;
        border-radius: 10px;
      }
      .nearby-trail {
        margin-top: 8px;
        border: 1px solid #bfd0e6;
        border-radius: 10px;
        padding: 8px;
        background: #f4f9ff;
      }
      .nearby-trail-title {
        font-size: 12px;
        color: #2f5f8f;
        font-weight: 700;
        margin-bottom: 6px;
      }
      .results-section {
        border: 1px dashed #b8c3d3;
        border-radius: 10px;
        padding: 8px;
        background: #f8fafd;
      }
      .results-section-title {
        font-size: 12px;
        color: #44556c;
        font-weight: 700;
        margin-bottom: 6px;
      }
      .debug-panel {
        margin-top: 12px;
        border: 2px dashed #c9a35c;
        border-radius: 12px;
        background: linear-gradient(180deg, #fff9ef, #fff5e6);
        padding: 10px;
      }
      .debug-panel input {
        flex: 1 1 560px;
        min-width: 280px;
      }
      .debug-panel button {
        border: 0;
        background: linear-gradient(180deg, var(--orange), #d87c00);
        color: #fff;
        padding: 10px 12px;
        border-radius: 10px;
        cursor: pointer;
        font-weight: 700;
        box-shadow: 0 5px 0 #9f6c1d;
      }
      .debug-panel button:nth-child(3) {
        background: linear-gradient(180deg, #6a7380, #4d5563);
        box-shadow: 0 5px 0 #3a4150;
      }
      .debug-panel button:disabled {
        opacity: 0.55;
        cursor: not-allowed;
        box-shadow: none;
      }
      .legend {
        border: 2px dashed #9ca5b2;
        border-radius: 12px;
        padding: 4px 8px;
        background: #f5f7fb;
        font-size: 12px;
        line-height: 1.25;
      }
      .legend > summary { font-weight: 700; font-size: 12px; cursor: pointer; }
      .legend-grid {
        display: grid;
        grid-template-columns: repeat(2, minmax(220px, 1fr));
        gap: 8px;
        margin-top: 6px;
      }
      .legend-title {
        font-size: 12px;
        color: var(--muted);
        margin-bottom: 4px;
      }
      .meta { font-size: 12px; color: var(--muted); }
      .muted { color: var(--muted); }
      .kv-grid {
        display: grid;
        grid-template-columns: minmax(120px, 170px) minmax(0, 1fr);
        gap: 6px 10px;
      }
      .stack { display: grid; gap: 8px; }
      details.subrecord, details.measure-details {
        border: 1px solid #c3c9d1;
        border-radius: 10px;
        padding: 6px 8px;
        background: #fff;
        box-shadow: none;
      }
      .measure-details {
        border: 1px solid #c3c9d1;
        border-radius: 10px;
        padding: 6px 8px;
        background: #fff;
      }
      .measure-group-section {
        border: 1px dashed #bcc5d2;
        border-radius: 10px;
        padding: 8px;
        background: #f6f8fc;
      }
      .measure-group-head {
        display: flex;
        align-items: center;
        gap: 8px;
        margin-bottom: 8px;
      }
      .measure-start-hint {
        font-size: 11px;
        font-weight: 700;
        color: #295f2e;
        background: #dff3df;
        border: 1px solid #a4cea6;
        border-radius: 999px;
        padding: 2px 8px;
      }
      .measure-summary {
        margin: 8px 0 10px 0;
        border: 1px solid #c5d4e7;
        border-radius: 10px;
        background: linear-gradient(180deg, #f8fbff, #edf4fc);
        padding: 8px 10px;
      }
      .measure-summary-title {
        font-size: 11px;
        text-transform: uppercase;
        letter-spacing: 0.03em;
        color: #30517a;
        font-weight: 800;
        margin-bottom: 4px;
      }
      .measure-summary-line {
        font-size: 13px;
        color: #213248;
        margin: 2px 0;
      }
      .best-summary {
        margin: 8px 0 10px 0;
        border: 1px solid #b9d0b6;
        border-radius: 10px;
        background: linear-gradient(180deg, #f7fff5, #ebf8e8);
        padding: 8px 10px;
      }
      .best-summary-title {
        font-size: 11px;
        text-transform: uppercase;
        letter-spacing: 0.03em;
        color: #2f6a33;
        font-weight: 800;
        margin-bottom: 4px;
      }
      .best-summary-line {
        font-size: 13px;
        color: #213d26;
        margin: 2px 0;
      }
      .hidden-reason {
        border: 1px solid #c7d8c4;
        background: #f8fff7;
        border-radius: 8px;
        padding: 8px;
      }
      .hidden-reason-head {
        display: flex;
        gap: 6px;
        flex-wrap: wrap;
        margin-bottom: 4px;
        align-items: center;
      }
      .nearby-card {
        border: 1px solid #c9d4e4;
        border-radius: 10px;
        background: #f8fbff;
        padding: 8px;
      }
      .nearby-card-head {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 8px;
        margin-bottom: 4px;
      }
      .nearby-card-title {
        font-size: 12px;
        color: #2c4058;
        margin-bottom: 6px;
      }
      .measure-head {
        width: 100%;
        border: 0;
        background: transparent;
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: 8px;
        cursor: pointer;
        text-align: left;
        padding: 2px 0;
      }
      .arrow { font-size: 14px; line-height: 1; }
      .records-flex {
        display: grid;
        gap: 8px;
      }
      .record-row {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
        gap: 8px;
        border: 1px solid #c8ced8;
        border-radius: 10px;
        padding: 8px;
        background: #f9fafc;
      }
      .record-row-badge {
        grid-column: 1 / -1;
        font-size: 11px;
        font-weight: 700;
        color: #5a6574;
      }
      .record-cell {
        min-width: 0;
        border: 1px solid #d8dde5;
        border-radius: 8px;
        padding: 6px 8px;
        background: #fff;
      }
      .record-cell-k {
        font-size: 11px;
        color: var(--muted);
        margin-bottom: 4px;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.02em;
      }
      .record-cell-v {
        min-width: 0;
        overflow-wrap: anywhere;
        word-break: break-word;
      }
      .records-table {
        width: 100%;
        border-collapse: collapse;
        border: 1px solid #c3c9d1;
        border-radius: 8px;
        overflow: hidden;
        background: #fff;
      }
      .records-table th,
      .records-table td {
        border-bottom: 1px solid #e0e4ea;
        border-right: 1px solid #e0e4ea;
        padding: 6px 8px;
        vertical-align: top;
        overflow-wrap: anywhere;
      }
      .records-table th:last-child,
      .records-table td:last-child { border-right: 0; }
      .records-table tr:last-child td { border-bottom: 0; }
      .records-table th {
        background: #f3f5f9;
        text-align: left;
        font-weight: 700;
      }
      details > summary { cursor: pointer; }
      .detail h2 { margin: 0 0 10px 0; }
      .kv { display: grid; grid-template-columns: 120px 1fr; margin: 6px 0; }
      .k { color: var(--muted); }
      .empty { color: var(--muted); }
      footer {
        color: #4f5967;
        font-size: 12px;
        font-weight: 600;
        border-left: 4px solid var(--red);
        padding-left: 10px;
      }
      @media (max-width: 900px) {
        .ingest input { min-width: 0; max-width: 100%; flex-basis: 100%; }
        .filters select, .filters input { max-width: 100%; }
        .inline-filter { min-width: 0; width: 100%; }
        .kv-grid { grid-template-columns: 1fr; }
        .legend-grid { grid-template-columns: 1fr; }
        .record-row { grid-template-columns: 1fr; }
        .detail-layout { grid-template-columns: 1fr; }
      }
