/* ── Theme Variables ── */
      :root {
        --bg: #f2f6fb;
        --surface: rgba(255, 255, 255, 0.86);
        --ink: #13223a;
        --muted: #4c5f7a;
        --line: #d5dfef;
        --brand: #0a7a8a;
        --brand-2: #1a9db0;
        --brand-glow: rgba(10, 122, 138, 0.25);
        --ok-bg: #e5f8eb;
        --ok-line: #bce7cc;
        --ok-accent: #22a855;
        --no-bg: #ffefeb;
        --no-line: #ffd2c8;
        --no-accent: #e05538;
        --neutral-accent: #8896a7;
        --shadow: 0 24px 50px rgba(23, 39, 64, 0.1);
        --shadow-hover: 0 28px 60px rgba(23, 39, 64, 0.16);
        --input-bg: #fff;
        --input-border: #c7d5e8;
        --subtle-bg: #e9f0fa;
        --subtle-color: #2c4560;
        --subtle-hover: #dce6f4;
        --meta-color: #35506a;
        --hero-bg: linear-gradient(140deg, #0f2238, #11485f);
        --summary-bg: linear-gradient(160deg, #dff3f6, #e7eefb);
        --body-gradient-1: #d7f4fb;
        --body-gradient-2: #e4e9ff;
        --badge-bg: rgba(0,0,0,0.06);
        --footer-color: #5a6c84;
        --dim-pass-bg: #d4f5de;
        --dim-pass-color: #1a7a3a;
        --dim-fail-bg: #fddcd5;
        --dim-fail-color: #b83a1f;
        --dim-neutral-bg: #e8ecf2;
        --dim-neutral-color: #5a6c84;
        --metric-card-bg: rgba(255,255,255,0.7);
        --source-link-bg: rgba(255,255,255,0.6);
        --conf-bar-bg: rgba(0,0,0,0.08);
      }

      [data-theme="dark"] {
        --bg: #0d1117;
        --surface: rgba(22, 27, 34, 0.92);
        --ink: #e6edf3;
        --muted: #8b949e;
        --line: #30363d;
        --brand: #39c5cf;
        --brand-2: #58d5e3;
        --brand-glow: rgba(57, 197, 207, 0.25);
        --ok-bg: #0d2818;
        --ok-line: #1a4d2e;
        --ok-accent: #3fb950;
        --no-bg: #2d1117;
        --no-line: #5c2d2d;
        --no-accent: #f85149;
        --neutral-accent: #6e7681;
        --shadow: 0 24px 50px rgba(0, 0, 0, 0.4);
        --shadow-hover: 0 28px 60px rgba(0, 0, 0, 0.5);
        --input-bg: #161b22;
        --input-border: #30363d;
        --subtle-bg: #21262d;
        --subtle-color: #c9d1d9;
        --subtle-hover: #30363d;
        --meta-color: #8b949e;
        --hero-bg: linear-gradient(140deg, #010409, #0d1117);
        --summary-bg: linear-gradient(160deg, #0d1117, #161b22);
        --body-gradient-1: transparent;
        --body-gradient-2: transparent;
        --badge-bg: rgba(255,255,255,0.08);
        --footer-color: #8b949e;
        --dim-pass-bg: #0d2818;
        --dim-pass-color: #3fb950;
        --dim-fail-bg: #2d1117;
        --dim-fail-color: #f85149;
        --dim-neutral-bg: #21262d;
        --dim-neutral-color: #8b949e;
        --metric-card-bg: rgba(255,255,255,0.04);
        --source-link-bg: rgba(255,255,255,0.05);
        --conf-bar-bg: rgba(255,255,255,0.1);
      }

      * { box-sizing: border-box; }
      html { scroll-behavior: smooth; }

      @keyframes fadeInUp {
        from { opacity: 0; transform: translateY(18px); }
        to { opacity: 1; transform: translateY(0); }
      }
      @keyframes shimmer {
        0% { background-position: -200% 0; }
        100% { background-position: 200% 0; }
      }
      @keyframes spin {
        to { transform: rotate(360deg); }
      }
      @keyframes fadeIn {
        from { opacity: 0; }
        to { opacity: 1; }
      }

      body {
        margin: 0;
        font-family: "Manrope", sans-serif;
        color: var(--ink);
        background:
          radial-gradient(1200px 800px at -10% -10%, var(--body-gradient-1) 0%, transparent 50%),
          radial-gradient(900px 700px at 105% 0%, var(--body-gradient-2) 0%, transparent 46%),
          var(--bg);
      }

      .wrap {
        max-width: 1240px;
        margin: 0 auto;
        padding: 28px 16px 40px;
        animation: fadeInUp 0.6s ease-out both;
      }

      /* ── Hero ── */
      .hero {
        background: var(--hero-bg);
        color: #eff9ff;
        border-radius: 20px;
        padding: 28px 26px;
        box-shadow: var(--shadow);
        position: relative;
        overflow: hidden;
        animation: fadeInUp 0.5s ease-out both;
      }

      .hero::before {
        content: "";
        position: absolute;
        inset: 0;
        background: linear-gradient(110deg, transparent 30%, rgba(119, 217, 224, 0.08) 45%, rgba(255, 255, 255, 0.1) 50%, rgba(119, 217, 224, 0.08) 55%, transparent 70%);
        background-size: 200% 100%;
        animation: shimmer 6s ease-in-out infinite;
        pointer-events: none;
      }

      .hero::after {
        content: "";
        position: absolute;
        inset: auto -20% -60% auto;
        width: 380px;
        height: 380px;
        background: radial-gradient(circle, rgba(119, 217, 224, 0.25), transparent 62%);
      }

      .hero-title-row {
        display: flex;
        align-items: center;
        gap: 14px;
        position: relative;
        z-index: 1;
      }

      .hero-icon {
        width: 46px;
        height: 46px;
        border-radius: 14px;
        background: linear-gradient(135deg, #1a9db0, #77d9e0);
        display: flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
        box-shadow: 0 4px 16px rgba(26, 157, 176, 0.35);
      }
      .hero-icon::after {
        content: "";
        width: 24px;
        height: 24px;
        border-radius: 50%;
        border: 2.5px solid #fff;
        background: radial-gradient(circle at 35% 35%, rgba(255,255,255,0.4), transparent 60%);
        box-shadow: inset 0 0 0 1px rgba(255,255,255,0.15);
      }

      h1 {
        margin: 0;
        font-family: "Space Grotesk", sans-serif;
        letter-spacing: -0.02em;
        font-size: clamp(1.8rem, 4vw, 3rem);
        position: relative;
        z-index: 1;
      }

      .sub {
        margin-top: 10px;
        max-width: 900px;
        opacity: 0.95;
        position: relative;
        z-index: 1;
      }

      .pill-row {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        margin-top: 14px;
        position: relative;
        z-index: 1;
      }

      .admin-hidden { display: none; }

      .pill {
        border: 1px solid rgba(207, 231, 255, 0.45);
        background: rgba(255, 255, 255, 0.1);
        border-radius: 999px;
        padding: 6px 14px;
        font-size: 0.82rem;
        backdrop-filter: blur(4px);
        box-shadow: 0 0 12px rgba(119, 217, 224, 0.1);
        transition: box-shadow 0.3s, background 0.3s;
      }
      .pill:hover {
        background: rgba(255, 255, 255, 0.16);
        box-shadow: 0 0 18px rgba(119, 217, 224, 0.2);
      }

      /* ── Theme Toggle ── */
      .theme-toggle {
        position: relative;
        z-index: 2;
        background: rgba(255,255,255,0.12);
        border: 1px solid rgba(255,255,255,0.2);
        border-radius: 10px;
        padding: 6px 12px;
        color: #eff9ff;
        cursor: pointer;
        font-size: 1.1rem;
        line-height: 1;
        transition: background 0.2s;
      }
      .theme-toggle:hover {
        background: rgba(255,255,255,0.2);
      }
      .theme-toggle:active { transform: none; }

      /* ── Grid & Cards ── */
      .grid {
        margin-top: 16px;
        display: grid;
        grid-template-columns: 1.35fr 1fr;
        gap: 14px;
      }
      @media (max-width: 980px) {
        .grid { grid-template-columns: 1fr; }
      }

      .card {
        border-radius: 18px;
        border: 1px solid var(--line);
        background: var(--surface);
        backdrop-filter: blur(7px);
        box-shadow: var(--shadow);
        padding: 20px;
        animation: fadeInUp 0.5s ease-out both;
        animation-delay: 0.1s;
        transition: box-shadow 0.3s;
      }
      .card h2 {
        margin: 0;
        font-family: "Space Grotesk", sans-serif;
        font-size: 1.15rem;
      }
      .hint {
        margin-top: 7px;
        color: var(--muted);
        font-size: 0.82rem;
      }

      /* ── Form Section Dividers ── */
      .form-section-label {
        grid-column: 1 / -1;
        font-size: 0.7rem;
        text-transform: uppercase;
        letter-spacing: 0.08em;
        color: var(--muted);
        font-weight: 700;
        padding-top: 10px;
        margin-bottom: -4px;
        border-top: 1px solid var(--line);
      }
      .form-section-label:first-child {
        border-top: none;
        padding-top: 0;
      }

      .form-grid {
        margin-top: 12px;
        display: grid;
        gap: 10px;
        grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
      }

      label {
        display: block;
        margin-bottom: 5px;
        font-size: 0.8rem;
        font-weight: 600;
        color: var(--muted);
        letter-spacing: 0.01em;
      }
      label .label-icon { margin-right: 4px; }

      select, input, textarea {
        width: 100%;
        min-height: 42px;
        border: 1.5px solid var(--input-border);
        border-radius: 11px;
        padding: 8px 10px;
        background: var(--input-bg);
        color: var(--ink);
        font: inherit;
        font-size: 0.92rem;
        transition: border-color 0.2s, box-shadow 0.2s;
      }
      select:focus, input:focus, textarea:focus {
        outline: none;
        border-color: var(--brand);
        box-shadow: 0 0 0 3px var(--brand-glow);
      }
      select[multiple] { min-height: 120px; }
      textarea { min-height: 130px; resize: vertical; }

      .actions {
        margin-top: 14px;
        display: flex;
        flex-wrap: wrap;
        gap: 9px;
      }

      button {
        border: 0;
        border-radius: 12px;
        padding: 12px 20px;
        font: inherit;
        font-weight: 800;
        cursor: pointer;
        transition: transform 0.12s, box-shadow 0.2s, background 0.2s, opacity 0.2s;
      }
      button:active { transform: scale(0.97); }

      .primary {
        color: #fff;
        background: linear-gradient(120deg, var(--brand), var(--brand-2));
        box-shadow: 0 4px 14px var(--brand-glow);
        display: inline-flex;
        align-items: center;
        gap: 7px;
      }
      .primary:hover {
        box-shadow: 0 6px 22px var(--brand-glow);
        filter: brightness(1.06);
      }
      .primary .btn-icon {
        display: inline-block;
        transition: transform 0.2s;
      }
      .primary:hover .btn-icon { transform: translateX(2px); }
      .primary.loading { pointer-events: none; opacity: 0.85; }
      .primary.loading .btn-icon { animation: spin 0.7s linear infinite; }

      .subtle {
        color: var(--subtle-color);
        background: var(--subtle-bg);
      }
      .subtle:hover { background: var(--subtle-hover); }

      .status {
        margin-top: 8px;
        font-size: 0.9rem;
        color: var(--meta-color);
      }

      /* ── Results ── */
      .results {
        margin-top: 16px;
        display: grid;
        gap: 12px;
      }

      .summary { background: var(--summary-bg); }
      .summary-metrics {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 12px;
        margin-top: 14px;
      }
      @media (max-width: 600px) {
        .summary-metrics { grid-template-columns: 1fr; }
      }
      .metric-card {
        background: var(--metric-card-bg);
        border-radius: 14px;
        padding: 16px;
        text-align: center;
        border: 1px solid var(--line);
        transition: transform 0.2s, box-shadow 0.2s;
      }
      .metric-card:hover {
        transform: translateY(-2px);
        box-shadow: 0 8px 24px rgba(23,39,64,0.08);
      }
      .metric-icon { font-size: 1.5rem; margin-bottom: 4px; }
      .metric-number {
        font-family: "Space Grotesk", sans-serif;
        font-size: 2rem;
        font-weight: 700;
        line-height: 1.1;
      }
      .metric-number.brand { color: var(--brand); }
      .metric-number.green { color: var(--ok-accent); }
      .metric-number.red { color: var(--no-accent); }
      .metric-label {
        font-size: 0.78rem;
        color: var(--muted);
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.04em;
        margin-top: 2px;
      }

      /* Tab bar */
      .tabs {
        display: flex;
        gap: 4px;
        margin-bottom: 14px;
        flex-wrap: wrap;
        position: relative;
        border-bottom: 2px solid var(--line);
        padding-bottom: 0;
      }
      .tab-btn {
        border: none;
        background: transparent;
        color: var(--muted);
        border-radius: 10px 10px 0 0;
        padding: 10px 18px;
        font-weight: 700;
        font-size: 0.9rem;
        position: relative;
        transition: color 0.2s, background 0.2s;
      }
      .tab-btn:hover {
        color: var(--ink);
        background: rgba(10, 122, 138, 0.05);
      }
      .tab-btn::after {
        content: "";
        position: absolute;
        bottom: -2px;
        left: 0;
        right: 0;
        height: 2.5px;
        border-radius: 2px 2px 0 0;
        background: transparent;
        transition: background 0.25s;
      }
      .tab-btn.active { color: var(--brand); background: transparent; }
      .tab-btn.active::after {
        background: linear-gradient(90deg, var(--brand), var(--brand-2));
      }
      .tab-panel { animation: fadeIn 0.25s ease-out; }
      .tab-panel.hidden { display: none; }

      /* ── Regulation Cards ── */
      .reg-list { display: grid; gap: 10px; margin-top: 10px; }
      .reg {
        border-radius: 14px;
        border: 1px solid transparent;
        padding: 16px 16px 14px 20px;
        position: relative;
        transition: transform 0.2s, box-shadow 0.2s;
        cursor: default;
      }
      .reg:hover {
        transform: translateY(-2px);
        box-shadow: 0 8px 28px rgba(23,39,64,0.08);
      }
      .reg::before {
        content: "";
        position: absolute;
        left: 0;
        top: 10px;
        bottom: 10px;
        width: 4px;
        border-radius: 0 4px 4px 0;
      }
      .reg.ok { background: var(--ok-bg); border-color: var(--ok-line); }
      .reg.ok::before { background: var(--ok-accent); }
      .reg.no { background: var(--no-bg); border-color: var(--no-line); }
      .reg.no::before { background: var(--no-accent); }

      .reg-header {
        display: flex;
        align-items: flex-start;
        justify-content: space-between;
        gap: 10px;
      }
      .name { font-weight: 800; font-size: 1.02rem; }
      .authority-badge {
        display: inline-block;
        background: var(--badge-bg);
        border-radius: 6px;
        padding: 2px 8px;
        font-size: 0.75rem;
        font-weight: 600;
        color: var(--muted);
        white-space: nowrap;
        flex-shrink: 0;
      }
      .meta {
        margin-top: 5px;
        color: var(--meta-color);
        font-size: 0.84rem;
      }
      .reason { margin-top: 6px; font-size: 0.92rem; line-height: 1.45; }

      .confidence-row {
        display: flex;
        align-items: center;
        gap: 8px;
        margin-top: 8px;
        font-size: 0.82rem;
        color: var(--muted);
        font-weight: 600;
      }
      .confidence-bar {
        width: 80px;
        height: 6px;
        border-radius: 3px;
        background: var(--conf-bar-bg);
        overflow: hidden;
      }
      .confidence-fill { height: 100%; border-radius: 3px; transition: width 0.4s ease-out; }
      .confidence-fill.green { background: var(--ok-accent); }
      .confidence-fill.red { background: var(--no-accent); }

      .dim-checks { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
      .dim-pill {
        display: inline-block;
        font-size: 0.72rem;
        font-weight: 600;
        padding: 2px 8px;
        border-radius: 6px;
      }
      .dim-pill.pass { background: var(--dim-pass-bg); color: var(--dim-pass-color); }
      .dim-pill.fail { background: var(--dim-fail-bg); color: var(--dim-fail-color); }
      .dim-pill.neutral { background: var(--dim-neutral-bg); color: var(--dim-neutral-color); }

      .reg-details {
        display: none;
        margin-top: 10px;
        padding-top: 10px;
        border-top: 1px solid rgba(0,0,0,0.06);
        animation: fadeIn 0.2s ease-out;
      }
      .reg-details.open { display: block; }
      .reg-toggle {
        font-size: 0.78rem;
        color: var(--brand);
        font-weight: 700;
        cursor: pointer;
        background: none;
        border: none;
        padding: 4px 0;
        margin-top: 6px;
        transition: opacity 0.2s;
      }
      .reg-toggle:hover { opacity: 0.75; }
      .reg-toggle:active { transform: none; }

      .source-link {
        display: inline-flex;
        align-items: center;
        gap: 4px;
        margin-top: 8px;
        font-size: 0.8rem;
        font-weight: 600;
        color: var(--brand);
        text-decoration: none;
        padding: 4px 10px;
        border-radius: 8px;
        border: 1px solid var(--line);
        background: var(--source-link-bg);
        transition: background 0.2s, box-shadow 0.2s;
      }
      .source-link:hover {
        background: var(--input-bg);
        box-shadow: 0 2px 8px rgba(0,0,0,0.06);
      }

      .profile-bar {
        display: flex;
        gap: 6px;
        align-items: center;
        margin-bottom: 12px;
        flex-wrap: wrap;
      }
      .profile-bar select { flex: 1; min-width: 140px; }

      .export-bar {
        display: flex;
        gap: 8px;
        margin-top: 12px;
        justify-content: flex-end;
      }

      /* ── Comparison diff ── */
      .diff-section { margin-top: 16px; }
      .diff-row {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 6px 10px;
        border-radius: 8px;
        font-size: 0.88rem;
        margin-bottom: 4px;
      }
      .diff-row.added { background: var(--ok-bg); color: var(--ok-accent); }
      .diff-row.removed { background: var(--no-bg); color: var(--no-accent); }
      .diff-arrow { font-weight: 700; }
      .diff-summary {
        display: flex;
        gap: 16px;
        font-weight: 600;
        font-size: 0.95rem;
        margin-bottom: 10px;
      }

      /* ── Timeline ── */
      .timeline-bar {
        display: flex;
        align-items: center;
        gap: 0;
        margin-top: 10px;
        padding: 8px 0;
        overflow-x: auto;
      }
      .timeline-node {
        display: flex;
        flex-direction: column;
        align-items: center;
        min-width: 100px;
        position: relative;
      }
      .timeline-dot {
        width: 14px;
        height: 14px;
        border-radius: 50%;
        background: var(--muted);
        border: 2px solid var(--line);
        z-index: 1;
      }
      .timeline-dot.active {
        background: var(--ok-accent);
        border-color: var(--ok-accent);
        box-shadow: 0 0 8px rgba(34,168,85,0.4);
      }
      .timeline-dot.repealed {
        background: var(--no-accent);
        border-color: var(--no-accent);
      }
      .timeline-label {
        font-size: 0.7rem;
        font-weight: 600;
        margin-top: 4px;
        text-align: center;
        color: var(--muted);
      }
      .timeline-label.active { color: var(--ok-accent); font-weight: 700; }
      .timeline-connector {
        height: 2px;
        flex: 1;
        min-width: 30px;
        background: var(--line);
        margin-top: -7px;
      }
      .timeline-toggle {
        font-size: 0.75rem;
        color: var(--brand);
        font-weight: 700;
        cursor: pointer;
        background: none;
        border: none;
        padding: 2px 0;
        margin-top: 4px;
      }
      .timeline-toggle:hover { opacity: 0.7; }
      .timeline-toggle:active { transform: none; }
      .timeline-wrap { display: none; }
      .timeline-wrap.open { display: block; }

      /* ── Related Regulations ── */
      .related-list {
        margin-top: 8px;
        padding-left: 16px;
      }
      .related-item {
        font-size: 0.82rem;
        color: var(--muted);
        padding: 2px 0;
      }
      .related-item .related-code {
        font-weight: 700;
        color: var(--brand);
      }

      /* ── Toast ── */
      .toast {
        position: fixed;
        bottom: 24px;
        left: 50%;
        transform: translateX(-50%) translateY(80px);
        background: var(--ink);
        color: var(--bg);
        padding: 10px 22px;
        border-radius: 12px;
        font-size: 0.88rem;
        font-weight: 600;
        box-shadow: 0 8px 30px rgba(0,0,0,0.25);
        z-index: 9999;
        opacity: 0;
        transition: transform 0.3s, opacity 0.3s;
        pointer-events: none;
      }
      .toast.visible {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
      }

      /* ── Print / PDF ── */
      #printableReport { display: none; }

      @media print {
        body * { visibility: hidden; }
        #printableReport, #printableReport * { visibility: visible; }
        #printableReport {
          display: block !important;
          position: absolute;
          left: 0;
          top: 0;
          width: 100%;
          padding: 20px;
          font-family: "Manrope", sans-serif;
          color: #000;
          background: #fff;
        }
        #printableReport h1 { font-size: 1.4rem; margin-bottom: 4px; }
        #printableReport h2 { font-size: 1.1rem; margin-top: 16px; }
        #printableReport table {
          width: 100%;
          border-collapse: collapse;
          font-size: 0.82rem;
          margin-top: 8px;
        }
        #printableReport th, #printableReport td {
          border: 1px solid #ccc;
          padding: 6px 8px;
          text-align: left;
        }
        #printableReport th { background: #f0f0f0; font-weight: 700; }
        #printableReport .print-meta { color: #555; font-size: 0.8rem; margin-top: 4px; }
      }

      /* ── Footer ── */
      .footer-credit {
        margin-top: 24px;
        padding-top: 16px;
        border-top: 1px solid var(--line);
        text-align: center;
        color: var(--footer-color);
        font-size: 0.9rem;
        font-weight: 600;
      }

      a { color: var(--brand); }

      /* ── Dark mode auto-detection ── */
      @media (prefers-color-scheme: dark) {
        html:not([data-theme="light"]) {
          --bg: #0d1117;
          --surface: rgba(22, 27, 34, 0.92);
          --ink: #e6edf3;
          --muted: #8b949e;
          --line: #30363d;
          --brand: #39c5cf;
          --brand-2: #58d5e3;
          --brand-glow: rgba(57, 197, 207, 0.25);
          --ok-bg: #0d2818;
          --ok-line: #1a4d2e;
          --ok-accent: #3fb950;
          --no-bg: #2d1117;
          --no-line: #5c2d2d;
          --no-accent: #f85149;
          --neutral-accent: #6e7681;
          --shadow: 0 24px 50px rgba(0, 0, 0, 0.4);
          --shadow-hover: 0 28px 60px rgba(0, 0, 0, 0.5);
          --input-bg: #161b22;
          --input-border: #30363d;
          --subtle-bg: #21262d;
          --subtle-color: #c9d1d9;
          --subtle-hover: #30363d;
          --meta-color: #8b949e;
          --hero-bg: linear-gradient(140deg, #010409, #0d1117);
          --summary-bg: linear-gradient(160deg, #0d1117, #161b22);
          --body-gradient-1: transparent;
          --body-gradient-2: transparent;
          --badge-bg: rgba(255,255,255,0.08);
          --footer-color: #8b949e;
          --dim-pass-bg: #0d2818;
          --dim-pass-color: #3fb950;
          --dim-fail-bg: #2d1117;
          --dim-fail-color: #f85149;
          --dim-neutral-bg: #21262d;
          --dim-neutral-color: #8b949e;
          --metric-card-bg: rgba(255,255,255,0.04);
          --source-link-bg: rgba(255,255,255,0.05);
          --conf-bar-bg: rgba(255,255,255,0.1);
        }
      }

      /* ── Responsive tweaks ── */
      @media (max-width: 600px) {
        .hero { padding: 20px 16px; }
        .hero-icon { width: 38px; height: 38px; border-radius: 10px; }
        .hero-icon::after { width: 20px; height: 20px; }
        .card { padding: 16px; }
        .reg { padding: 14px 14px 12px 18px; }
        .summary-metrics { gap: 8px; }
        .metric-card { padding: 12px; }
        .metric-number { font-size: 1.6rem; }
      }

      /* ── Settings Modal ── */
      .settings-btn { background:none; border:none; cursor:pointer; font-size:1.35rem; padding:4px 8px; color:var(--muted); transition:color .2s; }
      .settings-btn:hover { color:var(--brand); }
      .modal-overlay { display:none; position:fixed; inset:0; background:rgba(0,0,0,0.45); z-index:900; align-items:center; justify-content:center; }
      .modal-overlay.open { display:flex; }
      .modal { background:var(--surface); border:1px solid var(--line); border-radius:16px; padding:28px; max-width:480px; width:92%; max-height:85vh; overflow-y:auto; box-shadow:var(--shadow); }
      .modal h2 { margin:0 0 16px; font-size:1.15rem; }
      .modal label { display:block; font-size:0.82rem; font-weight:600; margin:10px 0 4px; color:var(--muted); }
      .modal input[type="text"], .modal input[type="password"], .modal input[type="email"] { width:100%; padding:8px 10px; border:1px solid var(--input-border); border-radius:8px; background:var(--input-bg); color:var(--ink); font-size:0.88rem; }
      .modal .modal-actions { display:flex; gap:8px; margin-top:16px; justify-content:flex-end; }
      .modal .section-label { font-size:0.78rem; text-transform:uppercase; letter-spacing:0.06em; color:var(--brand); margin-top:18px; font-weight:700; }

      /* ── Auth Bar ── */
      .auth-bar { display:flex; align-items:center; gap:8px; margin-left:auto; }
      .auth-bar .auth-avatar { width:28px; height:28px; border-radius:50%; background:var(--brand); color:#fff; display:flex; align-items:center; justify-content:center; font-size:0.78rem; font-weight:700; }
      .auth-bar .auth-email { font-size:0.78rem; color:var(--muted); max-width:140px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
      .auth-bar button { font-size:0.78rem; }
      .auth-modal-tabs { display:flex; gap:0; margin-bottom:14px; }
      .auth-modal-tabs button { flex:1; padding:8px; border:1px solid var(--line); background:var(--subtle-bg); color:var(--muted); cursor:pointer; font-size:0.82rem; font-weight:600; }
      .auth-modal-tabs button:first-child { border-radius:8px 0 0 8px; }
      .auth-modal-tabs button:last-child { border-radius:0 8px 8px 0; }
      .auth-modal-tabs button.active { background:var(--brand); color:#fff; border-color:var(--brand); }

      /* ── Risk Dashboard ── */
      .risk-dashboard { display:grid; grid-template-columns:1fr 1fr; gap:16px; margin-top:16px; }
      .risk-dashboard .chart-box { background:var(--metric-card-bg); border:1px solid var(--line); border-radius:12px; padding:16px; }
      .risk-dashboard .chart-box h3 { font-size:0.88rem; margin:0 0 10px; color:var(--muted); }
      .risk-dashboard .chart-box.full-width { grid-column:1/-1; }
      @media(max-width:700px) { .risk-dashboard { grid-template-columns:1fr; } }

      /* ── News Feed ── */
      .news-grid { display:grid; grid-template-columns:1fr; gap:12px; }
      .news-card { display:flex; gap:12px; background:var(--metric-card-bg); border:1px solid var(--line); border-radius:10px; padding:12px; transition:box-shadow .2s; }
      .news-card:hover { box-shadow:var(--shadow-hover); }
      .news-card img { width:90px; height:68px; object-fit:cover; border-radius:8px; flex-shrink:0; }
      .news-card .news-body { flex:1; min-width:0; }
      .news-card .news-title { font-size:0.88rem; font-weight:700; color:var(--ink); margin:0 0 4px; }
      .news-card .news-title a { color:inherit; text-decoration:none; }
      .news-card .news-title a:hover { color:var(--brand); }
      .news-card .news-meta { font-size:0.74rem; color:var(--muted); margin-bottom:4px; }
      .news-card .news-snippet { font-size:0.8rem; color:var(--muted); display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; overflow:hidden; }
      .news-apikey-prompt { text-align:center; padding:20px; color:var(--muted); font-size:0.88rem; }
      .news-apikey-prompt button { margin-top:8px; }

      /* ── Chat Panel ── */
      .chat-fab { position:fixed; bottom:24px; right:24px; width:56px; height:56px; border-radius:50%; background:var(--brand); color:#fff; border:none; cursor:pointer; font-size:1.5rem; box-shadow:0 4px 16px rgba(0,0,0,0.2); z-index:800; display:flex; align-items:center; justify-content:center; transition:transform .2s,background .2s; }
      .chat-fab:hover { transform:scale(1.08); background:var(--brand-2); }
      .chat-panel { position:fixed; bottom:90px; right:24px; width:380px; max-height:520px; background:var(--surface); border:1px solid var(--line); border-radius:16px; box-shadow:var(--shadow); z-index:810; display:none; flex-direction:column; overflow:hidden; }
      .chat-panel.open { display:flex; }
      .chat-header { padding:12px 16px; border-bottom:1px solid var(--line); display:flex; align-items:center; justify-content:space-between; }
      .chat-header h3 { margin:0; font-size:0.95rem; }
      .chat-header button { background:none; border:none; cursor:pointer; font-size:1.1rem; color:var(--muted); }
      .chat-messages { flex:1; overflow-y:auto; padding:12px 16px; display:flex; flex-direction:column; gap:8px; min-height:200px; max-height:360px; }
      .chat-msg { max-width:85%; padding:8px 12px; border-radius:12px; font-size:0.84rem; line-height:1.45; word-wrap:break-word; }
      .chat-msg.user { align-self:flex-end; background:var(--brand); color:#fff; border-bottom-right-radius:4px; }
      .chat-msg.bot { align-self:flex-start; background:var(--subtle-bg); color:var(--ink); border-bottom-left-radius:4px; }
      .chat-msg.system { align-self:center; font-size:0.74rem; color:var(--muted); font-style:italic; }
      .chat-input-row { display:flex; gap:6px; padding:10px 12px; border-top:1px solid var(--line); }
      .chat-input-row input { flex:1; padding:8px 10px; border:1px solid var(--input-border); border-radius:8px; background:var(--input-bg); color:var(--ink); font-size:0.84rem; }
      .chat-input-row button { padding:8px 14px; border-radius:8px; background:var(--brand); color:#fff; border:none; cursor:pointer; font-size:0.84rem; font-weight:600; }
      .chat-disclaimer { font-size:0.68rem; color:var(--muted); text-align:center; padding:0 12px 8px; }
      @media(max-width:500px) { .chat-panel { right:8px; left:8px; width:auto; bottom:80px; max-height:70vh; } }

      /* ── Currency Hint ── */
      .currency-hint { font-size:0.74rem; color:var(--brand); margin-top:2px; min-height:1em; }
      /* ── Site Navigation ── */
      .site-nav { display:flex; gap:4px; padding:10px 0; margin-bottom:8px; flex-wrap:wrap; justify-content:center; }
      .nav-link { padding:8px 18px; border-radius:10px; font-size:0.88rem; font-weight:600; color:var(--muted); text-decoration:none; background:var(--subtle-bg); transition:all .2s; border:1px solid transparent; }
      .nav-link:hover { color:var(--ink); background:var(--subtle-hover); }
      .nav-link.active { color:#fff; background:var(--brand); border-color:var(--brand); }

      /* ── Page Container (for sub-pages) ── */
      .page-card { background:var(--surface); border:1px solid var(--line); border-radius:16px; padding:28px; box-shadow:var(--shadow); margin-bottom:20px; }
      .page-card h2 { margin:0 0 16px; font-family:'Space Grotesk',sans-serif; }

      /* ── Full-page Chat ── */
      .chat-fullpage { display:flex; flex-direction:column; height:calc(100vh - 260px); min-height:400px; }
      .chat-fullpage .chat-messages { flex:1; overflow-y:auto; padding:16px; display:flex; flex-direction:column; gap:8px; }
      .chat-fullpage .chat-input-row { display:flex; gap:8px; padding:12px 16px; border-top:1px solid var(--line); }
      .chat-fullpage .chat-input-row input { flex:1; padding:10px 14px; border:1px solid var(--input-border); border-radius:10px; background:var(--input-bg); color:var(--ink); font-size:0.92rem; }
      .chat-fullpage .chat-input-row button { padding:10px 20px; border-radius:10px; background:var(--brand); color:#fff; border:none; cursor:pointer; font-size:0.92rem; font-weight:600; }
