:root {
    --bg: #f4f7fb;
    --panel: rgba(255,255,255,0.88);
    --panel-solid: #ffffff;
    --line: #e6edf7;
    --line-strong: #d6e1f0;
    --text: #12233d;
    --muted: #64748b;
    --blue: #2164f3;
    --blue-2: #4f8cff;
    --green: #16a34a;
    --green-soft: #eaf9ef;
    --red-soft: #fff1f2;
    --red: #e11d48;
    --shadow-sm: 0 8px 24px rgba(16, 24, 40, .05);
    --shadow-md: 0 18px 50px rgba(16, 24, 40, .08);
    --shadow-lg: 0 28px 70px rgba(16, 24, 40, .10);
    --radius: 20px;
    --radius-sm: 14px;
    --radius-xs: 12px;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
    background:
        radial-gradient(circle at top left, rgba(79,140,255,.08), transparent 320px),
        radial-gradient(circle at top right, rgba(33,100,243,.06), transparent 280px),
        var(--bg);
    color: var(--text);
}

a {
    text-decoration: none;
    color: inherit;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 900;
    font-size: 20px;
    letter-spacing: -.02em;
}

.logo {
    color: var(--blue);
    font-size: 22px;
}

.btn {
    appearance: none;
    border: 1px solid var(--line);
    background: #fff;
    color: var(--text);
    border-radius: 14px;
    padding: 12px 18px;
    font-weight: 800;
    cursor: pointer;
    transition: .18s ease;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    box-shadow: var(--shadow-sm);
}

.btn:hover {
    transform: translateY(-1px);
}

.btn.primary {
    background: linear-gradient(135deg, var(--blue), #0f56ea);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 14px 28px rgba(33,100,243,.28);
}

.btn.primary:hover {
    filter: brightness(1.03);
}

.btn.ghost {
    background: rgba(255,255,255,.9);
}

.btn.full {
    width: 100%;
}

.app {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 260px 1fr;
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 24px 18px;
    background: rgba(255,255,255,.72);
    backdrop-filter: blur(16px);
    border-right: 1px solid rgba(230,237,247,.95);
    overflow: auto;
}

.sidebar .brand {
    margin-bottom: 24px;
    padding: 10px 12px 18px;
    border-bottom: 1px solid var(--line);
}

.sidebar > a:not(.brand) {
    display: block;
    padding: 14px 14px;
    margin: 4px 0;
    border-radius: 14px;
    font-weight: 800;
    color: #21314d;
    transition: .16s ease;
}

.sidebar > a:hover {
    background: #edf4ff;
    color: var(--blue);
}

.sidebar > a.active {
    background: linear-gradient(135deg, #eaf2ff, #f3f7ff);
    color: var(--blue);
    box-shadow: inset 0 0 0 1px #d9e7ff;
}

.upgrade {
    margin-top: 18px;
    padding: 18px;
    border-radius: 20px;
    background: linear-gradient(180deg, rgba(255,255,255,.95), rgba(245,249,255,.95));
    border: 1px solid var(--line);
    box-shadow: var(--shadow-md);
}

.upgrade strong {
    display: block;
    font-size: 24px;
    letter-spacing: -.03em;
    margin-bottom: 8px;
}

.upgrade p {
    margin: 0 0 14px;
    color: var(--muted);
    line-height: 1.55;
    font-weight: 600;
}

.plan-ok {
    display: block;
    text-align: center;
    background: var(--green-soft);
    color: #0f7a37;
    border: 1px solid #bde9c8;
    border-radius: 14px;
    padding: 12px 14px;
    font-weight: 900;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,.4);
}

.dash {
    padding: 28px;
}

.dash-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 22px;
}

.dash-top h1 {
    margin: 0 0 8px;
    font-size: 48px;
    line-height: 1;
    letter-spacing: -.04em;
    font-weight: 900;
}

.dash-top p {
    margin: 0;
    color: var(--muted);
    font-size: 17px;
}

.panel-card,
.chart-card,
.page-row-card,
.script-box,
.empty {
    background: rgba(255,255,255,.88);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(230,237,247,.95);
    border-radius: 26px;
    box-shadow: var(--shadow-md);
}

.panel-card,
.chart-card,
.script-box {
    padding: 24px;
    margin-bottom: 20px;
}

.panel-card h2,
.chart-card h2 {
    margin: 0 0 12px;
    font-size: 22px;
    letter-spacing: -.02em;
}

.panel-card h3,
.chart-card h3 {
    margin: 0 0 10px;
    font-size: 19px;
    letter-spacing: -.02em;
}

.panel-card p,
.chart-card p {
    color: var(--muted);
    line-height: 1.6;
}

.tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 14px;
}

.tab {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 18px;
    border-radius: 999px;
    background: #fff;
    border: 1px solid var(--line-strong);
    font-weight: 900;
    color: #22314f;
    box-shadow: var(--shadow-sm);
    transition: .16s ease;
}

.tab:hover {
    transform: translateY(-1px);
    border-color: #bfd4ff;
}

.tab.on {
    background: linear-gradient(135deg, var(--blue), var(--blue-2));
    color: #fff;
    border-color: transparent;
    box-shadow: 0 12px 24px rgba(33,100,243,.24);
}

.period-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 18px;
}

.period-filters a {
    padding: 11px 15px;
    border-radius: 999px;
    border: 1px solid var(--line-strong);
    background: #fff;
    color: #22314f;
    font-weight: 900;
    box-shadow: var(--shadow-sm);
    transition: .16s ease;
}

.period-filters a:hover {
    transform: translateY(-1px);
}

.period-filters a.on {
    background: linear-gradient(135deg, var(--blue), var(--blue-2));
    color: #fff;
    border-color: transparent;
}

.kpi-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 20px;
}

.kpi {
    background: linear-gradient(180deg, rgba(255,255,255,.98), rgba(247,250,255,.98));
    border: 1px solid var(--line);
    border-radius: 22px;
    padding: 20px 18px;
    box-shadow: var(--shadow-md);
}

.kpi span {
    display: block;
    font-size: 14px;
    color: var(--muted);
    font-weight: 800;
    margin-bottom: 8px;
}

.kpi strong {
    display: block;
    font-size: 44px;
    line-height: 1;
    letter-spacing: -.04em;
    margin-bottom: 10px;
    font-weight: 900;
}

.kpi em {
    display: block;
    font-style: normal;
    color: var(--green);
    font-weight: 900;
    font-size: 15px;
}

.bars {
    height: 260px;
    display: flex;
    align-items: flex-end;
    gap: 10px;
    border-bottom: 1px solid var(--line);
    margin-top: 16px;
    padding: 16px 0 0;
}

.bars span {
    flex: 1;
    min-width: 8px;
    border-radius: 14px 14px 4px 4px;
    background: linear-gradient(180deg, var(--blue-2), var(--blue));
    box-shadow: 0 10px 18px rgba(33,100,243,.18);
}

.grid3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 18px;
    margin-bottom: 20px;
}

.grid2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 18px;
}

.panel-card p strong,
.chart-card p strong {
    color: var(--text);
}

.panel-card > p,
.chart-card > p {
    margin-top: 0;
}

.panel-card p,
.page-row-main p {
    margin: 0;
}

.panel-card .help-text {
    display: block !important;
    color: var(--muted);
    border-bottom: 0 !important;
    padding: 0 0 10px !important;
    font-size: 14px;
    margin-top: -2px;
}

.panel-card p:not(.help-text) {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    padding: 12px 0;
    border-bottom: 1px dashed #e5edf8;
}

.panel-card p:not(.help-text):last-child {
    border-bottom: 0;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: transparent;
    overflow: hidden;
}

th,
td {
    text-align: left;
    padding: 14px 14px;
    border-bottom: 1px solid var(--line);
    vertical-align: top;
}

th {
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--muted);
    font-weight: 900;
    background: #f8fbff;
}

td {
    color: #26354f;
    font-weight: 600;
}

tr:hover td {
    background: rgba(247,250,255,.65);
}

.inline-form {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 12px;
    margin: 16px 0 14px;
}

input,
textarea,
select {
    width: 100%;
    border: 1px solid var(--line-strong);
    border-radius: 16px;
    padding: 14px 16px;
    font: inherit;
    color: var(--text);
    background: #fff;
    outline: none;
    transition: .15s ease;
}

input:focus,
textarea:focus,
select:focus {
    border-color: #8ab0ff;
    box-shadow: 0 0 0 4px rgba(33,100,243,.10);
}

.plan-note {
    background: linear-gradient(180deg, #f7fbff, #fdfefe);
    border: 1px solid var(--line);
    border-radius: 16px;
    color: var(--muted);
    padding: 14px 16px;
    font-weight: 700;
}

.page-row-card {
    padding: 20px;
    margin-bottom: 16px;
}

.page-row-main {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 18px;
}

.page-row-main h3 {
    margin: 0 0 8px;
    font-size: 24px;
    letter-spacing: -.02em;
}

.page-row-main p {
    color: var(--muted);
    line-height: 1.55;
}

.page-row-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.js-toggle-code {
    min-width: 48px;
    min-height: 48px;
    padding: 0;
    font-size: 24px;
    border-radius: 16px;
}

.tracking-code-box {
    display: none;
    margin-top: 18px;
    padding-top: 18px;
    border-top: 1px dashed var(--line-strong);
}

.tracking-code-box.open {
    display: block;
}

.code-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
}

.code-grid h4 {
    margin: 0 0 10px;
    font-size: 18px;
    letter-spacing: -.02em;
}

.code-grid h4 span {
    display: inline-block;
    margin-left: 8px;
    padding: 4px 9px;
    border-radius: 999px;
    background: var(--green-soft);
    border: 1px solid #bde9c8;
    color: #0f7a37;
    font-size: 12px;
    font-weight: 900;
    vertical-align: middle;
}

.code-grid p {
    color: var(--muted);
    margin: 0 0 10px;
}

code {
    display: block;
    background: linear-gradient(180deg, #132240, #0f1d37);
    color: #dce8ff;
    border-radius: 18px;
    padding: 16px;
    overflow: auto;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 13px;
    line-height: 1.55;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,.04);
}

.alert,
.success {
    padding: 16px 18px;
    border-radius: 18px;
    font-weight: 800;
    margin-bottom: 18px;
    box-shadow: var(--shadow-sm);
}

.alert {
    background: var(--red-soft);
    border: 1px solid #fecdd3;
    color: #be123c;
}

.success {
    background: #ecfdf5;
    border: 1px solid #bbf7d0;
    color: #166534;
}

.empty {
    padding: 48px 26px;
    text-align: center;
}

.empty h2 {
    margin: 0 0 8px;
    font-size: 28px;
}

.empty p {
    margin: 0 0 16px;
    color: var(--muted);
}

.topbar,
.hero,
.feature-grid,
.split,
.seo-section,
.cta,
.footer,
.auth,
.auth-card,
.demo-card,
.kpi-grid,
.mini-grid,
.score {
    /* no-op para no romper otras páginas si existen clases antiguas */
}

@media (max-width: 1200px) {
    .kpi-row,
    .grid3 {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 900px) {
    .app {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: relative;
        height: auto;
        border-right: 0;
        border-bottom: 1px solid var(--line);
    }

    .dash {
        padding: 20px;
    }

    .dash-top {
        flex-direction: column;
        align-items: stretch;
    }

    .dash-top h1 {
        font-size: 38px;
    }

    .kpi-row,
    .grid3,
    .grid2,
    .code-grid {
        grid-template-columns: 1fr;
    }

    .inline-form {
        grid-template-columns: 1fr;
    }

    .page-row-main,
    .page-row-actions {
        flex-direction: column;
        align-items: stretch;
    }
}

@media (max-width: 560px) {
    .dash {
        padding: 16px;
    }

    .dash-top h1 {
        font-size: 32px;
    }

    .panel-card,
    .chart-card,
    .page-row-card,
    .script-box,
    .empty {
        border-radius: 22px;
    }

    .kpi strong {
        font-size: 36px;
    }

    .sidebar {
        padding: 18px 14px;
    }
}

/* =========================================================
   MiTráficoWeb - Dark Premium Dashboard Layer
   Solo afecta el panel interno .app
========================================================= */

body:has(.app) {
    background:
        radial-gradient(circle at 18% 0%, rgba(59,130,246,.20), transparent 360px),
        radial-gradient(circle at 85% 12%, rgba(20,184,166,.12), transparent 320px),
        linear-gradient(135deg, #08111f 0%, #101827 42%, #f4f7fb 42%, #eef3fa 100%);
}

.app {
    background:
        linear-gradient(90deg, #08111f 0, #0d1627 260px, transparent 260px),
        radial-gradient(circle at 65% 0%, rgba(33,100,243,.10), transparent 420px),
        #eef3fa;
}

/* Sidebar oscuro premium */
.sidebar {
    background:
        linear-gradient(180deg, rgba(8,17,31,.98), rgba(12,22,39,.98));
    border-right: 1px solid rgba(148,163,184,.16);
    box-shadow: 18px 0 50px rgba(2,6,23,.18);
}

.sidebar .brand {
    color: #ffffff;
    border-bottom: 1px solid rgba(148,163,184,.18);
}

.sidebar .logo {
    color: #60a5fa;
}

.sidebar > a:not(.brand) {
    color: #cbd5e1;
}

.sidebar > a:hover {
    background: rgba(96,165,250,.12);
    color: #ffffff;
}

.sidebar > a.active {
    background:
        linear-gradient(135deg, rgba(37,99,235,.95), rgba(14,165,233,.82));
    color: #ffffff;
    box-shadow:
        0 12px 30px rgba(37,99,235,.28),
        inset 0 0 0 1px rgba(255,255,255,.12);
}

/* Caja del plan en modo premium */
.upgrade {
    background:
        linear-gradient(180deg, rgba(15,23,42,.98), rgba(15,23,42,.86));
    border: 1px solid rgba(148,163,184,.22);
    box-shadow:
        0 22px 60px rgba(2,6,23,.28),
        inset 0 1px 0 rgba(255,255,255,.06);
}

.upgrade strong {
    color: #ffffff;
}

.upgrade p {
    color: #94a3b8;
}

.plan-ok {
    background: linear-gradient(135deg, rgba(34,197,94,.16), rgba(16,185,129,.10));
    color: #86efac;
    border-color: rgba(134,239,172,.28);
}

/* Área principal más elegante */
.dash {
    padding: 34px;
}

.dash-top {
    background:
        linear-gradient(135deg, rgba(15,23,42,.96), rgba(30,41,59,.92));
    border: 1px solid rgba(148,163,184,.20);
    border-radius: 28px;
    padding: 28px;
    box-shadow:
        0 28px 70px rgba(15,23,42,.18),
        inset 0 1px 0 rgba(255,255,255,.07);
}

.dash-top h1 {
    color: #ffffff;
    font-size: 46px;
}

.dash-top p {
    color: #cbd5e1;
}

.dash-top .btn.ghost {
    background: rgba(255,255,255,.08);
    color: #ffffff;
    border-color: rgba(255,255,255,.16);
    box-shadow: none;
}

.dash-top .btn.ghost:hover {
    background: rgba(255,255,255,.14);
}

/* Cards con blanco premium, no plano */
.panel-card,
.chart-card,
.page-row-card,
.script-box,
.empty {
    background:
        linear-gradient(180deg, rgba(255,255,255,.96), rgba(248,251,255,.94));
    border: 1px solid rgba(203,213,225,.82);
    box-shadow:
        0 22px 60px rgba(15,23,42,.08),
        inset 0 1px 0 rgba(255,255,255,.95);
}

/* Primera card del resumen con look más hero */
.panel-card:first-of-type {
    background:
        linear-gradient(135deg, rgba(255,255,255,.97), rgba(239,246,255,.96));
}

/* Tabs de webs */
.tab {
    background: #ffffff;
    border-color: #d8e3f3;
    color: #17233c;
}

.tab.on {
    background:
        linear-gradient(135deg, #1d4ed8, #0284c7);
    color: #ffffff;
    box-shadow:
        0 14px 28px rgba(29,78,216,.26),
        inset 0 1px 0 rgba(255,255,255,.18);
}

/* Filtros de periodo más premium */
.period-filters {
    padding-top: 8px;
}

.period-filters a {
    background: #ffffff;
    border-color: #d6e2f2;
    color: #1e293b;
}

.period-filters a.on {
    background:
        linear-gradient(135deg, #0f172a, #1d4ed8);
    color: #ffffff;
    box-shadow:
        0 14px 28px rgba(15,23,42,.22),
        inset 0 1px 0 rgba(255,255,255,.15);
}

/* KPI cards más PRO */
.kpi {
    position: relative;
    overflow: hidden;
    background:
        linear-gradient(180deg, #ffffff, #f8fbff);
    border: 1px solid rgba(203,213,225,.78);
}

.kpi::before {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 4px;
    background: linear-gradient(90deg, #1d4ed8, #38bdf8, #22c55e);
}

.kpi span {
    color: #64748b;
}

.kpi strong {
    color: #07132a;
}

.kpi em {
    color: #059669;
}

/* Chart card */
.chart-card {
    background:
        linear-gradient(180deg, #ffffff, #f8fbff);
}

.bars {
    background:
        linear-gradient(180deg, rgba(239,246,255,.65), rgba(255,255,255,.1));
    border-radius: 20px;
    padding: 18px 16px 0;
    border: 1px solid #e6edf7;
}

.bars span {
    background:
        linear-gradient(180deg, #38bdf8, #1d4ed8);
    box-shadow:
        0 12px 24px rgba(29,78,216,.18),
        inset 0 1px 0 rgba(255,255,255,.32);
}

/* Tablas y listas */
.panel-card p:not(.help-text) {
    border-bottom-color: #e2eaf5;
}

.panel-card p:not(.help-text) span {
    font-weight: 900;
    color: #0f172a;
    background: #eef4ff;
    border: 1px solid #dbeafe;
    border-radius: 999px;
    padding: 4px 10px;
    min-width: 42px;
    text-align: center;
}

th {
    background:
        linear-gradient(180deg, #f8fbff, #eef4ff);
    color: #475569;
}

td {
    color: #17233c;
}

/* Botones */
.btn.primary {
    background:
        linear-gradient(135deg, #1d4ed8, #0284c7);
    box-shadow: 0 16px 34px rgba(29,78,216,.28);
}

.btn.ghost {
    background: #ffffff;
    border-color: #d8e3f3;
}

/* Código */
code {
    background:
        linear-gradient(180deg, #07111f, #0f172a);
    border: 1px solid rgba(148,163,184,.18);
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,.05),
        0 16px 34px rgba(15,23,42,.16);
}

/* Páginas registradas */
.page-row-card {
    background:
        linear-gradient(135deg, #ffffff, #f8fbff);
}

.page-row-main h3 {
    color: #07132a;
}

/* Alertas */
.success {
    background:
        linear-gradient(135deg, #ecfdf5, #f7fffb);
    border-color: #bbf7d0;
}

.alert {
    background:
        linear-gradient(135deg, #fff1f2, #fff7f8);
    border-color: #fecdd3;
}

/* Responsive */
@media (max-width: 900px) {
    body:has(.app) {
        background: #eef3fa;
    }

    .app {
        background: #eef3fa;
    }

    .sidebar {
        background:
            linear-gradient(180deg, #08111f, #0d1627);
    }

    .dash {
        padding: 20px;
    }

    .dash-top {
        border-radius: 24px;
    }

    .dash-top h1 {
        font-size: 36px;
    }
}

@media (max-width: 560px) {
    .dash {
        padding: 14px;
    }

    .dash-top {
        padding: 22px;
    }
}
