/* ── Shared tokens ────────────────────────────────── */
    :root {
      /* Paleta derivada del logo Intercyd.ai: azul profundo · cian · verde menta */
      --accent:      #1878c0;   /* azul cian del isotipo */
      --accent2:     #004890;   /* azul profundo del wordmark */
      --accent-dim:  rgba(24,120,192,0.10);
      --mint:        #78c090;   /* verde menta del isotipo */
      --brand-grad:  linear-gradient(120deg, #004890 0%, #1878c0 55%, #78c090 100%);
      --green:       #16a34a;
      --yellow:      #f59e0b;
      --red:         #ef4444;
      --font:        'DM Sans', sans-serif;
      --mono:        'JetBrains Mono', monospace;
      --radius:      8px;
      --radius-lg:   12px;
    }

    /* ── Theme: light (default) ────────────────────── */
    [data-theme="light"] {
      --bg:       #f5f7fa;
      --bg2:      #ffffff;
      --bg3:      #f0f2f5;
      --border:   #e2e6ea;
      --border2:  #edf0f3;
      --text:     #1a202c;
      --text2:    #4a5568;
      --text3:    #a0aec0;
      --chart-grid:   rgba(160,174,192,0.25);
      --chart-tick:   #718096;
      --chart-legend: #4a5568;
    }

    /* ── Theme: dusk (mid) ─────────────────────────── */
    [data-theme="dusk"] {
      --bg:       #1e2433;
      --bg2:      #252d3d;
      --bg3:      #1a2030;
      --border:   #2e3a50;
      --border2:  #28334a;
      --text:     #cdd6f4;
      --text2:    #8892a4;
      --text3:    #4a5568;
      --chart-grid:   rgba(46,58,80,0.8);
      --chart-tick:   #8892a4;
      --chart-legend: #cdd6f4;
    }

    /* ── Theme: dark ───────────────────────────────── */
    [data-theme="dark"] {
      --bg:       #0d1117;
      --bg2:      #161b22;
      --bg3:      #1c2333;
      --border:   #30363d;
      --border2:  #21262d;
      --text:     #e6edf3;
      --text2:    #8b949e;
      --text3:    #484f58;
      --chart-grid:   rgba(48,54,61,0.7);
      --chart-tick:   #8b949e;
      --chart-legend: #8b949e;
    }

    /* ── Size scale: small (default) ──────────────────── */
    [data-size="small"] {
      --fs-base:    13px;
      --fs-sm:      11px;
      --fs-xs:      10px;
      --fs-lg:      15px;
      --fs-label:   10px;
      --lh:         1.5;
      --row-pad:    7px 14px;
      --cell-pad:   5px 10px;
      --bubble-pad: 8px 12px;
      --input-pad:  8px 10px;
      --sidebar-w:  320px;
    }

    /* ── Size scale: medium ─────────────────────────────── */
    [data-size="medium"] {
      --fs-base:    15px;
      --fs-sm:      13px;
      --fs-xs:      11px;
      --fs-lg:      17px;
      --fs-label:   11px;
      --lh:         1.6;
      --row-pad:    9px 16px;
      --cell-pad:   7px 12px;
      --bubble-pad: 10px 14px;
      --input-pad:  9px 12px;
      --sidebar-w:  340px;
    }

    /* ── Size scale: large ──────────────────────────────── */
    [data-size="large"] {
      --fs-base:    17px;
      --fs-sm:      15px;
      --fs-xs:      13px;
      --fs-lg:      20px;
      --fs-label:   13px;
      --lh:         1.7;
      --row-pad:    11px 18px;
      --cell-pad:   9px 14px;
      --bubble-pad: 12px 16px;
      --input-pad:  10px 14px;
      --sidebar-w:  360px;
    }

    *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

    html, body {
      height: 100%; overflow: hidden;
      background: var(--bg);
      color: var(--text);
      font-family: var(--font);
      font-size: var(--fs-base);
      line-height: var(--lh);
    }

    /* ── Layout ─────────────────────────────────────────── */
    .layout {
      display: grid;
      grid-template-rows: 58px 1fr;
      grid-template-columns: var(--sidebar-w) 1fr;
      height: 100vh;
    }

    /* Header */
    .header {
      grid-column: 1 / -1;
      display: flex;
      align-items: center;
      gap: 12px;
      padding: 0 20px;
      background: var(--bg2);
      border-bottom: 1px solid var(--border);
    }
    .header-logo {
      display: flex; align-items: center; gap: 10px;
    }
    .header-logo img {
      height: 30px; width: auto; display: block;
    }
    /* En tema claro el logo lleva texto azul oscuro propio; en oscuro va tal cual */
    .header-divider {
      width: 1px; height: 26px;
      background: var(--border);
      margin: 0 4px;
    }
    .header-logo svg { color: var(--accent); }
    .header-title {
      font-size: 13px; font-weight: 600; letter-spacing: 0.02em;
      color: var(--text);
    }
    .header-sub {
      font-size: 11px; color: var(--text3);
      margin-left: 4px;
    }
    .header-version {
      font-size: 10px; font-weight: 600;
      color: var(--accent);
      background: var(--accent-dim);
      border: 1px solid rgba(24,120,192,0.25);
      border-radius: 4px;
      padding: 1px 6px;
      margin-left: 6px;
      letter-spacing: 0.03em;
      cursor: default;
    }
    .header-right { margin-left: auto; display: flex; gap: 8px; }

    /* Sidebar chat */
    .sidebar {
      display: flex; flex-direction: column;
      background: var(--bg2);
      border-right: 1px solid var(--border);
      overflow: hidden;
    }
    .sidebar-label {
      padding: 12px 16px 8px;
      font-size: 10px; font-weight: 600;
      letter-spacing: 0.1em; text-transform: uppercase;
      color: var(--text3);
      border-bottom: 1px solid var(--border2);
    }
    .chat {
      flex: 1; overflow-y: auto;
      padding: 12px;
      display: flex; flex-direction: column; gap: 8px;
    }
    .chat::-webkit-scrollbar { width: 4px; }
    .chat::-webkit-scrollbar-track { background: transparent; }
    .chat::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

    /* Bubbles */
    .bubble {
      padding: var(--bubble-pad);
      border-radius: var(--radius);
      font-size: var(--fs-base); line-height: var(--lh);
      max-width: 100%;
      word-break: break-word;
    }
    .bubble-user {
      background: var(--accent);
      color: #fff;
      align-self: flex-end;
      border-bottom-right-radius: 3px;
    }
    .bubble-bot {
      background: var(--bg3);
      border: 1px solid var(--border);
      color: var(--text2);
      align-self: flex-start;
      border-bottom-left-radius: 3px;
    }
    .bubble-bot a {
      color: var(--accent); text-decoration: none;
    }
    .bubble-bot a:hover { text-decoration: underline; }

    /* Input */
    .chat-input {
      padding: 10px 12px;
      border-top: 1px solid var(--border);
      display: flex; gap: 8px; align-items: flex-end;
      background: var(--bg2);
    }
    .chat-input textarea {
      flex: 1; resize: none;
      background: var(--bg3);
      border: 1px solid var(--border);
      border-radius: var(--radius);
      color: var(--text);
      font-family: var(--font);
      font-size: var(--fs-base);
      padding: var(--input-pad);
      outline: none;
      transition: border-color 0.15s;
      min-height: 38px; max-height: 100px;
    }
    .chat-input textarea:focus { border-color: var(--accent); }
    .chat-input textarea::placeholder { color: var(--text3); }
    .btn-send {
      width: 36px; height: 36px; flex-shrink: 0;
      background: var(--accent);
      border: none; border-radius: var(--radius);
      color: #fff; cursor: pointer;
      display: flex; align-items: center; justify-content: center;
      transition: background 0.15s;
    }
    .btn-send:hover { background: var(--accent2); }
    .btn-send:disabled { background: var(--border); cursor: not-allowed; }

    /* Spinner */
    .spinner {
      width: 16px; height: 16px;
      border: 2px solid var(--border);
      border-top-color: var(--accent);
      border-radius: 50%;
      animation: spin 0.8s linear infinite;
      display: inline-block;
    }
    @keyframes spin { to { transform: rotate(360deg); } }

    /* ── Main area ──────────────────────────────────────── */
    .main {
      overflow: hidden;
      display: flex; flex-direction: column;
      background: var(--bg);
    }

    /* Result tabs */
    .result-tabs {
      display: flex; align-items: center;
      padding: 0 16px;
      border-bottom: 1px solid var(--border);
      background: var(--bg2);
      gap: 0;
      flex-shrink: 0;
      min-height: 40px;
    }
    .result-tab {
      padding: 0 14px;
      height: 40px;
      display: flex; align-items: center;
      font-size: var(--fs-sm); font-weight: 500;
      color: var(--text3);
      cursor: pointer;
      border-bottom: 2px solid transparent;
      transition: color 0.15s, border-color 0.15s;
      white-space: nowrap;
      user-select: none;
    }
    .result-tab:hover { color: var(--text2); }
    .result-tab.active { color: var(--text); border-bottom-color: var(--accent); }
    .result-tab .tab-dot {
      width: 6px; height: 6px; border-radius: 50%;
      background: var(--accent); margin-right: 6px;
      display: none;
    }
    .result-tab.has-data .tab-dot { display: block; }
    .tabs-right { margin-left: auto; display: flex; gap: 6px; }

    /* Result panes */
    .result-pane {
      flex: 1; overflow: hidden;
      display: none;
    }
    .result-pane.active { display: flex; flex-direction: column; }

    /* Empty state */
    .empty-state {
      flex: 1; display: flex; flex-direction: column;
      align-items: center; justify-content: center;
      gap: 12px; color: var(--text3);
    }
    .empty-state svg { opacity: 0.3; }
    .empty-state p { font-size: 13px; }

    /* ── Onboarding por pasos ───────────────────────────── */
    .onboard {
      flex: 1; overflow-y: auto;
      display: flex; flex-direction: column;
      align-items: center; justify-content: center;
      padding: 40px 32px; gap: 32px;
    }
    .onboard-hero {
      text-align: center; max-width: 620px;
      animation: ob-rise 0.6s cubic-bezier(0.16,1,0.3,1) both;
    }
    .onboard-eyebrow {
      font-family: var(--mono);
      font-size: 11px; letter-spacing: 0.18em; text-transform: uppercase;
      color: var(--accent); margin-bottom: 14px;
    }
    .onboard-hero h1 {
      font-size: 30px; font-weight: 600; line-height: 1.15;
      letter-spacing: -0.02em; color: var(--text);
      margin-bottom: 12px;
    }
    .onboard-hero h1 .grad {
      background: var(--brand-grad);
      -webkit-background-clip: text; background-clip: text;
      -webkit-text-fill-color: transparent;
    }
    .onboard-hero p {
      font-size: 15px; color: var(--text2); line-height: 1.6;
    }
    .onboard-steps {
      display: grid;
      grid-template-columns: repeat(4, 1fr);
      gap: 14px; width: 100%; max-width: 920px;
    }
    .ob-step {
      position: relative;
      background: var(--bg2);
      border: 1px solid var(--border);
      border-radius: var(--radius-lg);
      padding: 22px 18px 18px;
      display: flex; flex-direction: column; gap: 10px;
      animation: ob-rise 0.6s cubic-bezier(0.16,1,0.3,1) both;
      transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
    }
    .ob-step:nth-child(1) { animation-delay: 0.05s; }
    .ob-step:nth-child(2) { animation-delay: 0.13s; }
    .ob-step:nth-child(3) { animation-delay: 0.21s; }
    .ob-step:nth-child(4) { animation-delay: 0.29s; }
    .ob-step:hover {
      transform: translateY(-3px);
      border-color: var(--accent);
      box-shadow: 0 10px 30px -12px rgba(24,120,192,0.4);
    }
    /* línea conectora entre pasos */
    .ob-step:not(:last-child)::after {
      content: ""; position: absolute;
      top: 36px; right: -8px; width: 14px; height: 1px;
      background: var(--border);
      z-index: 1;
    }
    .ob-num {
      width: 30px; height: 30px;
      display: flex; align-items: center; justify-content: center;
      font-family: var(--mono); font-size: 13px; font-weight: 600;
      color: #fff; border-radius: 8px;
      background: var(--brand-grad);
    }
    .ob-step h3 {
      font-size: 14px; font-weight: 600; color: var(--text);
      letter-spacing: -0.01em;
    }
    .ob-step p {
      font-size: 12px; color: var(--text2); line-height: 1.55;
    }
    .ob-step .ob-eg {
      margin-top: auto;
      font-family: var(--mono); font-size: 11px;
      color: var(--accent);
      background: var(--accent-dim);
      border: 1px solid rgba(24,120,192,0.18);
      border-radius: 6px; padding: 6px 9px;
      cursor: pointer; transition: background 0.15s, color 0.15s;
      line-height: 1.4;
    }
    .ob-step .ob-eg:hover {
      background: var(--accent); color: #fff;
    }
    .onboard-foot {
      font-size: 12px; color: var(--text3);
      display: flex; align-items: center; gap: 8px;
      animation: ob-rise 0.6s 0.36s cubic-bezier(0.16,1,0.3,1) both;
    }
    .onboard-foot svg { opacity: 0.6; }
    @keyframes ob-rise {
      from { opacity: 0; transform: translateY(16px); }
      to   { opacity: 1; transform: translateY(0); }
    }
    @media (max-width: 900px) {
      .onboard-steps { grid-template-columns: repeat(2, 1fr); }
      .ob-step:not(:last-child)::after { display: none; }
    }

    /* ── Table ──────────────────────────────────────────── */
    .table-wrap {
      flex: 1; overflow: auto;
    }
    .table-wrap::-webkit-scrollbar { width: 6px; height: 6px; }
    .table-wrap::-webkit-scrollbar-track { background: var(--bg2); }
    .table-wrap::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

    .data-table {
      width: 100%; border-collapse: collapse;
      font-size: var(--fs-base);
    }
    .data-table thead {
      position: sticky; top: 0; z-index: 2;
    }
    .data-table th {
      background: var(--bg2);
      border-bottom: 1px solid var(--border);
      padding: var(--cell-pad);
      font-weight: 500; font-size: var(--fs-xs);
      letter-spacing: 0.05em; text-transform: uppercase;
      color: var(--text2);
      white-space: nowrap;
      cursor: pointer;
      user-select: none;
    }
    .data-table th:hover { color: var(--text2); }
    .data-table th.metric { text-align: right; }
    .data-table th.dimension { text-align: left; }
    .data-table td {
      padding: var(--row-pad);
      border-bottom: 1px solid var(--border2);
      color: var(--text);
      white-space: nowrap;
    }
    .data-table td.metric {
      text-align: right;
      font-family: var(--mono);
      font-size: var(--fs-sm);
      color: var(--text2);
    }
    .data-table tr:hover td { background: var(--bg3); }

    .table-toolbar {
      display: flex; align-items: center; gap: 10px;
      padding: 10px 16px;
      border-bottom: 1px solid var(--border);
      background: var(--bg2);
      flex-shrink: 0;
    }
    .table-toolbar input {
      flex: 1; max-width: 280px;
      background: var(--bg);
      border: 1px solid var(--border);
      border-radius: var(--radius);
      color: var(--text);
      font-family: var(--font);
      font-size: var(--fs-sm);
      padding: 5px 10px;
      outline: none;
    }
    .table-toolbar input:focus { border-color: var(--accent); }
    .table-toolbar input::placeholder { color: var(--text3); }
    .table-info {
      font-size: 11px; color: var(--text3);
      margin-left: auto;
      font-variant-numeric: tabular-nums;
    }
    .toolbar-btn {
      padding: 4px 10px;
      background: var(--bg3);
      border: 1px solid var(--border);
      border-radius: var(--radius);
      color: var(--text2);
      font-family: var(--font);
      font-size: var(--fs-xs);
      cursor: pointer;
      transition: background 0.15s, color 0.15s;
      white-space: nowrap;
    }
    .toolbar-btn:hover { background: var(--border); color: var(--text); }

    /* ── Chart pane ─────────────────────────────────────── */
    .chart-pane {
      flex: 1; overflow: hidden;
      display: flex; flex-direction: column;
    }
    .chart-toolbar {
      display: flex; align-items: center; gap: 8px;
      padding: 10px 16px;
      border-bottom: 1px solid var(--border);
      background: var(--bg2);
      flex-shrink: 0;
    }
    .chart-type-btn {
      padding: 4px 10px;
      background: var(--bg3);
      border: 1px solid var(--border);
      border-radius: var(--radius);
      color: var(--text3);
      font-family: var(--font);
      font-size: var(--fs-xs);
      cursor: pointer;
      transition: all 0.15s;
    }
    .chart-type-btn:hover { color: var(--text2); border-color: var(--accent); }
    .chart-type-btn.active {
      background: var(--accent-dim);
      border-color: var(--accent);
      color: var(--accent);
    }
    .chart-container {
      flex: 1; padding: 20px;
      overflow: hidden;
      position: relative;
    }
    .chart-container canvas { max-height: 100%; }
    .chart-loading {
      position: absolute; inset: 0;
      display: flex; align-items: center; justify-content: center;
      background: var(--bg);
      font-size: 12px; color: var(--text3);
      gap: 8px;
    }
    .chart-error {
      padding: 20px; color: var(--red);
      font-size: 12px; font-family: var(--mono);
    }

    /* Series selector */
    .series-selector {
      display: flex; align-items: flex-start; gap: 12px;
      padding: 8px 16px;
      border-bottom: 1px solid var(--border);
      background: var(--bg2);
      flex-shrink: 0;
      flex-wrap: wrap;
    }
    .series-group {
      display: flex; flex-direction: column; gap: 4px;
    }
    .series-group-label {
      font-size: var(--fs-xs); font-weight: 600; letter-spacing: 0.08em;
      text-transform: uppercase; color: var(--text3);
    }
    .series-pills {
      display: flex; gap: 4px; flex-wrap: wrap;
    }
    .series-pill {
      padding: 3px 10px;
      border-radius: 9999px;
      font-size: var(--fs-xs); font-weight: 500;
      border: 1px solid var(--border);
      background: var(--bg3);
      color: var(--text2);
      cursor: pointer;
      transition: all 0.15s;
      user-select: none;
      white-space: nowrap;
    }
    .series-pill:hover { border-color: var(--accent); color: var(--accent); }
    .series-pill.active {
      background: var(--accent);
      border-color: var(--accent);
      color: #fff;
    }
    .series-pill.dim-active {
      background: var(--accent-dim);
      border-color: var(--accent);
      color: var(--accent);
    }

    /* ── Debug drawer ───────────────────────────────────── */
    #debugDrawer {
      position: fixed; top: 0; right: 0;
      width: 500px; max-width: 90vw; height: 100vh;
      background: #060912;
      border-left: 1px solid var(--border);
      box-shadow: -8px 0 40px rgba(0,0,0,0.6);
      display: flex; flex-direction: column;
      z-index: 9999;
      transform: translateX(100%);
      transition: transform 0.22s cubic-bezier(0.4,0,0.2,1);
      font-family: var(--mono);
      font-size: 11px;
      color: #e2e8f0;
    }
    #debugDrawer.open { transform: translateX(0); }
    .dbg-header {
      display: flex; align-items: center; justify-content: space-between;
      padding: 10px 14px;
      background: #0a0d14;
      border-bottom: 1px solid #1e293b;
      flex-shrink: 0;
    }
    .dbg-header span { color: var(--accent); font-weight: 700; font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; }
    .dbg-header-right { display: flex; gap: 8px; align-items: center; }
    .dbg-tabs {
      display: flex; background: #0a0d14;
      border-bottom: 1px solid #1e293b;
      flex-shrink: 0; overflow-x: auto;
    }
    .dbg-tab {
      padding: 6px 14px; font-size: 10px; cursor: pointer;
      color: #64748b; border-bottom: 2px solid transparent;
      white-space: nowrap; transition: color 0.15s, border-color 0.15s;
    }
    .dbg-tab:hover { color: #94a3b8; }
    .dbg-tab.active { color: #38bdf8; border-bottom-color: #38bdf8; }
    .dbg-body { flex: 1; overflow-y: auto; padding: 12px 14px; }
    .dbg-body::-webkit-scrollbar { width: 4px; }
    .dbg-body::-webkit-scrollbar-thumb { background: #334155; border-radius: 2px; }
    .dbg-entry { margin-bottom: 6px; border: 1px solid #1e293b; border-radius: 4px; overflow: hidden; }
    .dbg-entry-header { display: flex; align-items: center; justify-content: space-between; padding: 6px 10px; background: #141a26; cursor: pointer; user-select: none; }
    .dbg-entry-header:hover { background: #1a2235; }
    .dbg-entry-q { color: #94a3b8; font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 300px; }
    .dbg-entry-meta { display: flex; gap: 6px; flex-shrink: 0; }
    .dbg-badge { padding: 1px 6px; border-radius: 9999px; font-size: 10px; font-weight: 600; }
    .badge-high { background: #14532d; color: #4ade80; }
    .badge-medium { background: #713f12; color: #fbbf24; }
    .badge-low { background: #7f1d1d; color: #f87171; }
    .badge-ms { background: #1e293b; color: #64748b; }
    .dbg-entry-body { display: none; }
    .dbg-entry-body.open { display: block; }
    .dbg-section { border-top: 1px solid #1e293b; }
    .dbg-section-title { padding: 5px 10px; background: #0d111c; color: #475569; font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; cursor: pointer; display: flex; align-items: center; justify-content: space-between; user-select: none; }
    .dbg-section-title:hover { color: #64748b; }
    .dbg-section-content { display: none; padding: 8px 10px; }
    .dbg-section-content.open { display: block; }
    .dbg-sql { background: #060912; border: 1px solid #1e293b; border-radius: 4px; padding: 8px 10px; white-space: pre-wrap; word-break: break-all; line-height: 1.6; color: #cbd5e1; }
    .sql-kw { color: #7dd3fc; } .sql-fn { color: #c084fc; } .sql-str { color: #86efac; }
    .sql-num { color: #fbbf24; } .sql-tbl { color: #f0abfc; }
    .json-key { color: #7dd3fc; } .json-str { color: #86efac; } .json-num { color: #fbbf24; }
    .json-bool { color: #f97316; } .json-null { color: #94a3b8; }
    .dbg-metrics { display: flex; gap: 8px; flex-wrap: wrap; padding: 8px 10px; }
    .dbg-metric { background: #141a26; border: 1px solid #1e293b; border-radius: 6px; padding: 4px 10px; font-size: 11px; }
    .dbg-metric label { color: #475569; margin-right: 5px; }
    .dbg-copy-btn { float: right; margin-left: 8px; padding: 1px 8px; font-size: 10px; background: #1e293b; color: #64748b; border: 1px solid #334155; border-radius: 4px; cursor: pointer; font-family: inherit; }
    .dbg-copy-btn:hover { background: #334155; color: #94a3b8; }

    /* Debug toggle */
    #debugToggle {
      position: fixed; bottom: 12px; right: 12px;
      width: 34px; height: 34px;
      background: var(--bg3);
      border: 1px solid var(--border);
      border-radius: var(--radius);
      color: var(--text3);
      display: flex; align-items: center; justify-content: center;
      cursor: pointer; z-index: 9998; font-size: 13px;
      transition: all 0.15s;
    }
    #debugToggle:hover { border-color: var(--accent); color: var(--accent); }
    #debugToggle.has-data { color: var(--accent); border-color: var(--accent); background: var(--accent-dim); }

    /* Fullscreen */
    .fullscreen-overlay {
      position: fixed; inset: 0;
      background: var(--bg);
      z-index: 9990;
      display: flex; flex-direction: column;
    }
    .fullscreen-hidden { display: none !important; }
    .fullscreen-header {
      display: flex; align-items: center; justify-content: space-between;
      padding: 10px 16px;
      background: var(--bg2);
      border-bottom: 1px solid var(--border);
      flex-shrink: 0;
    }
    .fullscreen-header span { font-size: 13px; font-weight: 500; color: var(--text2); }
    /* ── Sidebar controls ──────────────────────────────── */
    .sidebar-controls {
      display: flex; gap: 6px; flex-wrap: wrap;
      padding: 8px 12px;
      border-top: 1px solid var(--border);
      background: var(--bg2);
      flex-shrink: 0;
    }
    .ctrl-btn {
      flex: 1; min-width: 0;
      padding: 5px 8px;
      background: var(--bg3);
      border: 1px solid var(--border);
      border-radius: var(--radius);
      color: var(--text2);
      font-family: var(--font);
      font-size: 11px;
      cursor: pointer;
      transition: all 0.15s;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
      text-align: center;
    }
    .ctrl-btn:hover { background: var(--border); color: var(--text); }
    .ctrl-btn.danger:hover { background: rgba(239,68,68,0.1); border-color: var(--red); color: var(--red); }

    /* ── Pivot suggestion banner ────────────────────────── */
    .pivot-banner {
      display: flex; align-items: center; gap: 10px;
      padding: 7px 14px;
      background: var(--accent-dim);
      border-bottom: 1px solid rgba(24,120,192,0.2);
      font-size: 11px; color: var(--accent);
      flex-shrink: 0;
    }
    .pivot-banner span { flex: 1; }
    .pivot-banner button {
      padding: 3px 10px;
      border: 1px solid var(--accent);
      border-radius: var(--radius);
      background: transparent;
      color: var(--accent);
      font-size: 11px; font-family: var(--font);
      cursor: pointer; transition: background 0.15s;
    }
    .pivot-banner button:hover { background: var(--accent); color: #fff; }
    .pivot-banner .dismiss {
      border: none; background: none;
      color: var(--text3); font-size: 14px; padding: 2px 4px;
    }
    .pivot-banner .dismiss:hover { background: none; color: var(--text2); }

    /* ── Prompt selector ───────────────────────────────── */
    .prompt-selector { display: flex; align-items: center; gap: 6px; }
    .prompt-selector label { font-size: 10px; color: var(--text3); white-space: nowrap; }
    .prompt-select {
      background: var(--bg3); border: 1px solid var(--border);
      border-radius: var(--radius); color: var(--text2);
      font-family: var(--font); font-size: 11px;
      padding: 3px 6px; cursor: pointer; outline: none; max-width: 150px;
    }
    .prompt-select:focus { border-color: var(--accent); }
    .prompt-select:disabled { opacity: 0.5; cursor: wait; }
    /* ── Theme switcher ────────────────────────────── */
    .theme-switcher {
      display: flex;
      background: var(--bg3);
      border: 1px solid var(--border);
      border-radius: 20px;
      padding: 2px;
      gap: 0;
    }
    .theme-btn {
      width: 26px; height: 26px;
      border: none; border-radius: 16px;
      background: transparent;
      color: var(--text3);
      cursor: pointer;
      display: flex; align-items: center; justify-content: center;
      font-size: 13px;
      transition: background 0.15s, color 0.15s;
    }
    .theme-btn:hover { color: var(--text2); }
    .theme-btn.active {
      background: var(--bg2);
      color: var(--accent);
      box-shadow: 0 1px 3px rgba(0,0,0,0.15);
    }
    /* Size switcher — reutiliza .theme-switcher shape */
    .size-btn {
      width: 26px; height: 26px;
      border: none; border-radius: 16px;
      background: transparent;
      color: var(--text3);
      cursor: pointer;
      display: flex; align-items: center; justify-content: center;
      font-family: var(--font);
      font-weight: 700;
      line-height: 1;
      transition: background 0.15s, color 0.15s;
    }
    .size-btn:hover { color: var(--text2); }
    .size-btn.active {
      background: var(--bg2);
      color: var(--accent);
      box-shadow: 0 1px 3px rgba(0,0,0,0.15);
    }
    /* ── Welcome bubble ────────────────────────────────── */
    .bubble-welcome {
      background: linear-gradient(135deg, var(--accent-dim), var(--bg3));
      border: 1px solid rgba(24,120,192,0.25);
      border-radius: var(--radius-lg);
      padding: var(--bubble-pad);
      font-size: var(--fs-base);
      line-height: 1.7;
      color: var(--text);
      align-self: flex-start;
      max-width: 100%;
    }
    .bubble-welcome strong { color: var(--accent); }
    .bubble-welcome em { color: var(--text2); font-style: italic; }
    .bubble-welcome p { margin-bottom: 6px; }
    .bubble-welcome p:last-child { margin-bottom: 0; }
    .welcome-example {
      display: flex;
      align-items: center;
      gap: 7px;
      margin: 3px 0;
      padding: 5px 10px;
      background: var(--bg2);
      border: 1px solid var(--border);
      border-radius: var(--radius);
      color: var(--text2);
      font-size: var(--fs-sm);
      cursor: pointer;
      transition: border-color 0.15s, color 0.15s, background 0.15s;
      width: fit-content;
    }
    .welcome-example:hover {
      border-color: var(--accent);
      color: var(--accent);
      background: var(--accent-dim);
    }
    .example-list {
      list-style: none;
      margin: 6px 0 2px 0;
      padding: 0;
      display: flex;
      flex-direction: column;
      gap: 4px;
    }
    .welcome-example .play-icon {
      color: var(--accent);
      font-size: 10px;
      flex-shrink: 0;
    }

    /* ── Action bubble (save + feedback) ──────────────── */
    .bubble-actions {
      display: flex; flex-direction: column; gap: 6px;
      align-self: flex-start;
      max-width: 100%;
    }
    .action-row {
      display: flex; gap: 6px; flex-wrap: wrap; align-items: center;
    }
    .action-label {
      font-size: var(--fs-xs); color: var(--text3);
      letter-spacing: 0.05em; text-transform: uppercase;
      width: 100%; margin-bottom: 2px;
      display: block;
    }
    /* Action row inside bubble: remove bubble's default max-width limit */
    .bubble-bot .action-row { flex-wrap: wrap; }
    .action-btn {
      padding: 4px 10px;
      background: var(--bg2);
      border: 1px solid var(--border);
      border-radius: var(--radius);
      color: var(--text2);
      font-family: var(--font);
      font-size: var(--fs-xs); font-weight: 500;
      cursor: pointer;
      transition: all 0.15s;
      white-space: nowrap;
    }
    .action-btn:hover { border-color: var(--accent); color: var(--accent); }
    .action-btn:disabled { opacity: 0.5; cursor: default; }
    .action-btn.disabled-look { opacity: 0.45; cursor: not-allowed; }
    .action-btn.saved { border-color: var(--green); color: var(--green); }
    .action-btn.thumb-up:hover   { border-color: var(--green);  color: var(--green); }
    .action-btn.thumb-down:hover { border-color: var(--red);    color: var(--red); }
    .action-btn.thumb-up.voted   { background: rgba(34,197,94,0.1);
                                   border-color: var(--green); color: var(--green); }
    .action-btn.thumb-down.voted { background: rgba(239,68,68,0.1);
                                   border-color: var(--red); color: var(--red); }

    /* ── Saved queries panel ───────────────────────── */
    .sidebar-tabs {
      display: flex;
      border-bottom: 1px solid var(--border);
      flex-shrink: 0;
    }
    .sidebar-tab {
      flex: 1; padding: 7px 0;
      font-size: var(--fs-xs); font-weight: 500;
      text-align: center; cursor: pointer;
      color: var(--text3);
      border-bottom: 2px solid transparent;
      transition: color 0.15s, border-color 0.15s;
      user-select: none;
    }
    .sidebar-tab:hover { color: var(--text2); }
    .sidebar-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

    .sidebar-panel { flex: 1; overflow-y: auto; display: none; }
    .sidebar-panel.active { display: flex; flex-direction: column; }

    .saved-item {
      padding: 9px 12px;
      border-bottom: 1px solid var(--border2);
      cursor: pointer;
      transition: background 0.1s;
    }
    .saved-item:hover { background: var(--bg3); }
    .saved-item-title {
      font-size: var(--fs-sm); font-weight: 500;
      color: var(--text);
      white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    }
    .saved-item-meta {
      display: flex; align-items: center; gap: 6px;
      margin-top: 2px;
    }
    .saved-item-q {
      font-size: var(--fs-xs); color: var(--text3);
      white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
      flex: 1;
    }
    .saved-item-actions {
      display: flex; gap: 4px; opacity: 0;
      transition: opacity 0.15s;
    }
    .saved-item:hover .saved-item-actions { opacity: 1; }
    .saved-action-btn {
      padding: 1px 5px; font-size: 10px;
      border: 1px solid var(--border);
      border-radius: 3px;
      background: var(--bg2);
      color: var(--text3);
      cursor: pointer; font-family: var(--font);
    }
    .saved-action-btn:hover { color: var(--accent); border-color: var(--accent); }
    .saved-action-btn.del:hover { color: var(--red); border-color: var(--red); }
    .pin-star { color: var(--yellow); font-size: 11px; }
    .saved-empty {
      padding: 24px 12px; text-align: center;
      font-size: 12px; color: var(--text3);
    }

    /* ── Tooltips ──────────────────────────────────────── */
    /* Regla base: todos los tooltips salen desde el borde
       izquierdo del elemento hacia la derecha, alineados
       con el cursor natural. Sin centrado, sin transforms. */
    [data-tooltip] {
      position: relative;
    }
    [data-tooltip]::after {
      content: attr(data-tooltip);
      position: absolute;
      top: calc(100% + 6px);   /* debajo del elemento */
      left: 0;                 /* alineado al borde izquierdo */
      transform: none;
      background: var(--text);
      color: var(--bg2);
      font-size: 11px;
      font-family: var(--font);
      font-weight: 400;
      white-space: nowrap;
      padding: 4px 10px;
      border-radius: 5px;
      pointer-events: none;
      opacity: 0;
      transition: opacity 0.12s;
      z-index: 9000;
      box-shadow: 0 2px 8px rgba(0,0,0,0.18);
      line-height: 1.3;
      max-width: min(280px, 80vw);
    }
    [data-tooltip]:hover::after { opacity: 1; }

    /* Sin flecha — con posición "debajo-izquierda" no hace falta */
    [data-tooltip]::before { display: none; }

    /* Excepción: botones del header (theme, size, debug)
       donde hay espacio arriba y poco abajo */
    .header-right [data-tooltip]::after {
      top: auto;
      bottom: calc(100% + 6px);
      left: 0;
    }

    /* ── Table title bar ────────────────────────────────── */
    .table-title-bar {
      display: flex; align-items: baseline; gap: 10px;
      padding: 8px 16px 0;
      flex-shrink: 0;
    }
    .table-title {
      font-size: var(--fs-base); font-weight: 600;
      color: var(--text);
      white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
      max-width: 100%;
    }
    .table-subtitle {
      font-size: var(--fs-xs); color: var(--text3);
      white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    }
    /* ── Language switcher ────────────────────────────── */
    .lang-switcher {
      display: flex;
      background: var(--bg3);
      border: 1px solid var(--border);
      border-radius: 20px;
      padding: 2px;
      gap: 0;
      flex-shrink: 0;
    }
    .lang-btn {
      min-width: 30px;
      height: 26px;
      border: none;
      border-radius: 16px;
      background: transparent;
      color: var(--text3);
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: center;
      font-family: var(--font);
      font-size: 10px;
      font-weight: 700;
      letter-spacing: 0.04em;
      transition: background 0.15s, color 0.15s;
    }
    .lang-btn:hover { color: var(--text2); }
    .lang-btn.active {
      background: var(--bg2);
      color: var(--accent);
      box-shadow: 0 1px 3px rgba(0,0,0,0.15);
    }

    /* ══════════════════════════════════════════════════════
       MOBILE BOTTOM BAR — base
       ══════════════════════════════════════════════════════ */
    .mob-bar {
      display: none;
      position: fixed;
      left: 0;
      right: 0;
      bottom: 0;
      height: calc(52px + env(safe-area-inset-bottom));
      padding-bottom: env(safe-area-inset-bottom);
      background: var(--bg2);
      border-top: 1px solid var(--border);
      z-index: 7000;
      align-items: stretch;
      justify-content: stretch;
    }
    .mob-bar-btn {
      flex: 1;
      min-width: 0;
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 5px;
      border: none;
      border-right: 1px solid var(--border);
      background: transparent;
      color: var(--text2);
      font-family: var(--font);
      font-size: 11px;
      font-weight: 500;
      line-height: 1;
      cursor: pointer;
      transition: background 0.15s, color 0.15s;
      overflow: hidden;
    }
    .mob-bar-btn:last-child { border-right: none; }
    .mob-bar-btn:hover { background: var(--bg3); }
    .mob-bar-btn.active { color: var(--accent); }
    .mob-bar-btn svg {
      display: inline-block !important;
      width: 16px !important;
      height: 16px !important;
      min-width: 16px;
      min-height: 16px;
      flex: 0 0 16px;
      stroke: currentColor !important;
      fill: none !important;
      opacity: 1 !important;
      visibility: visible !important;
    }

    /* ══════════════════════════════════════════════════════
       RESPONSIVE — mobile/tablet (≤ 768px)
       ══════════════════════════════════════════════════════ */
    @media (max-width: 768px) {
      html, body {
        height: 100dvh;
        overflow: hidden;
      }
      .layout {
        grid-template-columns: 1fr;
        grid-template-rows: 48px minmax(0, 1fr);
        height: 100dvh;
        min-height: 100dvh;
        padding-bottom: 0;
      }
      .header {
        height: 48px;
        min-height: 48px;
        padding: 0 10px;
      }
      .header-logo img { height: 24px; }
      .header-sub { display: none; }
      .header-title { font-size: 12px; }
      .prompt-selector,
      #sizeSwitcher,
      #themeSwitcher,
      #debugToggleHeader { display: none; }
      .main {
        grid-column: 1;
        min-height: 0;
        overflow: hidden;
        padding-bottom: calc(52px + env(safe-area-inset-bottom));
      }
      .result-tabs {
        min-height: 38px;
        height: 38px;
        padding: 0 8px;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
      }
      .result-tabs::-webkit-scrollbar { display: none; }
      .result-tab {
        height: 38px;
        font-size: 11px;
        padding: 0 10px;
        flex-shrink: 0;
      }
      .tabs-right { flex-shrink: 0; }
      .result-pane {
        min-height: 0;
        overflow: hidden;
      }
      .result-pane.active { min-height: 0; }
      #paneEmpty {
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
      }
      .onboard {
        min-height: auto;
        justify-content: flex-start;
        padding: 24px 14px 90px;
        gap: 22px;
      }
      .onboard-hero { max-width: 100%; }
      .onboard-eyebrow {
        font-size: 10px;
        margin-bottom: 10px;
      }
      .onboard-hero h1 {
        font-size: 24px;
        line-height: 1.18;
      }
      .onboard-hero p { font-size: 13px; }
      .onboard-steps {
        grid-template-columns: 1fr;
        max-width: 100%;
        gap: 12px;
      }
      .ob-step { padding: 18px 16px 16px; }
      .ob-step:not(:last-child)::after { display: none; }
      .onboard-foot {
        padding-bottom: 20px;
        text-align: center;
        justify-content: center;
      }
      .sidebar {
        position: fixed;
        top: 48px;
        left: 0;
        bottom: calc(52px + env(safe-area-inset-bottom));
        width: min(var(--sidebar-w), 92vw);
        height: auto;
        z-index: 8000;
        transform: translateX(-100%);
        transition: transform 0.25s cubic-bezier(0.4,0,0.2,1);
        box-shadow: 4px 0 24px rgba(0,0,0,0.18);
      }
      .sidebar.mob-open { transform: translateX(0); }
      #mobBackdrop {
        display: none;
        position: fixed;
        inset: 0;
        top: 48px;
        bottom: calc(52px + env(safe-area-inset-bottom));
        background: rgba(0,0,0,0.4);
        z-index: 7999;
      }
      #mobBackdrop.visible { display: block; }
      .sidebar-panel,
      .sidebar-panel.active { min-height: 0; }
      .chat {
        min-height: 0;
        padding-bottom: 12px;
      }
      .sidebar-controls { flex-shrink: 0; }
      .chat-input {
        flex-shrink: 0;
        position: sticky;
        bottom: 0;
        z-index: 2;
        padding: 8px 10px;
        background: var(--bg2);
        box-shadow: 0 -4px 16px rgba(15, 23, 42, 0.06);
      }
      .chat-input textarea {
        min-height: 42px;
        max-height: 86px;
        font-size: 13px;
      }
      .btn-send {
        width: 40px;
        height: 40px;
      }
      #paneTable {
        min-width: 0;
        overflow: hidden;
      }
      .table-title-bar {
        padding: 8px 10px 0;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
      }
      .table-toolbar {
        padding: 8px 10px;
        gap: 6px;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
      }
      .table-toolbar input {
        min-width: 150px;
        max-width: none;
      }
      .table-info { flex-shrink: 0; }
      .table-wrap {
        flex: 1;
        min-height: 0;
        width: 100%;
        max-width: 100%;
        overflow-x: scroll;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
        touch-action: pan-x pan-y;
      }
      .data-table {
        width: max-content;
        min-width: max-content;
        table-layout: auto;
        border-collapse: collapse;
      }
      .data-table th,
      .data-table td {
        white-space: nowrap;
        min-width: 120px;
      }
      .data-table th.dimension,
      .data-table td.dimension { min-width: 180px; }
      .data-table th.metric,
      .data-table td.metric { min-width: 130px; }
      .data-table th:first-child,
      .data-table td:first-child {
        position: static;
        left: auto;
        z-index: auto;
        background: inherit;
      }
      #paneChart { overflow: hidden; }
      .chart-toolbar {
        padding: 8px 10px;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
      }
      .chart-toolbar::-webkit-scrollbar { display: none; }
      .chart-type-btn,
      .toolbar-btn { flex-shrink: 0; }
      .series-selector {
        padding: 8px 10px;
        overflow-x: auto;
        overflow-y: hidden;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
      }
      .series-selector::-webkit-scrollbar { display: none; }
      .series-group { flex-shrink: 0; }
      .series-pills { flex-wrap: nowrap; }
      .series-pill { flex-shrink: 0; }
      .chart-container {
        flex: 1;
        min-height: 0;
        padding: 10px;
        overflow: auto;
        -webkit-overflow-scrolling: touch;
      }
      .chart-container canvas { min-width: 640px; }
      .mob-bar { display: flex !important; }
      .mob-bar-btn {
        font-size: 10px;
        white-space: nowrap;
      }
      #debugDrawer {
        width: 100vw;
        max-width: 100vw;
      }
      #debugToggle { display: none !important; }
      #btnFullscreen { display: none !important; }
      .pivot-banner {
        flex-wrap: wrap;
        gap: 6px;
        padding: 7px 10px;
      }
    }

    /* Selector de sector */
    .sector-grid {
      display: grid;
      grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
      gap: 18px; 
      width: 100%; 
      max-width: 720px;
    }
    .sector-card {
      position: relative;
      background: var(--bg2);
      border: 2px solid var(--border);
      border-radius: var(--radius-lg);
      padding: 24px 20px 18px;
      cursor: pointer;
      display: flex; flex-direction: column; gap: 12px;
      transition: transform 0.2s, border-color 0.25s, box-shadow 0.25s;
      animation: ob-rise 0.5s cubic-bezier(0.16,1,0.3,1) both;
    }
    .sector-card:nth-child(1) { animation-delay: 0.08s; }
    .sector-card:nth-child(2) { animation-delay: 0.16s; }
    .sector-card:nth-child(3) { animation-delay: 0.24s; }
    .sector-card:nth-child(4) { animation-delay: 0.32s; }
    .sector-card:hover {
      transform: translateY(-4px);
      box-shadow: 0 12px 36px -10px rgba(0,0,0,0.18);
    }
    .sector-card:hover .sector-enter { opacity: 1; }
    .sector-card.active {
      border-color: var(--accent);
      box-shadow: 0 0 0 3px var(--accent-dim);
    }
    .sector-icon {
      font-size: 32px; line-height: 1;
    }
    .sector-card h3 {
      font-size: 17px; font-weight: 600; color: var(--text);
      display: flex; align-items: center; gap: 8px;
    }
    .sector-card p {
      font-size: 12.5px; color: var(--text2); line-height: 1.55;
    }
    .sector-examples {
      display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto;
    }
    .sector-examples .ob-eg {
      font-family: var(--mono); font-size: 10.5px;
      color: var(--accent); background: var(--accent-dim);
      border: 1px solid rgba(24,120,192,0.15);
      border-radius: 5px; padding: 4px 8px;
      cursor: pointer; line-height: 1.35;
      transition: background 0.15s, color 0.15s;
    }
    .sector-examples .ob-eg:hover {
      background: var(--accent); color: #fff;
    }
    .sector-enter {
      position: absolute; top: 14px; right: 14px;
      font-size: 11px; font-weight: 500; color: var(--accent);
      opacity: 0; transition: opacity 0.2s;
      display: flex; align-items: center; gap: 4px;
    }
    .sector-badge {
      display: inline-block; font-size: 10px; font-weight: 600;
      letter-spacing: 0.06em; text-transform: uppercase;
      padding: 2px 7px; border-radius: 4px;
      color: #fff;
    }
    .sector-steps-mini {
      display: flex; gap: 16px; align-items: flex-start;
      max-width: 720px; animation: ob-rise 0.5s 0.3s cubic-bezier(0.16,1,0.3,1) both;
    }
    .step-mini {
      display: flex; align-items: center; gap: 8px;
      font-size: 12px; color: var(--text3);
    }
    .step-mini .step-num {
      width: 22px; height: 22px; border-radius: 6px;
      background: var(--brand-grad);
      color: #fff; font-family: var(--mono); font-size: 10px; font-weight: 600;
      display: flex; align-items: center; justify-content: center;
      flex-shrink: 0;
    }
    
    .empty-mode {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
}

.onboard-sector-switch {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg2);
  animation: ob-rise 0.5s cubic-bezier(0.16,1,0.3,1) both;
}

.onboard-sector-switch > span:first-child {
  padding: 0 8px;
  font-size: 11px;
  color: var(--text3);
  white-space: nowrap;
}

.sector-mini-btn {
  height: 30px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: var(--text2);
  font-family: var(--font);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.sector-mini-btn:hover {
  color: var(--accent);
  background: var(--accent-dim);
}

.sector-mini-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

@media (max-width: 768px) {
  .empty-mode {
    gap: 20px;
  }

  .onboard-sector-switch {
    width: 100%;
    justify-content: center;
    flex-wrap: wrap;
    border-radius: var(--radius-lg);
    padding: 8px;
  }

  .onboard-sector-switch > span:first-child {
    width: 100%;
    text-align: center;
    padding-bottom: 2px;
  }

  .sector-mini-btn {
    flex: 1;
    justify-content: center;
  }
}

.cookie-panel {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 10050;
  display: flex;
  justify-content: flex-end;
  pointer-events: none;
}

.cookie-panel-inner {
  width: min(520px, 100%);
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 18px 60px rgba(0,0,0,0.24);
  padding: 16px;
  pointer-events: auto;
}

.cookie-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
}

.cookie-text {
  font-size: 12px;
  color: var(--text2);
  line-height: 1.55;
  margin-bottom: 12px;
}

.cookie-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-bottom: 8px;
}

.cookie-btn {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 12px;
  font-weight: 600;
  padding: 7px 12px;
  cursor: pointer;
}

.cookie-btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.cookie-btn.secondary {
  background: var(--bg3);
  color: var(--text2);
}

.cookie-link {
  font-size: 11px;
  color: var(--accent);
  text-decoration: none;
}

.cookie-link:hover {
  text-decoration: underline;
}

.cookie-settings-btn {
  position: fixed;
  right: 10px;
  bottom: 10px;
  z-index: 7001;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg2);
  color: var(--text3);
  font-size: 10px;
  font-family: var(--font);
  padding: 5px 9px;
  cursor: pointer;
  opacity: 0.75;
}

.cookie-settings-btn:hover {
  opacity: 1;
  color: var(--accent);
  border-color: var(--accent);
}

@media (max-width: 768px) {
  .cookie-panel {
    left: 10px;
    right: 10px;
    bottom: calc(62px + env(safe-area-inset-bottom));
  }

  .cookie-actions {
    flex-direction: column-reverse;
  }

  .cookie-btn {
    width: 100%;
  }

.cookie-settings-btn {
  right: 10px;
  bottom: calc(58px + env(safe-area-inset-bottom));
}

}

.cookie-link-btn {
  border: 0;
  background: transparent;
  padding: 0;
  font-family: var(--font);
  cursor: pointer;
}

.cookie-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 10080;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(0,0,0,0.46);
  backdrop-filter: blur(4px);
}

.cookie-modal {
  width: min(760px, 100%);
  max-height: min(760px, calc(100dvh - 36px));
  display: flex;
  flex-direction: column;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 80px rgba(0,0,0,0.32);
  overflow: hidden;
}

.cookie-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}

.cookie-modal-header h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
}

.cookie-modal-close {
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg3);
  color: var(--text2);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.cookie-modal-close:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.cookie-modal-body {
  padding: 18px;
  overflow-y: auto;
  color: var(--text2);
  font-size: 13px;
  line-height: 1.58;
}

.cookie-modal-body section + section {
  margin-top: 18px;
}

.cookie-modal-body h3 {
  margin: 0 0 7px;
  font-size: 14px;
  color: var(--text);
}

.cookie-modal-body p {
  margin: 0;
}

.cookie-table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.cookie-policy-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 680px;
  background: var(--bg2);
}

.cookie-policy-table th,
.cookie-policy-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
  font-size: 12px;
}

.cookie-policy-table th {
  color: var(--text);
  background: var(--bg3);
  font-weight: 700;
}

.cookie-policy-table tr:last-child td {
  border-bottom: 0;
}

.cookie-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 18px;
  border-top: 1px solid var(--border);
  background: var(--bg2);
}

.cookie-modal-open {
  overflow: hidden;
}

@media (max-width: 768px) {
  .cookie-modal-backdrop {
    align-items: flex-end;
    padding: 10px;
    padding-bottom: calc(10px + env(safe-area-inset-bottom));
  }

  .cookie-modal {
    max-height: calc(100dvh - 80px);
    border-radius: 18px;
  }

  .cookie-modal-footer {
    flex-direction: column-reverse;
  }

  .cookie-modal-footer .cookie-btn {
    width: 100%;
  }
}