/* ==========================================================================
   PacketLens — Diagnóstico de red
   Tokens de diseño (oscuro por defecto, claro con [data-theme="light"])
   ========================================================================== */
:root {
    color-scheme: dark;

    --bg: #07090d;
    --bg-2: #0a0d12;
    --surface: #0d1117;
    --surface-2: #121821;
    --surface-3: #18202b;
    --input-bg: #090c11;
    --border: rgba(255, 255, 255, 0.07);
    --border-strong: rgba(255, 255, 255, 0.13);
    --row-border: rgba(255, 255, 255, 0.045);
    --hover: rgba(255, 255, 255, 0.03);
    --dash: rgba(255, 255, 255, 0.12);

    --text-strong: #ffffff;
    --text: #e6edf3;
    --text-2: #a3afbd;
    --muted: #6b7785;
    --placeholder: #4b5562;

    --cyan: #22d3ee;
    --cyan-soft: rgba(34, 211, 238, 0.12);
    --cyan-border: rgba(34, 211, 238, 0.45);
    --cyan-glow: rgba(34, 211, 238, 0.45);
    --green: #3dff8a;
    --green-soft: rgba(61, 255, 138, 0.12);
    --btn-primary-bg: #3dff8a;
    --btn-primary-hover: #6bffa7;
    --btn-primary-text: #04130a;
    --btn-primary-shadow: 0 0 0 1px rgba(61, 255, 138, 0.4), 0 6px 20px -6px rgba(61, 255, 138, 0.55);

    --critical: #ef4b5b;
    --critical-ink: #ff8a95;
    --critical-soft: rgba(239, 75, 91, 0.12);
    --critical-border: rgba(239, 75, 91, 0.35);
    --warning: #fab219;
    --warning-ink: #ffd277;
    --warning-soft: rgba(250, 178, 25, 0.12);
    --warning-border: rgba(250, 178, 25, 0.32);
    --ok: #3ddc84;
    --ok-soft: rgba(61, 220, 132, 0.1);

    --wm-1: #ffffff;
    --wm-2: #3dff8a;
    --wm-glow-1: 0 0 18px rgba(34, 211, 238, 0.45), 0 0 42px rgba(34, 211, 238, 0.18);
    --wm-glow-2: 0 0 18px rgba(61, 255, 138, 0.45), 0 0 42px rgba(61, 255, 138, 0.18);

    --landing-glow-1: rgba(34, 211, 238, 0.10);
    --landing-glow-2: rgba(61, 255, 138, 0.08);
    --grid-line: rgba(255, 255, 255, 0.035);
    --dz-bg: linear-gradient(180deg, rgba(18, 24, 33, 0.85), rgba(10, 13, 18, 0.85));
    --topbar-bg: rgba(7, 9, 13, 0.92);
    --backdrop: rgba(3, 5, 8, 0.6);
    --tip-bg: #0b0f15;
    --scroll: #1f2833;
    --scroll-hover: #2a3644;
    --shadow: 0 1px 0 rgba(255, 255, 255, 0.03) inset, 0 12px 32px -12px rgba(0, 0, 0, 0.6);
    --shadow-pop: 0 10px 30px -10px rgba(0, 0, 0, 0.8);

    --json-bg: #070a0e;
    --j-key: #7dd3fc;
    --j-str: #86efac;
    --j-num: #fcd34d;
    --j-bool: #f0abfc;
    --j-punc: #4b5562;

    --radius: 14px;
    --radius-sm: 9px;
    --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Code", Menlo, Consolas, monospace;
    --topbar-h: 64px;
    --sidebar-w: 272px;
}

[data-theme="light"] {
    color-scheme: light;

    --bg: #f4f6f9;
    --bg-2: #ffffff;
    --surface: #ffffff;
    --surface-2: #f3f5f8;
    --surface-3: #e7ebf0;
    --input-bg: #ffffff;
    --border: rgba(15, 23, 42, 0.08);
    --border-strong: rgba(15, 23, 42, 0.15);
    --row-border: rgba(15, 23, 42, 0.06);
    --hover: rgba(15, 23, 42, 0.035);
    --dash: rgba(15, 23, 42, 0.18);

    --text-strong: #0b1220;
    --text: #1e293b;
    --text-2: #475569;
    --muted: #64748b;
    --placeholder: #94a3b8;

    --cyan: #0e7490;
    --cyan-soft: rgba(8, 145, 178, 0.10);
    --cyan-border: rgba(8, 145, 178, 0.45);
    --cyan-glow: rgba(8, 145, 178, 0.25);
    --green: #047857;
    --green-soft: rgba(16, 185, 129, 0.12);
    --btn-primary-bg: #19c37d;
    --btn-primary-hover: #2ad38d;
    --btn-primary-text: #04130a;
    --btn-primary-shadow: 0 0 0 1px rgba(4, 120, 87, 0.25), 0 6px 18px -8px rgba(4, 120, 87, 0.55);

    --critical: #d03b3b;
    --critical-ink: #c42b3c;
    --critical-soft: rgba(208, 59, 59, 0.09);
    --critical-border: rgba(208, 59, 59, 0.35);
    --warning: #eda100;
    --warning-ink: #9a6200;
    --warning-soft: rgba(237, 161, 0, 0.12);
    --warning-border: rgba(237, 161, 0, 0.4);
    --ok: #0a8a4a;
    --ok-soft: rgba(10, 138, 74, 0.1);

    --wm-1: #0b1220;
    --wm-2: #0a9e5c;
    --wm-glow-1: none;
    --wm-glow-2: none;

    --landing-glow-1: rgba(8, 145, 178, 0.10);
    --landing-glow-2: rgba(16, 185, 129, 0.09);
    --grid-line: rgba(15, 23, 42, 0.05);
    --dz-bg: linear-gradient(180deg, #ffffff, #f8fafc);
    --topbar-bg: rgba(255, 255, 255, 0.94);
    --backdrop: rgba(15, 23, 42, 0.35);
    --tip-bg: #ffffff;
    --scroll: #cbd5e1;
    --scroll-hover: #94a3b8;
    --shadow: 0 1px 2px rgba(15, 23, 42, 0.05), 0 8px 24px -14px rgba(15, 23, 42, 0.18);
    --shadow-pop: 0 12px 32px -12px rgba(15, 23, 42, 0.3);

    --json-bg: #f8fafc;
    --j-key: #0369a1;
    --j-str: #15803d;
    --j-num: #b45309;
    --j-bool: #a21caf;
    --j-punc: #94a3b8;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.45;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
}
body.app-mode { overflow: hidden; }
.hidden { display: none !important; }
.mono { font-family: var(--mono); }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
a { color: inherit; }
svg { flex: none; }
:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--scroll); border-radius: 10px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--scroll-hover); }
* { scrollbar-color: var(--scroll) transparent; scrollbar-width: thin; }

/* ==========================================================================
   Wordmark
   ========================================================================== */
.wordmark {
    margin: 0;
    font-weight: 850;
    letter-spacing: -0.03em;
    text-transform: uppercase;
    line-height: 0.95;
    color: var(--wm-1);
    text-shadow: var(--wm-glow-1);
    white-space: nowrap;
}
.wordmark span { color: var(--wm-2); text-shadow: var(--wm-glow-2); }
.wordmark.sm { font-size: 1.3rem; }
.wordmark.xl { font-size: clamp(3rem, 7vw, 5.2rem); }
.wordmark.xl span { display: block; }

@keyframes flicker-in {
    0% { opacity: 0; }
    8% { opacity: 1; }
    12% { opacity: 0.35; }
    18% { opacity: 1; }
    22% { opacity: 0.6; }
    30%, 100% { opacity: 1; }
}
.flicker { animation: flicker-in 1.6s ease-out both; }

/* ==========================================================================
   Buttons + preference controls
   ========================================================================== */
.btn {
    display: inline-flex; align-items: center; gap: 8px;
    height: 36px; padding: 0 14px;
    border-radius: var(--radius-sm);
    font-size: 13px; font-weight: 600;
    transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
    white-space: nowrap;
}
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--btn-primary-bg); color: var(--btn-primary-text); box-shadow: var(--btn-primary-shadow); }
.btn-primary:hover { background: var(--btn-primary-hover); }
.btn-secondary { background: var(--surface-2); border: 1px solid var(--border-strong); color: var(--text); }
.btn-secondary:hover { border-color: var(--cyan-border); color: var(--text-strong); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 12px; }
.btn-icon {
    display: inline-grid; place-items: center;
    width: 36px; height: 36px; border-radius: var(--radius-sm);
    color: var(--text-2); border: 1px solid transparent;
}
.btn-icon:hover { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.btn-icon svg { width: 18px; height: 18px; }
.link-btn { color: var(--cyan); font-size: 12px; font-weight: 600; padding: 2px 4px; border-radius: 6px; }
.link-btn:hover { text-decoration: underline; }

.prefs { display: inline-flex; align-items: center; gap: 6px; }
.lang-switch {
    display: inline-grid; grid-template-columns: 1fr 1fr; gap: 2px;
    padding: 3px; border-radius: 999px;
    background: var(--surface); border: 1px solid var(--border-strong);
}
.lang-switch button {
    min-width: 32px; height: 26px; padding: 0 8px; border-radius: 999px;
    font-size: 11.5px; font-weight: 700; letter-spacing: 0.04em; color: var(--muted);
}
.lang-switch button:hover { color: var(--text); }
.lang-switch button[aria-pressed="true"] { background: var(--cyan-soft); color: var(--cyan); box-shadow: inset 0 0 0 1px var(--cyan-border); }
.theme-btn { border-color: var(--border-strong); background: var(--surface); border-radius: 999px; }
.theme-btn .i-moon { display: none; }
[data-theme="light"] .theme-btn .i-sun { display: none; }
[data-theme="light"] .theme-btn .i-moon { display: block; }

/* ==========================================================================
   Landing
   ========================================================================== */
.landing { position: relative; min-height: 100vh; display: flex; flex-direction: column; overflow: hidden; }
.landing-bg {
    position: absolute; inset: 0; z-index: 0; pointer-events: none;
    background:
        radial-gradient(900px 520px at 12% 8%, var(--landing-glow-1), transparent 60%),
        radial-gradient(800px 520px at 92% 92%, var(--landing-glow-2), transparent 60%);
}
.landing-bg::after {
    content: ""; position: absolute; inset: 0;
    background-image:
        linear-gradient(var(--grid-line) 1px, transparent 1px),
        linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
    background-size: 44px 44px;
    -webkit-mask-image: radial-gradient(ellipse at center, #000 20%, transparent 75%);
            mask-image: radial-gradient(ellipse at center, #000 20%, transparent 75%);
}
.landing > * { position: relative; z-index: 1; }

.landing-top, .landing-foot {
    display: flex; align-items: center; justify-content: space-between;
    width: 100%; max-width: 1180px; margin: 0 auto; padding: 22px 28px;
}
.landing-foot { color: var(--muted); font-size: 12px; justify-content: center; gap: 10px; }
.landing-foot a { color: var(--text-2); text-decoration: none; }
.landing-foot a:hover { color: var(--cyan); }

.hero {
    flex: 1;
    display: grid; grid-template-columns: 1.05fr 1fr; gap: 64px; align-items: center;
    width: 100%; max-width: 1180px; margin: 0 auto; padding: 24px 28px 48px;
}
.eyebrow {
    display: inline-flex; align-items: center; gap: 8px;
    font-size: 11.5px; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase;
    color: var(--cyan);
    padding: 6px 12px; border-radius: 999px;
    background: var(--cyan-soft); border: 1px solid var(--cyan-border);
    margin-bottom: 22px;
}
.pulse-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); animation: pulse 2.4s infinite; }
@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(61, 255, 138, 0.55); }
    70% { box-shadow: 0 0 0 8px rgba(61, 255, 138, 0); }
    100% { box-shadow: 0 0 0 0 rgba(61, 255, 138, 0); }
}
.lead { margin: 26px 0 30px; max-width: 30em; font-size: 17px; line-height: 1.6; color: var(--text-2); }

.features { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.features li { display: flex; gap: 14px; align-items: flex-start; }
.feat-icon {
    flex: none; display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px;
    background: var(--surface); border: 1px solid var(--border-strong); color: var(--cyan);
}
.feat-icon svg { width: 18px; height: 18px; }
.features strong { display: block; font-size: 14px; font-weight: 600; color: var(--text); }
.features div span { font-size: 13px; color: var(--muted); }


/* Drop zone */
.drop-panel { display: flex; flex-direction: column; gap: 14px; }
.dropzone {
    position: relative;
    display: grid; place-items: center; text-align: center;
    min-height: 340px; padding: 36px;
    border-radius: 22px;
    background: var(--dz-bg);
    border: 1px solid var(--border-strong);
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: border-color .2s, box-shadow .2s, transform .2s;
}
.dropzone::before {
    content: ""; position: absolute; inset: 12px; border-radius: 14px;
    border: 1.5px dashed var(--dash);
    transition: border-color .2s;
    pointer-events: none;
}
.dropzone:hover::before, .dropzone.drag::before { border-color: var(--cyan-border); }
.dropzone:hover { box-shadow: var(--shadow), 0 0 60px -20px var(--cyan-glow); }
.dropzone.drag { transform: scale(1.01); box-shadow: var(--shadow), 0 0 0 1px var(--cyan-border), 0 0 80px -16px var(--cyan-glow); }
.dropzone.busy { cursor: progress; }
.dz-state { display: flex; flex-direction: column; align-items: center; gap: 10px; width: 100%; max-width: 400px; }
.dz-icon {
    display: grid; place-items: center; width: 64px; height: 64px; border-radius: 18px; margin-bottom: 8px;
    color: var(--cyan); background: var(--cyan-soft); border: 1px solid var(--cyan-border);
    transition: transform .2s;
}
.dz-icon svg { width: 28px; height: 28px; }
.dropzone:hover .dz-icon, .dropzone.drag .dz-icon { transform: translateY(-3px); }
.dz-title { margin: 0; font-size: 17px; font-weight: 600; color: var(--text-strong); }
.dz-sub { margin: 0; color: var(--text-2); font-size: 14px; }
.dz-sub .link { color: var(--green); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.dz-hint {
    margin-top: 14px; font-size: 12px; color: var(--muted);
    padding: 8px 12px; border-radius: 8px; background: var(--hover); border: 1px solid var(--border);
}
.dz-hint b { color: var(--text-2); font-weight: 500; }
.dz-file { margin: 0; font-size: 12px; color: var(--muted); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dz-error-icon { color: var(--critical); background: var(--critical-soft); border-color: var(--critical-border); }
.dz-error-msg { margin: 0; color: var(--text-2); font-size: 13px; }

.progress { width: 100%; height: 6px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--border); overflow: hidden; margin-top: 6px; }
.progress-fill {
    height: 100%; width: 0%;
    background: linear-gradient(90deg, var(--cyan), var(--green));
    box-shadow: 0 0 14px var(--cyan-glow);
    transition: width .15s linear;
}
.spinner {
    width: 44px; height: 44px; border-radius: 50%; margin-bottom: 8px;
    border: 3px solid var(--cyan-soft); border-top-color: var(--cyan);
    animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.sample-btn {
    align-self: center;
    display: inline-flex; align-items: center; gap: 8px;
    font-size: 13px; font-weight: 500; color: var(--text-2);
    padding: 8px 14px; border-radius: 999px;
}
.sample-btn:hover { color: var(--text-strong); background: var(--surface); }
.sample-btn svg { width: 15px; height: 15px; color: var(--green); }

/* ==========================================================================
   App shell
   ========================================================================== */
.app { height: 100vh; display: grid; grid-template-rows: var(--topbar-h) 1fr; }
.topbar {
    position: relative;
    display: flex; align-items: center; justify-content: space-between; gap: 16px;
    padding: 0 20px;
    background: var(--topbar-bg);
    border-bottom: 1px solid var(--border);
    z-index: 20;
}
.topbar::after {
    content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 1px;
    background: linear-gradient(90deg, transparent, var(--cyan) 30%, var(--green) 70%, transparent);
    opacity: 0.5;
}
.topbar-left { display: flex; align-items: center; gap: 18px; min-width: 0; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.topbar-actions .prefs { margin-right: 6px; }
.file-chip {
    display: inline-flex; align-items: center; gap: 8px; min-width: 0;
    padding: 6px 12px; border-radius: 999px;
    background: var(--surface); border: 1px solid var(--border);
    font-size: 12.5px; color: var(--text-2);
}
.file-chip svg { width: 14px; height: 14px; color: var(--cyan); }
.file-chip .file-name { color: var(--text); max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-chip .sep { color: var(--muted); }

.layout { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 0; }

/* Sidebar */
.sidebar {
    display: flex; flex-direction: column; gap: 18px;
    padding: 20px 18px;
    background: var(--bg-2);
    border-right: 1px solid var(--border);
    overflow-y: auto;
}
.side-head { display: flex; align-items: center; justify-content: space-between; }
.side-head h2 {
    margin: 0; font-size: 11.5px; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase; color: var(--cyan);
    display: flex; align-items: center; gap: 8px;
}
.side-head h2 svg { width: 14px; height: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span { font-size: 12px; font-weight: 500; color: var(--text-2); }
.field-row { display: grid; grid-template-columns: 1fr 88px; gap: 10px; }
.input-wrap { position: relative; }
.input-wrap svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 14px; height: 14px; color: var(--muted); pointer-events: none; }
input[type="text"], select {
    width: 100%; height: 36px; padding: 0 11px;
    background: var(--input-bg); border: 1px solid var(--border-strong); border-radius: 8px;
    color: var(--text); font-size: 13px; outline: none;
    transition: border-color .15s, box-shadow .15s;
}
.input-wrap input[type="text"] { padding-left: 32px; }
input[type="text"].mono { font-family: var(--mono); font-size: 12.5px; }
input::placeholder { color: var(--placeholder); }
input[type="text"]:focus, select:focus { border-color: var(--cyan-border); box-shadow: 0 0 0 3px var(--cyan-soft); }
select {
    appearance: none; -webkit-appearance: none; cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7785' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 10px center; padding-right: 28px;
}

.chips { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 5px; }
.chip {
    height: 28px; padding: 0 4px; border-radius: 999px;
    font-family: var(--mono); font-size: 11px; font-weight: 600; letter-spacing: 0.02em;
    color: var(--text-2); background: var(--surface); border: 1px solid var(--border-strong);
    transition: all .15s;
}
.chip:hover { color: var(--text); border-color: var(--cyan-border); }
.chip[aria-pressed="true"] { color: var(--cyan); background: var(--cyan-soft); border-color: var(--cyan-border); }
.chip[data-flag="RST"][aria-pressed="true"] { color: var(--critical-ink); background: var(--critical-soft); border-color: var(--critical-border); }

.segmented {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px;
    padding: 3px; border-radius: 10px; background: var(--input-bg); border: 1px solid var(--border-strong);
}
.segmented button {
    height: 30px; border-radius: 7px; font-size: 12px; font-weight: 600; color: var(--text-2);
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.segmented button:hover { color: var(--text); }
.segmented button[aria-pressed="true"] { background: var(--surface-3); color: var(--text-strong); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25); }
.segmented .sev-dot { width: 7px; height: 7px; border-radius: 50%; }

.side-foot { margin-top: auto; padding-top: 16px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; align-items: center; text-align: center; }
.privacy { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); letter-spacing: 0.04em; }
.privacy svg { width: 13px; height: 13px; color: var(--green); }
.byline { font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); }
.byline strong { color: var(--cyan); font-weight: 700; text-shadow: 0 0 10px var(--cyan-glow); }
[data-theme="light"] .byline strong { text-shadow: none; }

/* Main column */
.main { position: relative; overflow-y: auto; padding: 22px 24px 40px; display: flex; flex-direction: column; gap: 18px; min-width: 0; }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    min-width: 0;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px 6px; flex-wrap: wrap; }
.card-head h3 { margin: 0; font-size: 13.5px; font-weight: 600; color: var(--text); }
.card-sub { font-size: 12px; font-weight: 400; color: var(--muted); }
.chart-wrap { position: relative; height: 200px; padding: 4px 12px 12px; }
.chart-wrap.tall { height: 176px; }

/* KPIs */
.kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px; }
.kpi { position: relative; overflow: hidden; padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; }
.kpi-top { display: flex; align-items: center; justify-content: space-between; }
.kpi-label { font-size: 11px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.kpi-icon { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 8px; color: var(--cyan); background: var(--cyan-soft); }
.kpi-icon svg { width: 14px; height: 14px; }
.kpi-value { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; color: var(--text-strong); line-height: 1.15; margin-top: 4px; }
.kpi-sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi::after { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 2px; background: transparent; }
.kpi.is-critical .kpi-icon { color: var(--critical-ink); background: var(--critical-soft); }
.kpi.is-warning .kpi-icon { color: var(--warning-ink); background: var(--warning-soft); }
.kpi.is-green .kpi-icon { color: var(--green); background: var(--green-soft); }
.kpi.is-critical.has-value::after { background: var(--critical); box-shadow: 0 0 12px var(--critical); }
.kpi.is-warning.has-value::after { background: var(--warning); box-shadow: 0 0 12px var(--warning); }
.kpi.is-critical.has-value .kpi-value { color: var(--critical-ink); }
.kpi.is-warning.has-value .kpi-value { color: var(--warning-ink); }

.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }

.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--text-2); }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend-swatch { width: 10px; height: 10px; border-radius: 3px; }
.legend-item b { font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }

/* Table */
.table-card { display: flex; flex-direction: column; }
.active-filters { display: flex; gap: 6px; flex-wrap: wrap; }
.af-chip {
    display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 4px 0 9px;
    border-radius: 999px; font-size: 11.5px; color: var(--text);
    background: var(--cyan-soft); border: 1px solid var(--cyan-border);
}
.af-chip b { font-weight: 500; color: var(--text-2); }
.af-chip button { display: grid; place-items: center; width: 16px; height: 16px; border-radius: 50%; color: var(--text-2); }
.af-chip button:hover { background: var(--hover); color: var(--text-strong); }
.af-chip svg { width: 10px; height: 10px; }

.table-scroll { overflow-x: auto; border-top: 1px solid var(--border); margin-top: 8px; }
table.ptable { width: 100%; border-collapse: collapse; font-size: 12.5px; min-width: 1060px; }
.ptable th {
    text-align: left; font-weight: 600; font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase;
    color: var(--muted); background: var(--surface-2);
    padding: 10px 12px; border-bottom: 1px solid var(--border);
    white-space: nowrap; cursor: help;
}
.ptable th:first-child { padding-left: 16px; }
.ptable td {
    padding: 0 12px; height: 40px;
    border-bottom: 1px solid var(--row-border);
    color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 240px;
    font-variant-numeric: tabular-nums;
}
.ptable td:first-child { padding-left: 16px; }
.ptable tbody tr { cursor: pointer; transition: background .1s; }
.ptable tbody tr:hover { background: var(--cyan-soft); }
.ptable tbody tr:focus-visible { outline: none; background: var(--cyan-soft); }
.ptable tbody tr.lvl-critical { background: var(--critical-soft); box-shadow: inset 3px 0 0 var(--critical); }
.ptable tbody tr.lvl-warning { background: var(--warning-soft); box-shadow: inset 3px 0 0 var(--warning); }
.ptable tbody tr.lvl-critical:hover, .ptable tbody tr.lvl-warning:hover { filter: brightness(1.15); }
[data-theme="light"] .ptable tbody tr.lvl-critical:hover, [data-theme="light"] .ptable tbody tr.lvl-warning:hover { filter: brightness(0.97); }
.ptable .c-no { color: var(--muted); font-family: var(--mono); font-size: 11.5px; }
.ptable .c-num { font-family: var(--mono); font-size: 12px; color: var(--text-2); }
.ptable .c-ip { font-family: var(--mono); font-size: 12px; }
.ptable .c-host { color: var(--cyan); }
.ptable .c-host.inferred { color: var(--text-2); }
.ptable .c-dim { color: var(--placeholder); }
.proto-tag {
    display: inline-block; padding: 2px 7px; border-radius: 6px;
    font-family: var(--mono); font-size: 11px; font-weight: 600;
    color: var(--text); background: var(--surface-3); border: 1px solid var(--border);
}
.flags { font-family: var(--mono); font-size: 11.5px; color: var(--text-2); }
.flags .f-rst { color: var(--critical-ink); font-weight: 700; }
.flags .f-syn { color: var(--cyan); }
.flags .f-fin { color: var(--warning-ink); }

.badge {
    display: inline-flex; align-items: center; gap: 6px;
    height: 22px; padding: 0 9px; border-radius: 999px;
    font-size: 11.5px; font-weight: 600; white-space: nowrap;
    border: 1px solid transparent;
}
.badge svg { width: 12px; height: 12px; }
.badge.ok { color: var(--muted); background: var(--hover); border-color: var(--border); }
.badge.warning { color: var(--warning-ink); background: var(--warning-soft); border-color: var(--warning-border); }
.badge.critical { color: var(--critical-ink); background: var(--critical-soft); border-color: var(--critical-border); }

.table-foot {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 10px 16px; border-top: 1px solid var(--border); font-size: 12px; color: var(--muted);
}
.pager { display: flex; align-items: center; gap: 6px; }
.pager .btn-icon { width: 30px; height: 30px; border: 1px solid var(--border); }
.pager .btn-icon:disabled { opacity: 0.35; cursor: default; background: none; }
.pager span { font-variant-numeric: tabular-nums; color: var(--text-2); }

.empty { padding: 48px 16px; text-align: center; color: var(--muted); }
.empty strong { display: block; color: var(--text); font-size: 14px; margin-bottom: 4px; }

/* ==========================================================================
   Packet drawer
   ========================================================================== */
.drawer-backdrop {
    position: fixed; inset: 0; z-index: 40;
    background: var(--backdrop);
    -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
    opacity: 0; transition: opacity .2s;
}
.drawer-backdrop.open { opacity: 1; }
.drawer {
    position: fixed; top: 0; right: 0; bottom: 0; z-index: 50;
    width: min(620px, 100vw);
    display: flex; flex-direction: column;
    background: var(--bg-2);
    border-left: 1px solid var(--border-strong);
    box-shadow: var(--shadow-pop);
    transform: translateX(100%); transition: transform .25s cubic-bezier(.2, .8, .2, 1);
    visibility: hidden;
}
.drawer.open { transform: translateX(0); visibility: visible; }
.drawer-head {
    display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
    padding: 18px 20px 16px; border-bottom: 1px solid var(--border);
}
.drawer-kicker { margin: 0 0 4px; font-size: 11px; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; color: var(--cyan); }
.drawer-title { margin: 0; font-family: var(--mono); font-size: 15px; font-weight: 600; color: var(--text-strong); word-break: break-all; }
.drawer-title .arrow { color: var(--muted); margin: 0 6px; }
.drawer-body { flex: 1; overflow-y: auto; padding: 18px 20px 28px; display: flex; flex-direction: column; gap: 18px; }
.drawer-body > * { flex-shrink: 0; }
.drawer h4 { margin: 0; font-size: 11.5px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }

.kv-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.kv { background: var(--surface); padding: 10px 12px; min-width: 0; }
.kv span { display: block; font-size: 11px; color: var(--muted); margin-bottom: 2px; }
.kv b { display: block; font-family: var(--mono); font-size: 12.5px; font-weight: 500; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.issues { display: flex; flex-direction: column; gap: 8px; }
.issue {
    display: flex; gap: 12px; align-items: flex-start;
    padding: 12px 14px; border-radius: 12px; border: 1px solid var(--border);
    background: var(--surface);
}
.issue.critical { border-color: var(--critical-border); background: linear-gradient(90deg, var(--critical-soft), var(--surface) 70%); }
.issue.warning { border-color: var(--warning-border); background: linear-gradient(90deg, var(--warning-soft), var(--surface) 70%); }
.issue.ok { color: var(--text-2); }
.issue-icon { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; flex: none; }
.issue.critical .issue-icon { color: var(--critical-ink); background: var(--critical-soft); }
.issue.warning .issue-icon { color: var(--warning-ink); background: var(--warning-soft); }
.issue.ok .issue-icon { color: var(--ok); background: var(--ok-soft); }
.issue-icon svg { width: 15px; height: 15px; }
.issue strong { display: block; font-size: 13.5px; color: var(--text-strong); margin-bottom: 2px; }
.issue p { margin: 0; font-size: 12.5px; color: var(--text-2); line-height: 1.5; }

.layers-head { display: flex; align-items: center; justify-content: space-between; }
.layers { display: flex; flex-direction: column; gap: 6px; }
.layer { border: 1px solid var(--border); border-radius: 10px; background: var(--surface); overflow: hidden; }
.layer summary {
    list-style: none; cursor: pointer;
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px; font-size: 12.5px; font-weight: 600; color: var(--text);
}
.layer summary::-webkit-details-marker { display: none; }
.layer summary .chev { width: 14px; height: 14px; color: var(--muted); transition: transform .15s; }
.layer[open] summary .chev { transform: rotate(90deg); }
.layer summary .proto-tag { font-size: 11px; }
.layer summary .layer-meta { margin-left: auto; font-size: 11px; font-weight: 500; color: var(--muted); }
.layer summary:hover { background: var(--hover); }
.json {
    margin: 0; padding: 12px 14px; border-top: 1px solid var(--border);
    background: var(--json-bg);
    font-family: var(--mono); font-size: 12px; line-height: 1.6; color: var(--text-2);
    white-space: pre-wrap; word-break: break-all;
    max-height: 420px; overflow: auto;
}
.j-key { color: var(--j-key); }
.j-str { color: var(--j-str); }
.j-num { color: var(--j-num); }
.j-bool { color: var(--j-bool); }
.j-punc { color: var(--j-punc); }

/* Tooltip + toast */
.tip {
    position: fixed; z-index: 100; pointer-events: none;
    max-width: 240px; padding: 7px 10px; border-radius: 8px;
    background: var(--tip-bg); border: 1px solid var(--cyan-border);
    color: var(--text); font-size: 12px; line-height: 1.4; font-weight: 400; letter-spacing: 0; text-transform: none;
    box-shadow: var(--shadow-pop);
    opacity: 0; transform: translateY(4px); transition: opacity .12s, transform .12s;
}
.tip.show { opacity: 1; transform: translateY(0); }
.toast {
    position: fixed; left: 50%; bottom: 24px; z-index: 120;
    transform: translateX(-50%);
    display: inline-flex; align-items: center; gap: 8px;
    padding: 10px 16px; border-radius: 999px;
    background: var(--surface-3); border: 1px solid var(--border-strong);
    font-size: 13px; color: var(--text); box-shadow: var(--shadow-pop);
}
.toast svg { width: 15px; height: 15px; color: var(--green); }

.only-mobile { display: none; }

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 1280px) {
    .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 1100px) {
    .grid-3 { grid-template-columns: 1fr 1fr; }
    .grid-3 .card:last-child { grid-column: span 2; }
    .file-chip { display: none; }
}
@media (max-width: 960px) {
    .hero { grid-template-columns: 1fr; gap: 36px; padding-top: 8px; }
    .wordmark.xl span { display: inline; }
    .dropzone { min-height: 260px; }
}
@media (max-width: 860px) {
    body.app-mode { overflow: auto; }
    .app { height: auto; min-height: 100vh; }
    .topbar { position: sticky; top: 0; padding: 0 12px; gap: 8px; }
    .topbar-left { gap: 8px; }
    .topbar-actions { gap: 6px; }
    .topbar-actions .prefs { margin-right: 0; }
    .topbar .wordmark.sm { font-size: 1.05rem; }
    .layout { grid-template-columns: 1fr; }
    .main { overflow: visible; padding: 16px 14px 32px; }
    .sidebar {
        position: fixed; top: var(--topbar-h); left: 0; bottom: 0; z-index: 30;
        width: min(320px, 88vw);
        transform: translateX(-100%); transition: transform .25s;
        box-shadow: var(--shadow-pop);
    }
    .sidebar.open { transform: translateX(0); }
    .only-mobile { display: inline-grid; }
    .kpis { grid-template-columns: 1fr 1fr; }
    .kpis .kpi:last-child { grid-column: span 2; }
    .grid-3 { grid-template-columns: 1fr; }
    .grid-3 .card:last-child { grid-column: auto; }
    .btn .btn-label { display: none; }
    .btn { padding: 0 10px; }
    .kv-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 480px) {
    .home-btn .brand-mark { display: none; }
    .landing-top, .landing-foot, .hero { padding-left: 18px; padding-right: 18px; }
    .lead { font-size: 15.5px; }
    /* en el teléfono el selector muestra solo el otro idioma (toca "EN" para cambiar) */
    .topbar .lang-switch { grid-template-columns: 1fr; }
    .topbar .lang-switch button[aria-pressed="true"] { display: none; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ==========================================================================
   Pestañas, diagnóstico, conversaciones y latencias
   ========================================================================== */
.tabs {
    position: sticky; top: -22px; z-index: 5;
    display: flex; gap: 4px; padding: 4px;
    margin: 2px 0 -4px;
    background: var(--bg); border: 1px solid var(--border); border-radius: 12px;
    box-shadow: 0 8px 16px -12px rgba(0, 0, 0, 0.5);
    overflow-x: auto; scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tabs [role="tab"] {
    display: inline-flex; align-items: center; gap: 8px;
    height: 38px; padding: 0 14px; border-radius: 9px;
    font-size: 13px; font-weight: 600; color: var(--text-2); white-space: nowrap;
    transition: background .15s, color .15s;
}
.tabs [role="tab"] svg { width: 16px; height: 16px; }
.tabs [role="tab"]:hover { color: var(--text); background: var(--hover); }
.tabs [role="tab"][aria-selected="true"] { color: var(--cyan); background: var(--cyan-soft); box-shadow: inset 0 0 0 1px var(--cyan-border); }
.tab-count {
    min-width: 22px; height: 20px; padding: 0 6px; border-radius: 999px;
    display: inline-grid; place-items: center;
    font-size: 11px; font-weight: 700; font-variant-numeric: tabular-nums;
    background: var(--surface-3); color: var(--text-2);
}
.tabs [aria-selected="true"] .tab-count { background: var(--cyan); color: var(--bg); }
.tab-panel { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.main > .active-filters { margin: -6px 0 -6px; align-items: center; }
.af-clear { margin-left: 4px; }

/* Diagnóstico */
.diag-card .card-head { padding-bottom: 10px; border-bottom: 1px solid var(--border); }
.diag-head-right { display: flex; align-items: center; gap: 12px; }
.diag-count { font-size: 12px; color: var(--muted); }
.verdict {
    display: inline-flex; align-items: center; gap: 6px;
    height: 26px; padding: 0 11px; border-radius: 999px;
    font-size: 12px; font-weight: 700; border: 1px solid transparent;
}
.verdict svg { width: 14px; height: 14px; }
.verdict-critical { color: var(--critical-ink); background: var(--critical-soft); border-color: var(--critical-border); }
.verdict-warning { color: var(--warning-ink); background: var(--warning-soft); border-color: var(--warning-border); }
.verdict-ok { color: var(--ok); background: var(--ok-soft); border-color: var(--ok-soft); }
.findings { list-style: none; margin: 0; padding: 6px 8px 8px; display: flex; flex-direction: column; }
.finding {
    display: grid; grid-template-columns: 30px 1fr auto; gap: 12px; align-items: start;
    padding: 12px 10px; border-radius: 10px;
}
.finding + .finding { border-top: 1px solid var(--row-border); border-radius: 0; }
.finding .f-icon, .verdict-box .f-icon { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; }
.finding .f-icon svg, .verdict-box .f-icon svg { width: 16px; height: 16px; }
.finding.critical .f-icon, .verdict-box.critical .f-icon { color: var(--critical-ink); background: var(--critical-soft); }
.finding.warning .f-icon, .verdict-box.warning .f-icon { color: var(--warning-ink); background: var(--warning-soft); }
.finding.info .f-icon, .verdict-box.info .f-icon { color: var(--cyan); background: var(--cyan-soft); }
.verdict-box.ok .f-icon { color: var(--ok); background: var(--ok-soft); }
.f-body strong { display: block; font-size: 14px; color: var(--text-strong); margin-bottom: 3px; }
.f-body p { margin: 0; font-size: 13px; line-height: 1.5; color: var(--text-2); }
.f-body .f-rec { margin-top: 5px; color: var(--muted); font-size: 12.5px; }
.f-body .f-rec b { color: var(--text-2); font-weight: 600; }
.f-action { align-self: center; }
.f-action svg { width: 14px; height: 14px; }
.oks { padding: 0 18px 14px; }
.oks:empty { display: none; }
.oks h4 { margin: 4px 0 8px; font-size: 11px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.oks ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.oks li {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 7px 12px; border-radius: 999px; font-size: 12.5px; color: var(--text-2);
    background: var(--ok-soft); border: 1px solid var(--border);
}
.oks li svg { width: 14px; height: 14px; color: var(--ok); }
.oks li b { color: var(--text); font-weight: 600; }

/* Conversaciones */
.ctable th[data-sort] { cursor: pointer; user-select: none; }
.ctable th[data-sort]:hover { color: var(--text); }
.ctable th[aria-sort="ascending"]::after { content: " ↑"; color: var(--cyan); }
.ctable th[aria-sort="descending"]::after { content: " ↓"; color: var(--cyan); }
.ctable { min-width: 1180px; }
.ptable .kind { margin-left: 4px; font-size: 10px; font-weight: 700; color: var(--muted); letter-spacing: 0.04em; }
.ptable .c-port { color: var(--muted); }
.ptable .c-pct { color: var(--warning-ink); font-weight: 600; }
.ptable td.cell2 { line-height: 1.25; max-width: 260px; }
.ptable td.cell2 b { display: block; font-weight: 600; color: var(--cyan); overflow: hidden; text-overflow: ellipsis; }
.ptable td.cell2 span { display: block; font-size: 11.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.ptable td.cell2 span.strong { color: var(--text); font-size: 12px; }
.ptable td.strong { color: var(--text); font-weight: 500; }
.ctable td { height: 46px; }
.lat { font-family: var(--mono); font-weight: 600; }
.lat-good { color: var(--ok); }
.lat-slow { color: var(--warning-ink); }
.lat-very { color: var(--critical-ink); }

/* Latencias */
.lat-tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.lat-tile { padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; position: relative; }
.lat-big { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; color: var(--text-strong); line-height: 1.15; margin-top: 4px; }
.lat-big.lat-good { color: var(--ok); }
.lat-big.lat-slow { color: var(--warning-ink); }
.lat-big.lat-very { color: var(--critical-ink); }
.lat-flag { position: absolute; top: 12px; right: 14px; display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 600; }
.lat-flag i { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.verdict-card { padding: 4px; }
.verdict-box { display: flex; gap: 14px; align-items: flex-start; padding: 14px 16px; }
.verdict-box strong { display: block; font-size: 14.5px; color: var(--text-strong); margin-bottom: 3px; }
.verdict-box p { margin: 0; color: var(--text-2); font-size: 13.5px; line-height: 1.5; }
.verdict-box p.small { font-size: 12px; margin-top: 4px; color: var(--muted); }
.lat-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.lat-grid .table-scroll { margin-top: 4px; }
.ltable { min-width: 0 !important; }
.ltable td { height: 38px; }
.lat-cell { position: relative; min-width: 110px; }
.mbar { display: block; height: 3px; border-radius: 2px; margin-top: 3px; background: currentColor; opacity: 0.7; }
.mbar.lat-good { color: var(--ok); }
.mbar.lat-slow { color: var(--warning); }
.mbar.lat-very { color: var(--critical); }

/* Drawer extras */
.d-conv-btn { align-self: flex-start; }
.hex-block summary { color: var(--text-2); }
.json.hex { white-space: pre; word-break: normal; overflow-x: auto; color: var(--text-2); }

@media (max-width: 1280px) {
    .lat-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1100px) {
    .lat-grid { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
    .tabs { top: var(--topbar-h); border-radius: 0; margin: 0 -14px; border-left: 0; border-right: 0; }
    .finding { grid-template-columns: 30px 1fr; }
    .f-action { grid-column: 2; justify-self: start; }
    .diag-head-right { width: 100%; justify-content: space-between; }
}
@media (max-width: 480px) {
    .lat-tiles { grid-template-columns: 1fr 1fr; gap: 10px; }
    .lat-big { font-size: 22px; }
    .lat-flag { position: static; }
    .tabs [role="tab"] { padding: 0 10px; }
}
.main > *, .tab-panel > * { flex-shrink: 0; }
.kv.wide { grid-column: span 2; }
.verdict { white-space: nowrap; }
.ctable { min-width: 1040px; }
.ctable td, .ctable th { padding-left: 10px; padding-right: 10px; }
.ctable td { font-size: 12px; }
@media (max-width: 480px) {
    .tabs [role="tab"] svg { display: none; }
    .diag-card .card-head { gap: 8px; }
}
.ctable td, .ctable th { padding-left: 8px; padding-right: 8px; }
.ctable td.cell2 { max-width: 210px; }
.ctable td.c-ip { max-width: 190px; }
.ptable td.cell2.num b { color: var(--text-2); font-family: var(--mono); font-weight: 500; font-size: 12px; }
.ptable td.c-idcell b { color: var(--muted); font-family: var(--mono); font-weight: 600; font-size: 12px; }
.ptable td.c-idcell span { font-size: 10px; font-weight: 700; letter-spacing: 0.06em; }
.ptable td.c-client b { color: var(--text); font-weight: 500; font-size: 12px; }
.ptable td.cell2 b.plain { color: var(--text); font-weight: 500; font-size: 12px; }

/* ==========================================================================
   v5: seguridad, diagrama de flujo, IA, exportar y capturas grandes
   ========================================================================== */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.card-head h3 .h-icon { width: 15px; height: 15px; margin-right: 6px; vertical-align: -2px; color: var(--cyan); }

/* Botón de IA */
.btn-ai { background: linear-gradient(135deg, rgba(34, 211, 238, 0.14), rgba(61, 255, 138, 0.12)); border: 1px solid var(--cyan-border); color: var(--text); }
.btn-ai:hover { color: var(--text-strong); box-shadow: 0 0 0 3px var(--cyan-soft); }
.btn-ai svg { color: var(--cyan); }
.f-actions { display: flex; align-items: center; gap: 6px; align-self: center; }
.f-ai { width: 30px; height: 30px; border: 1px solid var(--border); color: var(--cyan); }
.f-ai svg { width: 15px; height: 15px; }

/* Seguridad: lo que se revisó */
.checks { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; padding: 2px 16px 16px; }
.check { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); min-width: 0; }
.check .ck-icon { flex: 0 0 22px; height: 22px; border-radius: 7px; display: grid; place-items: center; }
.check .ck-icon svg { width: 13px; height: 13px; }
.check.ok .ck-icon { color: var(--ok); background: var(--ok-soft); }
.check.bad .ck-icon { color: var(--warning-ink); background: var(--warning-soft); }
.check.na .ck-icon { color: var(--muted); background: var(--hover); }
.check b { display: block; font-size: 12.5px; color: var(--text); font-weight: 600; }
.check span { display: block; font-size: 11.5px; color: var(--muted); line-height: 1.4; margin-top: 1px; }
.checks-head { grid-column: 1 / -1; margin: 6px 0 0; font-size: 11px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.sec-empty { padding: 14px 18px 4px; display: flex; gap: 12px; align-items: center; color: var(--text-2); font-size: 13.5px; }
.sec-empty .f-icon { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; color: var(--ok); background: var(--ok-soft); }
.sec-empty .f-icon svg { width: 16px; height: 16px; }

/* Conversaciones: versión TLS y botón de diagrama */
.tls-ver { font-family: var(--mono); font-size: 10.5px; font-weight: 700; }
.tls-ver.old { color: var(--warning-ink); }
.c-flowcol { width: 44px; }
.flow-btn { width: 30px; height: 30px; border: 1px solid var(--border); color: var(--text-2); }
.flow-btn:hover { color: var(--cyan); border-color: var(--cyan-border); }
.flow-btn svg { width: 15px; height: 15px; }
.d-conv-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.d-conv-actions:has(> .hidden + .hidden) { display: none; }

/* Menú de exportar */
.menu-wrap { position: relative; }
.btn .chev-down { width: 14px; height: 14px; margin-left: -2px; opacity: 0.8; }
.menu {
    position: absolute; right: 0; top: calc(100% + 8px); z-index: 35; min-width: 270px; padding: 6px;
    background: var(--surface); border: 1px solid var(--border-strong); border-radius: 12px; box-shadow: var(--shadow-pop);
}
.menu button { display: flex; gap: 12px; align-items: flex-start; width: 100%; padding: 9px 10px; border-radius: 8px; text-align: left; color: var(--text); }
.menu button:hover, .menu button:focus-visible { background: var(--hover); outline: none; }
.menu button > svg { width: 17px; height: 17px; margin-top: 1px; color: var(--cyan); }
.menu b { display: block; font-size: 13px; font-weight: 600; }
.menu small { display: block; font-size: 11.5px; color: var(--muted); margin-top: 1px; }

/* Aviso (captura parcial) */
.notice {
    display: flex; gap: 10px; align-items: flex-start; padding: 11px 14px; border-radius: 12px;
    background: var(--warning-soft); border: 1px solid var(--warning-border); color: var(--text); font-size: 13px; line-height: 1.45;
}
.notice svg { width: 16px; height: 16px; color: var(--warning-ink); margin-top: 1px; flex: 0 0 16px; }
.notice .link-btn { font-size: 12.5px; padding: 0; }

/* Ventanas */
.modal-backdrop { position: fixed; inset: 0; z-index: 44; background: var(--backdrop); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
.modal {
    position: fixed; z-index: 45; left: 50%; top: 50%; transform: translate(-50%, -50%);
    width: min(640px, calc(100vw - 24px)); max-height: calc(100vh - 40px);
    display: flex; flex-direction: column;
    background: var(--bg-2); border: 1px solid var(--border-strong); border-radius: 16px; box-shadow: var(--shadow-pop);
}
.modal.modal-wide { width: min(1100px, calc(100vw - 24px)); height: calc(100vh - 40px); }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 16px 18px 14px; border-bottom: 1px solid var(--border); }
.modal-head .drawer-title { font-size: 16px; }
.kicker-icon { width: 12px; height: 12px; margin-right: 6px; vertical-align: -1px; }
.modal-body { padding: 16px 18px; overflow-y: auto; min-height: 0; flex: 1; font-size: 13.5px; color: var(--text-2); line-height: 1.55; }
.modal-body p { margin: 0 0 10px; }
.modal-foot { display: flex; align-items: center; justify-content: flex-end; gap: 10px; padding: 12px 18px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.modal-foot .c-dim { margin-right: auto; font-size: 12px; color: var(--muted); }
.small { font-size: 12px; }
code { font-family: var(--mono); font-size: 0.92em; padding: 1px 5px; border-radius: 5px; background: var(--surface-3); color: var(--text); }

/* Tamaño de la captura */
.size-facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 4px 0 14px; }
.size-facts div { padding: 10px 12px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); }
.size-facts span { display: block; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; font-weight: 600; }
.size-facts b { display: block; font-size: 17px; color: var(--text-strong); margin-top: 2px; }
.cut-tips { margin-top: 6px; padding: 12px 14px; border-radius: 12px; border: 1px dashed var(--dash); }
.cut-tips h4 { display: flex; align-items: center; gap: 8px; margin: 0 0 8px; font-size: 12.5px; color: var(--text); }
.cut-tips h4 svg { width: 15px; height: 15px; color: var(--cyan); }
.cut-tips ul { list-style: none; margin: 0 0 8px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.cut-tips li span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 3px; }
.cut-tips li code { display: block; padding: 7px 10px; white-space: pre-wrap; word-break: break-all; user-select: all; }
.dz-limit { margin-top: 8px; font-size: 11.5px; color: var(--muted); }
.dz-tips { margin-top: 6px; }

/* IA */
.ai-out { color: var(--text); font-size: 14px; line-height: 1.6; min-height: 120px; }
.ai-out h4 { margin: 16px 0 6px; font-size: 13px; color: var(--cyan); letter-spacing: 0.02em; }
.ai-out h4:first-child { margin-top: 0; }
.ai-out p { margin: 0 0 10px; color: var(--text-2); }
.ai-out ul, .ai-out ol { margin: 0 0 10px; padding-left: 20px; color: var(--text-2); }
.ai-out li { margin: 3px 0; }
.ai-out strong { color: var(--text-strong); }
.ai-out pre { margin: 0 0 10px; padding: 10px 12px; border-radius: 9px; background: var(--json-bg); border: 1px solid var(--border); overflow-x: auto; font-size: 12px; }
.ai-out .ai-caret { display: inline-block; width: 8px; height: 15px; margin-left: 2px; vertical-align: -2px; background: var(--cyan); animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.ai-wait { display: flex; align-items: center; gap: 10px; color: var(--muted); }
.ai-wait .spinner { width: 18px; height: 18px; border-width: 2px; margin: 0; }
.ai-err { display: flex; gap: 10px; padding: 12px 14px; border-radius: 10px; background: var(--warning-soft); border: 1px solid var(--warning-border); color: var(--text); }
.ai-err svg { width: 16px; height: 16px; color: var(--warning-ink); flex: 0 0 16px; margin-top: 2px; }
.ai-foot { justify-content: space-between; }
.ai-note { display: flex; gap: 8px; align-items: flex-start; margin: 0; font-size: 11.5px; color: var(--muted); max-width: 420px; line-height: 1.4; }
.ai-note svg { width: 13px; height: 13px; flex: 0 0 13px; margin-top: 1px; }
.ai-actions { display: flex; gap: 8px; }

/* Diagrama de flujo (escalera) */
.flow-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.flow-meta span { font-size: 11.5px; padding: 3px 9px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2); }
.flow-meta span b { color: var(--text); font-weight: 600; }
.flow-head, .flow-row { display: grid; grid-template-columns: 96px minmax(0, 1fr) 150px; align-items: center; }
.flow-head { padding: 10px 18px 8px; border-bottom: 1px solid var(--border); font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.flow-ends { display: flex; justify-content: space-between; padding: 0 4px; gap: 12px; }
.flow-ends > div { max-width: 46%; text-transform: none; letter-spacing: 0; }
.flow-ends b { display: block; font-size: 12.5px; color: var(--text); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.flow-ends small { display: block; font-family: var(--mono); font-size: 11px; color: var(--muted); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.flow-ends > div:last-child { text-align: right; }
.flow-body { padding: 0 18px 8px; }
.flow-row { min-height: 44px; cursor: pointer; border-radius: 8px; }
.flow-row:hover { background: var(--hover); }
.flow-row:focus-visible { outline: 2px solid var(--cyan-border); outline-offset: -2px; }
.fl-time { font-family: var(--mono); font-size: 11.5px; color: var(--text-2); padding-left: 4px; }
.fl-time small { display: block; color: var(--muted); font-size: 10.5px; }
.fl-lane { position: relative; height: 44px; margin: 0 4px;
    background: linear-gradient(var(--dash), var(--dash)) left 6px top / 1px 100% no-repeat, linear-gradient(var(--dash), var(--dash)) right 6px top / 1px 100% no-repeat; }
.fl-arrow { position: absolute; left: 7px; right: 7px; top: 24px; height: 2px; background: var(--muted); }
.fl-arrow::after { content: ""; position: absolute; top: -5px; border: 6px solid transparent; }
.fl-arrow.right::after { right: -2px; border-left: 9px solid var(--muted); border-right: 0; }
.fl-arrow.left::after { left: -2px; border-right: 9px solid var(--muted); border-left: 0; }
.fl-label { position: absolute; left: 24px; right: 24px; top: 3px; text-align: center; font-size: 12.5px; color: var(--text); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fl-sub { position: absolute; left: 24px; right: 24px; top: 28px; text-align: center; font-family: var(--mono); font-size: 10.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.flow-row.k-syn .fl-arrow { background: var(--cyan); }
.flow-row.k-syn .fl-arrow.right::after { border-left-color: var(--cyan); }
.flow-row.k-syn .fl-arrow.left::after { border-right-color: var(--cyan); }
.flow-row.k-app .fl-arrow { background: var(--text-2); }
.flow-row.k-app .fl-arrow.right::after { border-left-color: var(--text-2); }
.flow-row.k-app .fl-arrow.left::after { border-right-color: var(--text-2); }
.flow-row.lvl-warning .fl-arrow { background: var(--warning); }
.flow-row.lvl-warning .fl-arrow.right::after { border-left-color: var(--warning); }
.flow-row.lvl-warning .fl-arrow.left::after { border-right-color: var(--warning); }
.flow-row.lvl-critical .fl-arrow { background: var(--critical); }
.flow-row.lvl-critical .fl-arrow.right::after { border-left-color: var(--critical); }
.flow-row.lvl-critical .fl-arrow.left::after { border-right-color: var(--critical); }
.flow-row.lvl-critical .fl-label { color: var(--critical-ink); }
.flow-row.lvl-warning .fl-label { color: var(--warning-ink); }
.fl-note { padding-left: 10px; min-width: 0; }
.fl-note .badge { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.flow-gap { display: grid; grid-template-columns: 96px minmax(0, 1fr) 150px; align-items: center; height: 26px; }
.flow-gap span { grid-column: 2; text-align: center; font-size: 11.5px; color: var(--muted); font-family: var(--mono); }
.flow-gap span::before, .flow-gap span::after { content: "· · ·"; margin: 0 8px; color: var(--dash); }
.flow-gap.long span { color: var(--warning-ink); font-weight: 600; }
.flow-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 11.5px; color: var(--muted); margin-right: auto; }
.flow-legend i { display: inline-block; width: 14px; height: 2px; vertical-align: middle; margin-right: 6px; background: var(--muted); }
.flow-legend i.syn { background: var(--cyan); }
.flow-legend i.warning { background: var(--warning); }
.flow-legend i.critical { background: var(--critical); }

@media (max-width: 1100px) {
    .checks { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 860px) {
    .flow-head, .flow-row, .flow-gap { grid-template-columns: 62px minmax(0, 1fr); }
    .fl-note { grid-column: 2; padding: 0 28px 6px; }
    .fl-note:empty { display: none; }
    .flow-head > div:last-child { display: none; }
    .modal.modal-wide { height: calc(100vh - 24px); }
    .size-facts { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 560px) {
    .checks { grid-template-columns: 1fr; }
    .modal { width: calc(100vw - 16px); max-height: calc(100vh - 16px); }
    .flow-body { padding: 0 8px 8px; }
    .flow-head { padding: 8px; }
    .ai-foot { flex-direction: column; align-items: stretch; }
    .menu { right: -60px; }
}
.drawer-backdrop.over-modal { z-index: 46; }
.sec-empty { grid-column: 1 / -1; padding: 6px 2px 4px; }
.drawer-title.sans { font-family: var(--font); font-weight: 600; letter-spacing: -0.01em; word-break: normal; }
.flow-legend { display: inline-flex; margin-right: 16px; vertical-align: middle; }
.ai-note { max-width: 370px; }
.ctable td, .ctable th { padding-left: 7px; padding-right: 7px; }
/* lo absoluto dentro de una tabla no debe ensanchar la página */
.table-scroll { position: relative; }
.ctable td:last-child, .ctable th:last-child { padding-left: 0; padding-right: 8px; width: 36px; }
.flow-btn { width: 28px; height: 28px; }
.diag-head-right { flex-wrap: wrap; justify-content: flex-end; }
@media (max-width: 560px) {
    .diag-head-right { justify-content: flex-start; }
    .diag-head-right .btn-ai { margin-left: auto; }
}
#flow-title { word-break: normal; overflow-wrap: anywhere; }
.flow-legend { flex-wrap: wrap; row-gap: 4px; }

/* ==========================================================================
   v6: donaciones, inicio, KPIs que filtran
   ========================================================================== */
.landing-top { justify-content: flex-end; gap: 10px; }
.btn-donate svg { color: #f472b6; }
[data-theme="light"] .btn-donate svg { color: #db2777; }
.foot-donate { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; }
.foot-donate svg { width: 13px; height: 13px; color: #f472b6; }
[data-theme="light"] .foot-donate svg { color: #db2777; }
.home-btn { display: inline-flex; align-items: center; padding: 2px 6px 2px 2px; border-radius: 8px; transition: opacity .15s, background .15s; }
.home-btn .brand-mark { width: 24px; height: 24px; flex: none; margin-right: 8px; border-radius: 6px; }
.home-btn:hover { background: var(--hover); }
.donate-amounts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin: 6px 0 14px; }
.donate-amt {
    display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 14px 8px; border-radius: 12px; text-decoration: none;
    background: var(--surface-2); border: 1px solid var(--border-strong); color: var(--text); transition: border-color .15s, transform .15s, background .15s;
}
.donate-amt:hover { border-color: var(--cyan-border); background: var(--cyan-soft); transform: translateY(-1px); }
.donate-amt b { font-size: 20px; font-weight: 700; color: var(--text-strong); }
.donate-amt[data-amt="otro"] b { font-size: 14px; line-height: 28px; }
.donate-amt span { font-size: 11.5px; color: var(--muted); }
.donate-thanks { display: flex; align-items: center; gap: 8px; color: var(--ok); font-weight: 600; font-size: 13px; }
.donate-thanks svg { width: 15px; height: 15px; }
.ai-extra { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; font-size: 12.5px; color: var(--muted); }
.ai-cta { margin-top: 12px; }
/* tarjetas KPI: son botones que filtran */
button.kpi { text-align: left; width: 100%; color: inherit; cursor: pointer; transition: border-color .15s, transform .15s, background .15s; }
button.kpi:hover { border-color: var(--cyan-border); transform: translateY(-1px); }
button.kpi.is-active { border-color: var(--cyan-border); box-shadow: 0 0 0 1px var(--cyan-border) inset; }
.kpi-top { width: 100%; }
.segmented { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 860px) {
    .topbar .btn-donate { display: none; }
    .donate-amounts { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 480px) {
    .landing-top .btn-donate span { display: none; }
}
.ai-cta-text { margin: 8px 0 0; color: var(--text-2); }
